This commit is contained in:
2026-04-10 10:19:42 +08:00
parent 7a490f0ffc
commit cdf0bc5a01
7 changed files with 186 additions and 92 deletions

View File

@ -2,7 +2,7 @@ import request from "../utils/request";
import { LOGIN, GET_PHONE, USER_SHARE,USER_WALLET,RECHARGE_WALLET,USER_WXPAY,USER_TRANSACTION,USER_ADDITIONAL,MEMBER_TYPES,
USER_RECHARGE,USER_REDEEM,USER_HolderList,USER_MEMBERSHIP,USER_BINDPETS,USER_PETBINDING,USER_DISCOUNTFEE,USER_COUPONLIST,CANCEL_PET_ORDER,
GET_VIP_PRICE,POINTS_RECHARGE_LIST,POINTS_DONATE,POINTS_RECORDS,POINTS_RANK,OSS_STS,DONATION_SUMMARY,
USER_DISPATCHFEE,CANCEL_MALL_ORDER,DOUY_REVIEW,CANCEL_NOMO_ORDER
USER_DISPATCHFEE,CANCEL_MALL_ORDER,DOUY_REVIEW,CANCEL_NOMO_ORDER,LOGIN_PHONE
} from "./url";
// 微信登陆
export const getCodeByWxLogin = () => {
@ -10,7 +10,7 @@ export const getCodeByWxLogin = () => {
tt.login({
provider: "toutiao",
success: function (loginRes) {
// console.log(loginRes,'?1?')
console.log(loginRes,'?1?')
resolve(loginRes.code);
},
fail: function (err) {
@ -23,7 +23,7 @@ export const getCodeByWxLogin = () => {
import Store from "../store";
// 登录鉴权
export const login = (nickName, avatarUrl) => {
export const login = ( phone) => {
return getCodeByWxLogin().then((code) => {
// 从 vuex 中获取 referrerID如果通过二维码扫描进入
const referrerID = Store.state.user?.referrerID || 0;
@ -32,17 +32,11 @@ export const login = (nickName, avatarUrl) => {
url: LOGIN,
method: "POST",
data: {
nickName:nickName,
avatarUrl:avatarUrl,
code: code,
source:'douyin',
referrerID:0,
referrerType:'douyin'
// // yaoqing_code: inviteCode || null,
// phone: phone || null,
// source: "wechat",
// referrerID: Number(referrerID) || 0,
// referrerType: "wechat"
phone: phone || null,
source: 'douyin',
referrerID: 0,
referrerType: 'douyin'
},
}).then((res) => {
// 登录接口使用完 referrerID 后,清除一次,避免重复使用
@ -54,12 +48,13 @@ export const login = (nickName, avatarUrl) => {
});
};
// 获取手机号
export const getPhone = (code) => {
export const getPhone = (phoneCode, loginCode) => {
return request({
url: GET_PHONE,
method: "POST",
data: {
code: code
code: phoneCode,
loginCode: loginCode
},
});
};
@ -74,6 +69,18 @@ export const userShare = (id) => {
});
};
export const login_phone = (phone) => {
return request({
url: LOGIN_PHONE,
method: "POST",
data: {
phone
},
});
};
// 用户钱包
export const userWllet = (id) => {
return request({

View File

@ -59,6 +59,7 @@ export const DOUY_REVIEW = '/douyin/goods/order/appointment'
// 抖音未支付订单取消接口
export const CANCEL_NOMO_ORDER = '/douyin/goods/order/cancel'
export const LOGIN_PHONE = '/api/v1/auth/login'
// 取消商城接口
export const CANCEL_MALL_ORDER = '/douyin/goods/order/refund'

View File

@ -1,17 +1,28 @@
<template>
<view class="loginContainer">
<view class="body">
<image class="login-ground-img" :src="`${imgPrefix}loginGroundImg.png`" mode="widthFix" />
<image
class="login-ground-img"
:src="`${imgPrefix}loginGroundImg.png`"
mode="widthFix"
/>
<view class="btnConent">
<button v-show="!checked" class="loginBtn" @click="unCheckAndGetPhoneNumber">
<button
v-show="!checked"
class="loginBtn"
@click="unCheckAndGetPhoneNumber"
>
抖音用户信息授权登录
</button>
<button v-show="checked" class="loginBtn" @tap="getPhoneNumber" >
抖音用户信息授权登录
<button
v-show="checked"
class="loginBtn"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
>
抖音用户信息授权登录
</button>
<view class="notLoginBtn" @click="goBack">
暂不登录
</view>
<view class="notLoginBtn" @click="goBack"> 暂不登录 </view>
</view>
</view>
@ -19,7 +30,11 @@
<view class="radioWrapper">
<view class="checkbox-wrapper" @click.stop="changeChecked">
<view class="checkbox" :class="{ 'checkbox-checked': checked }">
<image v-if="checked" class="check-icon" :src="require('@/static/images/y.png')" />
<image
v-if="checked"
class="check-icon"
:src="require('@/static/images/y.png')"
/>
</view>
<!-- <view v-if="uncheckMessageDialog" class="tooltip">
<view class="tooltip-content">请先勾选同意后再进行登录</view>
@ -28,7 +43,9 @@
</view>
<text class="radioText">
请阅读并同意
<text class="color" @click.stop="ptfwxy">帮宠到家平台服务协议</text>
<text class="color" @click.stop="ptfwxy"
>帮宠到家平台服务协议</text
>
<text class="color" @click.stop="ysxy">隐私协议</text>
</text>
</view>
@ -54,6 +71,16 @@ export default {
},
onLoad(options) {
this.yaoqing_code = options.yaoqing_code
tt.login({
provider: "toutiao",
success: function (loginRes) {
console.log('获取 login code 成功:', loginRes);
},
fail: function (err) {
console.log('获取 login code 失败:', err);
},
});
},
mounted() { },
methods: {
@ -81,14 +108,14 @@ export default {
duration: 2000
});
},
getmembeInfo(nickName,avatarUrl) {
getmembeInfo(phone) {
const inviteCode = this.yaoqing_code ? this.yaoqing_code : getApp().globalData.inviteCode
uni.showLoading({
title: "登录中...",
icon: "none",
mask: true,
});
login(nickName,avatarUrl).then((res) => {
login(phone).then((res) => {
uni.hideLoading()
this.$store.dispatch("user/setToken", res?.data?.token || "");
this.$store.dispatch("user/setUserInfo", res?.data || {});
@ -143,77 +170,128 @@ export default {
// });
// }),
async getPhoneNumber(e) {
// console.log(e,'?')
// return
// 检查是否有 code
// if (!e.detail.code) {
console.log('获取手机号事件:', e);
this.getmembeInfo(e.detail.code)
// // 检查是否有 code
// if (!e.detail || !e.detail.code) {
// uni.showToast({
// title: "获取手机号失败,请重试",
// title: "用户取消授权或获取手机号失败",
// icon: "none",
// });
// return;
// }
// uni.showLoading({
// title: "获取手机号中...",
// title: "登录中...",
// icon: "none",
// mask: true,
// });
try {
let that = this
tt.getUserProfile({
// try {
// const that = this;
// let loginCode = null;
success(res) {
console.log(res,'???')
// this.nickName = res.res.userInfo.nickName
// this.avatarUrl = res.userInfo.avatarUrl
that.getmembeInfo(res.userInfo.nickName,res.userInfo.avatarUrl)
// console.log(res,'--=')
},
fail(res) {
console.log("getUserProfile 调用失败", res);
},
// // 先获取 login code
// try {
// loginCode = await new Promise((resolve, reject) => {
// tt.login({
// provider: "toutiao",
// success: function (loginRes) {
// console.log('获取 login code 成功:', loginRes);
// resolve(loginRes.code);
// },
// fail: function (err) {
// console.log('获取 login code 失败:', err);
// reject(err);
// },
// });
// });
// } catch (loginErr) {
// throw new Error('获取登录凭证失败');
// }
});
// // 拿着 phone code 和 login code 获取手机号
// let phone = null;
// try {
// const codeRes = await getPhone(e.detail.code, loginCode);
// phone = codeRes?.data?.phoneNumber || "";
// console.log('获取手机号成功:', phone);
// } catch (phoneErr) {
// console.error('获取手机号失败:', phoneErr);
// throw new Error('获取手机号失败');
// }
// if (!phone) {
// throw new Error('获取手机号失败,请重试');
// }
// const inviteCode = this.yaoqing_code ? this.yaoqing_code : getApp().globalData.inviteCode
// console.log('获取到邀请码----->', inviteCode)
// 手机号登录
// 获取用户信息
// tt.getUserProfile({
// success: async (profileRes) => {
// console.log('获取用户信息成功:', profileRes);
// const nickName = profileRes.userInfo?.nickName || '';
// const avatarUrl = profileRes.userInfo?.avatarUrl || '';
// 拿着code获取手机号
// const codeRes = await getPhone(e.detail.code);
// const phone = codeRes?.data?.phoneNumber || "";
// try {
// const inviteCode = that.yaoqing_code ? that.yaoqing_code : getApp().globalData.inviteCode;
// if (!phone) {
// uni.hideLoading();
// uni.showToast({
// title: "获取手机号失败,请重试",
// icon: "none",
// });
// return;
// }
// // 登录
// const loginRes = await login(nickName, avatarUrl, phone);
// uni.hideLoading();
// that.$store.dispatch("user/setToken", loginRes?.data?.token || "");
// that.$store.dispatch("user/setUserInfo", loginRes?.data || {});
} catch (error) {
uni.hideLoading();
console.error("获取手机号失败:", error);
// 检查是否是 access_token 相关错误
const errorMsg = error?.message || error || "";
if (errorMsg.includes("access_token") || errorMsg.includes("invalid credential")) {
uni.showToast({
title: "服务暂时不可用,请稍后重试",
icon: "none",
duration: 3000,
});
} else {
uni.showToast({
title: errorMsg || "获取手机号失败,请重试",
icon: "none",
});
}
}
// var pages = getCurrentPages();
// if (inviteCode) {
// uni.reLaunch({
// url: "/pages/client/index/index",
// });
// return;
// }
// if (pages.length === 1) {
// uni.reLaunch({
// url: "/pages/client/index/index",
// });
// return;
// }
// uni.navigateBack();
// } catch (loginErr) {
// uni.hideLoading();
// console.error('登录失败:', loginErr);
// uni.showToast({
// title: loginErr || "登录失败,请重试",
// icon: "none",
// });
// }
// },
// fail: (profileErr) => {
// uni.hideLoading();
// console.log("getUserProfile 调用失败", profileErr);
// uni.showToast({
// title: "获取用户信息失败",
// icon: "none",
// });
// },
// });
// } catch (error) {
// uni.hideLoading();
// console.error("获取手机号失败:", error);
// const errorMsg = error?.message || error || "";
// if (errorMsg.includes("access_token") || errorMsg.includes("invalid credential")) {
// uni.showToast({
// title: "服务暂时不可用,请稍后重试",
// icon: "none",
// duration: 3000,
// });
// } else {
// uni.showToast({
// title: errorMsg || "获取手机号失败,请重试",
// icon: "none",
// });
// }
// }
},
loginAction() {
if (!this.checked) {
@ -300,8 +378,8 @@ export default {
.notLoginBtn {
background-color: #fff;
color: #FF19A0;
border: 1rpx solid #FF19A0;
color: #ff19a0;
border: 1rpx solid #ff19a0;
border-radius: 300rpx;
padding: 26rpx 0rpx;
text-align: center;
@ -333,13 +411,13 @@ export default {
display: flex;
align-items: center;
justify-content: center;
background: #FFFFFF;
background: #ffffff;
transition: all 0.3s ease;
flex-shrink: 0;
&.checkbox-checked {
border-color: #FF19A0;
background: #FF19A0;
border-color: #ff19a0;
background: #ff19a0;
}
.check-icon {
@ -362,7 +440,7 @@ export default {
.tooltip-content {
font-size: 24rpx;
color: #FFFFFF;
color: #ffffff;
line-height: 1.4;
}
@ -385,7 +463,7 @@ export default {
color: #9b939a;
.color {
color: #FF19A0;
color: #ff19a0;
font-size: 22rpx;
}
}

View File

@ -385,7 +385,7 @@ export default {
height: 100%;
align-items: stretch;
position: relative;
padding-top: calc(var(--status-bar-height, 0px) + 88rpx + 20rpx);
padding-top: 0;
.custom-navbar {
position: fixed;
@ -394,7 +394,7 @@ export default {
right: 0;
z-index: 999;
background: #ff19a0;
border-radius: 0px 0px 16px 16px;
border-radius: 0px;
.status-bar {
background: #ff19a0;

View File

@ -384,6 +384,7 @@ export default {
.home-page {
height: 100vh;
background-color: #ffecf3;
padding-top: 0;
}
.recommand-goods-wrapper {
@ -442,10 +443,13 @@ export default {
.swiperWrapper {
position: relative;
margin-top: -88rpx;
.swiper {
height: 552rpx;
width: 100%;
padding-top: 88rpx;
box-sizing: content-box;
.swiper-img {
width: 100%;

View File

@ -330,13 +330,17 @@ title: '请添加客服号',
overflow-y: auto;
-webkit-overflow-scrolling: touch;
height: calc(100vh - #{$app_tabbar_height + 26});
padding-top: 0;
.mineGroundImgView {
position: relative;
margin-top: -88rpx;
.groundImg {
width: 100%;
height: 552rpx;
padding-top: 88rpx;
box-sizing: content-box;
}
}

View File

@ -476,7 +476,7 @@ export default {
align-items: center;
justify-content: center;
padding: 0 32rpx;
height: 88rpx;
height: 80rpx;
box-sizing: border-box;
margin-bottom: 20px;