hookehuyr

配置pinia获取数据成功

...@@ -7,10 +7,8 @@ export {} ...@@ -7,10 +7,8 @@ export {}
7 7
8 declare module '@vue/runtime-core' { 8 declare module '@vue/runtime-core' {
9 export interface GlobalComponents { 9 export interface GlobalComponents {
10 - NutCol: typeof import('@nutui/nutui-taro')['Col']
11 NutConfigProvider: typeof import('@nutui/nutui-taro')['ConfigProvider'] 10 NutConfigProvider: typeof import('@nutui/nutui-taro')['ConfigProvider']
12 NutDialog: typeof import('@nutui/nutui-taro')['Dialog'] 11 NutDialog: typeof import('@nutui/nutui-taro')['Dialog']
13 - NutRow: typeof import('@nutui/nutui-taro')['Row']
14 RouterLink: typeof import('vue-router')['RouterLink'] 12 RouterLink: typeof import('vue-router')['RouterLink']
15 RouterView: typeof import('vue-router')['RouterView'] 13 RouterView: typeof import('vue-router')['RouterView']
16 } 14 }
......
1 /* 1 /*
2 * @Date: 2023-03-23 11:17:54 2 * @Date: 2023-03-23 11:17:54
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-03-24 10:59:28 4 + * @LastEditTime: 2023-03-24 13:49:26
5 * @FilePath: /custom_form/config/index.js 5 * @FilePath: /custom_form/config/index.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -47,6 +47,7 @@ const config = { ...@@ -47,6 +47,7 @@ const config = {
47 sourceRoot: 'src', 47 sourceRoot: 'src',
48 outputRoot: `dist/${process.env.TARO_ENV}`, 48 outputRoot: `dist/${process.env.TARO_ENV}`,
49 plugins: [ 49 plugins: [
50 + 'taro-plugin-pinia',
50 '@tarojs/plugin-html', 51 '@tarojs/plugin-html',
51 [ 52 [
52 '@tarojs/plugin-http', 53 '@tarojs/plugin-http',
......
...@@ -56,7 +56,8 @@ ...@@ -56,7 +56,8 @@
56 "@tarojs/taro": "3.6.2", 56 "@tarojs/taro": "3.6.2",
57 "axios-miniprogram": "^2.0.0-rc-2", 57 "axios-miniprogram": "^2.0.0-rc-2",
58 "dayjs": "^1.11.7", 58 "dayjs": "^1.11.7",
59 - "pinia": "^2.0.33", 59 + "pinia": "2.0.10",
60 + "taro-plugin-pinia": "^1.0.0",
60 "taro-plugin-style-resource": "^0.1.9", 61 "taro-plugin-style-resource": "^0.1.9",
61 "vue": "^3.0.0", 62 "vue": "^3.0.0",
62 "weixin-js-sdk": "^1.6.0" 63 "weixin-js-sdk": "^1.6.0"
......
1 /* 1 /*
2 * @Date: 2023-03-23 11:17:54 2 * @Date: 2023-03-23 11:17:54
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-03-24 11:26:51 4 + * @LastEditTime: 2023-03-24 13:13:44
5 * @FilePath: /custom_form/src/app.config.js 5 * @FilePath: /custom_form/src/app.config.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
......
1 /* 1 /*
2 * @Date: 2023-03-23 11:17:54 2 * @Date: 2023-03-23 11:17:54
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-03-23 13:47:12 4 + * @LastEditTime: 2023-03-24 14:14:27
5 * @FilePath: /custom_form/src/app.js 5 * @FilePath: /custom_form/src/app.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
...@@ -10,7 +10,31 @@ import { createPinia } from 'pinia' ...@@ -10,7 +10,31 @@ import { createPinia } from 'pinia'
10 import './app.less' 10 import './app.less'
11 11
12 const App = createApp({ 12 const App = createApp({
13 - onShow (options) {}, 13 + // 可以使用所有的 Vue 生命周期方法
14 + mounted() {
15 + },
16 +
17 + // 对应 onLaunch
18 + onLaunch(options) {
19 + // // 未授权状态跳转授权页面,首页不需要权限
20 + // const path = options.path;
21 + // // 缓存没有权限的地址
22 + // const router = routerStore();
23 + // router.add(path);
24 + // if (path !== 'pages/index/index' && !wx.getStorageSync("sessionid")) {
25 + // wx.navigateTo({
26 + // url: './pages/auth/index'
27 + // })
28 + // }
29 + },
30 +
31 + // 对应 onShow
32 + onShow(options) {
33 + },
34 +
35 + // 对应 onHide
36 + onHide() { },
37 +
14 // 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖 38 // 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖
15 }) 39 })
16 40
......
1 +/*
2 + * @Author: hookehuyr hookehuyr@gmail.com
3 + * @Date: 2022-05-17 12:13:13
4 + * @LastEditors: hookehuyr hookehuyr@gmail.com
5 + * @LastEditTime: 2022-07-19 10:33:36
6 + * @FilePath: /front/src/composables/index.js
7 + * @Description:
8 + */
9 +import { onMounted, onUnmounted } from 'vue'
10 +
11 +/**
12 + * 添加和清除 DOM 事件监听器
13 + * @param {*} target
14 + * @param {*} event
15 + * @param {*} callback
16 + */
17 +export function useEventListener(target, event, callback) {
18 + onMounted(() => target?.addEventListener(event, callback))
19 + onUnmounted(() => target?.removeEventListener(event, callback))
20 +}
1 +/*
2 + * @Date: 2022-06-13 17:42:32
3 + * @LastEditors: hookehuyr hookehuyr@gmail.com
4 + * @LastEditTime: 2023-03-03 17:51:55
5 + * @FilePath: /data-table/src/composables/useShare.js
6 + * @Description: 文件描述
7 + */
8 +import wx from 'weixin-js-sdk';
9 +// import { Toast } from 'vant';
10 +
11 +/**
12 + * @description: 微信分享功能
13 + * @param {*} title 标题
14 + * @param {*} desc 描述
15 + * @param {*} imgUrl 图标
16 + * @return {*}
17 + */
18 +export const sharePage = ({title = '自定义表单', desc = '数据收集', imgUrl = ''}) => {
19 + const shareData = {
20 + title, // 分享标题
21 + desc, // 分享描述
22 + link: location.origin + location.pathname + location.hash, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
23 + imgUrl, // 分享图标
24 + success: function () {
25 + console.warn('设置成功');
26 + }
27 + }
28 + // 分享好友(微信好友或qq好友)
29 + // wx.updateAppMessageShareData(shareData);
30 + wx.onMenuShareAppMessage(shareData);
31 + // 分享到朋友圈或qq空间
32 + // wx.updateTimelineShareData(shareData);
33 + wx.onMenuShareTimeline(shareData);
34 + // 分享到腾讯微博
35 + wx.onMenuShareWeibo(shareData);
36 + // // 获取“分享给朋友”按钮点击状态及自定义分享内容接口(即将废弃)
37 + // wx.onMenuShareAppMessage(shareData);
38 + // // 获取“分享到朋友圈”按钮点击状态及自定义分享内容接口(即将废弃)
39 + // wx.onMenuShareTimeline(shareData);
40 + // // 获取“分享到QQ”按钮点击状态及自定义分享内容接口(即将废弃)
41 + // wx.onMenuShareQQ(shareData);
42 +}
...@@ -9,9 +9,6 @@ ...@@ -9,9 +9,6 @@
9 <script setup> 9 <script setup>
10 import { ref, computed, watchEffect, onMounted } from "vue"; 10 import { ref, computed, watchEffect, onMounted } from "vue";
11 import Taro from '@tarojs/taro' 11 import Taro from '@tarojs/taro'
12 -import { useDidShow } from '@tarojs/taro'
13 -import request from '@/utils/request';
14 -import { storeToRefs } from 'pinia'
15 import { mainStore } from '@/stores' 12 import { mainStore } from '@/stores'
16 import { wxInfo, getUrlParams } from "@/utils/tools"; 13 import { wxInfo, getUrlParams } from "@/utils/tools";
17 // 初始化WX环境 14 // 初始化WX环境
...@@ -29,17 +26,20 @@ const themeVars = { ...@@ -29,17 +26,20 @@ const themeVars = {
29 // web端判断 26 // web端判断
30 const is_pc = computed(() => process.env.TARO_ENV === 'h5' && wxInfo().isPC); 27 const is_pc = computed(() => process.env.TARO_ENV === 'h5' && wxInfo().isPC);
31 28
32 -const store = mainStore(); 29 +const code = getUrlParams(location.href) ? getUrlParams(location.href).code : '';
33 -const { formInfo } = storeToRefs(store); 30 +const model = getUrlParams(location.href) ? getUrlParams(location.href).model : '';
34 31
35 const show_reach_sjsj_max_count = ref(false); 32 const show_reach_sjsj_max_count = ref(false);
33 +
36 const onOk = () => { 34 const onOk = () => {
37 show_reach_sjsj_max_count.value = false; 35 show_reach_sjsj_max_count.value = false;
36 + Taro.redirectTo({
37 + url: `../table/index?code=${code}&model=${model}`
38 + })
38 } 39 }
39 40
40 onMounted(async () => { 41 onMounted(async () => {
41 - const code = getUrlParams(location.href) ? getUrlParams(location.href).code : ''; 42 + const store = mainStore();
42 - const model = getUrlParams(location.href) ? getUrlParams(location.href).model : '';
43 const raw_url = encodeURIComponent(location.pathname + location.hash); 43 const raw_url = encodeURIComponent(location.pathname + location.hash);
44 // 数据收集设置 44 // 数据收集设置
45 const { data } = await getFormSettingAPI({ form_code: code }); 45 const { data } = await getFormSettingAPI({ form_code: code });
...@@ -61,13 +61,6 @@ onMounted(async () => { ...@@ -61,13 +61,6 @@ onMounted(async () => {
61 if (process.env.NODE_ENV !== 'development' && no_auth_info && form_setting.wxzq_scope) { 61 if (process.env.NODE_ENV !== 'development' && no_auth_info && form_setting.wxzq_scope) {
62 // 预览模式不开启 62 // 预览模式不开启
63 if (no_preview_model) { 63 if (no_preview_model) {
64 - // $router.replace({
65 - // path: '/auth',
66 - // query: {
67 - // href: location.hash,
68 - // code
69 - // }
70 - // });
71 Taro.redirectTo({ 64 Taro.redirectTo({
72 url: `../auth/index?href=${location.hash}&code=${code}` 65 url: `../auth/index?href=${location.hash}&code=${code}`
73 }) 66 })
...@@ -76,7 +69,6 @@ onMounted(async () => { ...@@ -76,7 +69,6 @@ onMounted(async () => {
76 // 判断跳转页面 69 // 判断跳转页面
77 if (form_setting.sjsj_enable === 0 && !form_setting.sjsj_enable) { 70 if (form_setting.sjsj_enable === 0 && !form_setting.sjsj_enable) {
78 // 表单已结束 71 // 表单已结束
79 - // $router.push("/stop?status=disable");
80 Taro.navigateTo({ 72 Taro.navigateTo({
81 url: '../stop/index?status=disable' 73 url: '../stop/index?status=disable'
82 }) 74 })
...@@ -85,14 +77,12 @@ onMounted(async () => { ...@@ -85,14 +77,12 @@ onMounted(async () => {
85 if (form_setting.sjsj_is_time_range && form_setting.sjsj_is_time_range) { 77 if (form_setting.sjsj_is_time_range && form_setting.sjsj_is_time_range) {
86 // 未开始 78 // 未开始
87 if (form_setting.server_time < form_setting.sjsj_begin_time) { 79 if (form_setting.server_time < form_setting.sjsj_begin_time) {
88 - // $router.push("/stop?status=apply");
89 Taro.navigateTo({ 80 Taro.navigateTo({
90 url: '../stop/index?status=apply' 81 url: '../stop/index?status=apply'
91 }) 82 })
92 } 83 }
93 // 已结束 84 // 已结束
94 if (form_setting.server_time > form_setting.sjsj_end_time) { 85 if (form_setting.server_time > form_setting.sjsj_end_time) {
95 - // $router.push("/stop?status=finish");
96 Taro.navigateTo({ 86 Taro.navigateTo({
97 url: '../stop/index?status=finish' 87 url: '../stop/index?status=finish'
98 }) 88 })
...@@ -112,13 +102,8 @@ onMounted(async () => { ...@@ -112,13 +102,8 @@ onMounted(async () => {
112 } 102 }
113 // 当数据量达到限额时,该表单将不能继续提交数据。 103 // 当数据量达到限额时,该表单将不能继续提交数据。
114 if (form_setting.is_reach_sjsj_max_count) { 104 if (form_setting.is_reach_sjsj_max_count) {
115 - // showDialog({
116 - // title: '温馨提示',
117 - // message: '表单收集量已达到限额,无法再提交数据。',
118 - // theme: 'round-button',
119 - // confirmButtonColor: styleColor.baseColor
120 - // });
121 show_reach_sjsj_max_count.value = true; 105 show_reach_sjsj_max_count.value = true;
106 + return false;
122 } 107 }
123 // 设定填写次数 108 // 设定填写次数
124 if (form_setting.wxzq_scope && no_preview_model) { 109 if (form_setting.wxzq_scope && no_preview_model) {
......
1 <!-- 1 <!--
2 * @Date: 2023-03-24 09:19:27 2 * @Date: 2023-03-24 09:19:27
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-03-24 09:20:19 4 + * @LastEditTime: 2023-03-24 14:21:47
5 * @FilePath: /custom_form/src/pages/table/index.vue 5 * @FilePath: /custom_form/src/pages/table/index.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
8 <template> 8 <template>
9 - <div class=""></div> 9 + <div class="">table</div>
10 </template> 10 </template>
11 11
12 <script setup> 12 <script setup>
13 -import { ref } from 'vue' 13 +import wx from 'weixin-js-sdk'
14 +import { ref, computed } from 'vue'
15 +import _ from "@/utils/lodash";
16 +import { storeToRefs } from 'pinia'
17 +import { mainStore } from '@/stores'
18 +import { queryFormAPI, postVerifyPasswordAPI } from "@/api/form.js";
19 +import { addFormDataAPI } from "@/api/data.js";
20 +import { wxInfo, getUrlParams } from "@/utils/tools";
21 +import { styleColor } from "@/constant.js";
22 +import { sharePage } from '@/composables/useShare.js'
14 23
24 +// // 获取表单设置
25 +const store = mainStore();
26 +const { formSetting, formInfo } = storeToRefs(store);
27 +// web端判断封面图片高度
28 +const is_pc = computed(() => process.env.TARO_ENV === 'h5' && wxInfo().isPC);
29 +const PHeaderHeight = computed(() => {
30 + if (is_pc.value) {
31 + return "35vh";
32 + } else {
33 + return "20vh";
34 + }
35 +});
36 +// TAG: 自定义主题颜色
37 +const themeVars = {
38 + buttonPrimaryBackground: styleColor.baseColor,
39 + buttonPrimaryBorderColor: styleColor.baseColor,
40 +};
15 </script> 41 </script>
16 42
17 <style lang="less" scoped> 43 <style lang="less" scoped>
......
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-03-23 13:19:21 4 + * @LastEditTime: 2023-03-24 14:04:54
5 * @FilePath: /custom_form/src/stores/index.js 5 * @FilePath: /custom_form/src/stores/index.js
6 * @Description: 文件描述 6 * @Description: 文件描述
7 */ 7 */
......
This diff could not be displayed because it is too large.
...@@ -2335,7 +2335,7 @@ ...@@ -2335,7 +2335,7 @@
2335 "@vue/compiler-dom" "3.2.47" 2335 "@vue/compiler-dom" "3.2.47"
2336 "@vue/shared" "3.2.47" 2336 "@vue/shared" "3.2.47"
2337 2337
2338 -"@vue/devtools-api@^6.5.0": 2338 +"@vue/devtools-api@^6.0.0-beta.21":
2339 version "6.5.0" 2339 version "6.5.0"
2340 resolved "https://mirrors.cloud.tencent.com/npm/@vue/devtools-api/-/devtools-api-6.5.0.tgz#98b99425edee70b4c992692628fa1ea2c1e57d07" 2340 resolved "https://mirrors.cloud.tencent.com/npm/@vue/devtools-api/-/devtools-api-6.5.0.tgz#98b99425edee70b4c992692628fa1ea2c1e57d07"
2341 integrity sha512-o9KfBeaBmCKl10usN4crU53fYtC1r7jJwdGKjPT24t348rHxgfpZ0xL3Xm/gLUYnc0oTp8LAmrxOeLyu6tbk2Q== 2341 integrity sha512-o9KfBeaBmCKl10usN4crU53fYtC1r7jJwdGKjPT24t348rHxgfpZ0xL3Xm/gLUYnc0oTp8LAmrxOeLyu6tbk2Q==
...@@ -9792,12 +9792,12 @@ pify@^4.0.1: ...@@ -9792,12 +9792,12 @@ pify@^4.0.1:
9792 resolved "https://mirrors.cloud.tencent.com/npm/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231" 9792 resolved "https://mirrors.cloud.tencent.com/npm/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231"
9793 integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g== 9793 integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==
9794 9794
9795 -pinia@^2.0.33: 9795 +pinia@2.0.10:
9796 - version "2.0.33" 9796 + version "2.0.10"
9797 - resolved "https://mirrors.cloud.tencent.com/npm/pinia/-/pinia-2.0.33.tgz#b70065be697874d5824e9792f59bd5d87ddb5e7d" 9797 + resolved "https://mirrors.cloud.tencent.com/npm/pinia/-/pinia-2.0.10.tgz#66ae65e10d9062d110cb8ce47aedf491b4b131ef"
9798 - integrity sha512-HOj1yVV2itw6rNIrR2f7+MirGNxhORjrULL8GWgRwXsGSvEqIQ+SE0MYt6cwtpegzCda3i+rVTZM+AM7CG+kRg== 9798 + integrity sha512-Gq8qCjWkz1SZSCrHqGg/k+wbeu35R7y44eDXFHJlBr5gZ8ooAf6bAHLt5zpAVIDptv09h0+XLZpy9dMHbwvXWw==
9799 dependencies: 9799 dependencies:
9800 - "@vue/devtools-api" "^6.5.0" 9800 + "@vue/devtools-api" "^6.0.0-beta.21"
9801 vue-demi "*" 9801 vue-demi "*"
9802 9802
9803 pinkie-promise@^2.0.0: 9803 pinkie-promise@^2.0.0:
...@@ -12105,6 +12105,11 @@ taro-css-to-react-native@3.6.2: ...@@ -12105,6 +12105,11 @@ taro-css-to-react-native@3.6.2:
12105 css-mediaquery "^0.1.2" 12105 css-mediaquery "^0.1.2"
12106 postcss-value-parser "^3.3.0" 12106 postcss-value-parser "^3.3.0"
12107 12107
12108 +taro-plugin-pinia@^1.0.0:
12109 + version "1.0.0"
12110 + resolved "https://mirrors.cloud.tencent.com/npm/taro-plugin-pinia/-/taro-plugin-pinia-1.0.0.tgz#7dee620cc84303a4b4c2df50e649bae72c3b6ac0"
12111 + integrity sha512-Ip2LTRh7NGsFyEzkZWvU115xDqV3D8cRRbqqw0JKTvzHFBzpwycmrUVQQxV61AMg0r2RJm3mcEbQ997j7xNjtg==
12112 +
12108 taro-plugin-style-resource@^0.1.9: 12113 taro-plugin-style-resource@^0.1.9:
12109 version "0.1.9" 12114 version "0.1.9"
12110 resolved "https://mirrors.cloud.tencent.com/npm/taro-plugin-style-resource/-/taro-plugin-style-resource-0.1.9.tgz#46448a384a8d96bbe4c363c8bed2d1c5ec031803" 12115 resolved "https://mirrors.cloud.tencent.com/npm/taro-plugin-style-resource/-/taro-plugin-style-resource-0.1.9.tgz#46448a384a8d96bbe4c363c8bed2d1c5ec031803"
......