diff --git a/miniprogram/pages/index/index.js b/miniprogram/pages/index/index.js index 7db329085c3e4b698a87f583c3dd10d0b20ce9da..c46c440b29aa0305c78b1b845628cf207cc214dd 100644 --- a/miniprogram/pages/index/index.js +++ b/miniprogram/pages/index/index.js @@ -1,6 +1,7 @@ //index.js const app = getApp() const db = wx.cloud.database() +const _ = db.command function getDateStr() { var dd = new Date() @@ -39,6 +40,7 @@ Page({ introductionVisible: false }, + // 加载时执行 onLoad: function() { if (!wx.cloud) { wx.redirectTo({ @@ -58,12 +60,14 @@ Page({ this.setTypeValue("airplane") }, + // 日期变化处理 bindDateChange: function(e) { this.setData({ date: e.detail.value }) }, + // 设置交通类型和placeholder setTypeValue(n) { switch (n) { case "airplane": @@ -99,6 +103,7 @@ Page({ } }, + // 提交表单 formSubmit: function(e) { var vals = e.detail.value this.setData({ @@ -106,12 +111,109 @@ Page({ }) }, + // 生成二维码 onGetWXACode(e) { if (this.getwxaCode(e)) { wx.hideLoading() } }, + // 查询是否有确诊同行班次 + checkTraffic(e) { + if (this.data.formData.typeValue == "") { + wx.showToast({ + title: this.data.typeName + '不能为空', + icon: 'none', + duration: 2000 + }) + return + } + const self = this + let danger = false + // 从上报查询 + db.collection('roomInfo').where({ + typeName: this.data.formData.typeName, + typeValue: this.data.formData.typeValue, + date: this.data.formData.date + }).get({ + success: res => { + if (res.errMsg === 'collection.get:ok' && res.data.length > 0) { + console.log(res.data[0]) + const flight = res.data[0] + db.collection('report').where({ + roomId: flight._id, + review: 1 // 只查审核过的病例 + }).get({ + success: res => { + if (res.errMsg === 'collection.get:ok' && res.data.length > 0) { + wx.showModal({ + title: '查询结果', + content: self.data.typeName + self.data.formData.typeValue + '存在新冠病例,请注意安全,及时隔离!', + showCancel: false + }) + danger = true + } + }, + error: console.log + }) + } + }, + error: console.log + }) + // 从公开数据源查询 + let key = '' + switch (this.data.formData.typeName) { + case "airplane": + key = '飞机' + break + case "train": + key = '火车' + break + case "car": + key = _.in(['出租车', '公交车']) + break + default: + break + } + let date = this.data.formData.date.split('-') + let items = [] + items.push(date[0]) + date[1][0] === '0' ? items.push(date[1].slice(1)) : items.push(date[1]) + date[2][0] === '0' ? items.push(date[2].slice(1)) : items.push(date[2]) + date = items.join('/') + console.log({ + t_type: key, + t_no: this.data.formData.typeValue, + t_date: date + }) + db.collection('traffic').where({ + t_type: key, + t_no: this.data.formData.typeValue, + t_date: date + }).get({ + success: res => { + console.log(res) + if (res.errMsg === 'collection.get:ok' && res.data.length > 0) { + wx.showModal({ + title: '查询结果', + content: self.data.typeName + self.data.formData.typeValue + '存在新冠病例,请注意安全,及时隔离!', + showCancel: false + }) + danger = true + } + } + }) + // 安全 + if (!danger) { + wx.showModal({ + title: '查询结果', + content: '恭喜你!' + self.data.typeName + self.data.formData.typeValue + '安全,请关注后续信息', + showCancel: false + }) + } + }, + + // 订阅处理 onGetUserInfo(e) { if (!e.detail.userInfo) { wx.showToast({ @@ -171,6 +273,7 @@ Page({ }) }, + // 加入同行 joinRoom: function() { var roomId = this.data.roomId var openId = app.globalData.openid @@ -198,6 +301,7 @@ Page({ }) }, + // 获取同行二维码 getwxaCode(e) { var roomId = e.id if (!roomId) { @@ -281,6 +385,7 @@ Page({ return false }, + // 交通类型变化处理 bindTypeChange: function(e) { const typeValue = this.data.radioItems[e.detail.value].value this.setTypeValue(typeValue) @@ -294,82 +399,22 @@ Page({ }); }, - showMine: function() { - if (this.data.showMine == 'Y') { - this.setData({ - showText: '显示我的关注', - showMine: '', - }) - return - } - var self = this - console.log("openid", app.globalData.openid) - db.collection("member").where({ - openid: app.globalData.openid, - status: 0 - }).get({ - success: res => { - console.log("res", res) - let roomIds = [] - for (let i in res.data) { - if (res.data[i].roomId) { - roomIds.push(res.data[i].roomId) - } - } - if (roomIds.length == 0) { - wx.showToast({ - title: '无内容', - }) - return - } - - db.collection('roomInfo').where({ - _id: db.command.in(roomIds) - }).get({ - success: res => { - self.setData({ - showText: '收起我的关注', - showMine: 'Y', - mylist: res.data, - }) - } - }) - fail: console.log - }, - fail: console.log - }) - }, - - tabChange: function(e) { - switch (e.detail.index) { - case 0: - wx.redirectTo({ - url: '../index/index', - }) - break - case 1: - wx.redirectTo({ - url: '../focus/focus', - }) - break - default: - break - } - }, - + // 显示查看说明 showIntroduction: function(e) { this.setData({ introductionVisible: true }) }, + // 关闭查看说明 closeIntroduction: function(e) { this.setData({ introductionVisible: false }) }, + // 分享 onShareAppMessage: function() { - + } }) \ No newline at end of file diff --git a/miniprogram/pages/index/index.wxml b/miniprogram/pages/index/index.wxml index 83b3a4d48ea37b6521304eff687cc8812933b6aa..2759ec020509f076f2df9dffbcf29abc7e0c7a72 100644 --- a/miniprogram/pages/index/index.wxml +++ b/miniprogram/pages/index/index.wxml @@ -45,7 +45,7 @@ - - + diff --git a/project.config.json b/project.config.json index 59c0ff1f43af4f8bad7eb6be12dd60e5abcb32e8..4b894d3c81cf0419514db5f6ffe9e54c7594db33 100644 --- a/project.config.json +++ b/project.config.json @@ -9,7 +9,7 @@ "newFeature": true, "enhance": true }, - "appid": "wx62c7114b65055f99", + "appid": "wx83ec1d839ccc8492", "projectname": "%E8%A1%8C%E8%BD%A6%E7%A0%81", "libVersion": "2.10.1", "simulatorType": "wechat",