From 7dd4c226d8831c54e7b1ff1afc8fc66e07a381f5 Mon Sep 17 00:00:00 2001 From: jiechaowu Date: Wed, 12 Feb 2020 22:20:38 +0800 Subject: [PATCH] feat: audit --- miniprogram/app.js | 4 +- miniprogram/app.json | 3 +- miniprogram/pages/audit/audit.js | 118 +++++++++++++++++++++++++++++ miniprogram/pages/audit/audit.json | 7 ++ miniprogram/pages/audit/audit.wxml | 8 ++ miniprogram/pages/audit/audit.wxss | 4 + miniprogram/pages/focus/focus.js | 6 +- miniprogram/pages/focus/focus.wxml | 14 ++-- miniprogram/pages/report/list.js | 3 +- miniprogram/pages/report/list.wxml | 4 +- miniprogram/pages/report/report.js | 1 + 11 files changed, 159 insertions(+), 13 deletions(-) create mode 100644 miniprogram/pages/audit/audit.js create mode 100644 miniprogram/pages/audit/audit.json create mode 100644 miniprogram/pages/audit/audit.wxml create mode 100644 miniprogram/pages/audit/audit.wxss diff --git a/miniprogram/app.js b/miniprogram/app.js index 75af5b0..a2a2ba1 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -11,8 +11,8 @@ App({ // 此处请填入环境 ID, 环境 ID 可打开云控制台查看 // 如不填则使用默认环境(第一个创建的环境) // env: 'release-5b9ba9', - // env: 'test-juk88', - env: 'release-2cwn8', + env: 'test-juk88', + // env: 'release-2cwn8', traceUser: true, }) } diff --git a/miniprogram/app.json b/miniprogram/app.json index 9a5094f..84722dd 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -17,7 +17,8 @@ "pages/report/report", "pages/report/list", "pages/focus/focus", - "pages/member/member" + "pages/member/member", + "pages/audit/audit" ], "window": { "backgroundColor": "#F6F6F6", diff --git a/miniprogram/pages/audit/audit.js b/miniprogram/pages/audit/audit.js new file mode 100644 index 0000000..97f1cdb --- /dev/null +++ b/miniprogram/pages/audit/audit.js @@ -0,0 +1,118 @@ +// miniprogram/pages/audit/audit.js +const db = wx.cloud.database() + +Page({ + + /** + * 页面的初始数据 + */ + data: { + reports: [], + slideButtons: [{ + text: '通过' + }, { + type: 'warn', + text: '驳回', + }] + }, + + audit: function(_id, action) { + db.collection('report').doc(_id).update({ + data: { + review: action + }, + success: res => { + wx.showToast({ + title: '审核成功', + }) + this.getReports() + }, + fail: err => { + console.log(err) + wx.showToast({ + title: '审核失败', + }) + } + }) + }, + + onAuditTap: function(e) { + const _id = e.currentTarget.dataset.id + if (e.detail.index === 0) { + // 通过 + this.audit(_id, 1) + } else { + // 驳回 + this.audit(_id, 2) + } + }, + + getReports() { + db.collection('report').where({ + review: 0 + }).get({ + success: res => { + this.setData({ + reports: res.data + }) + }, + fail: console.log + }) + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function(options) { + this.getReports() + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function() { + + } +}) \ No newline at end of file diff --git a/miniprogram/pages/audit/audit.json b/miniprogram/pages/audit/audit.json new file mode 100644 index 0000000..b223ab9 --- /dev/null +++ b/miniprogram/pages/audit/audit.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "mp-cells": "../components/cells/cells", + "mp-cell": "../components/cell/cell", + "mp-slideview": "../components/slideview/slideview" + } +} \ No newline at end of file diff --git a/miniprogram/pages/audit/audit.wxml b/miniprogram/pages/audit/audit.wxml new file mode 100644 index 0000000..e4b0095 --- /dev/null +++ b/miniprogram/pages/audit/audit.wxml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/miniprogram/pages/audit/audit.wxss b/miniprogram/pages/audit/audit.wxss new file mode 100644 index 0000000..ed2be5a --- /dev/null +++ b/miniprogram/pages/audit/audit.wxss @@ -0,0 +1,4 @@ +/* miniprogram/pages/audit/audit.wxss */ + +@import "../../lib/weui-miniprogram/weui-wxss/dist/style/weui.wxss"; + diff --git a/miniprogram/pages/focus/focus.js b/miniprogram/pages/focus/focus.js index c5cc61c..50e52d5 100644 --- a/miniprogram/pages/focus/focus.js +++ b/miniprogram/pages/focus/focus.js @@ -23,7 +23,8 @@ Page({ car: '汽车', ship: '轮船', other: '其他', - } + }, + isAdmin: false }, showMine: function() { @@ -72,6 +73,9 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function(options) { + this.setData({ + isAdmin: ['ogacd5D7Jmu1tiLuUdGfbGVOPNic', 'ogacd5OZFhnml16yxrG8h1iE26iQ'].indexOf(app.globalData.openid) > -1 + }) }, /** diff --git a/miniprogram/pages/focus/focus.wxml b/miniprogram/pages/focus/focus.wxml index 774b7c2..d84f4bd 100644 --- a/miniprogram/pages/focus/focus.wxml +++ b/miniprogram/pages/focus/focus.wxml @@ -1,15 +1,17 @@ + + + + + + + + - \ No newline at end of file diff --git a/miniprogram/pages/report/list.js b/miniprogram/pages/report/list.js index 8fd2e54..9ef70ca 100644 --- a/miniprogram/pages/report/list.js +++ b/miniprogram/pages/report/list.js @@ -1,5 +1,6 @@ // miniprogram/pages/report/list.js const db = wx.cloud.database() +const _ = db.command Page({ @@ -16,7 +17,7 @@ Page({ onLoad: function (options) { var roomId = options.roomId var self = this - db.collection('report').where({roomId: roomId}).get({ + db.collection('report').where({review: _.gt(0)}).get({ success: res =>{ let listData = [] for(let i in res.data){ diff --git a/miniprogram/pages/report/list.wxml b/miniprogram/pages/report/list.wxml index ffcec35..fe25e30 100644 --- a/miniprogram/pages/report/list.wxml +++ b/miniprogram/pages/report/list.wxml @@ -13,14 +13,14 @@ {{item.name}} {{item.phone}} {{item.date}} - {{item.review ? item.review: '审核中'}} + {{item.review ? (item.review === 1 ? '通过' : '驳回') : '审核中'}} {{item.rtype == 'confirm' ? '确诊': '疑似'}} {{item.name}} {{item.phone}} {{item.date}} - {{item.review ? item.review: '审核中'}} + {{item.review ? (item.review === 1 ? '通过' : '驳回') : '审核中'}} \ No newline at end of file diff --git a/miniprogram/pages/report/report.js b/miniprogram/pages/report/report.js index 1424ac8..d878927 100644 --- a/miniprogram/pages/report/report.js +++ b/miniprogram/pages/report/report.js @@ -69,6 +69,7 @@ Page({ }) vals.roomId = this.data.roomId vals.date = getDateStr() + vals.review = 0 db.collection("report").add({ data: vals, -- Gitee