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, 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, 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, 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"; } from "./url";
// 微信登陆 // 微信登陆
export const getCodeByWxLogin = () => { export const getCodeByWxLogin = () => {
@ -10,7 +10,7 @@ export const getCodeByWxLogin = () => {
tt.login({ tt.login({
provider: "toutiao", provider: "toutiao",
success: function (loginRes) { success: function (loginRes) {
// console.log(loginRes,'?1?') console.log(loginRes,'?1?')
resolve(loginRes.code); resolve(loginRes.code);
}, },
fail: function (err) { fail: function (err) {
@ -23,7 +23,7 @@ export const getCodeByWxLogin = () => {
import Store from "../store"; import Store from "../store";
// 登录鉴权 // 登录鉴权
export const login = (nickName, avatarUrl) => { export const login = ( phone) => {
return getCodeByWxLogin().then((code) => { return getCodeByWxLogin().then((code) => {
// 从 vuex 中获取 referrerID如果通过二维码扫描进入 // 从 vuex 中获取 referrerID如果通过二维码扫描进入
const referrerID = Store.state.user?.referrerID || 0; const referrerID = Store.state.user?.referrerID || 0;
@ -32,17 +32,11 @@ export const login = (nickName, avatarUrl) => {
url: LOGIN, url: LOGIN,
method: "POST", method: "POST",
data: { data: {
nickName:nickName,
avatarUrl:avatarUrl,
code: code, code: code,
source:'douyin', phone: phone || null,
referrerID:0, source: 'douyin',
referrerType:'douyin' referrerID: 0,
// // yaoqing_code: inviteCode || null, referrerType: 'douyin'
// phone: phone || null,
// source: "wechat",
// referrerID: Number(referrerID) || 0,
// referrerType: "wechat"
}, },
}).then((res) => { }).then((res) => {
// 登录接口使用完 referrerID 后,清除一次,避免重复使用 // 登录接口使用完 referrerID 后,清除一次,避免重复使用
@ -54,12 +48,13 @@ export const login = (nickName, avatarUrl) => {
}); });
}; };
// 获取手机号 // 获取手机号
export const getPhone = (code) => { export const getPhone = (phoneCode, loginCode) => {
return request({ return request({
url: GET_PHONE, url: GET_PHONE,
method: "POST", method: "POST",
data: { 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) => { export const userWllet = (id) => {
return request({ 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 CANCEL_NOMO_ORDER = '/douyin/goods/order/cancel'
export const LOGIN_PHONE = '/api/v1/auth/login'
// 取消商城接口 // 取消商城接口
export const CANCEL_MALL_ORDER = '/douyin/goods/order/refund' export const CANCEL_MALL_ORDER = '/douyin/goods/order/refund'

View File

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

View File

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

View File

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

View File

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

View File

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