// pages/problemList/problemList.js import { CheckEdit, GetQuList, Delete, TOperation } from '../../utils/network' Page({ /** * 页面的初始数据 */ data: { showPage: false, showNull: false, roleKey: '', nextlevel: 0, showTabs: false, erectoListLevel: [], state: 0, listdata: [], active1: 0, active2: 0, active3: 0, isadmin: true, bohui: true, show: false, text: '', itemId: '', modalHidden: true, delModal: true, // currentIndex:1, // totalPage:0, index: 1, total: 10, pageMask: false, prevBtnDis: true, nextBtnDis: false, properties: { currentIndex: { //当前页码 type: Number, value: 1 }, totalPage: { type: Number } }, form: { }, nickName: '', info1: 0, info2: 0, info3: 0, info4: 0, topNum:0, }, lifetimes: { // 在组件实例进入页面节点树时执行 attached: function () { this.setData({ index: this.properties.currentIndex, total: this.properties.totalPage }) } }, // 详情展示 toxiangqin(e) { console.log(e.target.dataset.id) var id = e.target.dataset.id wx.navigateTo({ url: '/pages/xiangqing/xiangqing?id=' + id, }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, goTop () { // 一键回到顶部 wx.pageScrollTo({ scrollTop: 0, duration: 300 }); }, // 设置异步请求之后的页面、总记录数 setPage(index, total) { this.setData({ index, total }) }, //每次改变页码就调用该函数 triggerParent: function () { // 通知父组件当前加载的页数 // 自定义组件向父组件传值 const option = { currentIndex: this.data.index }; // pagingChange 自定义名称事件,父组件中使用 this.triggerEvent('pagingChange', option) }, //开启页码弹窗 showPagePopUp: function () { this.setData({ pageMask: true }) }, //关闭页码弹窗 hidePagePopUp: function () { this.setData({ pageMask: false }) }, //更改页码点击事件 onChangePage: function (e) { console.log("更改页码事件:",e); this.setData({ pageMask: false, index: e.currentTarget.dataset.index //点击的页数 }) this.getList() // 先判断当前页数,是否需要更新disabled的状态 this.triggerParent(); if (e.currentTarget.dataset.index <= 1) { this.setData({ prevBtnDis: false, }) } }, //上一页点击事件 prevPage: function () { console.log(this.data.index,this.data.total); if (this.data.index <= 1) { this.setData({ prevBtnDis: false, }) return false } if (this.data.index <= this.data.total) { this.setData({ nextBtnDis: false, }) } let num = this.data.index - 1; this.setData({ index: num, prevBtnDis:true }) this.getList() this.triggerParent(); }, //下一页点击事件 nextPage: function () { console.log(this.data.index,this.data.total); if (this.data.index >= this.data.total) { this.setData({ nextBtnDis: false, }) return false } this.setData({ nextBtnDis: true, }) if (this.data.index >= 1) { this.setData({ prevBtnDis: false }) } let num = this.data.index + 1; this.setData({ index: num }) this.getList() this.triggerParent(); // 更新按钮状态 }, changeActive1(e) { console.log(e.detail.index); this.setData({ state: e.detail.index, active1: e.detail.index, nickName: wx.getStorageSync('nickName'), index:1 }) this.getList() }, changeActive2(e) { console.log(e.detail.index, this.data.erectoListLevel) this.setData({ active2: e.detail.index, nextlevel: this.data.erectoListLevel[0].userId, index:1 }) this.getNumInfo() this.getList() }, changeActive3(e) { console.log(e.detail.index); this.setData({ active3: e.detail.index, nextlevel: this.data.erectoListLevel[e.detail.index].userId, index:1 }) this.getNumInfo() this.getList() }, getList() { wx.showLoading({ title: '加载中', }) this.setData({ tableData: [] }) var erectoId = wx.getStorageSync("erectoId") var roleKey = wx.getStorageSync('roleKey') let data = { pageNum: this.data.index, pageSize: 5, state: this.data.state, orderType: 1, } if (roleKey == 'tenantservice') { data.createUserId = 0 data.erectoId = erectoId } if (roleKey == 'admin') { data.createUserId = 0; data.erectoId = 0; } if (roleKey == 'tenant' || roleKey == 'tenanthelper') { data.createUserId = erectoId; data.erectoId = 0; } if (this.data.active2 == 1) { //当选择下级时\ data.createUserId = this.data.nextlevel } wx.request({ url: 'https://puyue.yhupai.com/prod-api/iot/deviceOrder/list', method: "GET", header: { "Access-Control-Allow-Headers": 'token', Authorization: `Bearer ${wx.getStorageSync('token')}` }, data: data, success: (res, header) => { if (res.data.code == 200 && res.data.rows.length > 0) { let data = res.data let total = Math.ceil(res.data.total / 5) this.setData({ listdata: data.rows, total: total, showPage: true, showNull: false }) this.goTop() wx.hideLoading() } else { this.setData({ listdata: [], total: 0, showPage: false, showNull: true, prevBtnDis:true, nextBtnDis:true, }) this.goTop() wx.hideLoading() } } }) }, getErectoListLevel() { this.setData({ erectoListLevel: [] }) let data = { pageNum: 1, pageSize: 10000, deptId: wx.getStorageSync('deptId'), roleKey: 'tenanthelper', isAuthentication: 1 } console.log(data); wx.request({ url: 'https://puyue.yhupai.com/prod-api/system/user/list', method: "GET", header: { "Access-Control-Allow-Headers": 'token', Authorization: `Bearer ${wx.getStorageSync('token')}` }, data: data, success: (res, header) => { if (res.data.code == 200 || res.data.rows.length > 0) { let data = res.data.rows this.setData({ nextlevel: data[0].userId, erectoListLevel: data, showTabs: true }) } else { this.setData({ showTabs: false }) } } }) }, call(e) { console.log(e); let item = JSON.parse(JSON.stringify(e.currentTarget.dataset.base)) wx.makePhoneCall({ phoneNumber: item.userPhone, success: function () { console.log("拨打电话成功!") }, fail: function () { console.log("拨打电话失败!") } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, getNumInfo() { var erectoId = wx.getStorageSync("erectoId") var roleKey = wx.getStorageSync('roleKey') let data = { orderType: '1', } if (roleKey == 'tenantservice') { data.createUserId = 0 data.erectoId = erectoId } if (roleKey == 'admin') { data.createUserId = 0; data.erectoId = 0; } if (roleKey == 'tenant' || roleKey == 'tenanthelper') { data.createUserId = erectoId; data.erectoId = 0; } if (this.data.active2 == 1) { //当选择下级时\ data.createUserId = this.data.nextlevel } wx.request({ url: `https://puyue.yhupai.com/prod-api/iot/deviceOrder/get/`, method: "GET", header: { "Access-Control-Allow-Headers": 'token', Authorization: `Bearer ${wx.getStorageSync('token')}` }, data: data, success: (res, header) => { if (res.data.code == 200) { console.log(res); this.setData({ info1: res.data.data.deviceOrderUndeliveredorders, info2: res.data.data.deviceOrderDispatchedorders, info3: res.data.data.deviceOrderReceivedorders, info4: res.data.data.deviceOrderCompleted, }) } else { this.setData({ info1: 0, info2: 0, info3: 0, info4: 0, }) } } }) }, /** * 生命周期函数--监听页面显示 */ onShow: function () { // wx.showLoading({ // title: '加载中', // }) this.setData({ nickName: wx.getStorageSync('nickName'), roleKey: wx.getStorageSync('roleKey') }) this.getNumInfo() console.log(this.data); this.getErectoListLevel() this.getList() }, edit(e) { console.log(e); var item = e.currentTarget.dataset.base wx.navigateTo({ url: '/pages/problemReport/proRep?info=' + JSON.stringify(item), }) }, statements(e) { console.log(e); let item = JSON.parse(JSON.stringify(e.currentTarget.dataset.base)) console.log(item); item.state = 3 console.log(item); wx.navigateTo({ url: '/pages/problemReport/proRep?info=' + JSON.stringify(item), }) }, yetstatements(e) { let item = JSON.parse(JSON.stringify(e.currentTarget.dataset.base)) wx.navigateTo({ url: '/pages/yetAZ/yetAZ?info=' + JSON.stringify(item), }) }, goAddress(e) { var address = e.currentTarget.dataset.base.address console.log(e.currentTarget.dataset); wx.request({ url: 'https://apis.map.qq.com/ws/geocoder/v1/', data: { address: address, key: 'SRGBZ-FLCKU-2TIVH-BFHUM-D5CTO-LFBHQ' }, success: function (res) { if (res.data.status != 0) { wx.showToast({ title: res.data.message, icon: 'error' }) return false } console.log(res.data); // 打印出经纬度 let params = res.data.result.location params.name = e.currentTarget.dataset.base.userName params.address = e.currentTarget.dataset.base.address console.log(params); wx.navigateTo({ url: '/pages/devicelogs/devicelogs?address=' + JSON.stringify(params), }) }, }); }, jd(e) { var item = e.currentTarget.dataset.base if (!item.appointmentTime) { wx.showToast({ title: '请和客户确认预约时间并录入系统再接单', icon: 'none' }) return false } this.setData({ modalHidden: false, form: item }) }, getreceiveTime() { let date = new Date(); let year = date.getFullYear(); let month = date.getMonth() + 1; let day = date.getDate(); let hour = date.getHours(); let minute = date.getMinutes(); let second = date.getSeconds(); return `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day} ${hour < 10 ? '0' + hour : hour}:${minute < 10 ? '0' + minute : minute}:${second < 10 ? '0' + second : second}`; }, modalChange() { this.data.form.state = 2 let data = this.data.form data.id = this.data.form.id data.receiveTime = this.getreceiveTime() // console.log(this.data.form); // return // data.receiveTime=this.getreceiveTime() wx.request({ url: 'https://puyue.yhupai.com/prod-api/iot/deviceOrder', method: "PUT", header: { "Access-Control-Allow-Headers": 'token', Authorization: `Bearer ${wx.getStorageSync('token')}` }, data: data, success: (res, header) => { if (res.data.code == 200) { this.setData({ index: 1, modalHidden: true }) this.getNumInfo() this.getList() } else { this.setData({ index: 1, modalHidden: true }) this.getList() } } }) }, modalCancel() { this.setData({ modalHidden: true }) }, delAZ(e) { console.log(e); var item = e.currentTarget.dataset.base this.setData({ delModal: false, form: item }) }, DelChange() { wx.request({ url: `https://puyue.yhupai.com/prod-api/iot/deviceOrder/${this.data.form.id}/${this.data.form.deviceId}`, method: "DELETE", header: { "Access-Control-Allow-Headers": 'token', Authorization: `Bearer ${wx.getStorageSync('token')}` }, success: (res, header) => { if (res.data.code == 200) { this.setData({ index: 1, delModal: true }) this.getNumInfo() this.getList() } else { this.setData({ index: 1, delModal: true }) this.getList() } } }) }, DelCancel() { this.setData({ delModal: true }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { wx.switchTab({ url: '/pages/home/home', }) }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })