seimin 11 ヶ月 前
コミット
f3e466f4cd

+ 13 - 0
.vite/deps/_metadata.json

@@ -0,0 +1,13 @@
1
+{
2
+  "hash": "bdd12d27",
3
+  "browserHash": "ad50140b",
4
+  "optimized": {
5
+    "weixin-jsapi": {
6
+      "src": "../../node_modules/weixin-jsapi/index.js",
7
+      "file": "weixin-jsapi.js",
8
+      "fileHash": "998090f1",
9
+      "needsInterop": false
10
+    }
11
+  },
12
+  "chunks": {}
13
+}

+ 3 - 0
.vite/deps/package.json

@@ -0,0 +1,3 @@
1
+{
2
+  "type": "module"
3
+}

+ 424 - 0
.vite/deps/weixin-jsapi.js

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

File diff suppressed because it is too large
+ 7 - 0
.vite/deps/weixin-jsapi.js.map


+ 50 - 0
http/http.js

@@ -0,0 +1,50 @@
1
+// #ifdef H5
2
+let path = `${location.origin}/service`
3
+// #endif
4
+
5
+// get方法
6
+export function get(url, data = {}) {
7
+  url = path + url;
8
+  return new Promise((resolve, reject) => {
9
+    uni.request({
10
+      url,
11
+      data,
12
+      header: {
13
+        'Cache-Control': 'no-cache'
14
+      },
15
+      success(res) {
16
+        resolve(res.data);
17
+      },
18
+      fail(err) {
19
+        uni.showToast({
20
+          icon: 'none',
21
+          title: '请求数据失败!'
22
+        });
23
+      }
24
+    })
25
+  });
26
+}
27
+// post方法
28
+export function post(url, data = {}) {
29
+  url = path + url;
30
+  return new Promise((resolve, reject) => {
31
+    uni.request({
32
+      method: 'POST',
33
+      url,
34
+      data,
35
+      header: {
36
+        'Cache-Control': 'no-cache'
37
+      },
38
+      success(res) {
39
+        resolve(res.data);
40
+      },
41
+      fail(err) {
42
+        reject(err);
43
+        uni.showToast({
44
+          icon: 'none',
45
+          title: '请求数据失败!'
46
+        });
47
+      }
48
+    })
49
+  });
50
+}

+ 16 - 4
main.js

@@ -1,4 +1,3 @@
1
-
2 1
 // #ifndef VUE3
3 2
 import Vue from 'vue'
4 3
 import App from './App'
@@ -8,18 +7,31 @@ Vue.config.productionTip = false
8 7
 App.mpType = 'app'
9 8
 
10 9
 const app = new Vue({
11
-    ...App
10
+  ...App
12 11
 })
13 12
 app.$mount()
14 13
 // #endif
15 14
 
16 15
 // #ifdef VUE3
17
-import { createSSRApp } from 'vue'
16
+import {
17
+  createSSRApp
18
+} from 'vue'
18 19
 import App from './App.vue'
20
+import * as Pinia from "pinia";
21
+import {
22
+  createUnistorage
23
+} from "./uni_modules/pinia-plugin-unistorage";
24
+console.info('v3.5.0');
25
+
19 26
 export function createApp() {
20 27
   const app = createSSRApp(App)
28
+  const store = Pinia.createPinia();
29
+  store.use(createUnistorage());
30
+  app.use(store);
31
+
21 32
   return {
22
-    app
33
+    app,
34
+    Pinia,
23 35
   }
24 36
 }
25 37
 // #endif

+ 14 - 1
manifest.json

@@ -56,5 +56,18 @@
56 56
         },
57 57
         "usingComponents" : true
58 58
     },
59
-    "vueVersion" : "3"
59
+    "vueVersion" : "3",
60
+    // h5特有相关
61
+    "h5":{
62
+    	"devServer": {
63
+    		"proxy":{
64
+    			"/service":{ 
65
+    				"target" : "http://192.168.4.105", //请求的目标域名
66
+    				"changeOrigin" : true, //是否跨域
67
+    				"secure" : false
68
+    			}
69
+    		},
70
+    		"port" : 8080 //当前项目的端口号
71
+    	}
72
+    }
60 73
 }

+ 12 - 0
node_modules/.package-lock.json

@@ -0,0 +1,12 @@
1
+{
2
+  "name": "itsm-wx-handle",
3
+  "lockfileVersion": 3,
4
+  "requires": true,
5
+  "packages": {
6
+    "node_modules/weixin-jsapi": {
7
+      "version": "1.1.0",
8
+      "resolved": "https://registry.npmmirror.com/weixin-jsapi/-/weixin-jsapi-1.1.0.tgz",
9
+      "integrity": "sha512-986drpgKs1yf8gK1A/hrdF2U5cjp/zW/7bhoL37JLoePhNiO14JqZpa+wlNslge0Hlw7gEXMTnEntFvvSXz8Bw=="
10
+    }
11
+  }
12
+}

+ 3 - 0
node_modules/.vite/deps_temp_155cf1a7/package.json

@@ -0,0 +1,3 @@
1
+{
2
+  "type": "module"
3
+}

+ 3 - 0
node_modules/.vite/deps_temp_b41cdf10/package.json

@@ -0,0 +1,3 @@
1
+{
2
+  "type": "module"
3
+}

+ 37 - 0
node_modules/weixin-jsapi/.npmignore

@@ -0,0 +1,37 @@
1
+# Logs
2
+logs
3
+*.log
4
+npm-debug.log*
5
+
6
+# Runtime data
7
+pids
8
+*.pid
9
+*.seed
10
+
11
+# Directory for instrumented libs generated by jscoverage/JSCover
12
+lib-cov
13
+
14
+# Coverage directory used by tools like istanbul
15
+coverage
16
+
17
+# nyc test coverage
18
+.nyc_output
19
+
20
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21
+.grunt
22
+
23
+# node-waf configuration
24
+.lock-wscript
25
+
26
+# Compiled binary addons (http://nodejs.org/api/addons.html)
27
+build/Release
28
+
29
+# Dependency directories
30
+node_modules
31
+jspm_packages
32
+
33
+# Optional npm cache directory
34
+.npm
35
+
36
+# Optional REPL history
37
+.node_repl_history

+ 21 - 0
node_modules/weixin-jsapi/LICENSE

@@ -0,0 +1,21 @@
1
+MIT License
2
+
3
+Copyright (c) 2016 jere
4
+
5
+Permission is hereby granted, free of charge, to any person obtaining a copy
6
+of this software and associated documentation files (the "Software"), to deal
7
+in the Software without restriction, including without limitation the rights
8
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+copies of the Software, and to permit persons to whom the Software is
10
+furnished to do so, subject to the following conditions:
11
+
12
+The above copyright notice and this permission notice shall be included in all
13
+copies or substantial portions of the Software.
14
+
15
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+SOFTWARE.

+ 12 - 0
node_modules/weixin-jsapi/README.md

@@ -0,0 +1,12 @@
1
+# weixin-jssdk
2
+微信官方 js-sdk es6 版本
3
+说明: 仅将官方 js-sdk 发布到 npm,便于 webpack 使用
4
+
5
+js源码: [http://res.wx.qq.com/open/js/jweixin-1.0.0.js](http://res.wx.qq.com/open/js/jweixin-1.0.0.js)
6
+
7
+官方使用说明: [http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html](http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html)
8
+
9
+安装:`npm install weixin-jsapi`
10
+
11
+
12
+使用:`import wx from 'weixin-jsapi'`

+ 389 - 0
node_modules/weixin-jsapi/index.d.ts

@@ -0,0 +1,389 @@
1
+/**
2
+ * Copyright (c) 2015,Egret-Labs.org
3
+ * All rights reserved.
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are met:
6
+ *
7
+ *     * Redistributions of source code must retain the above copyright
8
+ *       notice, this list of conditions and the following disclaimer.
9
+ *     * Redistributions in binary form must reproduce the above copyright
10
+ *       notice, this list of conditions and the following disclaimer in the
11
+ *       documentation and/or other materials provided with the distribution.
12
+ *     * Neither the name of the Egret-Labs.org nor the
13
+ *       names of its contributors may be used to endorse or promote products
14
+ *       derived from this software without specific prior written permission.
15
+ *
16
+ * THIS SOFTWARE IS PROVIDED BY EGRET-LABS.ORG AND CONTRIBUTORS "AS IS" AND ANY
17
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ * DISCLAIMED. IN NO EVENT SHALL EGRET-LABS.ORG AND CONTRIBUTORS BE LIABLE FOR ANY
20
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ *
27
+ * Created by wibrst on 2015/1/10.
28
+ */
29
+
30
+
31
+declare class wx {
32
+
33
+    /**
34
+     * 通过config接口注入权限验证配置
35
+     * @param bodyConfig
36
+     */
37
+    static config( bodyConfig:BodyConfig ):void;
38
+
39
+
40
+    /**
41
+     * 通过ready接口处理成功验证
42
+     * @param cbValidated 成功验证后的处理函数
43
+     */
44
+    static ready( cbValidated:Function ):void;
45
+
46
+
47
+    /**
48
+     * 通过error接口处理失败验证
49
+     * @param cbError 处理失败验证后的处理函数
50
+     */
51
+    static error( cbError:Function ):void;
52
+
53
+
54
+    /**
55
+     * 判断当前客户端版本是否支持指定JS接口
56
+     * @param bodyCheckJsAPISupport
57
+     */
58
+    static checkJsApi( bodyCheckJsAPISupport:BodyCheckJsAPISupport ):void;
59
+
60
+
61
+    /**
62
+     * 获取“分享到朋友圈”按钮点击状态及自定义分享内容接口
63
+     * @param bodyMenuShareTimeline
64
+     */
65
+    static onMenuShareTimeline( bodyMenuShareTimeline:BodyMenuShareTimeline ):void;
66
+
67
+
68
+    /**
69
+     * 获取“分享给朋友”按钮点击状态及自定义分享内容接口
70
+     * @param bodyMenuShareAppMessage
71
+     */
72
+    static onMenuShareAppMessage( bodyMenuShareAppMessage:BodyMenuShareAppMessage ):void;
73
+
74
+
75
+    /**
76
+     * 获取“分享到QQ”按钮点击状态及自定义分享内容接口
77
+     * @param bodyMenuShareQQ
78
+     */
79
+    static onMenuShareQQ( bodyMenuShareQQ:BodyMenuShareQQ ):void;
80
+
81
+
82
+    /**
83
+     * 获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口
84
+     * @param bodyMenuShareWeibo
85
+     */
86
+    static onMenuShareWeibo( bodyMenuShareWeibo:BodyMenuShareWeibo ):void;
87
+
88
+
89
+    /// 华丽的分界线, 以下接口参数结构较简单或使用较少,均可自行查阅微信官方api文档给出适合的参数
90
+
91
+    /**
92
+     * 拍照或从手机相册中选图接口
93
+     * @param bodyChooseImage
94
+     */
95
+    static chooseImage( body:Object ):void;
96
+
97
+    /**
98
+     * 预览图片接口
99
+     * @param body
100
+     */
101
+    static previewImage( body:Object ):void;
102
+
103
+    /**
104
+     * 上传图片接口
105
+     * @param body
106
+     */
107
+    static uploadImage( body:Object ):void;
108
+
109
+    /**
110
+     * 下载图片接口
111
+     * @param body
112
+     */
113
+    static downloadImage( body:Object ):void;
114
+
115
+    /**
116
+      * 开始录音接口
117
+      * @param body
118
+      */
119
+     static startRecord( body:Object ):void;
120
+
121
+    /**
122
+      * 停止录音接口
123
+      * @param body
124
+      */
125
+     static stopRecord( body:Object ):void;
126
+
127
+    /**
128
+      * 监听录音自动停止接口
129
+      * @param body
130
+      */
131
+     static onVoiceRecordEnd( body:Object ):void;
132
+
133
+
134
+    /**
135
+      * 播放语音接口
136
+      * @param body
137
+      */
138
+     static playVoice( body:Object ):void;
139
+
140
+
141
+    /**
142
+      * 暂停播放接口
143
+      * @param body
144
+      */
145
+     static pauseVoice( body:Object ):void;
146
+
147
+
148
+    /**
149
+      * 停止播放接口
150
+      * @param body
151
+      */
152
+     static stopVoice( body:Object ):void;
153
+
154
+
155
+    /**
156
+      * 监听语音播放完毕接口
157
+      * @param body
158
+      */
159
+     static onVoicePlayEnd( body:Object ):void;
160
+
161
+    /**
162
+      * 上传语音接口
163
+      * @param body
164
+      */
165
+     static uploadVoice( body:Object ):void;
166
+
167
+
168
+    /**
169
+      * 下载语音接口
170
+      * @param body
171
+      */
172
+     static downloadVoice( body:Object ):void;
173
+
174
+
175
+    // ---- 智能接口
176
+
177
+    /**
178
+      * 识别音频并返回识别结果接口
179
+      * @param body
180
+      */
181
+     static translateVoice( body:Object ):void;
182
+
183
+
184
+    /// ---- 设备信息
185
+
186
+    /**
187
+      * 获取网络状态接口
188
+
189
+      * @param body
190
+      */
191
+     static getNetworkType( body:Object ):void;
192
+
193
+
194
+    /// ---- 地理位置
195
+
196
+    /**
197
+      * 使用微信内置地图查看位置接口
198
+      * @param body
199
+      */
200
+     static openLocation( body:Object ):void;
201
+
202
+
203
+    /**
204
+      * 获取地理位置接口
205
+      * @param body
206
+      */
207
+     static getLocation( body:Object ):void;
208
+
209
+    /// ---- 界面操作
210
+
211
+    /**
212
+      * 隐藏右上角菜单接口
213
+      * @param body
214
+      */
215
+     static hideOptionMenu( body:Object ):void;
216
+
217
+    /**
218
+      * 显示右上角菜单接口
219
+      * @param body
220
+      */
221
+     static showOptionMenu( body:Object ):void;
222
+
223
+    /**
224
+      * 关闭当前网页窗口接口
225
+      * @param body
226
+      */
227
+     static closeWindow( body:Object ):void;
228
+
229
+    /**
230
+      * 批量隐藏功能按钮接口
231
+      * @param body
232
+      */
233
+     static hideMenuItems( body:Object ):void;
234
+
235
+    /**
236
+      * 批量显示功能按钮接口
237
+      * @param body
238
+      */
239
+     static showMenuItems( body:Object ):void;
240
+
241
+    /**
242
+      * 隐藏所有非基础按钮接口
243
+      * @param body
244
+      */
245
+     static hideAllNonBaseMenuItem( body:Object ):void;
246
+
247
+    /**
248
+      * 显示所有功能按钮接口
249
+      * @param body
250
+      */
251
+     static showAllNonBaseMenuItem( body:Object ):void;
252
+
253
+    /// ---- 微信扫一扫
254
+
255
+    /**
256
+      * 调起微信扫一扫接口
257
+      * @param body
258
+      */
259
+     static scanQRCode( body:Object ):void;
260
+
261
+
262
+    /// ---- 微信小店
263
+
264
+    /**
265
+      * 跳转微信商品页接口
266
+      * @param body
267
+      */
268
+     static openProductSpecificView( body:Object ):void;
269
+
270
+
271
+    /// ---- 微信卡券
272
+
273
+    /**
274
+      * 调起适用于门店的卡券列表并获取用户选择列表
275
+      * @param body
276
+      */
277
+     static chooseCard( body:Object ):void;
278
+
279
+    /**
280
+      * 批量添加卡券接口
281
+      * @param body
282
+      */
283
+     static addCard( body:Object ):void;
284
+
285
+    /**
286
+      * 查看微信卡包中的卡券接口
287
+      * @param body
288
+      */
289
+     static openCard( body:Object ):void;
290
+
291
+    /// ---- 微信支付
292
+
293
+    /**
294
+      * 发起一个微信支付请求
295
+      * @param body
296
+      */
297
+     static chooseWXPay( body:Object ):void;
298
+
299
+}
300
+
301
+///////////////////////////////// 常用API的参数结构类
302
+
303
+/**
304
+ * config 参数结构
305
+ * jsApiList: 所有要调用的 API
306
+ */
307
+declare class BodyConfig {
308
+
309
+    debug:boolean;
310
+    appId:string;
311
+    timestamp:number;
312
+    nonceStr:string;
313
+    signature:string;
314
+    jsApiList:Array<string>;
315
+
316
+}
317
+
318
+/**
319
+ * checkJsApi 参数结构
320
+ * jsApiList:  需要检测的JS接口列表
321
+ */
322
+declare class BodyCheckJsAPISupport {
323
+
324
+    success:Function;
325
+    jsApiList:Array<string>;
326
+
327
+}
328
+
329
+/**
330
+ * onMenuShareTimeline 参数结构
331
+ */
332
+declare class BodyMenuShareTimeline {
333
+
334
+    title:string;
335
+    link:string;
336
+    imgUrl:string;
337
+    success:Function;
338
+    cancel: Function;
339
+
340
+}
341
+
342
+/**
343
+ * onMenuShareAppMessage 参数结构
344
+ */
345
+declare class BodyMenuShareAppMessage {
346
+
347
+    title:string;
348
+    desc:string;
349
+    link:string;
350
+    imgUrl:string;
351
+    type:string;
352
+    dataUrl:string;
353
+    success:Function;
354
+    cancel: Function;
355
+
356
+}
357
+
358
+/**
359
+ * onMenuShareQQ 参数结构
360
+ */
361
+declare class BodyMenuShareQQ {
362
+
363
+    title:string;
364
+    desc:string;
365
+    link:string;
366
+    imgUrl:string;
367
+    type:string;
368
+    dataUrl:string;
369
+    success:Function;
370
+    cancel: Function;
371
+
372
+}
373
+
374
+
375
+/**
376
+ * onMenuShareWeibo 参数结构
377
+ */
378
+declare class BodyMenuShareWeibo {
379
+
380
+    title:string;
381
+    desc:string;
382
+    link:string;
383
+    imgUrl:string;
384
+    success:Function;
385
+    cancel: Function;
386
+
387
+}
388
+
389
+export default wx;

+ 382 - 0
node_modules/weixin-jsapi/index.js

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

+ 595 - 0
node_modules/weixin-jsapi/jweixin-1.0.0.js

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

+ 24 - 0
node_modules/weixin-jsapi/package.json

@@ -0,0 +1,24 @@
1
+{
2
+  "name": "weixin-jsapi",
3
+  "version": "1.1.0",
4
+  "description": "微信官方 js-sdk es6 版本",
5
+  "main": "index.js",
6
+  "scripts": {
7
+    "test": "echo \"Error: no test specified\" && exit 1"
8
+  },
9
+  "repository": {
10
+    "type": "git",
11
+    "url": "git+https://github.com/jerexyz/weixin-jssdk.git"
12
+  },
13
+  "keywords": [
14
+    "weixin",
15
+    "wechat",
16
+    "jssdk"
17
+  ],
18
+  "author": "jere",
19
+  "license": "MIT",
20
+  "bugs": {
21
+    "url": "https://github.com/jerexyz/weixin-jssdk/issues"
22
+  },
23
+  "homepage": "https://github.com/jerexyz/weixin-jssdk#readme"
24
+}

+ 17 - 0
package-lock.json

@@ -0,0 +1,17 @@
1
+{
2
+  "name": "itsm-wx-handle",
3
+  "lockfileVersion": 3,
4
+  "requires": true,
5
+  "packages": {
6
+    "": {
7
+      "dependencies": {
8
+        "weixin-jsapi": "^1.1.0"
9
+      }
10
+    },
11
+    "node_modules/weixin-jsapi": {
12
+      "version": "1.1.0",
13
+      "resolved": "https://registry.npmmirror.com/weixin-jsapi/-/weixin-jsapi-1.1.0.tgz",
14
+      "integrity": "sha512-986drpgKs1yf8gK1A/hrdF2U5cjp/zW/7bhoL37JLoePhNiO14JqZpa+wlNslge0Hlw7gEXMTnEntFvvSXz8Bw=="
15
+    }
16
+  }
17
+}

+ 5 - 0
package.json

@@ -0,0 +1,5 @@
1
+{
2
+  "dependencies": {
3
+    "weixin-jsapi": "^1.1.0"
4
+  }
5
+}

+ 14 - 16
pages.json

@@ -1,17 +1,15 @@
1 1
 {
2
-	"pages": [{
3
-		"path": "pages/index/index",
4
-		"style": {
5
-			"navigationBarTitleText": "uni-app"
6
-		}
7
-	}],
8
-	"globalStyle": {
9
-		"navigationBarTextStyle": "black",
10
-		"navigationBarTitleText": "uni-app",
11
-		"navigationBarBackgroundColor": "#F8F8F8",
12
-		"backgroundColor": "#F8F8F8",
13
-		"app-plus": {
14
-			"background": "#efeff4"
15
-		}
16
-	}
17
-}
2
+  "pages": [{
3
+    "path": "pages/homePage/homePage",
4
+    "style": {
5
+      "h5": {
6
+        "titleNView": false
7
+      }
8
+    }
9
+  }],
10
+  "globalStyle": {
11
+    "navigationBarTextStyle": "black",
12
+    "navigationBarBackgroundColor": "#F8F8F8",
13
+    "backgroundColor": "#F8F8F8"
14
+  }
15
+}

+ 131 - 0
pages/homePage/homePage.vue

@@ -0,0 +1,131 @@
1
+<template>
2
+  <view>
3
+
4
+  </view>
5
+</template>
6
+
7
+<script setup>
8
+  import {
9
+    onLoad
10
+  } from '@dcloudio/uni-app'
11
+  import {
12
+    get,
13
+    post,
14
+  } from "@/http/http.js";
15
+  import {
16
+    useLoginUserStore
17
+  } from '@/stores/loginUser'
18
+  const loginUserStore = useLoginUserStore()
19
+
20
+  /**
21
+   * 微信登录
22
+   */
23
+  function wechatLoginEncrypt() {
24
+    const url = window.location.href.split("?");
25
+    if (!url[1]) {
26
+      wechatAuth();
27
+    } else {
28
+      const code = {
29
+        code: url[1],
30
+        type: 'user',
31
+      };
32
+      uni.showLoading({
33
+        title: "登录中",
34
+        mask: true,
35
+      });
36
+      post("/auth/wechatLoginEncrypt", code).then(res => {
37
+        uni.hideLoading();
38
+        if (res.state == 200) {
39
+          loginSuccess(res.user);
40
+        } else if (res.state == 501) {
41
+          uni.showModal({
42
+          	title: '提示',
43
+          	content: '您的账号被删除,请联系管理员',
44
+            showCancel: false,
45
+            confirmColor: '#49b856'
46
+          });
47
+        } else if (res.state == 403) {
48
+          // 没有填写微信和工号
49
+          // this.$createDialog({
50
+          //   type: 'prompt',
51
+          //   title: '请填写工号',
52
+          //   prompt: {
53
+          //     value: '',
54
+          //     placeholder: '请填写工号'
55
+          //   },
56
+          //   onConfirm: (e, promptValue) => {
57
+          //     console.log(e, promptValue);
58
+          //     that.$http.post("/auth/bindAccount", {
59
+          //       account: promptValue,
60
+          //       wechat: res.wechat
61
+          //     }).then(res1 => {
62
+          //       if (res1.data.status == 403) {
63
+          //         that
64
+          //           .$createDialog({
65
+          //             type: "alert",
66
+          //             title: '请联系管理员进行添加',
67
+          //             icon: "cubeic-alert"
68
+          //           })
69
+          //           .show();
70
+          //       } else {
71
+          //         wechatAuth();
72
+          //       }
73
+          //     })
74
+          //   }
75
+          // }).show()
76
+        } else {
77
+          uni.showModal({
78
+          	title: '提示',
79
+          	content: res.remarks || '请求数据失败!',
80
+            showCancel: false,
81
+            confirmColor: '#49b856'
82
+          });
83
+        }
84
+      });
85
+    }
86
+  }
87
+
88
+  /**
89
+   * 微信登录2
90
+   */
91
+  function wechatAuth() {
92
+    uni.showLoading({
93
+      title: "登录中",
94
+      mask: true,
95
+    });
96
+    post("/auth/wechatAuth", {
97
+      redirectUrl: location.origin + location.pathname
98
+    }).then(res => {
99
+      uni.hideLoading();
100
+      if (res.url) {
101
+        window.location.href = res.url;
102
+      } else {
103
+        loginSuccess(res.user);
104
+      }
105
+    });
106
+  }
107
+
108
+  /**
109
+   * 登录成功后的操作
110
+   */
111
+  function loginSuccess(user) {
112
+    loginUserStore.setLoginUser(user.user);
113
+    loginUserStore.setLoginUserMenu(user.menu);
114
+    // 判断用户标识是否为处理人
115
+    if(user.user.engineer === 1){
116
+      console.log('进入事件列表页');
117
+    }else{
118
+      console.log('进入错误页');
119
+    }
120
+  }
121
+
122
+  onLoad((option) => {
123
+    // #ifdef H5
124
+    wechatLoginEncrypt();
125
+    // #endif
126
+  })
127
+</script>
128
+
129
+<style lang="scss">
130
+
131
+</style>

