@alu008/test_yuanqikaixiang 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/App.vue +294 -0
  2. package/Local/en.json +3 -0
  3. package/Local/indian.json +3 -0
  4. package/Local/zh-Hans.json +3 -0
  5. package/Local/zh-Hant.json +3 -0
  6. package/README.md +1 -0
  7. package/androidPrivacy.json +28 -0
  8. package/components/ball/ball.vue +230 -0
  9. package/components/cardDetails/cardDetails.vue +273 -0
  10. package/components/confirmModal/confirmModal.vue +125 -0
  11. package/components/fillInfo/fillInfo.vue +255 -0
  12. package/components/header/header.vue +92 -0
  13. package/components/selectAddress/selectAddress.vue +156 -0
  14. package/components/signDetail/signDetail.vue +33 -0
  15. package/components/skeleton/skeleton.vue +62 -0
  16. package/index.html +20 -0
  17. package/index.template.html +35 -0
  18. package/jsconfig.json +9 -0
  19. package/main.js +48 -0
  20. package/manifest.json +159 -0
  21. package/package.json +14 -0
  22. package/pages/index/index.vue +5421 -0
  23. package/pages.json +173 -0
  24. package/project.config.json +25 -0
  25. package/project.private.config.json +14 -0
  26. package/static/fonts/Alibaba-PuHuiTi-Bold.ttf +0 -0
  27. package/static/fonts/Alibaba-PuHuiTi-Medium.ttf +0 -0
  28. package/static/fonts/Alibaba-PuHuiTi-Regular.ttf +0 -0
  29. package/static/fonts/fxlh.ttf +0 -0
  30. package/static/img/R.png +0 -0
  31. package/static/img/SR.png +0 -0
  32. package/static/img/SSR.png +0 -0
  33. package/static/img/bottomBgc1.png +0 -0
  34. package/static/img/centerBgc.png +0 -0
  35. package/static/img/goldBgc.png +0 -0
  36. package/static/img/goldText.png +0 -0
  37. package/static/img/home/calendar/bgc0.png +0 -0
  38. package/static/img/home/calendar/bgc1.png +0 -0
  39. package/static/img/home/calendar/bgc2.png +0 -0
  40. package/static/img/home/calendar/bgc3.png +0 -0
  41. package/static/img/home/calendar/progress0.png +0 -0
  42. package/static/img/home/calendar/progress1.png +0 -0
  43. package/static/img/home/calendar/progress2.png +0 -0
  44. package/static/img/home/calendar/progress3.png +0 -0
  45. package/static/img/kuang.gif +0 -0
  46. package/static/img/luckyBgc.png +0 -0
  47. package/static/img/lucyText.png +0 -0
  48. package/static/img/top_Bgc.png +0 -0
  49. package/subpackages/article/article.vue +64 -0
  50. package/subpackages/confirmSendLogistics/confirmSendLogistics.vue +1035 -0
  51. package/subpackages/coupon/coupon.vue +276 -0
  52. package/subpackages/fragment/fragment.vue +1592 -0
  53. package/subpackages/myAddress/myAddress.vue +656 -0
  54. package/subpackages/myCards/myCards.vue +1250 -0
  55. package/subpackages/myOrder/myOrder.vue +779 -0
  56. package/subpackages/myOrderDetail/myOrderDetail.vue +659 -0
  57. package/subpackages/poster/poster.vue +130 -0
  58. package/subpackages/selectCoupon/selectCoupon.vue +251 -0
  59. package/subpackages/sendLogistics/sendLogistics.vue +1097 -0
  60. package/subpackages/vote/vote.vue +877 -0
  61. package/uni.promisify.adaptor.js +10 -0
  62. package/uni.scss +114 -0
  63. package/uni_modules/qf-image-cropper/changelog.md +72 -0
  64. package/uni_modules/qf-image-cropper/components/qf-image-cropper/qf-image-cropper.render.js +855 -0
  65. package/uni_modules/qf-image-cropper/components/qf-image-cropper/qf-image-cropper.vue +749 -0
  66. package/uni_modules/qf-image-cropper/components/qf-image-cropper/qf-image-cropper.wxs +727 -0
  67. package/uni_modules/qf-image-cropper/package.json +81 -0
  68. package/uni_modules/qf-image-cropper/readme.md +97 -0
  69. package/uni_modules/uni-data-select/changelog.md +51 -0
  70. package/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue +837 -0
  71. package/uni_modules/uni-data-select/package.json +106 -0
  72. package/uni_modules/uni-data-select/readme.md +8 -0
  73. package/uni_modules/uni-icons/changelog.md +44 -0
  74. package/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue +91 -0
  75. package/uni_modules/uni-icons/components/uni-icons/uni-icons.vue +110 -0
  76. package/uni_modules/uni-icons/components/uni-icons/uniicons.css +664 -0
  77. package/uni_modules/uni-icons/components/uni-icons/uniicons.ttf +0 -0
  78. package/uni_modules/uni-icons/components/uni-icons/uniicons_file.ts +664 -0
  79. package/uni_modules/uni-icons/components/uni-icons/uniicons_file_vue.js +649 -0
  80. package/uni_modules/uni-icons/package.json +111 -0
  81. package/uni_modules/uni-icons/readme.md +8 -0
  82. package/uni_modules/uni-load-more/changelog.md +23 -0
  83. package/uni_modules/uni-load-more/components/uni-load-more/i18n/en.json +5 -0
  84. package/uni_modules/uni-load-more/components/uni-load-more/i18n/index.js +8 -0
  85. package/uni_modules/uni-load-more/components/uni-load-more/i18n/zh-Hans.json +5 -0
  86. package/uni_modules/uni-load-more/components/uni-load-more/i18n/zh-Hant.json +5 -0
  87. package/uni_modules/uni-load-more/components/uni-load-more/uni-load-more.vue +404 -0
  88. package/uni_modules/uni-load-more/package.json +105 -0
  89. package/uni_modules/uni-load-more/readme.md +14 -0
  90. package/uni_modules/uni-scss/changelog.md +8 -0
  91. package/uni_modules/uni-scss/index.scss +1 -0
  92. package/uni_modules/uni-scss/package.json +82 -0
  93. package/uni_modules/uni-scss/readme.md +4 -0
  94. package/uni_modules/uni-scss/styles/index.scss +7 -0
  95. package/uni_modules/uni-scss/styles/setting/_border.scss +3 -0
  96. package/uni_modules/uni-scss/styles/setting/_color.scss +66 -0
  97. package/uni_modules/uni-scss/styles/setting/_radius.scss +55 -0
  98. package/uni_modules/uni-scss/styles/setting/_space.scss +56 -0
  99. package/uni_modules/uni-scss/styles/setting/_styles.scss +167 -0
  100. package/uni_modules/uni-scss/styles/setting/_text.scss +24 -0
  101. package/uni_modules/uni-scss/styles/setting/_variables.scss +146 -0
  102. package/uni_modules/uni-scss/styles/tools/functions.scss +19 -0
  103. package/uni_modules/uni-scss/theme.scss +31 -0
  104. package/uni_modules/uni-scss/variables.scss +62 -0
  105. package/utils/addressData.js +6042 -0
  106. package/utils/api.js +160 -0
  107. package/utils/fetch.js +548 -0
  108. package/utils/index.js +994 -0
  109. package/utils/navigator.js +17 -0
  110. package/utils/request.js +162 -0
