master
wuxiang 3 years ago
parent e97fc7c19c
commit 21d48233f8

@ -1,5 +1,6 @@
{
"pages": [
"pages/chat/chat",
"pages/index/index",
"pages/logs/logs",
"pages/test/icon",

@ -0,0 +1,6 @@
{
"permissions": {
"openapi": [
]
}
}

@ -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,
}
}

@ -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"
}
}

@ -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 () {
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,2 @@
<!--pages/chat/chat.wxml-->
<text>pages/chat/chat.wxml</text>

@ -0,0 +1 @@
/* pages/chat/chat.wxss */

@ -1,5 +1,6 @@
{
"description": "项目配置文件",
"cloudfunctionRoot": "cloudfunctions/",
"packOptions": {
"ignore": [
{
@ -59,6 +60,7 @@
"servePath": ""
},
"isGameTourist": false,
"cloudfunctionTemplateRoot": "cloudfunctionTemplate",
"condition": {
"search": {
"list": []

Loading…
Cancel
Save