diff --git a/common/js/uniapp.utils.js b/common/js/uniapp.utils.js new file mode 100644 index 0000000..e450d28 --- /dev/null +++ b/common/js/uniapp.utils.js @@ -0,0 +1,89 @@ +/** + * 将常用的Uniapp提供的函数,存放到这里,按需引用 + */ + + +/** + * 显示错误信息 + * @param {Exception} err + */ +const showError = (err) => { + uni.showToast({ + title: err?.message || err?.errMsg || err?.toString(), + icon: 'none', + duration: 2000 + }); +} + +/** + * 打电话 + * @param {string} mobile 电话号码 + */ +export const makePhoneCall = (mobile) => { + try { + uni.makePhoneCall({ + phoneNumber: `${mobile}`, + success(e) { + console.log(e); + } + }); + } catch (err) { + showError(err); + } +} + +/** + * 拷贝文本 + * @param {*} text + * @param {*} options + */ +export const copyText = (text, { copySuccess = '', copyFailed = '' } = {}) => { + try { + console.log('copyText'); + uni.setClipboardData({ + data: `${text}`, + success: () => { + console.error('复制成功'); + try { + uni.showToast({ + title: copySuccess, + icon: 'success', + duration: 2000 + }); + } catch (e) { + showError(e); + } + }, + fail: (err) => { + console.error('复制失败:', err); + try { + uni.showToast({ + title: err.message || err.errMsg || copyFailed, + icon: 'none', + duration: 2000 + }); + } catch (e) { + showError(e); + } + } + }); + } catch (err) { + showError(err); + } +} + +/** + * 打开定位 + * @param {Object} options + */ +export const openLocation = ({ latitude, longitude, name } = {}) => { + try { + uni.openLocation({ + latitude, + longitude, + name, + }); + } catch (err) { + showError(err); + } +} \ No newline at end of file diff --git a/components-diy/diy-kefu.vue b/components-diy/diy-kefu.vue index 4a631a4..7f68ecd 100644 --- a/components-diy/diy-kefu.vue +++ b/components-diy/diy-kefu.vue @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/components/ns-goods-promotion/ns-goods-promotion.vue b/pages_goods/_components/ns-goods-promotion/ns-goods-promotion.vue similarity index 100% rename from components/ns-goods-promotion/ns-goods-promotion.vue rename to pages_goods/_components/ns-goods-promotion/ns-goods-promotion.vue diff --git a/components/pengpai-fadein-out/pengpai-fadein-out.vue b/pages_goods/_components/pengpai-fadein-out/pengpai-fadein-out.vue similarity index 100% rename from components/pengpai-fadein-out/pengpai-fadein-out.vue rename to pages_goods/_components/pengpai-fadein-out/pengpai-fadein-out.vue diff --git a/pages_goods/detail.vue b/pages_goods/detail.vue index 2328b31..5e7d1f1 100644 --- a/pages_goods/detail.vue +++ b/pages_goods/detail.vue @@ -519,12 +519,19 @@ - \ No newline at end of file diff --git a/pages_tool/form/formdata.vue b/pages_tool/form/formdata.vue index 7743cc8..db3deb7 100644 --- a/pages_tool/form/formdata.vue +++ b/pages_tool/form/formdata.vue @@ -20,7 +20,13 @@ \ No newline at end of file diff --git a/pages_tool/member/pay_password.vue b/pages_tool/member/pay_password.vue index 233fd4a..0511b4b 100644 --- a/pages_tool/member/pay_password.vue +++ b/pages_tool/member/pay_password.vue @@ -16,7 +16,11 @@ \ No newline at end of file