hookehuyr

h5和小程序获取表单配置调整

/*
* @Date: 2023-03-23 11:17:54
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-03-24 13:13:44
* @LastEditTime: 2023-03-24 16:01:10
* @FilePath: /custom_form/src/app.config.js
* @Description: 文件描述
*/
......
/*
* @Date: 2023-03-23 11:17:54
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-03-24 14:14:27
* @LastEditTime: 2023-03-24 16:04:21
* @FilePath: /custom_form/src/app.js
* @Description: 文件描述
*/
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import './app.less'
import { mainStore } from '@/stores'
import { getFormSettingAPI } from '@/api/form.js'
import { getUrlParams } from '@/utils/tools'
const App = createApp({
// 可以使用所有的 Vue 生命周期方法
mounted() {
async mounted() {
if (process.env.TARO_ENV === 'h5') {
const code = getUrlParams(location.href)
? getUrlParams(location.href).code
: ''
const store = mainStore();
// 数据收集设置
const { data } = await getFormSettingAPI({ form_code: code });
const form_setting = {};
if (data.length) {
Object.assign(form_setting, data[0]['property_list'], data[0]['extend']);
}
// 缓存表单设置
store.changeFormSetting(form_setting);
}
},
// 对应 onLaunch
......
......@@ -8,15 +8,15 @@
<script setup>
import { ref, computed, watchEffect, onMounted } from "vue";
import Taro from '@tarojs/taro'
import { mainStore } from '@/stores'
import { wxInfo, getUrlParams } from "@/utils/tools";
// 初始化WX环境
import wx from 'weixin-js-sdk'
import { wxJsAPI } from '@/api/wx/config'
import { apiList } from '@/api/wx/jsApiList.js'
import { styleColor } from "@/constant.js";
import { getFormSettingAPI } from "@/api/form.js";
import { mainStore } from '@/stores'
import { getFormSettingAPI } from '@/api/form.js'
import Taro from '@tarojs/taro'
// TAG: 自定义主题颜色
const themeVars = {
......@@ -37,7 +37,6 @@ const onOk = () => {
onMounted(async () => {
const store = mainStore();
const raw_url = encodeURIComponent(location.pathname + location.hash);
// 数据收集设置
const { data } = await getFormSettingAPI({ form_code: code });
const form_setting = {};
......@@ -46,6 +45,8 @@ onMounted(async () => {
}
// 缓存表单设置
store.changeFormSetting(form_setting);
const raw_url = encodeURIComponent(location.pathname + location.hash);
// 没有授权判断
const no_auth_info = form_setting.wxzq_enable && !form_setting.x_field_weixin_openid;
const no_preview_model = model !== 'preview';
......
<!--
* @Date: 2023-03-24 09:19:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-03-24 15:19:34
* @FilePath: /custom_form/src/pages/table/index.vue
* @LastEditTime: 2023-03-24 15:55:18
* @FilePath: /custom_form/src/pages/index/index.vue
* @Description: 文件描述
-->
<template>
......@@ -13,7 +13,7 @@
</template>
<script setup>
import Taro from '@tarojs/taro'
import Taro, { useLoad } from '@tarojs/taro'
import { $ } from '@tarojs/extend'
import { createComponentType } from "@/hooks/useComponentType";
import { ref, computed, watchEffect, onMounted } from "vue";
......@@ -125,6 +125,7 @@ onMounted(async () => {
// TAG: 全局背景色
$('body').css('background-color', styleColor.backgroundColor)
const { data } = await queryFormAPI({ form_code });
const form_data = data;
// 动态修改标题
Taro.setNavigationBarTitle({
......