|
@@ -14,25 +14,32 @@ import {
|
|
|
CountDown,
|
|
|
RadioGroup,
|
|
|
Radio,
|
|
|
- Picker
|
|
|
+ Picker,
|
|
|
+ closeToast
|
|
|
} from 'vant';
|
|
|
import {
|
|
|
computed,
|
|
|
defineComponent,
|
|
|
nextTick,
|
|
|
onMounted,
|
|
|
+ onUnmounted,
|
|
|
reactive,
|
|
|
ref
|
|
|
} from 'vue';
|
|
|
import qs from 'query-string';
|
|
|
-import { state as baseState, setLogin, setLoginInit } from '@/state';
|
|
|
+import {
|
|
|
+ state as baseState,
|
|
|
+ goWechatAuth,
|
|
|
+ setLogin,
|
|
|
+ setLoginInit
|
|
|
+} from '@/state';
|
|
|
import styles from './index.module.less';
|
|
|
import MSticky from '@/components/m-sticky';
|
|
|
// import MVideo from '@/components/m-video';
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
|
import { useStudentRegisterStore } from '@/store/modules/student-register-store';
|
|
|
import request from '@/helpers/request';
|
|
|
-import { browser, checkPhone, moneyFormat } from '@/helpers/utils';
|
|
|
+import { browser, checkPhone, getUrlCode, moneyFormat } from '@/helpers/utils';
|
|
|
import deepClone from '@/helpers/deep-clone';
|
|
|
import OWxTip from '@/components/m-wx-tip';
|
|
|
import MDialog from '@/components/m-dialog';
|
|
@@ -50,6 +57,9 @@ import Payment from '../adapay/payment';
|
|
|
import QrcodePayment from './qrcode-payment';
|
|
|
import MImgCode from '@/components/m-img-code';
|
|
|
import { beforeSubmit } from './order-state';
|
|
|
+import { useInterval, useIntervalFn } from '@vueuse/core';
|
|
|
+import MPopup from '@/components/m-popup';
|
|
|
+import UserAuth from './component/user-auth';
|
|
|
|
|
|
const classList: any = [];
|
|
|
for (let i = 1; i <= 40; i++) {
|
|
@@ -140,7 +150,11 @@ export default defineComponent({
|
|
|
showOtherMessage: '',
|
|
|
joinType: '' as 'digitalize' | 'tradition',
|
|
|
gradeList: [] as any,
|
|
|
- classList: [] as any
|
|
|
+ classList: [] as any,
|
|
|
+ saveId: null as any,
|
|
|
+ openId: null as any,
|
|
|
+ code: null as any,
|
|
|
+ intervalFnRef: null as any // 页面订时器
|
|
|
});
|
|
|
|
|
|
const state = reactive({
|
|
@@ -171,6 +185,9 @@ export default defineComponent({
|
|
|
password: '',
|
|
|
username: ''
|
|
|
});
|
|
|
+ // 页面定时
|
|
|
+ const pageTimer = useInterval(1000, { controls: true });
|
|
|
+ pageTimer.pause();
|
|
|
|
|
|
const countDown = useCountDown({
|
|
|
// 倒计时 60 秒
|
|
@@ -379,6 +396,22 @@ export default defineComponent({
|
|
|
);
|
|
|
setLoginInit();
|
|
|
|
|
|
+ let joinType = 'NOT_REGISTER';
|
|
|
+ if (forms.joinType === 'digitalize') {
|
|
|
+ joinType = 'SELECT_INSTRUMENT';
|
|
|
+ }
|
|
|
+ if (forms.joinType === 'tradition') {
|
|
|
+ joinType = 'NOT_BUY_INSTRUMENT';
|
|
|
+ }
|
|
|
+ // 更新时间
|
|
|
+ await updateStat(
|
|
|
+ pageTimer.counter.value,
|
|
|
+ joinType,
|
|
|
+ result.data.userId,
|
|
|
+ forms.schoolId
|
|
|
+ );
|
|
|
+ pageTimer.counter.value = 0;
|
|
|
+
|
|
|
// 传统方式
|
|
|
if (forms.joinType === 'tradition') {
|
|
|
setTimeout(() => {
|
|
@@ -532,6 +565,7 @@ export default defineComponent({
|
|
|
{
|
|
|
// hideLoading: false,
|
|
|
data: {
|
|
|
+ buryId: forms.saveId,
|
|
|
registerType: forms.registerType,
|
|
|
paymentType: forms.paymentType,
|
|
|
bizId: forms.schoolId, // 乐团编号
|
|
@@ -719,8 +753,108 @@ export default defineComponent({
|
|
|
paymentContinue(); // 实名成功后自动支付
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * 页面停留时间
|
|
|
+ * @param pageBrowseTime 停留时间
|
|
|
+ * @param joinType 加入方式
|
|
|
+ * @param userId 用户编号
|
|
|
+ * @param schoolId 学校编号
|
|
|
+ */
|
|
|
+ const updateStat = async (
|
|
|
+ pageBrowseTime = 10,
|
|
|
+ joinType?: string,
|
|
|
+ userId?: string,
|
|
|
+ schoolId?: string
|
|
|
+ ) => {
|
|
|
+ try {
|
|
|
+ const { data } = await request.post(
|
|
|
+ '/edu-app/open/studentRegisterPointRecord/update',
|
|
|
+ {
|
|
|
+ data: {
|
|
|
+ id: forms.saveId,
|
|
|
+ useTime: pageBrowseTime, // 固定10秒
|
|
|
+ joinType,
|
|
|
+ userId,
|
|
|
+ schoolId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ forms.saveId = data;
|
|
|
+ } catch {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ 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 =
|
|
|
+ window.location.origin +
|
|
|
+ window.location.pathname +
|
|
|
+ '#' +
|
|
|
+ route.path +
|
|
|
+ '?' +
|
|
|
+ qs.stringify({
|
|
|
+ ...route.query
|
|
|
+ });
|
|
|
+ getAppIdAndCode(newUrl);
|
|
|
+ return '';
|
|
|
+ } else {
|
|
|
+ forms.code = code;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
onMounted(async () => {
|
|
|
- getRegisterGoods();
|
|
|
+ try {
|
|
|
+ getRegisterGoods();
|
|
|
+ // 判断是否获取微信code码
|
|
|
+ if (!forms.code) return;
|
|
|
+ const { data } = await request.post(
|
|
|
+ '/edu-app/open/studentRegisterPointRecord/save',
|
|
|
+ {
|
|
|
+ data: {
|
|
|
+ code: forms.code,
|
|
|
+ schoolId: forms.schoolId,
|
|
|
+ openId: forms.openId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ forms.saveId = data.id;
|
|
|
+ forms.openId = data.openId;
|
|
|
+ sessionStorage.setItem('active-open-id', data.openId);
|
|
|
+
|
|
|
+ // 间隔多少时间同步数据
|
|
|
+ forms.intervalFnRef = useIntervalFn(async () => {
|
|
|
+ // 页面时间恢复
|
|
|
+ pageTimer.counter.value = 0;
|
|
|
+ pageTimer.resume();
|
|
|
+ // 同步数据时先进行有效时间进行保存
|
|
|
+
|
|
|
+ await updateStat();
|
|
|
+ }, 5000);
|
|
|
+ } catch {}
|
|
|
+ });
|
|
|
+
|
|
|
+ onUnmounted(() => {
|
|
|
+ forms.intervalFnRef?.pause(); // 暂停回调
|
|
|
});
|
|
|
|
|
|
return () => (
|
|
@@ -1172,6 +1306,10 @@ export default defineComponent({
|
|
|
/>
|
|
|
</Popup>
|
|
|
|
|
|
+ <MPopup v-model:modelValue={state.authShow}>
|
|
|
+ <UserAuth onSuccess={onAuthSuccess} hideHeader={!browser().isApp} />
|
|
|
+ </MPopup>
|
|
|
+
|
|
|
{/* 是否在微信中打开 */}
|
|
|
<OWxTip
|
|
|
show={forms.showTips}
|