Showing
1 changed file
with
41 additions
and
6 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-07-18 10:22:22 | 2 | * @Date: 2022-07-18 10:22:22 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-12-07 10:57:10 | 4 | + * @LastEditTime: 2022-12-07 15:08:29 |
| 5 | * @FilePath: /data-table/src/views/index.vue | 5 | * @FilePath: /data-table/src/views/index.vue |
| 6 | * @Description: 首页 | 6 | * @Description: 首页 |
| 7 | --> | 7 | --> |
| ... | @@ -63,7 +63,7 @@ | ... | @@ -63,7 +63,7 @@ |
| 63 | <div class="wrapper"> | 63 | <div class="wrapper"> |
| 64 | <div class="block"> | 64 | <div class="block"> |
| 65 | <div style="text-align: center; margin-top: 0.5rem;">请先关注公众号</div> | 65 | <div style="text-align: center; margin-top: 0.5rem;">请先关注公众号</div> |
| 66 | - <van-image width="100%" fit="cover" :src="qr_url" /> | 66 | + <van-image @touchstart="onTap" width="100%" fit="cover" :src="qr_url" /> |
| 67 | <div style="text-align: center; margin-bottom: 0.5rem; font-size: 0.85rem;">长按识别二维码</div> | 67 | <div style="text-align: center; margin-bottom: 0.5rem; font-size: 0.85rem;">长按识别二维码</div> |
| 68 | </div> | 68 | </div> |
| 69 | </div> | 69 | </div> |
| ... | @@ -87,8 +87,9 @@ import { useRoute } from "vue-router"; | ... | @@ -87,8 +87,9 @@ import { useRoute } from "vue-router"; |
| 87 | import { queryFormAPI } from "@/api/form.js"; | 87 | import { queryFormAPI } from "@/api/form.js"; |
| 88 | import { addFormDataAPI } from "@/api/data.js"; | 88 | import { addFormDataAPI } from "@/api/data.js"; |
| 89 | import { showSuccessToast, showFailToast } from "vant"; | 89 | import { showSuccessToast, showFailToast } from "vant"; |
| 90 | -import { wxInfo } from "@/utils/tools"; | 90 | +import { wxInfo, getUrlParams } from "@/utils/tools"; |
| 91 | import { styleColor } from "@/constant.js"; | 91 | import { styleColor } from "@/constant.js"; |
| 92 | +import { getFormSettingAPI } from "@/api/form.js"; | ||
| 92 | 93 | ||
| 93 | const store = mainStore(); | 94 | const store = mainStore(); |
| 94 | // 获取表单设置 | 95 | // 获取表单设置 |
| ... | @@ -250,14 +251,48 @@ onMounted(async () => { | ... | @@ -250,14 +251,48 @@ onMounted(async () => { |
| 250 | // 过期时间显示 | 251 | // 过期时间显示 |
| 251 | notice_text.value = `表单报名将在 ${formSetting.value.sjsj_end_time} 后结束`; | 252 | notice_text.value = `表单报名将在 ${formSetting.value.sjsj_end_time} 后结束`; |
| 252 | // 判断是否需要关注公众号, 弹出二维码识别 | 253 | // 判断是否需要关注公众号, 弹出二维码识别 |
| 253 | - if (formSetting.value.wxzq_must_follow) { | 254 | + if (formSetting.value.wxzq_must_follow && !formSetting.value.x_field_weixin_subscribe) { |
| 254 | - // wxzq_mp_qrcode | ||
| 255 | show.value = true; | 255 | show.value = true; |
| 256 | - // qr_url.value = "http://gyzs.onwall.cn/gzs-img-6.png"; | ||
| 257 | qr_url.value = formSetting.value.wxzq_mp_qrcode; | 256 | qr_url.value = formSetting.value.wxzq_mp_qrcode; |
| 257 | + // 标记用户还未关注 | ||
| 258 | + localStorage.setItem('weixin_subscribe', 0); | ||
| 258 | } | 259 | } |
| 259 | }); | 260 | }); |
| 260 | 261 | ||
| 262 | +const onTap = () => { | ||
| 263 | + // 打开轮询用户是否关注 | ||
| 264 | + if (localStorage.getItem('weixin_subscribe') === '0') { | ||
| 265 | + setInterval(() => { | ||
| 266 | + checkUserSubscribe() | ||
| 267 | + }, 1000); | ||
| 268 | + } | ||
| 269 | +} | ||
| 270 | + | ||
| 271 | +const checkUserSubscribe = async () => { | ||
| 272 | + // 数据收集设置 | ||
| 273 | + const code = getUrlParams(location.href) ? getUrlParams(location.href).code : ''; | ||
| 274 | + const { data } = await getFormSettingAPI({ form_code: code }); | ||
| 275 | + const form_setting = {}; | ||
| 276 | + if (data.length) { | ||
| 277 | + data[0].property_list.forEach((prop) => { | ||
| 278 | + const key = prop["property_code"]; | ||
| 279 | + const obj = { | ||
| 280 | + [key]: | ||
| 281 | + prop["setting_value"].length > 1 | ||
| 282 | + ? prop["setting_value"] | ||
| 283 | + : prop["setting_value"][0], | ||
| 284 | + }; | ||
| 285 | + Object.assign(form_setting, obj, data[0]['extend']); | ||
| 286 | + }); | ||
| 287 | + } | ||
| 288 | + // 判断是否需要关注公众号, 弹出二维码识别 | ||
| 289 | + if (form_setting.wxzq_must_follow && form_setting.x_field_weixin_subscribe) { | ||
| 290 | + // 标记用户已关注 | ||
| 291 | + localStorage.setItem('weixin_subscribe', 1); | ||
| 292 | + show.value = false; | ||
| 293 | + } | ||
| 294 | +} | ||
| 295 | + | ||
| 261 | const show = ref(false); | 296 | const show = ref(false); |
| 262 | const qr_url = ref(""); | 297 | const qr_url = ref(""); |
| 263 | const onClose = () => { | 298 | const onClose = () => { | ... | ... |
-
Please register or login to post a comment