From ca82f6a6a68d38da3c1c39002d663c4dba66bfdb Mon Sep 17 00:00:00 2001 From: HuanCheng Bai Date: Fri, 20 Dec 2019 14:35:32 +0800 Subject: [PATCH] feat: add new demo --- miniprogram/tcb-demo-happy/README.md | 14 +++++ .../cloudfunctions/getbless/index.js | 10 +++ .../cloudfunctions/getbless/package.json | 14 +++++ miniprogram/tcb-demo-happy/miniprogram/app.js | 9 +++ .../tcb-demo-happy/miniprogram/app.json | 11 ++++ .../tcb-demo-happy/miniprogram/app.wxss | 7 +++ .../tcb-demo-happy/miniprogram/index/index.js | 38 +++++++++++ .../miniprogram/index/index.json | 3 + .../miniprogram/index/index.wxml | 15 +++++ .../miniprogram/index/index.wxss | 63 +++++++++++++++++++ .../tcb-demo-happy/miniprogram/sitemap.json | 7 +++ .../tcb-demo-happy/project.config.json | 44 +++++++++++++ 12 files changed, 235 insertions(+) create mode 100644 miniprogram/tcb-demo-happy/README.md create mode 100644 miniprogram/tcb-demo-happy/cloudfunctions/getbless/index.js create mode 100644 miniprogram/tcb-demo-happy/cloudfunctions/getbless/package.json create mode 100644 miniprogram/tcb-demo-happy/miniprogram/app.js create mode 100644 miniprogram/tcb-demo-happy/miniprogram/app.json create mode 100644 miniprogram/tcb-demo-happy/miniprogram/app.wxss create mode 100644 miniprogram/tcb-demo-happy/miniprogram/index/index.js create mode 100644 miniprogram/tcb-demo-happy/miniprogram/index/index.json create mode 100644 miniprogram/tcb-demo-happy/miniprogram/index/index.wxml create mode 100644 miniprogram/tcb-demo-happy/miniprogram/index/index.wxss create mode 100644 miniprogram/tcb-demo-happy/miniprogram/sitemap.json create mode 100644 miniprogram/tcb-demo-happy/project.config.json diff --git a/miniprogram/tcb-demo-happy/README.md b/miniprogram/tcb-demo-happy/README.md new file mode 100644 index 0000000..5dc4535 --- /dev/null +++ b/miniprogram/tcb-demo-happy/README.md @@ -0,0 +1,14 @@ +# 腾讯云云开发圣诞祝福 + +这是云开发团队为云开发者特制的圣诞祝福,在打开后请按照下述步骤完成配置,即可看到: + +- 开通云开发 +- 在云开发下创建一个数据库,名称为happy; +- 将cloudfunctions/database文件夹下的json文件导入happy数据库 +- 将cloudfunctions/getbless右键创建云函数 +- 重新编译运行,即可看到祝福哦 + +## 参考文档 + +- [云开发文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html) + diff --git a/miniprogram/tcb-demo-happy/cloudfunctions/getbless/index.js b/miniprogram/tcb-demo-happy/cloudfunctions/getbless/index.js new file mode 100644 index 0000000..63bfcce --- /dev/null +++ b/miniprogram/tcb-demo-happy/cloudfunctions/getbless/index.js @@ -0,0 +1,10 @@ +const cloud = require('wx-server-sdk') + +cloud.init(); +const db = cloud.database(); + +exports.main = async (event, context) => { + let ibless = (await db.collection('happy').doc('mess').get()).data.bless; + let lucky = Math.floor(Math.random() * ibless.length); + return ibless[lucky]; +} \ No newline at end of file diff --git a/miniprogram/tcb-demo-happy/cloudfunctions/getbless/package.json b/miniprogram/tcb-demo-happy/cloudfunctions/getbless/package.json new file mode 100644 index 0000000..8f57843 --- /dev/null +++ b/miniprogram/tcb-demo-happy/cloudfunctions/getbless/package.json @@ -0,0 +1,14 @@ +{ + "name": "getbless", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "wx-server-sdk": "latest" + } +} \ No newline at end of file diff --git a/miniprogram/tcb-demo-happy/miniprogram/app.js b/miniprogram/tcb-demo-happy/miniprogram/app.js new file mode 100644 index 0000000..95fb07a --- /dev/null +++ b/miniprogram/tcb-demo-happy/miniprogram/app.js @@ -0,0 +1,9 @@ +App({ + onLaunch(){ + if (!wx.cloud) { + console.error('请使用 2.2.3 或以上的基础库以使用云能力') + } else { + wx.cloud.init(); + } + } +}); diff --git a/miniprogram/tcb-demo-happy/miniprogram/app.json b/miniprogram/tcb-demo-happy/miniprogram/app.json new file mode 100644 index 0000000..e153f04 --- /dev/null +++ b/miniprogram/tcb-demo-happy/miniprogram/app.json @@ -0,0 +1,11 @@ +{ + "pages": [ + "index/index" + ], + "window": { + "navigationBarBackgroundColor": "#f3302d", + "navigationBarTitleText": "", + "navigationBarTextStyle": "white" + }, + "sitemapLocation": "sitemap.json" +} \ No newline at end of file diff --git a/miniprogram/tcb-demo-happy/miniprogram/app.wxss b/miniprogram/tcb-demo-happy/miniprogram/app.wxss new file mode 100644 index 0000000..fee1b07 --- /dev/null +++ b/miniprogram/tcb-demo-happy/miniprogram/app.wxss @@ -0,0 +1,7 @@ +page{ + background-color: #f3302d; + padding-top: 15px; +} +button::after{ + border: none; +} \ No newline at end of file diff --git a/miniprogram/tcb-demo-happy/miniprogram/index/index.js b/miniprogram/tcb-demo-happy/miniprogram/index/index.js new file mode 100644 index 0000000..2dddcd3 --- /dev/null +++ b/miniprogram/tcb-demo-happy/miniprogram/index/index.js @@ -0,0 +1,38 @@ +Page({ + data: { + dear:'亲爱的微信小程序开发者:', + message:'圣诞快乐!感谢你对腾讯云云开发的支持,我们的进步离不开你的努力。我们会与你携手共进,一起去发现更多可能。', + me:'——腾讯云云开发团队' + }, + Getbless:function(){ + wx.showLoading({ + title: '获取祝福中', + }) + wx.cloud.callFunction({ + name:'getbless', + success(res){ + wx.hideLoading(); + wx.showModal({ + title: '圣诞快乐', + content: res.result, + showCancel: false, + confirmText: '收下' + }) + }, + fail(e){ + wx.hideLoading(); + wx.showModal({ + title: '圣诞快乐', + content: '内容走丢了,请连接网络重试吧!', + showCancel:false + }) + } + }) + }, + onShareAppMessage:function(){ + return { + title:"【云开发】圣诞节祝福卡片", + imageUrl:'https://636c-cloud-cmm55-1300478727.tcb.qcloud.la/happy/share.png' + } + } +}) \ No newline at end of file diff --git a/miniprogram/tcb-demo-happy/miniprogram/index/index.json b/miniprogram/tcb-demo-happy/miniprogram/index/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/miniprogram/tcb-demo-happy/miniprogram/index/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/miniprogram/tcb-demo-happy/miniprogram/index/index.wxml b/miniprogram/tcb-demo-happy/miniprogram/index/index.wxml new file mode 100644 index 0000000..bdc953e --- /dev/null +++ b/miniprogram/tcb-demo-happy/miniprogram/index/index.wxml @@ -0,0 +1,15 @@ +Merry Christmas! + + + + + + {{dear}} + {{message}} + {{me}} + + + + \ No newline at end of file diff --git a/miniprogram/tcb-demo-happy/miniprogram/index/index.wxss b/miniprogram/tcb-demo-happy/miniprogram/index/index.wxss new file mode 100644 index 0000000..6dca4bb --- /dev/null +++ b/miniprogram/tcb-demo-happy/miniprogram/index/index.wxss @@ -0,0 +1,63 @@ +.mywish{ + font-size: 25px; + color: #ecb444; + font-weight: 900; + text-align: center; +} + +.myblessbox{ + margin:25px 12px; + color: white; + font-size: 12px; +} + +.myblessitem{ + margin-bottom: 12px; + letter-spacing: 1px; +} + +.mytouch{ + margin-top: 25px; + width: 75%; + font-size: 15px; + font-weight: 900; + background-color: #30c07a; + color: #fdf8e5; +} + +.mycard{ + width: 75%; + margin: 25px auto; + padding: 15px; + background-color: rgb(238, 231, 234); + box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.2); +} + +.mycard_text{ + font-size: 13px; + height: calc(100% - 30px); + padding: 10px; + border: 5px solid #f3302d; + color: rgb(95, 90, 78); +} + +.card_title{ + line-height: 4; + font-weight:bold; +} + +.card_text{ + line-height: 1.8; +} + +.card_bottom{ + line-height: 4; + text-align: right; + font-weight:bold; +} + +.myimage{ + width: 100%; + position: fixed; + bottom:0; +} \ No newline at end of file diff --git a/miniprogram/tcb-demo-happy/miniprogram/sitemap.json b/miniprogram/tcb-demo-happy/miniprogram/sitemap.json new file mode 100644 index 0000000..ca02add --- /dev/null +++ b/miniprogram/tcb-demo-happy/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/tcb-demo-happy/project.config.json b/miniprogram/tcb-demo-happy/project.config.json new file mode 100644 index 0000000..969e983 --- /dev/null +++ b/miniprogram/tcb-demo-happy/project.config.json @@ -0,0 +1,44 @@ +{ + "miniprogramRoot": "miniprogram/", + "cloudfunctionRoot": "cloudfunctions/", + "setting": { + "urlCheck": true, + "es6": true, + "postcss": true, + "minified": true, + "newFeature": true, + "enhance": true + }, + "appid": "", + "projectname": "happy", + "libVersion": "2.8.1", + "simulatorType": "wechat", + "simulatorPluginLibVersion": {}, + "condition": { + "search": { + "current": -1, + "list": [] + }, + "conversation": { + "current": -1, + "list": [] + }, + "plugin": { + "current": -1, + "list": [] + }, + "game": { + "list": [] + }, + "miniprogram": { + "current": 0, + "list": [ + { + "id": -1, + "name": "db guide", + "pathName": "pages/databaseGuide/databaseGuide" + } + ] + } + } +} \ No newline at end of file