/* * 手太欠 * 愿这世界都如故事里一样 美好而动人~ */ Page({ data: { userLogin : false, userData : '', //用户信息 ordersData : '', //订单数据 // Progress : '', //商品数 parentStatus: false //推荐人弹出 }, onLoad(options) {}, onShow() { // 获取登录状态 if(wx.getStorageSync("token") != ''){ this.setData({ userLogin: true }) // 获取用户信息 this.userInfo(); return } this.setData({ userLogin: false }) }, /** * 用户信息 */ userInfo() { wx.$api.user.userIndex().then(res => { this.setData({ userData : res.data, ordersData: res.data.count.orders, Progress : res.data.count.progress }) if(res.data.invite != '') { wx.setStorage({ key : 'invite', data : res.data.invite }) } }).catch(err => {}) }, /** * 处理未登录时的转跳 */ userNav(e){ let pageUrl = e.currentTarget.dataset.url if(wx.getStorageSync("token") != ''){ wx.navigateTo({ url: pageUrl }) }else{ // 去登录 wx.navigateTo({ url: "/pages/login/index" }) } }, /** * 复制订单号 */ copyUrl(val) { wx.setClipboardData({ data: val.currentTarget.dataset.no, success: () => { wx.showToast({ title: "邀请码复制成功", icon : "none" }) } }) }, /** * 我的客服 */ callCenter() { wx.openCustomerServiceChat({ extInfo: {url: 'https://work.weixin.qq.com/kfid/kfcaf0d242864812bcb'}, corpId: 'ww988d2bd112e71dd2', success: res=> {}, fail: err=> { console.log(err) } }) }, /** * 退出登录 */ outLogin() { wx.showModal({ title : '提示', content : '是否退出登录', success : res=> { if (res.confirm) { getApp().globalData.inviteText = '' // 清理客户端登录缓存 wx.removeStorageSync("token") // 清理邀请码 wx.removeStorageSync("invite") this.setData({ userLogin: false }) } } }) }, /** * 推荐人弹出 */ parentTap() { this.setData({ parentStatus: !this.data.parentStatus }) }, /** * 拨打电话 */ clickcall(e){ wx.makePhoneCall({ phoneNumber: e.currentTarget.dataset.tel }) } })