Browse Source

Merge branch 'feature-2025-1-10' into online

TIANYONG 3 months ago
parent
commit
e7a2eaf976

+ 168 - 0
src/hooks/useAuthCode/index.ts

@@ -0,0 +1,168 @@
+import request from '@/helpers/request';
+import { browser, getUrlCode } from '@/helpers/utils';
+import { goWechatAuth } from '@/state';
+import { ref } from 'vue';
+/** 微信Code签名 */
+const WX_CODE_SIGN = 'WXCODESIGN';
+/** 签名有效时间 3分钟 */
+const SIGN_VALID_TIME = 1000 * 60 * 3;
+/** 微信OpenId */
+const WX_OPEN_ID = 'WXOPENID';
+
+/**
+ * 获取微信微信Code码 | 获取微信OPENID - 用于微信授权
+ */
+export default function useAuthCode() {
+  // 微信Code
+  const weChatCode = ref<string>('');
+  // 微信appId
+  const wxAppId = ref<string>('');
+  /**
+   * 获取微信appId
+   */
+  const getAppId = async () => {
+    if (wxAppId.value) return;
+    const { data } = await request.get('/edu-app/open/paramConfig/wechatAppId');
+    // 判断是否有微信appId
+    if (data) {
+      wxAppId.value = data;
+    }
+  };
+
+  /**
+   * 检查签名是否有效
+   */
+  const checkSignValid = () => {
+    const sign = sessionStorage.getItem(WX_CODE_SIGN);
+    if (!sign) {
+      return false;
+    }
+    const now = Date.now();
+    //
+    if (now - Number(sign) > SIGN_VALID_TIME) {
+      return false;
+    }
+    return true;
+  };
+
+  /**
+   * 去微信获取Code
+   * @param url 当前页面的url
+   */
+  const getWeChatAuthCode = async (url?: string) => {
+    const authUrl = url || window.location.href;
+    // 判断是否在微信浏览器中打开
+    if (!browser().weixin) {
+      console.warn('在微信浏览器中打开');
+      return;
+    }
+
+    // 获取链接上的code
+    const code = getUrlCode();
+    // 如果链接上有code 或者 签名无效
+    if (!code || !checkSignValid()) {
+      await getAppId();
+      if (!wxAppId.value) {
+        console.warn('没有获取到微信appId');
+        return;
+      }
+      // 设置签名
+      onWeChatSign('SET', Date.now().toString());
+      goWechatAuth(wxAppId.value, authUrl);
+    } else {
+      weChatCode.value = code;
+      onWeChatSign('REMOVE');
+    }
+  };
+
+  /**
+   * 微信Code操作
+   * @param type 操作类型
+   */
+  const onWeChatCode = (type: 'GET' | 'REMOVE') => {
+    if (type === 'GET') {
+      return weChatCode.value;
+    }
+    weChatCode.value = '';
+  };
+
+  /**
+   * 微信sign操作
+   * @param type 操作类型
+   * @param value 值
+   */
+  const onWeChatSign = (type: 'GET' | 'REMOVE' | 'SET', value?: string) => {
+    if (type === 'GET') {
+      return sessionStorage.getItem(WX_CODE_SIGN);
+    } else if (type === 'REMOVE') {
+      sessionStorage.removeItem(WX_CODE_SIGN);
+    } else if (type === 'SET') {
+      sessionStorage.setItem(WX_CODE_SIGN, value || '');
+    }
+  };
+
+  /**
+   * 获取缓存微信OpenId
+   * @param type 操作类型
+   * @param value 值
+   */
+  const onWeChatCatchOpenId = (
+    type: 'GET' | 'REMOVE' | 'SET',
+    value?: string
+  ) => {
+    if (type === 'GET') {
+      return sessionStorage.getItem(WX_OPEN_ID);
+    } else if (type === 'REMOVE') {
+      sessionStorage.removeItem(WX_OPEN_ID);
+    } else if (type === 'SET') {
+      sessionStorage.setItem(WX_OPEN_ID, value || '');
+    }
+  };
+
+  /**
+   * 获取微信OpenId
+   * @param url 当前页面的url
+   * @param code 微信Code
+   */
+  const getOpenId = async (url?: string, code?: string) => {
+    // 获取缓存OpenId
+    const openId = onWeChatCatchOpenId('GET');
+    if (openId) {
+      return openId;
+    }
+    // debugger
+    // 如果没有code - 去获取code
+    if (!code) {
+      await getWeChatAuthCode(url);
+    }
+
+    if (!code && !weChatCode.value) {
+      console.warn('没有获取到微信Code');
+      return;
+    }
+
+    await getAppId();
+    if (!wxAppId.value) {
+      return;
+    }
+    const { data } = await request.post(
+      '/edu-app/open/paramConfig/wechatOpenId',
+      {
+        data: {
+          code: code || weChatCode.value,
+          appId: wxAppId.value
+        }
+      }
+    );
+    onWeChatCatchOpenId('SET', data);
+    return data;
+  };
+
+  return {
+    getOpenId,
+    getWeChatAuthCode,
+    onWeChatCode,
+    onWeChatSign,
+    onWeChatCatchOpenId
+  };
+}

+ 1 - 1
src/hooks/useWeChatShare/index.ts

