Browse Source

志愿者修改

chenjj 3 months ago
parent
commit
6f06e4a8e0

+ 25 - 6
api/volunteer.js

@@ -60,8 +60,8 @@ export function getVolunteerOrderInfo(data) {
 //志愿者滑动,开始订单
 export function getTimesByDate(data) {
     return request({
-      url: `/core/volunteer/orders/volunteerStartSecondOrder?${data}`,
-      method: 'post',
+        url: `/core/volunteer/orders/volunteerStartSecondOrder?${data}`,
+        method: 'post',
     })
 }
 //志愿者点击结束订单
@@ -85,8 +85,27 @@ export function getVolunteerAccount(volunteerAccountId) {
 //查询所有业务列表(树形结构)
 export function getTreeList(query) {
     return request({
-      url: '/core/business/management/getTreeList',
-      method: 'get',
-      params: query
+        url: '/core/business/management/getTreeList',
+        method: 'get',
+        params: query
     })
-  }
+}
+
+
+
+//志愿者信息先调这个接口进行校验
+export function hadOrder(volunteerAccountId) {
+    return request({
+        url: `/core/volunteer/info/hadOrder?volunteerInfoId=${volunteerAccountId}`,
+        method: 'get',
+    })
+}
+
+// 修改志愿者
+export function updateInfo(data) {
+    return request({
+        url: `/core/volunteer/info/updateInfo`,
+        method: 'put',
+        data
+    })
+}

+ 19 - 5
pages_home/pages/details/index.vue

@@ -80,7 +80,7 @@
 <script setup>
 import { ref, reactive, onMounted, nextTick, computed } from 'vue';
 import { onLoad } from '@dcloudio/uni-app';
-import { add, getVolunteerInfo } from "@/api/volunteer";
+import { add, getVolunteerInfo,hadOrder } from "@/api/volunteer";
 import Picker from '@/pages_home/components/picker/index.vue'
 import { getTreeList } from '@/api/volunteer'
 import { useDict } from '@/utils/dict.js';
@@ -254,10 +254,24 @@ async function getRegister() {
     }
 }
 
-const startSubmit = () => {
-    uni.redirectTo({
-        url: `/pages_home/pages/register/index?data=${encodeURIComponent(JSON.stringify(data.value))}`
-    })
+const startSubmit =async () => {
+    try {
+        const res = await hadOrder(details.value.volunteerInfoId);
+        if(res.code === 200){
+            uni.redirectTo({
+                url: `/pages_home/pages/register/index?data=${encodeURIComponent(JSON.stringify(data.value))}`
+            })
+        }else{
+            uni.showToast({
+                title: res.msg,
+                icon: 'error',
+            });
+        }
+    } catch (error) {
+		console.log("TCL: startSubmit -> error", error)
+        
+    }
+  
 }
 
 onLoad((options) => {

+ 4 - 3
pages_home/pages/register/index.vue

@@ -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 } from "@/api/volunteer";
+import { add, getVolunteerInfo,updateInfo } from "@/api/volunteer";
 import { computed } from 'vue';
 import { getTreeList } from '@/api/volunteer'
 
@@ -382,11 +382,12 @@ function submitForm() {
 
 			console.log('提交', parmas);
 
+				const btnSubmit = isAdd.value ? add:updateInfo;
 			// 提交接口,注册人员
-			const submit_res = await add(parmas);
+			const submit_res = await btnSubmit(parmas);
 			if (submit_res.code == 200) {
 				uni.showToast({
-					title: '申请成功',
+					title: '操作成功',
 					icon: 'success',
 					success: () => {
 						setTimeout(() => {

+ 19 - 6
store/modules/user.ts

@@ -63,13 +63,13 @@ const user: Module<UserState, UserState> = {
       state.userId = id
     },
     SET_MESSAGECOUNT: (state, num: Number) => {
-			console.log("TCL: num", num)
+      console.log("TCL: num", num)
       state.messageCount = num
     },
-    SET_MESSAGE: (state, ms:any) => {
+    SET_MESSAGE: (state, ms: any) => {
       state.wsManager = ms
     },
-    SET_ADDRESSINFO: (state, data:any) => {
+    SET_ADDRESSINFO: (state, data: any) => {
       state.addressInfo = data
     },
   },
@@ -120,10 +120,10 @@ const user: Module<UserState, UserState> = {
           commit('SET_USERID', res.user.userId)
 
 
-         
+
           if (this.wsManager) {
             this.wsManager.closeConnection();
-          }else{
+          } else {
             //获取账户时,连接soket 
             const ms = new WebSocketManager(res.user.userId);
             // 设置消息回调
@@ -139,7 +139,7 @@ const user: Module<UserState, UserState> = {
             commit('SET_MESSAGE', ms)
 
           }
-          
+
 
           resolve(res)
         }).catch(error => {
@@ -173,6 +173,19 @@ const user: Module<UserState, UserState> = {
     handlerAddress({ commit, state }, address) {
       commit('SET_ADDRESSINFO', address);
     },
+    // 退出系统
+    ClearUserInfo({ commit, state }) {
+      console.log('ClearUserInfo');
+      
+      return new Promise((resolve, reject) => {
+        commit('SET_TOKEN', '')
+        commit('SET_ROLES', [])
+        commit('SET_PERMISSIONS', [])
+        removeToken()
+        uni.removeStorageSync('userId')
+        storage.clean()
+      })
+    },
   }
 }
 

+ 6 - 7
utils/request.ts

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