快乐的梦鱼 před 1 měsícem
rodič
revize
52f12cb63b

+ 7 - 0
src/api/collect/InheritorContent.ts

@@ -3,6 +3,7 @@ import { AppServerRequestModule } from '../RequestModules';
 import dayjs from 'dayjs';
 import { transformSomeToArray } from '../Utils';
 import { GetContentListItem } from '../CommonContent';
+import AppCofig from '@/common/config/AppCofig';
 
 export class CommonInfo<T extends DataModel> extends DataModel<T> {
 
@@ -703,6 +704,12 @@ export class InheritorContentApi extends AppServerRequestModule<DataModel> {
   }
   async getSeminarExpandInfo(id: number|undefined) {
     return await this.getExpandInfo(id, SeminarExpandInfo);
+  }  
+  async bindWechat(data: { code: string }) {
+    return this.post('/village/volunteer/bindWechat', '绑定微信', {
+      code: data.code,
+      appid: AppCofig.appId
+    });
   }
 }
 

+ 7 - 0
src/pages.json

@@ -262,6 +262,13 @@
           }
         },
         {
+          "path": "user/bind-wx",
+          "style": {
+            "navigationBarTitleText": "绑定微信",
+            "enablePullDownRefresh": false
+          }
+        },
+        {
           "path": "forms/ich",
           "style": {
             "navigationBarTitleText": "非遗项目",

+ 3 - 0
src/pages/collect/admin.vue

@@ -37,6 +37,7 @@
       <CellGroup round>
         <Cell title="返回闽南文化" showArrow touchable @click="back()" />
         <Cell title="修改密码" showArrow touchable @click="navTo('user/change-password')" />
+        <Cell v-if="!isBindWx" title="绑定微信" showArrow touchable @click="navTo('user/bind-wx')" />
         <Cell title="退出登录" showArrow touchable @click="onLogout" />
       </CellGroup>
     </FlexCol>
@@ -59,8 +60,10 @@ import Avatar from '@/components/display/Avatar.vue';
 import Button from '@/components/basic/Button.vue';
 import { back, navTo } from '@/components/utils/PageAction';
 import { confirm } from '@/components/utils/DialogAction';
+import { useIsBindWx } from './composeable/isBindWx';
 
 const authStore = useAuthStore();
+const { isBindWx } = useIsBindWx();
 
 function onLogout() {
   confirm({

+ 1 - 0
src/pages/collect/assessment/evaluation-form.vue

@@ -195,6 +195,7 @@ async function loadCheckItems() {
   checkItemList.value = top;
   currentFormCheckItems.value = currentForm.value.checkItems.concat();
 }
+
 async function loadAnnexList() {
   assertNotNull(currentForm.value, 'currentForm is null');
   console.log('awardTime', currentForm.value.awardTime);

+ 11 - 0
src/pages/collect/composeable/isBindWx.ts

@@ -0,0 +1,11 @@
+import { useAuthStore } from "@/store/auth";
+
+export function useIsBindWx() {
+  const authStore = useAuthStore();
+
+  return {
+    isBindWx() {
+      return Boolean(authStore.userInfo?.openId);
+    }
+  }
+}

+ 3 - 0
src/pages/collect/inheritor.vue

@@ -43,6 +43,7 @@
       <CellGroup round>
         <Cell title="返回闽南文化" showArrow touchable @click="back()" />
         <Cell title="修改密码" showArrow touchable @click="navTo('user/change-password')" />
+        <Cell v-if="!isBindWx" title="绑定微信" showArrow touchable @click="navTo('user/bind-wx')" />
         <Cell title="退出登录" showArrow touchable @click="onLogout" />
       </CellGroup>
     </FlexCol>
@@ -65,8 +66,10 @@ import Avatar from '@/components/display/Avatar.vue';
 import Button from '@/components/basic/Button.vue';
 import { back, navTo } from '@/components/utils/PageAction';
 import { confirm } from '@/components/utils/DialogAction';
+import { useIsBindWx } from './composeable/isBindWx';
 
 const authStore = useAuthStore();
+const { isBindWx } = useIsBindWx();
 
 function onLogout() {
   confirm({

+ 58 - 33
src/pages/collect/login.vue

@@ -1,46 +1,50 @@
 <template>
-  <FlexCol gap="gap.xl" padding="space.lg">
-    <FlexCol center>
-      <Text fontConfig="subText">欢迎使用闽南文化数字资源采集</Text>
-      <Text fontConfig="subText">技术支持:18649931391</Text>
+  <CommonRoot>
+    <FlexCol gap="gap.xl" padding="space.lg">
+      <FlexCol center>
+        <Text fontConfig="subText">欢迎使用闽南文化数字资源采集</Text>
+        <Text fontConfig="subText">技术支持:18649931391</Text>
+      </FlexCol>
+      <FlexCol position="relative" radius="radius.md" backgroundColor="white" overflow="hidden">
+        <LoadingPage :loading="loading" loadingText="登录中..." />
+        <DynamicForm
+          ref="formRef"
+          :model="formModel"
+          :options="formDefine"
+        />
+      </FlexCol>
+      <FlexCol gap="gap.md">
+        <Button type="primary" block :loading="loading" @click="handleSubmit">
+          登录
+        </Button>
+        <Button block @click="back()">
+          返回
+        </Button>
+      </FlexCol>
+      <XBarSpace />
     </FlexCol>
-    <FlexCol position="relative" radius="radius.md" backgroundColor="white" overflow="hidden">
-      <LoadingPage :loading="loading" loadingText="登录中..." />
-      <DynamicForm
-        ref="formRef"
-        :model="formModel"
-        :options="formDefine"
-      />
-    </FlexCol>
-    <FlexCol gap="gap.md">
-      <Button type="primary" block :loading="loading" @click="handleSubmit">
-        登录
-      </Button>
-      <Button block @click="back()">
-        返回
-      </Button>
-    </FlexCol>
-    <XBarSpace />
-  </FlexCol>
+  </CommonRoot>
 </template>
 
 <script setup lang="ts">
 import { onMounted, ref } from 'vue';
 import { useAuthStore } from '@/store/auth';
 import { showError } from '@/common/composeabe/ErrorDisplay';
-import { toast } from '@/components/utils/DialogAction';
+import { waitTimeOut } from '@imengyu/imengyu-utils';
+import { confirm, toast } from '@/components/dialog/CommonRoot';
+import { back, redirectTo } from '@/components/utils/PageAction';
 import Button from '@/components/basic/Button.vue';
 import XBarSpace from '@/components/layout/space/XBarSpace.vue';
 import DynamicForm from '@/components/dynamic/DynamicForm.vue';
 import type { IDynamicFormOptions, IDynamicFormRef } from '@/components/dynamic';
 import type { FormProps } from '@/components/form/Form.vue';
 import type { RadioValueProps } from '@/components/dynamic/wrappers/RadioValue';
-import { back, redirectTo } from '@/components/utils/PageAction';
 import FlexCol from '@/components/layout/FlexCol.vue';
 import FlexRow from '@/components/layout/FlexRow.vue';
 import Text from '@/components/basic/Text.vue';
 import LoadingPage from '@/components/display/loading/LoadingPage.vue';
-import { waitTimeOut } from '@imengyu/imengyu-utils';
+import MemoryTimeOut from '@/components/composeabe/MemoryTimeOut';
+import CommonRoot from '@/components/dialog/CommonRoot.vue';
 
 const authStore = useAuthStore();
 const formRef = ref<IDynamicFormRef>();
@@ -111,14 +115,16 @@ const formDefine: IDynamicFormOptions = {
   ],
 };
 
+const tipBindWechat = new MemoryTimeOut('TipBindWechat', 1000 * 3600 * 72);
+
 async function handleSubmit() {
   if (!formRef.value)
     return;
   try {
     await formRef.value.validate();
   } catch {
-    uni.showToast({
-      title: '有必填项未填写,请检查',
+    toast({
+      content: '有必填项未填写,请检查',
       icon: 'none',
     });
     return;
@@ -130,8 +136,8 @@ async function handleSubmit() {
       ? formModel.value.account.trim()
       : formModel.value.mobile.trim();
   if (!account) {
-    uni.showToast({
-      title: '请输入账号',
+    toast({
+      content: '请输入账号',
       icon: 'none',
     });
     return;
@@ -142,13 +148,32 @@ async function handleSubmit() {
     await authStore.loginCollect(account, formModel.value.password, loginType);
     toast('您已成功登录');
     await new Promise((r) => setTimeout(r, 200));
+
+    let nextPage = '';
     if (authStore.loginType === 0) {
-      uni.redirectTo({ url: '/pages/collect/inheritor' });
+      nextPage = '/pages/collect/inheritor';
     } else if (authStore.loginType === 1) {
-      uni.redirectTo({ url: '/pages/collect/admin' });
-    } else {
-      uni.switchTab({ url: '/pages/user/index' });
+      nextPage = '/pages/collect/admin';
+    }
+
+    //如果用户未绑定微信,提示用户绑定微信
+    if (!authStore.userInfo?.openId && tipBindWechat.isTimeout()) {
+      tipBindWechat.recordTime();
+
+      if (await confirm({
+        title: '提示',
+        content: '绑定微信账号后登录更方便,是否前往绑定?',
+        confirmText: '前往绑定',
+        cancelText: '稍后绑定',
+        width: 580,
+      })) {
+        redirectTo('bind-wx', {
+          nextPage
+        });
+        return;
+      }
     }
+    redirectTo(nextPage);
   } catch (e) {
     showError(e);
   } finally {

+ 52 - 0
src/pages/collect/user/bind-wx.vue

@@ -0,0 +1,52 @@
+<template>
+  <CommonRoot>
+    <FlexCol :gap="20" :padding="30">
+      <Image src="https://mn.wenlvti.net/app_static/xiangyuan/images/bind-banner.jpg" width="100%" height="400" />
+      <Button type="primary" @click="submit" :loading="loading">立即绑定</Button>
+      <Button @click="doBack">稍后再说</Button>
+    </FlexCol>
+  </CommonRoot>
+</template>
+
+<script setup lang="ts">
+import { ref } from 'vue';
+import { useLoadQuerys } from '@/common/composeabe/LoadQuerys';
+import { toast } from '@/components/dialog/CommonRoot';
+import { showError } from '@/common/composeabe/ErrorDisplay';
+import { back, redirectTo } from '@/components/utils/PageAction';
+import Button from '@/components/basic/Button.vue';
+import FlexCol from '@/components/layout/FlexCol.vue';
+import CommonRoot from '@/components/dialog/CommonRoot.vue';
+import Image from '@/components/basic/Image.vue';
+import InheritorContentApi from '@/api/collect/InheritorContent';
+
+/**
+ *  账号绑定微信页面
+ */
+
+const { querys } = useLoadQuerys({
+  nextPage: ''
+});
+const loading = ref(false);
+
+async function submit() {
+  try {
+    loading.value = true;
+    const res = await uni.login({ provider: 'weixin' });
+    await InheritorContentApi.bindWechat({ code: res.code });
+    toast({ content: '绑定成功' });
+    setTimeout(doBack, 800);
+  } catch (e) {
+    showError(e);
+  } finally {
+    loading.value = false;
+  }
+}
+function doBack() {
+  if (querys.value.nextPage) {
+    redirectTo(querys.value.nextPage);
+  } else {
+    back();
+  }
+}
+</script>