Skip to content

Commit def03dd

Browse files
committed
Add two Demo
Sports and breakfast in miniprogram
1 parent fea5254 commit def03dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2739
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# 【外卖点餐-早餐预定】小程序云开发项目实战
2+
3+
## 项目介绍
4+
5+
- 小程序模拟一个商户对辖区内供应早餐的情景,用户通过在线预定早餐,商户实施配送,直到付款配送完成整个流程。整个流程分为预定中,已确认,已完成3个状态。在预定中状态用户可以取消预定。其他时候用户可以发起客服会话。
6+
- 因为模拟展示,所以没有添加商户端和配送员端,状态变化由时间触发。
7+
8+
9+
## 部署介绍
10+
11+
此处为项目完整代码,可以直接部署使用;以下是部署步骤:
12+
13+
- 初始化云开发环境,如果有多个云开发环境造成wx.cloud.init错误,则在app.js处进行环境定义;
14+
- 在云开发环境中创建一个数据库,名称为food;
15+
- 将项目目录下base文件夹中的food.json文件导入food数据库;
16+
- 将项目目录下base文件夹中的food.jpg图片文件上传至云存储,并将CloudID填写到food数据库ADMIN中的img字段里;
17+
- 将cloudfunctions文件夹内的6个云函数创建并部署,并将donefood、sendfood云函数上传触发器;
18+
- 打开云开发控制台-设置tag-全局设置,添加消息推送,选择消息类型为text,环境ID选择你部署的环境ID,云函数选择contact;
19+
20+
## 参考文档
21+
22+
- [云开发文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html)
10.2 KB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"_id":"ADMIN","ban":[],"tel":"13255524548","price":15.0,"food":"WAMAFO独营营养新鲜早餐全餐【手抓饼、玉米、坚果、黑豆浆、水果小食】","img":"","tips":"每个用户每天只能购买一次,在订餐时需要你的个人信息用于核验;若你点餐但不收配送也不付款则影响你后续的订餐。"}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"permissions": {
3+
"openapi": [
4+
]
5+
}
6+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const cloud = require('wx-server-sdk')
2+
3+
cloud.init();
4+
const db = cloud.database();
5+
const _ = db.command;
6+
7+
exports.main = async (event, context) => {
8+
await db.collection('food').where({
9+
userID:event.userInfo.openId
10+
}).remove();
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "cancelfood",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "ISC",
11+
"dependencies": {
12+
"wx-server-sdk": "~1.8.0"
13+
}
14+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"permissions": {
3+
"openapi": [
4+
"customerServiceMessage.send"
5+
]
6+
}
7+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// 云函数入口文件
2+
const cloud = require('wx-server-sdk')
3+
4+
cloud.init();
5+
const db = cloud.database();
6+
const _ = db.command;
7+
8+
// 云函数入口函数
9+
exports.main = async (event, context) => {
10+
console.log(event);
11+
12+
let content = "收到消息,将在稍后打电话处理"
13+
14+
if(event.Content.indexOf('取消')!=-1){
15+
await db.collection('food').where({
16+
userID:event.userInfo.openId
17+
}).remove();
18+
content='已经成功删除'
19+
}
20+
21+
22+
await cloud.openapi.customerServiceMessage.send({
23+
touser: event.userInfo.openId,
24+
msgtype: 'text',
25+
text: {
26+
content: content,
27+
},
28+
})
29+
30+
return 'success'
31+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "contact",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "ISC",
11+
"dependencies": {
12+
"wx-server-sdk": "~1.8.0"
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"permissions": {
3+
"openapi": [
4+
"subscribeMessage.send"
5+
]
6+
},
7+
"triggers": [
8+
{
9+
"name": "sendMessagerTimer",
10+
"type": "timer",
11+
"config": "*/5 * * * * * *"
12+
}
13+
]
14+
}

0 commit comments

Comments
 (0)