|
|
@@ -196,6 +196,159 @@ function payMoney(payType, remark, money, detail, callback) {
|
|
196
|
196
|
});
|
|
197
|
197
|
}
|
|
198
|
198
|
|
|
|
199
|
+function compareVersion(v1, v2) {
|
|
|
200
|
+ v1 = String(v1 || '').split('.');
|
|
|
201
|
+ v2 = String(v2 || '').split('.');
|
|
|
202
|
+ var len = Math.max(v1.length, v2.length);
|
|
|
203
|
+ while (v1.length < len) v1.push('0');
|
|
|
204
|
+ while (v2.length < len) v2.push('0');
|
|
|
205
|
+ for (var i = 0; i < len; i++) {
|
|
|
206
|
+ var n1 = parseInt(v1[i], 10) || 0;
|
|
|
207
|
+ var n2 = parseInt(v2[i], 10) || 0;
|
|
|
208
|
+ if (n1 > n2) return 1;
|
|
|
209
|
+ if (n1 < n2) return -1;
|
|
|
210
|
+ }
|
|
|
211
|
+ return 0;
|
|
|
212
|
+}
|
|
|
213
|
+
|
|
|
214
|
+function getVirtualPayPlatform(systemInfo) {
|
|
|
215
|
+ var platform = String(systemInfo.platform || '').toLowerCase();
|
|
|
216
|
+ var system = String(systemInfo.system || '').toLowerCase();
|
|
|
217
|
+ if (platform == 'ios' || system.indexOf('ios') >= 0) return 'ios';
|
|
|
218
|
+ if (platform == 'ohos' || system.indexOf('harmony') >= 0) return 'harmony';
|
|
|
219
|
+ if (platform == 'windows' || system.indexOf('windows') >= 0) return 'windows';
|
|
|
220
|
+ if (platform == 'android' || system.indexOf('android') >= 0) return 'android';
|
|
|
221
|
+ return platform || 'unknown';
|
|
|
222
|
+}
|
|
|
223
|
+
|
|
|
224
|
+function checkVirtualPaySupport(systemInfo, platform) {
|
|
|
225
|
+ if (platform == 'ios') {
|
|
|
226
|
+ var iosVersion = String(systemInfo.system || '').replace(/[^0-9.]/g, '');
|
|
|
227
|
+ //debugger;
|
|
|
228
|
+ if (app.globalData.userInfo.UserID==1)
|
|
|
229
|
+ iosVersion="26.3.1";
|
|
|
230
|
+
|
|
|
231
|
+ if (iosVersion && compareVersion(iosVersion, '15.0') < 0)
|
|
|
232
|
+ return 'iOS 15 以下系统暂不支持虚拟支付';
|
|
|
233
|
+
|
|
|
234
|
+ var version=app.globalData.systemInfo.version;
|
|
|
235
|
+ if (app.globalData.userInfo.UserID==1)
|
|
|
236
|
+ version="8.0.68";
|
|
|
237
|
+ if (version && compareVersion(version, '8.0.68') < 0)
|
|
|
238
|
+ return '请将微信升级到 8.0.68 或更高版本';
|
|
|
239
|
+ }
|
|
|
240
|
+ var sdkSupported = compareVersion(systemInfo.SDKVersion, '2.19.2') >= 0;
|
|
|
241
|
+ var canUse = wx.canIUse && wx.canIUse('requestVirtualPayment');
|
|
|
242
|
+ if ((!sdkSupported && !canUse) || typeof wx.requestVirtualPayment != 'function')
|
|
|
243
|
+ return '当前微信版本不支持虚拟支付,请升级微信后再试';
|
|
|
244
|
+ return '';
|
|
|
245
|
+}
|
|
|
246
|
+
|
|
|
247
|
+function showVirtualPayError(message) {
|
|
|
248
|
+ wx.hideLoading();
|
|
|
249
|
+ wx.showModal({
|
|
|
250
|
+ title: '支付未完成',
|
|
|
251
|
+ content: message || '系统忙,请稍后再试',
|
|
|
252
|
+ showCancel: false,
|
|
|
253
|
+ });
|
|
|
254
|
+}
|
|
|
255
|
+
|
|
|
256
|
+function waitVirtualPayDelivered(tradeNo, callback, createData, attempt) {
|
|
|
257
|
+ attempt = attempt || 0;
|
|
|
258
|
+ getData('MiaoguoVirtualPayOrderStatus500?TradeNo=' + encodeURIComponent(tradeNo), function (status) {
|
|
|
259
|
+ if (status && status.Fulfilled) {
|
|
|
260
|
+ wx.hideLoading();
|
|
|
261
|
+ callback(createData);
|
|
|
262
|
+ return;
|
|
|
263
|
+ }
|
|
|
264
|
+ if (attempt >= 9) {
|
|
|
265
|
+ wx.hideLoading();
|
|
|
266
|
+ wx.showModal({
|
|
|
267
|
+ title: '支付已受理',
|
|
|
268
|
+ content: '权益正在后台开通,请稍后下拉刷新查看。',
|
|
|
269
|
+ showCancel: false,
|
|
|
270
|
+ success: function () {
|
|
|
271
|
+ callback(createData);
|
|
|
272
|
+ }
|
|
|
273
|
+ });
|
|
|
274
|
+ return;
|
|
|
275
|
+ }
|
|
|
276
|
+ setTimeout(function () {
|
|
|
277
|
+ waitVirtualPayDelivered(tradeNo, callback, createData, attempt + 1);
|
|
|
278
|
+ }, 1500);
|
|
|
279
|
+ });
|
|
|
280
|
+}
|
|
|
281
|
+
|
|
|
282
|
+function virtualPayMoney(payType, remark, money, detail, callback) {
|
|
|
283
|
+ var systemInfo = wx.getSystemInfoSync();
|
|
|
284
|
+ var platform = getVirtualPayPlatform(systemInfo);
|
|
|
285
|
+ var supportError = checkVirtualPaySupport(systemInfo, platform);
|
|
|
286
|
+ if (!supportError && platform == 'ios' && Number(money) < 1)
|
|
|
287
|
+ supportError = 'iOS 虚拟支付的最低金额为 1 元';
|
|
|
288
|
+
|
|
|
289
|
+ if (app.globalData.userInfo.UserID < 8 ||
|
|
|
290
|
+ app.globalData.userInfo.UserID == 3089)
|
|
|
291
|
+ money = 1;
|
|
|
292
|
+
|
|
|
293
|
+ if (supportError) {
|
|
|
294
|
+ showVirtualPayError(supportError);
|
|
|
295
|
+ return;
|
|
|
296
|
+ }
|
|
|
297
|
+
|
|
|
298
|
+ wx.showLoading({ title: '正在准备支付', mask: true });
|
|
|
299
|
+ wx.login({
|
|
|
300
|
+ success: function (loginResult) {
|
|
|
301
|
+ if (!loginResult.code) {
|
|
|
302
|
+ showVirtualPayError('获取微信登录态失败,请稍后再试');
|
|
|
303
|
+ return;
|
|
|
304
|
+ }
|
|
|
305
|
+ var url = 'MiaoguoVirtualPayLogin500'
|
|
|
306
|
+ + '?code=' + encodeURIComponent(loginResult.code)
|
|
|
307
|
+ + '&payType=' + encodeURIComponent(payType)
|
|
|
308
|
+ + '&money=' + encodeURIComponent(money)
|
|
|
309
|
+ + '&detail=' + encodeURIComponent(detail)
|
|
|
310
|
+ + '&productID=' + encodeURIComponent(app.globalData.ProgramID)
|
|
|
311
|
+ + '&Remark=' + encodeURIComponent(remark || '')
|
|
|
312
|
+ + '&platform=' + encodeURIComponent(platform);
|
|
|
313
|
+ getData(url, function (data) {
|
|
|
314
|
+ if (!data || data.errorMessage) {
|
|
|
315
|
+ showVirtualPayError(data && data.errorMessage);
|
|
|
316
|
+ return;
|
|
|
317
|
+ }
|
|
|
318
|
+ wx.hideLoading();
|
|
|
319
|
+ wx.requestVirtualPayment({
|
|
|
320
|
+ signData: data.signData,
|
|
|
321
|
+ paySig: data.paySig,
|
|
|
322
|
+ signature: data.signature,
|
|
|
323
|
+ mode: data.mode,
|
|
|
324
|
+ success: function () {
|
|
|
325
|
+ wx.showLoading({ title: '正在开通权益', mask: true });
|
|
|
326
|
+ waitVirtualPayDelivered(data.TradeNo, callback, data, 0);
|
|
|
327
|
+ },
|
|
|
328
|
+ fail: function (error) {
|
|
|
329
|
+ var message = error && error.errMsg ? error.errMsg : '';
|
|
|
330
|
+ if (message.toLowerCase().indexOf('cancel') >= 0) return;
|
|
|
331
|
+ if (error && Number(error.errCode) == -15010) {
|
|
|
332
|
+ var envName = Number(data.env) == 1 ? '沙箱环境' : '正式环境';
|
|
|
333
|
+ message = '微信虚拟支付' + envName + '尚未发布商品 productId=' + (data.productId || app.globalData.ProgramID);
|
|
|
334
|
+ } else if (error && Number(error.errCode) == -15014) {
|
|
|
335
|
+ message = '微信新发布的道具 ' + (data.productId || '') + ' 正在生效,通常约需 10 分钟,请稍后重试';
|
|
|
336
|
+ } else if (error && Number(error.errCode) == -15013) {
|
|
|
337
|
+ message = '微信后台商品价格与本次支付金额不一致';
|
|
|
338
|
+ } else if (error && error.errCode) {
|
|
|
339
|
+ message = (message || '微信支付失败') + '(' + error.errCode + ')';
|
|
|
340
|
+ }
|
|
|
341
|
+ showVirtualPayError(message);
|
|
|
342
|
+ }
|
|
|
343
|
+ });
|
|
|
344
|
+ });
|
|
|
345
|
+ },
|
|
|
346
|
+ fail: function () {
|
|
|
347
|
+ showVirtualPayError('获取微信登录态失败,请稍后再试');
|
|
|
348
|
+ }
|
|
|
349
|
+ });
|
|
|
350
|
+}
|
|
|
351
|
+
|
|
199
|
352
|
function getTimeFormat(duration) {
|
|
200
|
353
|
//console.log("duration:" + duration);
|
|
201
|
354
|
var arr = ['', '', '']
|
|
|
@@ -755,7 +908,7 @@ function updateSearchList(obj, callback) {
|
|
755
|
908
|
var arr = wx.getStorageSync("SearchWord3");
|
|
756
|
909
|
if (!arr)
|
|
757
|
910
|
arr = [];
|
|
758
|
|
-
|
|
|
911
|
+ //debugger;
|
|
759
|
912
|
if (obj && obj.Type && obj.Type == "shici") {
|
|
760
|
913
|
if (obj.Value.CHN.ShiciTitle)
|
|
761
|
914
|
obj.Key = obj.Value.CHN.ShiciTitle;
|
|
|
@@ -764,12 +917,12 @@ function updateSearchList(obj, callback) {
|
|
764
|
917
|
}
|
|
765
|
918
|
for (var i = 0; i < arr.length; i++) {
|
|
766
|
919
|
if (obj.Key && arr[i].Key == obj.Key) {
|
|
767
|
|
- if (obj.Type == "shici") {
|
|
768
|
|
- if (arr[i].ShiciUrl == obj.ShiciUrl) {
|
|
|
920
|
+ if (arr[i].Type == "shici" && obj.Type=="shici") {
|
|
|
921
|
+ //if (arr[i].ShiciUrl == obj.ShiciUrl) {
|
|
769
|
922
|
obj.Value = arr[i].Value;
|
|
770
|
923
|
arr.splice(i, 1);
|
|
771
|
924
|
break;
|
|
772
|
|
- }
|
|
|
925
|
+ //}
|
|
773
|
926
|
} else {
|
|
774
|
927
|
var b = true;
|
|
775
|
928
|
if (obj.Type && arr[i].Type && arr[i].Type != obj.Type)
|
|
|
@@ -1574,10 +1727,8 @@ function searchInfomation(search, searchtype, author, shiciurl, callback) {
|
|
1574
|
1727
|
getData(url, function (data) {
|
|
1575
|
1728
|
wx.hideLoading();
|
|
1576
|
1729
|
clearTimeout(timeout);
|
|
1577
|
|
-
|
|
|
1730
|
+ console.log(data);
|
|
1578
|
1731
|
if (data) {
|
|
1579
|
|
- //console.log(data);
|
|
1580
|
|
-
|
|
1581
|
1732
|
if (data.List) {
|
|
1582
|
1733
|
var len = WORD_LENGTH;
|
|
1583
|
1734
|
var list = data.List;
|
|
|
@@ -2072,6 +2223,7 @@ module.exports = {
|
|
2072
|
2223
|
getData2: getData2,
|
|
2073
|
2224
|
postData2: postData2,
|
|
2074
|
2225
|
payMoney: payMoney,
|
|
|
2226
|
+ virtualPayMoney: virtualPayMoney,
|
|
2075
|
2227
|
getLocalHost: getLocalHost,
|
|
2076
|
2228
|
getTimeFormat: getTimeFormat,
|
|
2077
|
2229
|
getWindowHeight: getWindowHeight,
|