Files
xuan_wechat/pages/user/index.js
2023-09-15 17:14:36 +08:00

100 lines
2.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 手太欠
* 愿这世界都如故事里一样 美好而动人~
*/
Page({
/**
* 页面的初始数据
*/
data: {
userLogin : false,
userData : '',
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// 获取登录状态
if(wx.getStorageSync("token") != ''){
this.setData({
userLogin: true
})
// 获取用户信息
this.userInfo();
return
}
this.setData({
userLogin: false,
userData : ''
})
},
/**
* 用户信息
*/
userInfo() {
wx.$api.user.userIndex().then(res => {
this.setData({
userData: res.data
})
})
},
/**
* 处理未登录时的转跳
*/
userNav(e){
let pageUrl = e.currentTarget.dataset.url
if(wx.getStorageSync("token") != ''){
if(e.currentTarget.dataset.type && e.currentTarget.dataset.type == 'needSign' && this.data.userData.need_sign){
wx.showModal({
title : '提示',
content : '您还未完成实名认证与签约成为VIP用户无法获得邀请码',
cancelText : '稍后完成',
confirmText : '立即完善',
confirmColor : '#da2b54',
complete : res => {
if (res.confirm) {
wx.navigateTo({
url: '/pages/idcard/idcard'
})
}
}
})
return
}
wx.navigateTo({
url: pageUrl
})
}else{
// 去登录
wx.navigateTo({
url: "/pages/login/index"
})
}
},
/**
* 购买产品
*/
onBuy(e){
let { id } = e.currentTarget.dataset
if(id){
wx.navigateTo({
url: '/pages/mall/details/details?id=' + id,
})
}
},
/**
* 拨打电话
*/
toCall(){
wx.makePhoneCall({
phoneNumber: this.data.userData.parent.username,
success: res=> {
console.log()
}
})
},
})