+ 0 - 29
pages/index/index.vue

@@ -1,29 +0,0 @@
1
-<template>
2
-	<view class="container">
3
-		
4
-		<view class="intro">本项目已包含uni ui组件,无需import和注册,可直接使用。在代码区键入字母u,即可通过代码助手列出所有可用组件。光标置于组件名称处按F1,即可查看组件文档。</view>
5
-		<text class="intro">详见:</text>
6
-		<uni-link :href="href" :text="href"></uni-link>
7
-	</view>
8
-</template>
9
-
10
-<script>
11
-	export default {
12
-		data() {
13
-			return {
14
-				href: 'https://uniapp.dcloud.io/component/README?id=uniui'
15
-			}
16
-		},
17
-		methods: {
18
-
19
-		}
20
-	}
21
-</script>
22
-
23
-<style>
24
-	.container {
25
-		padding: 20px;
26
-		font-size: 14px;
27
-		line-height: 24px;
28
-	}
29
-</style>

+ 34 - 0
stores/loginUser.js

@@ -0,0 +1,34 @@
1
+import {
2
+  defineStore
3
+} from "pinia"
4
+import {
5
+  reactive
6
+} from 'vue'
7
+
8
+export const useLoginUserStore = defineStore(
9
+  "loginUser",
10
+  () => {
11
+    const loginUser = reactive({
12
+      user: {},
13
+      menu: [],
14
+    });
15
+
16
+    // 设置当前登录用户
17
+    function setLoginUser(data) {
18
+      loginUser.user = data;
19
+    }
20
+
21
+    // 设置当前登录用户菜单
22
+    function setLoginUserMenu(data) {
23
+      loginUser.menu = data;
24
+    }
25
+
26
+    return {
27
+      loginUser,
28
+      setLoginUser,
29
+      setLoginUserMenu,
30
+    };
31
+  }, {
32
+    unistorage: true, // 开启后对 state 的数据读写都将持久化
33
+  },
34
+);