@@ -32,7 +32,7 @@ export default function useWeChatShare(
       });
   };
   const setWeChatShare = (data: any) => {
-    console.log(wxChat, 'wxChat');
+    // console.log(wxChat, 'wxChat');
     wxChat.config({
       debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
       appId: data.appId, // 必填,公众号的唯一标识

+ 4 - 4
src/router/router-root.ts

@@ -349,7 +349,7 @@ export default [
     meta: {
       title: '数字化转型问卷统计'
     }
-  },  
+  },
   {
     path: '/statistics-detail',
     name: 'statistics-detail',
@@ -357,7 +357,7 @@ export default [
     meta: {
       title: '数字化转型问卷统计'
     }
-  },    
+  },
   {
     path: '/questionnaire-statistics-new',
     name: 'questionnaire-statistics-new',
@@ -365,7 +365,7 @@ export default [
     meta: {
       title: '数字化转型问卷统计'
     }
-  },  
+  },
   {
     path: '/statistics-detail-new',
     name: 'statistics-detail-new',
@@ -373,7 +373,7 @@ export default [
     meta: {
       title: '数字化转型问卷统计'
     }
-  },   
+  },
   {
     path: '/:pathMatch(.*)*',
     component: () => import('@/views/404'),

+ 6 - 6
src/state.ts

@@ -76,7 +76,7 @@ export const goWechatAuth = (wxAppId: string, urlString?: string) => {
   // 开发环境
   if (import.meta.env.DEV) {
     const replaceUrl =
-      `https://online.lexiaoya.cn/getWxCode?appid=${
+      `https://kt.colexiu.com/getWxCode?appid=${
         wxAppId || 'wx8654c671631cfade'
       }&state=STATE&redirect_uri=` +
       encodeURIComponent(urlString || window.location.href);
@@ -110,15 +110,15 @@ export const goAliAuth = (alipayAppId: string, urlString?: string) => {
   const urlNow = encodeURIComponent(urlString || window.location.href);
   const appid = alipayAppId || '2021004100630808';
   // 开发环境
-  if (import.meta.env.DEV) {
+  // if (import.meta.env.DEV) {
     let url = `https://kt.colexiu.com/getAliCode?app_id=${appid}&state=STATE&redirect_uri=${urlNow}`;
     window.location.replace(url);
-  }
+  // }
 
   // 生产环境
-  if (import.meta.env.PROD) {
-    alipayAuth(alipayAppId, urlString);
-  }
+  // if (import.meta.env.PROD) {
+  //   alipayAuth(alipayAppId, urlString);
+  // }
 };
 
 const alipayAuth = (alipayAppId: string, urlString?: string) => {

+ 1 - 0
src/views/adapay/pay-define/index.tsx

@@ -37,6 +37,7 @@ export default defineComponent({
           merOrderNo: state.orderNo,
           paymentChannel: state.pay_channel, // 支付渠道
           userId: state.userId,
+          wxPubAppId: state.wxAppId,
           code: state.code
         };
         // 判断是否是微信公众号支付

+ 1 - 0
src/views/adapay/pay-result-wechat/index.tsx

@@ -81,6 +81,7 @@ export default defineComponent({
           merOrderNo: state.orderNo,
           paymentChannel: state.pay_channel, // 支付渠道
           userId: state.userId,
+          wxPubAppId: state.wxAppId,
           code: state.code
         };
         //     // 判断是否是微信公众号支付

+ 1 - 0
src/views/adapay/pay-result/index.tsx

@@ -81,6 +81,7 @@ export default defineComponent({
           merOrderNo: state.orderNo,
           paymentChannel: state.pay_channel, // 支付渠道
           userId: state.userId,
+          wxPubAppId: state.wxAppId,
           code: state.code
         };
         //     // 判断是否是微信公众号支付

+ 1 - 0
src/views/adapay/payment/index.tsx

@@ -117,6 +117,7 @@ export default defineComponent({
           merOrderNo: props.paymentConfig.orderNo,
           paymentChannel: payChannel, // 支付渠道
           paymentType: paymentType,
+          wxPubAppId: props.paymentConfig.wxAppId,
           userId: props.paymentConfig.userId
         };
 

+ 2 - 2
src/views/fill-questionnaire/index.module.less

@@ -27,7 +27,7 @@
   padding: 15px 16px 0;
   .formItem {
     margin-bottom: 24px;
-    >p {
+    p {
       color: #333333;
       font-size: 15px;
       font-weight: 600;
@@ -90,7 +90,7 @@
       .vdSchool {
         font-size: 15px;
         color: #000000;
-        margin-bottom: 4px;
+        // margin-bottom: 4px;
         text-overflow: ellipsis;
         overflow: hidden;
         word-break: break-all;

+ 50 - 60
src/views/fill-questionnaire/index.tsx

@@ -15,14 +15,11 @@ import {
   Area,
 } from 'vant';
 import { useRoute, useRouter } from 'vue-router';
-import threeMan from './images/update/three-man.png'
+// import threeMan from './images/update/three-man.png'
 import OWxTip from '@/components/m-wx-tip';
-import { browser, getHttpOrigin, getUrlCode, checkPhone } from '@/helpers/utils';
+import { checkPhone } from '@/helpers/utils';
 import qs from 'query-string';
 import request from '@/helpers/request';
-import { goWechatAuth } from '@/state';
-import { useInterval, useIntervalFn } from '@vueuse/core';
-import MMessageTip from '@/components/m-message-tip';
 import MImgCode from '@/components/m-img-code';
 import MSearch from '@/components/m-search';
 import submitBtn from './images/submit_icon.png'
@@ -30,14 +27,15 @@ import signupBtn from './images/signup_icon.png'
 import signSusIcon from './images/sign_icon.png'
 import subSusIcon from './images/subsus_icon.png'
 import doneIcon from './images/done_icon.png'
-import { subscribe } from 'diagnostics_channel';
-import { api_sysAreaQueryAllProvince } from '@/views/school-register/api';
+import { api_sysAreaQueryAllProvince, api_queryTennatArea } from '@/views/school-register/api';
+import useAuthCode from '@/hooks/useAuthCode';
 
 export default defineComponent({
   name: 'fill-questionnaire',
   setup() {
     const router = useRouter();
     const route = useRoute();
+    const authCode = useAuthCode();
 
     const classList: any = [];
     for (let i = 1; i <= 40; i++) {
@@ -201,31 +199,35 @@ export default defineComponent({
       code: null as any,
       areaPopupIndex: null as any,
       customSearchText: '' as any,
+      tenantId: null as any, // 机构id
+      customQuestionE: null as any, // 自定义的题目标题
     })
 
     onMounted(async () => {
+      // 根据机构id获取省市区id
+      forms.tenantId = route.query.tenantId
+      if (sessionStorage.getItem('customQuestionE')) {
+        forms.customQuestionE = sessionStorage.getItem('customQuestionE')
+      }
+      const { data } = await api_queryTennatArea(forms.tenantId)
+      if (data && data.length) {
+        forms.provinceCode = data[0].provinceCode
+        forms.cityCode = data[0].cityCode
+        forms.districtCode = data[0].regionCode
+        /**
+         * 2025.02.28,修改为不需要选区域,直接选学校,之前的逻辑如果areaName存在,则不需要选区域,后续可能会放开,又需要选区域,所以先随便给areaName赋值
+         */
+        forms.areaName = '学校名称'
+        //getSchoolAreaList()
+      }
+      console.log(333,forms.provinceCode)
       queryDetail();
-      getAreaList();
+      // getAreaList();
     });
 
-    const getAppIdAndCode = async (url?: string) => {
-      try {
-        const { data } = await request.get(
-          '/edu-app/open/paramConfig/wechatAppId'
-        );
-        // 判断是否有微信appId
-        if (data) {
-          closeToast();
-          goWechatAuth(data, url);
-        }
-      } catch(e) {
-        //
-        console.log(e)
-      }
-    };
-
     // 如果没有openId,跳转到第一个页面
-    if (!sessionStorage.getItem('active-open-id')) {
+    forms.openId = authCode.onWeChatCatchOpenId("GET");
+    if (!forms.openId) {
       router.push({
         path: '/intention-questionnaire',
         query: {
@@ -233,28 +235,6 @@ export default defineComponent({
         }
       });
     }
-    if (browser().weixin) {
-      //授权
-      const openId = sessionStorage.getItem('active-open-id');
-      forms.openId = openId;
-      const code = getUrlCode();
-      console.log(code, 'code')
-      if (!code) {
-        const newUrl =
-          getHttpOrigin() +
-          window.location.pathname +
-          '#' +
-          route.path +
-          '?' +
-          qs.stringify({
-            ...route.query
-          });
-        getAppIdAndCode(newUrl);
-        return '';
-      } else {
-        forms.code = code;
-      }
-    }
 
     const onPageShow = () => {
       console.log(forms.isPageHide, 'showInfo');
@@ -278,10 +258,11 @@ export default defineComponent({
         const { data } = await request.get(
           '/edu-app/open/schoolMeetingQuestion/detail?openId=' + forms.openId
         );
-        console.log(12222,data)
-        forms.provinceCode = data.provinceCode
-        forms.cityCode = data.cityCode
-        forms.districtCode = data.districtCode
+        if (!data) return;
+        // forms.provinceCode = data.provinceCode
+        // forms.cityCode = data.cityCode
+        // forms.districtCode = data.districtCode
+        // console.log(12222,data,forms.provinceCode)
         // 回显省市区
         forms.areaPopupIndex = data.districtCode || data.cityCode || data.provinceCode
         forms.areaPopupIndex = forms.areaPopupIndex ? String(forms.areaPopupIndex) : null
@@ -390,9 +371,9 @@ export default defineComponent({
       if (checkForm()) {
         try {
           forms.submitLoading = true;
-          const { currentClass, districtCode, currentGrade, participationFlag,cityCode, openId,provinceCode,smsCode,phone,schoolAreaId,supportFlag,username,id} = forms
+          const { currentClass, districtCode, currentGrade, participationFlag,cityCode, openId,provinceCode,smsCode,phone,schoolAreaId,supportFlag,username,id, tenantId} = forms
           let params: any = {
-            currentClass, districtCode, currentGrade, participationFlag,cityCode, openId,provinceCode,schoolAreaId,supportFlag,username
+            currentClass, districtCode, currentGrade, participationFlag,cityCode, openId,provinceCode,schoolAreaId,supportFlag,username, tenantId
           }
           if (id) {
             params.id = id
@@ -612,12 +593,12 @@ export default defineComponent({
             <p>1. 学校</p>
             {
               forms.schoolName ?
-              <div class={[styles.valDone, forms.schoolName && styles.valDone2, (forms.schoolStatus||forms.showPicker) && styles.openVal]} onClick={() => {
+              <div class={[styles.valDone, (forms.schoolStatus||forms.showPicker) && styles.openVal]} onClick={() => {
                 forms.schoolStatus = true
                 getSchoolAreaList()
               }}>
                 {forms.schoolName && <span class={styles.vdSchool}>{forms.schoolName}</span>}
-                <span class={styles.vdArea}>{forms.areaName}</span>
+                {/* <span class={styles.vdArea}>{forms.areaName}</span> */}
                 <i></i>
               </div> :
               <div class={[styles.valDot, styles.grayText, (forms.schoolStatus||forms.showPicker) && styles.openVal]} onClick={openAreaPop}>请选择学校<i></i></div>
@@ -669,10 +650,19 @@ export default defineComponent({
           </div>
           <div class={styles.formItem}>
             {
-              route.query.meetingType === 'primarySchoolNo' || route.query.meetingType === 'juniorSchoolNo' ?
-              <p>6. 您是否愿意学生参加数字化转型<span>(注:以学生及家长自愿参加为原则。如愿意参加,家长需自行为学生准备好乐器和“器乐数字Ai”应用软件两项学习工具,市面上均有提供,大约300多元一年。学校不涉及任何收费行为。如不参加,学生按原有方式进行音乐课学习。)</span></p> :
-              <p>6. 您是否愿意学生参加数字化转型<span>(注:以学生及家长自愿参加为原则。如愿意参加,家长需自行为学生准备好“器乐数字Ai”应用软件,市面上均有提供,大约300多元一年,学校不涉及任何收费行为。如不参加,学生按原有方式进行器乐课程学习。)</span></p>
+              forms.customQuestionE ? 
+              <>
+                <div v-html={forms.customQuestionE}></div>
+              </> : 
+              <>
+                {
+                  route.query.meetingType === 'primarySchoolNo' || route.query.meetingType === 'juniorSchoolNo' ?
+                  <p>6. 您是否愿意学生参加数字化转型<span>(注:以学生及家长自愿参加为原则。如愿意参加,家长需自行为学生准备好乐器和“器乐数字Ai”应用软件两项学习工具,市面上均有提供,大约300多元一年。学校不涉及任何收费行为。如不参加,学生按原有方式进行音乐课学习。)</span></p> :
+                  <p>6. 您是否愿意学生参加数字化转型<span>(注:以学生及家长自愿参加为原则。如愿意参加,家长需自行为学生准备好“器乐数字Ai”应用软件,市面上均有提供,大约300多元一年,学校不涉及任何收费行为。如不参加,学生按原有方式进行器乐课程学习。)</span></p>
+                }
+              </>
             }
+
             <div class={styles.selectItem}>
               {
                 forms.willingList.map(item =>
@@ -860,9 +850,9 @@ export default defineComponent({
                 {{
                   'columns-top': (
                     <div class={styles.columnsTop}>
-                      <Cell border={false} clickable={false} title={forms.areaName || '请选择省市区'} isLink onClick={() => {
+                      {/* <Cell border={false} clickable={false} title={forms.areaName || '请选择省市区'} isLink onClick={() => {
                         forms.showPicker = true;
-                      }} />
+                      }} /> */}
                       <MSearch
                         placeholder="请输入学校名称"
                         onSearch={(val: any) => {

+ 39 - 100
src/views/intention-questionnaire/index.tsx

@@ -1,51 +1,36 @@
-import {
-  defineComponent,
-  onMounted,
-  onUnmounted,
-  reactive,
-  ref,
-  nextTick
-} from 'vue';
+import { defineComponent, onMounted, onUnmounted, reactive, ref } from 'vue';
 import styles from './index.module.less';
-// import signinTips from './images/signin-tips.png';
-import {
-  Button,
-  CellGroup,
-  Field,
-  Picker,
-  Popup,
-  closeToast,
-  showToast,
-  Loading
-} from 'vant';
+import { closeToast } from 'vant';
 import { useRoute, useRouter } from 'vue-router';
-import threeMan from './images/update/three-man.png';
 import OWxTip from '@/components/m-wx-tip';
-import { browser, getHttpOrigin, getUrlCode } from '@/helpers/utils';
+import { browser, getHttpOrigin } from '@/helpers/utils';
 import qs from 'query-string';
 import request from '@/helpers/request';
-import { goWechatAuth, goWechatAuthTemp } from '@/state';
-import { useInterval, useIntervalFn } from '@vueuse/core';
-import MMessageTip from '@/components/m-message-tip';
-import TCPlayer from 'tcplayer.js';
+import { useInterval } from '@vueuse/core';
 import 'tcplayer.js/dist/tcplayer.css';
 import { _initVideo } from './initVideo';
 import nextBtn from './images/next_btn.png';
 import useWeChatShare from '@/hooks/useWeChatShare';
+import useAuthCode from '@/hooks/useAuthCode';
 
 export default defineComponent({
   name: 'intention-questionnaire',
   setup() {
     const route = useRoute();
-    const shareTitle = route.query.type === 'primarySchoolNo' ? '(小学)关于开展音乐(器乐)课堂数字化转型的调查问卷' :
-    route.query.type === 'juniorSchoolNo' ? '(初中)关于开展音乐(器乐)课堂数字化转型的调查问卷' :
-    '关于开展音乐(器乐)课堂数字化转型的调查问卷'
+    const shareTitle =
+      route.query.type === 'primarySchoolNo'
+        ? '(小学)关于开展音乐(器乐)课堂数字化转型的调查问卷'
+        : route.query.type === 'juniorSchoolNo'
+        ? '(初中)关于开展音乐(器乐)课堂数字化转型的调查问卷'
+        : '关于开展音乐(器乐)课堂数字化转型的调查问卷';
     const weChatShare = useWeChatShare(
       shareTitle,
       '科学的教育改变世界,科技的力量让音乐传播更远,让孩子奏响心中的乐章',
       window.location.origin + '/classroom-app/shareImg/question-share.png'
     );
 
+    const authCode = useAuthCode();
+
     // 页面定时
     const pageTimer = useInterval(1000, { controls: true });
     pageTimer.pause();
@@ -63,6 +48,7 @@ export default defineComponent({
         '<p style="text-align: left;"><strong style="font-size:15px; color: #0B8BFE;">三、开展原则</strong></p><p style="text-align: left;">本次活动面向全体学生,完全遵循学生自愿参加的原则。</p><p style="text-align: left;">1.若学生选择参加转型,家长需自行为学生准备好自用的乐器(硬件)和“器乐数字 Ai”应用(软件,用于联通学校音乐课堂)两项学习工具。</p><p style="text-align: left;">2.若学生不参加转型,可继续按原有方式进行音乐课学习。</p>',
       contentD:
         '<p style="text-align: left;"><strong style="font-size:15px; color: #0B8BFE;">五、事项说明</strong></p><p style="text-align: left;">1.学校不涉及任何费用收取。学生所需的自用工具在市面上均可购买到,家长可自行根据实际情况为学生准备。</p><p style="text-align: left;">2.如学生有参加数字化转型的意愿,但存在特殊或特困情况,可先向学校进行登记,学校将尽力寻求资源协助家长解决。</p><p style="text-align: left;">在您了解上述内容后,请点击下一步进行意见填写:</p>',
+      contentE: null as any,  
       introductionVideo: 'https://oss.dayaedu.com/ktyq/02/1739345029052.mp4',
       introductionVideoTime: 117,
       coverImg: 'https://oss.dayaedu.com/ktyq/02/1739362815061.png',
@@ -82,7 +68,8 @@ export default defineComponent({
         | 'juniorSchool'
         | any,
       intentionInfo: null as any,
-      contentShow: false
+      contentShow: false,
+      tenantId: null as any, // 机构id
     });
 
     const showPopup = ref(false);
@@ -97,38 +84,37 @@ export default defineComponent({
 
     onMounted(async () => {
       forms.meetingType = route.query.type || forms.meetingType;
-      forms.code = route.query.code || forms.code;
-      // nextTick(() => {
-      //   const videoRef: any = document.querySelector('#register-video')
-      //   const videoRef2: any = document.querySelector('#register-video2')
-      //   if(videoRef) {
-      //     const rect = videoRef?.getBoundingClientRect()
-      //     console.log(rect)
-      //     videoRef.style.height = rect.width / 16 * 9 + 'px'
-      //   }
-      //   if(videoRef2) {
-      //     const rect = videoRef2?.getBoundingClientRect()
-      //     console.log(rect)
-      //     videoRef2.style.height = rect.width / 16 * 9 + 'px'
-      //   }
-      // })
+      forms.tenantId = route.query.id || '1891864516088385538'
       try {
-        // 判断是否获取微信code码
-        if (!forms.code  && browser().weixin) return;
+        const openId = await authCode.getOpenId(
+          getHttpOrigin() +
+            window.location.pathname +
+            '#' +
+            route.path +
+            '?' +
+            qs.stringify({
+              ...route.query
+            })
+        );
+        forms.openId = openId
+        // 获取微信分享签名
+        weChatShare.getAppSignature();
+        // if (!browser().weixin || !openId) return;
         const { data } = await request.get(
           '/edu-app/open/meetingQuestionSetting/detail?type=' +
             forms.meetingType +
-            '&weChatCode=' +
-            forms.code
+            '&tenantId=' + forms.tenantId
         );
         if (data) {
           forms.contentA = data.contentA || forms.contentA;
           forms.contentB = data.contentB || forms.contentB;
           forms.contentC = data.contentC || forms.contentC;
           forms.contentD = data.contentD || forms.contentD;
-          forms.openId = data.openId || forms.openId;
-          sessionStorage.setItem('active-open-id', forms.openId);
-          sessionStorage.removeItem('isWxcode');
+          forms.contentE = data.contentE || null;
+          // 如果设置了题目名称,则存储,下一步页面需要用到
+          if (forms.contentE) {
+            sessionStorage.setItem('customQuestionE', forms.contentE)
+          }
         }
         forms.contentShow = true;
       } catch {
@@ -138,59 +124,13 @@ export default defineComponent({
       forms.player1 = _initVideo('one', forms, videoIntervalRef);
       forms.player2 = _initVideo('two', forms, videoIntervalRef2);
     });
-
-    const getAppIdAndCode = async (url?: string) => {
-      try {
-        // const { data } = await request.get(
-        //   '/edu-app/open/paramConfig/wechatAppId'
-        // );
-        // // 判断是否有微信appId
-        // if (data) {
-        //   sessionStorage.setItem('isWxcode', '1');
-        //   closeToast();
-        //   goWechatAuth(data, url);
-        // }
-
-        sessionStorage.setItem('isWxcode', '1');
-        closeToast()
-        goWechatAuthTemp('wxccc2efd2678adbe3', url)
-      } catch (e) {
-        //
-        console.log(e);
-      }
-    };
-
-    if (browser().weixin) {
-      //授权
-      const openId = sessionStorage.getItem('active-open-id');
-      forms.openId = openId;
-      const code = getUrlCode();
-      const isWxcode = sessionStorage.getItem('isWxcode');
-      if (!code || isWxcode !== '1') {
-        const newUrl =
-          getHttpOrigin() +
-          window.location.pathname +
-          '#' +
-          route.path +
-          '?' +
-          qs.stringify({
-            ...route.query
-          });
-        getAppIdAndCode(newUrl);
-        return '';
-      } else {
-        forms.code = code;
-
-        // 获取微信分享签名
-        weChatShare.getAppSignature()
-      }
-    }
     const nextSkip = () => {
       router.push({
         path: '/fill-questionnaire',
         query: {
           openId: forms.openId, //
-          meetingType: forms.meetingType
+          meetingType: forms.meetingType,
+          tenantId: forms.tenantId
         }
       });
     };
@@ -208,7 +148,6 @@ export default defineComponent({
       forms.isPageHide = true;
     };
     window.addEventListener('pagehide', onPageHide);
-
     onUnmounted(() => {
       window.removeEventListener('pageshow', onPageShow);
       window.removeEventListener('pagehide', onPageHide);

+ 14 - 72
src/views/intention-questionnaire/show.tsx

@@ -1,29 +1,9 @@
 import { defineComponent, onMounted, onUnmounted, reactive, ref, nextTick } from 'vue';
 import styles from './index.module.less';
-// import signinTips from './images/signin-tips.png';
-import {
-  Button,
-  CellGroup,
-  Field,
-  Picker,
-  Popup,
-  closeToast,
-  showToast,
-  Loading
-} from 'vant';
 import { useRoute, useRouter } from 'vue-router';
-import threeMan from './images/update/three-man.png'
-import OWxTip from '@/components/m-wx-tip';
-import { browser, getHttpOrigin, getUrlCode } from '@/helpers/utils';
-import qs from 'query-string';
-import request from '@/helpers/request';
-import { goWechatAuth } from '@/state';
 import { useInterval, useIntervalFn } from '@vueuse/core';
-import MMessageTip from '@/components/m-message-tip';
-import TCPlayer from 'tcplayer.js';
 import 'tcplayer.js/dist/tcplayer.css';
 import { _initVideo } from './initVideo'
-import nextBtn from './images/next_btn.png'
 
 export default defineComponent({
   name: 'intention-questionnaire-show',
@@ -111,53 +91,15 @@ export default defineComponent({
       window.addEventListener('message', getMessage)
     });
 
-    const getAppIdAndCode = async (url?: string) => {
-      try {
-        const { data } = await request.get(
-          '/edu-app/open/paramConfig/wechatAppId'
-        );
-        // 判断是否有微信appId
-        if (data) {
-          closeToast();
-          goWechatAuth(data, url);
-        }
-      } catch(e) {
-        //
-        console.log(e)
-      }
-    };
-
-    if (browser().weixin) {
-      //授权
-      const openId = sessionStorage.getItem('active-open-id');
-      forms.openId = openId;
-      const code = getUrlCode();
-      console.log(code, 'code')
-      if (!code) {
-        const newUrl =
-          getHttpOrigin() +
-          window.location.pathname +
-          '#' +
-          route.path +
-          '?' +
-          qs.stringify({
-            ...route.query
-          });
-        getAppIdAndCode(newUrl);
-        return '';
-      } else {
-        forms.code = code;
-      }
-    }
-    const nextSkip = () => {
-      router.push({
-        path: '/fill-questionnaire',
-        query: {
-          openId: forms.openId, //
-          meetingType: forms.meetingType
-        }
-      });
-    };
+    // const nextSkip = () => {
+    //   router.push({
+    //     path: '/fill-questionnaire',
+    //     query: {
+    //       openId: forms.openId, //
+    //       meetingType: forms.meetingType
+    //     }
+    //   });
+    // };
     const onPageShow = () => {
       console.log(forms.isPageHide, 'showInfo');
       if (forms.isPageHide) {
@@ -194,16 +136,16 @@ export default defineComponent({
                     playsinline={true}
                     poster={forms.coverImg}
                     preload="auto"></video>
-                </div> 
+                </div>
               </div>
             </div>
           </div>
           <div class={styles.contentBody} v-html={forms.contentB}></div>
           <div class={styles.contentBody} v-html={forms.contentC}></div>
           <div class={styles.contentBody}>
-            <div class={styles.cbTitle}>四、什么是器乐数字 Ai<span>(详见视频介绍)</span></div>   
+            <div class={styles.cbTitle}>四、什么是器乐数字 Ai<span>(详见视频介绍)</span></div>
             <div class={styles.videoBoxCon}>
-              <div class={styles.videoBox}>       
+              <div class={styles.videoBox}>
                 <div class={[styles['video-content']]}>
                   <video
                     id="register-video2"
@@ -212,10 +154,10 @@ export default defineComponent({
                     playsinline={true}
                     poster={forms.coverImg2}
                     preload="auto"></video>
-                </div>  
+                </div>
               </div>
             </div>
-          </div>          
+          </div>
           <div class={styles.contentBody} v-html={forms.contentD}></div>
         </div>
 

+ 57 - 46
src/views/pre-register-active/index.tsx

@@ -16,9 +16,9 @@ import OWxTip from '@/components/m-wx-tip';
 import { browser, getHttpOrigin, getUrlCode } from '@/helpers/utils';
 import qs from 'query-string';
 import request from '@/helpers/request';
-import { goWechatAuth } from '@/state';
 import { useInterval, useIntervalFn } from '@vueuse/core';
 import MMessageTip from '@/components/m-message-tip';
+import useAuthCode from '@/hooks/useAuthCode';
 
 const classList: any = [];
 for (let i = 1; i <= 40; i++) {
@@ -73,6 +73,7 @@ export default defineComponent({
     pageTimer.pause();
     const router = useRouter();
     const route = useRoute();
+    const authCode = useAuthCode();
     const forms = reactive({
       loading: true,
       schoolId: route.query.id,
@@ -192,6 +193,16 @@ export default defineComponent({
     };
 
     onMounted(async () => {
+      forms.openId = await authCode.getOpenId(
+        getHttpOrigin() +
+          window.location.pathname +
+          '#' +
+          route.path +
+          '?' +
+          qs.stringify({
+            ...route.query
+          })
+      );
       try {
         if (!forms.schoolId) {
           showToast('信息获取失败,请联系老师');
@@ -261,7 +272,7 @@ export default defineComponent({
           forms.classList = classList;
         }
         // 判断是否获取微信code码
-        if (!forms.code) return;
+        // if (!forms.code) return;
 
         // // 乐团注册
         // if (data.status !== 'PRE_REGISTER') {
@@ -295,7 +306,7 @@ export default defineComponent({
           {
             data: {
               schoolId: forms.schoolId,
-              code: forms.code,
+              // code: forms.code,
               openId: forms.openId
             }
           }
@@ -309,10 +320,10 @@ export default defineComponent({
         forms.videoBrowsePoint = recordObj.videoBrowsePoint;
         forms.id = recordObj.id;
 
-        sessionStorage.setItem('active-open-id', recordObj.openId);
-        sessionStorage.removeItem('isWxcode');
+        // sessionStorage.setItem('active-open-id', recordObj.openId);
+        // sessionStorage.removeItem('isWxcode');
 
-        console.log(forms, 'forms')
+        // console.log(forms, 'forms')
 
         pageTimer.resume();
         // 间隔10秒更新停留时间
@@ -327,46 +338,46 @@ export default defineComponent({
       }
     });
 
-    const getAppIdAndCode = async (url?: string) => {
-      try {
-        const { data } = await request.get(
-          '/edu-app/open/paramConfig/wechatAppId'
-        );
-        // 判断是否有微信appId
-        if (data) {
-          sessionStorage.setItem('isWxcode', '1');
-          closeToast();
-          goWechatAuth(data, url);
-        }
-      } catch(e) {
-        //
-        console.log(e)
-      }
-    };
-
-    if (browser().weixin) {
-      //授权
-      const openId = sessionStorage.getItem('active-open-id');
-      forms.openId = openId;
-      const code = getUrlCode();
-      console.log(code, 'code')
-      const isWxcode = sessionStorage.getItem('isWxcode');
-      if (!code || isWxcode !== '1') {
-        const newUrl =
-          getHttpOrigin() +
-          window.location.pathname +
-          '#' +
-          route.path +
-          '?' +
-          qs.stringify({
-            ...route.query
-          });
-        getAppIdAndCode(newUrl);
-        return '';
-      } else {
-        forms.code = code;
-      }
-    }
+    // const getAppIdAndCode = async (url?: string) => {
+    //   try {
+    //     const { data } = await request.get(
+    //       '/edu-app/open/paramConfig/wechatAppId'
+    //     );
+    //     // 判断是否有微信appId
+    //     if (data) {
+    //       sessionStorage.setItem('isWxcode', '1');
+    //       closeToast();
+    //       goWechatAuth(data, url);
+    //     }
+    //   } catch(e) {
+    //     //
+    //     console.log(e)
+    //   }
+    // };
+
+    // if (browser().weixin) {
+    //   //授权
+    //   const openId = sessionStorage.getItem('active-open-id');
+    //   forms.openId = openId;
+    //   const code = getUrlCode();
+    //   console.log(code, 'code')
+    //   const isWxcode = sessionStorage.getItem('isWxcode');
+    //   if (!code || isWxcode !== '1') {
+    //     const newUrl =
+    //       getHttpOrigin() +
+    //       window.location.pathname +
+    //       '#' +
+    //       route.path +
+    //       '?' +
+    //       qs.stringify({
+    //         ...route.query
+    //       });
+    //     getAppIdAndCode(newUrl);
+    //     return '';
+    //   } else {
+    //     forms.code = code;
+    //   }
+    // }
 
     const onPageShow = () => {
       console.log(forms.isPageHide, 'showInfo');

+ 6 - 0
src/views/school-register/api.ts

@@ -23,3 +23,9 @@ export const api_openSendSms = (params: any): Promise<any> => {
     requestType: 'form',
   });
 };
+
+
+/** 获取机构省市区id */
+export const api_queryTennatArea = (id: number | string): Promise<any> => {
+  return request.get(`/edu-app/open/tenantInfo/getArea?tenantId=${id}`);
+};

+ 58 - 47
src/views/student-register/index-apply.tsx

@@ -81,6 +81,7 @@ import giftCard2Icon from './images/gift_card2.png';
 import giftZsIcon from './images/gift_zs_icon.png';
 import selectZsTip from './images/select_zs_tip.png';
 import useWeChatShare from '@/hooks/useWeChatShare';
+import useAuthCode from '@/hooks/useAuthCode';
 
 const classList: any = [];
 for (let i = 1; i <= 40; i++) {
@@ -135,6 +136,7 @@ export default defineComponent({
       '智慧旋律,告别枯燥练习。科技的光芒让音乐跨越山海,点亮每一颗童心',
       window.location.origin + '/classroom-app/shareImg/instrument-share.png'
     );
+    const authCode = useAuthCode();
 
     const route = useRoute();
     const studentRegisterStore = useStudentRegisterStore();
@@ -1266,49 +1268,49 @@ export default defineComponent({
       }
     };
 
-    const getAppIdAndCode = async (url?: string) => {
-      try {
-        // const { data } = await request.get(
-        //   '/edu-app/open/paramConfig/wechatAppId'
-        // );
-        // // 判断是否有微信appId
-        // if (data) {
-        //   closeToast();
-        //   goWechatAuth(data, url);
-        // }
-        sessionStorage.setItem('isWxcode', '1');
-        closeToast();
-        goWechatAuthTemp('wxccc2efd2678adbe3', url)
-      } catch {
-        //
-      }
-    };
-
-    if (browser().weixin) {
-      //授权
-      const openId = sessionStorage.getItem('active-open-id');
-      forms.openId = openId;
-      const code = getUrlCode();
-      const isWxcode = sessionStorage.getItem('isWxcode');
-      if (!code || isWxcode !== '1') {
-        const newUrl =
-          getHttpOrigin() +
-          window.location.pathname +
-          '#' +
-          route.path +
-          '?' +
-          qs.stringify({
-            ...route.query
-          });
-        getAppIdAndCode(newUrl);
-        return '';
-      } else {
-        forms.code = code;
-        // 获取微信分享签名
-        weChatShare.getAppSignature()
-      }
-
-    }
+    // const getAppIdAndCode = async (url?: string) => {
+    //   try {
+    //     // const { data } = await request.get(
+    //     //   '/edu-app/open/paramConfig/wechatAppId'
+    //     // );
+    //     // // 判断是否有微信appId
+    //     // if (data) {
+    //     //   closeToast();
+    //     //   goWechatAuth(data, url);
+    //     // }
+    //     sessionStorage.setItem('isWxcode', '1');
+    //     closeToast();
+    //     goWechatAuthTemp('wxccc2efd2678adbe3', url)
+    //   } catch {
+    //     //
+    //   }
+    // };
+
+    // if (browser().weixin) {
+    //   //授权
+    //   const openId = sessionStorage.getItem('active-open-id');
+    //   forms.openId = openId;
+    //   const code = getUrlCode();
+    //   const isWxcode = sessionStorage.getItem('isWxcode');
+    //   if (!code || isWxcode !== '1') {
+    //     const newUrl =
+    //       getHttpOrigin() +
+    //       window.location.pathname +
+    //       '#' +
+    //       route.path +
+    //       '?' +
+    //       qs.stringify({
+    //         ...route.query
+    //       });
+    //     getAppIdAndCode(newUrl);
+    //     return '';
+    //   } else {
+    //     forms.code = code;
+    //     // 获取微信分享签名
+    //     weChatShare.getAppSignature()
+    //   }
+
+    // }
 
     const formatTimerTo = (num: number): string => {
       if (num > 9) {
@@ -1320,13 +1322,12 @@ export default defineComponent({
 
     const pagePointInit = async () => {
       try {
-        // 判断是否获取微信code码
-        if (!forms.code) return;
+        if (!forms.openId) return;
         const { data } = await request.post(
           '/edu-app/open/studentRegisterPointRecord/save',
           {
             data: {
-              code: forms.code,
+              // code: forms.code,
               schoolId: forms.schoolId,
               openId: forms.openId
             }
@@ -1399,6 +1400,17 @@ export default defineComponent({
     }
 
     onMounted(async () => {
+      const openId = await authCode.getOpenId(
+        getHttpOrigin() +
+          window.location.pathname +
+          '#' +
+          route.path +
+          '?' +
+          qs.stringify({
+            ...route.query
+          })
+      );
+      forms.openId = openId;
       try {
         // 获取支付类型
         let expireDay = null;
@@ -2431,7 +2443,6 @@ export default defineComponent({
             </div>
           </div>
         }
-
       </div>
     );
   }

+ 60 - 42
src/views/student-register/index.tsx

@@ -39,7 +39,13 @@ import { useRoute, useRouter } from 'vue-router';
 import { useStudentRegisterStore } from '@/store/modules/student-register-store';
 import request from '@/helpers/request';
 import requestStudent from './request';
-import { browser, checkPhone, getHttpOrigin, getUrlCode, moneyFormat } from '@/helpers/utils';
+import {
+  browser,
+  checkPhone,
+  getHttpOrigin,
+  getUrlCode,
+  moneyFormat
+} from '@/helpers/utils';
 import deepClone from '@/helpers/deep-clone';
 import OWxTip from '@/components/m-wx-tip';
 import MDialog from '@/components/m-dialog';
@@ -70,6 +76,7 @@ import UserAuth from './component/user-auth';
 import MMessageTip from '@/components/m-message-tip';
 import SelectStudent from './modal/select-student';
 import { Timer } from './timer';
+import useAuthCode from '@/hooks/useAuthCode';
 
 const classList: any = [];
 for (let i = 1; i <= 40; i++) {
@@ -128,6 +135,7 @@ export default defineComponent({
     const route = useRoute();
     const pageVisibility = usePageVisibility();
     const studentRegisterStore = useStudentRegisterStore();
+    const authCode = useAuthCode();
     const router = useRouter();
     // 初始化学校编号
     studentRegisterStore.setShoolId(route.query.sId as any);
@@ -1259,42 +1267,42 @@ export default defineComponent({
       }
     };
 
-    const getAppIdAndCode = async (url?: string) => {
-      try {
-        const { data } = await request.get(
-          '/edu-app/open/paramConfig/wechatAppId'
-        );
-        // 判断是否有微信appId
-        if (data) {
-          closeToast();
-          goWechatAuth(data, url);
-        }
-      } catch {
-        //
-      }
-    };
-
-    if (browser().weixin) {
-      //授权
-      const openId = sessionStorage.getItem('active-open-id');
-      forms.openId = openId;
-      const code = getUrlCode();
-      if (!code) {
-        const newUrl =
-          getHttpOrigin() +
-          window.location.pathname +
-          '#' +
-          route.path +
-          '?' +
-          qs.stringify({
-            ...route.query
-          });
-        getAppIdAndCode(newUrl);
-        return '';
-      } else {
-        forms.code = code;
-      }
-    }
+    // const getAppIdAndCode = async (url?: string) => {
+    //   try {
+    //     const { data } = await request.get(
+    //       '/edu-app/open/paramConfig/wechatAppId'
+    //     );
+    //     // 判断是否有微信appId
+    //     if (data) {
+    //       closeToast();
+    //       goWechatAuth(data, url);
+    //     }
+    //   } catch {
+    //     //
+    //   }
+    // };
+
+    // if (browser().weixin) {
+    //   //授权
+    //   const openId = sessionStorage.getItem('active-open-id');
+    //   forms.openId = openId;
+    //   const code = getUrlCode();
+    //   if (!code) {
+    //     const newUrl =
+    //       getHttpOrigin() +
+    //       window.location.pathname +
+    //       '#' +
+    //       route.path +
+    //       '?' +
+    //       qs.stringify({
+    //         ...route.query
+    //       });
+    //     getAppIdAndCode(newUrl);
+    //     return '';
+    //   } else {
+    //     forms.code = code;
+    //   }
+    // }
 
     const formatTimerTo = (num: number): string => {
       if (num > 9) {
@@ -1521,13 +1529,12 @@ export default defineComponent({
 
     const pagePointInit = async () => {
       try {
-        // 判断是否获取微信code码
-        if (!forms.code) return;
+        if (!forms.openId) return;
         const { data } = await request.post(
           '/edu-app/open/studentRegisterPointRecord/save',
           {
             data: {
-              code: forms.code,
+              // code: forms.code,
               schoolId: forms.schoolId,
               openId: forms.openId
             }
@@ -1544,7 +1551,7 @@ export default defineComponent({
           videoForms.player.currentTime(data.videoBrowsePoint || 0);
         }
 
-        sessionStorage.setItem('active-open-id', data.openId);
+        // sessionStorage.setItem('active-open-id', data.openId);
 
         // 间隔多少时间同步数据
         forms.intervalFnRef = useIntervalFn(async () => {
@@ -1580,6 +1587,17 @@ export default defineComponent({
     };
 
     onMounted(async () => {
+      const openId = await authCode.getOpenId(
+        getHttpOrigin() +
+          window.location.pathname +
+          '#' +
+          route.path +
+          '?' +
+          qs.stringify({
+            ...route.query
+          })
+      );
+      forms.openId = openId;
       try {
         // 获取支付类型
         let expireDay = null;
@@ -1890,7 +1908,7 @@ export default defineComponent({
                   forms.classStatus = true;
                 }}
               />
-              {(forms.giftVipDay > 0 && forms.registerDetails.giftVipFlag) ? (
+              {forms.giftVipDay > 0 && forms.registerDetails.giftVipFlag ? (
                 <div class={styles.memberNumer}>
                   <img src={iconGift} class={styles.iconGift} />