100 lines
2.1 KiB
JavaScript
100 lines
2.1 KiB
JavaScript
import userApi from '../../api/user';
|
|
const app = getApp();
|
|
|
|
Page({
|
|
data: {
|
|
isAgree: false,
|
|
loging:false,
|
|
animation:null,
|
|
userCode:'',
|
|
appConfig:{}
|
|
},
|
|
onLoad(options){
|
|
this.setData({
|
|
userCode:options.shared_user_code||''
|
|
});
|
|
|
|
app.getAppConfig().then((data)=>{
|
|
console.log(data);
|
|
this.setData({
|
|
appConfig:data
|
|
})
|
|
})
|
|
},
|
|
radioChange(event){
|
|
this.setData({
|
|
isAgree:event.detail.value!=''
|
|
})
|
|
},
|
|
preLogin(){
|
|
this.shake();
|
|
},
|
|
getPhoneNumber(event){
|
|
if(!event.detail.code){
|
|
//未接受
|
|
return;
|
|
}
|
|
this.setData({
|
|
loging:true
|
|
});
|
|
wx.login({
|
|
success: (res) => {
|
|
// 实现登录逻辑
|
|
this.sendLogin(res.code,event.detail.code);
|
|
},
|
|
fail:()=>{
|
|
this.setData({
|
|
loging:false
|
|
});
|
|
}
|
|
})
|
|
},
|
|
sendLogin(wxcode,phonecode){
|
|
userApi.loginWithCode(wxcode,phonecode,this.data.userCode).then((data)=>{
|
|
this.setData({
|
|
loging:false
|
|
});
|
|
app.globalData.accessToken = data.access_token;
|
|
wx.setStorage({
|
|
key:"accessToken",
|
|
data:data.access_token,
|
|
success(){
|
|
wx.navigateBack({
|
|
fail(){
|
|
wx.reLaunch({
|
|
url: '/pages/help/index/index',
|
|
})
|
|
}
|
|
});
|
|
}
|
|
})
|
|
})
|
|
},
|
|
navToPrivacy(){
|
|
wx.navigateTo({
|
|
url: `/pages/browser/index?url=${this.data.appConfig.url_user_privacy}`,
|
|
})
|
|
},
|
|
navToAgreement(){
|
|
wx.navigateTo({
|
|
url: `/pages/browser/index?url=${this.data.appConfig.url_user_agreement}`,
|
|
})
|
|
},
|
|
shake(){
|
|
if(!this.animation){
|
|
this.animation = wx.createAnimation({
|
|
duration: 20,
|
|
})
|
|
}
|
|
this.animation.translateX(10).step();
|
|
this.animation.translateX(-10).step();
|
|
this.animation.translateX(10).step();
|
|
this.animation.translateX(-10).step();
|
|
this.animation.translateX(5).step();
|
|
this.animation.translateX(0).step();
|
|
// needSetData[`${key}Animation`] = item.animation.export();
|
|
this.setData({
|
|
animation:this.animation.export()
|
|
})
|
|
}
|
|
}) |