瀏覽代碼

feat:选择组件问题

storeBelieveInLight 1 年之前
父節點
當前提交
d05f9d27f2
共有 8 個文件被更改,包括 863 次插入725 次删除
  1. 2 1
      commit/requestPhp.js
  2. 5 0
      main.js
  3. 1 1
      manifest.json
  4. 757 550
      openmerchant/shopentry/processidentity.vue
  5. 2 0
      package.json
  6. 43 18
      pages/cashier/index.vue
  7. 41 139
      shop/perating/activitecode.vue
  8. 12 16
      utils/readAppInfo.js

+ 2 - 1
commit/requestPhp.js

@@ -11,13 +11,14 @@ const token = ""
11 11
 export const phpToken = uni.getStorageSync('phpToken') || token
12 12
 // 需要修改token,和根据实际修改请求头
13 13
 export function myRequestPhp(options) {
14
+	const phpTokens = uni.getStorageSync('phpToken') || token
14 15
 	let url = options.url;
15 16
 	let method = options.method || "get";
16 17
 	let data = options.data || {};
17 18
 	let contentType = options.contentType || "application/json;charset=UTF-8";
18 19
 	let header = {
19 20
 		'Content-Type': contentType,
20
-		"X-Token": phpToken,
21
+		"X-Token": phpTokens,
21 22
 		...options.header
22 23
 	}
23 24
 	return new Promise((resolve, reject) => {

+ 5 - 0
main.js

@@ -9,6 +9,11 @@ import Vconsole from "vconsole"
9 9
 // import VConsole from 'vconsole'
10 10
 const vConsole = new Vconsole();
11 11
 // console.log('vConsole is running!');
12
+// main.js,注意要在use方法之后执行
13
+import uViews from 'uview-ui'
14
+Vue.use(uViews)
15
+// 如此配置即可
16
+uni.$u.config.unit = 'rpx'
12 17
 
13 18
 Vue.config.productionTip = false
14 19
 Vue.prototype.$time = time 

+ 1 - 1
manifest.json

@@ -90,7 +90,7 @@
90 90
         // 自行修改下方的 /web
91 91
         "/gateway": {
92 92
           // "secure": false,
93
-          "target": "https://api.hxxfb.com",
93
+          "target": "https://testapi.hxxfb.com",
94 94
           "pathRewirte": {
95 95
             //路径重写
96 96
             "^/gateway": "/gateway"

文件差異過大導致無法顯示
+ 757 - 550
openmerchant/shopentry/processidentity.vue


+ 2 - 0
package.json

@@ -4,10 +4,12 @@
4 4
     "@wangeditor/editor-for-vue": "^1.0.2",
5 5
     "base-64": "^1.0.0",
6 6
     "crypto-js": "^4.1.1",
7
+    "dayjs": "^1.11.13",
7 8
     "easemob-websdk": "^4.6.0",
8 9
     "file-saver": "^2.0.5",
9 10
     "html2canvas": "^1.4.1",
10 11
     "pinia": "^2.1.0",
12
+    "uview-ui": "^2.0.38",
11 13
     "vconsole": "^3.15.1"
12 14
   }
13 15
 }

+ 43 - 18
pages/cashier/index.vue

@@ -241,10 +241,13 @@ export default {
241 241
       zhuangi: "",
242 242
       gongxian: 0,
243 243
       jingdou: 0,
244
+      phpToken: "",
245
+      
244 246
     };
245 247
   },
246 248
   async onLoad() {
247 249
     console.log("进了我的页面了");
250
+
248 251
     await readAppInfo();
249 252
     let daySart = new Date();
250 253
     this.start_time = this.$time.dateFormat("yyyy-MM-dd", daySart);
@@ -255,9 +258,7 @@ export default {
255 258
     let userinfo = uni.getStorageSync("userinfo");
256 259
     this.mer_id = selectmerchant.merId;
257 260
     let jurisdiction = uni.getStorageSync("jurisdiction");
258
-    if (this.mer_id > 0) {
259
-      await getPhpToken();
260
-    }
261
+
261 262
     if (jurisdiction) {
262 263
       jurisdiction.forEach((res, index) => {
263 264
         if (res == 7) {
@@ -266,6 +267,8 @@ export default {
266 267
       });
267 268
     }
268 269
     // let selectmerchant = uni.getStorageSync("selectmerchant");
270
+    const res = await getPhpToken();
271
+    this.phpToken = res || uni.getStorageSync("phpToken");
269 272
     let uid = userinfo.uid;
270 273
     console.log(authorization, uid);
271 274
     if (authorization && uid) {
@@ -278,15 +281,7 @@ export default {
278 281
         selectmerchant.merId > 0 &&
279 282
         (selectmerchant.status == 1 || selectmerchant.status == 5)
280 283
       ) {
281
-        uni.showLoading({
282
-          title: "加载中",
283
-          mask: true,
284
-        });
285
-        this.selectMerchant();
286
-        this.selectMerchantOrder();
287
-        this.getZuorijinri();
288
-        this.getZuixinjilu();
289
-        this.payUserList();
284
+        this.getInitData(selectmerchant);
290 285
         return;
291 286
       } else if (
292 287
         selectmerchant.merId >= 0 &&
@@ -363,6 +358,18 @@ export default {
363 358
       });
364 359
     }
365 360
   },
361
+  watch: {
362
+    phpToken:{
363
+      handler(newVal, oldVal) {
364
+         let selectmerchant = uni.getStorageSync("selectmerchant");
365
+         if(newVal){
366
+          this.getInitData(selectmerchant);
367
+         }
368
+      },
369
+      immediate:true
370
+    }
371
+  },
372
+
366 373
   //监听tab 分类
367 374
   onPageScroll(res) {
368 375
     const query = uni.createSelectorQuery().in(this);
@@ -386,21 +393,38 @@ export default {
386 393
     this.page = 1;
387 394
     this.is_panudn = true;
388 395
     this.List = [];
389
-    this.getZuixinjilu()
390
-    this.payUserList();
391 396
     this.selectMerchant();
392 397
     this.selectMerchantOrder();
398
+    this.getZuorijinri();
399
+    this.getZuixinjilu();
400
+    // this.payUserList();
393 401
   },
394 402
 
395 403
   onReachBottom() {
396 404
     if (this.is_panudn == true) {
397 405
       this.page++;
398
-      this.payUserList();
406
+      this.getZuixinjilu();
399 407
     } else {
400 408
       return;
401 409
     }
402 410
   },
403 411
   methods: {
412
+      getInitData(selectmerchant) {
413
+    if (
414
+      selectmerchant.merId > 0 &&
415
+      (selectmerchant.status == 1 || selectmerchant.status == 5)
416
+    ) {
417
+      uni.showLoading({
418
+        title: "加载中",
419
+        mask: true,
420
+      });
421
+      this.selectMerchant();
422
+      this.selectMerchantOrder();
423
+      this.getZuorijinri();
424
+      this.getZuixinjilu();
425
+      this.payUserList();
426
+    }
427
+  },
404 428
     // 店铺信息头
405 429
     selectMerchant() {
406 430
       selectMerchant({
@@ -410,7 +434,8 @@ export default {
410 434
           console.log(res);
411 435
           if (res.data.status == 200) {
412 436
             this.merchantCashierShow = res.data.data.merchantCashierShow;
413
-			this.merchantCashierShow.create_time = this.merchantCashierShow.create_time.split(' ')[0]
437
+            this.merchantCashierShow.create_time =
438
+              this.merchantCashierShow.create_time.split(" ")[0];
414 439
           }
415 440
         },
416 441
         (fail) => {
@@ -486,7 +511,7 @@ export default {
486 511
     },
487 512
     // 最新纪录列表
488 513
     payUserList() {
489
-      return
514
+      return;
490 515
       payUserList({
491 516
         mer_id: this.mer_id,
492 517
         pageNum: this.page,
@@ -560,7 +585,7 @@ export default {
560 585
               }
561 586
               this.is_panudn = false;
562 587
             }
563
-            console.log(this.records,"recordsrecordsrecords")
588
+            console.log(this.records, "recordsrecordsrecords");
564 589
             uni.hideLoading();
565 590
           }
566 591
         },

+ 41 - 139
shop/perating/activitecode.vue

@@ -14,7 +14,7 @@
14 14
         <view class="statement-header-text-title" @click="topgi"> 返回</view>
15 15
       </view>
16 16
     </view>
17
-    <view class="activite-nav">
17
+    <view class="activite-nav" id="huoquId">
18 18
       <view class="activite-card">
19 19
         <image
20 20
           class="activite-card-logo"
@@ -22,7 +22,7 @@
22 22
           mode=""
23 23
         ></image>
24 24
 
25
-        <view class="activite-cardImg">
25
+        <!-- <view class="activite-cardImg">
26 26
           <image :src="qrcode_src" mode="widthFix" ref="imagRef"></image>
27 27
         </view>
28 28
         <view class="activite-cardText">{{ code_id }}</view>
@@ -43,7 +43,7 @@
43 43
               mode=""
44 44
             ></image>
45 45
           </view>
46
-        </view>
46
+        </view> -->
47 47
       </view>
48 48
       <!-- <image class="activite-card-logo" :src="imageUrl" mode=""></image> -->
49 49
       <!-- <view class="downLoadButton" @click="clickGeneratePicture">
@@ -63,7 +63,6 @@
63 63
         <view class="downLoad-text"> 保存图片 </view>
64 64
       </view>
65 65
     </view>
66
-
67 66
     <!-- ************************* 海报画板 **********************-->
68 67
     <view style="position: absolute; bottom: 10%; left: 0%" v-show="flag">
69 68
       <l-painter
@@ -113,9 +112,9 @@ export default {
113 112
       poster: null,
114 113
       image: "",
115 114
       flag: false,
116
-      canvasWidth: 300, // 单位:rpx
117
-      canvasHeight: 300,
118 115
       imageUrl: "",
116
+      canvasWidth: 300,
117
+      canvasHeight: 400,
119 118
     };
120 119
   },
121 120
   onLoad(e) {
@@ -129,7 +128,11 @@ export default {
129 128
     this.qrcode_src = e.qrcode_src;
130 129
     this.code_id = e.code_id;
131 130
   },
131
+  mounted() {
132
+
133
+  },
132 134
   methods: {
135
+
133 136
     queryByKey() {
134 137
       const _this = this;
135 138
       queryByKey({
@@ -151,54 +154,7 @@ export default {
151 154
         }
152 155
       );
153 156
     },
154
-    async drawImageToCanvas() {
155
-      // const ctx = uni.createCanvasContext("myCanvas", this);
156
-      // 清空画布
157
-      // ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight);
158
-      //  const img = new Image();
159
-      //   img.crossOrigin = 'anonymous'; // 设置跨域属性
160
-      //   img.src = 'https://example.com/your-image.jpg'; // 替换为实际的图片地址
161
-      const _this = this;
162
-      try {
163
-        const resData = await uni.getImageInfo({
164
-          src: decodeURIComponent(this.qrcode_src),
165
-        });
166
-        const res = resData[1] || {};
167
-        // 居中绘制图片(带缩放)
168
-        const imgWidth = res.width;
169
-        const imgHeight = res.height;
170
-        const scale = Math.min(
171
-          this.canvasWidth / imgWidth,
172
-          this.canvasHeight / imgHeight
173
-        );
174
-        const drawWidth = imgWidth * scale;
175
-        const drawHeight = imgHeight * scale;
176
-        const offsetX = (this.canvasWidth - drawWidth) / 2;
177
-        const offsetY = (this.canvasHeight - drawHeight) / 2;
178
-        console.log(res, "resData");
179
-        uni.canvasToTempFilePath({
180
-          x: offsetX,
181
-          y: offsetY,
182
-          width: imgWidth,
183
-          height: imgHeight,
184
-          destWidth: drawWidth,
185
-          destHeight: drawHeight,
186
-          canvasId: "container",
187
-          success: function (res) {
188
-            // 在H5平台下,tempFilePath 为 base64
189
-            // const imageUrl = `data:image/png;base64,${res.tempFilePath}`;
190
-            const imageUrl = `${res.tempFilePath}`;
191
-            const contentPath = _this.$refs.imagRef.contentPath;
192
-            _this.fileDwonload(imageUrl, contentPath);
193
-          },
194
-        });
195 157
 
196
-        // ctx.drawImage(res.path, offsetX, offsetY, drawWidth, drawHeight);
197
-        // ctx.draw();
198
-      } catch (err) {
199
-        console.error("图片加载失败:", err);
200
-      }
201
-    },
202 158
 
203 159
     // 绘制图片
204 160
     drawPoster() {
@@ -380,26 +336,34 @@ export default {
380 336
       });
381 337
     },
382 338
     clickGeneratePicture2() {
383
-      //this.drawImageToCanvas();
339
+      let _this = this;
384 340
       let fileName = "pension_分享海报.jpg";
385
-      if (this.qrcode_src == "") {
386
-        uni.showToast({
387
-          title: "无生成二维码",
388
-          icon: "none",
389
-          duration: 2000,
390
-        });
391
-        return;
392
-      }
393
-      let fileUrl = decodeURIComponent(this.qrcode_src);
394
-      if (window.android) {
395
-        window.android.downloadFile(fileName, fileUrl);
396
-      } else {
397
-        uni.showToast({
398
-          title: "未检测到Android环境",
399
-          icon: "none",
400
-          duration: 2000,
401
-        });
402
-      }
341
+      this.drawCanvas();
342
+      // const cardElement = document.getElementById('huoquId');
343
+      // console.log(cardElement,"cardElement")
344
+      // html2canvas(cardElement).then((canvas) => {
345
+      //     const imageUrl = canvas.toDataURL('image/png');
346
+      //     _this.saveImageData(imageUrl);
347
+      //   });
348
+      //
349
+      // if (this.qrcode_src == "") {
350
+      //   uni.showToast({
351
+      //     title: "无生成二维码",
352
+      //     icon: "none",
353
+      //     duration: 2000,
354
+      //   });
355
+      //   return;
356
+      // }
357
+      // let fileUrl = decodeURIComponent(this.qrcode_src);
358
+      // if (window.android) {
359
+      //   window.android.downloadFile(fileName, fileUrl);
360
+      // } else {
361
+      //   uni.showToast({
362
+      //     title: "未检测到Android环境",
363
+      //     icon: "none",
364
+      //     duration: 2000,
365
+      //   });
366
+      // }
403 367
     },
404 368
     // 保存图片
405 369
     saveImage() {
@@ -442,54 +406,7 @@ export default {
442 406
       }
443 407
     },
444 408
 
445
-    fileDwonload(base64Data, path) {
446
-      uni.showLoading({ title: "保存中...", mask: true });
447
-      const _this = this;
448
-      // const blob = this.base64ToBlob(base64Data);
449
-      // const blobUrl = URL.createObjectURL(blob);
450
-      const finName = "海报.jpg";
451
-      uni.downloadFile({
452
-        url: path, //请求地址
453
-        success: (res) => {
454
-          //下载成功
455
-          console.log(res, "下载成功");
456
-          if (res.statusCode === 200) {
457
-            //保存文件
458
-            let filePath = res.tempFilePath;
459
-            // #ifdef H5
460
-            saveAs(filePath, finName);
461
-            uni.showModal({
462
-              title: "保存成功",
463
-              content: "图片已成功保存到相册,快去分享到您的圈子吧",
464
-              showCancel: false,
465
-            });
466
-            // #endif
467
-            //  #ifdef MP-WEIXIN || APP-PLUS
468
-            uni.saveFile({
469
-              tempFilePath: filePath,
470
-              success: function (filRes) {
471
-                console.log(filRes, "=====>");
472
-              },
473
-              fail: function (err) {
474
-                console.log("保存失败");
475
-              },
476
-            });
477
-            // #endif
478
-            uni.hideLoading();
479
-          }
480
-        },
481
-        fail: (e) => {
482
-          console.log(e, "文件下载失败downloadFile");
483
-          uni.hideLoading();
484
-          _this.loadFiles(path, finName);
485 409
 
486
-          // uni.showToast({
487
-          //   title: "文件下载保存失败",
488
-          //   icon: "error",
489
-          // });
490
-        },
491
-      });
492
-    },
493 410
     loadFiles(url, fileName) {
494 411
       const a = document.createElement("a");
495 412
       a.href = url;
@@ -531,20 +448,6 @@ export default {
531 448
         },
532 449
       });
533 450
     },
534
-    base64ToBlob(base64) {
535
-      const parts = base64.split(";base64,");
536
-      const mimeType = parts[0].split(":")[1];
537
-      const base64Data = parts[1];
538
-      var binaryData = atob(base64.split(";base64,")[1]);
539
-      // const binaryData = atob(base64Data);
540
-      const arrayBuffer = new ArrayBuffer(binaryData.length);
541
-      const uint8Array = new Uint8Array(arrayBuffer);
542
-      for (let i = 0; i < binaryData.length; i++) {
543
-        uint8Array[i] = binaryData.charCodeAt(i);
544
-      }
545
-
546
-      return new Blob([uint8Array], { type: mimeType });
547
-    },
548 451
     // 保存到相册
549 452
     saveImageToAlbum() {
550 453
       uni.saveImageToPhotosAlbum({
@@ -575,7 +478,7 @@ page {
575 478
   flex-direction: column;
576 479
   align-items: center;
577 480
   justify-content: center;
578
-  
481
+
579 482
   .statement-header {
580 483
     position: fixed;
581 484
     top: 0;
@@ -586,7 +489,7 @@ page {
586 489
     background: url("https://cdn.bjtdba.com/vod/image/2022-08-23/20220823132549341.png");
587 490
     display: flex;
588 491
     justify-content: center;
589
-  
492
+
590 493
     .statement-header-text {
591 494
       width: 686rpx;
592 495
       font-size: 36rpx;
@@ -595,17 +498,17 @@ page {
595 498
       display: flex;
596 499
       // margin-top: 107rpx;
597 500
       align-items: center;
598
-  
501
+
599 502
       .statement-header-text-neishi {
600 503
         width: 45rpx;
601 504
         height: 45rpx;
602 505
         margin-right: 17rpx;
603
-  
506
+
604 507
         .statement-header-text-icon {
605 508
           width: 36rpx;
606 509
           height: 36rpx;
607 510
           margin-top: 2rpx;
608
-  
511
+
609 512
           image {
610 513
             width: 100%;
611 514
             height: 100%;
@@ -614,7 +517,6 @@ page {
614 517
       }
615 518
     }
616 519
   }
617
-  
618 520
 
619 521
   .activite-nav {
620 522
     width: 100%;

+ 12 - 16
utils/readAppInfo.js

@@ -175,7 +175,7 @@ const func = async () => {
175 175
       );
176 176
       localStorage.setItem("aaa", "33333");
177 177
       console.log("读原生的", localStorage.getItem("aaa"));
178
-
178
+       getPhpToken()
179 179
       if (storeStaff) {
180 180
         queryStoreBranch({
181 181
           id: storeStaff.department
@@ -260,14 +260,14 @@ export default func;
260 260
 export async function getPhpToken(merId) {
261 261
   let phpToken = uni.getStorageSync("phpToken");
262 262
   let selectmerchant = uni.getStorageSync("selectmerchant");
263
-  // console.log("phpToken", phpToken);
264
-  // console.log("selectmerchant", selectmerchant);
263
+  console.log("phpToken", phpToken);
264
+  console.log("selectmerchant", selectmerchant);
265 265
   if (!phpToken && (selectmerchant && selectmerchant.merId > 0) || merId > 0) {
266
-	  uni.showLoading({
267
-		  title:"数据加载中",
268
-		  mask:true
269
-	  })
270
-     const merIdS = merId || selectmerchant.merId || ""
266
+    uni.showLoading({
267
+      title: "数据加载中",
268
+      mask: true
269
+    })
270
+    const merIdS = merId || selectmerchant.merId || ""
271 271
     try {
272 272
       const res = await getPhpGlobalToken({
273 273
         merId: merIdS
@@ -275,17 +275,13 @@ export async function getPhpToken(merId) {
275 275
       if (res.data.status == 200) {
276 276
         const token = res.data.data.token || "";
277 277
         uni.setStorageSync("phpToken", token);
278
-		console.log(this,"uni.navigateBack({})")
279
-		if(this.$router){
280
-			this.$router.go(0)
281
-		}else{
282
-			window.location.reload()
283
-		}
284
-		
278
+        console.log(this, "uni.navigateBack({})")
279
+        return token
280
+        // window.location.reload()
285 281
       } else {
286 282
         uni.setStorageSync("phpToken", "");
287 283
       }
288
-	  
284
+
289 285
     } catch (error) {}
290 286
   }
291 287
 }