支付成功

This commit is contained in:
魏啾
2024-04-18 14:36:14 +08:00
parent 007d9e4336
commit 4bc97b35fd
11 changed files with 1145 additions and 140 deletions

View File

@@ -37,10 +37,18 @@
<text @click="register">注册账号</text>
<text @click="passwords">忘记密码</text>
</view>
<!-- #ifdef MP-WEIXIN -->
<button class="toLogin" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" v-if="!showbox">手机号快速登录
</button>
<view class="toLogin" v-if="showbox" @click="toLoginconfirm">登录</view>
<view class="toLogins" @click="showbox = !showbox">其他手机号登录/注册</view>
<!-- #endif -->
<!-- #ifdef APP-PLUS || H5 -->
<button class="toLogin" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" v-if="!showbox">手机号快速登录
</button>
<view class="toLogin" v-if="showbox" @click="toLoginconfirm">登录</view>
<view class="toLogins" @click="showbox = !showbox">其他手机号登录/注册</view>
<!-- #endif -->
<view class="agreement flex-start">
<u-checkbox-group><u-checkbox shape="circle" @change="radioChange"
size="24"></u-checkbox></u-checkbox-group>
@@ -50,7 +58,7 @@
<view class="agreement-Item" @click="Privacy(2)">隐私政策</view>
</view>
</view>
<!-- #ifdef APP-PLUS -->
<!-- #ifdef APP-PLUS || H5 -->
<view class="box_conf" v-if="debug" @click="showpicker = true">{{ baseUrl || '切换' }}</view>
<!-- #endif -->
<u-overlay :show="agreeShow">
@@ -93,6 +101,7 @@
showpopup: false,
valueinput: '',
showbox: false,
columns: [
['http://admintestapi.sxczgkj.cn/', 'https://ky.sxczgkj.cn', 'http://192.168.2.22:7004',
'http://admintestapi.sxczgkj.cn/', '自定义输入'
@@ -121,7 +130,11 @@
this.computed_h();
},
onLoad() {},
onLoad() {
// #ifdef APP-PLUS || H5
this.showbox = true
// #endif
},
methods: {
// 同意隐私政策
agree() {
@@ -145,7 +158,7 @@
},
// 拒绝隐私政策-退出应用
refuse() {
// #ifdef APP-PLUS
// #ifdef APP-PLUS || H5
//android 退出方法
plus.runtime.quit();
// ios 退出方法
@@ -163,18 +176,17 @@
},
async CodeRegister() {
//发起验证码
if (this.form.telephone == null || this.form.telephone == '') {
if (this.form.loginName == null || this.form.loginName == '') {
uni.showToast({
title: '请输入电话号码',
icon: 'none'
});
return false;
}
const res = await this.apix.phoneValidateCode({
const res = await this.api.phoneValidateCode({
// post 手机验证码
phone: this.form.telephone
phone: this.form.loginName
});
console.log(res);
if (res) {
uni.showToast({
title: '验证码获取成功',
@@ -240,7 +252,7 @@
height: h
};
},
async toLogin() {
async toLoginconfirm() {
//登录
if (this.form.loginName == null || this.form.loginName == '') {
uni.showToast({
@@ -249,14 +261,6 @@
});
return false;
}
if (this.form.password == null || this.form.password == '' || uni.$u.trim(this.form.password, 'all') ==
'') {
uni.showToast({
title: '请输入密码或密码不能输入空格',
icon: 'none'
});
return false;
}
if (this.radioChangeItem == false) {
uni.showToast({
icon: 'none',
@@ -264,45 +268,21 @@
});
return;
}
let res = await this.api.Login({
loginName: this.form.loginName,
password: this.form.password
let res = await this.api.loginapplogin({
username: this.form.loginName,
password: this.form.password,
code: this.form.code
});
console.log(res);
if (res.code == 200) {
uni.cache.set('loginName', this.form.loginName + '');
uni.cache.set('password', this.form.password + '');
uni.cache.set('token', res.data.userApp.token);
uni.cache.set('myLoginName', res.data.userInfo.loginName);
uni.cache.set('userId', res.data.userInfo.id);
if (res.code == 0) {
uni.cache.set('token', res.data.token);
uni.cache.set('miniAppOpenId', res.data.userInfo
.miniAppOpenId)
uni.cache.set('userInfo', res.data.userInfo);
uni.cache.set('userApp', res.data.userApp);
// 积分商城用到的token
// uni.cache.set('rechargeToken', res.data.rechargeToken);
this.$store.commit('set_login', true);
this.$store.commit('userInfo', res.data.userInfo);
this.$store.commit('userApp', res.data.userApp);
this.$store.dispatch('USerVoiceactions'); //获取语音播报初始数据
// #ifdef APP-PLUS
try {
let pinf = plus.push.getClientInfo();
let cid = (pinf && pinf.clientid) || ''; //客户端标识
uni.cache.set('cid', cid);
let res = await this.api.pushbindalias({
cid: cid
});
console.log('cid res===', res);
console.log('cid===', cid);
} catch (e) {
console.log('ciderr===', e);
//TODO handle the exception
}
// #endif
uni.pro.switchTab('/pages/index/index');
} else {
this.$api.msg(res.message);
// uni.cache.set('shopUser', res.data.shopUser);
uni.pro.switchTab('index/index')
}
},
async getPhoneNumber(res) { // 获取手机号
var resdataa = res
@@ -321,12 +301,47 @@
this.phone = resdata.data
this.userlogin()
}
// this.userlogin()
}
});
// #endif
},
async userlogin() {
// #ifdef MP-WEIXIN
uni.login({
provider: 'weixin',
success: async (data) => {
try {
uni.getUserInfo({
provider: 'weixin',
success: async (infoRes) => {
uni.cache.set('weixincode', data.code);
let res = await this.api.userwxlogin({
code: uni.cache.get('weixincode'), //临时登录凭证
encryptedData: infoRes
.encryptedData, // 用户非敏感信息
rawData: infoRes.rawData,
signature: infoRes.signature,
iv: infoRes.iv,
phone: this.phone
})
if (res.code == 0) {
uni.cache.set('token', res.data.token);
uni.cache.set('miniAppOpenId', res.data.userInfo
.miniAppOpenId)
uni.cache.set('userInfo', res.data.userInfo);
uni.cache.set('shopUser', res.data.shopUser);
uni.pro.switchTab('index/index')
}
},
fail: (err) => {
console.log(err)
}
});
} catch (e) {
console.log(e)
}
}
});
// #endif
},
}