You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

466 lines
12 KiB

  1. ! function(a, b) {
  2. "function" == typeof define && (define.amd || define.cmd) ? define(function() {
  3. return b(a)
  4. }) : b(a, !0)
  5. }(this, function(a, b) {
  6. function c(b, c, d) {
  7. a.WeixinJSBridge ? WeixinJSBridge.invoke(b, e(c), function(a) {
  8. g(b, a, d)
  9. }) : j(b, d)
  10. }
  11. function d(b, c, d) {
  12. a.WeixinJSBridge ? WeixinJSBridge.on(b, function(a) {
  13. d && d.trigger && d.trigger(a), g(b, a, c)
  14. }) : d ? j(b, d) : j(b, c)
  15. }
  16. function e(a) {
  17. return a = a || {}, a.appId = E.appId, a.verifyAppId = E.appId, a.verifySignType = "sha1", a.verifyTimestamp = E.timestamp + "", a.verifyNonceStr = E.nonceStr, a.verifySignature = E.signature, a
  18. }
  19. function f(a) {
  20. return {
  21. timeStamp: a.timestamp + "",
  22. nonceStr: a.nonceStr,
  23. "package": a.package,
  24. paySign: a.paySign,
  25. signType: a.signType || "SHA1"
  26. }
  27. }
  28. function g(a, b, c) {
  29. var d, e, f;
  30. switch(delete b.err_code, delete b.err_desc, delete b.err_detail, d = b.errMsg, d || (d = b.err_msg, delete b.err_msg, d = h(a, d), b.errMsg = d), c = c || {}, c._complete && (c._complete(b), delete c._complete), d = b.errMsg || "", E.debug && !c.isInnerInvoke && alert(JSON.stringify(b)), e = d.indexOf(":"), f = d.substring(e + 1)) {
  31. case "ok":
  32. c.success && c.success(b);
  33. break;
  34. case "cancel":
  35. c.cancel && c.cancel(b);
  36. break;
  37. default:
  38. c.fail && c.fail(b)
  39. }
  40. c.complete && c.complete(b)
  41. }
  42. function h(a, b) {
  43. var e, f, c = a,
  44. d = p[c];
  45. return d && (c = d), e = "ok", b && (f = b.indexOf(":"), e = b.substring(f + 1), "confirm" == e && (e = "ok"), "failed" == e && (e = "fail"), -1 != e.indexOf("failed_") && (e = e.substring(7)), -1 != e.indexOf("fail_") && (e = e.substring(5)), e = e.replace(/_/g, " "), e = e.toLowerCase(), ("access denied" == e || "no permission to execute" == e) && (e = "permission denied"), "config" == c && "function not exist" == e && (e = "ok"), "" == e && (e = "fail")), b = c + ":" + e
  46. }
  47. function i(a) {
  48. var b, c, d, e;
  49. if(a) {
  50. for(b = 0, c = a.length; c > b; ++b) d = a[b], e = o[d], e && (a[b] = e);
  51. return a
  52. }
  53. }
  54. function j(a, b) {
  55. if(!(!E.debug || b && b.isInnerInvoke)) {
  56. var c = p[a];
  57. c && (a = c), b && b._complete && delete b._complete, console.log('"' + a + '",', b || "")
  58. }
  59. }
  60. function k() {
  61. 0 != D.preVerifyState && (u || v || E.debug || "6.0.2" > z || D.systemType < 0 || A || (A = !0, D.appId = E.appId, D.initTime = C.initEndTime - C.initStartTime, D.preVerifyTime = C.preVerifyEndTime - C.preVerifyStartTime, H.getNetworkType({
  62. isInnerInvoke: !0,
  63. success: function(a) {
  64. var b, c;
  65. D.networkType = a.networkType, b = "http://open.weixin.qq.com/sdk/report?v=" + D.version + "&o=" + D.preVerifyState + "&s=" + D.systemType + "&c=" + D.clientVersion + "&a=" + D.appId + "&n=" + D.networkType + "&i=" + D.initTime + "&p=" + D.preVerifyTime + "&u=" + D.url, c = new Image, c.src = b
  66. }
  67. })))
  68. }
  69. function l() {
  70. return(new Date).getTime()
  71. }
  72. function m(b) {
  73. w && (a.WeixinJSBridge ? b() : q.addEventListener && q.addEventListener("WeixinJSBridgeReady", b, !1))
  74. }
  75. function n() {
  76. H.invoke || (H.invoke = function(b, c, d) {
  77. a.WeixinJSBridge && WeixinJSBridge.invoke(b, e(c), d)
  78. }, H.on = function(b, c) {
  79. a.WeixinJSBridge && WeixinJSBridge.on(b, c)
  80. })
  81. }
  82. var o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H;
  83. if(!a.jWeixin) return o = {
  84. config: "preVerifyJSAPI",
  85. onMenuShareTimeline: "menu:share:timeline",
  86. onMenuShareAppMessage: "menu:share:appmessage",
  87. onMenuShareQQ: "menu:share:qq",
  88. onMenuShareWeibo: "menu:share:weiboApp",
  89. onMenuShareQZone: "menu:share:QZone",
  90. previewImage: "imagePreview",
  91. getLocation: "geoLocation",
  92. openProductSpecificView: "openProductViewWithPid",
  93. addCard: "batchAddCard",
  94. openCard: "batchViewCard",
  95. chooseWXPay: "getBrandWCPayRequest"
  96. }, p = function() {
  97. var b, a = {};
  98. for(b in o) a[o[b]] = b;
  99. return a
  100. }(), q = a.document, r = q.title, s = navigator.userAgent.toLowerCase(), t = navigator.platform.toLowerCase(), u = !(!t.match("mac") && !t.match("win")), v = -1 != s.indexOf("wxdebugger"), w = -1 != s.indexOf("micromessenger"), x = -1 != s.indexOf("android"), y = -1 != s.indexOf("iphone") || -1 != s.indexOf("ipad"), z = function() {
  101. var a = s.match(/micromessenger\/(\d+\.\d+\.\d+)/) || s.match(/micromessenger\/(\d+\.\d+)/);
  102. return a ? a[1] : ""
  103. }(), A = !1, B = !1, C = {
  104. initStartTime: l(),
  105. initEndTime: 0,
  106. preVerifyStartTime: 0,
  107. preVerifyEndTime: 0
  108. }, D = {
  109. version: 1,
  110. appId: "",
  111. initTime: 0,
  112. preVerifyTime: 0,
  113. networkType: "",
  114. preVerifyState: 1,
  115. systemType: y ? 1 : x ? 2 : -1,
  116. clientVersion: z,
  117. url: encodeURIComponent(location.href)
  118. }, E = {}, F = {
  119. _completes: []
  120. }, G = {
  121. state: 0,
  122. data: {}
  123. }, m(function() {
  124. C.initEndTime = l()
  125. }), H = {
  126. config: function(a) {
  127. E = a, j("config", a);
  128. var b = E.check === !1 ? !1 : !0;
  129. m(function() {
  130. var a, d, e;
  131. if(b) c(o.config, {
  132. verifyJsApiList: i(E.jsApiList)
  133. }, function() {
  134. F._complete = function(a) {
  135. C.preVerifyEndTime = l(), G.state = 1, G.data = a
  136. }, F.success = function() {
  137. D.preVerifyState = 0
  138. }, F.fail = function(a) {
  139. F._fail ? F._fail(a) : G.state = -1
  140. };
  141. var a = F._completes;
  142. return a.push(function() {
  143. k()
  144. }), F.complete = function() {
  145. for(var c = 0, d = a.length; d > c; ++c) a[c]();
  146. F._completes = []
  147. }, F
  148. }()), C.preVerifyStartTime = l();
  149. else {
  150. for(G.state = 1, a = F._completes, d = 0, e = a.length; e > d; ++d) a[d]();
  151. F._completes = []
  152. }
  153. }), E.beta && n()
  154. },
  155. ready: function(a) {
  156. 0 != G.state ? a() : (F._completes.push(a), !w && E.debug && a())
  157. },
  158. error: function(a) {
  159. "6.0.2" > z || B || (B = !0, -1 == G.state ? a(G.data) : F._fail = a)
  160. },
  161. checkJsApi: function(a) {
  162. var b = function(a) {
  163. var c, d, b = a.checkResult;
  164. for(c in b) d = p[c], d && (b[d] = b[c], delete b[c]);
  165. return a
  166. };
  167. c("checkJsApi", {
  168. jsApiList: i(a.jsApiList)
  169. }, function() {
  170. return a._complete = function(a) {
  171. if(x) {
  172. var c = a.checkResult;
  173. c && (a.checkResult = JSON.parse(c))
  174. }
  175. a = b(a)
  176. }, a
  177. }())
  178. },
  179. onMenuShareTimeline: function(a) {
  180. d(o.onMenuShareTimeline, {
  181. complete: function() {
  182. c("shareTimeline", {
  183. title: a.title || r,
  184. desc: a.title || r,
  185. img_url: a.imgUrl || "",
  186. link: a.link || location.href,
  187. type: a.type || "link",
  188. data_url: a.dataUrl || ""
  189. }, a)
  190. }
  191. }, a)
  192. },
  193. onMenuShareAppMessage: function(a) {
  194. d(o.onMenuShareAppMessage, {
  195. complete: function() {
  196. c("sendAppMessage", {
  197. title: a.title || r,
  198. desc: a.desc || "",
  199. link: a.link || location.href,
  200. img_url: a.imgUrl || "",
  201. type: a.type || "link",
  202. data_url: a.dataUrl || ""
  203. }, a)
  204. }
  205. }, a)
  206. },
  207. onMenuShareQQ: function(a) {
  208. d(o.onMenuShareQQ, {
  209. complete: function() {
  210. c("shareQQ", {
  211. title: a.title || r,
  212. desc: a.desc || "",
  213. img_url: a.imgUrl || "",
  214. link: a.link || location.href
  215. }, a)
  216. }
  217. }, a)
  218. },
  219. onMenuShareWeibo: function(a) {
  220. d(o.onMenuShareWeibo, {
  221. complete: function() {
  222. c("shareWeiboApp", {
  223. title: a.title || r,
  224. desc: a.desc || "",
  225. img_url: a.imgUrl || "",
  226. link: a.link || location.href
  227. }, a)
  228. }
  229. }, a)
  230. },
  231. onMenuShareQZone: function(a) {
  232. d(o.onMenuShareQZone, {
  233. complete: function() {
  234. c("shareQZone", {
  235. title: a.title || r,
  236. desc: a.desc || "",
  237. img_url: a.imgUrl || "",
  238. link: a.link || location.href
  239. }, a)
  240. }
  241. }, a)
  242. },
  243. startRecord: function(a) {
  244. c("startRecord", {}, a)
  245. },
  246. stopRecord: function(a) {
  247. c("stopRecord", {}, a)
  248. },
  249. onVoiceRecordEnd: function(a) {
  250. d("onVoiceRecordEnd", a)
  251. },
  252. playVoice: function(a) {
  253. c("playVoice", {
  254. localId: a.localId
  255. }, a)
  256. },
  257. pauseVoice: function(a) {
  258. c("pauseVoice", {
  259. localId: a.localId
  260. }, a)
  261. },
  262. stopVoice: function(a) {
  263. c("stopVoice", {
  264. localId: a.localId
  265. }, a)
  266. },
  267. onVoicePlayEnd: function(a) {
  268. d("onVoicePlayEnd", a)
  269. },
  270. uploadVoice: function(a) {
  271. c("uploadVoice", {
  272. localId: a.localId,
  273. isShowProgressTips: 0 == a.isShowProgressTips ? 0 : 1
  274. }, a)
  275. },
  276. downloadVoice: function(a) {
  277. c("downloadVoice", {
  278. serverId: a.serverId,
  279. isShowProgressTips: 0 == a.isShowProgressTips ? 0 : 1
  280. }, a)
  281. },
  282. translateVoice: function(a) {
  283. c("translateVoice", {
  284. localId: a.localId,
  285. isShowProgressTips: 0 == a.isShowProgressTips ? 0 : 1
  286. }, a)
  287. },
  288. chooseImage: function(a) {
  289. c("chooseImage", {
  290. scene: "1|2",
  291. count: a.count || 9,
  292. sizeType: a.sizeType || ["original", "compressed"],
  293. sourceType: a.sourceType || ["album", "camera"]
  294. }, function() {
  295. return a._complete = function(a) {
  296. if(x) {
  297. var b = a.localIds;
  298. b && (a.localIds = JSON.parse(b))
  299. }
  300. }, a
  301. }())
  302. },
  303. previewImage: function(a) {
  304. c(o.previewImage, {
  305. current: a.current,
  306. urls: a.urls
  307. }, a)
  308. },
  309. uploadImage: function(a) {
  310. c("uploadImage", {
  311. localId: a.localId,
  312. isShowProgressTips: 0 == a.isShowProgressTips ? 0 : 1
  313. }, a)
  314. },
  315. downloadImage: function(a) {
  316. c("downloadImage", {
  317. serverId: a.serverId,
  318. isShowProgressTips: 0 == a.isShowProgressTips ? 0 : 1
  319. }, a)
  320. },
  321. getNetworkType: function(a) {
  322. var b = function(a) {
  323. var c, d, e, b = a.errMsg;
  324. if(a.errMsg = "getNetworkType:ok", c = a.subtype, delete a.subtype, c) a.networkType = c;
  325. else switch(d = b.indexOf(":"), e = b.substring(d + 1)) {
  326. case "wifi":
  327. case "edge":
  328. case "wwan":
  329. a.networkType = e;
  330. break;
  331. default:
  332. a.errMsg = "getNetworkType:fail"
  333. }
  334. return a
  335. };
  336. c("getNetworkType", {}, function() {
  337. return a._complete = function(a) {
  338. a = b(a)
  339. }, a
  340. }())
  341. },
  342. openLocation: function(a) {
  343. alert("zj====="+a.infoUrl);
  344. c("openLocation", {
  345. latitude: a.latitude,
  346. longitude: a.longitude,
  347. name: a.name || "",
  348. address: a.address || "",
  349. scale: a.scale || 28,
  350. infoUrl: a.infoUrl || ""
  351. }, a)
  352. },
  353. getLocation: function(a) {
  354. a = a || {}, c(o.getLocation, {
  355. type: a.type || "wgs84"
  356. }, function() {
  357. return a._complete = function(a) {
  358. delete a.type
  359. }, a
  360. }())
  361. },
  362. hideOptionMenu: function(a) {
  363. c("hideOptionMenu", {}, a)
  364. },
  365. showOptionMenu: function(a) {
  366. c("showOptionMenu", {}, a)
  367. },
  368. closeWindow: function(a) {
  369. a = a || {}, c("closeWindow", {}, a)
  370. },
  371. hideMenuItems: function(a) {
  372. c("hideMenuItems", {
  373. menuList: a.menuList
  374. }, a)
  375. },
  376. showMenuItems: function(a) {
  377. c("showMenuItems", {
  378. menuList: a.menuList
  379. }, a)
  380. },
  381. hideAllNonBaseMenuItem: function(a) {
  382. c("hideAllNonBaseMenuItem", {}, a)
  383. },
  384. showAllNonBaseMenuItem: function(a) {
  385. c("showAllNonBaseMenuItem", {}, a)
  386. },
  387. scanQRCode: function(a) {
  388. a = a || {}, c("scanQRCode", {
  389. needResult: a.needResult || 0,
  390. scanType: a.scanType || ["qrCode", "barCode"]
  391. }, function() {
  392. return a._complete = function(a) {
  393. var b, c;
  394. y && (b = a.resultStr, b && (c = JSON.parse(b), a.resultStr = c && c.scan_code && c.scan_code.scan_result))
  395. }, a
  396. }())
  397. },
  398. openProductSpecificView: function(a) {
  399. c(o.openProductSpecificView, {
  400. pid: a.productId,
  401. view_type: a.viewType || 0,
  402. ext_info: a.extInfo
  403. }, a)
  404. },
  405. addCard: function(a) {
  406. var e, f, g, h, b = a.cardList,
  407. d = [];
  408. for(e = 0, f = b.length; f > e; ++e) g = b[e], h = {
  409. card_id: g.cardId,
  410. card_ext: g.cardExt
  411. }, d.push(h);
  412. c(o.addCard, {
  413. card_list: d
  414. }, function() {
  415. return a._complete = function(a) {
  416. var c, d, e, b = a.card_list;
  417. if(b) {
  418. for(b = JSON.parse(b), c = 0, d = b.length; d > c; ++c) e = b[c], e.cardId = e.card_id, e.cardExt = e.card_ext, e.isSuccess = e.is_succ ? !0 : !1, delete e.card_id, delete e.card_ext, delete e.is_succ;
  419. a.cardList = b, delete a.card_list
  420. }
  421. }, a
  422. }())
  423. },
  424. chooseCard: function(a) {
  425. c("chooseCard", {
  426. app_id: E.appId,
  427. location_id: a.shopId || "",
  428. sign_type: a.signType || "SHA1",
  429. card_id: a.cardId || "",
  430. card_type: a.cardType || "",
  431. card_sign: a.cardSign,
  432. time_stamp: a.timestamp + "",
  433. nonce_str: a.nonceStr
  434. }, function() {
  435. return a._complete = function(a) {
  436. a.cardList = a.choose_card_info, delete a.choose_card_info
  437. }, a
  438. }())
  439. },
  440. openCard: function(a) {
  441. var e, f, g, h, b = a.cardList,
  442. d = [];
  443. for(e = 0, f = b.length; f > e; ++e) g = b[e], h = {
  444. card_id: g.cardId,
  445. code: g.code
  446. }, d.push(h);
  447. c(o.openCard, {
  448. card_list: d
  449. }, a)
  450. },
  451. chooseWXPay: function(a) {
  452. c(o.chooseWXPay, f(a), a)
  453. }
  454. }, b && (a.wx = a.jWeixin = H), H
  455. });