diff --git a/miniprogram-3/.eslintrc.js b/miniprogram-3/.eslintrc.js new file mode 100644 index 0000000..115cc02 --- /dev/null +++ b/miniprogram-3/.eslintrc.js @@ -0,0 +1,31 @@ +/* + * Eslint config file + * Documentation: https://eslint.org/docs/user-guide/configuring/ + * Install the Eslint extension before using this feature. + */ +module.exports = { + env: { + es6: true, + browser: true, + node: true, + }, + ecmaFeatures: { + modules: true, + }, + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, + globals: { + wx: true, + App: true, + Page: true, + getCurrentPages: true, + getApp: true, + Component: true, + requirePlugin: true, + requireMiniProgram: true, + }, + // extends: 'eslint:recommended', + rules: {}, +} diff --git a/miniprogram-3/README.md b/miniprogram-3/README.md new file mode 100644 index 0000000..e097b0c --- /dev/null +++ b/miniprogram-3/README.md @@ -0,0 +1,12 @@ +# 云开发 quickstart + +这是云开发的快速启动指引,其中演示了如何上手使用云开发的三大基础能力: + +- 数据库:一个既可在小程序前端操作,也能在云函数中读写的 JSON 文档型数据库 +- 文件存储:在小程序前端直接上传/下载云端文件,在云开发控制台可视化管理 +- 云函数:在云端运行的代码,微信私有协议天然鉴权,开发者只需编写业务逻辑代码 + +## 参考文档 + +- [云开发文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html) + diff --git a/miniprogram-3/miniprogram/app.js b/miniprogram-3/miniprogram/app.js new file mode 100644 index 0000000..56db3cc --- /dev/null +++ b/miniprogram-3/miniprogram/app.js @@ -0,0 +1,21 @@ +// app.js +App({ + onLaunch: function () { + if (!wx.cloud) { + console.error('请使用 2.2.3 或以上的基础库以使用云能力'); + } else { + wx.cloud.init({ + // env 参数说明: + // env 参数决定接下来小程序发起的云开发调用(wx.cloud.xxx)会默认请求到哪个云环境的资源 + // 此处请填入环境 ID, 环境 ID 可打开云控制台查看 + // 如不填则使用默认环境(第一个创建的环境) + env: 'xiongchangding-1g3rqdct5b84e492', + traceUser: true, + }); + } + + this.globalData = { + chosen_index: 1 + }; + } +}); diff --git a/miniprogram-3/miniprogram/app.json b/miniprogram-3/miniprogram/app.json new file mode 100644 index 0000000..88f8df6 --- /dev/null +++ b/miniprogram-3/miniprogram/app.json @@ -0,0 +1,24 @@ +{ + "pages": [ + "pages/1/1", + "pages/3/3", + "pages/2/2", + "pages/4/4", + "pages/5-1/5-1", + "pages/52/52", + "pages/53/53", + "pages/54/54", + "pages/42/42", + "pages/31/31", + "pages/index/index" + ], + "window": { + "backgroundColor": "#F6F6F6", + "backgroundTextStyle": "light", + "navigationBarBackgroundColor": "#F6F6F6", + "navigationBarTitleText": "云开发-点名系统", + "navigationBarTextStyle": "black" + }, + "sitemapLocation": "sitemap.json", + "style": "v2" +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/app.wxss b/miniprogram-3/miniprogram/app.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram-3/miniprogram/components/cloudTipModal/index.js b/miniprogram-3/miniprogram/components/cloudTipModal/index.js new file mode 100644 index 0000000..2d44c6e --- /dev/null +++ b/miniprogram-3/miniprogram/components/cloudTipModal/index.js @@ -0,0 +1,60 @@ +// miniprogram/components/cloudTipModal/index.js +const { isMac } = require('../../envList.js'); + +Component({ + + /** + * 页面的初始数据 + */ + data: { + showUploadTip: false, + tipText: isMac ? 'sh ./uploadCloudFunction.sh' : './uploadCloudFunction.bat' + }, + properties: { + showUploadTipProps: Boolean + }, + observers: { + showUploadTipProps: function(showUploadTipProps) { + this.setData({ + showUploadTip: showUploadTipProps + }); + } + }, + methods: { + onCheckEnv(){ + wx.showLoading({ + title: '', + }); + wx.cloud + .callFunction({ + name: 'quickstartFunctions', + data: { + type: 'getOpenId', + }, + }) + .then(() => { + wx.hideLoading(); + this.setData({ + showUploadTip: !this.data.showUploadTip + }); + }) + .catch((e) => { + // 报错信息提示环境不存在 + wx.hideLoading(); + if(e.message.includes('env not exists') || e.message.includes('Environment not found') || e.message.includes('env check invalid be filterd')){ + wx.showToast({ + title: '环境未找到', + icon: 'error', + duration: 2000 + }) + } + }); + }, + + onCheckEnvCancel(){ + this.setData({ + showUploadTip: !this.data.showUploadTip + }); + }, + } +}); diff --git a/miniprogram-3/miniprogram/components/cloudTipModal/index.json b/miniprogram-3/miniprogram/components/cloudTipModal/index.json new file mode 100644 index 0000000..4575d1b --- /dev/null +++ b/miniprogram-3/miniprogram/components/cloudTipModal/index.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "component": true +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/components/cloudTipModal/index.wxml b/miniprogram-3/miniprogram/components/cloudTipModal/index.wxml new file mode 100644 index 0000000..4e74c9c --- /dev/null +++ b/miniprogram-3/miniprogram/components/cloudTipModal/index.wxml @@ -0,0 +1,14 @@ + + + + + + 云开发环境未找到 + 请点击上方「云开发」按钮,开通云开发环境后重试。 + 如果已经开通云开发,请检查环境ID与 `miniprogram/app.js` 中的 `env` 参数是否一致。 + + 重新检测 + 取消 + + + diff --git a/miniprogram-3/miniprogram/components/cloudTipModal/index.wxss b/miniprogram-3/miniprogram/components/cloudTipModal/index.wxss new file mode 100644 index 0000000..9ef2b39 --- /dev/null +++ b/miniprogram-3/miniprogram/components/cloudTipModal/index.wxss @@ -0,0 +1,54 @@ +.install_tip_back { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + background-color: rgba(0,0,0,0.4); + z-index: 1; +} + +.install_tip_detail { + position: fixed; + background-color: white; + right: 0; + bottom: 0; + left: 0; + top: 65%; + border-radius: 40rpx 40rpx 0 0; + padding: 50rpx; + z-index: 9; +} + +.install_tip_detail_title { + font-weight: 400; + font-size: 40rpx; + text-align: center; +} + +.install_tip_detail_tip { + font-size: 25rpx; + color: rgba(0,0,0,0.4); + margin-top: 20rpx; + text-align: left; +} +.install_tip_detail_buttons { + padding-top: 50rpx; + display: flex; +} +.install_tip_detail_button { + color: #07C160; + font-weight: 500; + background-color: rgba(0,0,0,0.1); + width: 40%; + text-align: center; + height: 90rpx; + line-height: 90rpx; + border-radius: 10rpx; + margin: 0 auto; +} + +.install_tip_detail_button_primary { + background-color: #07C160; + color: #fff; +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/components/cloudbaseModuleInstallModal/index.js b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallModal/index.js new file mode 100644 index 0000000..536b2f7 --- /dev/null +++ b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallModal/index.js @@ -0,0 +1,39 @@ +Component({ + data: { + modalVisible: false, + tipText: '云开发>云模板>模板中心', + }, + properties: { + installModulePageTitleProps: String, + modalVisibleProps: Boolean, + tipTextProps: String, + installModuleNameProps: String, + }, + observers: { + modalVisibleProps: function (modalVisibleProps) { + this.setData({ + modalVisible: modalVisibleProps, + }); + }, + tipTextProps: function (tipTextProps) { + this.setData({ + tipText: tipTextProps, + }); + }, + }, + methods: { + hideModal() { + if (this.data.modalVisible) { + this.setData({ + modalVisible: false, + }); + } + }, + onViewDetail() { + this.hideModal(); + wx.navigateTo({ + url: `/pages/cloudbaseModuleInstallTips/index?moduleName=${this.properties.installModuleNameProps}&title=${this.properties.installModulePageTitleProps}`, + }); + }, + }, +}); diff --git a/miniprogram-3/miniprogram/components/cloudbaseModuleInstallModal/index.json b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallModal/index.json new file mode 100644 index 0000000..4575d1b --- /dev/null +++ b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallModal/index.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "component": true +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/components/cloudbaseModuleInstallModal/index.wxml b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallModal/index.wxml new file mode 100644 index 0000000..615d163 --- /dev/null +++ b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallModal/index.wxml @@ -0,0 +1,11 @@ + + + + + 体验前需安装云模板 + 请按照以下路径安装对应云模板 + {{ tipText }} + 查看详情{{ installModuleName }} + + + diff --git a/miniprogram-3/miniprogram/components/cloudbaseModuleInstallModal/index.wxss b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallModal/index.wxss new file mode 100644 index 0000000..ae36531 --- /dev/null +++ b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallModal/index.wxss @@ -0,0 +1,57 @@ +.install_tip_back { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + background-color: rgba(0,0,0,0.4); + z-index: 1; +} + +.install_tip_detail { + position: fixed; + background-color: white; + right: 0; + bottom: 0; + left: 0; + top: 60%; + border-radius: 40rpx 40rpx 0 0; + padding: 50rpx; + z-index: 9; +} + +.install_tip_detail_title { + font-weight: 400; + font-size: 40rpx; + text-align: center; +} + +.install_tip_detail_tip { + font-size: 25rpx; + color: rgba(0,0,0,0.4); + margin-top: 20rpx; + text-align: center; +} + +.install_tip_detail_shell { + margin: 70rpx 0; + display: flex; + justify-content: center; +} + +.install_tip_detail_copy { + color: #546488; + margin-left: 10rpx; +} + +.install_tip_detail_button { + color: #07C160; + font-weight: 500; + background-color: rgba(0,0,0,0.1); + width: 60%; + text-align: center; + height: 90rpx; + line-height: 90rpx; + border-radius: 10rpx; + margin: 0 auto; +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/components/cloudbaseModuleInstallPath/index.js b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallPath/index.js new file mode 100644 index 0000000..0d7e89c --- /dev/null +++ b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallPath/index.js @@ -0,0 +1,24 @@ +// components/cloudbaseModuleInstallPath/index.js +Component({ + + /** + * 组件的属性列表 + */ + properties: { + installModuleName: String, + }, + + /** + * 组件的初始数据 + */ + data: { + + }, + + /** + * 组件的方法列表 + */ + methods: { + + } +}) \ No newline at end of file diff --git a/miniprogram-3/miniprogram/components/cloudbaseModuleInstallPath/index.json b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallPath/index.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallPath/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/components/cloudbaseModuleInstallPath/index.wxml b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallPath/index.wxml new file mode 100644 index 0000000..c7ba516 --- /dev/null +++ b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallPath/index.wxml @@ -0,0 +1 @@ +可以在“云开发>云模板>模板中心>{{installModuleName}}”找到该模板 \ No newline at end of file diff --git a/miniprogram-3/miniprogram/components/cloudbaseModuleInstallPath/index.wxss b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallPath/index.wxss new file mode 100644 index 0000000..128ffdc --- /dev/null +++ b/miniprogram-3/miniprogram/components/cloudbaseModuleInstallPath/index.wxss @@ -0,0 +1,7 @@ +.tip { + font-size: 23rpx; + color: rgba(0, 0, 0, 0.5); + width: 90%; + text-align: center; + margin: 30rpx auto 0 auto; +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/components/mpCodeModal/index.js b/miniprogram-3/miniprogram/components/mpCodeModal/index.js new file mode 100644 index 0000000..65b369b --- /dev/null +++ b/miniprogram-3/miniprogram/components/mpCodeModal/index.js @@ -0,0 +1,21 @@ +Component({ + data: { + modalVisible: false, + }, + properties: { + visible: Boolean, + imageSrc: String, + }, + observers: { + visible: function (visible) { + this.setData({ + modalVisible: visible + }); + }, + }, + methods: { + onClose() { + this.setData({ modalVisible: false }); + } + } +}); diff --git a/miniprogram-3/miniprogram/components/mpCodeModal/index.json b/miniprogram-3/miniprogram/components/mpCodeModal/index.json new file mode 100644 index 0000000..4575d1b --- /dev/null +++ b/miniprogram-3/miniprogram/components/mpCodeModal/index.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "component": true +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/components/mpCodeModal/index.wxml b/miniprogram-3/miniprogram/components/mpCodeModal/index.wxml new file mode 100644 index 0000000..28eea72 --- /dev/null +++ b/miniprogram-3/miniprogram/components/mpCodeModal/index.wxml @@ -0,0 +1,8 @@ + + + X + + + + + \ No newline at end of file diff --git a/miniprogram-3/miniprogram/components/mpCodeModal/index.wxss b/miniprogram-3/miniprogram/components/mpCodeModal/index.wxss new file mode 100644 index 0000000..ce7b993 --- /dev/null +++ b/miniprogram-3/miniprogram/components/mpCodeModal/index.wxss @@ -0,0 +1,95 @@ +.modal_container { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + background-color: rgba(0,0,0,0.4); + z-index: 1; + width: 100%; + height: 100%; +} + +.icon_close { + position: fixed; + right: 40rpx; + top: 40rpx; + width: 70rpx; + height: 70rpx; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + /* background-color: #07c160; */ + background-color: rgba(0,0,0,0.7); + color: white; + font-size: 32rpx; + font-weight: bold; +} + +.code_img { + width: 400rpx; + height: 400rpx; + margin-top: 50%; + margin-left: 50%; + transform: translateX(-50%); + border-radius: 30rpx; +} + +.install_tip_back { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + background-color: rgba(0,0,0,0.4); + z-index: 1; +} + +.install_tip_detail { + position: fixed; + background-color: white; + right: 0; + bottom: 0; + left: 0; + top: 60%; + border-radius: 40rpx 40rpx 0 0; + padding: 50rpx; + z-index: 9; +} + +.install_tip_detail_title { + font-weight: 400; + font-size: 40rpx; + text-align: center; +} + +.install_tip_detail_tip { + font-size: 25rpx; + color: rgba(0,0,0,0.4); + margin-top: 20rpx; + text-align: center; +} + +.install_tip_detail_shell { + margin: 70rpx 0; + display: flex; + justify-content: center; +} + +.install_tip_detail_copy { + color: #546488; + margin-left: 10rpx; +} + +.install_tip_detail_button { + color: #07C160; + font-weight: 500; + background-color: rgba(0,0,0,0.1); + width: 60%; + text-align: center; + height: 90rpx; + line-height: 90rpx; + border-radius: 10rpx; + margin: 0 auto; +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/envList.js b/miniprogram-3/miniprogram/envList.js new file mode 100644 index 0000000..e9a169e --- /dev/null +++ b/miniprogram-3/miniprogram/envList.js @@ -0,0 +1,6 @@ +const envList = []; +const isMac = false; +module.exports = { + envList, + isMac +}; diff --git a/miniprogram-3/miniprogram/image/cuizi.png b/miniprogram-3/miniprogram/image/cuizi.png new file mode 100644 index 0000000..ae90b6a Binary files /dev/null and b/miniprogram-3/miniprogram/image/cuizi.png differ diff --git a/miniprogram-3/miniprogram/image/logo.png b/miniprogram-3/miniprogram/image/logo.png new file mode 100644 index 0000000..5202888 Binary files /dev/null and b/miniprogram-3/miniprogram/image/logo.png differ diff --git a/miniprogram-3/miniprogram/image/shenpaizhang.jpg b/miniprogram-3/miniprogram/image/shenpaizhang.jpg new file mode 100644 index 0000000..49fde33 Binary files /dev/null and b/miniprogram-3/miniprogram/image/shenpaizhang.jpg differ diff --git a/miniprogram-3/miniprogram/image/shenpan.jpg b/miniprogram-3/miniprogram/image/shenpan.jpg new file mode 100644 index 0000000..84a9571 Binary files /dev/null and b/miniprogram-3/miniprogram/image/shenpan.jpg differ diff --git a/miniprogram-3/miniprogram/image/xinyuu.png b/miniprogram-3/miniprogram/image/xinyuu.png new file mode 100644 index 0000000..bf7f3f6 Binary files /dev/null and b/miniprogram-3/miniprogram/image/xinyuu.png differ diff --git a/miniprogram-3/miniprogram/images/arrow.svg b/miniprogram-3/miniprogram/images/arrow.svg new file mode 100644 index 0000000..cd32a7d --- /dev/null +++ b/miniprogram-3/miniprogram/images/arrow.svg @@ -0,0 +1,11 @@ + + + ☀ iOS/☀ 图标/线型/icons_outlined_arrow@3x + + + + + + + + \ No newline at end of file diff --git a/miniprogram-3/miniprogram/images/avatar.png b/miniprogram-3/miniprogram/images/avatar.png new file mode 100644 index 0000000..48d5ee2 Binary files /dev/null and b/miniprogram-3/miniprogram/images/avatar.png differ diff --git a/miniprogram-3/miniprogram/images/cloud_backend.png b/miniprogram-3/miniprogram/images/cloud_backend.png new file mode 100644 index 0000000..6ff6dc3 Binary files /dev/null and b/miniprogram-3/miniprogram/images/cloud_backend.png differ diff --git a/miniprogram-3/miniprogram/images/cloud_backend_info.png b/miniprogram-3/miniprogram/images/cloud_backend_info.png new file mode 100644 index 0000000..c442378 Binary files /dev/null and b/miniprogram-3/miniprogram/images/cloud_backend_info.png differ diff --git a/miniprogram-3/miniprogram/images/cloud_backend_login.png b/miniprogram-3/miniprogram/images/cloud_backend_login.png new file mode 100644 index 0000000..beae5c6 Binary files /dev/null and b/miniprogram-3/miniprogram/images/cloud_backend_login.png differ diff --git a/miniprogram-3/miniprogram/images/cloud_dev.png b/miniprogram-3/miniprogram/images/cloud_dev.png new file mode 100644 index 0000000..9eb538a Binary files /dev/null and b/miniprogram-3/miniprogram/images/cloud_dev.png differ diff --git a/miniprogram-3/miniprogram/images/create_env.png b/miniprogram-3/miniprogram/images/create_env.png new file mode 100644 index 0000000..c319b9d Binary files /dev/null and b/miniprogram-3/miniprogram/images/create_env.png differ diff --git a/miniprogram-3/miniprogram/images/database.png b/miniprogram-3/miniprogram/images/database.png new file mode 100644 index 0000000..6551376 Binary files /dev/null and b/miniprogram-3/miniprogram/images/database.png differ diff --git a/miniprogram-3/miniprogram/images/database_add.png b/miniprogram-3/miniprogram/images/database_add.png new file mode 100644 index 0000000..f4ac9f9 Binary files /dev/null and b/miniprogram-3/miniprogram/images/database_add.png differ diff --git a/miniprogram-3/miniprogram/images/default-goods-image.png b/miniprogram-3/miniprogram/images/default-goods-image.png new file mode 100644 index 0000000..a5015f3 Binary files /dev/null and b/miniprogram-3/miniprogram/images/default-goods-image.png differ diff --git a/miniprogram-3/miniprogram/images/deploy_step1.png b/miniprogram-3/miniprogram/images/deploy_step1.png new file mode 100644 index 0000000..c0f08c6 Binary files /dev/null and b/miniprogram-3/miniprogram/images/deploy_step1.png differ diff --git a/miniprogram-3/miniprogram/images/deploy_step2.png b/miniprogram-3/miniprogram/images/deploy_step2.png new file mode 100644 index 0000000..3d8c30c Binary files /dev/null and b/miniprogram-3/miniprogram/images/deploy_step2.png differ diff --git a/miniprogram-3/miniprogram/images/env-select.png b/miniprogram-3/miniprogram/images/env-select.png new file mode 100644 index 0000000..36a7b6a Binary files /dev/null and b/miniprogram-3/miniprogram/images/env-select.png differ diff --git a/miniprogram-3/miniprogram/images/function_deploy.png b/miniprogram-3/miniprogram/images/function_deploy.png new file mode 100644 index 0000000..8d9c7a6 Binary files /dev/null and b/miniprogram-3/miniprogram/images/function_deploy.png differ diff --git a/miniprogram-3/miniprogram/images/icons/avatar.png b/miniprogram-3/miniprogram/images/icons/avatar.png new file mode 100644 index 0000000..45744b3 Binary files /dev/null and b/miniprogram-3/miniprogram/images/icons/avatar.png differ diff --git a/miniprogram-3/miniprogram/images/icons/business-active.png b/miniprogram-3/miniprogram/images/icons/business-active.png new file mode 100644 index 0000000..690c5b3 Binary files /dev/null and b/miniprogram-3/miniprogram/images/icons/business-active.png differ diff --git a/miniprogram-3/miniprogram/images/icons/business.png b/miniprogram-3/miniprogram/images/icons/business.png new file mode 100644 index 0000000..af0fbcf Binary files /dev/null and b/miniprogram-3/miniprogram/images/icons/business.png differ diff --git a/miniprogram-3/miniprogram/images/icons/copy.png b/miniprogram-3/miniprogram/images/icons/copy.png new file mode 100644 index 0000000..d2d8f61 Binary files /dev/null and b/miniprogram-3/miniprogram/images/icons/copy.png differ diff --git a/miniprogram-3/miniprogram/images/icons/customer-service.svg b/miniprogram-3/miniprogram/images/icons/customer-service.svg new file mode 100644 index 0000000..be7bba4 --- /dev/null +++ b/miniprogram-3/miniprogram/images/icons/customer-service.svg @@ -0,0 +1,3 @@ + + + diff --git a/miniprogram-3/miniprogram/images/icons/examples-active.png b/miniprogram-3/miniprogram/images/icons/examples-active.png new file mode 100644 index 0000000..a5715d7 Binary files /dev/null and b/miniprogram-3/miniprogram/images/icons/examples-active.png differ diff --git a/miniprogram-3/miniprogram/images/icons/examples.png b/miniprogram-3/miniprogram/images/icons/examples.png new file mode 100644 index 0000000..7ce740b Binary files /dev/null and b/miniprogram-3/miniprogram/images/icons/examples.png differ diff --git a/miniprogram-3/miniprogram/images/icons/goods-active.png b/miniprogram-3/miniprogram/images/icons/goods-active.png new file mode 100644 index 0000000..54a4680 Binary files /dev/null and b/miniprogram-3/miniprogram/images/icons/goods-active.png differ diff --git a/miniprogram-3/miniprogram/images/icons/goods.png b/miniprogram-3/miniprogram/images/icons/goods.png new file mode 100644 index 0000000..c1ec7ed Binary files /dev/null and b/miniprogram-3/miniprogram/images/icons/goods.png differ diff --git a/miniprogram-3/miniprogram/images/icons/home-active.png b/miniprogram-3/miniprogram/images/icons/home-active.png new file mode 100644 index 0000000..c1107cb Binary files /dev/null and b/miniprogram-3/miniprogram/images/icons/home-active.png differ diff --git a/miniprogram-3/miniprogram/images/icons/home.png b/miniprogram-3/miniprogram/images/icons/home.png new file mode 100644 index 0000000..e598e18 Binary files /dev/null and b/miniprogram-3/miniprogram/images/icons/home.png differ diff --git a/miniprogram-3/miniprogram/images/icons/question.svg b/miniprogram-3/miniprogram/images/icons/question.svg new file mode 100644 index 0000000..3389b03 --- /dev/null +++ b/miniprogram-3/miniprogram/images/icons/question.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/miniprogram-3/miniprogram/images/icons/setting.svg b/miniprogram-3/miniprogram/images/icons/setting.svg new file mode 100644 index 0000000..1c41dab --- /dev/null +++ b/miniprogram-3/miniprogram/images/icons/setting.svg @@ -0,0 +1,4 @@ + + + + diff --git a/miniprogram-3/miniprogram/images/icons/share.svg b/miniprogram-3/miniprogram/images/icons/share.svg new file mode 100644 index 0000000..297275e --- /dev/null +++ b/miniprogram-3/miniprogram/images/icons/share.svg @@ -0,0 +1,4 @@ + + + + diff --git a/miniprogram-3/miniprogram/images/icons/usercenter-active.png b/miniprogram-3/miniprogram/images/icons/usercenter-active.png new file mode 100644 index 0000000..38a93cf Binary files /dev/null and b/miniprogram-3/miniprogram/images/icons/usercenter-active.png differ diff --git a/miniprogram-3/miniprogram/images/icons/usercenter.png b/miniprogram-3/miniprogram/images/icons/usercenter.png new file mode 100644 index 0000000..e0e0131 Binary files /dev/null and b/miniprogram-3/miniprogram/images/icons/usercenter.png differ diff --git a/miniprogram-3/miniprogram/images/img/QQ图片20241003164959.jpg b/miniprogram-3/miniprogram/images/img/QQ图片20241003164959.jpg new file mode 100644 index 0000000..84a9571 Binary files /dev/null and b/miniprogram-3/miniprogram/images/img/QQ图片20241003164959.jpg differ diff --git a/miniprogram-3/miniprogram/images/img/logo.png b/miniprogram-3/miniprogram/images/img/logo.png new file mode 100644 index 0000000..5202888 Binary files /dev/null and b/miniprogram-3/miniprogram/images/img/logo.png differ diff --git a/miniprogram-3/miniprogram/images/img/审判长.jpg b/miniprogram-3/miniprogram/images/img/审判长.jpg new file mode 100644 index 0000000..49fde33 Binary files /dev/null and b/miniprogram-3/miniprogram/images/img/审判长.jpg differ diff --git a/miniprogram-3/miniprogram/images/img/幸运儿.png b/miniprogram-3/miniprogram/images/img/幸运儿.png new file mode 100644 index 0000000..bf7f3f6 Binary files /dev/null and b/miniprogram-3/miniprogram/images/img/幸运儿.png differ diff --git a/miniprogram-3/miniprogram/images/img/锤子.png b/miniprogram-3/miniprogram/images/img/锤子.png new file mode 100644 index 0000000..ae90b6a Binary files /dev/null and b/miniprogram-3/miniprogram/images/img/锤子.png differ diff --git a/miniprogram-3/miniprogram/images/list-database.png b/miniprogram-3/miniprogram/images/list-database.png new file mode 100644 index 0000000..88b6a2b Binary files /dev/null and b/miniprogram-3/miniprogram/images/list-database.png differ diff --git a/miniprogram-3/miniprogram/images/list-init.png b/miniprogram-3/miniprogram/images/list-init.png new file mode 100644 index 0000000..54be174 Binary files /dev/null and b/miniprogram-3/miniprogram/images/list-init.png differ diff --git a/miniprogram-3/miniprogram/images/list-scf.png b/miniprogram-3/miniprogram/images/list-scf.png new file mode 100644 index 0000000..e53f820 Binary files /dev/null and b/miniprogram-3/miniprogram/images/list-scf.png differ diff --git a/miniprogram-3/miniprogram/images/list-share.png b/miniprogram-3/miniprogram/images/list-share.png new file mode 100644 index 0000000..647496f Binary files /dev/null and b/miniprogram-3/miniprogram/images/list-share.png differ diff --git a/miniprogram-3/miniprogram/images/scf-enter.png b/miniprogram-3/miniprogram/images/scf-enter.png new file mode 100644 index 0000000..d71fb3a Binary files /dev/null and b/miniprogram-3/miniprogram/images/scf-enter.png differ diff --git a/miniprogram-3/miniprogram/images/single_template.png b/miniprogram-3/miniprogram/images/single_template.png new file mode 100644 index 0000000..d2ab181 Binary files /dev/null and b/miniprogram-3/miniprogram/images/single_template.png differ diff --git a/miniprogram-3/miniprogram/images/single_template_info.png b/miniprogram-3/miniprogram/images/single_template_info.png new file mode 100644 index 0000000..6cbd774 Binary files /dev/null and b/miniprogram-3/miniprogram/images/single_template_info.png differ diff --git a/miniprogram-3/miniprogram/images/single_template_sample.png b/miniprogram-3/miniprogram/images/single_template_sample.png new file mode 100644 index 0000000..bfe55e7 Binary files /dev/null and b/miniprogram-3/miniprogram/images/single_template_sample.png differ diff --git a/miniprogram-3/miniprogram/pages/1/1.js b/miniprogram-3/miniprogram/pages/1/1.js new file mode 100644 index 0000000..6da7114 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/1/1.js @@ -0,0 +1,66 @@ +// pages/1/1.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/1/1.json b/miniprogram-3/miniprogram/pages/1/1.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/1/1.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/1/1.wxml b/miniprogram-3/miniprogram/pages/1/1.wxml new file mode 100644 index 0000000..3d40132 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/1/1.wxml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/miniprogram-3/miniprogram/pages/1/1.wxss b/miniprogram-3/miniprogram/pages/1/1.wxss new file mode 100644 index 0000000..867b485 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/1/1.wxss @@ -0,0 +1,6 @@ +/* pages/1/1.wxss */ +.box{ + width: auto; + height: 300rpx; + background-color:white; +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/2/2.js b/miniprogram-3/miniprogram/pages/2/2.js new file mode 100644 index 0000000..1b42e3c --- /dev/null +++ b/miniprogram-3/miniprogram/pages/2/2.js @@ -0,0 +1,145 @@ +// pages/2/2.js +const db = wx.cloud.database(); // 获取数据库实例 +const app = getApp(); // 获取全局应用实例 + +Page({ + + async selectRandomIndexAndSetChosen() { + // 显示加载动画 + wx.showLoading({ + title: '加载中...', // 加载中的提示文字 + mask: true // 防止触摸穿透 + }); + + const score_list = []; // 用于存储所有数据的score + const index_list = []; // 用于存储所有数据的index + const MAX_LIMIT = 20; // 每次获取数据的最大数量 + + try { + // 获取所有数据并存入score_list和index_list + const total = await db.collection('demolist').count().then(res => res.total); + const batchTimes = Math.ceil(total / MAX_LIMIT); + + const tasks = []; + for (let i = 0; i < batchTimes; i++) { + const promise = db.collection('demolist').skip(i * MAX_LIMIT).limit(MAX_LIMIT).get().then(res => { + res.data.forEach(item => { + score_list.push(item.score); + index_list.push(item.index); + }); + }); + tasks.push(promise); + } + + await Promise.all(tasks); // 等待所有数据请求完成 + + // 根据score_list中的值生成权重 + const maxScore = 60; + const weights = score_list.map(score => maxScore - score); + + // 计算权重总和 + const totalWeight = weights.reduce((sum, weight) => sum + weight, 0); + + // 生成一个介于 0 和 totalWeight 之间的随机数 + const randomWeight = Math.random() * totalWeight; + + // 根据随机数选择index + let cumulativeWeight = 0; + for (let i = 0; i < weights.length; i++) { + cumulativeWeight += weights[i]; + if (randomWeight <= cumulativeWeight) { + // 将选中的 index 赋值给 app.js 中的 chosen_index 变量 + getApp().globalData.chosen_index = index_list[i]; + console.log('选中的 index:', index_list[i]); + + // 隐藏加载动画 + wx.hideLoading(); + + // 跳转到 pages/3/3 页面 + wx.redirectTo({ + url: '../3/3' + }); + return; // 跳转后结束函数 + } + } + } catch (error) { + console.error('获取数据失败:', error); + // 如果出错也隐藏加载动画 + wx.hideLoading(); + } + }, + + + + + + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + // selectRandomIndexAndSetChosen() + // .then(() => { + // console.log('index 已成功赋值给 chosen_index'); + // }) + // .catch(err => { + // console.error('获取数据失败:', err); + // }); + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/2/2.json b/miniprogram-3/miniprogram/pages/2/2.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/2/2.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/2/2.wxml b/miniprogram-3/miniprogram/pages/2/2.wxml new file mode 100644 index 0000000..3d6e473 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/2/2.wxml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/miniprogram-3/miniprogram/pages/2/2.wxss b/miniprogram-3/miniprogram/pages/2/2.wxss new file mode 100644 index 0000000..867b485 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/2/2.wxss @@ -0,0 +1,6 @@ +/* pages/1/1.wxss */ +.box{ + width: auto; + height: 300rpx; + background-color:white; +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/3/3.js b/miniprogram-3/miniprogram/pages/3/3.js new file mode 100644 index 0000000..23300dc --- /dev/null +++ b/miniprogram-3/miniprogram/pages/3/3.js @@ -0,0 +1,162 @@ +// pages/3/3.js +const db = wx.cloud.database(); +const app = getApp(); // 获取全局应用实例 + +Page({ + data: { + dataobj: undefined + }, + async updateScoreForIndex_j1() { + try { + // 显示加载动画 + wx.showLoading({ + title: '加载中...', // 可以自定义加载中的提示文字 + mask: true // 是否显示透明蒙层,防止触摸穿透 + }); + + // 查找 index 为 chosen_index 的记录 + const res = await db.collection('demolist').where({ index: app.globalData.chosen_index }).get(); + const data = res.data; + + if (data.length === 0) { + console.log('没有找到 index 为 chosen_index 的数据'); + wx.hideLoading(); // 隐藏加载动画 + return; + } + + const record = data[0]; + const newScore = record.score + 1; // 更新后的 score 值 + + // 更新记录中的 score 属性 + await db.collection('demolist').doc(record._id).update({ + data: { + score: newScore + } + }); + + console.log(`更新成功,新的 score 值为:${newScore}`); + + // 数据更新成功后隐藏加载动画并跳转 + wx.hideLoading(); + wx.redirectTo({ + url: '../31/31' + }); + } catch (error) { + console.error('更新失败:', error); + wx.hideLoading(); // 如果出错也隐藏加载动画 + } + }, + async updateScoreForIndex_fu1() { + try { + // 显示加载动画 + wx.showLoading({ + title: '加载中...', // 可以自定义加载中的提示文字 + mask: true // 是否显示透明蒙层,防止触摸穿透 + }); + + // 查找 index 为 chosen_index 的记录 + const res = await db.collection('demolist').where({ index: app.globalData.chosen_index }).get(); + const data = res.data; + + if (data.length === 0) { + console.log('没有找到 index 为 chosen_index 的数据'); + wx.hideLoading(); // 隐藏加载动画 + return; + } + + const record = data[0]; + const newScore = record.score - 1; // 更新后的 score 值 + + // 更新记录中的 score 属性 + await db.collection('demolist').doc(record._id).update({ + data: { + score: newScore + } + }); + + console.log(`更新成功,新的 score 值为:${newScore}`); + + // 数据更新成功后隐藏加载动画并跳转 + wx.hideLoading(); + wx.redirectTo({ + url: '../42/42' + }); + } catch (error) { + console.error('更新失败:', error); + wx.hideLoading(); // 如果出错也隐藏加载动画 + } + }, + get_data() { + const chosenIndex = app.globalData.chosen_index; // 获取 chosen_index + db.collection("demolist").where({ index: chosenIndex }).get({ + success: res => { + console.log(res); + if (res.data.length > 0) { + this.setData({ + dataobj: res.data[0] + }, () => { + console.log(this.data.dataobj); + }); + } else { + console.log("没有数据"); + } + } + }); + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + this.get_data() + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/3/3.json b/miniprogram-3/miniprogram/pages/3/3.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/3/3.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/3/3.wxml b/miniprogram-3/miniprogram/pages/3/3.wxml new file mode 100644 index 0000000..24e7f5d --- /dev/null +++ b/miniprogram-3/miniprogram/pages/3/3.wxml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + +姓名:{{dataobj.name}} +学号:{{dataobj.xuehao}} + + + 分数:{{dataobj.score}} + + + +该同学到了吗 + + + + + + diff --git a/miniprogram-3/miniprogram/pages/3/3.wxss b/miniprogram-3/miniprogram/pages/3/3.wxss new file mode 100644 index 0000000..d238e58 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/3/3.wxss @@ -0,0 +1,6 @@ +/* pages/1/1.wxss */ +.box{ + width: auto; + height: 150rpx; + background-color:white; +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/31/31.js b/miniprogram-3/miniprogram/pages/31/31.js new file mode 100644 index 0000000..4705899 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/31/31.js @@ -0,0 +1,162 @@ +// pages/3/3.js +const db = wx.cloud.database(); +const app = getApp(); // 获取全局应用实例 + +Page({ + data: { + dataobj: undefined + }, + async updateScoreForIndex_j05() { + try { + // 显示加载动画 + wx.showLoading({ + title: '加载中...', // 可以自定义加载中的提示文字 + mask: true // 是否显示透明蒙层,防止触摸穿透 + }); + + // 查找 index 为 chosen_index 的记录 + const res = await db.collection('demolist').where({ index: app.globalData.chosen_index }).get(); + const data = res.data; + + if (data.length === 0) { + console.log('没有找到 index 为 chosen_index 的数据'); + wx.hideLoading(); // 隐藏加载动画 + return; + } + + const record = data[0]; + const newScore = record.score + 0.5; // 更新后的 score 值 + + // 更新记录中的 score 属性 + await db.collection('demolist').doc(record._id).update({ + data: { + score: newScore + } + }); + + console.log(`更新成功,新的 score 值为:${newScore}`); + + // 数据更新成功后隐藏加载动画并跳转 + wx.hideLoading(); + wx.redirectTo({ + url: '../4/4' + }); + } catch (error) { + console.error('更新失败:', error); + wx.hideLoading(); // 如果出错也隐藏加载动画 + } + }, + async updateScoreForIndex_jian1() { + try { + // 显示加载动画 + wx.showLoading({ + title: '加载中...', // 可以自定义加载中的提示文字 + mask: true // 是否显示透明蒙层,防止触摸穿透 + }); + + // 查找 index 为 chosen_index 的记录 + const res = await db.collection('demolist').where({ index: app.globalData.chosen_index }).get(); + const data = res.data; + + if (data.length === 0) { + console.log('没有找到 index 为 chosen_index 的数据'); + wx.hideLoading(); // 隐藏加载动画 + return; + } + + const record = data[0]; + const newScore = record.score - 1; // 更新后的 score 值 + + // 更新记录中的 score 属性 + await db.collection('demolist').doc(record._id).update({ + data: { + score: newScore + } + }); + + console.log(`更新成功,新的 score 值为:${newScore}`); + + // 数据更新成功后隐藏加载动画并跳转 + wx.hideLoading(); + wx.redirectTo({ + url: '../42/42' + }); + } catch (error) { + console.error('更新失败:', error); + wx.hideLoading(); // 如果出错也隐藏加载动画 + } + }, + get_data() { + const chosenIndex = app.globalData.chosen_index; // 获取 chosen_index + db.collection("demolist").where({ index: chosenIndex }).get({ + success: res => { + console.log(res); + if (res.data.length > 0) { + this.setData({ + dataobj: res.data[0] + }, () => { + console.log(this.data.dataobj); + }); + } else { + console.log("没有数据"); + } + } + }); + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + this.get_data() + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/31/31.json b/miniprogram-3/miniprogram/pages/31/31.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/31/31.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/31/31.wxml b/miniprogram-3/miniprogram/pages/31/31.wxml new file mode 100644 index 0000000..dda0ec9 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/31/31.wxml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + +姓名:{{dataobj.name}} +学号:{{dataobj.xuehao}} + + + 分数:{{dataobj.score}} + + + +积分加1但是请重复刚才的问题 + + + + + + diff --git a/miniprogram-3/miniprogram/pages/31/31.wxss b/miniprogram-3/miniprogram/pages/31/31.wxss new file mode 100644 index 0000000..d238e58 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/31/31.wxss @@ -0,0 +1,6 @@ +/* pages/1/1.wxss */ +.box{ + width: auto; + height: 150rpx; + background-color:white; +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/4/4.js b/miniprogram-3/miniprogram/pages/4/4.js new file mode 100644 index 0000000..3e2b826 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/4/4.js @@ -0,0 +1,250 @@ +// pages/4/4.js +const db = wx.cloud.database(); // 获取数据库实例 +const app = getApp(); // 获取全局应用实例 + + +Page({ + async updateScoreForIndex_05() { + try { + // 显示加载动画 + wx.showLoading({ + title: '加载中...', // 可以自定义加载中的提示文字 + mask: true // 是否显示透明蒙层,防止触摸穿透 + }); + + // 查找 index 为 chosen_index 的记录 + const res = await db.collection('demolist').where({ index: app.globalData.chosen_index }).get(); + const data = res.data; + + if (data.length === 0) { + console.log('没有找到 index 为 chosen_index 的数据'); + wx.hideLoading(); // 隐藏加载动画 + return; + } + + const record = data[0]; + const newScore = record.score + 0.5; // 更新后的 score 值 + + // 更新记录中的 score 属性 + await db.collection('demolist').doc(record._id).update({ + data: { + score: newScore + } + }); + + console.log(`更新成功,新的 score 值为:${newScore}`); + + // 数据更新成功后隐藏加载动画并跳转 + wx.hideLoading(); + wx.redirectTo({ + url: '../5-1/5-1' + }); + } catch (error) { + console.error('更新失败:', error); + wx.hideLoading(); // 如果出错也隐藏加载动画 + } + }, + async updateScoreForIndex_1() { + try { + // 显示加载动画 + wx.showLoading({ + title: '加载中...', // 可以自定义加载中的提示文字 + mask: true // 是否显示透明蒙层,防止触摸穿透 + }); + + // 查找 index 为 chosen_index 的记录 + const res = await db.collection('demolist').where({ index: app.globalData.chosen_index }).get(); + const data = res.data; + + if (data.length === 0) { + console.log('没有找到 index 为 chosen_index 的数据'); + wx.hideLoading(); // 隐藏加载动画 + return; + } + + const record = data[0]; + const newScore = record.score + 1; // 更新后的 score 值 + + // 更新记录中的 score 属性 + await db.collection('demolist').doc(record._id).update({ + data: { + score: newScore + } + }); + + console.log(`更新成功,新的 score 值为:${newScore}`); + + // 数据更新成功后隐藏加载动画并跳转 + wx.hideLoading(); + wx.redirectTo({ + url: '../52/52' + }); + } catch (error) { + console.error('更新失败:', error); + wx.hideLoading(); // 如果出错也隐藏加载动画 + } + }, + async updateScoreForIndex_2() { + try { + // 显示加载动画 + wx.showLoading({ + title: '加载中...', // 可以自定义加载中的提示文字 + mask: true // 是否显示透明蒙层,防止触摸穿透 + }); + + // 查找 index 为 chosen_index 的记录 + const res = await db.collection('demolist').where({ index: app.globalData.chosen_index }).get(); + const data = res.data; + + if (data.length === 0) { + console.log('没有找到 index 为 chosen_index 的数据'); + wx.hideLoading(); // 隐藏加载动画 + return; + } + + const record = data[0]; + const newScore = record.score + 2; // 更新后的 score 值 + + // 更新记录中的 score 属性 + await db.collection('demolist').doc(record._id).update({ + data: { + score: newScore + } + }); + + console.log(`更新成功,新的 score 值为:${newScore}`); + + // 数据更新成功后隐藏加载动画并跳转 + wx.hideLoading(); + wx.redirectTo({ + url: '../53/53' + }); + } catch (error) { + console.error('更新失败:', error); + wx.hideLoading(); // 如果出错也隐藏加载动画 + } + }, + async updateScoreForIndex_3() { + try { + // 显示加载动画 + wx.showLoading({ + title: '加载中...', // 可以自定义加载中的提示文字 + mask: true // 是否显示透明蒙层,防止触摸穿透 + }); + + // 查找 index 为 chosen_index 的记录 + const res = await db.collection('demolist').where({ index: app.globalData.chosen_index }).get(); + const data = res.data; + + if (data.length === 0) { + console.log('没有找到 index 为 chosen_index 的数据'); + wx.hideLoading(); // 隐藏加载动画 + return; + } + + const record = data[0]; + const newScore = record.score + 3; // 更新后的 score 值 + + // 更新记录中的 score 属性 + await db.collection('demolist').doc(record._id).update({ + data: { + score: newScore + } + }); + + console.log(`更新成功,新的 score 值为:${newScore}`); + + // 数据更新成功后隐藏加载动画并跳转 + wx.hideLoading(); + wx.redirectTo({ + url: '../54/54' + }); + } catch (error) { + console.error('更新失败:', error); + wx.hideLoading(); // 如果出错也隐藏加载动画 + } + }, + + + get_data() { + const chosenIndex = app.globalData.chosen_index; // 获取 chosen_index + db.collection("demolist").where({ index: chosenIndex }).get({ + success: res => { + console.log(res); + if (res.data.length > 0) { + this.setData({ + dataobj: res.data[0] + }, () => { + console.log(this.data.dataobj); + }); + } else { + console.log("没有数据"); + } + } + }); + }, + + + /** + * 页面的初始数据 + */ + data: { + dataobj: undefined + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { +this.get_data() + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/4/4.json b/miniprogram-3/miniprogram/pages/4/4.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/4/4.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/4/4.wxml b/miniprogram-3/miniprogram/pages/4/4.wxml new file mode 100644 index 0000000..2cba6a5 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/4/4.wxml @@ -0,0 +1,33 @@ + + + + + + + + + + + +姓名:{{dataobj.name}} +学号:{{dataobj.xuehao}} + + + 分数:{{dataobj.score}} + + + +积分加0.5但是请回答这个问题 + + + + + + + + + + + + + \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/4/4.wxss b/miniprogram-3/miniprogram/pages/4/4.wxss new file mode 100644 index 0000000..302efc5 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/4/4.wxss @@ -0,0 +1,6 @@ +/* pages/1/1.wxss */ +.box{ + width: auto; + height: 100rpx; + background-color:white; +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/42/42.js b/miniprogram-3/miniprogram/pages/42/42.js new file mode 100644 index 0000000..bb82432 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/42/42.js @@ -0,0 +1,85 @@ +// pages/42/42.js +const db = wx.cloud.database(); +const app = getApp(); // 获取全局应用实例 +Page({ + data: { + dataobj: undefined + }, + get_data() { + const chosenIndex = app.globalData.chosen_index; // 获取 chosen_index + db.collection("demolist").where({ index: chosenIndex }).get({ + success: res => { + console.log(res); + if (res.data.length > 0) { + this.setData({ + dataobj: res.data[0] + }, () => { + console.log(this.data.dataobj); + }); + } else { + console.log("没有数据"); + } + } + }); + }, + /** + * 页面的初始数据 + */ + + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + this.get_data() + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/42/42.json b/miniprogram-3/miniprogram/pages/42/42.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/42/42.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/42/42.wxml b/miniprogram-3/miniprogram/pages/42/42.wxml new file mode 100644 index 0000000..ccf8a41 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/42/42.wxml @@ -0,0 +1,27 @@ + + + + + + + + + + + + +减一分 + + +姓名:{{dataobj.name}} +学号:{{dataobj.xuehao}} + + 分数:{{dataobj.score}} + + + + + + diff --git a/miniprogram-3/miniprogram/pages/42/42.wxss b/miniprogram-3/miniprogram/pages/42/42.wxss new file mode 100644 index 0000000..302efc5 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/42/42.wxss @@ -0,0 +1,6 @@ +/* pages/1/1.wxss */ +.box{ + width: auto; + height: 100rpx; + background-color:white; +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/5-1/5-1.js b/miniprogram-3/miniprogram/pages/5-1/5-1.js new file mode 100644 index 0000000..812432e --- /dev/null +++ b/miniprogram-3/miniprogram/pages/5-1/5-1.js @@ -0,0 +1,83 @@ +// pages/5-1/5-1.js +const db = wx.cloud.database(); +const app = getApp(); // 获取全局应用实例 + +Page({ + data: { + dataobj: undefined + }, + get_data() { + const chosenIndex = app.globalData.chosen_index; // 获取 chosen_index + db.collection("demolist").where({ index: chosenIndex }).get({ + success: res => { + console.log(res); + if (res.data.length > 0) { + this.setData({ + dataobj: res.data[0] + }, () => { + console.log(this.data.dataobj); + }); + } else { + console.log("没有数据"); + } + } + }); + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + this.get_data() + + }, + + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/5-1/5-1.json b/miniprogram-3/miniprogram/pages/5-1/5-1.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/5-1/5-1.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/5-1/5-1.wxml b/miniprogram-3/miniprogram/pages/5-1/5-1.wxml new file mode 100644 index 0000000..d2eaf7e --- /dev/null +++ b/miniprogram-3/miniprogram/pages/5-1/5-1.wxml @@ -0,0 +1,26 @@ + + + + + + + + + + + + +虽然,加0.5分 + +姓名:{{dataobj.name}} +学号:{{dataobj.xuehao}} + + 分数:{{dataobj.score}} + + + + + + diff --git a/miniprogram-3/miniprogram/pages/5-1/5-1.wxss b/miniprogram-3/miniprogram/pages/5-1/5-1.wxss new file mode 100644 index 0000000..302efc5 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/5-1/5-1.wxss @@ -0,0 +1,6 @@ +/* pages/1/1.wxss */ +.box{ + width: auto; + height: 100rpx; + background-color:white; +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/52/52.js b/miniprogram-3/miniprogram/pages/52/52.js new file mode 100644 index 0000000..5f07c93 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/52/52.js @@ -0,0 +1,82 @@ +// pages/52/52.js +const db = wx.cloud.database(); +const app = getApp(); // 获取全局应用实例 + +Page({ + data: { + dataobj: undefined + }, + get_data() { + const chosenIndex = app.globalData.chosen_index; // 获取 chosen_index + db.collection("demolist").where({ index: chosenIndex }).get({ + success: res => { + console.log(res); + if (res.data.length > 0) { + this.setData({ + dataobj: res.data[0] + }, () => { + console.log(this.data.dataobj); + }); + } else { + console.log("没有数据"); + } + } + }); + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + this.get_data() + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/52/52.json b/miniprogram-3/miniprogram/pages/52/52.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/52/52.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/52/52.wxml b/miniprogram-3/miniprogram/pages/52/52.wxml new file mode 100644 index 0000000..45b2609 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/52/52.wxml @@ -0,0 +1,26 @@ + + + + + + + + + + + + +虽然,加1分 + +姓名:{{dataobj.name}} +学号:{{dataobj.xuehao}} + + 分数:{{dataobj.score}} + + + + + + diff --git a/miniprogram-3/miniprogram/pages/52/52.wxss b/miniprogram-3/miniprogram/pages/52/52.wxss new file mode 100644 index 0000000..302efc5 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/52/52.wxss @@ -0,0 +1,6 @@ +/* pages/1/1.wxss */ +.box{ + width: auto; + height: 100rpx; + background-color:white; +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/53/53.js b/miniprogram-3/miniprogram/pages/53/53.js new file mode 100644 index 0000000..de35a24 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/53/53.js @@ -0,0 +1,82 @@ +// pages/53/53.js +const db = wx.cloud.database(); +const app = getApp(); // 获取全局应用实例 + +Page({ + data: { + dataobj: undefined + }, + get_data() { + const chosenIndex = app.globalData.chosen_index; // 获取 chosen_index + db.collection("demolist").where({ index: chosenIndex }).get({ + success: res => { + console.log(res); + if (res.data.length > 0) { + this.setData({ + dataobj: res.data[0] + }, () => { + console.log(this.data.dataobj); + }); + } else { + console.log("没有数据"); + } + } + }); + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + this.get_data() + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/53/53.json b/miniprogram-3/miniprogram/pages/53/53.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/53/53.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/53/53.wxml b/miniprogram-3/miniprogram/pages/53/53.wxml new file mode 100644 index 0000000..e6475af --- /dev/null +++ b/miniprogram-3/miniprogram/pages/53/53.wxml @@ -0,0 +1,26 @@ + + + + + + + + + + + + +虽然,加2分 + +姓名:{{dataobj.name}} +学号:{{dataobj.xuehao}} + + 分数:{{dataobj.score}} + + + + + + diff --git a/miniprogram-3/miniprogram/pages/53/53.wxss b/miniprogram-3/miniprogram/pages/53/53.wxss new file mode 100644 index 0000000..302efc5 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/53/53.wxss @@ -0,0 +1,6 @@ +/* pages/1/1.wxss */ +.box{ + width: auto; + height: 100rpx; + background-color:white; +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/54/54.js b/miniprogram-3/miniprogram/pages/54/54.js new file mode 100644 index 0000000..1a4bc9b --- /dev/null +++ b/miniprogram-3/miniprogram/pages/54/54.js @@ -0,0 +1,82 @@ +// pages/54/54.js +const db = wx.cloud.database(); +const app = getApp(); // 获取全局应用实例 + +Page({ + data: { + dataobj: undefined + }, + get_data() { + const chosenIndex = app.globalData.chosen_index; // 获取 chosen_index + db.collection("demolist").where({ index: chosenIndex }).get({ + success: res => { + console.log(res); + if (res.data.length > 0) { + this.setData({ + dataobj: res.data[0] + }, () => { + console.log(this.data.dataobj); + }); + } else { + console.log("没有数据"); + } + } + }); + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + this.get_data() + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/54/54.json b/miniprogram-3/miniprogram/pages/54/54.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/54/54.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/54/54.wxml b/miniprogram-3/miniprogram/pages/54/54.wxml new file mode 100644 index 0000000..66f8dbc --- /dev/null +++ b/miniprogram-3/miniprogram/pages/54/54.wxml @@ -0,0 +1,26 @@ + + + + + + + + + + + + +虽然,加3分 + +姓名:{{dataobj.name}} +学号:{{dataobj.xuehao}} + + 分数:{{dataobj.score}} + + + + + + diff --git a/miniprogram-3/miniprogram/pages/54/54.wxss b/miniprogram-3/miniprogram/pages/54/54.wxss new file mode 100644 index 0000000..302efc5 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/54/54.wxss @@ -0,0 +1,6 @@ +/* pages/1/1.wxss */ +.box{ + width: auto; + height: 100rpx; + background-color:white; +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/index/constants.js b/miniprogram-3/miniprogram/pages/index/constants.js new file mode 100644 index 0000000..328a02c --- /dev/null +++ b/miniprogram-3/miniprogram/pages/index/constants.js @@ -0,0 +1,279 @@ +/** + * 快速开始教程知识点 + */ +const QuickStartPoints = [ + { id: '1', title: '无需搭建服务器,快速构建小程序' }, + { id: '2', title: '免登录、免鉴权调用微信开放服务' }, +]; + +function highlightText(content) { + return ` \`${content}\` `; +} + +/** + * 快速开始教程步骤 + */ +const QuickStartSteps = [ + { + id: '1', + title: '创建列表页面并初始化数据', + contents: [ + { + type: 'text', + content: `编辑教程内置的页面${highlightText('miniprogram/pages/goods-list/index.js')},在${highlightText('Page')}的${highlightText('data')}配置项中添加初始化数据${highlightText('goodsList')},代码如下所示。该页面将用于展示商品列表。`, + }, + { + type: 'code', + content: ` +Page({ + data: { + goodsList: [{ + _id: '1', + title: '商品1', + price: 1, + }], + }, +}) + `, + }, + { + type: 'text', + content: '保存文件,查看页面,可以看到列表渲染出初始数据。', + }, + { + type: 'image', + content: 'list-init.png', + } + ], + showJumpButton: true, + }, + { + id: '2', + title: '实现并部署一个后台接口', + contents: [ + { + type: 'text', + content: `编辑教程内置的后台接口文件${highlightText('cloudfunctions/quickstartFunctions/fetchGoodsList/index.js')},使用下面代码覆盖文件内容,返回一些模拟的商品列表数据。`, + }, + { + type: 'code', + content: ` +const cloud = require('wx-server-sdk'); +cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }); +exports.main = async (event, context) => { + return { + dataList: [ + { _id: '1', title: '微信气泡徽章', price: 1800 }, + { _id: '2', title: '微信地球鼠标垫', price: 5800 }, + { _id: '3', title: '微信黄脸大贴纸', price: 500 } + ], + } +}; + ` + }, + { + type: 'text', + content: `保存文件后,在${highlightText('cloudfunctions/quickstartFunctions')}目录右键,选择【上传并部署-云端安装依赖】,等待进度完成,即完成后端接口的开发与部署。`, + }, + { + type: 'image', + content: 'function_deploy.png', + }, + { + type: 'text', + content: `注:新用户部署时会提示创建云开发环境。新用户可免费开通云开发环境并试用。`, + }, + { + type: 'image', + content: 'create_env.png', + }, + { + type: 'text', + content: `新用户开通环境后在${highlightText('cloudfunctions')}目录右键,选择当前环境为新建的环境。`, + }, + { + type: 'image', + content: 'env-select.png', + }, + ], + showJumpButton: false, + }, + { + id: '3', + title: '小程序端调用后台接口', + contents: [ + { + type: 'text', + content: `编辑列表页${highlightText('miniprogram/pages/goods-list/index.js')},在 Page 下新增一个方法${highlightText('fetchGoodsList')},用于调用后端接口,并在 Page 的${highlightText('onLoad')}生命周期调用该方法:`, + }, + { + type: 'code', + content: ` +async fetchGoodsList() { + this.setData({ isLoading: true }); + const res = await wx.cloud.callFunction({ + name: 'quickstartFunctions', + data: { type: 'fetchGoodsList' }, + }); + const goodsList = res?.result?.dataList || []; + this.setData({ + isLoading: false, + goodsList + }); +}, + ` + }, + { + type: 'code', + content: ` +onLoad() { + this.fetchGoodsList(); +}, + `, + }, + { + type: 'text', + content: `保存文件后,查看列表页,可以看到调用后台接口获取到了模拟数据并正确显示。`, + }, + { + type: 'image', + content: 'list-scf.png', + } + ], + showJumpButton: true, + }, + { + id: '4', + title: '从数据库中读取真实数据', + contents: [ + { + type: 'text', + content: '前面步骤中,后台接口返回的是模拟数据,实际开发中,我们需要利用数据库实现持久存储,下面我们来通过云开发数据库能力实现这个效果。', + }, + { + type: 'text', + content: `点击开发者工具顶部的【云开发】按钮,打开云开发控制台,选中【数据库】,新增一个商品集合命名${highlightText('goods')},并添加若干条记录。注:本示例中,集合中的记录请保证具有${highlightText('title')}和${highlightText('price')}字段。`, + }, + { + type: 'image', + content: 'scf-enter.png', + }, + { + type: 'image', + content: 'database_add.png', + }, + { + type: 'text', + content: `编辑后台接口代码${highlightText('cloudfunctions/quickstartFunctions/fetchGoodsList/index.js')},用下面代码覆盖文件内容,用于读取数据库中数据:`, + }, + { + type: 'code', + content: ` +const cloud = require('wx-server-sdk'); +cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }); + +const db = cloud.database(); + +exports.main = async (event, context) => { + const result = await db.collection('goods') + .skip(0) + .limit(10) + .get(); + return { + dataList: result?.data, + }; +}; + `, + }, + { + type: 'text', + content: `保存文件后,在${highlightText('cloudfunctions/quickstartFunctions')}目录右键,选择【上传并部署-云端安装依赖】,重新部署后台接口。`, + }, + { + type: 'text', + content: '查看页面,可以看到正确获取数据库中的数据并显示在列表中。', + }, + { + type: 'image', + content: 'list-database.png', + } + ], + showJumpButton: true, + }, + { + id: '5', + title: '调用开放接口生成小程序码', + contents: [ + { + type: 'text', + content: '实际小程序开发中,我们通常会对小程序进行传播分享。下面我们利用免鉴权的云调用能力实现小程序码。', + }, + { + type: 'text', + content: `编辑教程内置的接口文件${highlightText('cloudfunctions/quickstartFunctions/genMpQrcode/index.js')},用以下代码覆盖文件内容。该接口用于生成小程序码图片并上传到云存储保存。`, + }, + { + type: 'code', + content: ` +const cloud = require('wx-server-sdk'); + +cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }); + +exports.main = async (event, context) => { + const pagePath = event.pagePath; + // 获取小程序二维码的buffer + const resp = await cloud.openapi.wxacode.get({ + path: pagePath, + }); + const { buffer } = resp; + // 将图片上传云存储空间 + const upload = await cloud.uploadFile({ + cloudPath: String(pagePath).replaceAll('/', '_') + '.png', + fileContent: buffer + }); + return upload.fileID; +}; + `, + }, + { + type: 'text', + content: `保存文件后,在${highlightText('cloudfunctions/quickstartFunctions')}目录右键,选择【上传并部署-云端安装依赖】,部署该接口。`, + }, + { + type: 'text', + content: `编辑商品列表页${highlightText('miniprogram/pages/goods-list/index.js')},在 Page 配置中新增一个方法${highlightText('generateMPCode')},用于调用接口获取小程序码:`, + }, + { + type: 'code', + content: ` +async generateMPCode() { + wx.showLoading(); + const resp = await wx.cloud.callFunction({ + name: 'quickstartFunctions', + data: { + type: 'genMpQrcode', + pagePath: 'pages/goods-list/index', + } + }); + this.setData({ codeModalVisible: true, codeImageSrc: resp?.result }); + wx.hideLoading(); +}, + ` + }, + { + type: 'text', + content: `保存文件后,在商品列表页点击【分享】按钮,会调用${highlightText('generateMPCode')}方法获取小程序码并弹框显示。`, + }, + { + type: 'image', + content: 'list-share.png', + } + ], + showJumpButton: true, + }, +]; + +module.exports = { + QuickStartPoints, + QuickStartSteps, +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/index/index.js b/miniprogram-3/miniprogram/pages/index/index.js new file mode 100644 index 0000000..34a036f --- /dev/null +++ b/miniprogram-3/miniprogram/pages/index/index.js @@ -0,0 +1,75 @@ +Page({ + + /** + * 页面的初始数据 + */ + data: { + chosen_index2: 0 + }, + + test2() + { + const chosen_index2 = app.globalData.Paths; + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + chosen_index2 : getApp().globalData.chosen_index + + }) + + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/index/index.json b/miniprogram-3/miniprogram/pages/index/index.json new file mode 100644 index 0000000..bdf6915 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/index/index.json @@ -0,0 +1,6 @@ +{ + "usingComponents": { + "cloud-tip-modal": "/components/cloudTipModal/index" + }, + "navigationBarBackgroundColor": "#fff" +} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/index/index.wxml b/miniprogram-3/miniprogram/pages/index/index.wxml new file mode 100644 index 0000000..d9913b1 --- /dev/null +++ b/miniprogram-3/miniprogram/pages/index/index.wxml @@ -0,0 +1,5 @@ +云开发 +ani + + + nidsf{{chosen_index2}} \ No newline at end of file diff --git a/miniprogram-3/miniprogram/pages/index/index.wxss b/miniprogram-3/miniprogram/pages/index/index.wxss new file mode 100644 index 0000000..e69de29 diff --git a/miniprogram-3/miniprogram/sitemap.json b/miniprogram-3/miniprogram/sitemap.json new file mode 100644 index 0000000..27b2b26 --- /dev/null +++ b/miniprogram-3/miniprogram/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file diff --git a/miniprogram-3/project.config.json b/miniprogram-3/project.config.json new file mode 100644 index 0000000..1ee1388 --- /dev/null +++ b/miniprogram-3/project.config.json @@ -0,0 +1,76 @@ +{ + "miniprogramRoot": "miniprogram/", + "cloudfunctionRoot": "cloudfunctions/", + "setting": { + "urlCheck": true, + "es6": true, + "enhance": true, + "postcss": true, + "preloadBackgroundData": false, + "minified": true, + "newFeature": true, + "coverView": true, + "nodeModules": false, + "autoAudits": false, + "showShadowRootInWxmlPanel": true, + "scopeDataCheck": false, + "uglifyFileName": false, + "checkInvalidKey": true, + "checkSiteMap": true, + "uploadWithSourceMap": true, + "compileHotReLoad": false, + "useMultiFrameRuntime": true, + "useApiHook": true, + "useApiHostProcess": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "enableEngineNative": false, + "useIsolateContext": true, + "useCompilerModule": true, + "userConfirmedUseCompilerModuleSwitch": false, + "userConfirmedBundleSwitch": false, + "packNpmManually": false, + "packNpmRelationList": [], + "minifyWXSS": true + }, + "appid": "wx1b82b26a362cc917", + "projectname": "quickstart-wx-cloud", + "libVersion": "latest", + "cloudfunctionTemplateRoot": "cloudfunctionTemplate/", + "condition": { + "search": { + "list": [] + }, + "conversation": { + "list": [] + }, + "plugin": { + "list": [] + }, + "game": { + "list": [] + }, + "miniprogram": { + "list": [ + { + "id": -1, + "name": "db guide", + "pathName": "pages/databaseGuide/databaseGuide" + } + ] + } + }, + "compileType": "miniprogram", + "srcMiniprogramRoot": "miniprogram/", + "packOptions": { + "ignore": [], + "include": [] + }, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 2 + } +} \ No newline at end of file diff --git a/miniprogram-3/project.private.config.json b/miniprogram-3/project.private.config.json new file mode 100644 index 0000000..41a49d8 --- /dev/null +++ b/miniprogram-3/project.private.config.json @@ -0,0 +1,40 @@ +{ + "setting": { + "compileHotReLoad": true, + "urlCheck": true, + "bigPackageSizeSupport": true, + "skylineRenderEnable": false + }, + "condition": { + "miniprogram": { + "list": [ + { + "name": "首页-快速开始", + "pathName": "pages/index/index", + "query": "" + }, + { + "name": "商品列表", + "pathName": "pages/goods-list/index", + "query": "", + "scene": null + }, + { + "name": "云开发示例", + "pathName": "pages/examples/index", + "query": "", + "scene": null + }, + { + "name": "个人中心", + "pathName": "pages/user-center/index", + "query": "", + "scene": null + } + ] + } + }, + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "miniprogram-3", + "libVersion": "3.6.0" +} \ No newline at end of file diff --git a/miniprogram-3/uploadCloudFunction.sh b/miniprogram-3/uploadCloudFunction.sh new file mode 100644 index 0000000..df311b3 --- /dev/null +++ b/miniprogram-3/uploadCloudFunction.sh @@ -0,0 +1 @@ +${installPath} cloud functions deploy --e ${envId} --n quickstartFunctions --r --project ${projectPath} \ No newline at end of file