拼团模块新增完善对接接口等
This commit is contained in:
@@ -31,158 +31,189 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
smsAuth,
|
||||
getInvitationSms,
|
||||
keyAuth
|
||||
} from '@/apis/interfaces/auth.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
phone : '',
|
||||
code : '',
|
||||
parentId : '',
|
||||
getSms : false,
|
||||
sendCode : '获取验证码',
|
||||
isShowParent: false,
|
||||
isKeyAuth : false
|
||||
};
|
||||
},
|
||||
onShow () {
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
mask : true
|
||||
})
|
||||
// 预登录
|
||||
uni.preLogin({
|
||||
provider: 'univerify',
|
||||
success: res => {
|
||||
this.isKeyAuth = true
|
||||
},
|
||||
complete() {
|
||||
uni.hideLoading()
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
// 获取验证码
|
||||
getPhoneCode() {
|
||||
uni.showLoading({
|
||||
title : '加载中...',
|
||||
mask :true
|
||||
})
|
||||
let outTime;
|
||||
let smsTime = 60;
|
||||
getInvitationSms({
|
||||
mobileNo: this.phone,
|
||||
}).then(res => {
|
||||
uni.showToast({
|
||||
title: res.message,
|
||||
icon: "none",
|
||||
});
|
||||
this.isShowParent = res.is_show_parent
|
||||
this.getSms = true;
|
||||
this.sendCode = smsTime + 's后重新获取';
|
||||
outTime = setInterval(() => {
|
||||
if (smsTime <= 1) {
|
||||
this.getSms = false;
|
||||
this.sendCode = '重新获取';
|
||||
clearInterval(outTime);
|
||||
return
|
||||
}
|
||||
this.sendCode = smsTime + 's后重新获取';
|
||||
smsTime -= 1;
|
||||
}, 1000);
|
||||
}).catch((err) => {
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
icon: "none",
|
||||
});
|
||||
});
|
||||
},
|
||||
// 登录
|
||||
login(type) {
|
||||
if (type === 'code') {
|
||||
uni.showLoading({
|
||||
title: '登录中'
|
||||
})
|
||||
smsAuth({
|
||||
mobileNo : this.phone,
|
||||
code : this.code,
|
||||
parent_id : this.parentId
|
||||
}).then((res) => {
|
||||
this.setAuthToken(res.token_type + ' ' + res.access_token, res.is_new)
|
||||
uni.hideLoading()
|
||||
}).catch((err) => {
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
icon: "none",
|
||||
});
|
||||
});
|
||||
return
|
||||
}
|
||||
if (type === 'Akey') {
|
||||
this.onKeyLogin()
|
||||
}
|
||||
},
|
||||
// 一键登录
|
||||
onKeyLogin(){
|
||||
uni.login({
|
||||
provider:'univerify',
|
||||
univerifyStyle:{
|
||||
icon: {
|
||||
path: require('@/static/logo.png')
|
||||
},
|
||||
authButton: {
|
||||
normalColor: '#34CE98',
|
||||
highlightColor: '#25b381',
|
||||
disabledColor: '#25b381'
|
||||
},
|
||||
otherLoginButton: {
|
||||
visible: false
|
||||
},
|
||||
privacyTerms: {
|
||||
termsColor: '#34CE98',
|
||||
uncheckedImage: require('@/static/icon/unchecked-icon.png'),
|
||||
checkedImage: require('@/static/icon/checked-icon.png')
|
||||
}
|
||||
},
|
||||
success: Result => {
|
||||
if(Result.errMsg === 'login:ok'){
|
||||
let {access_token, openid} = Result.authResult
|
||||
keyAuth({
|
||||
access_token,
|
||||
openid
|
||||
}).then(res => {
|
||||
this.setAuthToken(res.token_type + ' ' + res.access_token, res.is_new)
|
||||
uni.closeAuthView()
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: '登录失败:' + err.message,
|
||||
icon : 'none'
|
||||
})
|
||||
uni.closeAuthView()
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: err => {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
// setToken
|
||||
setAuthToken(token, isNew){
|
||||
this.$store.commit('setToken', token);
|
||||
if(isNew){
|
||||
uni.setStorageSync('isnew', 0)
|
||||
this.$Router.replace({name: 'AuthRole'})
|
||||
return
|
||||
}
|
||||
uni.setStorageSync('isnew', 1)
|
||||
this.$Router.pushTab({name: 'Life'})
|
||||
}
|
||||
}
|
||||
}
|
||||
import {
|
||||
smsAuth,
|
||||
getInvitationSms,
|
||||
keyAuth
|
||||
} from '@/apis/interfaces/auth.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
phone: '',
|
||||
code: '',
|
||||
parentId: '', // 父类邀请码
|
||||
getSms: false,
|
||||
sendCode: '获取验证码',
|
||||
isShowParent: false,
|
||||
isKeyAuth: false,
|
||||
shareId: ''
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
setTimeout(() => {
|
||||
if (plus.runtime.arguments.split('?')[1]) {
|
||||
let args = plus.runtime.arguments.split('?')[1]
|
||||
this.shareId = args.split('invitation')[0]
|
||||
this.parentId = args.split('invitation')[1]
|
||||
}
|
||||
}, 100);
|
||||
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
})
|
||||
// 预登录
|
||||
uni.preLogin({
|
||||
provider: 'univerify',
|
||||
success: res => {
|
||||
this.isKeyAuth = true
|
||||
},
|
||||
complete() {
|
||||
uni.hideLoading()
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
// 获取验证码
|
||||
getPhoneCode() {
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
})
|
||||
let outTime;
|
||||
let smsTime = 60;
|
||||
getInvitationSms({
|
||||
mobileNo: this.phone,
|
||||
}).then(res => {
|
||||
uni.showToast({
|
||||
title: res.message,
|
||||
icon: "none",
|
||||
});
|
||||
this.isShowParent = res.is_show_parent
|
||||
this.getSms = true;
|
||||
this.sendCode = smsTime + 's后重新获取';
|
||||
outTime = setInterval(() => {
|
||||
if (smsTime <= 1) {
|
||||
this.getSms = false;
|
||||
this.sendCode = '重新获取';
|
||||
clearInterval(outTime);
|
||||
return
|
||||
}
|
||||
this.sendCode = smsTime + 's后重新获取';
|
||||
smsTime -= 1;
|
||||
}, 1000);
|
||||
}).catch((err) => {
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
icon: "none",
|
||||
});
|
||||
});
|
||||
},
|
||||
// 登录
|
||||
login(type) {
|
||||
if (type === 'code') {
|
||||
uni.showLoading({
|
||||
title: '登录中'
|
||||
})
|
||||
smsAuth({
|
||||
mobileNo: this.phone,
|
||||
code: this.code,
|
||||
parent_id: this.parentId
|
||||
}).then((res) => {
|
||||
this.setAuthToken(res.token_type + ' ' + res.access_token, res.is_new)
|
||||
uni.hideLoading()
|
||||
}).catch((err) => {
|
||||
uni.showToast({
|
||||
title: err.message,
|
||||
icon: "none",
|
||||
});
|
||||
});
|
||||
return
|
||||
}
|
||||
if (type === 'Akey') {
|
||||
this.onKeyLogin()
|
||||
}
|
||||
},
|
||||
// 一键登录
|
||||
onKeyLogin() {
|
||||
uni.login({
|
||||
provider: 'univerify',
|
||||
univerifyStyle: {
|
||||
icon: {
|
||||
path: require('@/static/logo.png')
|
||||
},
|
||||
authButton: {
|
||||
normalColor: '#34CE98',
|
||||
highlightColor: '#25b381',
|
||||
disabledColor: '#25b381'
|
||||
},
|
||||
otherLoginButton: {
|
||||
visible: false
|
||||
},
|
||||
privacyTerms: {
|
||||
termsColor: '#34CE98',
|
||||
uncheckedImage: require('@/static/icon/unchecked-icon.png'),
|
||||
checkedImage: require('@/static/icon/checked-icon.png')
|
||||
}
|
||||
},
|
||||
success: Result => {
|
||||
if (Result.errMsg === 'login:ok') {
|
||||
let {
|
||||
access_token,
|
||||
openid
|
||||
} = Result.authResult
|
||||
keyAuth({
|
||||
access_token,
|
||||
openid
|
||||
}).then(res => {
|
||||
this.setAuthToken(res.token_type + ' ' + res.access_token, res
|
||||
.is_new)
|
||||
uni.closeAuthView()
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: '登录失败:' + err.message,
|
||||
icon: 'none'
|
||||
})
|
||||
uni.closeAuthView()
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: err => {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
// setToken
|
||||
setAuthToken(token, isNew) {
|
||||
this.$store.commit('setToken', token);
|
||||
if (isNew) {
|
||||
uni.setStorageSync('isnew', 0)
|
||||
this.$Router.replace({
|
||||
name: 'AuthRole',
|
||||
params: {
|
||||
shareId: this.shareId
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
uni.setStorageSync('isnew', 1)
|
||||
if (this.shareId != '' && this.shareId != undefined) {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading()
|
||||
plus.runtime.arguments = null;
|
||||
plus.runtime.arguments = '';
|
||||
uni.reLaunch({
|
||||
url: '/pages/group-book/success/success?access=1&id=' + this.shareId
|
||||
})
|
||||
}, 1000)
|
||||
} else {
|
||||
this.$Router.pushTab({
|
||||
name: 'Life'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user