53 lines
1.0 KiB
JavaScript
53 lines
1.0 KiB
JavaScript
// index.js
|
|
var myRequest = require("../../utils/api.js");
|
|
|
|
Page({
|
|
data: {
|
|
active: 0,
|
|
role:'',
|
|
comp:''
|
|
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
|
|
this.getUserInfo()
|
|
},
|
|
onShow(){
|
|
if(this.data.active==0){
|
|
if(this.data.role){
|
|
if(this.data.role=='customer'){
|
|
let comp= this.selectComponent('#report');
|
|
comp.getlist()
|
|
}else{
|
|
let comp= this.selectComponent('#maintenance');
|
|
comp.init()
|
|
}
|
|
}
|
|
|
|
}else{
|
|
let comp= this.selectComponent('#my');
|
|
comp.init()
|
|
}
|
|
|
|
},
|
|
getUserInfo(){
|
|
let that = this;
|
|
myRequest.myRequest('getInfo',{},'get').then(res=>{
|
|
console.log(res)
|
|
let {role} = res.data.user
|
|
that.setData({role})
|
|
|
|
wx.setStorageSync('userInfo', res.data.user)
|
|
})
|
|
},
|
|
onChange(event) {
|
|
// event.detail 的值为当前选中项的索引
|
|
console.log(event.detail)
|
|
this.setData({ active: event.detail });
|
|
},
|
|
|
|
})
|