package/utils/index.js ADDED
@@ -0,0 +1,994 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { staticUrl } from "./api";
3
+ import { isProd } from "./api";
4
+ export const isLogin = () => {
5
+ let userData = uni.getStorageSync("userData") ?? {};
6
+ if (userData?.user_sn && userData?.mobile) {
7
+ return true;
8
+ } else {
9
+ return false;
10
+ }
11
+ };
12
+
13
+ export const getNavBarInfo = (extraHeight) => {
14
+ // wx.getMenuButtonBoundingClientRect();
15
+ let menuButton = null;
16
+ let height = 0;
17
+ const systemInfo = uni.getSystemInfoSync();
18
+ console.log(systemInfo.statusBarHeight, " systemInfo.statusBarHeight");
19
+ if (systemInfo.uniPlatform == "web" || systemInfo.uniPlatform == "h5") {
20
+ height = 44;
21
+ } else if (systemInfo.uniPlatform == "app") {
22
+ height = 44;
23
+ } else {
24
+ menuButton = wx.getMenuButtonBoundingClientRect();
25
+ height =
26
+ (menuButton.top - systemInfo.statusBarHeight) * 2 + menuButton.height;
27
+ }
28
+
29
+ return {
30
+ statusBarHeight: systemInfo.statusBarHeight, // 状态栏高度
31
+ navBarHeight: height,
32
+ // menuButtonRect: menuButton, // 胶囊位置信息
33
+ systemInfo: systemInfo,
34
+ scrollHeight:
35
+ systemInfo.windowHeight -
36
+ height -
37
+ systemInfo.statusBarHeight -
38
+ extraHeight,
39
+ };
40
+ };
41
+
42
+ export const isMobilePhone = (value) => {
43
+ return /^1[3-9]\d{9}$/.test(value);
44
+ };
45
+
46
+ export const toBigNumer = (value) => {
47
+ return new BigNumber(value);
48
+ };
49
+
50
+ export const addBigNumer = (value1, value2) => {
51
+ return toBigNumer(value1).plus(toBigNumer(value2));
52
+ };
53
+
54
+ export const timesBigNumer = (value1, value2) => {
55
+ return toBigNumer(value1).times(toBigNumer(value2));
56
+ };
57
+
58
+ export const subBigNumer = (value1, value2) => {
59
+ return toBigNumer(value1).minus(toBigNumer(value2));
60
+ };
61
+
62
+ export const divBigNumer = (value1, value2) => {
63
+ return toBigNumer(value1).dividedBy(toBigNumer(value2));
64
+ };
65
+
66
+ export const fixBigNumer = (value1, decimal = 2) => {
67
+ return toBigNumer(value1).toFormat(decimal, 1);
68
+ };
69
+ export const toFixed = (value, decimal = 2) => {
70
+ return toBigNumer(value).toFixed(decimal, 1);
71
+ };
72
+ export const checkLoginStatus = () => {
73
+ let userData = uni.getStorageSync("userInfo") ?? "";
74
+ if (userData) {
75
+ return true;
76
+ } else {
77
+ return false;
78
+ }
79
+ };
80
+
81
+ export const checkHasPhone = () => {
82
+ let userData = uni.getStorageSync("userInfo") ?? {};
83
+ if (userData?.detail && userData?.detail?.phone) {
84
+ return true;
85
+ } else {
86
+ return false;
87
+ }
88
+ };
89
+
90
+ export function getImageThemeColor(path, canvasId, callback) {
91
+ // 小程序下获取网络图片信息需先配置 download 域名白名单才能生效。
92
+ uni.getImageInfo({
93
+ src: path,
94
+ success: function (img) {
95
+ // 创建一个 Canvas 对象
96
+ const ctx = uni.createCanvasContext(canvasId);
97
+ // 将图片绘制到 Canvas 上
98
+ const imgWidth = canvasId == "getThemeColorCanvasArt" ? 40 : 45;
99
+ const imgHeight = canvasId == "getThemeColorCanvasArt" ? 40 : 97.44;
100
+ ctx.drawImage(img.path, 0, 0, imgWidth, imgHeight);
101
+ // ctx.save();
102
+ ctx.draw(false, () => {
103
+ uni.canvasGetImageData({
104
+ canvasId: canvasId,
105
+ x: 0,
106
+ y: 0,
107
+ width: imgWidth,
108
+ height: imgHeight,
109
+ success(res) {
110
+ const data = res.data;
111
+ let r = 0,
112
+ g = 0,
113
+ b = 0;
114
+ const total = data.length / 4;
115
+
116
+ for (let i = 0; i < data.length; i += 4) {
117
+ r += data[i]; // R
118
+ g += data[i + 1]; // G
119
+ b += data[i + 2]; // B
120
+ // 忽略透明通道 alpha = data[i+3] 可选
121
+ }
122
+
123
+ r = Math.round(r / total);
124
+ g = Math.round(g / total);
125
+ b = Math.round(b / total);
126
+ if (!!callback) {
127
+ // 返回图片主题色的 RGB 颜色值
128
+ callback(`${r},${g},${b}`);
129
+ }
130
+ },
131
+ fail: function (err) {
132
+ console.log(err);
133
+ callback(defaulColor);
134
+ },
135
+ });
136
+ });
137
+ },
138
+ fail: function (err) {
139
+ console.log(err);
140
+ callback(defaulColor);
141
+ },
142
+ });
143
+ }
144
+
145
+ export function getTestImageThemeColor(path, canvasId, callback) {
146
+ const suffix = path.split(".").slice(-1)[0];
147
+ uni.request({
148
+ url: path,
149
+ responseType: "arraybuffer",
150
+ success: (res) => {
151
+ let base64 = uni.arrayBufferToBase64(res.data);
152
+ const img = {
153
+ path: `data:image/${suffix};base64,${base64}`,
154
+ };
155
+
156
+ const ctx = uni.createCanvasContext(canvasId);
157
+ // 将图片绘制到 Canvas 上
158
+ const imgWidth = canvasId == "getThemeColorCanvasArt" ? 40 : 45;
159
+ const imgHeight = canvasId == "getThemeColorCanvasArt" ? 40 : 97.44;
160
+ ctx.drawImage(img.path, 0, 0, imgWidth, imgHeight);
161
+ // ctx.save();
162
+ ctx.draw(false, () => {
163
+ uni.canvasGetImageData({
164
+ canvasId: canvasId,
165
+ x: 0,
166
+ y: 0,
167
+ width: imgWidth,
168
+ height: imgHeight,
169
+ success(res) {
170
+ const data = res.data;
171
+ let r = 0,
172
+ g = 0,
173
+ b = 0;
174
+ const total = data.length / 4;
175
+
176
+ for (let i = 0; i < data.length; i += 4) {
177
+ r += data[i]; // R
178
+ g += data[i + 1]; // G
179
+ b += data[i + 2]; // B
180
+ // 忽略透明通道 alpha = data[i+3] 可选
181
+ }
182
+
183
+ r = Math.round(r / total);
184
+ g = Math.round(g / total);
185
+ b = Math.round(b / total);
186
+ if (!!callback) {
187
+ // 返回图片主题色的 RGB 颜色值
188
+ callback(`${r},${g},${b}`);
189
+ }
190
+ },
191
+ fail: function (err) {
192
+ console.log(err);
193
+ callback(defaulColor);
194
+ },
195
+ });
196
+ });
197
+ },
198
+ });
199
+ }
200
+ export function getImageThemeBottomColor(path, canvasId, callback) {
201
+ // 小程序下获取网络图片信息需先配置 download 域名白名单才能生效。
202
+ uni.getImageInfo({
203
+ src: path,
204
+ success: function (img) {
205
+ // 创建一个 Canvas 对象
206
+ const ctx = uni.createCanvasContext(canvasId);
207
+ // 将图片绘制到 Canvas 上
208
+ const imgWidth = 45;
209
+ const imgHeight = 97.44;
210
+ ctx.drawImage(img.path, 0, 0, imgWidth, imgHeight);
211
+ // ctx.save();
212
+ ctx.draw(false, () => {
213
+ uni.canvasGetImageData({
214
+ canvasId: canvasId,
215
+ x: 0,
216
+ y: imgHeight - Math.floor(imgHeight / 6), // imgHeight / 2,
217
+ width: imgWidth,
218
+ height: Math.floor(imgHeight / 6),
219
+ success(res) {
220
+ const data = res.data;
221
+ let r = 0,
222
+ g = 0,
223
+ b = 0;
224
+ const total = data.length / 4;
225
+
226
+ for (let i = 0; i < data.length; i += 4) {
227
+ r += data[i]; // R
228
+ g += data[i + 1]; // G
229
+ b += data[i + 2]; // B
230
+ // 忽略透明通道 alpha = data[i+3] 可选
231
+ }
232
+
233
+ r = Math.round(r / total);
234
+ g = Math.round(g / total);
235
+ b = Math.round(b / total);
236
+ if (!!callback) {
237
+ // 返回图片主题色的 RGB 颜色值
238
+ callback(`${r},${g},${b}`);
239
+ }
240
+ },
241
+ fail: function (err) {
242
+ console.log(err);
243
+ callback(defaulColor);
244
+ },
245
+ });
246
+ });
247
+ },
248
+ fail: function (err) {
249
+ console.log(err);
250
+ callback(defaulColor);
251
+ },
252
+ });
253
+ }
254
+ export function getImageTheme(path, canvasId) {
255
+ const platform = process.env.UNI_PLATFORM;
256
+ console.log(platform);
257
+ return new Promise((resolve) => {
258
+ uni.getImageInfo({
259
+ src: path,
260
+ success: function (img) {
261
+ const ctx = uni.createCanvasContext(canvasId);
262
+ const imgWidth = 40;
263
+ const imgHeight = 40;
264
+ ctx.drawImage(img.path, 0, 0, imgWidth, imgHeight);
265
+ ctx.draw(false, () => {
266
+ uni.canvasGetImageData({
267
+ canvasId,
268
+ x: 0,
269
+ y: 0,
270
+ width: imgWidth,
271
+ height: imgHeight,
272
+ success(res) {
273
+ const data = res.data;
274
+ let r = 0,
275
+ g = 0,
276
+ b = 0;
277
+ const total = data.length / 4;
278
+
279
+ for (let i = 0; i < data.length; i += 4) {
280
+ r += data[i]; // R
281
+ g += data[i + 1]; // G
282
+ b += data[i + 2]; // B
283
+ // 忽略透明通道 alpha = data[i+3] 可选
284
+ }
285
+
286
+ r = Math.round(r / total);
287
+ g = Math.round(g / total);
288
+ b = Math.round(b / total);
289
+
290
+ resolve(`${r},${g},${b}`);
291
+ },
292
+ fail() {
293
+ resolve(defaulColor);
294
+ },
295
+ });
296
+ });
297
+ },
298
+ fail() {
299
+ resolve(defaulColor);
300
+ },
301
+ });
302
+ });
303
+ }
304
+
305
+ export const getBtnStyle = ({ r, g, b }) => {
306
+ // ---------- 原始 RGB -> HSL ----------
307
+ const hsl = rgbToHsl(r, g, b);
308
+ let { h, s, l } = hsl;
309
+ if (l > 60) {
310
+ l = 35;
311
+ s = Math.min(80, s + 20);
312
+ } else if (l < 35) {
313
+ l = 65;
314
+ s = Math.min(80, s + 15);
315
+ } else {
316
+ l = l < 50 ? l - 10 : l + 10;
317
+ s = Math.min(85, s + 10);
318
+ }
319
+
320
+ const btnRGB = hslToRgb(h, s, l);
321
+ const btnColor = `rgb(${btnRGB.r},${btnRGB.g},${btnRGB.b})`;
322
+ const opacityBtnColor = `rgba(${btnRGB.r},${btnRGB.g},${btnRGB.b},0.45)`;
323
+ const brightness = (btnRGB.r * 299 + btnRGB.g * 587 + btnRGB.b * 114) / 1000; // 按钮颜色
324
+ const textColor = brightness > 150 ? "#000" : "#fff"; //按钮上面的文字
325
+ const tooltipBg = `rgba(${textColor === "#fff" ? 255 : 0}, ${textColor === "#fff" ? 255 : 0}, ${textColor === "#fff" ? 255 : 0}, 0.85)`;
326
+
327
+ const indexTextColor = brightness > 180 ? "#000" : "#fff"; //按钮上面的文字
328
+ const imageBrightness = (r * 299 + g * 587 + b * 114) / 1000;
329
+ const imageTextColor = imageBrightness > 180 ? "#000" : "#fff"; // 背景上面的文字
330
+
331
+ return {
332
+ btnColor,
333
+ textColor,
334
+ opacityBtnColor,
335
+ tooltipBg,
336
+ imageTextColor: imageTextColor,
337
+ indexBtnColor: btnColor,
338
+ indexTextColor,
339
+ };
340
+ };
341
+
342
+ function rgbToHsl(r, g, b) {
343
+ r /= 255;
344
+ g /= 255;
345
+ b /= 255;
346
+ const max = Math.max(r, g, b),
347
+ min = Math.min(r, g, b);
348
+ let h,
349
+ s,
350
+ l = (max + min) / 2;
351
+
352
+ if (max === min) {
353
+ h = s = 0;
354
+ } else {
355
+ const d = max - min;
356
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
357
+ switch (max) {
358
+ case r:
359
+ h = (g - b) / d + (g < b ? 6 : 0);
360
+ break;
361
+ case g:
362
+ h = (b - r) / d + 2;
363
+ break;
364
+ case b:
365
+ h = (r - g) / d + 4;
366
+ break;
367
+ }
368
+ h /= 6;
369
+ }
370
+ return { h: h * 360, s: s * 100, l: l * 100 };
371
+ }
372
+
373
+ function hslToRgb(h, s, l) {
374
+ h /= 360;
375
+ s /= 100;
376
+ l /= 100;
377
+ let r, g, b;
378
+
379
+ if (s === 0) {
380
+ r = g = b = l;
381
+ } else {
382
+ const hue2rgb = (p, q, t) => {
383
+ if (t < 0) t += 1;
384
+ if (t > 1) t -= 1;
385
+ if (t < 1 / 6) return p + (q - p) * 6 * t;
386
+ if (t < 1 / 2) return q;
387
+ if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
388
+ return p;
389
+ };
390
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
391
+ const p = 2 * l - q;
392
+ r = hue2rgb(p, q, h + 1 / 3);
393
+ g = hue2rgb(p, q, h);
394
+ b = hue2rgb(p, q, h - 1 / 3);
395
+ }
396
+ return {
397
+ r: Math.round(r * 255),
398
+ g: Math.round(g * 255),
399
+ b: Math.round(b * 255),
400
+ };
401
+ }
402
+
403
+ export const formateServerUrl = (url) => {
404
+ if (url.startsWith("http")) return url;
405
+ return staticUrl + "/" + url;
406
+ };
407
+
408
+ export const isPositiveInteger = (value) => {
409
+ return /^[1-9]\d*$/.test(value);
410
+ };
411
+
412
+ export const formateTime = (time) => {
413
+ let date = new Date(Number(time));
414
+ let year = date.getFullYear();
415
+ let month = String(date.getMonth() + 1).padStart(2, "0");
416
+ let day = String(date.getDate()).padStart(2, "0");
417
+ return `${year}-${month}-${day}`;
418
+ };
419
+
420
+ export const sendLogisticsFee = isProd ? 10 : 10;
421
+
422
+ export const defaulColor = "14, 77, 131";
423
+
424
+ // 计算相对亮度
425
+ function relativeLuminance(rgb) {
426
+ const a = rgb.map((v) => {
427
+ v /= 255;
428
+ return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
429
+ });
430
+ return 0.2126 * a[0] + 0.7152 * a[1] + 0.0722 * a[2];
431
+ }
432
+
433
+ // 计算对比度
434
+ function contrast(rgb1, rgb2) {
435
+ const data1 = [rgb1.r, rgb1.g, rgb1.b];
436
+ const data2 = [rgb2.r, rgb2.g, rgb2.b];
437
+ const L1 = relativeLuminance(data1);
438
+ const L2 = relativeLuminance(data2);
439
+ return (Math.max(L1, L2) + 0.05) / (Math.min(L1, L2) + 0.05);
440
+ }
441
+
442
+ // 自动生成渐变,保证白底可见
443
+ export const generateGradientsSafe = (rgb) => {
444
+ // 转成 HSL
445
+ const { h, s, l } = rgbToHsl(rgb[0], rgb[1], rgb[2]);
446
+ const white = [255, 255, 255];
447
+
448
+ // 亮度初始值
449
+ let baseL = l;
450
+ let lightL = Math.min(baseL + 25, 90);
451
+ let darkL = Math.max(baseL - 30, 10);
452
+
453
+ // 自动保证对比度 >= 4.5
454
+ while (contrast(hslToRgb(h, s, lightL), white) < 4.5 && lightL < 95)
455
+ lightL += 2;
456
+ while (contrast(hslToRgb(h, s, darkL), white) < 4.5 && darkL > 5) darkL -= 2;
457
+
458
+ const rgbColors = [
459
+ [
460
+ hslToRgb(h, s, lightL).r,
461
+ hslToRgb(h, s, lightL).g,
462
+ hslToRgb(h, s, lightL).b,
463
+ ],
464
+ [hslToRgb(h, s, baseL).r, hslToRgb(h, s, baseL).g, hslToRgb(h, s, baseL).b],
465
+ [hslToRgb(h, s, darkL).r, hslToRgb(h, s, darkL).g, hslToRgb(h, s, darkL).b],
466
+ ];
467
+
468
+ const rgba = rgbColors.map((c) => `rgba(${c[0]}, ${c[1]}, ${c[2]}, 1)`);
469
+
470
+ return [
471
+ `linear-gradient(135deg, ${rgba[0]}, ${rgba[1]})`,
472
+ `linear-gradient(135deg, ${rgba[1]}, ${rgba[2]})`,
473
+ `linear-gradient(135deg, ${rgba[0]}, ${rgba[2]})`,
474
+ ];
475
+ };
476
+
477
+ export const navagatorBack = () => {
478
+ let pages = getCurrentPages();
479
+ if (pages.length > 1) {
480
+ uni.navigateBack();
481
+ } else {
482
+ // const hideHeader = uni.getStorageSync('hideHeader');
483
+ // if(hideHeader && hideHeader == 1){
484
+ uni.reLaunch({ url: "/pages/index/index" });
485
+ // }else{
486
+ // MgtvApi.closeWebView();
487
+ // }
488
+ }
489
+ };
490
+
491
+ export const getTagText = (tag) => {
492
+ if ((tag & 16) == 16) {
493
+ return {
494
+ text: "门票掉落",
495
+ show: true,
496
+ };
497
+ } else {
498
+ return {
499
+ text: "",
500
+ show: false,
501
+ };
502
+ }
503
+ };
504
+
505
+ export const compareVersion = (v1, v2) => {
506
+ const a = v1.split(".").map(Number);
507
+ const b = v2.split(".").map(Number);
508
+ for (let i = 0; i < Math.max(a.length, b.length); i++) {
509
+ if ((a[i] || 0) > (b[i] || 0)) return 1;
510
+ if ((a[i] || 0) < (b[i] || 0)) return -1;
511
+ }
512
+ return 0;
513
+ };
514
+
515
+ export const toLoginPage = () => {
516
+ uni.navigateTo({
517
+ url: "/pages/login/login",
518
+ });
519
+ };
520
+ export const sortCouponsSameAsBest = (amount, coupons) => {
521
+ if (!Array.isArray(coupons)) return [];
522
+
523
+ // 1️⃣ 可用券
524
+ const usable = [];
525
+ // 2️⃣ 不可用券
526
+ const unusable = [];
527
+
528
+ for (const c of coupons) {
529
+ if (c.coupon.conditionAmount === 0 || amount >= c.coupon.conditionAmount) {
530
+ usable.push(c);
531
+ } else {
532
+ unusable.push(c);
533
+ }
534
+ }
535
+
536
+ // 3️⃣ 只对【可用券】排序
537
+ usable.sort((a, b) => {
538
+ // 优惠金额:大 → 小
539
+ if (a.coupon.giftAmount !== b.coupon.giftAmount) {
540
+ return b.coupon.giftAmount - a.coupon.giftAmount;
541
+ }
542
+
543
+ // 同优惠:有门槛优先(无门槛放后)
544
+ const aNoLimit = a.coupon.conditionAmount === 0;
545
+ const bNoLimit = b.coupon.conditionAmount === 0;
546
+ if (aNoLimit !== bNoLimit) {
547
+ return aNoLimit ? 1 : -1;
548
+ }
549
+
550
+ // 同门槛:最快过期
551
+ return parseExpireTime(a.expiredAt) - parseExpireTime(b.expiredAt);
552
+ });
553
+
554
+ // 4️⃣ 拼回去(可用在前,不可用永远在后)
555
+ return usable.concat(unusable);
556
+ };
557
+ const parseExpireTime = (str) => {
558
+ if (!str) return 0;
559
+ // iOS 兼容:yyyy-MM-dd HH:mm:ss → yyyy/MM/dd HH:mm:ss
560
+ return new Date(str.replace(/-/g, "/")).getTime();
561
+ };
562
+
563
+ export const getBestCoupon = (amount, coupons) => {
564
+ const usable = coupons.filter(
565
+ (c) =>
566
+ c.item.couponConditionAmount === 0 ||
567
+ amount >= c.item.couponConditionAmount,
568
+ );
569
+ console.log(amount, usable);
570
+ if (usable.length === 0) return null;
571
+
572
+ let best = usable[0];
573
+ // let bestExpire = parseExpireTime(best.expiredAt)
574
+ for (let i = 1; i < usable.length; i++) {
575
+ const c = usable[i];
576
+ // const cExpire = parseExpireTime(c.expiredAt)
577
+ const bestNoLimit = best.item.couponConditionAmount === 0;
578
+ const cNoLimit = c.item.couponConditionAmount === 0;
579
+ if (
580
+ // 1️⃣ 优惠更大
581
+ c.couponGiftAmount > best.couponGiftAmount ||
582
+ // 2️⃣ 优惠相同:有门槛优先
583
+ (c.couponGiftAmount === best.couponGiftAmount && bestNoLimit && !cNoLimit)
584
+ ) {
585
+ best = c;
586
+ }
587
+ }
588
+ return best;
589
+ };
590
+ // +"?isFullScreen=1&isHideNavBar=1"
591
+ export const navigateTo = (url) => {
592
+ uni.navigateTo({
593
+ url: `${url}`,
594
+ });
595
+ };
596
+ // ${url.includes("?") ? "&isFullScreen=1&isHideNavBar=1" : "?isFullScreen=1&isHideNavBar=1"}
597
+
598
+ export const isMTVapp = () => {
599
+ return /imgo/i.test(window.navigator.userAgent);
600
+ };
601
+
602
+ export const getDecievedModel = () => {
603
+ if (MgtvApi.isIpad) {
604
+ return "PlatformID_MGTV_IPAD";
605
+ } else {
606
+ const res = uni.getSystemInfoSync();
607
+ const osName = res.osName || res.platform;
608
+ return osName === "ios"
609
+ ? "PlatformID_MGTV_IPhone"
610
+ : "PlatformID_MGTV_Android";
611
+ }
612
+ };
613
+ export const isIos = () => {
614
+ const res = uni.getSystemInfoSync();
615
+ console.log(res);
616
+
617
+ const osName = res.osName || res.platform;
618
+ const isIOS = osName === "ios";
619
+
620
+ return isIOS;
621
+ };
622
+ export const isHonery = ()=>{
623
+ return /harmony/i.test(window.navigator.userAgent);
624
+ }
625
+ export const setWebViewTitle = (title) => {
626
+ if (isMTVapp()) {
627
+ MgtvApi.setWebViewTitle({
628
+ title: title,
629
+ });
630
+ }
631
+ };
632
+
633
+ export const saveImg = (url) => {
634
+ if (isMTVapp()) {
635
+ MgtvApi.callhandler("savePicture", {
636
+ imgUrl: url,
637
+ });
638
+ }
639
+ };
640
+
641
+ export const formateAmount = (amount) => {
642
+ if (amount > 10000) {
643
+ return new BigNumber(amount / 1000).toFixed(2, 1) + "K";
644
+ } else if (amount > 1000000) {
645
+ return new BigNumber(amount / 10000000).toFixed(2, 1) + "M";
646
+ } else {
647
+ return amount;
648
+ }
649
+ };
650
+
651
+ export const pay = (id, type = 2) => {
652
+ const ios = isIos();
653
+ return new Promise((resolve, reject) => {
654
+ return MGTVVIP.create_order({
655
+ serviceType: "as", // 下单类型, act or as,act调用活动服务下单接口,否则调用as下单接口
656
+ productInfo: {
657
+ prod_type: 1,
658
+ product_id: id, //产品包ID,从会员产品处获得
659
+ },
660
+ channel_id: type == 1 ? "wechat" : type == 2 ? "alipay" : "apple", //'3alipay' ,'2wechat' ,'1apple'
661
+ clocation: type, //不同的支付按钮用不同的ID,便于统计
662
+ return_url: "", //购买完成页,如果不写则使用默认的购买完成页
663
+ callback: (res) => {
664
+ return resolve(res);
665
+ },
666
+ });
667
+ });
668
+ };
669
+
670
+ export const getHasCouponList = (id, couponList, count) => {
671
+ const data = couponList.find((item) => {
672
+ return item.gachaId == id;
673
+ });
674
+ if (data) {
675
+ if (data.bet2Stock && data.bet2Stock[count]) {
676
+ return data.bet2Stock[count];
677
+ } else {
678
+ return { id: [] };
679
+ }
680
+ } else {
681
+ return { id: [] };
682
+ }
683
+ // if(list.length > 0){
684
+
685
+ // }
686
+ };
687
+
688
+ export const toUseXiaomangQuan = () => {
689
+ if (isMTVapp()) {
690
+ MgtvApi.jumpPage({
691
+ url: "https://m.ecom.mgtv.com/coupon-list?tab=0",
692
+ });
693
+ } else {
694
+ window.open("https://m.ecom.mgtv.com/coupon-list?tab=0");
695
+ }
696
+ };
697
+ // https://h5.ecom.mgtv.com/yg/20251209/20251209cluebieknhd/index.html
698
+ export const toBannerUrl = (url) => {
699
+ if (isMTVapp()) {
700
+ MgtvApi.jumpPage({
701
+ url: url,
702
+ });
703
+ } else {
704
+ window.open(url);
705
+ }
706
+ };
707
+
708
+ export const sortArr = (arr) => {
709
+ arr.forEach((item) => {
710
+ if (item.item.thirdPartyGoodsPrice) {
711
+ item.item.goodsShowPrice = item.item.thirdPartyGoodsPrice;
712
+ }
713
+ });
714
+
715
+ return arr.sort((a, b) => b.item.goodsShowPrice - a.item.goodsShowPrice);
716
+ };
717
+
718
+ export const subcribeList = () => {
719
+ MgtvApi.callhandler(
720
+ "addCalendarEvent",
721
+ {
722
+ title: "你好星期六",
723
+ description: "热闹好六团圆饭",
724
+ reminderTimeMS: 1770912000 * 1000, //预约的时间,时间戳,毫秒13位
725
+ durationMS: 86399000, //持续时长
726
+ previousTimeMinutes: 1440, //提前多少分钟提醒
727
+ },
728
+ function (data) {
729
+ //注意返回类型,是json字符串
730
+ var ret = typeof data === "string" ? JSON.parse(data) : data;
731
+
732
+ if (ret.code == 200) {
733
+ var resultCode =
734
+ typeof ret.data === "string"
735
+ ? JSON.parse(ret.data).resultCode
736
+ : ret.data.resultCode;
737
+ if (resultCode == 1 || resultCode == 2) {
738
+ MgtvApi.callhandler(
739
+ "addCalendarEvent",
740
+ {
741
+ title: "声生不息",
742
+ description: "声生马上闹新春",
743
+ reminderTimeMS: 1771516800 * 1000, //预约的时间,时间戳,毫秒13位
744
+ durationMS: 86399000, //持续时长
745
+ previousTimeMinutes: 1440, //提前多少分钟提醒
746
+ },
747
+ function (data) {
748
+ //注意返回类型,是json字符串
749
+ var ret = typeof data === "string" ? JSON.parse(data) : data;
750
+ if (ret.code == 200) {
751
+ var resultCode =
752
+ typeof ret.data === "string"
753
+ ? JSON.parse(ret.data).resultCode
754
+ : ret.data.resultCode;
755
+
756
+ if (resultCode == 1 || resultCode == 2) {
757
+
758
+ MgtvApi.callhandler(
759
+ "addCalendarEvent",
760
+ {
761
+ title: "声生不息",
762
+ description: "声生正月好友聚",
763
+ reminderTimeMS: 1772121600 * 1000, //预约的时间,时间戳,毫秒13位
764
+ durationMS: 86399000, //持续时长
765
+ previousTimeMinutes: 1440, //提前多少分钟提醒
766
+ },
767
+ function (data) {
768
+ //注意返回类型,是json字符串
769
+ var ret = typeof data === "string" ? JSON.parse(data) : data;
770
+ if (ret.code == 200) {
771
+ var resultCode =
772
+ typeof ret.data === "string"
773
+ ? JSON.parse(ret.data).resultCode
774
+ : ret.data.resultCode;
775
+
776
+ if (resultCode == 1 || resultCode == 2) {
777
+ MgtvApi.callhandler(
778
+ "addCalendarEvent",
779
+ {
780
+ title: "你好星期六",
781
+ description: "马儿快跑好六局",
782
+ reminderTimeMS: 1772726400 * 1000, //预约的时间,时间戳,毫秒13位
783
+ durationMS: 86399000, //持续时长
784
+ previousTimeMinutes: 1440, //提前多少分钟提醒
785
+ },
786
+ function (data) {
787
+ //注意返回类型,是json字符串
788
+ var ret = typeof data === "string" ? JSON.parse(data) : data;
789
+ if (ret.code == 200) {
790
+ var resultCode =
791
+ typeof ret.data === "string"
792
+ ? JSON.parse(ret.data).resultCode
793
+ : ret.data.resultCode;
794
+
795
+ if (resultCode == 1 || resultCode == 2) {
796
+ MgtvApi.callhandler(
797
+ "addCalendarEvent",
798
+ {
799
+ title: "大侦探",
800
+ description: "欢乐推理侦探局",
801
+ reminderTimeMS: 1773331200 * 1000, //预约的时间,时间戳,毫秒13位
802
+ durationMS: 86399000, //持续时长
803
+ previousTimeMinutes: 1440, //提前多少分钟提醒
804
+ },
805
+ function (data) {
806
+ //注意返回类型,是json字符串
807
+ var ret = typeof data === "string" ? JSON.parse(data) : data;
808
+ if (ret.code == 200) {
809
+ var resultCode =
810
+ typeof ret.data === "string"
811
+ ? JSON.parse(ret.data).resultCode
812
+ : ret.data.resultCode;
813
+
814
+ if (resultCode == 1 || resultCode == 2) {
815
+
816
+
817
+ }
818
+ }
819
+ },
820
+ );
821
+
822
+ }
823
+ }
824
+ },
825
+ );
826
+
827
+ }
828
+ }
829
+ },
830
+ );
831
+ }
832
+ }
833
+ },
834
+ );
835
+ }
836
+ }
837
+ },
838
+ );
839
+ };
840
+
841
+
842
+ export const magTvLoing =()=>{
843
+ MgtvApi.login((res) => {
844
+ window.location.reload();
845
+ });
846
+ }
847
+
848
+
849
+ function getAppType(){
850
+ return 'imgotv'
851
+ }
852
+
853
+
854
+ export function video_schema(m_video_url, type) {
855
+ let res = /\.mgtv\.com\/s\/(\d+).html/.exec(m_video_url);
856
+ if (res) {
857
+ const video_id = res[1];
858
+ if (type === 'mobile') {
859
+ return `${getAppType()}://player?clipId=0&plId=0&videoId=${video_id}`
860
+ } else if (type === "pad") {
861
+ return `imgotvhd://player?clipId=0&plId=0&videoId=${video_id}`
862
+ } else {
863
+ return m_video_url;
864
+ }
865
+ }
866
+
867
+
868
+ res = /\.mgtv\.com\/[hb]\/(\d+).html/.exec(m_video_url);
869
+ if (res) {
870
+ const clip_id = res[1]
871
+ if (type === 'mobile') {
872
+ return `${getAppType()}://player?clipId=${clip_id}&plId=0&videoId=0`
873
+ } else if (type === "pad") {
874
+ return `imgotvhd://player?clipId=${clip_id}&plId=0&videoId=0`
875
+ } else {
876
+ return m_video_url;
877
+ }
878
+ }
879
+
880
+ res = /\.mgtv\.com\/[hb]\/(\d+)\/?$/.exec(m_video_url);
881
+ if (res) {
882
+ const clip_id = res[1]
883
+ if (type === 'mobile') {
884
+ return `${getAppType()}://player?clipId=${clip_id}&plId=0&videoId=0`
885
+ } else if (type === "pad") {
886
+ return `imgotvhd://player?clipId=${clip_id}&plId=0&videoId=0`
887
+ } else {
888
+ return m_video_url;
889
+ }
890
+ }
891
+
892
+ res = /\.mgtv\.com\/b\/(\d+)\/(\d+)\.html/.exec(m_video_url);
893
+ if (res) {
894
+ console.log(res)
895
+ const clip_id = res[1]
896
+ const video_id = res[2]
897
+
898
+ if (type === 'mobile') {
899
+ return `${getAppType()}://player?clipId=${clip_id}&plId=0&videoId=${video_id}`
900
+ } else if (type === "pad") {
901
+ return `imgotvhd://player?clipId=${clip_id}&plId=0&videoId=${video_id}`
902
+ } else {
903
+ return m_video_url;
904
+ }
905
+ }
906
+
907
+ res = /m\.mgtv\.com\/l\/(\d+)\/?$/.exec(m_video_url);
908
+ if (res) {
909
+ const pl_id = res[1] //播单
910
+
911
+ if (type === 'mobile') {
912
+ return `${getAppType()}://player?clipId=0&plId=${pl_id}&videoId=0`
913
+ } else if (type === "pad") {
914
+ return `imgotvhd://player?clipId=0&plId=${pl_id}&videoId=0`
915
+ } else {
916
+ return m_video_url;
917
+ }
918
+ }
919
+
920
+
921
+ res = /\.mgtv\.com\/l\/(\d+)\/(\d+)\.html/.exec(m_video_url);
922
+ if (res) {
923
+ const pl_id = res[1]
924
+ const video_id = res[2]
925
+
926
+ if (type === 'mobile') {
927
+ return `${getAppType()}://player?clipId=0&plId=${pl_id}&videoId=${video_id}`
928
+ } else if (type === "pad") {
929
+ return `imgotvhd://player?clipId=0&plId=${pl_id}&videoId=${video_id}`
930
+ } else {
931
+ return m_video_url;
932
+ }
933
+ }
934
+ }
935
+
936
+
937
+ export function isVideo(url) {
938
+ return /(m|www|w)\.mgtv\.com\/l\//.test(url) || /(m|www|w)\.mgtv\.com\/b\//.test(url)
939
+ }
940
+
941
+
942
+ export const jumpUrl =(link)=>{
943
+ if(!isMTVapp()){
944
+ window.location.href = link
945
+ return;
946
+ }
947
+
948
+ const is_app = /imgo/i.test(window.navigator.userAgent)
949
+ const is_ipad = /ipad/i.test(window.navigator.userAgent)
950
+
951
+ if (isVideo(link)) {
952
+ let schema = link;
953
+ if (is_app) {
954
+ if (is_ipad) {
955
+ schema = video_schema(link, 'pad')
956
+ } else {
957
+ schema = video_schema(link, 'mobile')
958
+ }
959
+ window.location.href = schema
960
+ }else{
961
+ window.location.href = link;
962
+ }
963
+ }else{
964
+ MgtvApi.jumpPage({
965
+ url: link,
966
+ });
967
+ }
968
+ }
969
+
970
+ export const reportMessage=(text)=>{
971
+ MGTVVIP.click_event(text);
972
+ }
973
+
974
+
975
+ export const preloadBgImages = (list = [])=> {
976
+ return Promise.all(
977
+ list.map(url => {
978
+ return new Promise((resolve, reject) => {
979
+ const img = new Image()
980
+ img.src = url
981
+ img.onload = resolve
982
+ img.onerror = reject
983
+ })
984
+ })
985
+ )
986
+ }
987
+
988
+ export const chunk = (arr, size = 4) => {
989
+ const result = [];
990
+ for (let i = 0; i < arr.length; i += size) {
991
+ result.push(arr.slice(i, i + size));
992
+ }
993
+ return result;
994
+ }