let app = getApp(); import Notify from '@vant/weapp/notify/notify'; import { selfFormatTimeYMDHMS } from "../../../../utils/util.js" import { visitorPersonRq, selectVisitorRecordByIdRq, updateVisitorPersonStatusRq } from "../../../../api/meeting/visitorIinvitation.js" Page({ /** * 页面的初始数据 */ data: { IMG_NAME: app.IMG_NAME, id: null, title: null, type: null, verifyShow: false, userDetail: {}, fileList: [], // 上传文件 detail: { customerId: null, //企业id customerName: null, //企业名称 userId: null, // 被访人id username: null, //被访人姓名 mobile: null, //被访人手机号 intervieweeId: null, // 访客id name: null, // 访客姓名 phone: null, // 访客手机号 cardType: '居民身份证', // 证件类型 cardNo: null, // 证件号 visitTime: null, // 到访时间 leaveTime: null, // 离开时间 visitContent: null, // 来访事由 photo: null, // 头像-相对路径 url: null, // 人脸设备图片-全路径 }, // 审核 dialogShow: false, dialogId: null, dialogContent: null, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { console.log('onLoad', options) let _this = this; let userDetail = wx.getStorageSync('user') // let detail = _this.data.detail; _this.setData({ ...options, userDetail, detail }) // 页面初始化 options为页面跳转所带来的参数 wx.setNavigationBarTitle({ title: options.title }) // 有id查询详情 if (options.id) { // 获取详情 _this.getDetail() } }, // 获取详情 getDetail() { let _this = this; selectVisitorRecordByIdRq(_this.data.id).then(res => { console.log('selectVisitorRecordByIdRq', res); let detail = res.data; // 是点击审核菜单或按钮并且是未审核的数据 if (_this.data.type == 'verify' && detail.status == 0) { _this.setData({ verifyShow: true }) } // 设置状态颜色 let color = "#3794FF" if (detail.status == 0) { // 待审核 color = "#3794FF" } else if (detail.status == 1) { // 审核通过 color = "#62c855" } else if (detail.status == 2) { // 审核驳回 color = "red" } detail.fontColor = color; _this.setData({ detail, fileList: [{ relativeUrl: detail.photo, url: app.IMG_NAME + detail.photo, name: detail.photo, deletable: false, }] }) }) }, // 图片-上传前校验 beforeRead(event) { const { file, callback } = event.detail; callback(file.type === 'image'); }, // 图片-上传后 afterRead(event) { let _this = this; const { file } = event.detail; // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式 wx.uploadFile({ url: app.DOMAIN_NAME + '/api/dfs/upload', filePath: file.url, name: 'file', formData: {}, success(res) { console.log('upload file ', res); let fileData = JSON.parse(res.data) // 上传完成需要更新 fileList let fileList = _this.data.fileList; fileList.push({ relativeUrl: fileData.fileName, url: app.IMG_NAME + fileData.fileName, name: fileData.fileName, deletable: true, }) _this.setData({ fileList }) }, }); }, // 删除图片 deleteImg(event) { console.log('deleteImg', event); let _this = this; let fileList = _this.data.fileList; fileList.splice(event.detail.index, 1); _this.setData({ fileList }) }, // 显示-弹出框 showDialog(e) { console.log('showDialog', e); let _this = this _this.setData({ dialogShow: true, dialogId: e.currentTarget.dataset.id, dialogContent: null }) }, // 弹出框-审核 dialogVerify(e) { console.log('dialogSuccess', e); let status = e.currentTarget.dataset.status; let _this = this // 驳回 需要输入描述信息 if (status == 2 && !_this.data.dialogContent) { Notify({ type: 'danger', message: '请输入描述信息!' }); return } updateVisitorPersonStatusRq({ id: _this.data.dialogId, status, rejectContent: _this.data.dialogContent, }).then(res => { console.log('updateVisitorPersonStatusRq', res); // 刷新上个页面参数 let pages = getCurrentPages(); //获取page let prevPage = pages[pages.length - 2]; //上一个页面(父页面) prevPage.setData({ changeData: true }) // _this.setData({ dialogShow: false, }) // 获取详情 _this.getDetail() // if (res.code == 0) { _this.setData({ verifyShow: false }) } else { Notify({ type: 'danger', message: res.msg }); } }) }, // 弹出框-输入框:输入内容时触发 dialogInput(e) { let _this = this console.log('dialogInput', e.detail); _this.setData({ dialogContent: e.detail, }) }, // 显示错误消息 showErrMsg(msg) { Notify({ type: 'danger', message: msg }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })