diff --git a/app.json b/app.json index 83a6096..567fd97 100644 --- a/app.json +++ b/app.json @@ -1,37 +1,38 @@ { - "pages": [ - "pages/index/index", - "pages/logs/logs", - "pages/test/icon", - "pages/test/cover-view", - "pages/test/moveable-view", - "pages/test/swiper", - "pages/test/scrollview", - "pages/test/view", - "pages/test/text", - "pages/test/rich-text", - "pages/test/progress", - "pages/test/button", - "pages/test/checkbox", - "pages/test/input", - "pages/test/form", - "pages/test/picker", - "pages/test/picker-view", - "pages/test/radio", - "pages/test/slider", - "pages/test/switch", - "pages/test/textarea", - "pages/test/audio", - "pages/test/image", - "pages/test/video", - "pages/test/camera" - ], - "window": { - "backgroundTextStyle": "light", - "navigationBarBackgroundColor": "#fff", - "navigationBarTitleText": "Weixin", - "navigationBarTextStyle": "black" - }, - "style": "v2", - "sitemapLocation": "sitemap.json" + "pages": [ + "pages/chat/chat", + "pages/index/index", + "pages/logs/logs", + "pages/test/icon", + "pages/test/cover-view", + "pages/test/moveable-view", + "pages/test/swiper", + "pages/test/scrollview", + "pages/test/view", + "pages/test/text", + "pages/test/rich-text", + "pages/test/progress", + "pages/test/button", + "pages/test/checkbox", + "pages/test/input", + "pages/test/form", + "pages/test/picker", + "pages/test/picker-view", + "pages/test/radio", + "pages/test/slider", + "pages/test/switch", + "pages/test/textarea", + "pages/test/audio", + "pages/test/image", + "pages/test/video", + "pages/test/camera" + ], + "window": { + "backgroundTextStyle": "light", + "navigationBarBackgroundColor": "#fff", + "navigationBarTitleText": "Weixin", + "navigationBarTextStyle": "black" + }, + "style": "v2", + "sitemapLocation": "sitemap.json" } \ No newline at end of file diff --git a/cloudfunctions/getOpenId/config.json b/cloudfunctions/getOpenId/config.json new file mode 100644 index 0000000..5ecc33e --- /dev/null +++ b/cloudfunctions/getOpenId/config.json @@ -0,0 +1,6 @@ +{ + "permissions": { + "openapi": [ + ] + } +} \ No newline at end of file diff --git a/cloudfunctions/getOpenId/index.js b/cloudfunctions/getOpenId/index.js new file mode 100644 index 0000000..ba95da2 --- /dev/null +++ b/cloudfunctions/getOpenId/index.js @@ -0,0 +1,16 @@ +// 云函数入口文件 +const cloud = require('wx-server-sdk') + +cloud.init() + +// 云函数入口函数 +exports.main = async (event, context) => { + const wxContext = cloud.getWXContext() + + return { + event, + openid: wxContext.OPENID, + appid: wxContext.APPID, + unionid: wxContext.UNIONID, + } +} \ No newline at end of file diff --git a/cloudfunctions/getOpenId/package.json b/cloudfunctions/getOpenId/package.json new file mode 100644 index 0000000..3639cba --- /dev/null +++ b/cloudfunctions/getOpenId/package.json @@ -0,0 +1,14 @@ +{ + "name": "getOpenId", + "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.5.3" + } +} \ No newline at end of file diff --git a/pages/chat/chat.js b/pages/chat/chat.js new file mode 100644 index 0000000..b61da7c --- /dev/null +++ b/pages/chat/chat.js @@ -0,0 +1,85 @@ +// pages/chat/chat.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + wx.cloud.init() + wx.cloud.callFunction({ + name: 'getOpenId', + complete: res => { + console.log('callFunction test result: ', res) + } + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + wx.cloud.init({env:'cloud1-2go8vh3uf39b51e1'}) + const db = wx.cloud.database() + const _=db.command + const watcher = db.collection('message').where({ + room:'bf4a0bf261c46ca1000a8f8d7fcf50e2', + time:_.gt(new Date('2021-12-23 00:00:00')) + }).watch({ + onChange:snapshot=>{ + console.log('新事件',snapshot) + }, + onError:err=>{ + console.error('监听错误',err) + } + }) + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/chat/chat.json b/pages/chat/chat.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/chat/chat.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/chat/chat.wxml b/pages/chat/chat.wxml new file mode 100644 index 0000000..fee7da9 --- /dev/null +++ b/pages/chat/chat.wxml @@ -0,0 +1,2 @@ + +pages/chat/chat.wxml diff --git a/pages/chat/chat.wxss b/pages/chat/chat.wxss new file mode 100644 index 0000000..6e8bee3 --- /dev/null +++ b/pages/chat/chat.wxss @@ -0,0 +1 @@ +/* pages/chat/chat.wxss */ \ No newline at end of file diff --git a/project.config.json b/project.config.json index ef065a4..1fcffe6 100644 --- a/project.config.json +++ b/project.config.json @@ -1,5 +1,6 @@ { "description": "项目配置文件", + "cloudfunctionRoot": "cloudfunctions/", "packOptions": { "ignore": [ { @@ -59,6 +60,7 @@ "servePath": "" }, "isGameTourist": false, + "cloudfunctionTemplateRoot": "cloudfunctionTemplate", "condition": { "search": { "list": []