// StepPage/pages/zero/zero.js import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog'; Page({ /** * 页面的初始数据 */ data: { is_shi:true, is_pan:true, is_lin:true, is_tui:true, is_diao:true, is_shen:true }, handleQrCode(){ let app = getApp(); if(!app.globalData.openID){ return Dialog.confirm({ title: '确认登录', message: '当前账户未登录是否登录?', }).then(() => { // on confirm wx.redirectTo({ url: '../beforeLogin/beforeLogin', }) }) .catch(() => { // on cancel }); }else{ wx.p.request({ url: `${app.globalData.url}wx/wxCheck`, method:'POST', data:{ type:1, openid:app.globalData.openID } }).then(req=>{ if(req.data.code==200){ wx.redirectTo({ url: '../../StepPage/pages/qrCode/qrCode', }) }else{ wx.showToast({ icon:'none', title: req.data.msg }) if(req.data.code==1){ wx.redirectTo({ url: '../beforeLogin/beforeLogin', }) } } }) } }, changeShi(){ this.data.is_shi = !this.data.is_shi; this.setData({ is_shen:true, is_shi:this.data.is_shi, is_pan:true, is_lin:true, is_tui:true, is_diao:true }) }, changeLin(){ this.data.is_lin = !this.data.is_lin; this.setData({ is_shen:true, is_shi:true, is_pan:true, is_lin:this.data.is_lin, is_tui:true, is_diao:true }) }, changeTui(){ this.data.is_tui = !this.data.is_tui; this.setData({ is_shen:true, is_shi:true, is_pan:true, is_lin:true, is_tui:this.data.is_tui, is_diao:true }) }, changePan(){ this.data.is_pan = !this.data.is_pan; this.setData({ is_shen:true, is_shi:true, is_pan:this.data.is_pan, is_lin:true, is_tui:true, is_diao:true }) }, changeDiao(){ this.data.is_diao = !this.data.is_diao; this.setData({ is_shen:true, is_shi:true, is_pan:true, is_lin:true, is_tui:true, is_diao:this.data.is_diao }) }, changeShen(){ this.data.is_shen = !this.data.is_shen; this.setData({ is_shen:this.data.is_shen, is_shi:true, is_pan:true, is_lin:true, is_tui:true, is_diao:true }) }, creatPan(){ let app = getApp(); app.globalData.typePage = 2; wx.redirectTo({ url: '../../StepPage/pages/first/first', }) }, creatLin(){ wx.redirectTo({ url: '../../StepPage/pages/firstLin/firstLin', }) }, creatTui(){ wx.redirectTo({ url: '../../StepPage/pages/firstTui/firstTui', }) }, creatDiao(){ wx.navigateTo({ url: '../../StepPage/pages/diao/diao', }) }, creatShen(){ wx.navigateTo({ url: '../../StepPage/pages/shen/shen', }) }, creatWork(){ let app = getApp(); let openid = app.globalData.openID; wx.p.request({ url: `${app.globalData.url}wx/getWxConstructionData`, method:'POST', data:{ type:1, openid } }).then(req=>{ if(req.data.code==200){ if(req.data.data.data&&req.data.data.length!=0){ let data = JSON.parse(req.data.data.data); let sort = 1; data.stepData.forEach(ele => { console.log(ele); if((ele.sort*1)>sort){ sort = ele.sort; } }); app.globalData = data; app.globalData.typePage=1; app.globalData.set_status = ''; switch(sort){ case 1: wx.redirectTo({ url: '../../StepPage/pages/first/first', }) break; case 2: wx.redirectTo({ url: '../../StepPage/pages/second/second', }) break; case 3: wx.redirectTo({ url: '../../StepPage/pages/third/third', }) break; case 4: wx.redirectTo({ url: '../../StepPage/pages/writeVIN/writeVIN', }) break; case 5: wx.redirectTo({ url: '../../StepPage/pages/fourth/fourth', }) break; case 6: wx.redirectTo({ url: '../../StepPage/pages/fifth/fifth', }) break; } }else{ app.globalData.typePage = 1; app.globalData.set_status = ''; wx.redirectTo({ url: '../../StepPage/pages/first/first', }) } } }) }, handleCreate(){ //新增 if(this.data.is_diao&&this.data.is_shen&&this.data.is_tui&&this.data.is_lin&&this.data.is_pan&&this.data.is_shi){ return wx.showToast({ icon:'error', title: '请选择' }) } let app = getApp(); if(!app.globalData.openID){ return Dialog.confirm({ title: '确认登录', message: '当前账户未登录是否登录?', }).then(() => { // on confirm wx.redirectTo({ url: '../beforeLogin/beforeLogin', }) }) .catch(() => { // on cancel }); }else{ wx.p.request({ url: `${app.globalData.url}wx/wxCheck`, method:'POST', data:{ type:1, openid:app.globalData.openID } }).then(req=>{ if(req.data.code==200){ app.globalData.set_status = ''; if(!this.data.is_pan){ this.creatPan() }else if(!this.data.is_shen){ this.creatShen() }else if(!this.data.is_shi){ this.creatWork() }else if(!this.data.is_lin){ this.creatLin() }else if(!this.data.is_diao){ this.creatDiao() }else if(!this.data.is_tui){ this.creatTui() } }else{ wx.showToast({ icon:'none', title: req.data.msg }) if(req.data.code==1){ wx.redirectTo({ url: '../beforeLogin/beforeLogin', }) } } }) } }, handleCheck(){ //查询 if(this.data.is_diao&&this.data.is_shen&&this.data.is_tui&&this.data.is_lin&&this.data.is_pan&&this.data.is_shi){ return wx.showToast({ icon:'error', title: '请选择' }) } let app = getApp(); if(!app.globalData.openID){ return Dialog.confirm({ title: '确认登录', message: '当前账户未登录是否登录?', }) .then(() => { // on confirm wx.redirectTo({ url: '../beforeLogin/beforeLogin', }) }) .catch(() => { // on cancel }); }else{ wx.p.request({ url: `${app.globalData.url}wx/wxCheck`, method:'POST', data:{ type:1, openid:app.globalData.openID } }).then(req=>{ if(req.data.code==200){ if(!this.data.is_pan){ wx.redirectTo({ url: '../../StepPage/pages/report/PanList/PanList', }) }else if(!this.data.is_shen){ wx.redirectTo({ url: '../../StepPage/pages/report/ShenList/ShenList', }) }else if(!this.data.is_shi){ wx.redirectTo({ url: '../../StepPage/pages/report/ShiList/ShiList', }) }else if(!this.data.is_lin){ wx.redirectTo({ url: '../../StepPage/pages/report/LinList/LinList', }) }else if(!this.data.is_diao){ wx.redirectTo({ url: '../../StepPage/pages/report/DiaoList/DiaoList', }) }else if(!this.data.is_tui){ wx.redirectTo({ url: '../../StepPage/pages/report/TuiList/TuiList', }) } }else{ wx.showToast({ icon:'none', title: req.data.msg }) if(req.data.code==1){ wx.redirectTo({ url: '../beforeLogin/beforeLogin', }) } } }) } }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { let app = getApp(); if(app.globalData.openID){ wx.p.request({ url: `${app.globalData.url}wx/wxCheckWb`, method:'POST', data:{ openid:app.globalData.openID } }).then(req=>{ if(req.data.data&&req.data.data.is_wb){ this.creatWork() } }) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })