Skip to content

Commit ca82f6a

Browse files
committed
feat: add new demo
1 parent 02a9460 commit ca82f6a

File tree

12 files changed

+235
-0
lines changed

12 files changed

+235
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 腾讯云云开发圣诞祝福
2+
3+
这是云开发团队为云开发者特制的圣诞祝福,在打开后请按照下述步骤完成配置,即可看到:
4+
5+
- 开通云开发
6+
- 在云开发下创建一个数据库,名称为happy;
7+
- 将cloudfunctions/database文件夹下的json文件导入happy数据库
8+
- 将cloudfunctions/getbless右键创建云函数
9+
- 重新编译运行,即可看到祝福哦
10+
11+
## 参考文档
12+
13+
- [云开发文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html)
14+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const cloud = require('wx-server-sdk')
2+
3+
cloud.init();
4+
const db = cloud.database();
5+
6+
exports.main = async (event, context) => {
7+
let ibless = (await db.collection('happy').doc('mess').get()).data.bless;
8+
let lucky = Math.floor(Math.random() * ibless.length);
9+
return ibless[lucky];
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "getbless",
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": "latest"
13+
}
14+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
App({
2+
onLaunch(){
3+
if (!wx.cloud) {
4+
console.error('请使用 2.2.3 或以上的基础库以使用云能力')
5+
} else {
6+
wx.cloud.init();
7+
}
8+
}
9+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"pages": [
3+
"index/index"
4+
],
5+
"window": {
6+
"navigationBarBackgroundColor": "#f3302d",
7+
"navigationBarTitleText": "",
8+
"navigationBarTextStyle": "white"
9+
},
10+
"sitemapLocation": "sitemap.json"
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
page{
2+
background-color: #f3302d;
3+
padding-top: 15px;
4+
}
5+
button::after{
6+
border: none;
7+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Page({
2+
data: {
3+
dear:'亲爱的微信小程序开发者:',
4+
message:'圣诞快乐!感谢你对腾讯云云开发的支持,我们的进步离不开你的努力。我们会与你携手共进,一起去发现更多可能。',
5+
me:'——腾讯云云开发团队'
6+
},
7+
Getbless:function(){
8+
wx.showLoading({
9+
title: '获取祝福中',
10+
})
11+
wx.cloud.callFunction({
12+
name:'getbless',
13+
success(res){
14+
wx.hideLoading();
15+
wx.showModal({
16+
title: '圣诞快乐',
17+
content: res.result,
18+
showCancel: false,
19+
confirmText: '收下'
20+
})
21+
},
22+
fail(e){
23+
wx.hideLoading();
24+
wx.showModal({
25+
title: '圣诞快乐',
26+
content: '内容走丢了,请连接网络重试吧!',
27+
showCancel:false
28+
})
29+
}
30+
})
31+
},
32+
onShareAppMessage:function(){
33+
return {
34+
title:"【云开发】圣诞节祝福卡片",
35+
imageUrl:'https://636c-cloud-cmm55-1300478727.tcb.qcloud.la/happy/share.png'
36+
}
37+
}
38+
})
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"usingComponents": {}
3+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<view class="mywish">Merry Christmas!</view>
2+
3+
<button class="mytouch" bindtap="Getbless">来个圣诞祝福</button>
4+
5+
<view class="mycard">
6+
<view class="mycard_text">
7+
<view class="card_title">{{dear}}</view>
8+
<view class="card_text">{{message}}</view>
9+
<view class="card_bottom">{{me}}</view>
10+
</view>
11+
</view>
12+
13+
<image class="myimage"
14+
src="cloud://cloud-cmm55.636c-cloud-cmm55-1300478727/happy/bottom.png"
15+
mode="widthFix"></image>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
.mywish{
2+
font-size: 25px;
3+
color: #ecb444;
4+
font-weight: 900;
5+
text-align: center;
6+
}
7+
8+
.myblessbox{
9+
margin:25px 12px;
10+
color: white;
11+
font-size: 12px;
12+
}
13+
14+
.myblessitem{
15+
margin-bottom: 12px;
16+
letter-spacing: 1px;
17+
}
18+
19+
.mytouch{
20+
margin-top: 25px;
21+
width: 75%;
22+
font-size: 15px;
23+
font-weight: 900;
24+
background-color: #30c07a;
25+
color: #fdf8e5;
26+
}
27+
28+
.mycard{
29+
width: 75%;
30+
margin: 25px auto;
31+
padding: 15px;
32+
background-color: rgb(238, 231, 234);
33+
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.2);
34+
}
35+
36+
.mycard_text{
37+
font-size: 13px;
38+
height: calc(100% - 30px);
39+
padding: 10px;
40+
border: 5px solid #f3302d;
41+
color: rgb(95, 90, 78);
42+
}
43+
44+
.card_title{
45+
line-height: 4;
46+
font-weight:bold;
47+
}
48+
49+
.card_text{
50+
line-height: 1.8;
51+
}
52+
53+
.card_bottom{
54+
line-height: 4;
55+
text-align: right;
56+
font-weight:bold;
57+
}
58+
59+
.myimage{
60+
width: 100%;
61+
position: fixed;
62+
bottom:0;
63+
}

0 commit comments

Comments
 (0)