water_sh/components/my/index.js

57 lines
1020 B
JavaScript

// components/repair/index.js
var myRequest = require("../../utils/api.js");
const app = getApp()
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
imageSrc:app.globalData.imgUrl+'head.png',
userName:'微信用户',
userType:'报修人'
},
attached(){
this.init()
},
/**
* 组件的方法列表
*/
methods: {
init(){
console.log(wx.getStorageSync('userInfo'))
let userInfo = wx.getStorageSync('userInfo')
let userName = userInfo.nickName||userInfo.phonenumber
let userType=userInfo.role=="customer"?'报修客户':'维修人员'
this.setData({
userName,
userType
})
},
loginOut(){
myRequest.myRequest('logout',{
},'post').then(res=>{
wx.clearStorage()
wx.reLaunch({
url: '../../pages/login/index'
})
})
}
}
})