+ 21 - 0
uni_modules/pinia-plugin-unistorage/changelog.md

@@ -0,0 +1,21 @@
1
+## 0.0.19(2024-01-18)
2
+fix: 重新构建,不需要默认参数
3
+## 0.0.16(2023-05-06)
4
+
5
+fix: 修复全局 key 移除
6
+
7
+## 0.0.14(2023-04-29)
8
+
9
+fix: 修复全局 global key 选项
10
+
11
+## 0.0.12(2023-04-07)
12
+
13
+- fix: 修复类型错误
14
+
15
+## 0.0.11(2023-03-22)
16
+
17
+- chore: ts 支持
18
+
19
+## 0.0.7(2022-04-29)
20
+
21
+- 更新 README

+ 86 - 0
uni_modules/pinia-plugin-unistorage/index.js

@@ -0,0 +1,86 @@
1
+function get(state, path) {
2
+  return path.reduce((obj, p) => {
3
+    return obj?.[p];
4
+  }, state);
5
+}
6
+function set(state, path, val) {
7
+  return path.slice(0, -1).reduce((obj, p) => {
8
+    if (!/^(__proto__)$/.test(p)) {
9
+      return obj[p] = obj[p] || {};
10
+    } else
11
+      return {};
12
+  }, state)[path[path.length - 1]] = val, state;
13
+}
14
+function pick(baseState, paths) {
15
+  return paths.reduce((substate, path) => {
16
+    const pathArray = path.split(".");
17
+    return set(
18
+      substate,
19
+      pathArray,
20
+      get(baseState, pathArray)
21
+    );
22
+  }, {});
23
+}
24
+
25
+const isObject = (v) => typeof v === "object" && v !== null;
26
+const normalizeOptions = (options, globalOptions) => {
27
+  options = isObject(options) ? options : /* @__PURE__ */ Object.create(null);
28
+  return new Proxy(options, {
29
+    get(t, p, r) {
30
+      return Reflect.get(t, p, r) || Reflect.get(globalOptions, p, r);
31
+    }
32
+  });
33
+};
34
+
35
+function passage(key) {
36
+  return key;
37
+}
38
+function createUnistorage(globalOptions = {}) {
39
+  const { key: normalizeKey = passage } = globalOptions || {};
40
+  if (globalOptions?.key) {
41
+    delete globalOptions.key;
42
+  }
43
+  return function(ctx) {
44
+    {
45
+      const { store, options } = ctx;
46
+      let { unistorage } = options || {};
47
+      if (!unistorage)
48
+        return;
49
+      const {
50
+        paths = null,
51
+        afterRestore,
52
+        beforeRestore,
53
+        serializer = {
54
+          serialize: JSON.stringify,
55
+          deserialize: JSON.parse
56
+        },
57
+        key = store.$id
58
+      } = normalizeOptions(unistorage, globalOptions);
59
+      beforeRestore?.(ctx);
60
+      const normalizedKey = normalizeKey(key);
61
+      try {
62
+        const fromStorage = uni.getStorageSync(normalizedKey);
63
+        if (fromStorage) {
64
+          store.$patch(serializer.deserialize(fromStorage));
65
+        }
66
+      } catch (_error) {
67
+      }
68
+      afterRestore?.(ctx);
69
+      store.$subscribe(
70
+        (_, state) => {
71
+          try {
72
+            const toStore = Array.isArray(paths) ? pick(state, paths) : state;
73
+            uni.setStorageSync(
74
+              normalizedKey,
75
+              serializer.serialize(toStore)
76
+            );
77
+          } catch (_error) {
78
+          }
79
+        },
80
+        { detached: true }
81
+      );
82
+    }
83
+  };
84
+}
85
+
86
+export { createUnistorage };

