master
dongmu 1 year ago
parent 4929b2cede
commit 8eb206d1b9

@ -4,10 +4,16 @@
"version" : "0.0", "version" : "0.0",
"configurations" : [ "configurations" : [
{ {
"app-plus" : { "app-plus" :
{
"launchtype" : "local" "launchtype" : "local"
}, },
"default" : { "default" :
{
"launchtype" : "local"
},
"mp-weixin" :
{
"launchtype" : "local" "launchtype" : "local"
}, },
"type" : "uniCloud" "type" : "uniCloud"

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

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

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

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

Loading…
Cancel
Save