master
dongmu 1 year ago
parent 4929b2cede
commit 8eb206d1b9

@ -4,13 +4,19 @@
"version" : "0.0",
"configurations" : [
{
"app-plus" : {
"launchtype" : "local"
},
"default" : {
"launchtype" : "local"
},
"type" : "uniCloud"
"app-plus" :
{
"launchtype" : "local"
},
"default" :
{
"launchtype" : "local"
},
"mp-weixin" :
{
"launchtype" : "local"
},
"type" : "uniCloud"
},
{
"openVueDevtools" : true,

@ -118,7 +118,6 @@ const loginForm = ref({
account: '',
password: '',
smsCode: '',
jsCode: '',
})
const content = ref('获取验证码') //
@ -200,7 +199,6 @@ const handleLogin = async () => {
return
} else {
//
// loginForm.value.jsCode = UniCode.value
let URL = '/pages/index/index'
loginUser(loginForm.value)
.then((res: any) => {

@ -1,4 +1,5 @@
<script setup lang="ts">
import { useMemberStore } from '@/stores'
//
const { safeAreaInsets } = uni.getSystemInfoSync()
//
@ -8,6 +9,7 @@ const orderTypes = [
{ type: 3, text: '待收货', icon: 'icon-check' },
{ type: 4, text: '已评价', icon: 'icon-comment' },
]
const memberStore = useMemberStore()
</script>
<template>
@ -15,7 +17,7 @@ const orderTypes = [
<!-- 个人资料 -->
<view class="profile" :style="{ paddingTop: safeAreaInsets!.top + 'px' }">
<!-- 情况1已登录 -->
<view class="overview" v-if="false">
<view class="overview" v-if="memberStore.profile">
<navigator url="/pagesMember/profile/profile" hover-class="none">
<image
class="avatar"
@ -32,19 +34,16 @@ const orderTypes = [
</view>
<!-- 情况2未登录 -->
<view class="overview" v-else>
<navigator url="/pages/login/OneClickLogin/OneClickLogin" hover-class="none">
<navigator url="/pages/login/login" hover-class="none">
<image
class="avatar gray"
mode="aspectFill"
src="http://yjy-xiaotuxian-dev.oss-cn-beijing.aliyuncs.com/picture/2021-04-06/db628d42-88a7-46e7-abb8-659448c33081.png"
></image>
>
</image>
</navigator>
<view class="meta">
<navigator
url="/pages/login/OneClickLogin/OneClickLogin"
hover-class="none"
class="nickname"
>
<navigator url="/pages/login/login" hover-class="none" class="nickname">
未登录
</navigator>
<view class="extra">
@ -201,17 +200,20 @@ page {
display: flex;
justify-content: space-between;
padding: 40rpx 20rpx 10rpx;
.navigator,
.contact {
text-align: center;
font-size: 24rpx;
color: #333;
&::before {
display: block;
font-size: 60rpx;
color: #ff9545;
}
}
.contact {
padding: 0;
margin: 0;

@ -64,7 +64,7 @@ export const loginUser = (data: any) => {
// 如果index是1 就是登录/找回密码
return http({
method: 'GET',
url: '/auth/weiXin/login',
url: '/auth/mobile/login',
data,
})
}

@ -21,7 +21,8 @@ const httpInterceptor = {
}
// 4. 添加 token 请求头标识
const memberStore = useMemberStore()
const token = memberStore.profile?.token
const token = memberStore.profile
console.log(memberStore.profile, 'memberStore')
if (token) {
options.header.Authorization = 'Bearer ' + token // 让每个请求携带自定义token 请根据实际情况自行修改
}
@ -59,6 +60,8 @@ export const http = <T>(options: UniApp.RequestOptions) => {
})
// 1. 返回 Promise 对象
return new Promise<Data<T>>((resolve, reject) => {
console.log(options, 'options请求数据')
uni.request({
...options,
// 响应成功
@ -88,11 +91,11 @@ export const http = <T>(options: UniApp.RequestOptions) => {
title: '请求错误',
icon: 'error',
})
const memberStore = useMemberStore()
memberStore.clearProfile()
setTimeout(() => {
uni.navigateTo({ url: '/pages/login/OneClickLogin/OneClickLogin' })
}, 1000)
// const memberStore = useMemberStore()
// memberStore.clearProfile()
// setTimeout(() => {
// uni.navigateTo({ url: '/pages/login/OneClickLogin/OneClickLogin' })
// }, 1000)
reject(resList)
} else {
console.log('500请求错误', res.data)
@ -111,9 +114,9 @@ export const http = <T>(options: UniApp.RequestOptions) => {
title: (res.data as Data<T>).msg || '请求错误',
icon: 'error',
})
const memberStore = useMemberStore()
memberStore.clearProfile()
uni.navigateTo({ url: '/pages/login/OneClickLogin/OneClickLogin' })
// const memberStore = useMemberStore()
// memberStore.clearProfile()
// uni.navigateTo({ url: '/pages/login/OneClickLogin/OneClickLogin' })
reject(res)
} else {
console.log('500请求错误', res.data)

Loading…
Cancel
Save