Prechádzať zdrojové kódy

fix(app/api): 新增字典数据获取接口与用户认证信息创建接口

EvilDragon 5 mesiacov pred
rodič
commit
15fc124f60

+ 25 - 0
packages/app/src/core/libs/requests.ts

@@ -149,5 +149,30 @@ export const weixinMiniAppLogin = (phoneCode: string, loginCode: string, state:
     state,
   })
 export const getMemberUserInfo = () => httpGet<any>('/app-api/member/user/get')
+export const getByDictType = (dictType: string | 'member_channel_source') =>
+  httpGet<
+    {
+      label: string
+      value: string
+      dictType: string
+      status: number
+    }[]
+  >('/app-api/member/dict-data/getByDictType', { dictType })
+export const createUserAuthInfo = (
+  data: Partial<{
+    id: number
+    userId: number
+    designerName: string
+    gender: number
+    mobile: string
+    channelSource: number
+    referrer: string
+    employer: string
+    spatialExpertiseType: number
+    attachment: string
+    auditStatus: number
+    remark: string
+  }>,
+) => httpPost<any>('/app-api/member/user-auth-info/create', data)
 export const httpGetMock = <T>(data: T) =>
   new Promise<IResData<T>>((resolve) => resolve({ code: 1, msg: '', data } as IResData<T>))

+ 1 - 0
packages/app/src/typings.ts

@@ -18,6 +18,7 @@ type IUniUploadFileOptions = {
 type IUserInfo = {
   nickname?: string
   avatar?: string
+  sex?: number
   /** 微信的 openid,非微信没有这个字段 */
   openid?: string
   token?: string

+ 8 - 2
packages/app/src/utils/http.ts

@@ -20,13 +20,19 @@ export const http = <T>(options: CustomRequestOptions) => {
       // #endif
       // 响应成功
       success(res) {
+        console.log(res)
+
         // 状态码 2xx,参考 axios 的设计
         if (res.statusCode >= 200 && res.statusCode < 300) {
           // 2.1 提取核心数据 res.data
-          resolve(res.data as IResData<T>)
+          if ((res.data as IResData<T>).code === 401) {
+            userStore.clearUserInfo()
+          } else {
+            resolve(res.data as IResData<T>)
+          }
         } else if (res.statusCode === 401) {
           // 401错误  -> 清理用户信息,跳转到登录页
-          // userStore.clearUserInfo()
+          userStore.clearUserInfo()
           // uni.navigateTo({ url: '/pages/login/login' })
           reject(res)
         } else {