index.wxml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <!--pages/exampleDetail/index.wxml-->
  2. <block wx:if="{{ type === 'getOpenId' }}">
  3. <view class="page-container">
  4. <view class="title">功能介绍</view>
  5. <view class="info">云函数无需维护鉴权机制及登录票据,仅一行代码即可获得。</view>
  6. <view class="title">云函数获取OpenId示例</view>
  7. <!-- <view class="info">云函数无需维护鉴权机制及登录票据,仅一行代码即可获得。</view> -->
  8. <view class="block">
  9. <view class="step-title"><text class="step-left">step</text> <text class="step-right">1 </text>quickStartFunctions 云函数代码</view>
  10. <view class="code_zone">
  11. <rich-text nodes="<pre style='overflow: scroll;'>{{callOpenIdCode}}</pre>" />
  12. </view>
  13. <view class="step-title"><text class="step-left">step</text> <text class="step-right">2 </text>小程序代码段</view>
  14. <view class="code_zone">
  15. <rich-text nodes="<pre style='overflow: scroll;'>{{callFunctionCode}}</pre>" />
  16. </view>
  17. </view>
  18. <view class="block">
  19. <view class="btn-full" bind:tap="getOpenId" wx:if="{{!haveGetOpenId}}">运行示例</view>
  20. <view class="box_text">{{ openId ? openId : 'OpenID将展示在这里' }}</view>
  21. <cloud-tip-modal showTipProps="{{showTip}}" title="{{title}}" content="{{content}}"></cloud-tip-modal>
  22. <view class="button_clear" bindtap="clearOpenId" wx:if="{{haveGetOpenId}}">清空</view>
  23. </view>
  24. </view>
  25. </block>
  26. <block wx:if="{{ type === 'getMiniProgramCode' }}">
  27. <view class="page-container">
  28. <view class="title">功能介绍</view>
  29. <view class="info">可通过云函数免接口调用凭证,直接生成小程序码。</view>
  30. <view class="title">云函数获取小程序码示例</view>
  31. <view class="block">
  32. <view class="step-title"><text class="step-left">step</text> <text class="step-right">1 </text>quickStartFunctions 云函数代码</view>
  33. <view class="code_zone">
  34. <rich-text nodes="<pre style='overflow: scroll;'>{{callMiniProgramCode}}</pre>" />
  35. </view>
  36. <view class="step-title"><text class="step-left">step</text> <text class="step-right">2 </text>小程序代码段</view>
  37. <view class="code_zone">
  38. <rich-text nodes="<pre style='overflow: scroll;'>{{callFunctionCode}}</pre>" />
  39. </view>
  40. </view>
  41. <view class="block">
  42. <view class="btn-full" bind:tap="getCodeSrc" wx:if="{{!haveGetCodeSrc}}">运行示例</view>
  43. <view class="box_text" wx:if="{{!codeSrc}}">小程序码将展示在这里</view>
  44. <view wx:if="{{codeSrc}}" class="code_box">
  45. <image class="code_img" src="{{codeSrc}}"></image>
  46. </view>
  47. <view class="button_clear" bindtap="clearCodeSrc" wx:if="{{haveGetCodeSrc}}">清空</view>
  48. <cloud-tip-modal showTipProps="{{showTip}}" title="{{title}}" content="{{content}}"></cloud-tip-modal>
  49. </view>
  50. </view>
  51. </block>
  52. <block wx:if="{{ type === 'createCollection' }}">
  53. <view class="page-container">
  54. <view class="title">功能介绍</view>
  55. <view class="info">集合为常用数据库中表的概念。云开发数据库支持自动备份、无损回档,并且QPS高达3千+。</view>
  56. <view class="title">如何体验</view>
  57. <view class="info">已自动创建名为“sales”的体验合集,可打开“云开发控制台>数据库>记录列表”中找到该集合。</view>
  58. <image class="img" src="../../images/database.png"></image>
  59. <view class="title">云函数代码示例</view>
  60. <view class="code_zone">
  61. <rich-text nodes="<pre style='overflow: scroll;'>{{callCreateCollectionCode}}</pre>" />
  62. </view>
  63. </view>
  64. </block>
  65. <block wx:if="{{ type === 'selectRecord' }}">
  66. <view class="page-container">
  67. <view class="title">功能介绍</view>
  68. <view class="top_tip">体验查询记录能力,查询数据表中的销量数据。</view>
  69. <view class="box_text" wx:if="{{!record}}">销量数据将展示在这里</view>
  70. <view class="title">数据库操作示例</view>
  71. <view class="top_tip">参考云函数 quickstartFunctions 示例代码</view>
  72. <view wx:if="{{record}}" class="code_box">
  73. <view class="code_box_title">地区销量统计</view>
  74. <view class="code_box_record">
  75. <view class="code_box_record_title">地域</view>
  76. <view class="code_box_record_title">城市</view>
  77. <view class="code_box_record_title">销量</view>
  78. <view class="code_box_record_title">操作</view>
  79. </view>
  80. <view class="line"></view>
  81. <view class="code_box_record" wx:for="{{record}}" wx:key="_id">
  82. <view class="code_box_record_detail">{{item.region}}</view>
  83. <view class="code_box_record_detail">{{item.city}}</view>
  84. <!-- <view class="code_box_record_detail">{{item.sales}}</view> -->
  85. <input style="background-color: rgba(0, 0, 0, 0.03)" class="code_box_record_detail" bindinput="bindInput" data-index="{{index}}" value="{{item.sales}}" type="number"></input>
  86. <view class="code_box_record_detail">
  87. <button style="font-size: 12px" bind:tap="deleteRecord" data-id="{{item._id}}">删除</button>
  88. </view>
  89. </view>
  90. </view>
  91. <view class="btn-full" bind:tap="getRecord" >查询记录</view>
  92. <view class="btn-full" bind:tap="updateRecord" >更新记录</view>
  93. <view class="btn-full" bind:tap="insertRecord" >新增记录</view>
  94. <!-- <view class="button_clear" bindtap="clearRecord" wx:if="{{haveGetRecord}}">清空</view> -->
  95. <cloud-tip-modal showTipProps="{{showTip}}"></cloud-tip-modal>
  96. </view>
  97. <view wx:if="{{showInsertModal}}" class="modal-mask">
  98. <view class="modal-content">
  99. <view class="modal-title">新增销量记录</view>
  100. <input class="modal-input" placeholder="地域" value="{{insertRegion}}" bindinput="onInsertRegionInput"/>
  101. <input class="modal-input" placeholder="城市" value="{{insertCity}}" bindinput="onInsertCityInput"/>
  102. <input class="modal-input" placeholder="销量" value="{{insertSales}}" bindinput="onInsertSalesInput" type="number"/>
  103. <view class="modal-actions">
  104. <button bindtap="onInsertCancel">取消</button>
  105. <button bindtap="onInsertConfirm" type="primary">确认</button>
  106. </view>
  107. </view>
  108. </view>
  109. </block>
  110. <block wx:if="{{ type === 'uploadFile' }}">
  111. <view class="page-container">
  112. <view class="title">功能介绍</view>
  113. <view class="top_tip">多存储类型,仅需一个云函数即可完成上传。</view>
  114. <view class="title">文件上传示例</view>
  115. <view class="block">
  116. <view class="step-title">小程序代码段</view>
  117. <view class="code_zone">
  118. <rich-text nodes="<pre style='overflow: scroll;'>{{callUploadFileCode}}</pre>" />
  119. </view>
  120. </view>
  121. <view class="btn-full" bind:tap="uploadImg" wx:if="{{!haveGetImgSrc}}">运行示例</view>
  122. <view class="box_text" wx:if="{{!imgSrc}}">上传的图片将展示在这里</view>
  123. <view wx:if="{{imgSrc}}" class="code_box">
  124. <image class="code_img" src="{{imgSrc}}"></image>
  125. <!-- <view class="img_info">
  126. <view class="img_info_title">文件路径</view>
  127. <view class="img_info_detail">{{imgSrc}}</view>
  128. </view> -->
  129. </view>
  130. <view class="button_clear" bindtap="clearImgSrc" wx:if="{{haveGetImgSrc}}">清空</view>
  131. <cloud-tip-modal showTipProps="{{showTip}}"></cloud-tip-modal>
  132. </view>
  133. </block>
  134. <block wx:if="{{ type === 'model-guide'}}">
  135. <view class="page-container">
  136. <view class="title">功能介绍</view>
  137. <view class="top_tip">腾讯云开发提供 AI 对话能力,支持 Agent,大模型流式对话,可通过 Agent-UI 组件快速集成 AI 能力</view>
  138. <view class="title">集成 Agent-UI 组件指引</view>
  139. <view class="block">
  140. <view class="step-title"><text class="step-left">step</text> <text class="step-right">1 </text>拷贝组件源码包</view>
  141. <view style="display: flex;align-items: center;">点击复制查看组件仓库地址 <image mode="widthFix" style="width: 20px;height: 20px" bind:tap="copyUrl" src='../../images/copy.svg'/></view>
  142. <view class="step-title"><text class="step-left">step</text> <text class="step-right">2 </text>将组件拷贝至小程序目录中</view>
  143. <image class="img" mode="widthFix" src="../../images/ai_example2.png"></image>
  144. <view class="step-title"><text class="step-left">step</text> <text class="step-right">3 </text>在页面 .json 配置文件中注册组件</view>
  145. <view class="code_zone">
  146. <rich-text nodes="<pre style='overflow: scroll;'>{{ai_page_config}}</pre>" />
  147. </view>
  148. <view class="step-title"><text class="step-left">step</text> <text class="step-right">4 </text>在页面 .wxml 文件中引用组件</view>
  149. <view class="code_zone">
  150. <rich-text nodes="<pre style='overflow: scroll;'>{{ai_wxml_config}}</pre>" />
  151. </view>
  152. <view class="step-title"><text class="step-left">step</text> <text class="step-right">4 </text>在页面 .js 文件中编写配置</view>
  153. <view class="code_zone">
  154. <rich-text nodes="<pre style='overflow: scroll;'>{{ai_data_config}}</pre>" />
  155. </view>
  156. </view>
  157. </view>
  158. </block>
  159. <block wx:if="{{ type === 'cloudbaserun' }}">
  160. <view class="page-container">
  161. <view class="title">功能介绍</view>
  162. <view class="info">云托管 支持托管用任意语言和框架编写的容器化应用,为开发者提供高可用、自动弹性扩缩的云服务。</view>
  163. <view class="title">小程序调用云托管示例</view>
  164. <view class="block">
  165. <view class="step-title"><text class="step-left">step</text> <text class="step-right">1 </text>前往云开发平台开通云托管</view>
  166. <view class="step-title"><text class="step-left">step</text> <text class="step-right">2 </text>新建容器型托管服务,等待部署完成</view>
  167. <view class="step-text">
  168. 此处可使用 Express 示例模板进行安装,此处示例命名为 express-test
  169. </view>
  170. <view>
  171. <image class="img" src="../../images/create_cbr.png" mode="aspectFill"></image>
  172. </view>
  173. <view class="step-title"><text class="step-left">step</text> <text class="step-right">3</text>小程序端调用</view>
  174. <view class="code_zone">
  175. <rich-text nodes="<pre style='overflow: scroll;'>{{callcbrCode}}</pre>" />
  176. </view>
  177. <view class="btn-full" bind:tap="runCallContainer" wx:if="{{!haveGetCallContainerRes}}">运行示例</view>
  178. <view class="box_text">{{ callContainerResStr ? callContainerResStr : '云托管调用结果将展示在这里' }}</view>
  179. <view class="button_clear" bindtap="clearCallContainerRes" wx:if="{{haveGetCallContainerRes}}">清空</view>
  180. </view>
  181. </view>
  182. </block>