diff --git a/honey_box/components/order-confirm-popup/order-confirm-popup-flw.vue b/honey_box/components/order-confirm-popup/order-confirm-popup-flw.vue
index b1f0e021..d28f2e40 100644
--- a/honey_box/components/order-confirm-popup/order-confirm-popup-flw.vue
+++ b/honey_box/components/order-confirm-popup/order-confirm-popup-flw.vue
@@ -415,13 +415,14 @@ export default {
margin: 30rpx auto 0;
width: 686rpx;
height: 84rpx;
- background: url($imgurl + "common/payBtn.png") no-repeat 0 0 / 100% 100%;
+ background: #03D8F4;
+ border-radius: 14rpx;
display: flex;
margin-bottom: 90rpx;
align-items: center;
justify-content: center;
font-weight: 500;
- color: #cdef27;
+ color: #404040;
>text:nth-child(1) {
font-size: 28rpx;
diff --git a/honey_box/components/order-confirm-popup/order-confirm-popup.vue b/honey_box/components/order-confirm-popup/order-confirm-popup.vue
index cd05b2f7..de3f25c4 100644
--- a/honey_box/components/order-confirm-popup/order-confirm-popup.vue
+++ b/honey_box/components/order-confirm-popup/order-confirm-popup.vue
@@ -511,15 +511,14 @@
margin: 30rpx auto 0;
width: 686rpx;
height: 84rpx;
- // background: url($imgurl + "common/payBtn.png") no-repeat 0 0 / 100% 100%;
- background-color: #424242;
+ background: #03D8F4;
border-radius: 14rpx;
display: flex;
margin-bottom: 90rpx;
align-items: center;
justify-content: center;
font-weight: 500;
- color: #FFED94;
+ color: #404040;
>text:nth-child(1) {
font-size: 28rpx;
diff --git a/honey_box/pages.json b/honey_box/pages.json
index 20949777..7ece498b 100644
--- a/honey_box/pages.json
+++ b/honey_box/pages.json
@@ -64,7 +64,7 @@
"path": "pages/user/login",
"style": {
"navigationBarTitleText": "登录",
- "navigationBarBackgroundColor": "#FFFFFF",
+ "navigationStyle": "custom",
"navigationBarTextStyle": "black"
}
},
@@ -72,7 +72,7 @@
"path": "pages/user/bangding",
"style": {
"navigationBarTitleText": "绑定手机号",
- "navigationBarBackgroundColor": "#FFFFFF",
+ "navigationStyle": "custom",
"navigationBarTextStyle": "black"
}
},
diff --git a/honey_box/pages/user/bangding.vue b/honey_box/pages/user/bangding.vue
index a9c82791..4bac1164 100644
--- a/honey_box/pages/user/bangding.vue
+++ b/honey_box/pages/user/bangding.vue
@@ -1,28 +1,26 @@
-
-
-
@@ -31,129 +29,127 @@ import { bindMobileByWx } from '@/common/server/auth.js';
export default {
data() {
- return {
- z_imgPath: this.$z_img2
- }
- },
- created() {
- //默认加载
- // this.login();
+ return {}
},
methods: {
back() {
- // 尝试返回上一页
let that = this;
uni.navigateBack({
fail: function() {
- // 如果返回失败,表示没有上一页,则跳转到首页
that.$customRouter.navigateTo('/pages/user/index', {}, 'reLaunch');
}
});
},
+
async getPhoneNumber(e) {
- // console.log(e)
- let that = this
+ if (!e.detail.code) {
+ return uni.showToast({ title: '授权失败,请重试', icon: 'none' });
+ }
+
+ let that = this;
uni.login({
async success(res) {
- // console.log(res)
uni.checkSession({
async success() {
- const result = await bindMobileByWx(e.detail.code);
- if (result.status == 1) {
- if(result.data!=null&&result.data.token!=null){
- uni.setStorageSync('token', result.data.token);
- }
- uni.showToast({
- title: '绑定成功~',
- icon: 'success',
- success() {
- // var pageurl = uni.getStorageSync(
- // 'page');
- setTimeout(() => {
- // 返回上一页而不是跳转到首页
- uni.navigateBack({
- fail: function() {
- // 如果返回失败,表示没有上一页,则跳转到首页
- that.$customRouter.navigateTo('/pages/user/index', {}, 'reLaunch');
- }
- });
- }, 1000)
+ try {
+ const result = await bindMobileByWx(e.detail.code);
+ if (result.status == 1) {
+ if (result.data?.token) {
+ uni.setStorageSync('token', result.data.token);
}
- })
+ uni.showToast({
+ title: '绑定成功~',
+ icon: 'success',
+ success() {
+ setTimeout(() => {
+ uni.navigateBack({
+ fail: function() {
+ that.$customRouter.navigateTo('/pages/user/index', {}, 'reLaunch');
+ }
+ });
+ }, 1000);
+ }
+ });
+ } else {
+ uni.showToast({ title: result.msg || '绑定失败', icon: 'none' });
+ }
+ } catch (error) {
+ uni.showToast({ title: '绑定失败,请重试', icon: 'none' });
}
}
- })
+ });
}
- })
+ });
}
}
}
-
\ No newline at end of file
+
diff --git a/honey_box/pages/user/login.vue b/honey_box/pages/user/login.vue
index b0c29ea3..288a9fe6 100644
--- a/honey_box/pages/user/login.vue
+++ b/honey_box/pages/user/login.vue
@@ -1,100 +1,64 @@
-
-
-
-
-
@@ -105,105 +69,79 @@
export default {
data() {
return {
- z_imgPath: this.$z_img2,
- SessionKey: '',
- OpenId: '',
- nickName: null,
- avatarUrl: null,
- isCanUse: uni.getStorageSync('isCanUse') || true, //默认为true
- code: '',
isAgree: false,
- // H5手机号登录相关数据
- isMpWeixin: false, // 是否为小程序环境
- mobile: '', // 手机号
- verifyCode: '', // 验证码
- countdown: 0, // 发送验证码倒计时
- timer: null, // 倒计时定时器
- codeSent: false // 是否已发送验证码
+ isMpWeixin: false,
+ showPhoneLogin: false,
+ mobile: '',
+ verifyCode: '',
+ countdown: 0,
+ timer: null,
+ codeSent: false
}
},
- onLoad(option) {
- // 判断当前环境
+ onLoad() {
// #ifdef MP
this.isMpWeixin = true;
// #endif
-
- //默认加载
- if (option != null) {
- if (option.code != null) {
-
- }
- }
},
onUnload() {
- // 清除定时器
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
},
+ watch: {
+ showPhoneLogin(val) {
+ if (val && this.$refs.phonePopup) {
+ this.$refs.phonePopup.open();
+ }
+ }
+ },
methods: {
- //返回上一页
navigateBack() {
uni.navigateBack({
delta: 1,
fail: () => {
- // 如果没有上一页,则跳转到首页
this.$customRouter.navigateTo('/pages/shouye/index', {}, 'switchTab');
}
});
},
- //第一授权获取用户信息===》按钮触发
- getUserProfile(e) {
- if (!this.isAgree) {
- return uni.showToast({
- title: '请阅读并同意《用户协议》和《隐私政策》',
- icon: 'none'
- });
+
+ goAgreement(type) {
+ // #ifdef MP
+ this.$customRouter.navigateTo('/pages/guize/guize', { type });
+ // #endif
+ // #ifndef MP
+ if (type === 4) {
+ this.$platform.getUserAgreement();
+ } else {
+ this.$platform.getPrivacyAgreement();
+ }
+ // #endif
+ },
+
+ getUserProfile() {
+ if (!this.isAgree) {
+ return uni.showToast({ title: '请先同意用户协议和隐私政策', icon: 'none' });
}
-
// #ifdef MP
this.wxUserProfile();
// #endif
},
- // 发送验证码
+
async sendVerifyCode() {
- // 如果正在倒计时,不允许重复发送
- if (this.countdown > 0) {
- return;
- }
-
- // 检查是否同意协议
- if (!this.isAgree) {
- return uni.showToast({
- title: '请阅读并同意《用户协议》和《隐私政策》',
- icon: 'none'
- });
- }
-
- // 验证手机号
+ if (this.countdown > 0) return;
+
if (!this.mobile || !/^1\d{10}$/.test(this.mobile)) {
- return uni.showToast({
- title: '请输入正确的手机号',
- icon: 'none'
- });
+ return uni.showToast({ title: '请输入正确的手机号', icon: 'none' });
}
-
- // 发送验证码请求
+
try {
const res = await sendSms(this.mobile);
-
if (res.status == 1) {
- uni.showToast({
- title: '验证码已发送',
- icon: 'none'
- });
-
- // 标记已发送验证码(仅当前会话有效)
+ uni.showToast({ title: '验证码已发送', icon: 'none' });
this.codeSent = true;
-
- // 开始倒计时,使用接口返回的时间
- this.countdown = res.data || 60; // 使用返回的秒数,默认60秒
+ this.countdown = res.data || 60;
this.timer = setInterval(() => {
this.countdown--;
if (this.countdown <= 0) {
@@ -212,212 +150,98 @@
}
}, 1000);
} else {
- uni.showToast({
- title: res.msg || '发送失败,请稍后重试',
- icon: 'none'
- });
+ uni.showToast({ title: res.msg || '发送失败', icon: 'none' });
}
} catch (error) {
- uni.showToast({
- title: '发送验证码失败,请稍后重试',
- icon: 'none'
- });
- console.error('发送验证码失败:', error);
+ uni.showToast({ title: '发送失败,请稍后重试', icon: 'none' });
}
},
- // 手机号登录
+
async phoneLogin() {
- // 验证表单
if (!this.isAgree) {
- return uni.showToast({
- title: '请阅读并同意《用户协议》和《隐私政策》',
- icon: 'none'
- });
+ return uni.showToast({ title: '请先同意用户协议和隐私政策', icon: 'none' });
}
-
if (!this.mobile || !/^1\d{10}$/.test(this.mobile)) {
- return uni.showToast({
- title: '请输入正确的手机号',
- icon: 'none'
- });
+ return uni.showToast({ title: '请输入正确的手机号', icon: 'none' });
}
-
if (!this.verifyCode) {
- return uni.showToast({
- title: '请输入验证码',
- icon: 'none'
- });
+ return uni.showToast({ title: '请输入验证码', icon: 'none' });
}
-
- // 检查当前会话中是否发送过验证码
- // if (!this.codeSent) {
- // return uni.showToast({
- // title: '请先发送验证码',
- // icon: 'none'
- // });
- // }
-
- // 发送登录请求
+
try {
const res = await mobileLogin(this.mobile, this.verifyCode, uni.getStorageSync('pid'));
-
if (res.status == 1) {
- // 使用新的Token存储方法,支持双Token格式
saveLoginTokens(res.data);
this.$c.msg("登录成功");
-
- // 检查重定向URL
- const redirectUrl = uni.getStorageSync('redirect');
-
- if (redirectUrl) {
- // 清除重定向信息
- uni.removeStorageSync('redirect');
- // 使用公共方法处理重定向
- this.handleRedirect(redirectUrl);
- } else {
- // 无重定向页面,检查是否需要绑定手机号
- setTimeout(() => {
- this.getdata();
- }, 1000);
- }
+ this.handleLoginSuccess();
} else {
- this.$c.msg("登录失败!" + res.msg);
+ this.$c.msg("登录失败: " + res.msg);
}
} catch (error) {
- // this.$c.msg("登录请求失败,请稍后重试");
console.error('登录失败:', error);
}
},
- /**
- * 处理登录成功后的重定向逻辑
- * @param {String} redirectUrl 重定向URL
- */
- handleRedirect(redirectUrl) {
- let that = this;
-
- // 获取当前页面栈
- const pages = getCurrentPages();
-
- // 检查是否有上一页,以及redirect URL是否与上一页相同
- if (pages.length > 1) {
- const prevPage = pages[pages.length - 2];
- // 构建完整的上一页路径(带参数)
- let prevPageUrl = '/' + prevPage.route;
- if (prevPage.options && Object.keys(prevPage.options).length > 0) {
- const paramStr = Object.keys(prevPage.options)
- .map(key => `${key}=${prevPage.options[key]}`)
- .join('&');
- prevPageUrl += '?' + paramStr;
- }
-
- // 比较redirect URL和上一页URL
- const redirectUrlPath = redirectUrl.split('?')[0];
- const prevPageUrlPath = prevPageUrl.split('?')[0];
-
- if (redirectUrlPath === prevPageUrlPath) {
- // 如果路径相同,直接返回上一页
- console.log('重定向URL与上一页相同,直接返回');
- setTimeout(() => {
- uni.navigateBack();
- }, 1000);
- return true;
- }
- }
-
- // 重定向到指定URL
- setTimeout(() => {
- that.$customRouter.navigateTo(redirectUrl).catch(err => {
- console.error('重定向跳转失败:', err)
- // 失败时跳转到首页
- that.$customRouter.navigateTo('/pages/user/index')
- })
- }, 1000);
-
- return true;
- },
+
async wxUserProfile() {
try {
- const profileRes = await new Promise((resolve, reject) => {
+ await new Promise((resolve, reject) => {
uni.getUserProfile({
- desc: '用于向用户发送商品',
+ desc: '用于完善用户资料',
lang: 'zh_CN',
success: resolve,
- fail: reject,
- complete: (e) => {
- console.log(e, '用于向用户发送商品');
- }
+ fail: reject
});
});
-
- try {
- const loginRes = await new Promise((resolve, reject) => {
- uni.login({
- provider: 'weixin',
- success: resolve,
- fail: (e) => {
- this.$c.msg("登录失败,网络错误!" + e.msg);
- console.log(e, '登录失败', e);
- reject(e);
- },
- complete: (e) => {
- console.log(e, '登录');
- }
- });
+
+ const loginRes = await new Promise((resolve, reject) => {
+ uni.login({
+ provider: 'weixin',
+ success: resolve,
+ fail: reject
});
-
- try {
- const res = await wxLogin({
- code: loginRes.code,
- nickname: '',
- headimg: '',
- pid: uni.getStorageSync('pid')
- });
- console.log(res, '登录成功');
-
- if (res.status == 1) {
- // 使用新的Token存储方法,支持双Token格式
- saveLoginTokens(res.data);
- this.$c.msg("登录成功");
-
- // 检查重定向URL
- const redirectUrl = uni.getStorageSync('redirect');
-
- if (redirectUrl) {
- // 清除重定向信息
- uni.removeStorageSync('redirect');
-
- // 使用公共方法处理重定向
- this.handleRedirect(redirectUrl);
- } else {
- // 无重定向页面,检查是否需要绑定手机号
- setTimeout(() => {
- this.getdata();
- }, 1000);
- }
- } else {
- this.$c.msg("登录失败!" + res.msg);
- }
- } catch (error) {
- console.error('请求登录失败:', error);
- }
- } catch (error) {
- console.error('微信登录失败:', error);
+ });
+
+ const res = await wxLogin({
+ code: loginRes.code,
+ nickname: '',
+ headimg: '',
+ pid: uni.getStorageSync('pid')
+ });
+
+ if (res.status == 1) {
+ saveLoginTokens(res.data);
+ this.$c.msg("登录成功");
+ this.handleLoginSuccess();
+ } else {
+ this.$c.msg("登录失败: " + res.msg);
}
} catch (error) {
- this.$c.msg("登录失败,申请获取微信用户数据失败");
- console.log(error, '获取微信用户数据失败');
+ this.$c.msg("登录失败,请重试");
+ console.error('微信登录失败:', error);
}
},
- async getdata() {
+
+ async handleLoginSuccess() {
+ const redirectUrl = uni.getStorageSync('redirect');
+ if (redirectUrl) {
+ uni.removeStorageSync('redirect');
+ setTimeout(() => {
+ this.$customRouter.navigateTo(redirectUrl).catch(() => {
+ this.$customRouter.navigateTo('/pages/user/index');
+ });
+ }, 1000);
+ } else {
+ setTimeout(() => this.checkUserMobile(), 1000);
+ }
+ },
+
+ async checkUserMobile() {
try {
const res = await getUser();
- if (res.status == 1 && res.data.userinfo != null && res.data.userinfo.mobile_is == 0) {
- console.log("判断用户有没有手机号", res.data.userinfo.mobile_is);
- // 使用新的路由守卫方法跳转到绑定页面
- this.$customRouter.navigateTo('/pages/user/bangding', {}, 'navigateTo');
+ if (res.status == 1 && res.data.userinfo?.mobile_is == 0) {
+ this.$customRouter.navigateTo('/pages/user/bangding');
} else {
- // 使用新的路由守卫方法跳转到用户首页
- this.$customRouter.navigateTo('/pages/user/index', {}, 'navigateTo');
+ this.$customRouter.navigateTo('/pages/user/index');
}
} catch (error) {
console.error('获取用户数据失败:', error);
@@ -427,142 +251,169 @@
}
-
\ No newline at end of file
+