Showing
2 changed files
with
17 additions
and
25 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2022-04-18 15:59:42 | 2 | * @Date: 2022-04-18 15:59:42 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-02-16 10:01:56 | 4 | + * @LastEditTime: 2023-03-03 10:10:27 |
| 5 | * @FilePath: /data-table/src/store/index.js | 5 | * @FilePath: /data-table/src/store/index.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -24,6 +24,7 @@ export const mainStore = defineStore('main', { | ... | @@ -24,6 +24,7 @@ export const mainStore = defineStore('main', { |
| 24 | scrollTopPerson: 0, | 24 | scrollTopPerson: 0, |
| 25 | keepPages: ['default'], // 很坑爹,空值全部都缓存 | 25 | keepPages: ['default'], // 很坑爹,空值全部都缓存 |
| 26 | fieldName: '', | 26 | fieldName: '', |
| 27 | + formInfo: {}, // 表单字段信息 | ||
| 27 | formSetting: {}, // 表单数据收集设置 | 28 | formSetting: {}, // 表单数据收集设置 |
| 28 | successInfo: {}, // 表单提交返回值 | 29 | successInfo: {}, // 表单提交返回值 |
| 29 | }; | 30 | }; |
| ... | @@ -74,6 +75,9 @@ export const mainStore = defineStore('main', { | ... | @@ -74,6 +75,9 @@ export const mainStore = defineStore('main', { |
| 74 | changeFieldName (v) { | 75 | changeFieldName (v) { |
| 75 | this.fieldName = v; | 76 | this.fieldName = v; |
| 76 | }, | 77 | }, |
| 78 | + changeFormInfo (v) { | ||
| 79 | + this.formInfo = v; | ||
| 80 | + }, | ||
| 77 | changeFormSetting (v) { | 81 | changeFormSetting (v) { |
| 78 | this.formSetting = v; | 82 | this.formSetting = v; |
| 79 | }, | 83 | }, | ... | ... |
| 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: 2023-03-03 09:47:53 | 4 | + * @LastEditTime: 2023-03-03 10:14:40 |
| 5 | * @FilePath: /data-table/src/views/index.vue | 5 | * @FilePath: /data-table/src/views/index.vue |
| 6 | * @Description: 首页 | 6 | * @Description: 首页 |
| 7 | --> | 7 | --> |
| ... | @@ -93,7 +93,7 @@ import { | ... | @@ -93,7 +93,7 @@ import { |
| 93 | useTitle, | 93 | useTitle, |
| 94 | } from "@/utils/generatePackage.js"; | 94 | } from "@/utils/generatePackage.js"; |
| 95 | import { useRoute } from "vue-router"; | 95 | import { useRoute } from "vue-router"; |
| 96 | -import { queryFormAPI, getFormSettingAPI, postVerifyPasswordAPI } from "@/api/form.js"; | 96 | +import { queryFormAPI, postVerifyPasswordAPI } from "@/api/form.js"; |
| 97 | import { addFormDataAPI } from "@/api/data.js"; | 97 | import { addFormDataAPI } from "@/api/data.js"; |
| 98 | import { showSuccessToast, showFailToast } from "vant"; | 98 | import { showSuccessToast, showFailToast } from "vant"; |
| 99 | import { wxInfo, getUrlParams } from "@/utils/tools"; | 99 | import { wxInfo, getUrlParams } from "@/utils/tools"; |
| ... | @@ -103,7 +103,7 @@ import wx from 'weixin-js-sdk' | ... | @@ -103,7 +103,7 @@ import wx from 'weixin-js-sdk' |
| 103 | 103 | ||
| 104 | // 获取表单设置 | 104 | // 获取表单设置 |
| 105 | const store = mainStore(); | 105 | const store = mainStore(); |
| 106 | -const { formSetting } = storeToRefs(store); | 106 | +const { formSetting, formInfo } = storeToRefs(store); |
| 107 | // web端判断封面图片高度 | 107 | // web端判断封面图片高度 |
| 108 | const is_pc = computed(() => wxInfo().isPC); | 108 | const is_pc = computed(() => wxInfo().isPC); |
| 109 | const PHeaderHeight = computed(() => { | 109 | const PHeaderHeight = computed(() => { |
| ... | @@ -202,6 +202,8 @@ onMounted(async () => { | ... | @@ -202,6 +202,8 @@ onMounted(async () => { |
| 202 | .setAttribute("style", `background-color: ${styleColor.backgroundColor}`); | 202 | .setAttribute("style", `background-color: ${styleColor.backgroundColor}`); |
| 203 | const { data } = await queryFormAPI({ form_code: $route.query.code }); | 203 | const { data } = await queryFormAPI({ form_code: $route.query.code }); |
| 204 | const form_data = data; | 204 | const form_data = data; |
| 205 | + // 缓存表单信息 | ||
| 206 | + store.changeFormInfo(data); | ||
| 205 | // 表单网页标题 | 207 | // 表单网页标题 |
| 206 | useTitle(form_data.name); | 208 | useTitle(form_data.name); |
| 207 | form_name.value = form_data.name; | 209 | form_name.value = form_data.name; |
| ... | @@ -299,21 +301,15 @@ const onTap = () => { | ... | @@ -299,21 +301,15 @@ const onTap = () => { |
| 299 | } | 301 | } |
| 300 | 302 | ||
| 301 | // 检查数据收集设置 | 303 | // 检查数据收集设置 |
| 302 | -const checkUserSubscribe = async () => { | 304 | +const checkUserSubscribe = () => { |
| 303 | - const code = getUrlParams(location.href) ? getUrlParams(location.href).code : ''; | ||
| 304 | - const { data } = await getFormSettingAPI({ form_code: code }); | ||
| 305 | - const form_setting = {}; | ||
| 306 | - if (data.length) { | ||
| 307 | - Object.assign(form_setting, data[0]['property_list'], data[0]['extend']); | ||
| 308 | - } | ||
| 309 | // 判断是否需要关注公众号, 弹出二维码识别 | 305 | // 判断是否需要关注公众号, 弹出二维码识别 |
| 310 | - if (form_setting.wxzq_must_follow && form_setting.x_field_weixin_subscribe) { | 306 | + if (formSetting.value.wxzq_must_follow && formSetting.value.x_field_weixin_subscribe) { |
| 311 | // 标记用户已关注 | 307 | // 标记用户已关注 |
| 312 | localStorage.setItem('weixin_subscribe', 1); | 308 | localStorage.setItem('weixin_subscribe', 1); |
| 313 | show.value = false; | 309 | show.value = false; |
| 314 | } | 310 | } |
| 315 | // 凭密码填写设置 | 311 | // 凭密码填写设置 |
| 316 | - if (form_setting.mmtx_enable) { | 312 | + if (formSetting.value.mmtx_enable) { |
| 317 | pwd_show.value = true; | 313 | pwd_show.value = true; |
| 318 | } else { | 314 | } else { |
| 319 | pwd_show.value = false; | 315 | pwd_show.value = false; |
| ... | @@ -321,15 +317,9 @@ const checkUserSubscribe = async () => { | ... | @@ -321,15 +317,9 @@ const checkUserSubscribe = async () => { |
| 321 | } | 317 | } |
| 322 | 318 | ||
| 323 | // 检查密码验证功能 | 319 | // 检查密码验证功能 |
| 324 | -const checkUserPassword = async () => { | 320 | +const checkUserPassword = () => { |
| 325 | - const code = getUrlParams(location.href) ? getUrlParams(location.href).code : ''; | ||
| 326 | - const { data } = await getFormSettingAPI({ form_code: code }); | ||
| 327 | - const form_setting = {}; | ||
| 328 | - if (data.length) { | ||
| 329 | - Object.assign(form_setting, data[0]['property_list'], data[0]['extend']); | ||
| 330 | - } | ||
| 331 | // 凭密码填写设置 | 321 | // 凭密码填写设置 |
| 332 | - if (form_setting.mmtx_enable) { | 322 | + if (formSetting.value.mmtx_enable) { |
| 333 | pwd_show.value = true; | 323 | pwd_show.value = true; |
| 334 | } else { | 324 | } else { |
| 335 | pwd_show.value = false; | 325 | pwd_show.value = false; |
| ... | @@ -337,10 +327,8 @@ const checkUserPassword = async () => { | ... | @@ -337,10 +327,8 @@ const checkUserPassword = async () => { |
| 337 | } | 327 | } |
| 338 | 328 | ||
| 339 | // 根据规则隐藏相应字段 | 329 | // 根据规则隐藏相应字段 |
| 340 | -const checkRules = async () => { | 330 | +const checkRules = () => { |
| 341 | - // 数据收集设置 | 331 | + const rule_list = [...formInfo.value['rule_list']]; |
| 342 | - const { data } = await queryFormAPI({ form_code: $route.query.code }); | ||
| 343 | - const rule_list = [...data['rule_list']]; | ||
| 344 | formData.value.forEach(item => { | 332 | formData.value.forEach(item => { |
| 345 | // 给受作用的字段绑定判断规则 | 333 | // 给受作用的字段绑定判断规则 |
| 346 | // 规则失效需要踢出 | 334 | // 规则失效需要踢出 | ... | ... |
-
Please register or login to post a comment