From 281da73b38ad06eefbb545517bad30d57b7c08b0 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 4 Jun 2019 09:40:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E7=BB=83=E4=B9=A0,=E6=9D=83?= =?UTF-8?q?=E9=99=90=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 40 ++++++++++++++------------------ pages/exercise/index.wxml | 2 +- pages/main/main.js | 49 +++++++++++++++++++-------------------- pages/main/main.wxml | 8 +++---- 4 files changed, 46 insertions(+), 53 deletions(-) diff --git a/app.js b/app.js index 71dd99a..2217680 100644 --- a/app.js +++ b/app.js @@ -45,27 +45,21 @@ App({ console.log(that.globalData.isaqy) } }); - // //获取隐患待办数目 - // wx.request({ - // url: that.globalData.serverUrl + 'troublehandle?a=todonum', - // header: { - // 'content-type': 'application/json', // 默认值 - // 'Cookie': wx.getStorageSync("sessionid"), - // }, - // data: {}, - // success: res => { - // if (res.statusCode === 200) { - // //console.log(res.data) - // that.globalData.yhtodonum = res.data.todonum - // if (that.globalData.yhtodonum > 0) { - // wx.setTabBarBadge({ - // index: 1, - // text: '新' - // }) - // } - // } - // } - // }); + //拉取权限 + wx.request({ + url: getApp().globalData.serverUrl + 'api/rights?a=have', + header: { + 'content-type': 'application/json', // 默认值 + 'Cookie': wx.getStorageSync("sessionid"), + }, + data: {}, + success: res => { + if (res.statusCode === 200) { + that.globalData.rights = res.data.rights + } + + } + }); } else { wx.setStorageSync('mpopenid', res.data.mpopenid) wx.reLaunch({ @@ -79,8 +73,8 @@ App({ }, globalData: { userInfo: null, - //serverUrl: 'https://safeyun.ctcshe.com/', - serverUrl: 'http://127.0.0.1:8000/', + serverUrl: 'https://safeyun.ctcshe.com/', + //serverUrl: 'http://127.0.0.1:8000/', //serverUrl: 'http://192.168.0.102:8000/', //serverUrl:'http://10.7.100.250:8000/', isaqy: 0 diff --git a/pages/exercise/index.wxml b/pages/exercise/index.wxml index 8107526..3325528 100644 --- a/pages/exercise/index.wxml +++ b/pages/exercise/index.wxml @@ -11,7 +11,7 @@ - + \ No newline at end of file diff --git a/pages/main/main.js b/pages/main/main.js index 06677b8..0cb8829 100644 --- a/pages/main/main.js +++ b/pages/main/main.js @@ -9,8 +9,7 @@ Page({ zytodonum:0, noread:0, dqdnum:0, - dknum:0, - kaoshi:false + dknum:0 }, /** @@ -23,7 +22,6 @@ Page({ * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - }, /** @@ -33,7 +31,6 @@ Page({ var that = this //获取待阅读通知数目 if(wx.getStorageSync("sessionid")){ - this.getrights() this.getnoread() this.getyhtodonum() this.getzytodonum() @@ -41,7 +38,6 @@ Page({ this.getdknum() //待考 }else{ getApp().callback = () => { - this.getrights() this.getnoread() this.getyhtodonum() this.getzytodonum() @@ -184,26 +180,29 @@ Page({ } }); }, -getrights:function(){ - wx.request({ - url: getApp().globalData.serverUrl + 'api/rights?a=have', - header: { - 'content-type': 'application/json', // 默认值 - 'Cookie': wx.getStorageSync("sessionid"), - }, - data: {}, - success: res => { - if (res.statusCode === 200) { - //console.log(res.data.rights.indexOf('25')) - if (res.data.rights.indexOf('25') != -1) {//考试功能 - this.setData({ - kaoshi: true - }) - } - } - console.log(this.data.kaoshi) + taptest:function(){ + if (getApp().globalData.rights.indexOf('25') != -1) {//考试功能 + wx.navigateTo({ + url: '/pages/examtest/index', + }) + }else{ + wx.showModal({ + content: '该功能为增值服务,如需开通,请查看相关公告!', + showCancel: false + }) } - }); -} + }, + tapexercise: function () { + if (getApp().globalData.rights.indexOf('25') != -1) {//考试功能 + wx.navigateTo({ + url: '/pages/exercise/index', + }) + } else { + wx.showModal({ + content: '该功能为增值服务,如需开通,请查看相关公告!', + showCancel:false + }) + } + }, }) \ No newline at end of file diff --git a/pages/main/main.wxml b/pages/main/main.wxml index c573b1f..4127d86 100644 --- a/pages/main/main.wxml +++ b/pages/main/main.wxml @@ -42,15 +42,15 @@ 线下培训 {{dqdnum}} - + 在线考试 {{dknum}} - - + + 模拟练习 - + \ No newline at end of file