默认提交
Showing
20 changed files
with
1526 additions
and
161 deletions
... | @@ -8,6 +8,9 @@ | ... | @@ -8,6 +8,9 @@ |
8 | <meta name="viewport" | 8 | <meta name="viewport" |
9 | content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> | 9 | content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> |
10 | <link rel="icon" href="<%= BASE_URL %>favicon.ico"> | 10 | <link rel="icon" href="<%= BASE_URL %>favicon.ico"> |
11 | <!-- <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> | ||
13 | <script src="<%= BASE_URL %>static/js/kd/kd.js"></script> --> | ||
11 | <title>vue-cli3-framework</title> | 14 | <title>vue-cli3-framework</title> |
12 | </head> | 15 | </head> |
13 | 16 | ... | ... |
public/static/js/kd/kd-sdk.1.0.0-old.js
0 → 100644
1 | |||
2 | (function () { | ||
3 | |||
4 | let BASE_HOST = "https://api.kdao.xin"; | ||
5 | let BIZ_BASE_HOST = "https://bizapi.kdao.xin"; | ||
6 | // 打开微信调试的开关 | ||
7 | let DEBUG_SWITCH = "false"; | ||
8 | |||
9 | |||
10 | let KD = {}; | ||
11 | window.KD = KD; | ||
12 | |||
13 | |||
14 | let _app_id = "", _app_secret = "", _module_code = ""; | ||
15 | KD.init = function (appId, appKey, moduleCode) { | ||
16 | _app_id = appId; | ||
17 | _app_secret = appKey; | ||
18 | _module_code = moduleCode; | ||
19 | } | ||
20 | |||
21 | let _request_url = { | ||
22 | wx_signature: BASE_HOST + "/wx/signature", | ||
23 | // 授权后的用户信息 | ||
24 | wx_sns_user_info: BASE_HOST + "/wx_user_info", | ||
25 | // 含unionid 的用户信息 | ||
26 | wx_user_info: BASE_HOST + "/cgi_bin/user_info", | ||
27 | // 统计 | ||
28 | stat: BIZ_BASE_HOST + "/kd_platform_api/stat/s" | ||
29 | } | ||
30 | |||
31 | |||
32 | KD._tools = {}; | ||
33 | (function () { | ||
34 | KD._tools._post_json = function (url, data, header, callback) { | ||
35 | var xhr; | ||
36 | //创建ajax引擎 | ||
37 | if (window.XMLHttpRequest) { | ||
38 | xhr = new XMLHttpRequest(); | ||
39 | } else if (window.AtiveXObject) { | ||
40 | xhr = new ActiveXObject("Microsoft.XMLHTTP"); | ||
41 | } | ||
42 | |||
43 | xhr.onreadystatechange = function () { | ||
44 | if (xhr.readyState == 4) { | ||
45 | let data = { code: xhr.status, response: xhr.responseText }; | ||
46 | (typeof callback == "function") && callback(data); | ||
47 | } | ||
48 | }; | ||
49 | //创建请求 | ||
50 | xhr.open("post", url, true); | ||
51 | xhr.setRequestHeader('Content-type', 'application/json'); | ||
52 | if (header) { | ||
53 | for (let key in header) { | ||
54 | xhr.setRequestHeader(key, header[key]); | ||
55 | } | ||
56 | } | ||
57 | //发送请求 | ||
58 | xhr.send(JSON.stringify(data)); | ||
59 | } | ||
60 | |||
61 | |||
62 | KD._tools._post_form = function (url, data, header, callback) { | ||
63 | var xhr; | ||
64 | //创建ajax引擎 | ||
65 | if (window.XMLHttpRequest) { | ||
66 | xhr = new XMLHttpRequest(); | ||
67 | } else if (window.AtiveXObject) { | ||
68 | xhr = new ActiveXObject("Microsoft.XMLHTTP"); | ||
69 | } | ||
70 | |||
71 | xhr.onreadystatechange = function () { | ||
72 | if (xhr.readyState == 4) { | ||
73 | let data = { code: xhr.status, response: xhr.responseText }; | ||
74 | (typeof callback == "function") && callback(data); | ||
75 | } | ||
76 | }; | ||
77 | //创建请求 | ||
78 | xhr.open("post", url, true); | ||
79 | xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); | ||
80 | if (header) { | ||
81 | for (let key in header) { | ||
82 | xhr.setRequestHeader(key, header[key]); | ||
83 | } | ||
84 | } | ||
85 | //发送请求 | ||
86 | let postStr = ""; | ||
87 | for (let key in data) { | ||
88 | postStr += key + "=" + data[key] + "&"; | ||
89 | } | ||
90 | if (postStr) { | ||
91 | postStr = postStr.substring(0, postStr.length - 1); | ||
92 | } | ||
93 | xhr.send(postStr); | ||
94 | } | ||
95 | |||
96 | |||
97 | KD._tools._get = function (url, data, header, callback) { | ||
98 | var xhr; | ||
99 | //创建ajax引擎 | ||
100 | if (window.XMLHttpRequest) { | ||
101 | xhr = new XMLHttpRequest(); | ||
102 | } else if (window.AtiveXObject) { | ||
103 | xhr = new ActiveXObject("Microsoft.XMLHTTP"); | ||
104 | } | ||
105 | |||
106 | xhr.onreadystatechange = function () { | ||
107 | if (xhr.readyState == 4) { | ||
108 | let data = { code: xhr.status, response: xhr.responseText }; | ||
109 | (typeof callback == "function") && callback(data); | ||
110 | } | ||
111 | }; | ||
112 | //发送请求 | ||
113 | let postStr = ""; | ||
114 | for (let key in data) { | ||
115 | postStr += key + "=" + data[key] + "&"; | ||
116 | } | ||
117 | if (postStr) { | ||
118 | postStr = "?" + postStr.substring(0, postStr.length - 1); | ||
119 | } | ||
120 | xhr.open("GET", url + postStr, true); | ||
121 | |||
122 | //创建请求 | ||
123 | if (header) { | ||
124 | for (let key in header) { | ||
125 | xhr.setRequestHeader(key, header[key]); | ||
126 | } | ||
127 | } | ||
128 | xhr.send(null); | ||
129 | } | ||
130 | |||
131 | KD._tools._get_token = function () { | ||
132 | let key = "pl_token_" + _app_id; | ||
133 | return KD._tools._get_cookie(key); | ||
134 | } | ||
135 | |||
136 | |||
137 | KD._tools._get_wx_app_id = function () { | ||
138 | let key = "pl_wx_" + _app_id; | ||
139 | let res = KD._tools._get_cookie(key); | ||
140 | let wxAppId = res ? res.split(":")[0] : ""; | ||
141 | return wxAppId; | ||
142 | } | ||
143 | |||
144 | KD._tools._get_cookie = function (name) { | ||
145 | var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); | ||
146 | if (arr = document.cookie.match(reg)) { | ||
147 | return decodeURIComponent(arr[2]) | ||
148 | } else { | ||
149 | return null | ||
150 | } | ||
151 | }; | ||
152 | /** | ||
153 | * 处理响应结果 | ||
154 | */ | ||
155 | KD._tools._handle_response = function (response) { | ||
156 | if (response.code == 200) { | ||
157 | let res = JSON.parse(response.response); | ||
158 | if (res.code == 200) { | ||
159 | return res; | ||
160 | } else { | ||
161 | if (DEBUG_SWITCH) { | ||
162 | alert("_handle_response failure : " + response.content) | ||
163 | } | ||
164 | } | ||
165 | |||
166 | } else { | ||
167 | if (DEBUG_SWITCH) { | ||
168 | alert("_handle_response : " + JSON.stringify(response)) | ||
169 | } | ||
170 | } | ||
171 | } | ||
172 | |||
173 | |||
174 | /** | ||
175 | * 加解密CDN方式引入。 | ||
176 | * | ||
177 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/core.min.js"></script> | ||
178 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/enc-base64.min.js"></script> | ||
179 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/md5.min.js"></script> | ||
180 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/evpkdf.min.js"></script> | ||
181 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/cipher-core.min.js"></script> | ||
182 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/aes.min.js"></script> | ||
183 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/pad-pkcs7.min.js"></script> | ||
184 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/mode-ecb.min.js"></script> | ||
185 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/enc-utf8.min.js"></script> | ||
186 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/enc-hex.min.js"></script> | ||
187 | */ | ||
188 | |||
189 | KD._tools._init_aes = function () { | ||
190 | if (typeof KD._tools._aes_decrypt == "function") { | ||
191 | return true; | ||
192 | } | ||
193 | if (typeof CryptoJS == "undefined") { | ||
194 | console.error("install CryptoJS first"); | ||
195 | return false; | ||
196 | } | ||
197 | if (CryptoJS && _app_secret) { | ||
198 | const key = CryptoJS.enc.Utf8.parse(_app_secret); | ||
199 | const iv = CryptoJS.enc.Utf8.parse(_app_secret.substring(0, 16)); | ||
200 | |||
201 | // 解密方法 | ||
202 | KD._tools._aes_decrypt = function (srcs) { | ||
203 | // let encryptedHexStr = CryptoJS.enc.Hex.parse(word); | ||
204 | // console.log("1,", encryptedHexStr) | ||
205 | // let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr); | ||
206 | let decrypt = CryptoJS.AES.decrypt(srcs, key, { | ||
207 | iv: iv, | ||
208 | mode: CryptoJS.mode.CBC, | ||
209 | padding: CryptoJS.pad.Pkcs7 | ||
210 | }); | ||
211 | let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8); | ||
212 | return decryptedStr.toString(); | ||
213 | } | ||
214 | |||
215 | // 加密方法 | ||
216 | KD._tools._aes_encrypt = function (word) { | ||
217 | var srcs = CryptoJS.enc.Utf8.parse(word); | ||
218 | var encrypted = CryptoJS.AES.encrypt(srcs, key, { | ||
219 | iv: iv, | ||
220 | mode: CryptoJS.mode.ECB, | ||
221 | padding: CryptoJS.pad.Pkcs7 | ||
222 | }); | ||
223 | return encrypted.toString(); | ||
224 | } | ||
225 | return true; | ||
226 | } | ||
227 | return false; | ||
228 | } | ||
229 | |||
230 | KD._tools._init_headers = function () { | ||
231 | return { | ||
232 | "-kd-platform-id": _app_id, | ||
233 | "-kd-platform-module": _module_code | ||
234 | } | ||
235 | } | ||
236 | |||
237 | })(); | ||
238 | |||
239 | |||
240 | |||
241 | |||
242 | // 微信SDK地址 | ||
243 | KD.weixin = function () { | ||
244 | let weixin = {}; | ||
245 | let tools = KD._tools; | ||
246 | /** | ||
247 | * 权限列表: | ||
248 | * updateAppMessageShareData,updateTimelineShareData,onMenuShareWeibo,onMenuShareQZone, | ||
249 | * startRecord,stopRecord,onVoiceRecordEnd,playVoice,pauseVoice,stopVoice,onVoicePlayEnd,uploadVoice,downloadVoice, | ||
250 | * chooseImage,previewImage,uploadImage,downloadImage, | ||
251 | * translateVoice, | ||
252 | * getNetworkType,openLocation,getLocation, | ||
253 | * hideOptionMenu,showOptionMenu,hideMenuItems,showMenuItems,hideAllNonBaseMenuItem,showAllNonBaseMenuItem, | ||
254 | * closeWindow,scanQRCode,chooseWXPay,openProductSpecificView,addCard,chooseCard,openCard, | ||
255 | */ | ||
256 | weixin.initConfig = function (jsApiList) { | ||
257 | let url = window.location.href; | ||
258 | // jsApiList = jsApiList && jsApiList.length > 0 ? jsApiList : ["updateAppMessageShareData", "updateTimelineShareData", "onMenuShareWeibo", "onMenuShareQZone"]; | ||
259 | jsApiList = jsApiList && jsApiList.length > 0 ? jsApiList : ["onMenuShareTimeline", "onMenuShareAppMessage", "hideMenuItems"]; | ||
260 | tools._post_json(_request_url.wx_signature, { appId: _app_id, url: url }, null, function (response) { | ||
261 | let res = KD._tools._handle_response(response); | ||
262 | wx.config({ | ||
263 | debug: DEBUG_SWITCH, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 | ||
264 | appId: res.content.appId, // 必填,公众号的唯一标识 | ||
265 | timestamp: res.content.timestamp, // 必填,生成签名的时间戳 | ||
266 | nonceStr: res.content.nonceStr, // 必填,生成签名的随机串 | ||
267 | signature: res.content.signature,// 必填,签名 | ||
268 | jsApiList: jsApiList // 必填,需要使用的JS接口列表 | ||
269 | }); | ||
270 | |||
271 | wx.ready(function () { | ||
272 | wx.hideMenuItems({ | ||
273 | menuList: ["menuItem:copyUrl"] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3 | ||
274 | }); | ||
275 | }) | ||
276 | }); | ||
277 | } | ||
278 | |||
279 | /** | ||
280 | * 单独设置分享朋友圈 | ||
281 | */ | ||
282 | weixin.updateAppMessageShareData = function (title, desc, link, imageUrl, succ) { | ||
283 | wx.ready(function () { //需在用户可能点击分享按钮前就先调用 | ||
284 | wx.onMenuShareAppMessage({ | ||
285 | title: title, // 分享标题 | ||
286 | desc: desc, // 分享描述 | ||
287 | link: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 | ||
288 | imgUrl: imageUrl, // 分享图标 | ||
289 | success: function () { | ||
290 | (typeof succ == "function") && succ(); | ||
291 | } | ||
292 | }) | ||
293 | }); | ||
294 | } | ||
295 | |||
296 | weixin.updateTimelineShareData = function (title, link, imageUrl, succ) { | ||
297 | wx.ready(function () { //需在用户可能点击分享按钮前就先调用 | ||
298 | wx.onMenuShareTimeline({ | ||
299 | title: title, // 分享标题 | ||
300 | link: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 | ||
301 | imgUrl: imageUrl, // 分享图标 | ||
302 | success: function () { | ||
303 | (typeof succ == "function") && succ(); | ||
304 | } | ||
305 | }) | ||
306 | }); | ||
307 | } | ||
308 | |||
309 | /** | ||
310 | * 微信设置分享 | ||
311 | */ | ||
312 | weixin.setShare = function (title, desc, link, imageUrl, succ) { | ||
313 | weixin.updateAppMessageShareData(title, desc, link, imageUrl, function () { | ||
314 | (typeof succ == "function") && succ("appMessage"); | ||
315 | }); | ||
316 | weixin.updateTimelineShareData(desc, link, imageUrl, function () { | ||
317 | (typeof succ == "function") && succ("timeline"); | ||
318 | }); | ||
319 | } | ||
320 | |||
321 | /** | ||
322 | * 获取用户的openid | ||
323 | */ | ||
324 | weixin.getOpenId = function () { | ||
325 | let openId = tools._get_token(); | ||
326 | return openId; | ||
327 | } | ||
328 | |||
329 | /** | ||
330 | * 读取用户基本信息 | ||
331 | */ | ||
332 | weixin.getUserInfo = function (callback) { | ||
333 | if (typeof callback != "function") { | ||
334 | return; | ||
335 | } | ||
336 | if (typeof CryptoJS != "undefined") { | ||
337 | let info = _get_user_info_from_cookie(); | ||
338 | if (info) { | ||
339 | callback(info); | ||
340 | } else { | ||
341 | _get_user_info_by_openid(callback); | ||
342 | } | ||
343 | } else { | ||
344 | _get_user_info_by_openid(callback); | ||
345 | } | ||
346 | } | ||
347 | |||
348 | /** | ||
349 | * 这个是用户授权后,从微信端读取用户基本信息。这个接口需要用户显示授权 | ||
350 | */ | ||
351 | weixin.getCgiUserInfo = function (callback) { | ||
352 | if (typeof callback != "function") { | ||
353 | return; | ||
354 | } | ||
355 | let openId = tools._get_token(); | ||
356 | let wxAppId = tools._get_wx_app_id(); | ||
357 | tools._get(_request_url.wx_user_info, { wxAppId: wxAppId, openId: openId }, null, function (response) { | ||
358 | let res = tools._handle_response(response); | ||
359 | callback(res.content); | ||
360 | }) | ||
361 | } | ||
362 | |||
363 | |||
364 | /** | ||
365 | * 通过openid读取用户基本信息 | ||
366 | * | ||
367 | * @param {function} callback | ||
368 | */ | ||
369 | function _get_user_info_by_openid(callback) { | ||
370 | let openId = tools._get_token(); | ||
371 | let wxAppId = tools._get_wx_app_id(); | ||
372 | |||
373 | tools._get(_request_url.wx_sns_user_info, { wxAppId: wxAppId, openId: openId }, null, function (response) { | ||
374 | let res = tools._handle_response(response); | ||
375 | if (typeof callback == "function") { | ||
376 | callback(res.content); | ||
377 | } | ||
378 | }) | ||
379 | } | ||
380 | |||
381 | /** | ||
382 | * 从cookie中读取信息 | ||
383 | */ | ||
384 | function _get_user_info_from_cookie() { | ||
385 | let data = tools._get_cookie("pl_info_" + _app_id); | ||
386 | if (tools._init_aes()) { | ||
387 | let infoStr = tools._aes_decrypt(data); | ||
388 | return infoStr ? JSON.parse(infoStr) : null | ||
389 | } | ||
390 | return null; | ||
391 | } | ||
392 | |||
393 | return weixin; | ||
394 | |||
395 | } | ||
396 | |||
397 | KD.biz = function () { | ||
398 | let biz = {}; | ||
399 | let tools = KD._tools; | ||
400 | |||
401 | /** | ||
402 | * 统计接口 | ||
403 | * | ||
404 | * @param {String} channelCode 渠道编号 | ||
405 | * @param {String} statClassify 统计类型,可见统计表定义 | ||
406 | * @param {String} statKey 统计标识,可见统计表定义 | ||
407 | * @param {String} primaryKey 唯一标识,如用户标识、按钮标识 | ||
408 | */ | ||
409 | biz.stat = function (channelCode, statClassify, statKey, primaryKey) { | ||
410 | let form = { | ||
411 | aid: _app_id, | ||
412 | cc: !channelCode || channelCode == undefined ? "" : channelCode,//渠道 | ||
413 | sc: !statClassify || statClassify == undefined ? "" : statClassify,//统计类型 | ||
414 | sk: !statKey || statKey == undefined ? "" : statKey,//统计key | ||
415 | pc: !primaryKey || primaryKey == undefined ? "" : primaryKey //用户标识 | ||
416 | } | ||
417 | |||
418 | let headers = tools._init_headers(); | ||
419 | |||
420 | tools._get(_request_url.stat, form, headers, function (response) { }) | ||
421 | } | ||
422 | |||
423 | return biz; | ||
424 | } | ||
425 | |||
426 | })(); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
public/static/js/kd/kd-sdk.1.0.0.js
0 → 100644
1 | (function () { | ||
2 | |||
3 | let BASE_HOST = "https://api.kdao.xin"; | ||
4 | let BIZ_BASE_HOST = "https://bizapi.kdao.xin"; | ||
5 | // 打开微信调试的开关 | ||
6 | let DEBUG_SWITCH = false; | ||
7 | |||
8 | |||
9 | let KD = {}; | ||
10 | window.KD = KD; | ||
11 | |||
12 | |||
13 | let _app_id = "", | ||
14 | _app_secret = "", | ||
15 | _module_code = ""; | ||
16 | KD.init = function (appId, appKey, moduleCode) { | ||
17 | _app_id = appId; | ||
18 | _app_secret = appKey; | ||
19 | _module_code = moduleCode; | ||
20 | } | ||
21 | |||
22 | let _request_url = { | ||
23 | wx_signature: BASE_HOST + "/wx/signature", | ||
24 | // 授权后的用户信息 | ||
25 | wx_sns_user_info: BASE_HOST + "/wx_user_info", | ||
26 | // 含unionid 的用户信息 | ||
27 | wx_user_info: BASE_HOST + "/cgi_bin/user_info", | ||
28 | // 统计 | ||
29 | stat: BIZ_BASE_HOST + "/kd_platform_api/stat/s" | ||
30 | } | ||
31 | |||
32 | |||
33 | KD._tools = {}; | ||
34 | (function () { | ||
35 | KD._tools._post_json = function (url, data, header, callback) { | ||
36 | var xhr; | ||
37 | //创建ajax引擎 | ||
38 | if (window.XMLHttpRequest) { | ||
39 | xhr = new XMLHttpRequest(); | ||
40 | } else if (window.AtiveXObject) { | ||
41 | xhr = new ActiveXObject("Microsoft.XMLHTTP"); | ||
42 | } | ||
43 | |||
44 | xhr.onreadystatechange = function () { | ||
45 | if (xhr.readyState == 4) { | ||
46 | let data = { | ||
47 | code: xhr.status, | ||
48 | response: xhr.responseText | ||
49 | }; | ||
50 | (typeof callback == "function") && callback(data); | ||
51 | } | ||
52 | }; | ||
53 | //创建请求 | ||
54 | xhr.open("post", url, true); | ||
55 | xhr.setRequestHeader('Content-type', 'application/json'); | ||
56 | if (header) { | ||
57 | for (let key in header) { | ||
58 | xhr.setRequestHeader(key, header[key]); | ||
59 | } | ||
60 | } | ||
61 | //发送请求 | ||
62 | xhr.send(JSON.stringify(data)); | ||
63 | } | ||
64 | |||
65 | |||
66 | KD._tools._post_form = function (url, data, header, callback) { | ||
67 | var xhr; | ||
68 | //创建ajax引擎 | ||
69 | if (window.XMLHttpRequest) { | ||
70 | xhr = new XMLHttpRequest(); | ||
71 | } else if (window.AtiveXObject) { | ||
72 | xhr = new ActiveXObject("Microsoft.XMLHTTP"); | ||
73 | } | ||
74 | |||
75 | xhr.onreadystatechange = function () { | ||
76 | if (xhr.readyState == 4) { | ||
77 | let data = { | ||
78 | code: xhr.status, | ||
79 | response: xhr.responseText | ||
80 | }; | ||
81 | (typeof callback == "function") && callback(data); | ||
82 | } | ||
83 | }; | ||
84 | //创建请求 | ||
85 | xhr.open("post", url, true); | ||
86 | xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); | ||
87 | if (header) { | ||
88 | for (let key in header) { | ||
89 | xhr.setRequestHeader(key, header[key]); | ||
90 | } | ||
91 | } | ||
92 | //发送请求 | ||
93 | let postStr = ""; | ||
94 | for (let key in data) { | ||
95 | postStr += key + "=" + data[key] + "&"; | ||
96 | } | ||
97 | if (postStr) { | ||
98 | postStr = postStr.substring(0, postStr.length - 1); | ||
99 | } | ||
100 | xhr.send(postStr); | ||
101 | } | ||
102 | |||
103 | |||
104 | KD._tools._get = function (url, data, header, callback) { | ||
105 | var xhr; | ||
106 | //创建ajax引擎 | ||
107 | if (window.XMLHttpRequest) { | ||
108 | xhr = new XMLHttpRequest(); | ||
109 | } else if (window.AtiveXObject) { | ||
110 | xhr = new ActiveXObject("Microsoft.XMLHTTP"); | ||
111 | } | ||
112 | |||
113 | xhr.onreadystatechange = function () { | ||
114 | if (xhr.readyState == 4) { | ||
115 | let data = { | ||
116 | code: xhr.status, | ||
117 | response: xhr.responseText | ||
118 | }; | ||
119 | (typeof callback == "function") && callback(data); | ||
120 | } | ||
121 | }; | ||
122 | //发送请求 | ||
123 | let postStr = ""; | ||
124 | for (let key in data) { | ||
125 | postStr += key + "=" + data[key] + "&"; | ||
126 | } | ||
127 | if (postStr) { | ||
128 | postStr = "?" + postStr.substring(0, postStr.length - 1); | ||
129 | } | ||
130 | xhr.open("GET", url + postStr, true); | ||
131 | |||
132 | //创建请求 | ||
133 | if (header) { | ||
134 | for (let key in header) { | ||
135 | xhr.setRequestHeader(key, header[key]); | ||
136 | } | ||
137 | } | ||
138 | xhr.send(null); | ||
139 | } | ||
140 | |||
141 | KD._tools._get_token = function () { | ||
142 | let key = "pl_token_" + _app_id; | ||
143 | return KD._tools._get_cookie(key); | ||
144 | } | ||
145 | |||
146 | |||
147 | KD._tools._get_wx_app_id = function () { | ||
148 | let key = "pl_wx_" + _app_id; | ||
149 | let res = KD._tools._get_cookie(key); | ||
150 | let wxAppId = res ? res.split(":")[0] : ""; | ||
151 | return wxAppId; | ||
152 | } | ||
153 | |||
154 | KD._tools._get_cookie = function (name) { | ||
155 | var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); | ||
156 | if (arr = document.cookie.match(reg)) { | ||
157 | return decodeURIComponent(arr[2]) | ||
158 | } else { | ||
159 | return null | ||
160 | } | ||
161 | }; | ||
162 | /** | ||
163 | * 处理响应结果 | ||
164 | */ | ||
165 | KD._tools._handle_response = function (response) { | ||
166 | if (response.code == 200) { | ||
167 | let res = JSON.parse(response.response); | ||
168 | if (res.code == 200) { | ||
169 | return res; | ||
170 | } else { | ||
171 | if (DEBUG_SWITCH) { | ||
172 | alert("_handle_response failure : " + response.content) | ||
173 | } | ||
174 | } | ||
175 | |||
176 | } else { | ||
177 | if (DEBUG_SWITCH) { | ||
178 | alert("_handle_response : " + JSON.stringify(response)) | ||
179 | } | ||
180 | } | ||
181 | } | ||
182 | |||
183 | |||
184 | /** | ||
185 | * 加解密CDN方式引入。 | ||
186 | * | ||
187 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/core.min.js"></script> | ||
188 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/enc-base64.min.js"></script> | ||
189 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/md5.min.js"></script> | ||
190 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/evpkdf.min.js"></script> | ||
191 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/cipher-core.min.js"></script> | ||
192 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/aes.min.js"></script> | ||
193 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/pad-pkcs7.min.js"></script> | ||
194 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/mode-ecb.min.js"></script> | ||
195 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/enc-utf8.min.js"></script> | ||
196 | <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/enc-hex.min.js"></script> | ||
197 | */ | ||
198 | |||
199 | KD._tools._init_aes = function () { | ||
200 | if (typeof KD._tools._aes_decrypt == "function") { | ||
201 | return true; | ||
202 | } | ||
203 | if (typeof CryptoJS == "undefined") { | ||
204 | console.error("install CryptoJS first"); | ||
205 | return false; | ||
206 | } | ||
207 | if (CryptoJS && _app_secret) { | ||
208 | const key = CryptoJS.enc.Utf8.parse(_app_secret); | ||
209 | const iv = CryptoJS.enc.Utf8.parse(_app_secret.substring(0, 16)); | ||
210 | |||
211 | // 解密方法 | ||
212 | KD._tools._aes_decrypt = function (srcs) { | ||
213 | // let encryptedHexStr = CryptoJS.enc.Hex.parse(word); | ||
214 | // console.log("1,", encryptedHexStr) | ||
215 | // let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr); | ||
216 | console.log("2,", srcs) | ||
217 | let decrypt = CryptoJS.AES.decrypt(srcs, key, { | ||
218 | iv: iv, | ||
219 | mode: CryptoJS.mode.CBC, | ||
220 | padding: CryptoJS.pad.Pkcs7 | ||
221 | }); | ||
222 | let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8); | ||
223 | console.log("3,", decryptedStr) | ||
224 | return decryptedStr.toString(); | ||
225 | } | ||
226 | |||
227 | // 加密方法 | ||
228 | KD._tools._aes_encrypt = function (word) { | ||
229 | var srcs = CryptoJS.enc.Utf8.parse(word); | ||
230 | var encrypted = CryptoJS.AES.encrypt(srcs, key, { | ||
231 | iv: iv, | ||
232 | mode: CryptoJS.mode.ECB, | ||
233 | padding: CryptoJS.pad.Pkcs7 | ||
234 | }); | ||
235 | return encrypted.toString(); | ||
236 | } | ||
237 | return true; | ||
238 | } | ||
239 | return false; | ||
240 | } | ||
241 | |||
242 | KD._tools._init_headers = function () { | ||
243 | return { | ||
244 | "-kd-platform-id": _app_id, | ||
245 | "-kd-platform-module": _module_code | ||
246 | } | ||
247 | } | ||
248 | |||
249 | })(); | ||
250 | |||
251 | |||
252 | |||
253 | |||
254 | // 微信SDK地址 | ||
255 | KD.weixin = function () { | ||
256 | let weixin = {}; | ||
257 | let tools = KD._tools; | ||
258 | /** | ||
259 | * 权限列表: | ||
260 | * updateAppMessageShareData,updateTimelineShareData,onMenuShareWeibo,onMenuShareQZone, | ||
261 | * startRecord,stopRecord,onVoiceRecordEnd,playVoice,pauseVoice,stopVoice,onVoicePlayEnd,uploadVoice,downloadVoice, | ||
262 | * chooseImage,previewImage,uploadImage,downloadImage, | ||
263 | * translateVoice, | ||
264 | * getNetworkType,openLocation,getLocation, | ||
265 | * hideOptionMenu,showOptionMenu,hideMenuItems,showMenuItems,hideAllNonBaseMenuItem,showAllNonBaseMenuItem, | ||
266 | * closeWindow,scanQRCode,chooseWXPay,openProductSpecificView,addCard,chooseCard,openCard, | ||
267 | */ | ||
268 | weixin.initConfig = function (jsApiList) { | ||
269 | let url = window.location.href; | ||
270 | jsApiList = jsApiList && jsApiList.length > 0 ? jsApiList : ["updateAppMessageShareData", "updateTimelineShareData", "onMenuShareWeibo", "onMenuShareQZone", "hideMenuItems", "getLocation"]; | ||
271 | tools._post_json(_request_url.wx_signature, { | ||
272 | appId: _app_id, | ||
273 | url: url | ||
274 | }, null, function (response) { | ||
275 | let res = KD._tools._handle_response(response); | ||
276 | if (res) { | ||
277 | wx.config({ | ||
278 | debug: DEBUG_SWITCH, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 | ||
279 | appId: res.content.appId, // 必填,公众号的唯一标识 | ||
280 | timestamp: res.content.timestamp, // 必填,生成签名的时间戳 | ||
281 | nonceStr: res.content.nonceStr, // 必填,生成签名的随机串 | ||
282 | signature: res.content.signature, // 必填,签名 | ||
283 | jsApiList: jsApiList // 必填,需要使用的JS接口列表 | ||
284 | }); | ||
285 | wx.ready(function () { | ||
286 | wx.hideMenuItems({ | ||
287 | menuList: ["menuItem:copyUrl"] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3 | ||
288 | }); | ||
289 | }) | ||
290 | } | ||
291 | }); | ||
292 | } | ||
293 | |||
294 | /** | ||
295 | * 单独设置分享朋友圈 | ||
296 | */ | ||
297 | weixin.updateAppMessageShareData = function (title, desc, link, imageUrl, succ) { | ||
298 | wx.ready(function () { //需在用户可能点击分享按钮前就先调用 | ||
299 | wx.updateAppMessageShareData({ | ||
300 | title: title, // 分享标题 | ||
301 | desc: desc, // 分享描述 | ||
302 | link: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 | ||
303 | imgUrl: imageUrl, // 分享图标 | ||
304 | success: function () { | ||
305 | (typeof succ == "function") && succ(); | ||
306 | } | ||
307 | }) | ||
308 | }); | ||
309 | } | ||
310 | |||
311 | weixin.updateTimelineShareData = function (title, link, imageUrl, succ) { | ||
312 | wx.ready(function () { //需在用户可能点击分享按钮前就先调用 | ||
313 | wx.updateTimelineShareData({ | ||
314 | title: title, // 分享标题 | ||
315 | link: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 | ||
316 | imgUrl: imageUrl, // 分享图标 | ||
317 | success: function () { | ||
318 | (typeof succ == "function") && succ(); | ||
319 | } | ||
320 | }) | ||
321 | }); | ||
322 | } | ||
323 | |||
324 | /** | ||
325 | * 微信设置分享 | ||
326 | */ | ||
327 | weixin.setShare = function (title, desc, link, imageUrl, succ) { | ||
328 | weixin.updateAppMessageShareData(title, desc, link, imageUrl, function () { | ||
329 | (typeof succ == "function") && succ("appMessage"); | ||
330 | }); | ||
331 | weixin.updateTimelineShareData(desc, link, imageUrl, function () { | ||
332 | (typeof succ == "function") && succ("timeline"); | ||
333 | }); | ||
334 | } | ||
335 | |||
336 | /** | ||
337 | * 获取用户的openid | ||
338 | */ | ||
339 | weixin.getOpenId = function () { | ||
340 | let openId = tools._get_token(); | ||
341 | return openId; | ||
342 | } | ||
343 | |||
344 | /** | ||
345 | * 读取用户基本信息 | ||
346 | */ | ||
347 | weixin.localUserInfo = function (callback) { | ||
348 | if (typeof callback != "function") { | ||
349 | return; | ||
350 | } | ||
351 | if (typeof CryptoJS != "undefined") { | ||
352 | let info = _get_user_info_from_cookie(); | ||
353 | if (info) { | ||
354 | callback(info); | ||
355 | } else { | ||
356 | _get_user_info_by_openid(callback); | ||
357 | } | ||
358 | } else { | ||
359 | _get_user_info_by_openid(callback); | ||
360 | } | ||
361 | } | ||
362 | |||
363 | /** | ||
364 | * 读取用户基本信息 | ||
365 | */ | ||
366 | weixin.getUserInfo = function (callback) { | ||
367 | if (typeof callback != "function") { | ||
368 | return; | ||
369 | } | ||
370 | _get_user_info_by_openid(callback); | ||
371 | } | ||
372 | |||
373 | /** | ||
374 | * 这个是用户授权后,从微信端读取用户基本信息。这个接口需要用户关注公众号 | ||
375 | */ | ||
376 | weixin.getCgiUserInfo = function (callback) { | ||
377 | if (typeof callback != "function") { | ||
378 | return; | ||
379 | } | ||
380 | let openId = tools._get_token(); | ||
381 | let wxAppId = tools._get_wx_app_id(); | ||
382 | tools._get(_request_url.wx_user_info, { | ||
383 | wxAppId: wxAppId, | ||
384 | openId: openId | ||
385 | }, null, function (response) { | ||
386 | let res = tools._handle_response(response); | ||
387 | callback(res && res.content || null); | ||
388 | }) | ||
389 | } | ||
390 | |||
391 | |||
392 | /** | ||
393 | * 获取位置 | ||
394 | * @param {*} title | ||
395 | * @param {*} link | ||
396 | * @param {*} imageUrl | ||
397 | * @param {*} succ | ||
398 | */ | ||
399 | weixin.getLocation = function (callback) { | ||
400 | wx.ready(function () { | ||
401 | wx.getLocation({ | ||
402 | type: 'wgs84', // 默认为wgs84的 gps 坐标,如果要返回直接给 openLocation 用的火星坐标,可传入'gcj02' | ||
403 | success: function (res) { | ||
404 | var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90 | ||
405 | var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。 | ||
406 | var speed = res.speed; // 速度,以米/每秒计 | ||
407 | var accuracy = res.accuracy; // 位置精度 | ||
408 | (typeof callback == "function") && callback(res); | ||
409 | }, | ||
410 | fail: function (err) { | ||
411 | console.log("err:", err); | ||
412 | } | ||
413 | }); | ||
414 | }); | ||
415 | } | ||
416 | |||
417 | /** | ||
418 | * 通过openid读取用户基本信息 | ||
419 | * | ||
420 | * @param {function} callback | ||
421 | */ | ||
422 | function _get_user_info_by_openid(callback) { | ||
423 | let openId = tools._get_token(); | ||
424 | let wxAppId = tools._get_wx_app_id(); | ||
425 | |||
426 | tools._get(_request_url.wx_sns_user_info, { | ||
427 | wxAppId: wxAppId, | ||
428 | openId: openId | ||
429 | }, null, function (response) { | ||
430 | let res = tools._handle_response(response); | ||
431 | if (typeof callback == "function") { | ||
432 | callback(res.content); | ||
433 | } | ||
434 | }) | ||
435 | } | ||
436 | |||
437 | /** | ||
438 | * 从cookie中读取信息 | ||
439 | */ | ||
440 | function _get_user_info_from_cookie() { | ||
441 | let data = tools._get_cookie("pl_info_" + _app_id); | ||
442 | if (tools._init_aes()) { | ||
443 | let infoStr = tools._aes_decrypt(data); | ||
444 | return infoStr ? JSON.parse(infoStr) : null | ||
445 | } | ||
446 | return null; | ||
447 | } | ||
448 | |||
449 | return weixin; | ||
450 | |||
451 | } | ||
452 | |||
453 | KD.biz = function () { | ||
454 | let biz = {}; | ||
455 | let tools = KD._tools; | ||
456 | |||
457 | /** | ||
458 | * 统计接口 | ||
459 | * | ||
460 | * @param {String} channelCode 渠道编号 | ||
461 | * @param {String} statClassify 统计类型,可见统计表定义 | ||
462 | * @param {String} statKey 统计标识,可见统计表定义 | ||
463 | * @param {String} primaryKey 唯一标识,如用户标识、按钮标识 | ||
464 | */ | ||
465 | biz.stat = function (channelCode, statClassify, statKey, primaryKey) { | ||
466 | let form = { | ||
467 | aid: _app_id, | ||
468 | cc: !channelCode || channelCode == undefined ? "" : channelCode, //渠道 | ||
469 | sc: !statClassify || statClassify == undefined ? "" : statClassify, //统计类型 | ||
470 | sk: !statKey || statKey == undefined ? "" : statKey, //统计key | ||
471 | pc: !primaryKey || primaryKey == undefined ? "" : primaryKey //用户标识 | ||
472 | } | ||
473 | |||
474 | let headers = tools._init_headers(); | ||
475 | |||
476 | tools._get(_request_url.stat, form, headers, function (response) {}) | ||
477 | } | ||
478 | |||
479 | return biz; | ||
480 | } | ||
481 | |||
482 | })(); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
public/static/js/kd/kd.js
0 → 100644
1 | let appId = 'e13baf8d4a0d468eae005935332c5429'; | ||
2 | let appKey = '1c60d1543db640e5970ffa4a794eb5c6'; | ||
3 | KD.init(appId, appKey); | ||
4 | let weixin = new KD.weixin(); | ||
5 | weixin.initConfig(); | ||
6 | // window.weixin = weixin; | ||
7 | let openId = weixin.getOpenId(); | ||
8 | window.openId = openId; | ||
9 | window.openid = openId; | ||
10 | window.wxUserInfo = null; | ||
11 | |||
12 | let urlShortCode = 's2n7/'; | ||
13 | let href = location.href; | ||
14 | if (href.indexOf("192.168.") != -1 || href.indexOf("172.20.") != -1) { | ||
15 | urlShortCode = ""; | ||
16 | } | ||
17 | let domain = `${location.protocol}//${document.domain}/${urlShortCode}`; | ||
18 | let shareTitle = ""; | ||
19 | let shareDesc = ""; | ||
20 | let shareLink = `${domain}index.html`; | ||
21 | let shareImgUrl = `${domain}share.png`; | ||
22 | |||
23 | window.shareCodeLink = shareLink; | ||
24 | |||
25 | var KdIns = window.KdIns || ({}); | ||
26 | // 设置分享 | ||
27 | KdIns.setShare = function (title, desc, link, imgUrl) { | ||
28 | if (!title) title = shareTitle; | ||
29 | if (!desc) desc = shareDesc; | ||
30 | if (!link) link = shareLink; | ||
31 | if (!imgUrl) imgUrl = shareImgUrl; | ||
32 | weixin.setShare(title, desc, link, imgUrl, (pos) => {}) | ||
33 | } | ||
34 | |||
35 | console.log("domain:", domain); | ||
36 | KdIns.setShare(``, ``, ``, ``); | ||
37 | |||
38 | // KdIns.setShareShareCode = function (shareCode) { | ||
39 | // let shareCodeLink = `${shareLink}#/coop?shareCode=${shareCode}`; | ||
40 | // window.shareCodeLink = shareCodeLink; | ||
41 | // KdIns.setShare(``, ``, shareCodeLink, ``); | ||
42 | // } | ||
43 | |||
44 | // KdIns.getShareLink = function (shareCode) { | ||
45 | // let shareCodeLink = `${shareLink}#/coop?shareCode=${shareCode}`; | ||
46 | // return shareCodeLink; | ||
47 | // } | ||
48 | |||
49 | // | ||
50 | KdIns.setShareShareCode = function (shareCode) { | ||
51 | let shareCodeLink = `${shareLink}?f=coop&shareCode=${shareCode}`; | ||
52 | window.shareCodeLink = shareCodeLink; | ||
53 | KdIns.setShare(``, ``, shareCodeLink, ``); | ||
54 | } | ||
55 | KdIns.getShareLink = function (shareCode) { | ||
56 | let shareCodeLink = `${shareLink}?f=coop&shareCode=${shareCode}`; | ||
57 | return shareCodeLink; | ||
58 | } | ||
59 | |||
60 | |||
61 | // 读取微信身份 | ||
62 | KdIns.getUserInfo = function () { | ||
63 | return new Promise((resolve, reject) => { | ||
64 | weixin.getUserInfo((res) => { | ||
65 | window.wxUserInfo = res; | ||
66 | window.wxUserInfo.avatar = window.wxUserInfo.headimgurl; | ||
67 | resolve(res); | ||
68 | }); | ||
69 | }); | ||
70 | } | ||
71 | |||
72 | // 读取微信身份CGI模式,需要用户显示授权后才能获得数据。获取信息中包含了用户的关注信息与unionid | ||
73 | KdIns.getCgiUserInfo = function () { | ||
74 | return new Promise((resolve, reject) => { | ||
75 | weixin.getCgiUserInfo((res) => { | ||
76 | resolve(res); | ||
77 | }); | ||
78 | }); | ||
79 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
public/static/js/weixin/jweixin-1.1.0.js
0 → 100644
1 | !function(e,n){"function"==typeof define&&(define.amd||define.cmd)?define(function(){return n(e)}):n(e,!0)}(this,function(e,n){function i(n,i,t){e.WeixinJSBridge?WeixinJSBridge.invoke(n,o(i),function(e){c(n,e,t)}):u(n,t)}function t(n,i,t){e.WeixinJSBridge?WeixinJSBridge.on(n,function(e){t&&t.trigger&&t.trigger(e),c(n,e,i)}):t?u(n,t):u(n,i)}function o(e){return e=e||{},e.appId=P.appId,e.verifyAppId=P.appId,e.verifySignType="sha1",e.verifyTimestamp=P.timestamp+"",e.verifyNonceStr=P.nonceStr,e.verifySignature=P.signature,e}function r(e){return{timeStamp:e.timestamp+"",nonceStr:e.nonceStr,package:e.package,paySign:e.paySign,signType:e.signType||"SHA1"}}function a(e){return e.postalCode=e.addressPostalCode,delete e.addressPostalCode,e.provinceName=e.proviceFirstStageName,delete e.proviceFirstStageName,e.cityName=e.addressCitySecondStageName,delete e.addressCitySecondStageName,e.countryName=e.addressCountiesThirdStageName,delete e.addressCountiesThirdStageName,e.detailInfo=e.addressDetailInfo,delete e.addressDetailInfo,e}function c(e,n,i){"openEnterpriseChat"==e&&(n.errCode=n.err_code),delete n.err_code,delete n.err_desc,delete n.err_detail;var t=n.errMsg;t||(t=n.err_msg,delete n.err_msg,t=s(e,t),n.errMsg=t),(i=i||{})._complete&&(i._complete(n),delete i._complete),t=n.errMsg||"",P.debug&&!i.isInnerInvoke&&alert(JSON.stringify(n));var o=t.indexOf(":");switch(t.substring(o+1)){case"ok":i.success&&i.success(n);break;case"cancel":i.cancel&&i.cancel(n);break;default:i.fail&&i.fail(n)}i.complete&&i.complete(n)}function s(e,n){var i=e,t=h[i];t&&(i=t);var o="ok";if(n){var r=n.indexOf(":");"confirm"==(o=n.substring(r+1))&&(o="ok"),"failed"==o&&(o="fail"),-1!=o.indexOf("failed_")&&(o=o.substring(7)),-1!=o.indexOf("fail_")&&(o=o.substring(5)),"access denied"!=(o=(o=o.replace(/_/g," ")).toLowerCase())&&"no permission to execute"!=o||(o="permission denied"),"config"==i&&"function not exist"==o&&(o="ok"),""==o&&(o="fail")}return n=i+":"+o}function d(e){if(e){for(var n=0,i=e.length;n<i;++n){var t=e[n],o=g[t];o&&(e[n]=o)}return e}}function u(e,n){if(!(!P.debug||n&&n.isInnerInvoke)){var i=h[e];i&&(e=i),n&&n._complete&&delete n._complete,console.log('"'+e+'",',n||"")}}function l(e){if(!(I||T||P.debug||C<"6.0.2"||x.systemType<0)){var n=new Image;x.appId=P.appId,x.initTime=V.initEndTime-V.initStartTime,x.preVerifyTime=V.preVerifyEndTime-V.preVerifyStartTime,b.getNetworkType({isInnerInvoke:!0,success:function(e){x.networkType=e.networkType;var i="https://open.weixin.qq.com/sdk/report?v="+x.version+"&o="+x.isPreVerifyOk+"&s="+x.systemType+"&c="+x.clientVersion+"&a="+x.appId+"&n="+x.networkType+"&i="+x.initTime+"&p="+x.preVerifyTime+"&u="+x.url;n.src=i}})}}function p(){return(new Date).getTime()}function f(n){w&&(e.WeixinJSBridge?n():S.addEventListener&&S.addEventListener("WeixinJSBridgeReady",n,!1))}function m(){b.invoke||(b.invoke=function(n,i,t){e.WeixinJSBridge&&WeixinJSBridge.invoke(n,o(i),t)},b.on=function(n,i){e.WeixinJSBridge&&WeixinJSBridge.on(n,i)})}if(!e.jWeixin){var g={config:"preVerifyJSAPI",onMenuShareTimeline:"menu:share:timeline",onMenuShareAppMessage:"menu:share:appmessage",onMenuShareQQ:"menu:share:qq",onMenuShareWeibo:"menu:share:weiboApp",onMenuShareQZone:"menu:share:QZone",previewImage:"imagePreview",getLocation:"geoLocation",openProductSpecificView:"openProductViewWithPid",addCard:"batchAddCard",openCard:"batchViewCard",chooseWXPay:"getBrandWCPayRequest",openEnterpriseRedPacket:"getRecevieBizHongBaoRequest",startSearchBeacons:"startMonitoringBeacons",stopSearchBeacons:"stopMonitoringBeacons",onSearchBeacons:"onBeaconsInRange",consumeAndShareCard:"consumedShareCard",openAddress:"editAddress"},h=function(){var e={};for(var n in g)e[g[n]]=n;return e}(),S=e.document,y=S.title,v=navigator.userAgent.toLowerCase(),_=navigator.platform.toLowerCase(),I=!(!_.match("mac")&&!_.match("win")),T=-1!=v.indexOf("wxdebugger"),w=-1!=v.indexOf("micromessenger"),k=-1!=v.indexOf("android"),M=-1!=v.indexOf("iphone")||-1!=v.indexOf("ipad"),C=function(){var e=v.match(/micromessenger\/(\d+\.\d+\.\d+)/)||v.match(/micromessenger\/(\d+\.\d+)/);return e?e[1]:""}(),V={initStartTime:p(),initEndTime:0,preVerifyStartTime:0,preVerifyEndTime:0},x={version:1,appId:"",initTime:0,preVerifyTime:0,networkType:"",isPreVerifyOk:1,systemType:M?1:k?2:-1,clientVersion:C,url:encodeURIComponent(location.href)},P={},A={_completes:[]},B={state:0,data:{}};f(function(){V.initEndTime=p()});var b={config:function(e){P=e,u("config",e);var n=!1!==P.check;f(function(){if(n)i(g.config,{verifyJsApiList:d(P.jsApiList)},function(){A._complete=function(e){V.preVerifyEndTime=p(),B.state=1,B.data=e},A.success=function(e){x.isPreVerifyOk=0},A.fail=function(e){A._fail?A._fail(e):B.state=-1};var e=A._completes;return e.push(function(){l()}),A.complete=function(n){for(var i=0,t=e.length;i<t;++i)e[i]();A._completes=[]},A}()),V.preVerifyStartTime=p();else{B.state=1;for(var e=A._completes,t=0,o=e.length;t<o;++t)e[t]();A._completes=[]}}),P.beta&&m()},ready:function(e){0!=B.state?e():(A._completes.push(e),!w&&P.debug&&e())},error:function(e){C<"6.0.2"||(-1==B.state?e(B.data):A._fail=e)},checkJsApi:function(e){var n=function(e){var n=e.checkResult;for(var i in n){var t=h[i];t&&(n[t]=n[i],delete n[i])}return e};i("checkJsApi",{jsApiList:d(e.jsApiList)},(e._complete=function(e){if(k){var i=e.checkResult;i&&(e.checkResult=JSON.parse(i))}e=n(e)},e))},onMenuShareTimeline:function(e){t(g.onMenuShareTimeline,{complete:function(){i("shareTimeline",{title:e.title||y,desc:e.title||y,img_url:e.imgUrl||"",link:e.link||location.href,type:e.type||"link",data_url:e.dataUrl||""},e)}},e)},onMenuShareAppMessage:function(e){t(g.onMenuShareAppMessage,{complete:function(n){"favorite"===n.scene?i("sendAppMessage",{title:e.title||y,desc:e.desc||"",link:e.link||location.href,img_url:e.imgUrl||"",type:e.type||"link",data_url:e.dataUrl||""}):i("sendAppMessage",{title:e.title||y,desc:e.desc||"",link:e.link||location.href,img_url:e.imgUrl||"",type:e.type||"link",data_url:e.dataUrl||""},e)}},e)},onMenuShareQQ:function(e){t(g.onMenuShareQQ,{complete:function(){i("shareQQ",{title:e.title||y,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},onMenuShareWeibo:function(e){t(g.onMenuShareWeibo,{complete:function(){i("shareWeiboApp",{title:e.title||y,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},onMenuShareQZone:function(e){t(g.onMenuShareQZone,{complete:function(){i("shareQZone",{title:e.title||y,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},startRecord:function(e){i("startRecord",{},e)},stopRecord:function(e){i("stopRecord",{},e)},onVoiceRecordEnd:function(e){t("onVoiceRecordEnd",e)},playVoice:function(e){i("playVoice",{localId:e.localId},e)},pauseVoice:function(e){i("pauseVoice",{localId:e.localId},e)},stopVoice:function(e){i("stopVoice",{localId:e.localId},e)},onVoicePlayEnd:function(e){t("onVoicePlayEnd",e)},uploadVoice:function(e){i("uploadVoice",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},downloadVoice:function(e){i("downloadVoice",{serverId:e.serverId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},translateVoice:function(e){i("translateVoice",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},chooseImage:function(e){i("chooseImage",{scene:"1|2",count:e.count||9,sizeType:e.sizeType||["original","compressed"],sourceType:e.sourceType||["album","camera"]},(e._complete=function(e){if(k){var n=e.localIds;try{n&&(e.localIds=JSON.parse(n))}catch(e){}}},e))},previewImage:function(e){i(g.previewImage,{current:e.current,urls:e.urls},e)},uploadImage:function(e){i("uploadImage",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},downloadImage:function(e){i("downloadImage",{serverId:e.serverId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},getNetworkType:function(e){var n=function(e){var n=e.errMsg;e.errMsg="getNetworkType:ok";var i=e.subtype;if(delete e.subtype,i)e.networkType=i;else{var t=n.indexOf(":"),o=n.substring(t+1);switch(o){case"wifi":case"edge":case"wwan":e.networkType=o;break;default:e.errMsg="getNetworkType:fail"}}return e};i("getNetworkType",{},(e._complete=function(e){e=n(e)},e))},openLocation:function(e){i("openLocation",{latitude:e.latitude,longitude:e.longitude,name:e.name||"",address:e.address||"",scale:e.scale||28,infoUrl:e.infoUrl||""},e)},getLocation:function(e){e=e||{},i(g.getLocation,{type:e.type||"wgs84"},(e._complete=function(e){delete e.type},e))},hideOptionMenu:function(e){i("hideOptionMenu",{},e)},showOptionMenu:function(e){i("showOptionMenu",{},e)},closeWindow:function(e){i("closeWindow",{},e=e||{})},hideMenuItems:function(e){i("hideMenuItems",{menuList:e.menuList},e)},showMenuItems:function(e){i("showMenuItems",{menuList:e.menuList},e)},hideAllNonBaseMenuItem:function(e){i("hideAllNonBaseMenuItem",{},e)},showAllNonBaseMenuItem:function(e){i("showAllNonBaseMenuItem",{},e)},scanQRCode:function(e){i("scanQRCode",{needResult:(e=e||{}).needResult||0,scanType:e.scanType||["qrCode","barCode"]},(e._complete=function(e){if(M){var n=e.resultStr;if(n){var i=JSON.parse(n);e.resultStr=i&&i.scan_code&&i.scan_code.scan_result}}},e))},openAddress:function(e){i(g.openAddress,{},(e._complete=function(e){e=a(e)},e))},openProductSpecificView:function(e){i(g.openProductSpecificView,{pid:e.productId,view_type:e.viewType||0,ext_info:e.extInfo},e)},addCard:function(e){for(var n=e.cardList,t=[],o=0,r=n.length;o<r;++o){var a=n[o],c={card_id:a.cardId,card_ext:a.cardExt};t.push(c)}i(g.addCard,{card_list:t},(e._complete=function(e){var n=e.card_list;if(n){for(var i=0,t=(n=JSON.parse(n)).length;i<t;++i){var o=n[i];o.cardId=o.card_id,o.cardExt=o.card_ext,o.isSuccess=!!o.is_succ,delete o.card_id,delete o.card_ext,delete o.is_succ}e.cardList=n,delete e.card_list}},e))},chooseCard:function(e){i("chooseCard",{app_id:P.appId,location_id:e.shopId||"",sign_type:e.signType||"SHA1",card_id:e.cardId||"",card_type:e.cardType||"",card_sign:e.cardSign,time_stamp:e.timestamp+"",nonce_str:e.nonceStr},(e._complete=function(e){e.cardList=e.choose_card_info,delete e.choose_card_info},e))},openCard:function(e){for(var n=e.cardList,t=[],o=0,r=n.length;o<r;++o){var a=n[o],c={card_id:a.cardId,code:a.code};t.push(c)}i(g.openCard,{card_list:t},e)},consumeAndShareCard:function(e){i(g.consumeAndShareCard,{consumedCardId:e.cardId,consumedCode:e.code},e)},chooseWXPay:function(e){i(g.chooseWXPay,r(e),e)},openEnterpriseRedPacket:function(e){i(g.openEnterpriseRedPacket,r(e),e)},startSearchBeacons:function(e){i(g.startSearchBeacons,{ticket:e.ticket},e)},stopSearchBeacons:function(e){i(g.stopSearchBeacons,{},e)},onSearchBeacons:function(e){t(g.onSearchBeacons,e)},openEnterpriseChat:function(e){i("openEnterpriseChat",{useridlist:e.userIds,chatname:e.groupName},e)}};return n&&(e.wx=e.jWeixin=b),b}}); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
public/static/js/weixin/jweixin-1.6.0.js
0 → 100644
1 | !function(e,n){"function"==typeof define&&(define.amd||define.cmd)?define(function(){return n(e)}):n(e,!0)}(this,function(o,e){if(!o.jWeixin){var n,c={config:"preVerifyJSAPI",onMenuShareTimeline:"menu:share:timeline",onMenuShareAppMessage:"menu:share:appmessage",onMenuShareQQ:"menu:share:qq",onMenuShareWeibo:"menu:share:weiboApp",onMenuShareQZone:"menu:share:QZone",previewImage:"imagePreview",getLocation:"geoLocation",openProductSpecificView:"openProductViewWithPid",addCard:"batchAddCard",openCard:"batchViewCard",chooseWXPay:"getBrandWCPayRequest",openEnterpriseRedPacket:"getRecevieBizHongBaoRequest",startSearchBeacons:"startMonitoringBeacons",stopSearchBeacons:"stopMonitoringBeacons",onSearchBeacons:"onBeaconsInRange",consumeAndShareCard:"consumedShareCard",openAddress:"editAddress"},a=function(){var e={};for(var n in c)e[c[n]]=n;return e}(),i=o.document,t=i.title,r=navigator.userAgent.toLowerCase(),s=navigator.platform.toLowerCase(),d=!(!s.match("mac")&&!s.match("win")),u=-1!=r.indexOf("wxdebugger"),l=-1!=r.indexOf("micromessenger"),p=-1!=r.indexOf("android"),f=-1!=r.indexOf("iphone")||-1!=r.indexOf("ipad"),m=(n=r.match(/micromessenger\/(\d+\.\d+\.\d+)/)||r.match(/micromessenger\/(\d+\.\d+)/))?n[1]:"",g={initStartTime:L(),initEndTime:0,preVerifyStartTime:0,preVerifyEndTime:0},h={version:1,appId:"",initTime:0,preVerifyTime:0,networkType:"",isPreVerifyOk:1,systemType:f?1:p?2:-1,clientVersion:m,url:encodeURIComponent(location.href)},v={},S={_completes:[]},y={state:0,data:{}};O(function(){g.initEndTime=L()});var I=!1,_=[],w={config:function(e){B("config",v=e);var t=!1!==v.check;O(function(){if(t)M(c.config,{verifyJsApiList:C(v.jsApiList),verifyOpenTagList:C(v.openTagList)},function(){S._complete=function(e){g.preVerifyEndTime=L(),y.state=1,y.data=e},S.success=function(e){h.isPreVerifyOk=0},S.fail=function(e){S._fail?S._fail(e):y.state=-1};var t=S._completes;return t.push(function(){!function(){if(!(d||u||v.debug||m<"6.0.2"||h.systemType<0)){var i=new Image;h.appId=v.appId,h.initTime=g.initEndTime-g.initStartTime,h.preVerifyTime=g.preVerifyEndTime-g.preVerifyStartTime,w.getNetworkType({isInnerInvoke:!0,success:function(e){h.networkType=e.networkType;var n="https://open.weixin.qq.com/sdk/report?v="+h.version+"&o="+h.isPreVerifyOk+"&s="+h.systemType+"&c="+h.clientVersion+"&a="+h.appId+"&n="+h.networkType+"&i="+h.initTime+"&p="+h.preVerifyTime+"&u="+h.url;i.src=n}})}}()}),S.complete=function(e){for(var n=0,i=t.length;n<i;++n)t[n]();S._completes=[]},S}()),g.preVerifyStartTime=L();else{y.state=1;for(var e=S._completes,n=0,i=e.length;n<i;++n)e[n]();S._completes=[]}}),w.invoke||(w.invoke=function(e,n,i){o.WeixinJSBridge&&WeixinJSBridge.invoke(e,x(n),i)},w.on=function(e,n){o.WeixinJSBridge&&WeixinJSBridge.on(e,n)})},ready:function(e){0!=y.state?e():(S._completes.push(e),!l&&v.debug&&e())},error:function(e){m<"6.0.2"||(-1==y.state?e(y.data):S._fail=e)},checkJsApi:function(e){M("checkJsApi",{jsApiList:C(e.jsApiList)},(e._complete=function(e){if(p){var n=e.checkResult;n&&(e.checkResult=JSON.parse(n))}e=function(e){var n=e.checkResult;for(var i in n){var t=a[i];t&&(n[t]=n[i],delete n[i])}return e}(e)},e))},onMenuShareTimeline:function(e){P(c.onMenuShareTimeline,{complete:function(){M("shareTimeline",{title:e.title||t,desc:e.title||t,img_url:e.imgUrl||"",link:e.link||location.href,type:e.type||"link",data_url:e.dataUrl||""},e)}},e)},onMenuShareAppMessage:function(n){P(c.onMenuShareAppMessage,{complete:function(e){"favorite"===e.scene?M("sendAppMessage",{title:n.title||t,desc:n.desc||"",link:n.link||location.href,img_url:n.imgUrl||"",type:n.type||"link",data_url:n.dataUrl||""}):M("sendAppMessage",{title:n.title||t,desc:n.desc||"",link:n.link||location.href,img_url:n.imgUrl||"",type:n.type||"link",data_url:n.dataUrl||""},n)}},n)},onMenuShareQQ:function(e){P(c.onMenuShareQQ,{complete:function(){M("shareQQ",{title:e.title||t,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},onMenuShareWeibo:function(e){P(c.onMenuShareWeibo,{complete:function(){M("shareWeiboApp",{title:e.title||t,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},onMenuShareQZone:function(e){P(c.onMenuShareQZone,{complete:function(){M("shareQZone",{title:e.title||t,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},updateTimelineShareData:function(e){M("updateTimelineShareData",{title:e.title,link:e.link,imgUrl:e.imgUrl},e)},updateAppMessageShareData:function(e){M("updateAppMessageShareData",{title:e.title,desc:e.desc,link:e.link,imgUrl:e.imgUrl},e)},startRecord:function(e){M("startRecord",{},e)},stopRecord:function(e){M("stopRecord",{},e)},onVoiceRecordEnd:function(e){P("onVoiceRecordEnd",e)},playVoice:function(e){M("playVoice",{localId:e.localId},e)},pauseVoice:function(e){M("pauseVoice",{localId:e.localId},e)},stopVoice:function(e){M("stopVoice",{localId:e.localId},e)},onVoicePlayEnd:function(e){P("onVoicePlayEnd",e)},uploadVoice:function(e){M("uploadVoice",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},downloadVoice:function(e){M("downloadVoice",{serverId:e.serverId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},translateVoice:function(e){M("translateVoice",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},chooseImage:function(e){M("chooseImage",{scene:"1|2",count:e.count||9,sizeType:e.sizeType||["original","compressed"],sourceType:e.sourceType||["album","camera"]},(e._complete=function(e){if(p){var n=e.localIds;try{n&&(e.localIds=JSON.parse(n))}catch(e){}}},e))},getLocation:function(e){},previewImage:function(e){M(c.previewImage,{current:e.current,urls:e.urls},e)},uploadImage:function(e){M("uploadImage",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},downloadImage:function(e){M("downloadImage",{serverId:e.serverId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},getLocalImgData:function(e){!1===I?(I=!0,M("getLocalImgData",{localId:e.localId},(e._complete=function(e){if(I=!1,0<_.length){var n=_.shift();wx.getLocalImgData(n)}},e))):_.push(e)},getNetworkType:function(e){M("getNetworkType",{},(e._complete=function(e){e=function(e){var n=e.errMsg;e.errMsg="getNetworkType:ok";var i=e.subtype;if(delete e.subtype,i)e.networkType=i;else{var t=n.indexOf(":"),o=n.substring(t+1);switch(o){case"wifi":case"edge":case"wwan":e.networkType=o;break;default:e.errMsg="getNetworkType:fail"}}return e}(e)},e))},openLocation:function(e){M("openLocation",{latitude:e.latitude,longitude:e.longitude,name:e.name||"",address:e.address||"",scale:e.scale||28,infoUrl:e.infoUrl||""},e)},getLocation:function(e){M(c.getLocation,{type:(e=e||{}).type||"wgs84"},(e._complete=function(e){delete e.type},e))},hideOptionMenu:function(e){M("hideOptionMenu",{},e)},showOptionMenu:function(e){M("showOptionMenu",{},e)},closeWindow:function(e){M("closeWindow",{},e=e||{})},hideMenuItems:function(e){M("hideMenuItems",{menuList:e.menuList},e)},showMenuItems:function(e){M("showMenuItems",{menuList:e.menuList},e)},hideAllNonBaseMenuItem:function(e){M("hideAllNonBaseMenuItem",{},e)},showAllNonBaseMenuItem:function(e){M("showAllNonBaseMenuItem",{},e)},scanQRCode:function(e){M("scanQRCode",{needResult:(e=e||{}).needResult||0,scanType:e.scanType||["qrCode","barCode"]},(e._complete=function(e){if(f){var n=e.resultStr;if(n){var i=JSON.parse(n);e.resultStr=i&&i.scan_code&&i.scan_code.scan_result}}},e))},openAddress:function(e){M(c.openAddress,{},(e._complete=function(e){e=function(e){return e.postalCode=e.addressPostalCode,delete e.addressPostalCode,e.provinceName=e.proviceFirstStageName,delete e.proviceFirstStageName,e.cityName=e.addressCitySecondStageName,delete e.addressCitySecondStageName,e.countryName=e.addressCountiesThirdStageName,delete e.addressCountiesThirdStageName,e.detailInfo=e.addressDetailInfo,delete e.addressDetailInfo,e}(e)},e))},openProductSpecificView:function(e){M(c.openProductSpecificView,{pid:e.productId,view_type:e.viewType||0,ext_info:e.extInfo},e)},addCard:function(e){for(var n=e.cardList,i=[],t=0,o=n.length;t<o;++t){var r=n[t],a={card_id:r.cardId,card_ext:r.cardExt};i.push(a)}M(c.addCard,{card_list:i},(e._complete=function(e){var n=e.card_list;if(n){for(var i=0,t=(n=JSON.parse(n)).length;i<t;++i){var o=n[i];o.cardId=o.card_id,o.cardExt=o.card_ext,o.isSuccess=!!o.is_succ,delete o.card_id,delete o.card_ext,delete o.is_succ}e.cardList=n,delete e.card_list}},e))},chooseCard:function(e){M("chooseCard",{app_id:v.appId,location_id:e.shopId||"",sign_type:e.signType||"SHA1",card_id:e.cardId||"",card_type:e.cardType||"",card_sign:e.cardSign,time_stamp:e.timestamp+"",nonce_str:e.nonceStr},(e._complete=function(e){e.cardList=e.choose_card_info,delete e.choose_card_info},e))},openCard:function(e){for(var n=e.cardList,i=[],t=0,o=n.length;t<o;++t){var r=n[t],a={card_id:r.cardId,code:r.code};i.push(a)}M(c.openCard,{card_list:i},e)},consumeAndShareCard:function(e){M(c.consumeAndShareCard,{consumedCardId:e.cardId,consumedCode:e.code},e)},chooseWXPay:function(e){M(c.chooseWXPay,V(e),e)},openEnterpriseRedPacket:function(e){M(c.openEnterpriseRedPacket,V(e),e)},startSearchBeacons:function(e){M(c.startSearchBeacons,{ticket:e.ticket},e)},stopSearchBeacons:function(e){M(c.stopSearchBeacons,{},e)},onSearchBeacons:function(e){P(c.onSearchBeacons,e)},openEnterpriseChat:function(e){M("openEnterpriseChat",{useridlist:e.userIds,chatname:e.groupName},e)},launchMiniProgram:function(e){M("launchMiniProgram",{targetAppId:e.targetAppId,path:function(e){if("string"==typeof e&&0<e.length){var n=e.split("?")[0],i=e.split("?")[1];return n+=".html",void 0!==i?n+"?"+i:n}}(e.path),envVersion:e.envVersion},e)},openBusinessView:function(e){M("openBusinessView",{businessType:e.businessType,queryString:e.queryString||"",envVersion:e.envVersion},(e._complete=function(n){if(p){var e=n.extraData;if(e)try{n.extraData=JSON.parse(e)}catch(e){n.extraData={}}}},e))},miniProgram:{navigateBack:function(e){e=e||{},O(function(){M("invokeMiniProgramAPI",{name:"navigateBack",arg:{delta:e.delta||1}},e)})},navigateTo:function(e){O(function(){M("invokeMiniProgramAPI",{name:"navigateTo",arg:{url:e.url}},e)})},redirectTo:function(e){O(function(){M("invokeMiniProgramAPI",{name:"redirectTo",arg:{url:e.url}},e)})},switchTab:function(e){O(function(){M("invokeMiniProgramAPI",{name:"switchTab",arg:{url:e.url}},e)})},reLaunch:function(e){O(function(){M("invokeMiniProgramAPI",{name:"reLaunch",arg:{url:e.url}},e)})},postMessage:function(e){O(function(){M("invokeMiniProgramAPI",{name:"postMessage",arg:e.data||{}},e)})},getEnv:function(e){O(function(){e({miniprogram:"miniprogram"===o.__wxjs_environment})})}}},T=1,k={};return i.addEventListener("error",function(e){if(!p){var n=e.target,i=n.tagName,t=n.src;if("IMG"==i||"VIDEO"==i||"AUDIO"==i||"SOURCE"==i)if(-1!=t.indexOf("wxlocalresource://")){e.preventDefault(),e.stopPropagation();var o=n["wx-id"];if(o||(o=T++,n["wx-id"]=o),k[o])return;k[o]=!0,wx.ready(function(){wx.getLocalImgData({localId:t,success:function(e){n.src=e.localData}})})}}},!0),i.addEventListener("load",function(e){if(!p){var n=e.target,i=n.tagName;n.src;if("IMG"==i||"VIDEO"==i||"AUDIO"==i||"SOURCE"==i){var t=n["wx-id"];t&&(k[t]=!1)}}},!0),e&&(o.wx=o.jWeixin=w),w}function M(n,e,i){o.WeixinJSBridge?WeixinJSBridge.invoke(n,x(e),function(e){A(n,e,i)}):B(n,i)}function P(n,i,t){o.WeixinJSBridge?WeixinJSBridge.on(n,function(e){t&&t.trigger&&t.trigger(e),A(n,e,i)}):B(n,t||i)}function x(e){return(e=e||{}).appId=v.appId,e.verifyAppId=v.appId,e.verifySignType="sha1",e.verifyTimestamp=v.timestamp+"",e.verifyNonceStr=v.nonceStr,e.verifySignature=v.signature,e}function V(e){return{timeStamp:e.timestamp+"",nonceStr:e.nonceStr,package:e.package,paySign:e.paySign,signType:e.signType||"SHA1"}}function A(e,n,i){"openEnterpriseChat"!=e&&"openBusinessView"!==e||(n.errCode=n.err_code),delete n.err_code,delete n.err_desc,delete n.err_detail;var t=n.errMsg;t||(t=n.err_msg,delete n.err_msg,t=function(e,n){var i=e,t=a[i];t&&(i=t);var o="ok";if(n){var r=n.indexOf(":");"confirm"==(o=n.substring(r+1))&&(o="ok"),"failed"==o&&(o="fail"),-1!=o.indexOf("failed_")&&(o=o.substring(7)),-1!=o.indexOf("fail_")&&(o=o.substring(5)),"access denied"!=(o=(o=o.replace(/_/g," ")).toLowerCase())&&"no permission to execute"!=o||(o="permission denied"),"config"==i&&"function not exist"==o&&(o="ok"),""==o&&(o="fail")}return n=i+":"+o}(e,t),n.errMsg=t),(i=i||{})._complete&&(i._complete(n),delete i._complete),t=n.errMsg||"",v.debug&&!i.isInnerInvoke&&alert(JSON.stringify(n));var o=t.indexOf(":");switch(t.substring(o+1)){case"ok":i.success&&i.success(n);break;case"cancel":i.cancel&&i.cancel(n);break;default:i.fail&&i.fail(n)}i.complete&&i.complete(n)}function C(e){if(e){for(var n=0,i=e.length;n<i;++n){var t=e[n],o=c[t];o&&(e[n]=o)}return e}}function B(e,n){if(!(!v.debug||n&&n.isInnerInvoke)){var i=a[e];i&&(e=i),n&&n._complete&&delete n._complete,console.log('"'+e+'",',n||"")}}function L(){return(new Date).getTime()}function O(e){l&&(o.WeixinJSBridge?e():i.addEventListener&&i.addEventListener("WeixinJSBridgeReady",e,!1))}}); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -35,8 +35,7 @@ export default { | ... | @@ -35,8 +35,7 @@ export default { |
35 | }, | 35 | }, |
36 | }, | 36 | }, |
37 | mounted() { | 37 | mounted() { |
38 | console.log("111"); | 38 | // this.initWaterMark(); |
39 | this.initWaterMark(); | ||
40 | }, | 39 | }, |
41 | }; | 40 | }; |
42 | </script> | 41 | </script> |
... | @@ -69,21 +68,6 @@ div { | ... | @@ -69,21 +68,6 @@ div { |
69 | margin: 20px; | 68 | margin: 20px; |
70 | } | 69 | } |
71 | 70 | ||
72 | .app__title { | ||
73 | font-size: $fontSize; | ||
74 | line-height: $fontSize + 4px; | ||
75 | font-weight: bold; | ||
76 | padding-bottom: 10px; | ||
77 | margin-bottom: 20px; | ||
78 | border-bottom: 0.5px solid #eeeeee; | ||
79 | } | ||
80 | |||
81 | .app__desc { | ||
82 | font-size: $fontSizeSmaller; | ||
83 | line-height: $fontSizeSmaller + 2px; | ||
84 | margin-bottom: 20px; | ||
85 | color: $colorGray; | ||
86 | } | ||
87 | 71 | ||
88 | .app__bgc { | 72 | .app__bgc { |
89 | position: fixed; | 73 | position: fixed; | ... | ... |
1 | module.exports = { | 1 | module.exports = { |
2 | testListGet: '/xxx/xxx/list', | ||
3 | 2 | ||
3 | login: '/front/userApi/login', // 登录 | ||
4 | profile: '/front/userApi/profile', // 个人信息 | ||
5 | uploadProfile: '/front/userApi/uploadProfile', // 更新头像昵称 | ||
6 | |||
7 | |||
8 | upload: '/common/upload', // 上传文件 [x] | ||
9 | list: "xxx", | ||
10 | |||
11 | // areaQuery: 'https://api.k.wxpai.cn/bizproxy/kdapi/area', // post 区域查询 | ||
4 | 12 | ||
5 | areaQuery: 'https://api.k.wxpai.cn/bizproxy/kdapi/area', // post 区域查询 | ||
6 | } | 13 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -102,7 +102,7 @@ axios.interceptors.response.use( | ... | @@ -102,7 +102,7 @@ axios.interceptors.response.use( |
102 | /** | 102 | /** |
103 | * 分解参数&拦截请求 | 103 | * 分解参数&拦截请求 |
104 | */ | 104 | */ |
105 | function analysisParams(params) { | 105 | function analysisParams(params) { |
106 | let { | 106 | let { |
107 | url, | 107 | url, |
108 | data, | 108 | data, |
... | @@ -196,6 +196,22 @@ export const httpPost = params => { | ... | @@ -196,6 +196,22 @@ export const httpPost = params => { |
196 | data.append('path', '/pro/mzczcradmin/') | 196 | data.append('path', '/pro/mzczcradmin/') |
197 | data.append('file', file.file) | 197 | data.append('file', file.file) |
198 | */ | 198 | */ |
199 | // export const formdata = params => { | ||
200 | // let { | ||
201 | // url, | ||
202 | // data, | ||
203 | // } = params; | ||
204 | |||
205 | // let formData = new FormData(); //使用formData对象 | ||
206 | // for (let key in data) { | ||
207 | // formData.append(key, data[key]); | ||
208 | // } | ||
209 | // return axios.post(`${base}${url}`, formData, { | ||
210 | // headers: { | ||
211 | // "Content-Type": "multipart/form-data" | ||
212 | // } | ||
213 | // }).then(res => res.data.content); | ||
214 | // } | ||
199 | export const formdata = params => { | 215 | export const formdata = params => { |
200 | let { | 216 | let { |
201 | url, | 217 | url, |
... | @@ -208,13 +224,16 @@ export const formdata = params => { | ... | @@ -208,13 +224,16 @@ export const formdata = params => { |
208 | } | 224 | } |
209 | return axios.post(`${base}${url}`, formData, { | 225 | return axios.post(`${base}${url}`, formData, { |
210 | headers: { | 226 | headers: { |
211 | "Content-Type": "multipart/form-data" | 227 | "Content-Type": "multipart/form-data", |
228 | "-kd-platform-module": MODULE_CODE, | ||
229 | "-kd-platform-env": ENV | ||
212 | } | 230 | } |
213 | }).then(res => res.data.content); | 231 | }).then(res => res.data.content); |
214 | } | 232 | } |
215 | 233 | ||
216 | 234 | ||
217 | 235 | ||
236 | |||
218 | /** | 237 | /** |
219 | * 打点 | 238 | * 打点 |
220 | * @param {*} params | 239 | * @param {*} params | ... | ... |
src/common/area.js
0 → 100644
This diff could not be displayed because it is too large.
... | @@ -6,13 +6,15 @@ import store from './store' | ... | @@ -6,13 +6,15 @@ import store from './store' |
6 | import api from '@/api/api' | 6 | import api from '@/api/api' |
7 | import { | 7 | import { |
8 | httpGet, | 8 | httpGet, |
9 | httpPost | 9 | httpPost, |
10 | formdata | ||
10 | } from '@/api/fetch-api.js' | 11 | } from '@/api/fetch-api.js' |
11 | 12 | ||
12 | // import Mock from './mock' | 13 | // import Mock from './mock' |
13 | // Mock.bootstrap(); | 14 | // Mock.bootstrap(); |
14 | 15 | ||
15 | import 'amfe-flexible/index.js' | 16 | import 'amfe-flexible/index.js' |
17 | import vant from '@/utils/vant-util' | ||
16 | 18 | ||
17 | // import '@/styles/index.scss' // global css | 19 | // import '@/styles/index.scss' // global css |
18 | import '@/styles/fonticon.scss' // 图标字体 | 20 | import '@/styles/fonticon.scss' // 图标字体 |
... | @@ -22,30 +24,70 @@ import '@/assets/fonts/font.scss' // 字体引入 | ... | @@ -22,30 +24,70 @@ import '@/assets/fonts/font.scss' // 字体引入 |
22 | Vue.config.productionTip = false | 24 | Vue.config.productionTip = false |
23 | 25 | ||
24 | 26 | ||
25 | import { | 27 | |
26 | Swipe, | 28 | |
27 | SwipeItem, | 29 | // 原app节点请通过 document.getElementById('app') 获取 |
28 | Lazyload, | 30 | // routes里的component组件需要以import方式引入,否则页面创建的时候,app还没挂载。 |
29 | Tab, | 31 | |
30 | Tabs, | 32 | |
31 | Sticky, | 33 | |
32 | Popup, | 34 | // function initVue() { |
33 | Tabbar, | 35 | |
34 | TabbarItem, | 36 | // let codeSn = getQuery("c"); |
35 | Icon, | 37 | // if (process.env.NODE_ENV == "development") { |
36 | Toast, | 38 | // openid = "oDPvDjjha8EVFhJaceqxs3Bta-1k"; |
37 | Button | 39 | // } |
38 | } from 'vant'; | 40 | // console.log("openid:", openid); |
39 | 41 | // app.post({ | |
40 | Vue.use(Swipe).use(SwipeItem) | 42 | // url: app.api.login, |
41 | .use(Lazyload) | 43 | // data: { |
42 | .use(Tab).use(Tabs) | 44 | // openid: openid |
43 | .use(Sticky) | 45 | // } |
44 | .use(Popup) | 46 | // }).then((result) => { |
45 | .use(Tabbar).use(TabbarItem) | 47 | // console.log("result:", result); |
46 | .use(Icon) | 48 | // setToken(result.sessionId); |
47 | .use(Button) | 49 | // // console.log("KdIns:", KdIns); |
48 | .use(Toast); | 50 | |
51 | // // 显示授权,或者头像昵称 | ||
52 | // // if (process.env.NODE_ENV == "development") { | ||
53 | // // let wxUserInfo = {} | ||
54 | // // wxUserInfo.avatar = 'https://thirdwx.qlogo.cn/mmopen/vi_32/g5XHJelCh5ca3HbruKTM38uaOk0lqzMK4vDb7bLsUNiacRfEc7wp8wLP6GDlFicFFXZ1xAuTnSl8GfSoibPUgY1eg/132'; | ||
55 | // // wxUserInfo.nickname = "SimonFungC";; | ||
56 | // // app.post({ | ||
57 | // // url: app.api.uploadProfile, | ||
58 | // // data: wxUserInfo | ||
59 | // // }).then((result) => {}) | ||
60 | // // } else { | ||
61 | // // KdIns.getUserInfo().then((res) => { | ||
62 | // // let wxUserInfo = res; | ||
63 | // // wxUserInfo.avatar = wxUserInfo.headimgurl; | ||
64 | // // app.post({ | ||
65 | // // url: app.api.uploadProfile, | ||
66 | // // data: wxUserInfo | ||
67 | // // }).then((result) => {}) | ||
68 | // // }) | ||
69 | // // } | ||
70 | |||
71 | |||
72 | // window.vue = new Vue({ | ||
73 | // router, | ||
74 | // store, | ||
75 | // data: { | ||
76 | // isInit: false, | ||
77 | // // wxUserInfo: wxUserInfo, | ||
78 | // codeSn: codeSn, | ||
79 | // }, | ||
80 | // render: h => h(VueApp) | ||
81 | // }).$mount('#app'); | ||
82 | |||
83 | // // console.log('window.vue:',window.vue); | ||
84 | // }).catch((err) => { | ||
85 | |||
86 | // }); | ||
87 | |||
88 | // } | ||
89 | // initVue(); | ||
90 | |||
49 | 91 | ||
50 | let app = new Vue({ | 92 | let app = new Vue({ |
51 | router, | 93 | router, |
... | @@ -56,12 +98,11 @@ let app = new Vue({ | ... | @@ -56,12 +98,11 @@ let app = new Vue({ |
56 | render: h => h(VueApp) | 98 | render: h => h(VueApp) |
57 | }).$mount('#app') | 99 | }).$mount('#app') |
58 | 100 | ||
101 | |||
59 | // 挂载全局app | 102 | // 挂载全局app |
60 | app.api = api; | 103 | app.api = api; |
61 | app.get = httpGet; | 104 | app.get = httpGet; |
62 | app.post = httpPost; | 105 | app.post = httpPost; |
106 | app.uploadFile = formdata; | ||
63 | app.router = router; | 107 | app.router = router; |
64 | window.app = app; | 108 | window.app = app; |
... | \ No newline at end of file | ... | \ No newline at end of file |
65 | |||
66 | // 原app节点请通过 document.getElementById('app') 获取 | ||
67 | // routes里的component组件需要以import方式引入,否则页面创建的时候,app还没挂载。 | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
src/pages/exp/exp.js
0 → 100644
1 | import areaList from '@common/area.js' | ||
2 | import { | ||
3 | Toast | ||
4 | } from 'vant'; | ||
5 | |||
6 | export default { | ||
7 | data() { | ||
8 | return { | ||
9 | key: 'value', | ||
10 | fileList: [], | ||
11 | |||
12 | areaVisible: false, | ||
13 | areaList: [], | ||
14 | // 姓名、手机号、省市区、详细地址 | ||
15 | editable: false, | ||
16 | formData: { // 奖品信息。抽奖后显示 | ||
17 | "winCode": "", | ||
18 | "name": "", | ||
19 | "mobile": "", | ||
20 | "province": "", | ||
21 | "city": "", | ||
22 | "district": "", | ||
23 | "address": "", | ||
24 | "extData": "", | ||
25 | "prize": { // 奖品信息 | ||
26 | "prizeName": "", | ||
27 | "prizePic": "", | ||
28 | "prizeThumb": "", | ||
29 | "prizeType": "", // 如果不中奖,奖品标识为lose | ||
30 | "outParams": "", | ||
31 | "extParams": "", | ||
32 | "outParamsVo": { // outParams参数格式化} | ||
33 | } | ||
34 | } | ||
35 | }, | ||
36 | |||
37 | page: 1, | ||
38 | size: 10, | ||
39 | loading: false, | ||
40 | finished: false, | ||
41 | list: [], | ||
42 | } | ||
43 | }, | ||
44 | components: {}, | ||
45 | computed: { | ||
46 | areaStr() { | ||
47 | let result = ""; | ||
48 | let { | ||
49 | province, | ||
50 | city, | ||
51 | district | ||
52 | } = this.formData; | ||
53 | if (province && city && district) { | ||
54 | result = `${province}-${city}-${district}` | ||
55 | } | ||
56 | return result; | ||
57 | } | ||
58 | }, | ||
59 | methods: { | ||
60 | resetPage() { | ||
61 | this.loading = false; | ||
62 | this.page = 1; | ||
63 | this.total = 0; | ||
64 | this.list = []; | ||
65 | this.finished = false; | ||
66 | }, | ||
67 | onLoad() { | ||
68 | if (this.finished) { | ||
69 | this.loading = false; | ||
70 | } else { | ||
71 | this.page++; | ||
72 | this.queryList(); | ||
73 | } | ||
74 | |||
75 | }, | ||
76 | |||
77 | queryList() { | ||
78 | app.get({ | ||
79 | url: app.api.list, | ||
80 | data: { | ||
81 | page: this.page, | ||
82 | size: this.size | ||
83 | } | ||
84 | }).then((result) => { | ||
85 | this.list = this.list.concat(result.list); | ||
86 | this.finished = this.list.length >= result.total; | ||
87 | this.loading = false; | ||
88 | }).catch((err) => { | ||
89 | this.loading = false; | ||
90 | this.finished = true; | ||
91 | }); | ||
92 | }, | ||
93 | |||
94 | |||
95 | // 显示地区 | ||
96 | onShowAreaSelect() { | ||
97 | if (!this.editable) return; | ||
98 | this.areaVisible = true; | ||
99 | }, | ||
100 | // 确认省市区 | ||
101 | onAreaConfirm(val) { | ||
102 | this.areaVisible = false; | ||
103 | if (val && val.length >= 3) { | ||
104 | this.formData.province = val[0].name || ""; | ||
105 | this.formData.city = val[1].name || ""; | ||
106 | this.formData.district = val[2].name || ""; | ||
107 | |||
108 | this.formData.provinceCode = val[0].code || ""; | ||
109 | this.formData.cityCode = val[1].code || ""; | ||
110 | this.formData.districtCode = val[2].code || ""; | ||
111 | } | ||
112 | }, | ||
113 | |||
114 | beforeAvatarUpload(file) { | ||
115 | const size = 10 * 1024 * 1024; | ||
116 | if (file.size > size) { | ||
117 | Toast('上传图片大小不能超过10M'); | ||
118 | return false; | ||
119 | } | ||
120 | return true; | ||
121 | }, | ||
122 | afterRead(file) { | ||
123 | console.log("file:", file); | ||
124 | if (file.length == undefined) { | ||
125 | this.uploadFile(file); | ||
126 | } else { | ||
127 | for (let index = 0; index < file.length; index++) { | ||
128 | this.uploadFile(file[index]); | ||
129 | } | ||
130 | } | ||
131 | }, | ||
132 | uploadFile(file) { | ||
133 | file.status = 'uploading'; | ||
134 | file.message = '上传中...'; | ||
135 | this.loading = true; | ||
136 | app.uploadFile({ | ||
137 | url: app.api.upload, | ||
138 | // data: formData | ||
139 | data: { | ||
140 | file: file.file, | ||
141 | subPath: this.subPath | ||
142 | } | ||
143 | }) | ||
144 | .then(res => { | ||
145 | file.status = 'done'; | ||
146 | file.message = ''; | ||
147 | file.url = res; | ||
148 | console.log("file:", file); | ||
149 | console.log("fileList:", this.fileList); | ||
150 | this.loading = false; | ||
151 | }) | ||
152 | .catch(e => { | ||
153 | file.status = 'failed'; | ||
154 | file.message = '上传失败'; | ||
155 | this.loading = false; | ||
156 | this.refreshFileList(); | ||
157 | Toast("上传失败,请上传体积小于10的文件") | ||
158 | }); | ||
159 | }, | ||
160 | refreshFileList() { | ||
161 | let fileList = this.fileList.filter(item => { | ||
162 | return item.url | ||
163 | }); | ||
164 | this.fileList = fileList | ||
165 | }, | ||
166 | initData() { | ||
167 | this.editable = true; | ||
168 | } | ||
169 | }, | ||
170 | mounted() { | ||
171 | this.areaList = areaList; | ||
172 | this.initData(); | ||
173 | }, | ||
174 | created() {} | ||
175 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
src/pages/exp/exp.scss
0 → 100644
1 | .top-space { | ||
2 | height: 60px; | ||
3 | } | ||
4 | |||
5 | .form { | ||
6 | margin: 0 auto 0; | ||
7 | padding: 0 30px; | ||
8 | @extend .bb; | ||
9 | |||
10 | &-item { | ||
11 | margin: 0 auto 60px; | ||
12 | &-tit {} | ||
13 | |||
14 | .cont {} | ||
15 | } | ||
16 | } | ||
17 | |||
18 | .btn-wrap { | ||
19 | margin: 60px auto 0; | ||
20 | padding: 0 30px; | ||
21 | @extend .bb; | ||
22 | |||
23 | .btn { | ||
24 | @include bc(); | ||
25 | } | ||
26 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
src/pages/exp/exp.vue
0 → 100644
1 | |||
2 | <template> | ||
3 | <div class="page"> | ||
4 | <div class="app__bgc bgc"></div> | ||
5 | <div class="app__bg bg"></div> | ||
6 | <div class="app__content main"> | ||
7 | <div class="top-space"></div> | ||
8 | <div class="content"> | ||
9 | |||
10 | <div class="form"> | ||
11 | |||
12 | <div class="form-item"> | ||
13 | <div class="form-tit">列表</div> | ||
14 | <div class="cont"> | ||
15 | <div class="list"> | ||
16 | <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad" | ||
17 | :immediate-check="false"> | ||
18 | |||
19 | <div v-for="(item,index) in list" :key="item.id"> | ||
20 | {{ index }} | ||
21 | </div> | ||
22 | </van-list> | ||
23 | </div> | ||
24 | </div> | ||
25 | </div> | ||
26 | |||
27 | <div class="form-item"> | ||
28 | <div class="form-tit">地区</div> | ||
29 | <div class="cont"> | ||
30 | <div @click="onShowAreaSelect" class="val"> | ||
31 | <input readonly="true" v-model="areaStr" class="ipt" type="text"> | ||
32 | </div> | ||
33 | </div> | ||
34 | |||
35 | </div> | ||
36 | |||
37 | <div class="form-item"> | ||
38 | <div class="form-tit">图片上传</div> | ||
39 | <div class="cont"> | ||
40 | <van-uploader v-model="fileList" :after-read="afterRead" accept="image/png, image/jpeg, video/mp4" | ||
41 | preview-size='26vw' :max-count="9"> | ||
42 | </van-uploader> | ||
43 | </div> | ||
44 | </div> | ||
45 | </div> | ||
46 | |||
47 | <div class="btn-wrap"> | ||
48 | <div class="btn">提 交</div> | ||
49 | </div> | ||
50 | </div> | ||
51 | </div> | ||
52 | <van-popup v-model="areaVisible" position="bottom" get-container="body"> | ||
53 | <van-area title="省市区选择" :area-list="areaList" @confirm="onAreaConfirm" @cancel="areaVisible=false" /> | ||
54 | </van-popup> | ||
55 | </div> | ||
56 | </template> | ||
57 | |||
58 | <script src="./exp.js"></script> | ||
59 | <style lang="scss" scoped> | ||
60 | @import "./exp.scss"; | ||
61 | </style> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -20,6 +20,14 @@ const routes = [{ | ... | @@ -20,6 +20,14 @@ const routes = [{ |
20 | } | 20 | } |
21 | }, | 21 | }, |
22 | { | 22 | { |
23 | path: '/exp', | ||
24 | name: 'exp', | ||
25 | component: () => import('./pages/exp/exp.vue'), | ||
26 | meta: { | ||
27 | title: '' | ||
28 | } | ||
29 | }, | ||
30 | { | ||
23 | path: '/demo', | 31 | path: '/demo', |
24 | name: 'demo', | 32 | name: 'demo', |
25 | component: () => import('./pages/demo/demo.vue'), | 33 | component: () => import('./pages/demo/demo.vue'), | ... | ... |
... | @@ -17,6 +17,7 @@ | ... | @@ -17,6 +17,7 @@ |
17 | 17 | ||
18 | -ms-text-overflow: ellipsis; | 18 | -ms-text-overflow: ellipsis; |
19 | } | 19 | } |
20 | |||
20 | @mixin ellipsis1() { | 21 | @mixin ellipsis1() { |
21 | display: -webkit-box; | 22 | display: -webkit-box; |
22 | word-break: break-all; | 23 | word-break: break-all; |
... | @@ -51,6 +52,7 @@ | ... | @@ -51,6 +52,7 @@ |
51 | 52 | ||
52 | // 清除浮动 | 53 | // 清除浮动 |
53 | @mixin clearfix() { | 54 | @mixin clearfix() { |
55 | |||
54 | &:before, | 56 | &:before, |
55 | &:after { | 57 | &:after { |
56 | content: " "; // 1 | 58 | content: " "; // 1 |
... | @@ -101,81 +103,40 @@ | ... | @@ -101,81 +103,40 @@ |
101 | border: 0; | 103 | border: 0; |
102 | } | 104 | } |
103 | 105 | ||
104 | // 橙色底实心 自定义圆角按钮 | 106 | |
105 | @mixin btc($hei: 22px, $borderRadius: 4px, $padding: 12px, $fontSize: 14px) { | 107 | // 居中按钮样式 |
106 | @extend .fcc; | 108 | @mixin btc($width, $height) { |
107 | padding: 0 $padding; | 109 | width: $width; |
108 | height: $hei; | 110 | height: $height; |
109 | line-height: normal; | 111 | line-height: $height; |
110 | text-align: center; | ||
111 | border-radius: $borderRadius; | ||
112 | background-color: $cOrange; | ||
113 | font-size: $fontSize; | ||
114 | color: #ffffff; | ||
115 | letter-spacing: 1.4px; | ||
116 | cursor: pointer; | ||
117 | user-select: none; | ||
118 | } | ||
119 | |||
120 | // 白底空心 自定义圆角按钮 | ||
121 | @mixin btc-o($hei: 22px, $borderRadius: 4px, $padding: 12px, $fontSize: 14px) { | ||
122 | @extend .fcc; | ||
123 | @extend .bb; | ||
124 | padding: 0 $padding; | ||
125 | height: $hei; | ||
126 | line-height: normal; | ||
127 | text-align: center; | ||
128 | border-radius: $borderRadius; | ||
129 | font-size: $fontSize; | ||
130 | color: $cOrange; | ||
131 | letter-spacing: 1.4px; | ||
132 | background-color: #ffffff; | ||
133 | cursor: pointer; | ||
134 | border: solid 1px $cOrange; | ||
135 | user-select: none; | ||
136 | } | ||
137 | |||
138 | // 定宽 橙色底实心圆角按钮 | ||
139 | @mixin btc2($wid: 118px, $hei: 22px, $fontSize: 14px) { | ||
140 | width: $wid; | ||
141 | height: $hei; | ||
142 | line-height: $hei + 2px; | ||
143 | text-align: center; | 112 | text-align: center; |
144 | border-radius: $hei * 0.5; | ||
145 | background-color: $cOrange; | ||
146 | font-size: $fontSize; | ||
147 | color: #ffffff; | ||
148 | letter-spacing: 1.4px; | ||
149 | cursor: pointer; | ||
150 | user-select: none; | ||
151 | } | 113 | } |
152 | 114 | ||
153 | // 橙框橙字 | 115 | |
154 | @mixin btc3($hei: 22px, $fontSize: 14px) { | 116 | |
155 | height: $hei; | 117 | // 通用按钮 |
156 | line-height: $hei; | 118 | @mixin bc($width:100%, $height:88px, $fontSize:30px) { |
157 | padding: 0 12px; | 119 | color: #FFFFFF; |
120 | position: relative; | ||
121 | width: $width; | ||
122 | height: $height; | ||
123 | line-height: $height; | ||
158 | text-align: center; | 124 | text-align: center; |
159 | border-radius: 2px; | ||
160 | font-size: $fontSize; | 125 | font-size: $fontSize; |
161 | letter-spacing: 1.4px; | 126 | border-radius: 8px; |
162 | cursor: pointer; | 127 | background-color: $colorMain; |
163 | user-select: none; | 128 | } |
164 | color: $cOrange; | 129 | |
165 | border: solid 1px $cOrange; | 130 | // 通用按钮 |
166 | } | 131 | @mixin bc-o($width:100%, $height:88px, $fontSize:30px) { |
167 | 132 | position: relative; | |
168 | // 定宽 黑色底实心圆角按钮 | 133 | width: $width; |
169 | @mixin btc4($wid: 118px, $hei: 22px, $fontSize: 14px) { | 134 | height: $height; |
170 | width: $wid; | 135 | line-height: $height; |
171 | height: $hei; | ||
172 | line-height: $hei + 2px; | ||
173 | text-align: center; | 136 | text-align: center; |
174 | border-radius: $hei * 0.5; | ||
175 | background-color: $cLightDard; | ||
176 | font-size: $fontSize; | 137 | font-size: $fontSize; |
177 | color: #ffffff; | 138 | border-radius: 8px; |
178 | letter-spacing: 1.4px; | 139 | color: $colorMain; |
179 | cursor: pointer; | 140 | border: solid 1PX $colorMain; |
180 | user-select: none; | 141 | background-color: transparent; |
181 | } | 142 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -64,3 +64,17 @@ | ... | @@ -64,3 +64,17 @@ |
64 | .pointer { | 64 | .pointer { |
65 | cursor: pointer; | 65 | cursor: pointer; |
66 | } | 66 | } |
67 | |||
68 | |||
69 | .untouch { | ||
70 | pointer-events: none; | ||
71 | } | ||
72 | |||
73 | |||
74 | .ell { | ||
75 | @include ellipsis(1); | ||
76 | } | ||
77 | |||
78 | .ell2 { | ||
79 | @include ellipsis(2); | ||
80 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | /** | 1 | // Font 文字 |
2 | * ------------------------------------------------------------------ | 2 | |
3 | * Sass 变量 | 3 | // 大标题 Medium 26pt 34H 500 |
4 | * | 4 | $fontSizeTitleLarger: 52px; |
5 | * ------------------------------------------------------------------ | 5 | |
6 | * | 6 | // 标准标题 Medium 20pt 28H 500 |
7 | */ | 7 | $fontSizeTitleLarge: 40px; |
8 | 8 | ||
9 | // Margin | 9 | // 标准标题 Medium 18pt 24H 500 |
10 | $marginTopSmaller: 20px; | 10 | $fontSizeTitle: 36rpx; |
11 | $marginTopSmall: 30px; | 11 | |
12 | $marginTopMedium: 40px; | 12 | // 正文5 大部分正文文字+导航栏的文字 Regular 17pt 23H 400 |
13 | $marginTopLarge: 60px; | 13 | $fontSizeNavLarge: 34px; |
14 | $marginTopLarger: 80px; | 14 | |
15 | 15 | // 正文5 大部分正文文字+导航栏的文字 Regular 16pt 22H 400 | |
16 | // Padding | 16 | $fontSizeNav: 32px; |
17 | $paddingTopSmaller: 20px; | 17 | |
18 | $paddingTopSmall: 30px; | 18 | // 正文4 信息较多且需要多呈现时的正文使用 Regular 15pt 21H 400 |
19 | $paddingTopMedium: 40px; | 19 | $fontSize: 30px; |
20 | $paddingTopLarge: 60px; | 20 | |
21 | $paddingTopLarger: 80px; | 21 | // 正文3 信息较多且需要多呈现时的正文使用 Regular 14pt 21H 400 |
22 | |||
23 | // Color | ||
24 | $colorBlue: #20A0FF; | ||
25 | $colorGreen: #13CE66; | ||
26 | $colorGray: #475669; | ||
27 | $colorBlack: #000; | ||
28 | $colorRed: #FF4949; | ||
29 | $colorYellow: #F7BA2A; | ||
30 | |||
31 | $color: #787878; | ||
32 | $colorLink: #1D8CE0; | ||
33 | |||
34 | $backGroundColor: #fff; | ||
35 | |||
36 | // Font | ||
37 | $fontSize: 32px; | ||
38 | $fontSizeSmall: 28px; | 22 | $fontSizeSmall: 28px; |
39 | $fontSizeSmaller: 24px; | 23 | |
40 | $fontSizeLarge: 36px; | 24 | // 正文2 对主题进行释意的文字+协议条款文字等 Regular 13pt 19H 400 |
41 | $fontSizeLarger: 44px; | 25 | $fontSizeRemark: 26px; |
26 | |||
27 | // 正文1 对主题进行释意的文字+协议条款文字等 Regular 12pt 16H 400 | ||
28 | $fontSizeRemarkSmall: 24px; | ||
29 | |||
30 | // 标签栏辅助文字 Medium 10pt 14H 500 | ||
31 | $fontSizeTag: 20px; | ||
32 | |||
33 | // 表单中数据文字 Regular 8pt 10H 400 | ||
34 | $fontSizeData: 16px; | ||
35 | |||
36 | |||
37 | // Color 颜色 以下来自 有赞建议 | ||
38 | $color: #323233; // 文字色,指主文字1 | ||
39 | $colorText: #646566; // 文字色,指主文字2 | ||
40 | $colorLight: #969799; // 文字色,指辅助、说明文字 | ||
41 | $colorTips: #969799; // 文字色,指 disable、提示文字等 | ||
42 | $colorBorder: #DCDEE0; // 边框、线色 | ||
43 | $colorBorderLight: #EBEDF0; // 边框、线色 | ||
44 | $colorBg: #F2F3F5; // 深色背景 | ||
45 | $colorBgLight: #F7F8FA; // 浅色背景 | ||
46 | |||
47 | $colorBlack: #000000; // 黑色 | ||
48 | $colorWhite: #ffffff; // 白色 | ||
49 | |||
50 | // 功能色 | ||
51 | $colorLink:#576B95; // 文字链颜色 | ||
52 | $colorSuccess: #07C160; // 成功色 | ||
53 | $colorDanger: #EE0A24; // 报错色 | ||
54 | $colorWarning: #ED6A0C; // 通知消息中的文本颜色 | ||
55 | $colorWarning: #FFFBE8; // 通知消息中的背景颜色 | ||
56 | $colorInfo: #FAAB0C; // 文字辅助颜色 | ||
57 | |||
58 | |||
59 | |||
60 | // 业务色 以下颜色为自定义 | ||
61 | $colorMain:#409EFF; // 主题颜色 根据业务定义 // #EE0A24有赞默认 | ||
62 | $colorPrice: #ee0a24; // 价格颜色 | ||
63 | // $fontGray:#9F9E9E; // 提示文字颜色 | ||
64 | |||
65 | |||
66 | // BorderRadius 角边 | ||
67 | $borderRaidus: 16px; // 默认卡片编辑 角边 | ||
68 | $borderRaidusPopup: 40px; // 模态面板编辑 角边 | ||
69 | $borderRaidusDialog: 32px; // 对话框 角边 | ||
70 | |||
71 | |||
72 | // Space 间距 有赞建议为8的倍数(8点网格系统) | ||
73 | $marginLarge:32px; // 外边距 多用于主内容离屏幕边缘 | ||
74 | $margin:24px; // 外边距 多用于主内容离屏幕边缘 | ||
75 | $marginSmall: 16px; // 小外边距 多用于内容间上下距离 | ||
76 | $marginSmaller: 8px; // 小外边距 多用列表item间上下左右距离 | ||
77 | |||
78 | $paddinglarge:32px; // 内边距 | ||
79 | $padding: 24px; | ||
80 | $paddingSmall: 16px; | ||
81 | $paddingSmaller: 8px; | ||
82 | |||
83 | // 页面样式 | ||
84 | $pageBottom: 160px; // 页面底部 | ||
85 | $contentWid: 690px; //内容宽度 (由间距为8的倍数所得) | ||
86 | $contentWidth: 710px; //内容宽度 (由间距为8的倍数所得) | ||
87 | $screenWidth: 750px; // 屏幕宽度 | ... | ... |
src/utils/vant-util.js
0 → 100644
1 | import Vue from 'vue' | ||
2 | |||
3 | import { | ||
4 | Swipe, | ||
5 | SwipeItem, | ||
6 | Lazyload, | ||
7 | Tab, | ||
8 | Tabs, | ||
9 | Sticky, | ||
10 | Popup, | ||
11 | Tabbar, | ||
12 | TabbarItem, | ||
13 | Icon, | ||
14 | Uploader, | ||
15 | Area, | ||
16 | List, | ||
17 | Toast, | ||
18 | Button | ||
19 | } from 'vant'; | ||
20 | |||
21 | Vue.use(Swipe).use(SwipeItem) | ||
22 | .use(Lazyload) | ||
23 | .use(Tab).use(Tabs) | ||
24 | .use(Sticky) | ||
25 | .use(Popup) | ||
26 | .use(Tabbar).use(TabbarItem) | ||
27 | .use(Icon) | ||
28 | .use(Uploader) | ||
29 | .use(Area) | ||
30 | .use(List) | ||
31 | .use(Button) | ||
32 | .use(Toast); |
-
Please register or sign in to post a comment