382941bc by simon

默认提交

1 parent d7a783c4
...@@ -18,15 +18,16 @@ ...@@ -18,15 +18,16 @@
18 "co": "^4.6.0", 18 "co": "^4.6.0",
19 "core-js": "^2.6.5", 19 "core-js": "^2.6.5",
20 "crypto-js": "^4.0.0", 20 "crypto-js": "^4.0.0",
21 "jsencrypt": "^3.0.0-rc.1",
22 "moment": "^2.29.1",
23 "glob": "^7.1.4", 21 "glob": "^7.1.4",
24 "js-cookie": "^2.2.1", 22 "js-cookie": "^2.2.1",
23 "jsencrypt": "^3.0.0-rc.1",
25 "mockjs": "^1.0.1-beta3", 24 "mockjs": "^1.0.1-beta3",
25 "moment": "^2.29.1",
26 "postcss-px2rem": "^0.3.0", 26 "postcss-px2rem": "^0.3.0",
27 "postcss-pxtorem": "^4.0.1", 27 "postcss-pxtorem": "^4.0.1",
28 "sass-resources-loader": "^2.0.3", 28 "sass-resources-loader": "^2.0.3",
29 "vant": "^2.2.11", 29 "vant": "^2.2.11",
30 "vconsole": "^3.15.1",
30 "vue": "^2.6.10", 31 "vue": "^2.6.10",
31 "vue-router": "^3.0.3", 32 "vue-router": "^3.0.3",
32 "vuex": "^3.0.1" 33 "vuex": "^3.0.1"
......
...@@ -4,9 +4,8 @@ ...@@ -4,9 +4,8 @@
4 <head> 4 <head>
5 <meta charset="utf-8"> 5 <meta charset="utf-8">
6 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 6 <meta http-equiv="X-UA-Compatible" content="IE=edge">
7 <!-- <meta name="viewport" content="width=device-width,initial-scale=1.0"> -->
8 <meta name="viewport" 7 <meta name="viewport"
9 content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> 8 content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover" />
10 <link rel="icon" href="<%= BASE_URL %>favicon.ico"> 9 <link rel="icon" href="<%= BASE_URL %>favicon.ico">
11 <!-- <script src="<%= BASE_URL %>static/js/weixin/jweixin-1.6.0.js"></script> 10 <!-- <script src="<%= BASE_URL %>static/js/weixin/jweixin-1.6.0.js"></script>
12 <script src="<%= BASE_URL %>static/js/kd/kd-sdk.1.0.0.js"></script> 11 <script src="<%= BASE_URL %>static/js/kd/kd-sdk.1.0.0.js"></script>
......
1 module.exports = { 1 module.exports = {
2 2
3 login: '/front/userApi/login', // 登录 3 login: '/front/userApi/login', // 登录
4 code2session: "/front/wxApi/code2session", // code2session
4 profile: '/front/userApi/profile', // 个人信息 5 profile: '/front/userApi/profile', // 个人信息
5 uploadProfile: '/front/userApi/uploadProfile', // 更新头像昵称 6 uploadProfile: '/front/userApi/uploadProfile', // 更新头像昵称
6 7
8 oauthLink: "/front/wxApi/oauthLink", // 获取oauth授权地址
9 wxJsSign: "/front/wxApi/jsSign", // 微信jsSign签名接口
10
7 11
8 upload: '/common/upload', // 上传文件 [x] 12 upload: '/common/upload', // 上传文件 [x]
9 list: "xxx", 13 list: "xxx",
......
...@@ -3,6 +3,8 @@ import axios from 'axios'; ...@@ -3,6 +3,8 @@ import axios from 'axios';
3 import { 3 import {
4 Toast 4 Toast
5 } from 'vant'; 5 } from 'vant';
6 Toast.allowMultiple();
7 let loadingToast;
6 8
7 import router from '@/router' 9 import router from '@/router'
8 import { 10 import {
...@@ -21,25 +23,43 @@ import api from '@/api/api'; ...@@ -21,25 +23,43 @@ import api from '@/api/api';
21 // axios的默认url 23 // axios的默认url
22 // axios.defaults.baseURL = "" 24 // axios.defaults.baseURL = ""
23 let base = process.env.VUE_APP_BASE_API; 25 let base = process.env.VUE_APP_BASE_API;
24 const ENV = process.env.VUE_APP_ENV; 26 let MODULE_CODE = process.env.VUE_APP_MODULE_CODE;
25 const MODULE_CODE = process.env.VUE_APP_MODULE_CODE;
26 const IS_POST_ENC = process.env.VUE_APP_IS_POST_ENC; 27 const IS_POST_ENC = process.env.VUE_APP_IS_POST_ENC;
28 let ENV = process.env.VUE_APP_ENV;
29
30 // 配置环境
31 // let host = location.host;
32 if (location.host.indexOf("192.168.") != -1 || location.host.indexOf("172.20.") != -1 || location.host.indexOf('dev.h5.kdao.xin') != -1) {
33 // 测试环境
34 ENV = "demo";
35 } else {
36 // if (location.host.indexOf("prod.h5.kdao.xin") != -1) {
37 // // 恪道正式环境
38 // }
39 }
40
41
27 // 默认超时 42 // 默认超时
28 axios.defaults.timeout = 5000; 43 axios.defaults.timeout = 5000;
29 44
30 45
31 // 请求拦截器 46 // 请求拦截器
32 // axios.interceptors.request.use( 47 axios.interceptors.request.use(
33 // config => { 48 config => {
34 // // 每次发送请求之前判断是否存在token,如果存在,则统一在http请求的header都加上token,不用每次请求都手动添加了 49 let {
35 // // 即使本地存在token,也有可能token是过期的,所以在响应拦截器中要对返回状态进行判断 50 opt
36 // const token = "token"; //这里写入token 51 } = config;
37 // token && (config.headers.Authorization = token); 52 if (opt && opt.loading) {
38 // return config; 53 loadingToast = Toast.loading({
39 // }, 54 message: '加载中...',
40 // error => { 55 forbidClick: true,
41 // return Promise.error(error); 56 });
42 // }) 57 }
58 return config;
59 },
60 error => {
61 return Promise.error(error);
62 })
43 63
44 // 响应拦截器 64 // 响应拦截器
45 axios.interceptors.response.use( 65 axios.interceptors.response.use(
...@@ -50,6 +70,8 @@ axios.interceptors.response.use( ...@@ -50,6 +70,8 @@ axios.interceptors.response.use(
50 let { 70 let {
51 opt 71 opt
52 } = config; 72 } = config;
73 if (loadingToast) loadingToast.clear();
74
53 // 服务器状态码 75 // 服务器状态码
54 if (response.status === 200) { 76 if (response.status === 200) {
55 77
...@@ -71,6 +93,15 @@ axios.interceptors.response.use( ...@@ -71,6 +93,15 @@ axios.interceptors.response.use(
71 removeToken(); 93 removeToken();
72 break; 94 break;
73 95
96 case 3001:
97 app.router.replace({
98 name: "errorTips",
99 query: {
100 code: 3001
101 }
102 })
103 break;
104
74 default: 105 default:
75 break; 106 break;
76 } 107 }
...@@ -113,7 +144,7 @@ function analysisParams(params) { ...@@ -113,7 +144,7 @@ function analysisParams(params) {
113 method 144 method
114 } = params; 145 } = params;
115 if (IS_POST_ENC == 'true') { 146 if (IS_POST_ENC == 'true') {
116 if (method == 'post') { 147 if (method == 'post' || method == 'delete' || method == 'DELETE') {
117 data = makeEncrypt(data); 148 data = makeEncrypt(data);
118 } 149 }
119 } else { 150 } else {
...@@ -184,6 +215,20 @@ export const httpPost = params => { ...@@ -184,6 +215,20 @@ export const httpPost = params => {
184 opt 215 opt
185 }).then(res => res.data.content); 216 }).then(res => res.data.content);
186 } 217 }
218 export const httpDelete = params => {
219 params.method = 'delete';
220 let {
221 reqUrl,
222 data,
223 headers,
224 opt,
225 method
226 } = analysisParams(params);
227 return axios.delete(reqUrl, {
228 data: data,
229 headers: headers,
230 }).then(res => res.data.content);
231 }
187 232
188 233
189 /** 234 /**
...@@ -232,6 +277,31 @@ export const formdata = params => { ...@@ -232,6 +277,31 @@ export const formdata = params => {
232 } 277 }
233 278
234 279
280 /**
281 * 获取bolb对象的图片
282 * @param {*} params
283 * @returns
284 */
285 export const getBlob = params => {
286 let {
287 reqUrl,
288 data,
289 headers,
290 } = analysisParams(params);
291
292 return axios({
293 url: reqUrl,
294 method: 'get',
295 params: data,
296 headers: headers,
297 responseType: 'blob' // 改参数会以blob流格式返回
298 }).then((res) => {
299 let blob = new Blob([res.data])
300 let url = URL.createObjectURL(blob);
301 return url;
302 });
303 }
304
235 305
236 306
237 /** 307 /**
......
...@@ -7,6 +7,8 @@ import api from '@/api/api' ...@@ -7,6 +7,8 @@ import api from '@/api/api'
7 import { 7 import {
8 httpGet, 8 httpGet,
9 httpPost, 9 httpPost,
10 httpDelete,
11 getBlob,
10 formdata 12 formdata
11 } from '@/api/fetch-api.js' 13 } from '@/api/fetch-api.js'
12 14
...@@ -20,6 +22,9 @@ import { ...@@ -20,6 +22,9 @@ import {
20 import 'amfe-flexible/index.js' 22 import 'amfe-flexible/index.js'
21 import vant from '@/utils/vant-util' 23 import vant from '@/utils/vant-util'
22 24
25 // 微信签名
26 import wechat from '@/utils/wechat.js'
27
23 import '@/styles/index.scss' // global css 28 import '@/styles/index.scss' // global css
24 import '@/styles/fonticon.scss' // 图标字体 29 import '@/styles/fonticon.scss' // 图标字体
25 import '@/assets/fonts/font.scss' // 字体引入 30 import '@/assets/fonts/font.scss' // 字体引入
...@@ -27,16 +32,40 @@ import '@/assets/fonts/font.scss' // 字体引入 ...@@ -27,16 +32,40 @@ import '@/assets/fonts/font.scss' // 字体引入
27 32
28 Vue.config.productionTip = false 33 Vue.config.productionTip = false
29 34
35
36 // vconsole 组件
37 import Vconsole from 'vconsole';
38 if (getQuery("test") || process.env.NODE_ENV == "development") {
39 const vConsole = new Vconsole();
40 }
41
42 function setHtmlFontSize() {
43 // 最大缩放单元
44 const MAX_REM_UNIT = 54;
45 let htmlDom = document.querySelector('html');
46 let fontSize = window.innerWidth / 10;
47 fontSize = fontSize > MAX_REM_UNIT ? MAX_REM_UNIT : fontSize;
48 htmlDom.style.fontSize = fontSize + 'px'
49 htmlDom.style.maxWidth = (MAX_REM_UNIT * 10) + "px"
50 htmlDom.style.position = "relative";
51 htmlDom.style.margin = "0 auto";
52 htmlDom.style.backgroundColor = "#f7f8fa";
53 }
54
55 // 重新设置大小
56 window.onresize = () => {
57 return (() => {
58 setHtmlFontSize();
59 })()
60 }
61 setHtmlFontSize()
62
30 import { 63 import {
31 Dialog, 64 Dialog,
32 Toast 65 Toast
33 } from "vant"; 66 } from "vant";
34 67
35 68
36 // 原app节点请通过 document.getElementById('app') 获取
37 // routes里的component组件需要以import方式引入,否则页面创建的时候,app还没挂载。
38
39
40 let util = require('@/utils/utils'); 69 let util = require('@/utils/utils');
41 let func = require('@/utils/func'); 70 let func = require('@/utils/func');
42 71
...@@ -44,6 +73,8 @@ let func = require('@/utils/func'); ...@@ -44,6 +73,8 @@ let func = require('@/utils/func');
44 app.api = api; 73 app.api = api;
45 app.get = httpGet; 74 app.get = httpGet;
46 app.post = httpPost; 75 app.post = httpPost;
76 app.delete = httpDelete;
77 app.getBlob = getBlob;
47 app.uploadFile = formdata; 78 app.uploadFile = formdata;
48 app.router = router; 79 app.router = router;
49 app.util = util; 80 app.util = util;
...@@ -53,6 +84,8 @@ app.vant = { ...@@ -53,6 +84,8 @@ app.vant = {
53 Toast 84 Toast
54 } 85 }
55 window.app = app; 86 window.app = app;
87 // 原app节点请通过 document.getElementById('app') 获取
88 // routes里的component组件需要以import方式引入,否则页面创建的时候,app还没挂载。
56 89
57 90
58 function initVue() { 91 function initVue() {
...@@ -70,6 +103,11 @@ function initVue() { ...@@ -70,6 +103,11 @@ function initVue() {
70 }, 103 },
71 render: h => h(VueApp) 104 render: h => h(VueApp)
72 }).$mount('#app') 105 }).$mount('#app')
106
107 // 微信初始化,微信签名,需要在index.html 引入 jweixin-1.6.0
108 // wechat.init().then(() => {
109 // // wx.wxShare("","","","");
110 // });
73 } 111 }
74 112
75 // 微信授权 113 // 微信授权
......
...@@ -5,12 +5,28 @@ Vue.use(Vuex) ...@@ -5,12 +5,28 @@ Vue.use(Vuex)
5 5
6 export default new Vuex.Store({ 6 export default new Vuex.Store({
7 state: { 7 state: {
8 8 profile: null,
9 }, 9 },
10 mutations: { 10 mutations: {
11 11 basicMutation(state, payload) {
12 Object.assign(state, payload);
13 },
12 }, 14 },
13 actions: { 15 actions: {
14 16 // 获取用户身份
17 async getProfile({
18 commit
19 }, payload) {
20 let res = await app.get({
21 url: app.api.profile,
22 data: {},
23 opt: {
24 toast: false
25 }
26 })
27 commit('basicMutation', {
28 profile: res
29 })
30 },
15 } 31 }
16 }) 32 })
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -15,10 +15,6 @@ div { ...@@ -15,10 +15,6 @@ div {
15 width: 750px; 15 width: 750px;
16 } 16 }
17 17
18 .app__width {
19 width: 750px;
20 }
21
22 .app__inner { 18 .app__inner {
23 margin: 20px; 19 margin: 20px;
24 } 20 }
......
...@@ -160,6 +160,49 @@ export function getObjByListKeyValue(value, key, list) { ...@@ -160,6 +160,49 @@ export function getObjByListKeyValue(value, key, list) {
160 return result; 160 return result;
161 } 161 }
162 162
163
164
165 /**
166 * 根据某个标识,树状数组
167 * @param {*} list
168 * @param {*} key
169 * @param {*} value
170 * @returns
171 *
172 * - 传入原始数组
173 * - 分类检索值
174 *
175 * 输出
176 * - keys
177 * - 树状列表
178 */
179 export function getTreeByListKeyValue(list, key) {
180 let keys = [];
181 let result = [];
182 list.forEach(element => {
183 if (keys.indexOf(element[key]) == -1) {
184 keys.push(element[key]);
185 result.push({
186 text: element[key],
187 children: []
188 })
189 }
190 });
191 list.forEach(element => {
192 result.forEach(eleRes => {
193 if (element[key] == eleRes.text) {
194 eleRes.children.push(element);
195 }
196 });
197 });
198
199 return {
200 keys,
201 result
202 }
203 }
204
205
163 /** 206 /**
164 * 获取环境信息 207 * 获取环境信息
165 * @return {Object} 环境信息对象 208 * @return {Object} 环境信息对象
...@@ -219,7 +262,7 @@ export function setTitle(title) { ...@@ -219,7 +262,7 @@ export function setTitle(title) {
219 $iframe.onload = function onIframeLoad() { 262 $iframe.onload = function onIframeLoad() {
220 setTimeout(function () { 263 setTimeout(function () {
221 $iframe.onload = null; 264 $iframe.onload = null;
222 onIframeLoad = null; 265 // onIframeLoad = null;
223 document.body.removeChild($iframe); 266 document.body.removeChild($iframe);
224 $iframe = null; 267 $iframe = null;
225 }, 0); 268 }, 0);
...@@ -279,10 +322,13 @@ export function formatBr(str) { ...@@ -279,10 +322,13 @@ export function formatBr(str) {
279 * @param {date} date 日期时间 322 * @param {date} date 日期时间
280 * @param {string} fmt 格式,如:'yyyy-MM-dd hh:mm:ss' 323 * @param {string} fmt 格式,如:'yyyy-MM-dd hh:mm:ss'
281 */ 324 */
282 export function formatDate(date, fmt) { 325 export function formatDate(date, fmt = "yyyy-MM-dd hh:mm:ss") {
283 if (!date) return '-' 326 if (!date) return '-'
284 // 把-换成/ 避免iOS和安卓真机问题 327 // 把-换成/ 避免iOS和安卓真机问题
285 var reg = /-/g; 328 var reg = /-/g;
329 if (typeof date == 'string' && date.length == 13 && !isNaN(date)) {
330 date = parseInt(date)
331 }
286 if (typeof date == 'object') { 332 if (typeof date == 'object') {
287 date += ""; 333 date += "";
288 date = date && date.replace(reg, '/'); 334 date = date && date.replace(reg, '/');
......
1 import Vue from 'vue' 1 import Vue from 'vue'
2 2
3 import { 3 import {
4 Search,
5 Button,
4 Swipe, 6 Swipe,
5 SwipeItem, 7 SwipeItem,
6 Lazyload, 8 Lazyload,
7 Tab, 9 Tab,
8 Tabs, 10 Tabs,
11 Tag,
9 Sticky, 12 Sticky,
10 Popup, 13 Popup,
11 Tabbar, 14 Tabbar,
12 TabbarItem, 15 TabbarItem,
13 Icon, 16 Icon,
14 Uploader, 17 Loading,
15 Area, 18 Circle,
16 List, 19 CountDown,
20 GoodsAction,
21 GoodsActionIcon,
22 GoodsActionButton,
23 Divider,
24 Rate,
25 Field,
26 Form,
27 Area,
28 RadioGroup,
29 Radio,
30 List,
31 ImagePreview,
32 Step,
33 Steps,
34 Skeleton,
17 Toast, 35 Toast,
18 Button 36 Dialog,
37 Cell,
38 CellGroup,
39 AddressList,
40 AddressEdit,
41 Checkbox,
42 CheckboxGroup,
43 Stepper,
44 Switch,
45 Badge,
46 Picker,
47 DatetimePicker,
48 Empty,
49 Sidebar,
50 SidebarItem,
51 SubmitBar,
52 IndexBar,
53 IndexAnchor,
54 Calendar,
55 ActionSheet
56 } from 'vant';
57
58
59 import {
60 Image as VanImage
19 } from 'vant'; 61 } from 'vant';
20 62
21 Vue.use(Swipe).use(SwipeItem) 63 Vue.use(Swipe).use(SwipeItem)
64 .use(Search)
65 .use(Button)
22 .use(Lazyload) 66 .use(Lazyload)
23 .use(Tab).use(Tabs) 67 .use(Tab).use(Tabs)
24 .use(Sticky) 68 .use(Sticky)
69 .use(Tag)
25 .use(Popup) 70 .use(Popup)
26 .use(Tabbar).use(TabbarItem) 71 .use(Tabbar).use(TabbarItem)
72 .use(VanImage)
27 .use(Icon) 73 .use(Icon)
28 .use(Uploader) 74 .use(Loading)
75 .use(Circle)
76 .use(CountDown)
77 .use(GoodsAction)
78 .use(GoodsActionIcon)
79 .use(GoodsActionButton)
80 .use(Divider)
81 .use(Rate)
82 .use(Field)
83 .use(Form)
29 .use(Area) 84 .use(Area)
85 .use(Radio)
86 .use(RadioGroup)
30 .use(List) 87 .use(List)
31 .use(Button) 88 .use(ImagePreview)
32 .use(Toast); 89 .use(Step)
90 .use(Steps)
91 .use(Skeleton)
92 .use(Cell)
93 .use(CellGroup)
94 .use(Toast)
95 .use(Dialog)
96 .use(AddressList)
97 .use(AddressEdit)
98 .use(Checkbox)
99 .use(CheckboxGroup)
100 .use(Stepper)
101 .use(Switch)
102 .use(Badge)
103 .use(Picker)
104 .use(DatetimePicker)
105 .use(Empty)
106 .use(Sidebar)
107 .use(SidebarItem)
108 .use(IndexBar)
109 .use(IndexAnchor)
110 .use(ActionSheet)
111 .use(Calendar)
112 .use(SubmitBar);
...\ No newline at end of file ...\ No newline at end of file
......
1 import wx from 'weixin-js-sdk'; 1 import {
2 2 isWeiXin
3 wx.ready(function () { //通过ready接口处理成功验证 3 } from '@/utils/utils';
4 // config信息验证成功后会执行ready方法 4
5 wx.onMenuShareAppMessage({ // 分享给朋友 ,在config里面填写需要使用的JS接口列表,然后这个方法才可以用 5 function wxSign() {
6 title: '这里是标题', // 分享标题 6 return new Promise((resolve, reject) => {
7 desc: 'This is a test!', // 分享描述 7 app.post({
8 link: '链接', // 分享链接 8 url: app.api.wxJsSign,
9 imgUrl: '图片', // 分享图标 9 data: {
10 type: '', // 分享类型,music、video或link,不填默认为link 10 url: location.href
11 dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 11 },
12 success: function () { 12 // mode: "custom"
13 // 用户确认分享后执行的回调函数 13 }).then(res => {
14 }, 14 if (!window.wx) {
15 cancel: function () { 15 return
16 // 用户取消分享后执行的回调函数 16 }
17 wx.config({
18 debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
19 appId: res.appId, // 必填,公众号的唯一标识
20 timestamp: res.timestamp, // 必填,生成签名的时间戳
21 nonceStr: res.nonceStr, // 必填,生成签名的随机串
22 signature: res.signature, // 必填,签名,见附录1
23 jsApiList: [
24 "updateAppMessageShareData",
25 "updateTimelineShareData",
26 "onMenuShareTimeline",
27 "onMenuShareAppMessage",
28 "chooseWXPay",
29 ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
30 });
31 wx.ready(() => {
32 resolve()
33 })
34 });
35 })
36 }
37
38 function setShare(title, description, image, url) {
39 wx.updateAppMessageShareData({
40 title: title, // 分享标题
41 desc: description, // 分享描述
42 link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
43 imgUrl: image, // 分享图标
44 success() {
45 // 设置成功
17 } 46 }
18 }); 47 });
19 wx.onMenuShareTimeline({ //分享朋友圈 48
20 title: '标题', // 分享标题 49
21 link: '链接', 50 wx.updateTimelineShareData({
22 imgUrl: '图片', // 分享图标 51 title: title, // 分享标题
23 success: function () { 52 link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
24 // 用户确认分享后执行的回调函数 53 imgUrl: image, // 分享图标
25 }, 54 success() {
26 cancel: function () { 55 // 设置成功
27 // 用户取消分享后执行的回调函数
28 } 56 }
29 }); 57 });
30 }); 58 }
31 wx.error(function (res) {//通过error接口处理失败验证 59
32 // config信息验证失败会执行error函数 60
33 }); 61 let wechat = {
34 62 init() {
35 63 return new Promise((resolve, reject) => {
36 wx.config({ 64 if (isWeiXin()) {
37 debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 65 wxSign().then(() => {
38 appId: '', // 必填,公众号的唯一标识 66 resolve();
39 timestamp: '', // 必填,生成签名的时间戳 67 }).catch(e => {
40 nonceStr: '', // 必填,生成签名的随机串 68 resolve();
41 signature: '',// 必填,签名,见附录1 69 });
42 jsApiList: [] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 70 } else {
43 }); 71 resolve();
72 }
73 });
74 },
75 wxShare(title, description, image, url) {
76 title = title || process.env.VUE_APP_MALL_NAME + "";
77 description = description || "";
78 image = image || "";
79 url = url || location.href;
80
81 return new Promise((resolve, reject) => {
82 if (isWeiXin()) {
83 wx.onMenuShareAppMessage({
84 title: title, // 分享标题
85 desc: description, // 分享描述
86 link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
87 imgUrl: image, // 分享图标
88 success: function () {
89 // 分享成功
90 // alert("ShareApp")
91 resolve("ShareApp")
92 }
93 });
94
95 wx.onMenuShareTimeline({
96 title: title, // 分享标题
97 link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
98 imgUrl: image, // 分享图标
99 success: function () {
100 // 分享成功
101 // alert("ShareTimeline")
102 resolve("ShareTimeline")
103 }
104 });
105 }
106 });
107
108 // if (isWeiXin()) {
109 // setShare(title, description, image, url);
110 // }
111 }
112 };
113
114 export default wechat;
...\ No newline at end of file ...\ No newline at end of file
......