强制判断是否登录

This commit is contained in:
Vinjor 2024-09-27 17:57:20 +08:00
parent 110bbf8232
commit ece7767727
7 changed files with 40 additions and 28 deletions

View File

@ -19,6 +19,8 @@
<script>
import VNavigationBar from '@/components/VNavigationBar.vue'
import request from "@/utils/request";
import {getUserInfoRequest} from "@/utils/common.js";
import {getToken,setUserInfo} from '@/utils/auth.js'
export default {
components: {
VNavigationBar,
@ -41,6 +43,14 @@ export default {
};
},
onShow(data) {
if(!getToken()){
uni.reLaunch({
url: '/pages/login/login'
})
}else{
console.log("已登录")
this.getUserInfos()
}
this.customInfo = JSON.parse(uni.getStorageSync('customerInfo'))
this.getActive()
},
@ -48,7 +58,10 @@ export default {
this.getActive()
},
methods: {
//
async getUserInfos() {
getUserInfoRequest()
},
//
async getActive() {
let customInfo = JSON.parse(uni.getStorageSync('customerInfo'))

View File

@ -65,7 +65,7 @@
import VNavigationBar from '@/components/VNavigationBar.vue'
import tabBarVue from '@/components/tabBar/tabBar.vue'
import request from "@/utils/request";
import {getUserInfo} from "@/utils/common.js";
import {getUserInfoRequest} from "@/utils/common.js";
import {getToken,setUserInfo} from '@/utils/auth.js'
export default {
components: {
@ -112,7 +112,7 @@
//
async getServer() {
console.log("获取用户信息")
this.customInfo = getUserInfo()
this.customInfo = getUserInfoRequest()
}
}
}

View File

@ -39,12 +39,12 @@
</picker>
</view>
</view>
<view class="formItem">
<view class="formLabel">手机号</view>
<view class="formContainer">
<input placeholder="请填写你的手机号" v-model="formData.phoneNumber" type="text"/>
</view>
</view>
<!-- <view class="formItem">-->
<!-- <view class="formLabel">手机号</view>-->
<!-- <view class="formContainer">-->
<!-- <input placeholder="请填写你的手机号" v-model="formData.phoneNumber" type="text"/>-->
<!-- </view>-->
<!-- </view>-->
<view class="formItem">
<view class="formLabel">联系地址</view>
<view class="formContainer">
@ -52,7 +52,7 @@
</view>
</view>
<view class="dl" @click="getlogin()">
<text>注册</text>
<text>保存</text>
</view>
</view>
</view>
@ -77,7 +77,7 @@ export default {
sex: "",
idCard:"",
birthday:"请选择你的生日",
phoneNumber:"",
// phoneNumber:"",
address:"",
},
//
@ -153,13 +153,13 @@ export default {
})
return false
}
if(""==this.formData.phoneNumber || !this.isValidPhoneNumber(this.formData.phoneNumber)){
uni.showToast({
title: '请填写手机号',
icon: 'none'
})
return false
}
// if(""==this.formData.phoneNumber || !this.isValidPhoneNumber(this.formData.phoneNumber)){
// uni.showToast({
// title: '',
// icon: 'none'
// })
// return false
// }
if(""==this.formData.address){
uni.showToast({
title: '请填写联系地址',

View File

@ -26,7 +26,7 @@
import VNavigationBar from '@/components/VNavigationBar.vue';
import request from "../../utils/request";
import config from "config";
import {getUserInfo} from "@/utils/common.js";
import {getUserInfoRequest} from "@/utils/common.js";
import {getToken,setUserInfo} from '@/utils/auth.js'
export default {
@ -71,7 +71,7 @@ export default {
//
async getUserInfos() {
console.log("获取用户信息")
this.customInfo = getUserInfo()
getUserInfoRequest()
},
getList(){
request({

View File

@ -102,7 +102,7 @@
import request from '../../utils/request';
import VNavigationBar from '@/components/VNavigationBar.vue'
import config from "@/config";
import {getUserInfo} from "@/utils/common.js";
import {getUserInfoRequest} from "@/utils/common.js";
import {getToken,setUserInfo} from '@/utils/auth.js'
export default {
@ -203,7 +203,7 @@
//
async getUserInfos() {
console.log("获取用户信息")
this.customInfo = getUserInfo()
getUserInfo()
},
initDateList(){
const daysOfWeek = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];

View File

@ -18,7 +18,7 @@
import tabBarVue from '@/components/tabBar/tabBar.vue'
import reservationOrderVue from '../../components/reservationOrder/reservationOrder.vue'
import request from "@/utils/request";
import {getUserInfo} from "@/utils/common.js";
import {getUserInfoRequest} from "@/utils/common.js";
import {getToken,setUserInfo} from '@/utils/auth.js'
export default {
@ -61,8 +61,7 @@
methods: {
//
async getUserInfos() {
console.log("获取用户信息")
this.customInfo = getUserInfo()
getUserInfoRequest()
},
async getBookingPage(){
const res = await request({

View File

@ -59,7 +59,7 @@ export function tansParams(params) {
* 获取当前登录用户信息
* @returns {Promise<void>}
*/
export async function getUserInfo(){
export async function getUserInfoRequest(){
const res = await request({
url: "/userClient/customer/getUserCustomer",
method: 'get',