+ 84 - 0
uni_modules/pinia-plugin-unistorage/package.json

@@ -0,0 +1,84 @@
1
+{
2
+  "id": "pinia-plugin-unistorage",
3
+  "displayName": "pinia-plugin-unistorage",
4
+  "version": "0.0.19",
5
+  "description": "uniapp 下 pinia 的本地数据缓存插件",
6
+  "keywords": [
7
+    "pinia",
8
+    "uniapp",
9
+    "storage",
10
+    "pinia-plugin",
11
+    "persistence"
12
+],
13
+  "engines": {
14
+    "HBuilderX": "^3.4.7"
15
+  },
16
+  "dcloudext": {
17
+    "sale": {
18
+      "regular": {
19
+        "price": "0.00"
20
+      },
21
+      "sourcecode": {
22
+        "price": "0.00"
23
+      }
24
+    },
25
+    "contact": {
26
+      "qq": ""
27
+    },
28
+    "declaration": {
29
+      "ads": "无",
30
+      "data": "无",
31
+      "permissions": "无"
32
+    },
33
+    "npmurl": "https://www.npmjs.com/package/pinia-plugin-unistorage",
34
+    "type": "sdk-js"
35
+  },
36
+  "uni_modules": {
37
+    "dependencies": [],
38
+    "encrypt": [],
39
+    "platforms": {
40
+      "cloud": {
41
+        "tcb": "y",
42
+        "aliyun": "y"
43
+      },
44
+      "client": {
45
+        "Vue": {
46
+          "vue2": "y",
47
+          "vue3": "y"
48
+        },
49
+        "App": {
50
+          "app-vue": "y",
51
+          "app-nvue": "y"
52
+        },
53
+        "H5-mobile": {
54
+          "Safari": "y",
55
+          "Android Browser": "y",
56
+          "微信浏览器(Android)": "y",
57
+          "QQ浏览器(Android)": "y"
58
+        },
59
+        "H5-pc": {
60
+          "Chrome": "y",
61
+          "IE": "y",
62
+          "Edge": "y",
63
+          "Firefox": "y",
64
+          "Safari": "y"
65
+        },
66
+        "小程序": {
67
+          "微信": "y",
68
+          "阿里": "y",
69
+          "百度": "y",
70
+          "字节跳动": "y",
71
+          "QQ": "y",
72
+          "钉钉": "y",
73
+          "快手": "y",
74
+          "飞书": "y",
75
+          "京东": "y"
76
+        },
77
+        "快应用": {
78
+          "华为": "y",
79
+          "联盟": "y"
80
+        }
81
+      }
82
+    }
83
+  }
84
+}

+ 226 - 0
uni_modules/pinia-plugin-unistorage/readme.md

