zaijin 2 роки тому
батько
коміт
d18286114a

+ 2 - 1
pages.json

@@ -68,7 +68,8 @@
       "path": "pages/myCars/myCars",
       "style": {
         "navigationStyle": "custom",
-        "navigationBarTitleText": "我的车辆"
+        "navigationBarTitleText": "我的车辆",
+        "enablePullDownRefresh": true
       }
     },
     {

+ 39 - 99
pages/choosePayment/choosePayment.vue

@@ -295,7 +295,7 @@ export default {
      * @param {Array} orderList 需要支付的订单号组成的数组
      * @param {String} deviceNo 设备编号(只有车位锁部分有)
      * */
-    gyBankPay() {
+    async gyBankPay() {
       const params = {
         orderList: this.curOrderList,
         deviceNo: this.deviceNo,
@@ -306,54 +306,21 @@ export default {
         vehicleNo: this.vehicleNo,
         sanPay: this.sanPay
       };
-      if (this.exportFlag == true) {
-        this.$u.api
-          .quickPayExportApi(params)
-          .then((res) => {
-            if (res.data.needPay) {
-              let payUrl = res.data.url;
-              location.href = payUrl;
-            } else {
-              this.$refs.uToast.show({
-                title: '无需支付',
-                type: 'info'
-              });
-              setTimeout(() => {
-                uni.hideLoading();
-                location.reload();
-              }, 1000);
-            }
-          })
-          .catch((err) => {
-            this.$refs.uToast.show({
-              title: err.msg,
-              type: 'error'
-            });
-          });
-      } else {
-        this.$u.api
-          .payGzbank(params)
-          .then((res) => {
-            if (res.data.needPay) {
-              let payUrl = res.data.url;
-              location.href = payUrl;
-            } else {
-              this.$refs.uToast.show({
-                title: '无需支付',
-                type: 'info'
-              });
-              setTimeout(() => {
-                uni.hideLoading();
-                location.reload();
-              }, 1000);
-            }
-          })
-          .catch((err) => {
-            this.$refs.uToast.show({
-              title: err.msg,
-              type: 'error'
-            });
-          });
+      const apiCall = this.exportFlag ? this.$u.api.quickPayExportApi : this.$u.api.payGzbank;
+      try {
+        const res = await apiCall({ ...params });
+        if (res.data.needPay) {
+          let payUrl = res.data.url;
+          location.href = payUrl;
+        } else {
+          this.showToast('无需支付', 'info');
+          setTimeout(() => {
+            uni.hideLoading();
+            location.reload();
+          }, 1000);
+        }
+      } catch (err) {
+        // this.showToast(err.msg, 'error');
       }
     },
     /**
@@ -370,18 +337,12 @@ export default {
           if (res.code === 200) {
             location.href = res?.data?.url;
           } else {
-            this.$refs.uToast.show({
-              title: res.msg,
-              type: 'error'
-            });
+            this.showToast(res?.msg, 'error');
           }
         })
-				.catch((err) => {
-				  this.$refs.uToast.show({
-				    title: '无法调起支付!',
-				    type: 'error'
-				  });
-				});
+        .catch((err) => {
+          this.showToast('无法调起支付', 'error');
+        });
     },
     /**
      * 聚合支付
@@ -408,10 +369,7 @@ export default {
           }
         })
         .catch((err) => {
-          this.$refs.uToast.show({
-            title: `无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`,
-            type: 'error'
-          });
+          this.showToast(`无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`, 'error');
         });
     },
     /**
@@ -448,27 +406,18 @@ export default {
                       })
                       .then((res) => {
                         if (res.code === 200) {
-                          this.$refs.uToast.show({
-                            title: '已取消支付',
-                            type: 'info'
-                          });
+                          this.showToast('已取消支付', 'info');
                           window.location.reload();
                         }
                       });
                     break;
                   case 2: // 支付失败
-                    this.$refs.uToast.show({
-                      title: '支付失败,请检查!',
-                      type: 'error'
-                    });
+                    this.showToast('支付失败,请检查!', 'error');
                     break;
                 }
               });
             } else {
-              this.$refs.uToast.show({
-                title: '无需支付',
-                type: 'info'
-              });
+              this.showToast('无需支付', 'info');
               setTimeout(() => {
                 uni.hideLoading();
                 location.reload();
@@ -544,16 +493,10 @@ export default {
                   //#endif
                   break;
                 case 1: // 取消
-                  this.$refs.uToast.show({
-                    title: '已取消支付',
-                    type: 'info'
-                  });
+                  this.showToast('已取消支付', 'info');
                   break;
                 case 2: // 支付失败
-                  this.$refs.uToast.show({
-                    title: '支付失败,请检查!',
-                    type: 'error'
-                  });
+                  this.showToast('支付失败,请检查!', 'error');
                   break;
               }
             });
@@ -586,10 +529,7 @@ export default {
                 localStorage.setItem('jumpUrl', this.jumpUrl);
                 location.href = res.data.qrCodeUrl;
               } else {
-                this.$refs.uToast.show({
-                  title: '无需支付',
-                  type: 'info'
-                });
+                this.showToast('无需支付', 'info');
                 setTimeout(() => {
                   uni.hideLoading();
                   location.href = this.jumpUrl;
@@ -600,10 +540,7 @@ export default {
             }
           })
           .catch((err) => {
-            this.$refs.uToast.show({
-              title: `无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`,
-              type: 'error'
-            });
+            this.showToast(`无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`, 'error');
           });
       } else {
         this.$u.api
@@ -614,10 +551,7 @@ export default {
                 localStorage.setItem('jumpUrl', this.jumpUrl);
                 location.href = res.data.qrCodeUrl;
               } else {
-                this.$refs.uToast.show({
-                  title: '无需支付',
-                  type: 'info'
-                });
+                this.showToast('无需支付', 'info');
                 setTimeout(() => {
                   uni.hideLoading();
                   location.href = this.jumpUrl;
@@ -628,10 +562,7 @@ export default {
             }
           })
           .catch((err) => {
-            this.$refs.uToast.show({
-              title: `无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`,
-              type: 'error'
-            });
+            this.showToast(`无法调起${this.alipayEnv ? '支付宝' : this.wxEnv ? '微信' : '聚合'}支付!`, 'info');
           });
       }
     },
@@ -731,6 +662,15 @@ export default {
     },
     getDifference(a, b) {
       return a > b ? a - b : 0;
+    },
+    /**
+     * @description: 显示报错信息
+     * @param {*} title
+     * @param {*} type
+     * @return {*}
+     */
+    showToast(title, type = 'error') {
+      this.$refs.uToast.show({ title, type });
     }
   }
 };

+ 89 - 75
pages/myCars/myCars.vue

@@ -93,8 +93,40 @@ export default {
     };
   },
   onLoad() {
+    this.mycars = [];
     this.handlegetMycars();
   },
+  onPullDownRefresh() {
+    Object.assign(this, {
+      keyboardshow: false,
+      delCarshow: false,
+      delCarId: null,
+      delCarContent: '',
+      newPlateNumber: '',
+      vehicleColor: 0,
+      mycars: [],
+      status: 'loadmore',
+      page: {
+        num: 1,
+        size: 10,
+        total: 0
+      },
+      mycarsTotal: 0,
+      colorShow: false,
+      colorList: [
+        { text: '蓝色', colorCode: 0 },
+        { text: '黄色', colorCode: 1 },
+        { text: '黑色', colorCode: 2 },
+        { text: '白色', colorCode: 3 },
+        { text: '绿色', colorCode: 4 },
+        { text: '其他', colorCode: 99 }
+      ]
+    });
+    setTimeout(() => {
+      this.handlegetMycars();
+      uni.stopPullDownRefresh(); //停止刷新
+    }, 1000);
+  },
   onReachBottom() {
     if (this.page.num >= this.page.total) return;
     this.status = 'loading';
@@ -135,40 +167,27 @@ export default {
       });
     },
     // 添加车辆
-    handleAddCar() {
-      if (!this.$u.test.carNo(this.newPlateNumber)) {
-        this.$refs.uToast.show({
-          title: '请正确填写车牌号',
-          type: 'error'
-        });
+    async handleAddCar() {
+      const { newPlateNumber, vehicleColor } = this;
+      if (!this.$u.test.carNo(newPlateNumber)) {
+        this.showToast('请正确填写车牌号', 'warning');
         return;
       }
-      let param = {
-        vehicleNo: this.newPlateNumber,
-        vehicleColor: this.vehicleColor
-      };
-      this.$u.api
-        .addCar(param)
-        .then((res) => {
-          if (res.code === 200) {
-            this.$refs.uToast.show({
-              title: res.msg,
-              type: 'success'
-            });
-            this.handlegetMycars();
-          } else {
-            this.$refs.uToast.show({
-              title: res.msg,
-              type: 'error'
-            });
-          }
-        })
-        .catch((err) => {
-          this.$refs.uToast.show({
-            title: '操作失败!',
-            type: 'error'
+      try {
+        const { code, msg } = await this.$u.api.addCar({ vehicleNo: newPlateNumber, vehicleColor });
+        if (code === 200) {
+          this.showToast(msg, 'success');
+          Object.assign(this.page, {
+            num: 1,
+            size: 10,
+            total: 0
           });
-        });
+          this.mycars = [];
+          this.handlegetMycars();
+        }
+      } catch (error) {
+        this.showToast('操作失败!', 'error');
+      }
     },
     // 删除车辆
     handleDelCar(id, content) {
@@ -177,29 +196,22 @@ export default {
       this.delCarshow = true;
     },
     // 确认删除
-    confirmDelCar() {
-      this.$u.api
-        .delCar(this.delCarId)
-        .then((res) => {
-          if (res.code === 200) {
-            this.$refs.uToast.show({
-              title: res.msg,
-              type: 'success'
-            });
-            this.handlegetMycars();
-          } else {
-            this.$refs.uToast.show({
-              title: res.msg,
-              type: 'error'
-            });
-          }
-        })
-        .catch((err) => {
-          this.$refs.uToast.show({
-            title: '操作失败!',
-            type: 'error'
+    async confirmDelCar() {
+      try {
+        const { code, msg } = await this.$u.api.delCar(this.delCarId);
+        if (code === 200) {
+          this.showToast(msg, 'success');
+          Object.assign(this.page, {
+            num: 1,
+            size: 10,
+            total: 0
           });
-        });
+          this.mycars = [];
+          this.handlegetMycars();
+        }
+      } catch (error) {
+        this.showToast('操作失败!', 'error');
+      }
     },
     // 点击输入框
     messageInputClick() {
@@ -224,29 +236,31 @@ export default {
       this.vehicleColor = this.colorList[e].colorCode;
     },
     // 设置默认车辆操作
-    handlesetDefault(id) {
-      this.$u.api
-        .setDefaultCar({ id: id })
-        .then((res) => {
-          if (res.code === 200) {
-            this.$refs.uToast.show({
-              title: res.msg,
-              type: 'success'
-            });
-            this.handlegetMycars();
-          } else {
-            this.$refs.uToast.show({
-              title: res.msg,
-              type: 'error'
-            });
-          }
-        })
-        .catch((err) => {
-          this.$refs.uToast.show({
-            title: '操作失败!',
-            type: 'error'
+    async handlesetDefault(id) {
+      try {
+        const { code, msg } = await this.$u.api.setDefaultCar({ id });
+        if (code === 200) {
+          this.showToast(msg, 'success');
+          Object.assign(this.page, {
+            num: 1,
+            size: 10,
+            total: 0
           });
-        });
+          this.mycars = [];
+          this.handlegetMycars();
+        }
+      } catch (error) {
+        this.showToast('操作失败!', 'error');
+      }
+    },
+    /**
+     * @description: 显示提示
+     * @param {*} title
+     * @param {*} type
+     * @return {*}
+     */
+    showToast(title = '操作失败', type = 'info') {
+      this.$refs.uToast.show({ title, type });
     }
   }
 };

+ 31 - 34
pages/privacyPolicy/privacyPolicy.vue

@@ -16,43 +16,40 @@ export default {
   onLoad(query) {
     const termsType = query?.termsType;
     if (termsType) {
-      switch (Number(termsType)) {
-        case 1:
-          uni.setNavigationBarTitle({
-            title: '用户服务条款'
-          });
-          break;
-        case 2:
-          uni.setNavigationBarTitle({
-            title: '隐私政策'
-          });
-          break;
-      }
-      this.getSysterms(termsType);
+      const termsTypeObj = {
+        1: '用户服务条款',
+        2: '隐私政策'
+      };
+      uni.setNavigationBarTitle({
+        title: termsTypeObj[Number(termsType)]
+      });
+      this.getSysterms(Number(termsType));
     }
   },
   methods: {
-    getSysterms(termsType) {
-      this.$u.api
-        .getSysterms({
-          termsType: Number(termsType)
-        })
-        .then((res) => {
-          if (res.code === 200) {
-            this.content = res.data?.content;
-          } else {
-            this.$refs.uToast.show({
-              title: res.msg,
-              type: 'error'
-            });
-          }
-        })
-        .catch((err) => {
-          this.$refs.uToast.show({
-            title: '系统错误!',
-            type: 'error'
-          });
-        });
+    /**
+     * @description: 获取系统参数
+     * @param {*} termsType
+     * @return {*}
+     */
+    async getSysterms(termsType) {
+      try {
+        const { code, data } = await this.$u.api.getSysterms({ termsType });
+        if (code === 200) {
+          this.content = data?.content;
+        }
+      } catch (error) {
+        this.showToast('系统错误!', 'error');
+      }
+    },
+    /**
+     * @description: 显示提示
+     * @param {*} title
+     * @param {*} type
+     * @return {*}
+     */
+    showToast(title = '操作失败', type = 'info') {
+      this.$refs.uToast.show({ title, type });
     }
   }
 };