浏览代码

过期登陆弹窗防抖处理

chenjj 3 天之前
父节点
当前提交
5ad96964b0
共有 4 个文件被更改,包括 41 次插入34 次删除
  1. 2 0
      config.js
  2. 1 4
      pages/index.vue
  3. 22 21
      pages_home/pages/register/index.vue
  4. 16 9
      utils/request.ts

+ 2 - 0
config.js

@@ -1,5 +1,7 @@
 const base_url = {
   develop:'http://192.168.100.128:9527',//开发版 
+  // develop: 'http://192.168.100.139:9527', //嵘哥
+
   trial: 'https://zybooks.tech/prod-api',//体验版
   release: 'https://goldshulin.com/prod-api',//正式版
 }

+ 1 - 4
pages/index.vue

@@ -264,6 +264,7 @@ onShow(() => {
     },
   })
 
+  getList();
 })
 
 const addresstree = ref([])
@@ -296,12 +297,8 @@ onMounted(async () => {
         console.log('获取地址失败!', error)
         getList()
       })
-  } else {
-    getList();
   }
 
-
-
 })
 
 onUnload(() => { })

+ 22 - 21
pages_home/pages/register/index.vue

@@ -67,7 +67,7 @@
 
 					<view class="font-title">服务价格(<text class="activeColor">{{ serviceKeys.threeKeyname ||
 						serviceKeys.itemKeyname ||
-						serviceKeys.classKeyname }}</text>)</view>
+						serviceKeys.classKeyname }}</text>){{ serviceKeys.price }}</view>
 					<view class="service-list price-box">
 						<up-input v-model="serviceKeys.price"
 							:placeholder="min_max_price.minPrice && min_max_price.maxPrice ? `${min_max_price.minPrice}-${min_max_price.maxPrice}` : '请设置服务价格'"
@@ -114,7 +114,7 @@ import FontTitle from "@/pages_home/components/font-title/index.vue";
 import CustForm from "@/pages_home/components/cust-form/index";
 import UpdataImgs from "@/pages_home/components/updata-imgs/index.vue";
 import { column } from "./data";
-import { add, getVolunteerInfo,updateInfo } from "@/api/volunteer";
+import { add, getVolunteerInfo, updateInfo } from "@/api/volunteer";
 import { computed } from 'vue';
 import { getTreeList } from '@/api/volunteer'
 
@@ -357,17 +357,7 @@ function submitForm() {
 				return
 			}
 
-			const parmas = {
-				serviceCategory: data.value.key,
-				...file_url,
-				businessManagementId: serviceKeys.threeKey || serviceKeys.itemKey || serviceKeys.classKey,
-				businessPrice: serviceKeys.price,
-				businessDuration: Number(serviceKeys.time),
-				businessUnit: serviceKeys.businessUnit,
-				minQuantity: Number(serviceKeys.minQuantity),
-				businessDescribe: serviceKeys.businessDescribe,
-
-			};
+			let parmas = {};
 			for (const key in res) {
 				parmas[key] = key == 'sex' ? sex_status[res[key]] : res[key];
 				if (key === 'businessManagementIdkey') {
@@ -379,10 +369,22 @@ function submitForm() {
 					parmas[key] = Number(res[key])
 				}
 			}
+			parmas = {
+				...parmas,
+				serviceCategory: data.value.key,
+				...file_url,
+				businessManagementId: serviceKeys.threeKey || serviceKeys.itemKey || serviceKeys.classKey,
+				businessPrice: serviceKeys.price,
+				businessDuration: Number(serviceKeys.time),
+				businessUnit: serviceKeys.businessUnit,
+				minQuantity: Number(serviceKeys.minQuantity),
+				businessDescribe: serviceKeys.businessDescribe,
+			}
 
-			console.log('提交', parmas);
-
-				const btnSubmit = isAdd.value ? add:updateInfo;
+			console.log('提交', parmas,serviceKeys.price);
+			// return;
+			const btnSubmit = isAdd.value ? add : updateInfo;
+		
 			// 提交接口,注册人员
 			const submit_res = await btnSubmit(parmas);
 			if (submit_res.code == 200) {
@@ -505,21 +507,20 @@ function servesInit() {
 		const row = handlerList(serviceOptions.value, obj.itemKey)
 		serviceItems2.value = row.children;
 	}
+
+
+	handlerList(serviceOptions.value, serviceKeys.itemKey)
+
 	Object.assign(serviceKeys, {
 		time: details.value.businessDuration,//时间
 		price: details.value.businessPrice,//价格
 		...obj,
-		businessPrice: details.value.price,
-		businessDuration: details.value.time,
 		businessUnit: details.value.businessUnit,
 		minQuantity: details.value.minQuantity,
 		businessDescribe: details.value.businessDescribe,
 	})
 
 
-	handlerList(serviceOptions.value, serviceKeys.itemKey)
-
-
 }
 async function getRegister() {
 

+ 16 - 9
utils/request.ts

@@ -42,15 +42,8 @@ const request = <T>(config:RequestConfig):Promise<ResponseData<T>> => {
       // @ts-ignore
       const msg:string = errorCode[code] || data.msg || errorCode['default']
       if (code === 401) {
-        store.dispatch('ClearUserInfo');
-        showConfirm(getToken()?'您的登陆已过期,请重新登陆!':'您还未登陆系统,是否前往登陆?').then(res => {
-          if (res.confirm) {
-            store.dispatch('LogOut').then(res => {
-              uni.navigateTo({ url: '/pages/login' })
-            })
-          }
-        })
-
+        uni.$u.debounce(startConfirm, 500)
+      
         reject('无效的会话,或者会话已过期,请重新登录。')
       } else if (code === 500) {
         toast(msg)
@@ -77,4 +70,18 @@ const request = <T>(config:RequestConfig):Promise<ResponseData<T>> => {
   })
 }
 
+const startConfirm = ()=>{
+  console.log('________________________>>>>');
+  // return
+  store.dispatch('ClearUserInfo');
+  showConfirm(getToken()?'您的登陆已过期,请重新登陆!':'您还未登陆系统,是否前往登陆?').then(res => {
+    if (res.confirm) {
+      store.dispatch('LogOut').then(res => {
+        uni.navigateTo({ url: '/pages/login' })
+      })
+    }
+  })
+}
+
+
 export default request