Showing
2 changed files
with
33 additions
and
51 deletions
| ... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
| 2 | * @Author: hookehuyr hookehuyr@gmail.com | 2 | * @Author: hookehuyr hookehuyr@gmail.com |
| 3 | * @Date: 2022-05-26 23:52:36 | 3 | * @Date: 2022-05-26 23:52:36 |
| 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 4 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 5 | - * @LastEditTime: 2023-02-24 16:09:01 | 5 | + * @LastEditTime: 2023-03-01 15:45:20 |
| 6 | * @FilePath: /data-table/src/App.vue | 6 | * @FilePath: /data-table/src/App.vue |
| 7 | * @Description: | 7 | * @Description: |
| 8 | --> | 8 | --> |
| ... | @@ -27,7 +27,7 @@ import vConsole from "@/utils/vconsole"; | ... | @@ -27,7 +27,7 @@ import vConsole from "@/utils/vconsole"; |
| 27 | import wx from 'weixin-js-sdk' | 27 | import wx from 'weixin-js-sdk' |
| 28 | import { wxJsAPI } from '@/api/wx/config' | 28 | import { wxJsAPI } from '@/api/wx/config' |
| 29 | import { apiList } from '@/api/wx/jsApiList.js' | 29 | import { apiList } from '@/api/wx/jsApiList.js' |
| 30 | -import { wxInfo, getUrlParams } from "@/utils/tools"; | 30 | +import { wxInfo, getUrlParams, stringifyQuery } from "@/utils/tools"; |
| 31 | import { styleColor } from "@/constant.js"; | 31 | import { styleColor } from "@/constant.js"; |
| 32 | import { getFormSettingAPI } from "@/api/form.js"; | 32 | import { getFormSettingAPI } from "@/api/form.js"; |
| 33 | 33 | ||
| ... | @@ -61,45 +61,9 @@ watch( | ... | @@ -61,45 +61,9 @@ watch( |
| 61 | // web端判断 | 61 | // web端判断 |
| 62 | const is_pc = computed(() => wxInfo().isPC); | 62 | const is_pc = computed(() => wxInfo().isPC); |
| 63 | 63 | ||
| 64 | -// const stringify = (params) => { | ||
| 65 | -// const queryString = [] | ||
| 66 | -// Object.keys(params || {}).forEach(k => { | ||
| 67 | -// queryString.push(k + '=' + params[k]) | ||
| 68 | -// }) | ||
| 69 | - | ||
| 70 | -// return '?' + queryString.join('&') | ||
| 71 | -// } | ||
| 72 | - | ||
| 73 | onMounted(async () => { | 64 | onMounted(async () => { |
| 74 | const code = getUrlParams(location.href) ? getUrlParams(location.href).code : ''; | 65 | const code = getUrlParams(location.href) ? getUrlParams(location.href).code : ''; |
| 75 | - // const raw_url = encodeURIComponent(location.origin + location.pathname + stringify($route.query)); // 未授权的地址 | 66 | + const raw_url = encodeURIComponent(location.pathname + location.hash); |
| 76 | - // const wxJs = await wxJsAPI({ form_code: code, url: raw_url }); | ||
| 77 | - // wxJs.data.jsApiList = apiList; | ||
| 78 | - // wx.config(wxJs.data); | ||
| 79 | - // wx.ready(() => { | ||
| 80 | - // wx.scanQRCode({ | ||
| 81 | - // needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果, | ||
| 82 | - // scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有 | ||
| 83 | - // success: function (res) { | ||
| 84 | - // if (res.errMsg === 'scanQRCode:ok') { | ||
| 85 | - // let code = res.resultStr; | ||
| 86 | - // let code_arr = code.split(","); | ||
| 87 | - // console.warn(code_arr); | ||
| 88 | - // } else { | ||
| 89 | - // console.warn('扫描失败'); | ||
| 90 | - // } | ||
| 91 | - // }, | ||
| 92 | - // error: function (res) { | ||
| 93 | - // if (res.errMsg.indexOf('function_not_exist') > 0) { | ||
| 94 | - // alert('版本过低请升级') | ||
| 95 | - // } | ||
| 96 | - // alert(res.errMsg); | ||
| 97 | - // }, | ||
| 98 | - // }); | ||
| 99 | - // }); | ||
| 100 | - // wx.error((err) => { | ||
| 101 | - // console.warn(err); | ||
| 102 | - // }); | ||
| 103 | // 数据收集设置 | 67 | // 数据收集设置 |
| 104 | const { data } = await getFormSettingAPI({ form_code: code }); | 68 | const { data } = await getFormSettingAPI({ form_code: code }); |
| 105 | const form_setting = {}; | 69 | const form_setting = {}; |
| ... | @@ -135,6 +99,18 @@ onMounted(async () => { | ... | @@ -135,6 +99,18 @@ onMounted(async () => { |
| 135 | } | 99 | } |
| 136 | } | 100 | } |
| 137 | } | 101 | } |
| 102 | + // 微信分享打开并且openid存在时,开启wx授权功能 | ||
| 103 | + if (form_setting.wxzq_enable && form_setting.x_field_weixin_openid) { | ||
| 104 | + const wxJs = await wxJsAPI({ form_code: code, url: raw_url }); | ||
| 105 | + wxJs.data.jsApiList = apiList; | ||
| 106 | + wx.config(wxJs.data); | ||
| 107 | + wx.ready(() => { | ||
| 108 | + wx.showAllNonBaseMenuItem(); | ||
| 109 | + }); | ||
| 110 | + wx.error((err) => { | ||
| 111 | + console.warn(err); | ||
| 112 | + }); | ||
| 113 | + } | ||
| 138 | }); | 114 | }); |
| 139 | </script> | 115 | </script> |
| 140 | 116 | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-08-29 14:31:20 | 2 | * @Date: 2022-08-29 14:31:20 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-02-24 16:47:46 | 4 | + * @LastEditTime: 2023-03-01 16:09:00 |
| 5 | * @FilePath: /data-table/src/components/TextField/index.vue | 5 | * @FilePath: /data-table/src/components/TextField/index.vue |
| 6 | * @Description: 单行文本输入框 | 6 | * @Description: 单行文本输入框 |
| 7 | --> | 7 | --> |
| ... | @@ -39,25 +39,34 @@ const HideShow = computed(() => { | ... | @@ -39,25 +39,34 @@ const HideShow = computed(() => { |
| 39 | }) | 39 | }) |
| 40 | 40 | ||
| 41 | const $route = useRoute(); | 41 | const $route = useRoute(); |
| 42 | +// TODO: 等待真实数据进行判断,默认条形码识别 | ||
| 42 | const test = $route.query.test; | 43 | const test = $route.query.test; |
| 44 | +const scan_type_code = ref(2); | ||
| 45 | +const scanType = (scan_type_code) => { | ||
| 46 | + switch (scan_type_code) { | ||
| 47 | + case 0: | ||
| 48 | + return ["qrCode", "barCode"] | ||
| 49 | + case 1: | ||
| 50 | + return ["qrCode"] | ||
| 51 | + case 2: | ||
| 52 | + return ["barCode"] | ||
| 53 | + } | ||
| 54 | +} | ||
| 43 | 55 | ||
| 44 | const clickRightIcon = async () => { | 56 | const clickRightIcon = async () => { |
| 45 | - const code = getUrlParams(location.href) ? getUrlParams(location.href).code : ''; | ||
| 46 | - const raw_url = encodeURIComponent(location.pathname + stringifyQuery($route.query)); // 未授权的地址 | ||
| 47 | - const wxJs = await wxJsAPI({ form_code: code, url: raw_url }); | ||
| 48 | - wxJs.data.jsApiList = apiList; | ||
| 49 | - wx.config(wxJs.data); | ||
| 50 | wx.ready(() => { | 57 | wx.ready(() => { |
| 51 | wx.scanQRCode({ | 58 | wx.scanQRCode({ |
| 52 | needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果, | 59 | needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果, |
| 53 | - scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有 | 60 | + scanType: scanType(scan_type_code.value), // 可以指定扫二维码还是一维码,默认二者都有 |
| 54 | success: function (res) { | 61 | success: function (res) { |
| 55 | if (res.errMsg === 'scanQRCode:ok') { | 62 | if (res.errMsg === 'scanQRCode:ok') { |
| 56 | let code = res.resultStr; | 63 | let code = res.resultStr; |
| 57 | let code_arr = code.split(","); | 64 | let code_arr = code.split(","); |
| 58 | - console.warn(code_arr); | 65 | + props.item.value = code_arr[1]; |
| 66 | + showSuccessToast('扫描成功') | ||
| 59 | } else { | 67 | } else { |
| 60 | - console.warn('扫描失败'); | 68 | + console.warn(res); |
| 69 | + showFailToast('扫描失败') | ||
| 61 | } | 70 | } |
| 62 | }, | 71 | }, |
| 63 | error: function (res) { | 72 | error: function (res) { |
| ... | @@ -68,9 +77,6 @@ const clickRightIcon = async () => { | ... | @@ -68,9 +77,6 @@ const clickRightIcon = async () => { |
| 68 | }, | 77 | }, |
| 69 | }); | 78 | }); |
| 70 | }); | 79 | }); |
| 71 | - wx.error((err) => { | ||
| 72 | - console.warn(err); | ||
| 73 | - }); | ||
| 74 | } | 80 | } |
| 75 | </script> | 81 | </script> |
| 76 | 82 | ... | ... |
-
Please register or login to post a comment