Showing
3 changed files
with
59 additions
and
11 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 15:17:24 | 5 | + * @LastEditTime: 2023-02-24 16:09:01 |
| 6 | * @FilePath: /data-table/src/App.vue | 6 | * @FilePath: /data-table/src/App.vue |
| 7 | * @Description: | 7 | * @Description: |
| 8 | --> | 8 | --> |
| ... | @@ -24,9 +24,9 @@ import { Toast } from "vant"; | ... | @@ -24,9 +24,9 @@ import { Toast } from "vant"; |
| 24 | // eslint-disable-next-line no-unused-vars | 24 | // eslint-disable-next-line no-unused-vars |
| 25 | import vConsole from "@/utils/vconsole"; | 25 | import vConsole from "@/utils/vconsole"; |
| 26 | // 初始化WX环境 | 26 | // 初始化WX环境 |
| 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 } 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"; |
| ... | @@ -61,13 +61,41 @@ watch( | ... | @@ -61,13 +61,41 @@ 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 | + | ||
| 64 | onMounted(async () => { | 73 | onMounted(async () => { |
| 65 | const code = getUrlParams(location.href) ? getUrlParams(location.href).code : ''; | 74 | const code = getUrlParams(location.href) ? getUrlParams(location.href).code : ''; |
| 66 | - // const wxJs = await wxJsAPI({ form_code: code }); | 75 | + // const raw_url = encodeURIComponent(location.origin + location.pathname + stringify($route.query)); // 未授权的地址 |
| 76 | + // const wxJs = await wxJsAPI({ form_code: code, url: raw_url }); | ||
| 67 | // wxJs.data.jsApiList = apiList; | 77 | // wxJs.data.jsApiList = apiList; |
| 68 | // wx.config(wxJs.data); | 78 | // wx.config(wxJs.data); |
| 69 | // wx.ready(() => { | 79 | // wx.ready(() => { |
| 70 | - // wx.showAllNonBaseMenuItem(); | 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 | + // }); | ||
| 71 | // }); | 99 | // }); |
| 72 | // wx.error((err) => { | 100 | // wx.error((err) => { |
| 73 | // console.warn(err); | 101 | // console.warn(err); | ... | ... |
| 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 15:14:35 | 4 | + * @LastEditTime: 2023-02-24 16:47:46 |
| 5 | * @FilePath: /data-table/src/components/TextField/index.vue | 5 | * @FilePath: /data-table/src/components/TextField/index.vue |
| 6 | * @Description: 单行文本输入框 | 6 | * @Description: 单行文本输入框 |
| 7 | --> | 7 | --> |
| ... | @@ -28,7 +28,7 @@ import { showSuccessToast, showFailToast } from 'vant'; | ... | @@ -28,7 +28,7 @@ import { showSuccessToast, showFailToast } from 'vant'; |
| 28 | import wx from 'weixin-js-sdk' | 28 | import wx from 'weixin-js-sdk' |
| 29 | import { wxJsAPI } from '@/api/wx/config' | 29 | import { wxJsAPI } from '@/api/wx/config' |
| 30 | import { apiList } from '@/api/wx/jsApiList.js' | 30 | import { apiList } from '@/api/wx/jsApiList.js' |
| 31 | -import { wxInfo, getUrlParams } from "@/utils/tools"; | 31 | +import { wxInfo, getUrlParams, stringifyQuery } from "@/utils/tools"; |
| 32 | 32 | ||
| 33 | const props = defineProps({ | 33 | const props = defineProps({ |
| 34 | item: Object, | 34 | item: Object, |
| ... | @@ -43,7 +43,8 @@ const test = $route.query.test; | ... | @@ -43,7 +43,8 @@ const test = $route.query.test; |
| 43 | 43 | ||
| 44 | const clickRightIcon = async () => { | 44 | const clickRightIcon = async () => { |
| 45 | const code = getUrlParams(location.href) ? getUrlParams(location.href).code : ''; | 45 | const code = getUrlParams(location.href) ? getUrlParams(location.href).code : ''; |
| 46 | - const wxJs = await wxJsAPI({ form_code: code }); | 46 | + const raw_url = encodeURIComponent(location.pathname + stringifyQuery($route.query)); // 未授权的地址 |
| 47 | + const wxJs = await wxJsAPI({ form_code: code, url: raw_url }); | ||
| 47 | wxJs.data.jsApiList = apiList; | 48 | wxJs.data.jsApiList = apiList; |
| 48 | wx.config(wxJs.data); | 49 | wx.config(wxJs.data); |
| 49 | wx.ready(() => { | 50 | wx.ready(() => { | ... | ... |
| 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-15 18:20:03 | 4 | + * @LastEditTime: 2023-02-24 16:13:06 |
| 5 | * @FilePath: /data-table/src/utils/tools.js | 5 | * @FilePath: /data-table/src/utils/tools.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -115,4 +115,23 @@ const getUrlParams = (url) => { | ... | @@ -115,4 +115,23 @@ const getUrlParams = (url) => { |
| 115 | return items | 115 | return items |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | -export { formatDate, wxInfo, hasEllipsis, parseQueryString, strExist, changeURLArg, getUrlParams }; | 118 | +// 格式化URL参数为字符串 |
| 119 | +const stringifyQuery = (params) => { | ||
| 120 | + const queryString = []; | ||
| 121 | + Object.keys(params || {}).forEach((k) => { | ||
| 122 | + queryString.push(k + '=' + params[k]); | ||
| 123 | + }); | ||
| 124 | + | ||
| 125 | + return '?' + queryString.join('&'); | ||
| 126 | +}; | ||
| 127 | + | ||
| 128 | +export { | ||
| 129 | + formatDate, | ||
| 130 | + wxInfo, | ||
| 131 | + hasEllipsis, | ||
| 132 | + parseQueryString, | ||
| 133 | + strExist, | ||
| 134 | + changeURLArg, | ||
| 135 | + getUrlParams, | ||
| 136 | + stringifyQuery, | ||
| 137 | +}; | ... | ... |
-
Please register or login to post a comment