117 lines
2.7 KiB
JavaScript
117 lines
2.7 KiB
JavaScript
/*
|
|
* 手太欠
|
|
* 愿这世界都如故事里一样 美好而动人~
|
|
*/
|
|
|
|
Page({
|
|
data: {
|
|
payCode : '', // code获取openid
|
|
openId : '', // openid
|
|
userLogin : false, // 是否登录
|
|
testTitle : '', // 检测文字
|
|
disabled : false, // 支付按钮
|
|
payStatus : false, // 支付弹框
|
|
catchtouchmove: false
|
|
},
|
|
|
|
onLoad(options) {
|
|
if(options.invite != undefined) {
|
|
getApp().globalData.inviteText = options.invite
|
|
}
|
|
},
|
|
|
|
onShow() {
|
|
wx.login({
|
|
success: res => {
|
|
this.setData({
|
|
payCode: res.code
|
|
})
|
|
// 获取openid
|
|
this.openInfo()
|
|
}
|
|
})
|
|
|
|
// 获取登录状态
|
|
if(wx.getStorageSync("token") != ''){
|
|
this.setData({
|
|
userLogin: true
|
|
})
|
|
// 是否可检测
|
|
this.ifAnalyze();
|
|
return
|
|
}
|
|
|
|
this.setData({
|
|
userLogin: false
|
|
})
|
|
},
|
|
|
|
/**
|
|
* openid
|
|
*/
|
|
openInfo() {
|
|
wx.$api.auth.codeOpenid({code: this.data.payCode}).then(res => {
|
|
this.setData({
|
|
openId: res.data
|
|
})
|
|
}).catch(err => {})
|
|
},
|
|
|
|
/**
|
|
* 是否可检测
|
|
*/
|
|
ifAnalyze() {
|
|
wx.$api.index.analyze().then(res => {
|
|
if(res.data.is_first) {
|
|
this.setData({
|
|
testTitle: '首次免费,开始测肤'
|
|
})
|
|
} else if (res.data.is_first == false && res.data.analyze == false) {
|
|
this.setData({
|
|
testTitle: '支付' + res.data.price + '元,进行测肤'
|
|
})
|
|
} else if (res.data.is_first == false && res.data.analyze == true) {
|
|
this.setData({
|
|
testTitle: '您已付费,进行检测'
|
|
})
|
|
}
|
|
|
|
this.setData({
|
|
Analyze : res.data
|
|
})
|
|
if(!res.data.is_update) {
|
|
this.setData({
|
|
nameStatus: true
|
|
})
|
|
}
|
|
}).catch(err => {})
|
|
},
|
|
|
|
/**
|
|
* 处理未登录时的转跳
|
|
*/
|
|
assessGo(){
|
|
if(wx.getStorageSync("token") != ''){
|
|
wx.navigateTo({
|
|
url: '/pages/index/assess/assess?code='
|
|
})
|
|
return
|
|
}
|
|
|
|
// 去登录
|
|
wx.navigateTo({
|
|
url: "/pages/login/index?type=indexDemo"
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 微信分享
|
|
*/
|
|
onShareAppMessage(){
|
|
return {
|
|
title : '水感应',
|
|
path : "/pages/index/index?invite=" + wx.getStorageSync("invite")
|
|
}
|
|
},
|
|
})
|