@ -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: {},
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"permissions": {
|
||||
"openapi": [
|
||||
"wxacode.get"
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
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 }
|
||||
],
|
||||
}
|
||||
};
|
@ -0,0 +1,18 @@
|
||||
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;
|
||||
};
|
||||
|
@ -0,0 +1,20 @@
|
||||
const cloud = require('wx-server-sdk');
|
||||
|
||||
cloud.init({
|
||||
env: cloud.DYNAMIC_CURRENT_ENV
|
||||
});
|
||||
|
||||
// 获取小程序二维码云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
// 获取小程序二维码的buffer
|
||||
const resp = await cloud.openapi.wxacode.get({
|
||||
path: 'pages/index/index'
|
||||
});
|
||||
const { buffer } = resp;
|
||||
// 将图片上传云存储空间
|
||||
const upload = await cloud.uploadFile({
|
||||
cloudPath: 'code.png',
|
||||
fileContent: buffer
|
||||
});
|
||||
return upload.fileID;
|
||||
};
|
@ -0,0 +1,17 @@
|
||||
const cloud = require('wx-server-sdk');
|
||||
|
||||
cloud.init({
|
||||
env: cloud.DYNAMIC_CURRENT_ENV
|
||||
});
|
||||
|
||||
// 获取openId云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
// 获取基础信息
|
||||
const wxContext = cloud.getWXContext();
|
||||
|
||||
return {
|
||||
openid: wxContext.OPENID,
|
||||
appid: wxContext.APPID,
|
||||
unionid: wxContext.UNIONID,
|
||||
};
|
||||
};
|
@ -0,0 +1,31 @@
|
||||
const getOpenId = require('./getOpenId/index');
|
||||
const getMiniProgramCode = require('./getMiniProgramCode/index');
|
||||
const createCollection = require('./createCollection/index');
|
||||
const selectRecord = require('./selectRecord/index');
|
||||
const updateRecord = require('./updateRecord/index');
|
||||
const sumRecord = require('./sumRecord/index');
|
||||
const fetchGoodsList = require('./fetchGoodsList/index');
|
||||
const genMpQrcode = require('./genMpQrcode/index');
|
||||
|
||||
// 云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
switch (event.type) {
|
||||
case 'getOpenId':
|
||||
return await getOpenId.main(event, context);
|
||||
case 'getMiniProgramCode':
|
||||
return await getMiniProgramCode.main(event, context);
|
||||
case 'createCollection':
|
||||
return await createCollection.main(event, context);
|
||||
case 'selectRecord':
|
||||
return await selectRecord.main(event, context);
|
||||
case 'updateRecord':
|
||||
return await updateRecord.main(event, context);
|
||||
case 'sumRecord':
|
||||
return await sumRecord.main(event, context);
|
||||
case 'fetchGoodsList':
|
||||
return await fetchGoodsList.main(event, context);
|
||||
case 'genMpQrcode':
|
||||
return await genMpQrcode.main(event, context);
|
||||
}
|
||||
};
|
||||
|
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "quickstartFunctions",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wx-server-sdk": "~2.4.0"
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
const cloud = require('wx-server-sdk');
|
||||
|
||||
cloud.init({
|
||||
env: cloud.DYNAMIC_CURRENT_ENV
|
||||
});
|
||||
const db = cloud.database();
|
||||
|
||||
// 查询数据库集合云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
// 返回数据库查询结果
|
||||
return await db.collection('sales').get();
|
||||
};
|
@ -0,0 +1,18 @@
|
||||
const cloud = require('wx-server-sdk');
|
||||
|
||||
cloud.init({
|
||||
env: cloud.DYNAMIC_CURRENT_ENV
|
||||
});
|
||||
const db = cloud.database();
|
||||
const $ = db.command.aggregate;
|
||||
|
||||
// 聚合记录云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
// 返回数据库聚合结果
|
||||
return db.collection('sales').aggregate()
|
||||
.group({
|
||||
_id: '$region',
|
||||
sum: $.sum('$sales')
|
||||
})
|
||||
.end();
|
||||
};
|
@ -0,0 +1,32 @@
|
||||
const cloud = require('wx-server-sdk');
|
||||
|
||||
cloud.init({
|
||||
env: cloud.DYNAMIC_CURRENT_ENV
|
||||
});
|
||||
const db = cloud.database();
|
||||
|
||||
// 修改数据库信息云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
try {
|
||||
// 遍历修改数据库信息
|
||||
for (let i = 0; i < event.data.length; i++) {
|
||||
await db.collection('sales').where({
|
||||
_id: event.data[i]._id
|
||||
})
|
||||
.update({
|
||||
data: {
|
||||
sales: event.data[i].sales
|
||||
},
|
||||
});
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
data: event.data
|
||||
};
|
||||
} catch (e) {
|
||||
return {
|
||||
success: false,
|
||||
errMsg: e
|
||||
};
|
||||
}
|
||||
};
|
@ -0,0 +1,51 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index",
|
||||
"pages/goods-list/index",
|
||||
"pages/examples/index",
|
||||
"pages/user-center/index",
|
||||
"pages/exampleDetail/index",
|
||||
"pages/deployService/index",
|
||||
"pages/updateRecord/index",
|
||||
"pages/updateRecordResult/index",
|
||||
"pages/updateRecordSuccess/index",
|
||||
"pages/sumRecord/index",
|
||||
"pages/sumRecordResult/index",
|
||||
"pages/web/index"
|
||||
],
|
||||
"window": {
|
||||
"backgroundColor": "#F6F6F6",
|
||||
"backgroundTextStyle": "light",
|
||||
"navigationBarBackgroundColor": "#F6F6F6",
|
||||
"navigationBarTitleText": "云开发 QuickStart",
|
||||
"navigationBarTextStyle": "black"
|
||||
},
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"style": "v2",
|
||||
"lazyCodeLoading": "requiredComponents",
|
||||
"tabBar": {
|
||||
"color": "#A2A9B0",
|
||||
"selectedColor": "#07C160",
|
||||
"backgroundColor": "#ffffff",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/index/index",
|
||||
"text": "快速开始",
|
||||
"iconPath": "images/icons/home.png",
|
||||
"selectedIconPath": "images/icons/home-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/examples/index",
|
||||
"text": "云开发示例",
|
||||
"iconPath": "images/icons/examples.png",
|
||||
"selectedIconPath": "images/icons/examples-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/user-center/index",
|
||||
"text": "我",
|
||||
"iconPath": "images/icons/usercenter.png",
|
||||
"selectedIconPath": "images/icons/usercenter-active.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/**app.wxss**/
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
button {
|
||||
background: initial;
|
||||
}
|
||||
|
||||
button:focus{
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
button::after{
|
||||
border: none;
|
||||
}
|
||||
|
||||
|
||||
page {
|
||||
background: #f6f6f6;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
// 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: {
|
||||
onChangeShowUploadTip() {
|
||||
this.setData({
|
||||
showUploadTip: !this.data.showUploadTip
|
||||
});
|
||||
},
|
||||
|
||||
copyShell() {
|
||||
wx.setClipboardData({
|
||||
data: this.data.tipText,
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
});
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"component": true
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<!--miniprogram/components/cloudTipModal/index.wxml-->
|
||||
<view class="install_tip" wx:if="{{showUploadTip}}">
|
||||
<view class="install_tip_back"></view>
|
||||
<view class="install_tip_detail">
|
||||
<view class="install_tip_detail_title">体验前需部署云资源</view>
|
||||
<view class="install_tip_detail_tip">请开启调试器进入终端窗口,复制并运行以下命令</view>
|
||||
<view class="install_tip_detail_shell">
|
||||
{{tipText}}
|
||||
<view bindtap="copyShell" class="install_tip_detail_copy">复制</view>
|
||||
</view>
|
||||
<view bindtap="onChangeShowUploadTip" class="install_tip_detail_button">已执行命令</view>
|
||||
</view>
|
||||
</view>
|
@ -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;
|
||||
}
|
@ -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 });
|
||||
}
|
||||
}
|
||||
});
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"component": true
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
<view class="modal_container" wx:if="{{ modalVisible }}">
|
||||
<view class="icon_close" bind:tap="onClose">
|
||||
<view>X</view>
|
||||
</view>
|
||||
<view class="image_container">
|
||||
<image class="code_img" src="{{ imageSrc }}" />
|
||||
</view>
|
||||
</view>
|
@ -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;
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
const envList = [];
|
||||
const isMac = false;
|
||||
module.exports = {
|
||||
envList,
|
||||
isMac
|
||||
};
|
After Width: | Height: | Size: 906 B |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 63 KiB |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 666 B |
After Width: | Height: | Size: 376 B |
After Width: | Height: | Size: 779 B |
After Width: | Height: | Size: 789 B |
After Width: | Height: | Size: 917 B |
After Width: | Height: | Size: 888 B |
After Width: | Height: | Size: 873 B |
After Width: | Height: | Size: 879 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 711 B |
After Width: | Height: | Size: 620 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 81 KiB |
After Width: | Height: | Size: 137 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 147 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 140 KiB |
@ -0,0 +1,11 @@
|
||||
// miniprogram/pages/deployService/index.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
});
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<!--miniprogram/pages/deployService/index.wxml-->
|
||||
<view class="page">
|
||||
<view class="title">功能介绍</view>
|
||||
<view class="info">云托管是全托管的容器服务,支持任何语言及框架运行,只需将已有业务代码打包上传,即可快速迁移。</view>
|
||||
<view class="title">如何体验</view>
|
||||
<view class="info">步骤一:切换按量付费,打开“云开发控制台>设置>环境设置”找到按量付费,点击切换。</view>
|
||||
<image class="img" src="../../images/deploy_step1.png"></image>
|
||||
<view class="info">步骤二:开通云托管,体验相关能力</view>
|
||||
<image class="img" src="../../images/deploy_step2.png"></image>
|
||||
</view>
|
@ -0,0 +1,29 @@
|
||||
/* miniprogram/pages/deployService/index.wxss */
|
||||
page {
|
||||
background-color: white;
|
||||
padding-bottom: 50px;
|
||||
}
|
||||
|
||||
.page {
|
||||
padding: 0 32px;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin-top: 16px;
|
||||
font-size: 17px;
|
||||
font-family: PingFang SC;
|
||||
font-weight: 500;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.info {
|
||||
margin-top: 12px;
|
||||
font-size: 17px;
|
||||
font-family: PingFang SC;
|
||||
font-weight: 400;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.img {
|
||||
margin-top: 12px;
|
||||
}
|
@ -0,0 +1,172 @@
|
||||
// pages/exampleDetail/index.js
|
||||
Page({
|
||||
data: {
|
||||
type: '',
|
||||
envId: '',
|
||||
showUploadTip: false,
|
||||
|
||||
haveGetOpenId: false,
|
||||
openId: '',
|
||||
|
||||
haveGetCodeSrc: false,
|
||||
codeSrc: '',
|
||||
|
||||
haveGetRecord: false,
|
||||
record: '',
|
||||
|
||||
haveGetImgSrc: false,
|
||||
imgSrc: '',
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({ type: options?.type, envId: options?.envId });
|
||||
},
|
||||
|
||||
getOpenId() {
|
||||
wx.showLoading({
|
||||
title: '',
|
||||
});
|
||||
wx.cloud.callFunction({
|
||||
name: 'quickstartFunctions',
|
||||
config: {
|
||||
env: this.data.envId
|
||||
},
|
||||
data: {
|
||||
type: 'getOpenId'
|
||||
}
|
||||
}).then((resp) => {
|
||||
this.setData({
|
||||
haveGetOpenId: true,
|
||||
openId: resp.result.openid
|
||||
});
|
||||
wx.hideLoading();
|
||||
}).catch((e) => {
|
||||
this.setData({
|
||||
showUploadTip: true
|
||||
});
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
|
||||
clearOpenId() {
|
||||
this.setData({
|
||||
haveGetOpenId: false,
|
||||
openId: ''
|
||||
});
|
||||
},
|
||||
|
||||
getCodeSrc() {
|
||||
wx.showLoading({
|
||||
title: '',
|
||||
});
|
||||
wx.cloud.callFunction({
|
||||
name: 'quickstartFunctions',
|
||||
config: {
|
||||
env: this.data.envId
|
||||
},
|
||||
data: {
|
||||
type: 'getMiniProgramCode'
|
||||
}
|
||||
}).then((resp) => {
|
||||
this.setData({
|
||||
haveGetCodeSrc: true,
|
||||
codeSrc: resp.result
|
||||
});
|
||||
wx.hideLoading();
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
this.setData({
|
||||
showUploadTip: true
|
||||
});
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
|
||||
clearCodeSrc() {
|
||||
this.setData({
|
||||
haveGetCodeSrc: false,
|
||||
codeSrc: ''
|
||||
});
|
||||
},
|
||||
|
||||
getRecord() {
|
||||
wx.showLoading({
|
||||
title: '',
|
||||
});
|
||||
wx.cloud.callFunction({
|
||||
name: 'quickstartFunctions',
|
||||
config: {
|
||||
env: this.data.envId
|
||||
},
|
||||
data: {
|
||||
type: 'selectRecord'
|
||||
}
|
||||
}).then((resp) => {
|
||||
this.setData({
|
||||
haveGetRecord: true,
|
||||
record: resp.result.data
|
||||
});
|
||||
wx.hideLoading();
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
this.setData({
|
||||
showUploadTip: true
|
||||
});
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
|
||||
clearRecord() {
|
||||
this.setData({
|
||||
haveGetRecord: false,
|
||||
record: ''
|
||||
});
|
||||
},
|
||||
|
||||
uploadImg() {
|
||||
wx.showLoading({
|
||||
title: '',
|
||||
});
|
||||
// 让用户选择一张图片
|
||||
wx.chooseImage({
|
||||
count: 1,
|
||||
success: chooseResult => {
|
||||
// 将图片上传至云存储空间
|
||||
wx.cloud.uploadFile({
|
||||
// 指定上传到的云路径
|
||||
cloudPath: 'my-photo.png',
|
||||
// 指定要上传的文件的小程序临时文件路径
|
||||
filePath: chooseResult.tempFilePaths[0],
|
||||
config: {
|
||||
env: this.data.envId
|
||||
}
|
||||
}).then(res => {
|
||||
console.log('上传成功', res);
|
||||
this.setData({
|
||||
haveGetImgSrc: true,
|
||||
imgSrc: res.fileID
|
||||
});
|
||||
wx.hideLoading();
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
clearImgSrc() {
|
||||
this.setData({
|
||||
haveGetImgSrc: false,
|
||||
imgSrc: ''
|
||||
});
|
||||
},
|
||||
|
||||
goOfficialWebsite() {
|
||||
const url = 'https://docs.cloudbase.net/toolbox/quick-start';
|
||||
wx.navigateTo({
|
||||
url: `../web/index?url=${url}`,
|
||||
});
|
||||
},
|
||||
|
||||
})
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"cloud-tip-modal": "/components/cloudTipModal/index"
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
page {
|
||||
background-color: white;
|
||||
padding-bottom: 50px;
|
||||
font-family: PingFang SC;
|
||||
}
|
||||
|
||||
.page-container {
|
||||
padding: 20rpx 40rpx;
|
||||
}
|
||||
|
||||
.tip {
|
||||
font-size: 23rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
width: 90%;
|
||||
text-align: center;
|
||||
margin: 30rpx auto 0 auto;
|
||||
}
|
||||
|
||||
.top_tip {
|
||||
font-size: 28rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
width: 90%;
|
||||
text-align: left;
|
||||
margin-top: 30rpx;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.box_text {
|
||||
background-color: white;
|
||||
text-align: center;
|
||||
padding: 300rpx 0;
|
||||
margin-top: 30rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.button {
|
||||
width: 300rpx;
|
||||
text-align: center;
|
||||
margin: 250rpx auto 0 auto;
|
||||
height: 80rpx;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
line-height: 80rpx;
|
||||
background-color: #07c160;
|
||||
}
|
||||
|
||||
.button_clear {
|
||||
width: 300rpx;
|
||||
text-align: center;
|
||||
margin: 250rpx auto 0 auto;
|
||||
height: 80rpx;
|
||||
color: #07c160;
|
||||
border-radius: 5px;
|
||||
line-height: 80rpx;
|
||||
background-color: rgba(0, 0, 0, 0.03);
|
||||
}
|
||||
|
||||
.line {
|
||||
height: 1rpx;
|
||||
width: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.code_box {
|
||||
text-align: center;
|
||||
background-color: white;
|
||||
margin-top: 30rpx;
|
||||
padding: 17rpx;
|
||||
}
|
||||
|
||||
.code_box_title {
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
font-size: 26rpx;
|
||||
margin-bottom: 20rpx;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.code_box_record {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.code_box_record_title {
|
||||
width: 33%;
|
||||
font-size: 26rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.code_box_record_detail {
|
||||
width: 33%;
|
||||
font-size: 26rpx;
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin-top: 16px;
|
||||
font-size: 36rpx;
|
||||
font-weight: 500;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.info {
|
||||
margin-top: 12px;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
line-height: 52rpx;
|
||||
}
|
||||
|
||||
.img {
|
||||
margin-top: 16px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.code_img {
|
||||
width: 360rpx;
|
||||
height: 360rpx;
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
// index.js
|
||||
// const app = getApp()
|
||||
const { envList } = require('../../envList.js');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
showUploadTip: false,
|
||||
powerList: [{
|
||||
title: '云函数',
|
||||
tip: '安全、免鉴权运行业务代码',
|
||||
showItem: false,
|
||||
item: [{
|
||||
type: 'getOpenId',
|
||||
title: '获取OpenId',
|
||||
},
|
||||
{
|
||||
type: 'getMiniProgramCode',
|
||||
title: '生成小程序码',
|
||||
},
|
||||
]
|
||||
}, {
|
||||
title: '数据库',
|
||||
tip: '安全稳定的文档型数据库',
|
||||
showItem: false,
|
||||
item: [
|
||||
{
|
||||
type: 'createCollection',
|
||||
title: '创建集合',
|
||||
}, {
|
||||
type: 'selectRecord',
|
||||
title: '查询记录',
|
||||
}, {
|
||||
title: '更新记录',
|
||||
page: 'updateRecord'
|
||||
}, {
|
||||
title: '聚合操作',
|
||||
page: 'sumRecord'
|
||||
}
|
||||
]
|
||||
}, {
|
||||
title: '云存储',
|
||||
tip: '自带CDN加速文件存储',
|
||||
showItem: false,
|
||||
item: [
|
||||
{
|
||||
type: 'uploadFile',
|
||||
title: '上传文件',
|
||||
}]
|
||||
}, {
|
||||
type: 'singleTemplate',
|
||||
title: '云模板',
|
||||
tip: '基于页面模板,快速配置、搭建小程序页面',
|
||||
tag: 'new',
|
||||
}, {
|
||||
type: 'cloudBackend',
|
||||
title: '云后台',
|
||||
tip: '开箱即用的小程序后台管理系统',
|
||||
}, {
|
||||
title: '云托管',
|
||||
tip: '不限语言的全托管容器服务',
|
||||
link: 'https://cloud.weixin.qq.com/cloudrun',
|
||||
}],
|
||||
envList,
|
||||
selectedEnv: envList?.[0],
|
||||
haveCreateCollection: false
|
||||
},
|
||||
|
||||
onClickPowerInfo(e) {
|
||||
const index = e.currentTarget.dataset.index;
|
||||
const powerList = this.data.powerList;
|
||||
const selectedItem = powerList[index];
|
||||
selectedItem.showItem = !selectedItem.showItem;
|
||||
if (selectedItem.link) {
|
||||
wx.navigateTo({
|
||||
url: `../web/index?url=${selectedItem.link}&title=${selectedItem.title}`,
|
||||
});
|
||||
} else if (selectedItem.type) {
|
||||
wx.navigateTo({
|
||||
url: `/pages/exampleDetail/index?envId=${this.data.selectedEnv?.envId}&type=${selectedItem.type}`,
|
||||
});
|
||||
} else if (selectedItem.page) {
|
||||
wx.navigateTo({
|
||||
url: `/pages/${selectedItem.page}/index`,
|
||||
});
|
||||
} else if (selectedItem.title === '数据库' && !this.data.haveCreateCollection) {
|
||||
this.onClickDatabase(powerList);
|
||||
} else {
|
||||
this.setData({
|
||||
powerList
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onChangeShowEnvChoose() {
|
||||
wx.showActionSheet({
|
||||
itemList: this.data.envList.map(i => i.alias),
|
||||
success: (res) => {
|
||||
this.onChangeSelectedEnv(res.tapIndex);
|
||||
},
|
||||
fail(res) {
|
||||
console.log(res.errMsg);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onChangeSelectedEnv(index) {
|
||||
if (this.data.selectedEnv?.envId === this.data.envList?.[index]?.envId) {
|
||||
return;
|
||||
}
|
||||
const powerList = this.data.powerList;
|
||||
powerList.forEach(i => {
|
||||
i.showItem = false;
|
||||
});
|
||||
this.setData({
|
||||
selectedEnv: this.data.envList[index],
|
||||
powerList,
|
||||
haveCreateCollection: false
|
||||
});
|
||||
},
|
||||
|
||||
jumpPage(e) {
|
||||
const { type, page } = e.currentTarget.dataset;
|
||||
if (type) {
|
||||
wx.navigateTo({
|
||||
url: `/pages/exampleDetail/index?envId=${this.data.selectedEnv?.envId}&type=${type}`,
|
||||
});
|
||||
} else {
|
||||
wx.navigateTo({
|
||||
url: `/pages/${page}/index?envId=${this.data.selectedEnv?.envId}`,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onClickDatabase(powerList) {
|
||||
wx.showLoading({
|
||||
title: '',
|
||||
});
|
||||
wx.cloud.callFunction({
|
||||
name: 'quickstartFunctions',
|
||||
config: {
|
||||
env: this.data.selectedEnv?.envId
|
||||
},
|
||||
data: {
|
||||
type: 'createCollection'
|
||||
}
|
||||
}).then((resp) => {
|
||||
if (resp.result.success) {
|
||||
this.setData({
|
||||
haveCreateCollection: true
|
||||
});
|
||||
}
|
||||
this.setData({
|
||||
powerList
|
||||
});
|
||||
wx.hideLoading();
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
this.setData({
|
||||
showUploadTip: true
|
||||
});
|
||||
wx.hideLoading();
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"navigationBarTitleText": "云开发示例",
|
||||
"usingComponents": {
|
||||
"cloud-tip-modal": "/components/cloudTipModal/index"
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<!--index.wxml-->
|
||||
<view class="container">
|
||||
<view class="title">快速了解云开发</view>
|
||||
<view class="top_tip">免鉴权接口调用 免部署后台 高并发</view>
|
||||
<view class="power" wx:key="title" wx:for="{{powerList}}" wx:for-item="power">
|
||||
<view class="power_info" data-index="{{index}}" data-type="{{ power.type }}" bindtap="onClickPowerInfo">
|
||||
<view class="power_info_text">
|
||||
<view class="power_info_text_title">
|
||||
{{power.title}}
|
||||
<view class="power_info_text_tag" wx:if="{{power.tag}}">{{power.tag}}</view>
|
||||
</view>
|
||||
<view class="power_info_text_tip">{{power.tip}}</view>
|
||||
</view>
|
||||
<image wx:if="{{!power.showItem && power.item.length}}" class="power_info_more" src="../../images/arrow.svg"></image>
|
||||
<image wx:if="{{power.showItem && power.item.length}}" class="power_info_less" src="../../images/arrow.svg"></image>
|
||||
<image wx:if="{{!power.item.length}}" class="power_item_icon" src="../../images/arrow.svg"></image>
|
||||
</view>
|
||||
<view wx:if="{{power.showItem}}">
|
||||
<view wx:key="title" wx:for="{{power.item}}">
|
||||
<view class="line"></view>
|
||||
<view class="power_item" bindtap="jumpPage" data-type="{{ item.type }}" data-page="{{item.page}}">
|
||||
<view class="power_item_title">{{item.title}}</view>
|
||||
<image class="power_item_icon" src="../../images/arrow.svg"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="environment" bindtap="onChangeShowEnvChoose">当前环境 {{ selectedEnv.alias }}</view>
|
||||
|
||||
<cloud-tip-modal showUploadTipProps="{{showUploadTip}}"></cloud-tip-modal>
|
||||
|
||||
</view>
|
@ -0,0 +1,132 @@
|
||||
/**index.wxss**/
|
||||
|
||||
page {
|
||||
padding-top: 54rpx;
|
||||
background-color: #f6f6f6;
|
||||
padding-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.container {
|
||||
font-family: PingFang SC;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-family: PingFang SC;
|
||||
font-weight: 500;
|
||||
color: #000000;
|
||||
font-size: 44rpx;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.top_tip {
|
||||
font-size: 28rpx;
|
||||
font-family: PingFang SC;
|
||||
font-weight: 400;
|
||||
color: #888888;
|
||||
margin-bottom: 28rpx;
|
||||
}
|
||||
|
||||
.examples_container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.example_item {
|
||||
border: 3rpx solid #e5e5e5;
|
||||
border-radius: 10rpx;
|
||||
padding: 24rpx;
|
||||
width: 90%;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.power {
|
||||
margin-top: 30rpx;
|
||||
border-radius: 5px;
|
||||
background-color: white;
|
||||
width: 93%;
|
||||
padding-bottom: 1rpx;
|
||||
}
|
||||
|
||||
.power_info {
|
||||
display: flex;
|
||||
padding: 30rpx 25rpx;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.power_info_more {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.power_info_less {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
transform: rotate(270deg);
|
||||
}
|
||||
|
||||
.power_info_text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.power_info_text_title {
|
||||
margin-bottom: 10rpx;
|
||||
font-weight: 400;
|
||||
font-size: 32rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-family: "PingFang SC";
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.power_info_text_tag {
|
||||
margin-left: 20rpx;
|
||||
background-color: #fbe0e0;
|
||||
color: #e54545;
|
||||
padding: 0 7px;
|
||||
font-size: 14px;
|
||||
vertical-align: middle;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.power_info_text_tip {
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.power_item {
|
||||
padding: 30rpx 25rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.power_item_title {
|
||||
font-size: 28rpx;
|
||||
color: rgba(0, 0, 0, 0.9);
|
||||
}
|
||||
|
||||
.power_item_icon {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 95%;
|
||||
margin: 0 auto;
|
||||
height: 2rpx;
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.environment {
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
font-size: 24rpx;
|
||||
margin-top: 25%;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
Page({
|
||||
data: {
|
||||
goodsList: [{
|
||||
_id: '1',
|
||||
title: '商品1',
|
||||
price: 1,
|
||||
}],
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
// this.fetchGoodsList();
|
||||
},
|
||||
|
||||
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
|
||||
});
|
||||
},
|
||||
|
||||
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();
|
||||
},
|
||||
});
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"navigationBarTitleText": "商品列表",
|
||||
"usingComponents": {
|
||||
"cloud-tip-modal": "/components/cloudTipModal/index",
|
||||
"mp-code-modal": "/components/mpCodeModal/index"
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
/**index.wxss**/
|
||||
|
||||
page {
|
||||
padding-top: 54rpx;
|
||||
background-color: #fff;
|
||||
padding-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 100%;
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
.tip_text {
|
||||
width: 100%;
|
||||
height: 400rpx;
|
||||
line-height: 400rpx;
|
||||
text-align: center;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.goods-list {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.goods-item {
|
||||
width: calc(50% - 30px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.goods-item.even {
|
||||
margin-left: 20px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.goods-item.odd {
|
||||
margin-left: 10px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.goods-image {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.goods-title {
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.goods-bottom-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.goods-price {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
color: rgba(0, 0, 0, 0.9);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.price-symbol {
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.btn-share {
|
||||
width: 60px;
|
||||
height: 24px;
|
||||
line-height: 24px;
|
||||
border: 1px solid #07C160;
|
||||
text-align: center;
|
||||
border-radius: 2px;
|
||||
font-size: 28rpx;
|
||||
color: #07C160;
|
||||
}
|
||||
|
||||
|
||||
.bottom_tips {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
color: rgba(0, 0, 0, 0.7);
|
||||
position: absolute;
|
||||
bottom: 100rpx;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
@ -0,0 +1,279 @@
|
||||
/**
|
||||
* 快速开始教程知识点
|
||||
*/
|
||||
const QuickStartPoints = [
|
||||
{ id: '1', title: '无需搭建服务器,快速构建小程序' },
|
||||
{ id: '2', title: '免登录、免鉴权调用微信开放服务' },
|
||||
];
|
||||
|
||||
function highlightText(content) {
|
||||
return `<span> \`${content}\` </span>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 快速开始教程步骤
|
||||
*/
|
||||
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: `注:新用户部署时会提示创建云开发环境。<span style="color: red;">新用户可免费开通云开发环境并试用。</span>`,
|
||||
},
|
||||
{
|
||||
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,
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
Page({
|
||||
num1: 0,// 保存第一个数字
|
||||
num2: 0,//保存第二个数字
|
||||
num1Input: function (e) {
|
||||
this.num1 = Number(e.detail.value)
|
||||
},
|
||||
num2Input: function (e) {
|
||||
this.num2 = Number(e.detail.value)
|
||||
},
|
||||
data: {
|
||||
result: ''
|
||||
},
|
||||
compare: function () {
|
||||
var str = ''
|
||||
if (this.num1 > this.num2) {
|
||||
str = '第一个数大'
|
||||
} else if (this.num1 < this.num2) {
|
||||
str = '第二个数大'
|
||||
} else {
|
||||
str = '两数相等'
|
||||
}
|
||||
this.setData(
|
||||
{
|
||||
result: str
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"cloud-tip-modal": "/components/cloudTipModal/index"
|
||||
},
|
||||
"navigationBarTitleText": "比较数字大小"
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
<!--index.wxml-->
|
||||
<view>
|
||||
<view>请输入第一个数字</view>
|
||||
<input type="number" bindinput="num1Input"/>
|
||||
</view>
|
||||
<view>
|
||||
<view>请输入第二个数字</view>
|
||||
<input type="number"bindinput="num2Input"/>
|
||||
</view>
|
||||
<button bindtap="compare">比较</button>
|
||||
<view>
|
||||
<text wx:if="{{result}}">比较结果:{{result}}</text>
|
||||
</view>
|
||||
|
||||
|
@ -0,0 +1,221 @@
|
||||
/**index.wxss**/
|
||||
|
||||
page {
|
||||
/* padding-top: 54rpx; */
|
||||
padding-bottom: 60rpx;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.main {
|
||||
width: 90%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-family: PingFang SC;
|
||||
}
|
||||
|
||||
.image_container {
|
||||
margin-top: 48rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin-bottom: 20rpx;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
|
||||
.sub_title {
|
||||
font-size: 28rpx;
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
line-height: 52rpx;
|
||||
}
|
||||
|
||||
/* 一级标题字体 */
|
||||
.font_title_1 {
|
||||
font-weight: 500;
|
||||
color: #000;
|
||||
font-size: 48rpx;
|
||||
}
|
||||
|
||||
/* 二级标题字体 */
|
||||
.font_title_2 {
|
||||
color: #000;
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
font-family: "PingFang SC";
|
||||
}
|
||||
|
||||
/* 内容字体 */
|
||||
.font_content {
|
||||
font-size: 32rpx;
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
line-height: 52rpx;
|
||||
}
|
||||
|
||||
.seperator {
|
||||
border-top: 2rpx solid #dcdcdc;
|
||||
margin-top: 60rpx;
|
||||
margin-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.ability_container {
|
||||
border: 2rpx solid #e5e5e5;
|
||||
padding: 48rpx;
|
||||
box-sizing: border-box;
|
||||
border-radius: 20rpx;
|
||||
background-color: #f5f5f5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
|
||||
margin-top: 48rpx;
|
||||
}
|
||||
|
||||
.ability_title {
|
||||
font-size: 36rpx;
|
||||
font-weight: 500;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.ability_item {
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.ability_item::before {
|
||||
content: "";
|
||||
display: inline-block;
|
||||
width: 12rpx;
|
||||
height: 12rpx;
|
||||
border-radius: 50%;
|
||||
background-color: rgba(0, 0, 0, 0.6);
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
|
||||
.step_container {
|
||||
box-sizing: border-box;
|
||||
border-radius: 10rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.step_title,
|
||||
.step_content {
|
||||
padding: 8rpx;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.step_title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.step_id_container {
|
||||
display: flex;
|
||||
font-size: 28rpx;
|
||||
align-items: center;
|
||||
height: 36rpx;
|
||||
line-height: 36rpx;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.step_id_mark {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
border-radius: 2px 0px 0px 2px;
|
||||
color: #fff;
|
||||
height: 40rpx;
|
||||
line-height: 40rpx;
|
||||
width: 70rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.step_id_content {
|
||||
width: 50rpx;
|
||||
text-align: center;
|
||||
background-color: #fff;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
border: 1px solid rgba(0, 0, 0, 0.5);
|
||||
border-left: none;
|
||||
box-sizing: border-box;
|
||||
border-radius: 0px 2px 2px 0px;
|
||||
}
|
||||
|
||||
.step_content {
|
||||
background-color: #fff;
|
||||
color: #666;
|
||||
font-size: 28rpx;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.text_zone {
|
||||
margin-top: 20rpx;
|
||||
margin-bottom: 48rpx;
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
|
||||
.code_zone {
|
||||
background-color: #0E190E;
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
border-radius: 12rpx;
|
||||
padding: 0rpx 32rpx;
|
||||
box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
|
||||
position: relative;
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
|
||||
.image_zone {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
|
||||
.btn-copy {
|
||||
border-radius: 12rpx;
|
||||
height: 40rpx;
|
||||
width: 40rpx;
|
||||
position: absolute;
|
||||
right: 20rpx;
|
||||
bottom: 20rpx;
|
||||
}
|
||||
|
||||
.bottom-tip {
|
||||
margin-top: 10rpx;
|
||||
color: rgba(0, 0, 0, 0.9);
|
||||
font-size: 28rpx;
|
||||
line-height: 52rpx;
|
||||
}
|
||||
|
||||
.button {
|
||||
width: 70%;
|
||||
text-align: center;
|
||||
margin: 40rpx auto 0 auto;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
height: 80rpx;
|
||||
line-height: 80rpx;
|
||||
background-color: #07c160;
|
||||
}
|
||||
|
||||
.btn-view-demo-page {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
font-size: 26rpx;
|
||||
padding: 16rpx 0rpx;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #07c160;
|
||||
color: #07c160;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.with-margin {
|
||||
margin-top: 48rpx;
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
showUploadTip: false,
|
||||
haveGetRecord: false,
|
||||
envId: '',
|
||||
record: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
envId: options.envId
|
||||
});
|
||||
wx.showLoading({
|
||||
title: '',
|
||||
});
|
||||
wx.cloud.callFunction({
|
||||
name: 'quickstartFunctions',
|
||||
config: {
|
||||
env: this.data.envId
|
||||
},
|
||||
data: {
|
||||
type: 'selectRecord'
|
||||
}
|
||||
}).then((resp) => {
|
||||
this.setData({
|
||||
record: resp.result.data
|
||||
});
|
||||
wx.hideLoading();
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
this.setData({
|
||||
showUploadTip: true
|
||||
});
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
|
||||
sumRecord() {
|
||||
wx.navigateTo({
|
||||
url: `/pages/sumRecordResult/index?envId=${this.data.envId}`,
|
||||
});
|
||||
},
|
||||
|
||||
});
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"navigationBarTitleText": "聚合记录",
|
||||
"usingComponents": {
|
||||
"cloud-tip-modal": "/components/cloudTipModal/index"
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
.tip {
|
||||
font-size: 23rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
width: 90%;
|
||||
text-align: center;
|
||||
margin: 30rpx auto 0 auto;
|
||||
}
|
||||
|
||||
.top_tip {
|
||||
font-size: 28rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
width: 90%;
|
||||
text-align: left;
|
||||
margin-top: 30rpx;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.box_text {
|
||||
background-color: white;
|
||||
text-align: center;
|
||||
padding: 300rpx 0;
|
||||
margin-top: 30rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.code_box {
|
||||
text-align: center;
|
||||
background-color: white;
|
||||
margin-top: 30rpx;
|
||||
padding: 17rpx;
|
||||
}
|
||||
|
||||
.code_box_title {
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
font-size: 26rpx;
|
||||
margin-bottom: 20rpx;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.code_box_record {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.code_box_record_title {
|
||||
width: 33%;
|
||||
font-size: 26rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.code_box_record_detail {
|
||||
width: 33%;
|
||||
font-size: 26rpx;
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.button {
|
||||
width: 300rpx;
|
||||
text-align: center;
|
||||
margin: 250rpx auto 0 auto;
|
||||
height: 80rpx;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
line-height: 80rpx;
|
||||
background-color: #07c160;
|
||||
}
|
||||
|
||||
.button_clear {
|
||||
width: 300rpx;
|
||||
text-align: center;
|
||||
margin: 250rpx auto 0 auto;
|
||||
height: 80rpx;
|
||||
color: #07c160;
|
||||
border-radius: 5px;
|
||||
line-height: 80rpx;
|
||||
background-color: rgba(0, 0, 0, 0.03);
|
||||
}
|
||||
|
||||
.line {
|
||||
height: 1rpx;
|
||||
width: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
showUploadTip: false,
|
||||
haveGetRecord: false,
|
||||
envId: '',
|
||||
record: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
envId: options.envId
|
||||
});
|
||||
wx.showLoading({
|
||||
title: '',
|
||||
});
|
||||
wx.cloud.callFunction({
|
||||
name: 'quickstartFunctions',
|
||||
config: {
|
||||
env: this.data.envId
|
||||
},
|
||||
data: {
|
||||
type: 'sumRecord'
|
||||
}
|
||||
}).then((resp) => {
|
||||
this.setData({
|
||||
record: resp.result.list
|
||||
});
|
||||
wx.hideLoading();
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
this.setData({
|
||||
showUploadTip: true
|
||||
});
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
|
||||
goBack() {
|
||||
wx.navigateBack();
|
||||
},
|
||||
|
||||
});
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"navigationBarTitleText": "聚合记录",
|
||||
"usingComponents": {
|
||||
"cloud-tip-modal": "/components/cloudTipModal/index"
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
.tip {
|
||||
font-size: 23rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
width: 90%;
|
||||
text-align: center;
|
||||
margin: 30rpx auto 0 auto;
|
||||
}
|
||||
|
||||
.top_tip {
|
||||
font-size: 28rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
width: 90%;
|
||||
text-align: left;
|
||||
margin-top: 30rpx;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.box_text {
|
||||
background-color: white;
|
||||
text-align: center;
|
||||
padding: 300rpx 0;
|
||||
margin-top: 30rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.code_box {
|
||||
text-align: center;
|
||||
background-color: white;
|
||||
margin-top: 30rpx;
|
||||
padding: 17rpx;
|
||||
}
|
||||
|
||||
.code_box_title {
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
font-size: 26rpx;
|
||||
margin-bottom: 20rpx;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.code_box_record {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.code_box_record_title {
|
||||
width: 33%;
|
||||
font-size: 26rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.code_box_record_detail {
|
||||
width: 33%;
|
||||
font-size: 26rpx;
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.button {
|
||||
width: 300rpx;
|
||||
text-align: center;
|
||||
margin: 250rpx auto 0 auto;
|
||||
height: 80rpx;
|
||||
color: #07c160;
|
||||
border-radius: 5px;
|
||||
line-height: 80rpx;
|
||||
background-color: rgba(0, 0, 0, 0.03);
|
||||
}
|
||||
|
||||
.line {
|
||||
height: 1rpx;
|
||||
width: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
showUploadTip: false,
|
||||
haveGetRecord: false,
|
||||
envId: '',
|
||||
record: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
envId: options.envId
|
||||
});
|
||||
},
|
||||
|
||||
onShow() {
|
||||
wx.showLoading({
|
||||
title: '',
|
||||
});
|
||||
wx.cloud.callFunction({
|
||||
name: 'quickstartFunctions',
|
||||
config: {
|
||||
env: this.data.envId
|
||||
},
|
||||
data: {
|
||||
type: 'selectRecord'
|
||||
}
|
||||
}).then((resp) => {
|
||||
this.setData({
|
||||
record: resp.result.data
|
||||
});
|
||||
wx.hideLoading();
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
this.setData({
|
||||
showUploadTip: true
|
||||
});
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
|
||||
updateRecord() {
|
||||
wx.navigateTo({
|
||||
url: `/pages/updateRecordResult/index?envId=${this.data.envId}`,
|
||||
});
|
||||
},
|
||||
|
||||
});
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"navigationBarTitleText": "更新记录",
|
||||
"usingComponents": {
|
||||
"cloud-tip-modal": "/components/cloudTipModal/index"
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
.tip {
|
||||
font-size: 23rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
width: 90%;
|
||||
text-align: center;
|
||||
margin: 30rpx auto 0 auto;
|
||||
}
|
||||
|
||||
.top_tip {
|
||||
font-size: 28rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
width: 90%;
|
||||
text-align: left;
|
||||
margin-top: 30rpx;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.box_text {
|
||||
background-color: white;
|
||||
text-align: center;
|
||||
padding: 300rpx 0;
|
||||
margin-top: 30rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.code_box {
|
||||
text-align: center;
|
||||
background-color: white;
|
||||
margin-top: 30rpx;
|
||||
padding: 17rpx;
|
||||
}
|
||||
|
||||
.code_box_title {
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
font-size: 26rpx;
|
||||
margin-bottom: 20rpx;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.code_box_record {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.code_box_record_title {
|
||||
width: 33%;
|
||||
font-size: 26rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.code_box_record_detail {
|
||||
width: 33%;
|
||||
font-size: 26rpx;
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.button {
|
||||
width: 300rpx;
|
||||
text-align: center;
|
||||
margin: 250rpx auto 0 auto;
|
||||
height: 80rpx;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
line-height: 80rpx;
|
||||
background-color: #07c160;
|
||||
}
|
||||
|
||||
.button_clear {
|
||||
width: 300rpx;
|
||||
text-align: center;
|
||||
margin: 250rpx auto 0 auto;
|
||||
height: 80rpx;
|
||||
color: #07c160;
|
||||
border-radius: 5px;
|
||||
line-height: 80rpx;
|
||||
background-color: rgba(0, 0, 0, 0.03);
|
||||
}
|
||||
|
||||
.line {
|
||||
height: 1rpx;
|
||||
width: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
showUploadTip: false,
|
||||
haveGetRecord: false,
|
||||
envId: '',
|
||||
record: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
envId: options.envId
|
||||
});
|
||||
wx.showLoading({
|
||||
title: '',
|
||||
});
|
||||
wx.cloud.callFunction({
|
||||
name: 'quickstartFunctions',
|
||||
config: {
|
||||
env: this.data.envId
|
||||
},
|
||||
data: {
|
||||
type: 'selectRecord'
|
||||
}
|
||||
}).then((resp) => {
|
||||
this.setData({
|
||||
record: resp.result.data
|
||||
});
|
||||
wx.hideLoading();
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
this.setData({
|
||||
showUploadTip: true
|
||||
});
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
|
||||
updateRecord() {
|
||||
wx.showLoading({
|
||||
title: '',
|
||||
});
|
||||
wx.cloud.callFunction({
|
||||
name: 'quickstartFunctions',
|
||||
config: {
|
||||
env: this.data.envId
|
||||
},
|
||||
data: {
|
||||
type: 'updateRecord',
|
||||
data: this.data.record
|
||||
}
|
||||
}).then((resp) => {
|
||||
wx.navigateTo({
|
||||
url: `/pages/updateRecordSuccess/index`,
|
||||
});
|
||||
wx.hideLoading();
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
this.setData({
|
||||
showUploadTip: true
|
||||
});
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
|
||||
bindInput (e) {
|
||||
const index = e.currentTarget.dataset.index;
|
||||
const record = this.data.record;
|
||||
record[index].sales = Number(e.detail.value);
|
||||
this.setData({
|
||||
record
|
||||
});
|
||||
},
|
||||
|
||||
});
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"navigationBarTitleText": "更新记录",
|
||||
"usingComponents": {
|
||||
"cloud-tip-modal": "/components/cloudTipModal/index"
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
.tip {
|
||||
font-size: 23rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
width: 90%;
|
||||
text-align: center;
|
||||
margin: 30rpx auto 0 auto;
|
||||
}
|
||||
|
||||
.top_tip {
|
||||
font-size: 28rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
width: 90%;
|
||||
text-align: left;
|
||||
margin-top: 30rpx;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.box_text {
|
||||
background-color: white;
|
||||
text-align: center;
|
||||
padding: 300rpx 0;
|
||||
margin-top: 30rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.code_box {
|
||||
text-align: center;
|
||||
background-color: white;
|
||||
margin-top: 30rpx;
|
||||
padding: 17rpx;
|
||||
}
|
||||
|
||||
.code_box_title {
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
font-size: 26rpx;
|
||||
margin-bottom: 20rpx;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.code_box_record {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.code_box_record_title {
|
||||
width: 33%;
|
||||
font-size: 26rpx;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.code_box_record_detail {
|
||||
width: 33%;
|
||||
font-size: 26rpx;
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.button {
|
||||
width: 300rpx;
|
||||
text-align: center;
|
||||
margin: 250rpx auto 0 auto;
|
||||
height: 80rpx;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
line-height: 80rpx;
|
||||
background-color: #07c160;
|
||||
}
|
||||
|
||||
.line {
|
||||
height: 1rpx;
|
||||
width: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.1);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
goBack() {
|
||||
wx.navigateBack({
|
||||
delta: 2
|
||||
});
|
||||
},
|
||||
|
||||
});
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"navigationBarTitleText": "更新记录",
|
||||
"usingComponents": {
|
||||
"cloud-tip-modal": "/components/cloudTipModal/index"
|
||||
}
|
||||
}
|