You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
163 lines
3.0 KiB
163 lines
3.0 KiB
const util = require('../../utils/util.js') |
|
Page({ |
|
|
|
/** |
|
* 页面的初始数据 |
|
*/ |
|
data: { |
|
userInfo: false, |
|
tel: [], |
|
imgURL: "" |
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面加载 |
|
*/ |
|
onLoad: function(options) { |
|
this.setData({ |
|
imgURL: wx.getStorageSync("serverurl") |
|
}) |
|
}, |
|
// 获取用户信息 |
|
getUser() { |
|
let url = `api/salesman-info?id=${wx.getStorageSync("userInfo").id}`; |
|
let that = this; |
|
util.httpRequest(url).then((res) => { |
|
if (res.code == '200') { |
|
if (wx.getStorageSync("userInfo")) { |
|
wx.setStorageSync("userInfo", res.data); |
|
that.setData({ |
|
userInfo: res.data |
|
}) |
|
} else { |
|
wx.setStorageSync("userInfo", "") |
|
} |
|
} |
|
}) |
|
}, |
|
// 联系方式 |
|
getData() { |
|
let url = 'api/get-connect' |
|
util.httpRequest(url).then((res) => { |
|
if (res.code == '200') { |
|
console.log(res.data) |
|
this.setData({ |
|
tel: res.data.connect.split("|") |
|
}) |
|
} |
|
}) |
|
}, |
|
// 退出登录 |
|
escUser() { |
|
wx.showLoading({ |
|
title: '退出中...', |
|
mask: true |
|
}) |
|
let url = `api/login-out` |
|
let data = { |
|
id:this.data.userInfo.id |
|
} |
|
util.httpRequest(url,data,'post').then((res) => { |
|
wx.hideLoading() |
|
this.setData({ |
|
userInfo: false, |
|
tel: '', |
|
code: '', |
|
}) |
|
wx.removeStorageSync('userInfo') |
|
wx.removeStorageSync('token') |
|
wx.removeStorageSync('refresh_token') |
|
// wx.removeStorageSync('time') |
|
wx.showToast({ |
|
title: '退出成功' |
|
}) |
|
}) |
|
|
|
}, |
|
// 登录 |
|
sign() { |
|
wx.navigateTo({ |
|
url: '../Sign/Sign', |
|
}) |
|
}, |
|
// 联系我们 |
|
contactMy() { |
|
wx.makePhoneCall({ |
|
phoneNumber: this.data.tel[0], |
|
}) |
|
}, |
|
// 复制邀请码 |
|
copy(e) { |
|
let name = e.currentTarget.dataset.name |
|
wx.setClipboardData({ |
|
data: name, |
|
success: function(res) { |
|
wx.getClipboardData({ |
|
success: function(res) { |
|
wx.showToast({ |
|
title: '复制成功' |
|
}) |
|
} |
|
}) |
|
} |
|
}) |
|
}, |
|
/** |
|
* 生命周期函数--监听页面初次渲染完成 |
|
*/ |
|
onReady: function() { |
|
|
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面显示 |
|
*/ |
|
onShow: function() { |
|
this.getUser() |
|
if (wx.getStorageSync("userInfo")) { |
|
this.getData() |
|
} |
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面隐藏 |
|
*/ |
|
onHide: function() { |
|
|
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面卸载 |
|
*/ |
|
onUnload: function() { |
|
|
|
}, |
|
|
|
/** |
|
* 页面相关事件处理函数--监听用户下拉动作 |
|
*/ |
|
onPullDownRefresh: function() { |
|
this.getUser() |
|
setTimeout(() => { |
|
wx.stopPullDownRefresh({ |
|
success(res) { |
|
console.log('刷新成功'); |
|
} |
|
}); |
|
}, 1000) |
|
}, |
|
|
|
/** |
|
* 页面上拉触底事件的处理函数 |
|
*/ |
|
onReachBottom: function() { |
|
|
|
}, |
|
|
|
/** |
|
* 用户点击右上角分享 |
|
*/ |
|
onShareAppMessage: function() { |
|
|
|
} |
|
}) |