重新修改登录逻辑

This commit is contained in:
wangxiaowei
2025-10-17 15:40:03 +08:00
parent 2f59d0e8ba
commit c3ffadfded
10 changed files with 54 additions and 43 deletions

View File

@ -17,7 +17,8 @@
}
// 微信静默授权
await initJweixinSDK()
await snsapiBaseAuthorize()
// await initJweixinSDK()
})
onShow((options) => {
console.log('App Show', options)

View File

@ -18,3 +18,18 @@ export function getTeaSpecialistDetails(data: ITeaSpecialistDetailsParams) {
}
)
}
/**
* 收藏和取消收藏茶艺师
*/
export interface ICollectTeaSpecialistParams {
id: number
user_id: number
status: number
}
export function collectTeaSpecialist(data: ICollectTeaSpecialistParams) {
return http.Post('/api/Teamaster/teamasterCollect',
data
)
}

View File

@ -58,8 +58,8 @@ export async function snsapiBaseAuthorize() {
if (code == null || code === '' || code == 'undefined' || code == oldCode) {
// 如果没有code就去请求获取code
console.log('当前没有code进入授权页面')
let uri = encodeURIComponent(local)
console.log("🚀 ~ 当前没有code进入授权页面 snsapiBaseAuthorize ~ uri:", uri)
// 设置旧的code为0避免死循环
uni.setStorageSync('wechatCode',0)
window.location.href =

View File

@ -56,8 +56,6 @@ const alovaInstance = createAlova({
}
const { config } = method
console.log("🚀 ~ config.meta?.ignoreAuth:", config)
const ignoreAuth = !config.meta?.ignoreAuth
console.log('ignoreAuth===>', ignoreAuth)
// 处理认证信息 自行处理认证问题
@ -71,6 +69,10 @@ const alovaInstance = createAlova({
const userStore = useUserStore()
const { token } = userStore.userInfo as unknown as IUserInfo
if (!token) {
toast.info('请先登录')
setTimeout(() => {
uni.switchTab({ url: '/pages/my/my' })
}, 500)
throw new Error('[请求错误]:未登录')
}
method.config.headers.token = token;

View File

@ -111,7 +111,7 @@
<wd-img :src="`${OSS}icon/icon_gold_medal.png`" width="36rpx" height="36rpx"></wd-img>
</view>
<view>
<tea-specialist-level :level="TeaSpecialistLevelValue[info.teamasterLevel[0].level_name]"></tea-specialist-level>
<tea-specialist-level :level="TeaSpecialistLevelValue[info.teamasterLevel?.[0]?.level_name] || 'junior'"></tea-specialist-level>
</view>
</view>
</view>
@ -270,7 +270,7 @@
<script lang="ts" setup>
import TeaSpecialistLevel from '@/components/TeaSpecialistLevel.vue'
import { useMessage } from 'wot-design-uni'
import { getTeaSpecialistDetails } from '@/api/tea'
import { getTeaSpecialistDetails, collectTeaSpecialist } from '@/api/tea'
import { ITeaSpecialistDetailsFields } from '@/api/types/tea'
import {toast} from '@/utils/toast'
import {TeaSpecialistLevelValue} from '@/utils/teaSpecialist'
@ -349,8 +349,13 @@
const Detail = {
// 处理收藏
handleCollect: () => {
console.log('收藏')
handleCollect: async () => {
const res = await collectTeaSpecialist({
user_id: 1,
id: 1,
status: 1
})
console.log('收藏=', res)
},
// 处理分享

View File

@ -14,12 +14,12 @@
<view class="font-400 text-28rpx leading-44rpx text-[#6B7280] mt-12rpx"> {{ page.desc }}</view>
</view>
<view class="mt-106rpx mx-48rpx">
<wd-form ref="form" :model="form">
<wd-form ref="form" :model="formModel">
<view>
<view class="font-400 text-30rpx text-[#606266] leading-44rpx">手机号</view>
<view class="mt-20rpx">
<wd-input
v-model="form.mobile"
v-model="formData.mobile"
type="text"
placeholder="请输入手机号码"
inputmode="numeric"
@ -34,7 +34,7 @@
<view class="mt-40rpx">
<view class="font-400 text-30rpx text-[#606266] leading-44rpx">验证码</view>
<view class="mt-20rpx">
<wd-input type="text" placeholder="请输入验证码" v-model="form.code" inputmode="numeric" no-border custom-class="!bg-[#F6F7F8] !border !border-solid !border-[#EAECF0] !rounded-16rpx" custom-input-class="!px-32rpx !h-104rpx">
<wd-input type="text" placeholder="请输入验证码" v-model="formData.code" inputmode="numeric" no-border custom-class="!bg-[#F6F7F8] !border !border-solid !border-[#EAECF0] !rounded-16rpx" custom-input-class="!px-32rpx !h-104rpx">
<template #suffix>
<view class="flex items-center mr-34rpx">
<view class="flex items-center">
@ -104,19 +104,17 @@
const startCountDown = ref<boolean>(false) // 是否开始倒计时
const countDown = ref<any>(null) // 倒计时组件
/** 表单相关 **/
const form = reactive<{
// 表单相关
const formData = reactive<{
mobile: string
code: string
}>({
mobile: '15005837859',
code: ''
})
/** 结束 **/
/** 服务协议和隐私政策 **/
// 服务协议和隐私政策
const agree = ref<boolean>(false)
/** 结束 **/
onLoad((args) => {
// 从个人登录页面进入
@ -132,8 +130,8 @@
const mobile = {
// 验证手机号
handleInputMobile: (e: {value: string}) => {
form.mobile = e.value
disabled.value = !testMobile(form.mobile)
formData.mobile = e.value
disabled.value = !testMobile(formData.mobile)
},
// 发送验证码
@ -153,7 +151,7 @@
// 发送验证码请求
console.log("🚀 ~ 发送验证码请求:")
smsCode({ mobile: Number(form.mobile), scene: 'YZMDL' }).then(() => {
smsCode({ mobile: Number(formData.mobile), scene: 'YZMDL' }).then(() => {
toast.show({
iconClass: 'success-circle',
msg: '验证码发送成功',
@ -185,7 +183,7 @@
return
}
if (!testMobile(form.mobile)) {
if (!testMobile(formData.mobile)) {
toast.show({
iconClass: 'info-circle',
msg: '手机号码错误请重新输入',
@ -194,7 +192,7 @@
return
}
if (!form.code) {
if (!formData.code) {
toast.show({
iconClass: 'info-circle',
msg: '验证码错误',

View File

@ -254,23 +254,16 @@
},
// 跳转到个人信息
handleToProfile: async () => {
handleToProfile: () => {
if (isLogin.value) {
uni.navigateTo({
url: '/bundle/profile/profile'
})
} else {
// 登录操作
await snsapiBaseAuthorize()
const userStore = useUserStore()
if (!userStore.userInfo.mobile) {
uni.navigateTo({
url: '/pages/login/mobile'
})
} else {
userInfo.value = userStore.userInfo
isLogin.value = true
}
uni.navigateTo({
url: '/bundle/vip/benefits'
})
}
},

View File

@ -30,15 +30,15 @@ const MescrollCompMixin = {
},
methods:{
handlePageScroll(e){
let item = this.$refs["mescrollItem"];
let item = this && this.$refs && this.$refs["mescrollItem"];
if(item && item.mescroll) item.mescroll.onPageScroll(e);
},
handleReachBottom(){
let item = this.$refs["mescrollItem"];
let item = this && this.$refs && this.$refs["mescrollItem"];
if(item && item.mescroll) item.mescroll.onReachBottom();
},
handlePullDownRefresh(){
let item = this.$refs["mescrollItem"];
let item = this && this.$refs && this.$refs["mescrollItem"];
if(item && item.mescroll) item.mescroll.onPullDownRefresh();
}
}

View File

@ -46,13 +46,13 @@ const MescrollMoreMixin = {
getMescroll(i){
if(!this.mescrollItems) this.mescrollItems = [];
if(!this.mescrollItems[i]) {
// v-for中的refs
let vForItem = this.$refs["mescrollItem"];
if(vForItem){
// v-for中的refs(增加防护,避免 this 未定义时报错)
let vForItem = this && this.$refs && this.$refs["mescrollItem"];
if (vForItem) {
this.mescrollItems[i] = vForItem[i]
}else{
} else {
// 普通的refs,不可重复
this.mescrollItems[i] = this.$refs["mescrollItem"+i];
this.mescrollItems[i] = this && this.$refs && this.$refs["mescrollItem"+i];
}
}
let item = this.mescrollItems[i]

View File

@ -26,11 +26,8 @@ export async function initJweixinSDK(): Promise<any> {
let isiOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
let signLink = isiOS ? window.entryUrl : location.href.split('#')[0];
console.log('-----------当前签名url--------------')
console.log(signLink)
let url = encodeURIComponent(signLink);
const res = await wxSignature({ url })
console.log("🚀 ~ initJweixin ~ res:", res)
return new Promise((resolve) => {
wx.config({
debug: false,