@@ -0,0 +1,226 @@
1
+<div align="center">
2
+    <img width="200px" height="200px" src="https://gitee.com/dishait/pinia-plugin-unistorage/raw/main/static/favicon.png" />
3
+    <h1>pinia-plugin-unistorage</h1>
4
+    <p>uniapp 下 pinia 的本地数据缓存插件</p>
5
+</div>
6
+
7
+<br />
8
+<br />
9
+
10
+<div align="center">
11
+    <img width="100%" height="100%" src="https://gitee.com/dishait/pinia-plugin-unistorage/raw/main/static/pinia-plugin-unistorage.gif" />
12
+</div>
13
+
14
+<br />
15
+<br />
16
+
17
+## 引用
18
+
19
+该插件是
20
+[pinia-plugin-persistedstate](https://github.com/prazdevs/pinia-plugin-persistedstate)
21
+的 `uniapp` 版本,如果你需要在纯 `vue` 或者 `nuxt` 项目中使用 `pinia`
22
+的本地数据缓存,请使用
23
+[pinia-plugin-persistedstate](https://github.com/prazdevs/pinia-plugin-persistedstate)。
24
+
25
+<br />
26
+<br />
27
+
28
+## 动机
29
+
30
+为了实现多端的更简单的全局本地数据缓存
31
+
32
+<br />
33
+<br />
34
+
35
+## 组织 🦔
36
+
37
+欢迎关注 **帝莎编程**
38
+
39
+- [官网](http://dishaxy.dishait.cn/)
40
+- [Gitee](https://gitee.com/dishait)
41
+- [Github](https://github.com/dishait)
42
+- [网易云课堂](https://study.163.com/provider/480000001892585/index.htm?share=2&shareId=480000001892585)
43
+
44
+<br />
45
+<br />
46
+
47
+## 使用
48
+
49
+### 安装
50
+
51
+#### 1. `cli` 创建的 `uniapp` 项目
52
+
53
+```shell
54
+npm i pinia-plugin-unistorage -D
55
+```
56
+
57
+```js
58
+// main.js
59
+import { createSSRApp } from "vue";
60
+import * as Pinia from "pinia";
61
+import { createUnistorage } from "pinia-plugin-unistorage";
62
+
63
+export function createApp() {
64
+  const app = createSSRApp(App);
65
+
66
+  const store = Pinia.createPinia();
67
+
68
+  // 关键代码 👇
69
+  store.use(createUnistorage());
70
+
71
+  app.use(store);
72
+
73
+  return {
74
+    app,
75
+    Pinia, // 此处必须将 Pinia 返回
76
+  };
77
+}
78
+```
79
+
80
+<br />
81
+
82
+#### 2. `hbuilderx` 创建的 `uniapp` 项目
83
+
84
+直接插件市场安装后引入注册
85
+
86
+```js
87
+// main.js
88
+import { createSSRApp } from "vue";
89
+import * as Pinia from "pinia";
90
+import { createUnistorage } from "./uni_modules/pinia-plugin-unistorage";
91
+
92
+export function createApp() {
93
+  const app = createSSRApp(App);
94
+
95
+  const store = Pinia.createPinia();
96
+
97
+  // 关键代码 👇
98
+  store.use(createUnistorage());
99
+
100
+  app.use(store);
101
+
102
+  return {
103
+    app,
104
+    Pinia, // 此处必须将 Pinia 返回
105
+  };
106
+}
107
+```
108
+
109
+### 基础
110
+
111
+```js
112
+import { defineStore } from "pinia";
113
+
114
+export const useStore = defineStore("main", {
115
+  state() {
116
+    return {
117
+      someState: "hello pinia",
118
+    };
119
+  },
120
+  unistorage: true, // 开启后对 state 的数据读写都将持久化
121
+});
122
+```
123
+
124
+或者 `setup` 语法也是支持的
125
+
126
+```js
127
+import { defineStore } from "pinia";
128
+
129
+export const useStore = defineStore(
130
+  "main",
131
+  () => {
132
+    const someState = ref("hello pinia");
133
+    return { someState };
134
+  },
135
+  {
136
+    unistorage: true, // 开启后对 state 的数据读写都将持久化
137
+  },
138
+);
139
+```
140
+
141
+<br />
142
+
143
+### 选项
144
+
145
+#### 钩子
146
+
147
+```js
148
+import { defineStore } from "pinia";
149
+
150
+export const useStore = defineStore("main", {
151
+  state() {
152
+    return {
153
+      someState: "hello pinia",
154
+    };
155
+  },
156
+  unistorage: {
157
+    // 初始化恢复前触发
158
+    beforeRestore(ctx) {},
159
+    // 初始化恢复后触发
160
+    afterRestore(ctx) {},
161
+  },
162
+});
163
+```
164
+
165
+<br />
166
+
167
+#### 序列化
168
+
169
+大多数情况下你并不需要了解该选项
170
+
171
+```js
172
+import { defineStore } from "pinia";
173
+
174
+export const useStore = defineStore("main", {
175
+  state() {
176
+    return {
177
+      someState: "hello pinia",
178
+    };
179
+  },
180
+  unistorage: {
181
+    serializer: {
182
+      // 序列化,默认为 JSON.stringify
183
+      serialize(v) {
184
+        return JSON.stringify(v);
185
+      },
186
+      // 反序列化,默认为 JSON.parse
187
+      deserialize(v) {
188
+        return JSON.parse(v);
189
+      },
190
+    },
191
+  },
192
+});
193
+```
194
+
195
+<br />
196
+
197
+#### 其他
198
+
199
+```js
200
+import { defineStore } from "pinia";
201
+
202
+export const useStore = defineStore("main", {
203
+  state() {
204
+    return {
205
+      foo: "foo",
206
+      nested: {
207
+        data: "nested pinia",
208
+      },
209
+      someState: "hello pinia",
210
+    };
211
+  },
212
+  unistorage: {
213
+    key: "foo", // 缓存的键,默认为该 store 的 id,这里是 main,
214
+    paths: ["foo", "nested.data"], // 需要缓存的路径,这里设置 foo 和 nested 下的 data 会被缓存
215
+  },
216
+});
217
+```
218
+
219
+<br />
220
+<br />
221
+
222
+## License
223
+
224
+Made with [markthree](https://github.com/markthree)
225
+
226
+Published under [MIT License](./LICENSE).

+ 28 - 0
uni_modules/pinia-plugin-unistorage/src/filter.ts

@@ -0,0 +1,28 @@
1
+import type { StateTree } from "pinia";
2
+
3
+function get(state: StateTree, path: Array<string>) {
4
+  return path.reduce((obj, p) => {
5
+    return obj?.[p];
6
+  }, state);
7
+}
8
+
9
+function set(state: StateTree, path: Array<string>, val: unknown): StateTree {
10
+  return (
11
+    (path.slice(0, -1).reduce((obj, p) => {
12
+      if (!/^(__proto__)$/.test(p)) {
13
+        return (obj[p] = obj[p] || {});
14
+      } else return {};
15
+    }, state)[path[path.length - 1]] = val), state
16
+  );
17
+}
18
+
19
+export function pick(baseState: StateTree, paths: string[]): StateTree {
20
+  return paths.reduce((substate, path) => {
21
+    const pathArray = path.split(".");
22
+    return set(
23
+      substate,
24
+      pathArray,
25
+      get(baseState, pathArray),
26
+    );
27
+  }, {});
28
+}

+ 65 - 0
uni_modules/pinia-plugin-unistorage/src/index.ts

@@ -0,0 +1,65 @@
1
+import { pick } from "./filter";
2
+import type { PiniaPlugin } from "pinia";
3
+import { normalizeOptions } from "./normalize";
4
+import { PersistedStateFactoryOptions } from "./types";
5
+
6
+function passage(key: string) {
7
+  return key;
8
+}
9
+
10
+export function createUnistorage(
11
+  globalOptions: PersistedStateFactoryOptions = {},
12
+): PiniaPlugin {
13
+  const { key: normalizeKey = passage } = globalOptions || {};
14
+  if (globalOptions?.key) {
15
+    delete globalOptions.key;
16
+  }
17
+  return function (ctx) {
18
+    {
19
+      const { store, options } = ctx;
20
+      // @ts-ignore
21
+      let { unistorage } = options || {};
22
+
23
+      if (!unistorage) return;
24
+
25
+      const {
26
+        paths = null,
27
+        afterRestore,
28
+        beforeRestore,
29
+        serializer = {
30
+          serialize: JSON.stringify,
31
+          deserialize: JSON.parse,
32
+        },
33
+        key = store.$id,
34
+      } = normalizeOptions(unistorage, globalOptions);
35
+
36
+      beforeRestore?.(ctx);
37
+
38
+      const normalizedKey = normalizeKey(key);
39
+
40
+      try {
41
+        // @ts-ignore
42
+        const fromStorage = uni.getStorageSync(normalizedKey);
43
+        if (fromStorage) {
44
+          store.$patch(serializer.deserialize(fromStorage));
45
+        }
46
+      } catch (_error) {}
47
+
48
+      afterRestore?.(ctx);
49
+
50
+      store.$subscribe(
51
+        (_, state) => {
52
+          try {
53
+            const toStore = Array.isArray(paths) ? pick(state, paths) : state;
54
+            // @ts-ignore
55
+            uni.setStorageSync(
56
+              normalizedKey,
57
+              serializer.serialize(toStore),
58
+            );
59
+          } catch (_error) {}
60
+        },
61
+        { detached: true },
62
+      );
63
+    }
64
+  };
65
+}

+ 23 - 0
uni_modules/pinia-plugin-unistorage/src/normalize.ts

@@ -0,0 +1,23 @@
1
+import type {
2
+  PersistedStateFactoryOptions,
3
+  PersistedStateOptions,
4
+} from "./types";
5
+
6
+const isObject = (v: unknown): v is Object =>
7
+  typeof v === "object" && v !== null;
8
+
9
+export const normalizeOptions = (
10
+  options: boolean | PersistedStateOptions | undefined,
11
+  globalOptions: PersistedStateFactoryOptions,
12
+): PersistedStateOptions => {
13
+  options = isObject(options) ? options : Object.create(null);
14
+
15
+  return new Proxy(options as object, {
16
+    get(t, p, r) {
17
+      return (
18
+        Reflect.get(t, p, r) ||
19
+        Reflect.get(globalOptions, p, r)
20
+      );
21
+    },
22
+  });
23
+};

+ 69 - 0
uni_modules/pinia-plugin-unistorage/src/types.ts

@@ -0,0 +1,69 @@
1
+import type { PiniaPluginContext, StateTree } from "pinia";
2
+
3
+type Prettify<T> = { [K in keyof T]: T[K] };
4
+
5
+export type StorageLike = Pick<Storage, "getItem" | "setItem">;
6
+
7
+export interface Serializer {
8
+  /**
9
+   * Serializes state into string before storing
10
+   * @default JSON.stringify
11
+   */
12
+  serialize: (value: StateTree) => string;
13
+
14
+  /**
15
+   * Deserializes string into state before hydrating
16
+   * @default JSON.parse
17
+   */
18
+  deserialize: (value: string) => StateTree;
19
+}
20
+
21
+export interface PersistedStateOptions {
22
+  /**
23
+   * Storage key to use.
24
+   * @default $store.id
25
+   */
26
+  key?: string;
27
+
28
+  /**
29
+   * Dot-notation paths to partially save state. Saves everything if undefined.
30
+   * @default undefined
31
+   */
32
+  paths?: Array<string>;
33
+
34
+  /**
35
+   * Customer serializer to serialize/deserialize state.
36
+   */
37
+  serializer?: Serializer;
38
+
39
+  /**
40
+   * Hook called before state is hydrated from storage.
41
+   * @default null
42
+   */
43
+  beforeRestore?: (context: PiniaPluginContext) => void;
44
+
45
+  /**
46
+   * Hook called after state is hydrated from storage.
47
+   * @default undefined
48
+   */
49
+  afterRestore?: (context: PiniaPluginContext) => void;
50
+}
51
+
52
+export type PersistedStateFactoryOptions = Prettify<
53
+  Pick<
54
+    PersistedStateOptions,
55
+    "serializer" | "afterRestore" | "beforeRestore"
56
+  > & {
57
+    /**
58
+     * Global key generator, allows pre/postfixing store keys.
59
+     * @default storeKey => storeKey
60
+     */
61
+    key?: (storeKey: string) => string;
62
+  }
63
+>;
64
+
65
+declare module "pinia" {
66
+  export interface DefineStoreOptionsBase<S extends StateTree, Store> {
67
+    unistorage?: boolean | PersistedStateOptions;
68
+  }
69
+}