模拟练习,权限优化
This commit is contained in:
parent
582590b6db
commit
281da73b38
40
app.js
40
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
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</view>
|
||||
<button class="weui-btn" type="primary" bindtap='start1' wx:if='{{start1}}'>开始练习</button>
|
||||
<button class="weui-btn" type="primary" bindtap='start1' wx:if='{{start2}}'>继续练习</button>
|
||||
<button class="weui-btn" type="primary" bindtap='start2' wx:if='{{start2}}'>重新开始</button>
|
||||
<button class="weui-btn" type="primary" bindtap='start2' wx:if='{{start2}}' plain='true'>重新开始</button>
|
||||
</view>
|
||||
|
||||
</view>
|
|
@ -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
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
})
|
|
@ -42,15 +42,15 @@
|
|||
<view class="weui-grid__label">线下培训</view>
|
||||
<view class="weui-badge" style="position: absolute;top: 1em;right: 1em;" wx:if="{{dqdnum!=0}}">{{dqdnum}}</view>
|
||||
</navigator>
|
||||
<navigator url="/pages/examtest/index" class="weui-grid" hover-class="weui-grid_active" wx:if="{{kaoshi}}">
|
||||
<view class="weui-grid" hover-class="weui-grid_active" bindtap='taptest'>
|
||||
<image class="weui-grid__icon" src="../images/examtest.png" />
|
||||
<view class="weui-grid__label">在线考试</view>
|
||||
<view class="weui-badge" style="position: absolute;top: 1em;right: 1em;" wx:if="{{dknum!=0}}">{{dknum}}</view>
|
||||
</navigator>
|
||||
<navigator url="/pages/exercise/index" class="weui-grid" hover-class="weui-grid_active" wx:if="{{kaoshi}}">
|
||||
</view>
|
||||
<view class="weui-grid" hover-class="weui-grid_active" bindtap='tapexercise'>
|
||||
<image class="weui-grid__icon" src="../images/exercise.png" />
|
||||
<view class="weui-grid__label">模拟练习</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
Loading…
Reference in New Issue