Переглянути джерело

修改停车缴费页面bug

zaijin 2 роки тому
батько
коміт
efd4f0799b
1 змінених файлів з 93 додано та 97 видалено
  1. 93 97
      pages/payLists/payLists.vue

+ 93 - 97
pages/payLists/payLists.vue

@@ -125,24 +125,17 @@
     >
       <view class="slot-content">
         <view class="pay-tips">
-          <text>{{ payTipsItem.num || 0 }}</text
-          >场停车欠费,共 <text>{{ payTipsItem.price || 0 }}</text
+          <text>{{ totalCount || 0 }}</text
+          >场停车欠费,共 <text>{{ totalPayAmount || 0 }}</text
           >元
         </view>
       </view>
     </u-modal>
     <!-- 支付方式 -->
-    <!-- <PaymentMethod
-      :payWayPop="payWayPop"
-      :exportFlag="exportFlag"
-      :curOrderList="currentItem"
-      :jumpUrl="jumpUrl"
-      @closePaymentMethod="closePaymentMethod"
-    ></PaymentMethod> -->
     <ChoosePayment
       ref="choosePayment"
       :exportFlag="exportFlag"
-      :curOrderList="currentItem"
+      :curOrderList="payOrderIdList"
       :jumpUrl="jumpUrl"
       @closePaymentMethod="closePaymentMethod"
     />
@@ -190,13 +183,12 @@ export default {
       PayUrl: '',
       payTipsPop: false,
       payWayPop: false,
-      // 选中去支付的单条条目
-      currentItem: [],
-      // 缴费提示类目
-      payTipsItem: {
-        num: '',
-        price: ''
-      },
+      // 用来筛选已经加入列表中的id集合
+      haveIncludesIdList: [],
+      // 订单支付id集合
+      payOrderIdList: [],
+      // 所有订单列表(不分页)
+      allOrderList: [],
       code: null,
       jumpUrl: ''
     };
@@ -225,6 +217,7 @@ export default {
     this.list[this.current].pageNum = 1;
     this.payList = [[], []];
     this.orderListArr(this.list[this.current], this.swiperCurrent);
+    this.getAllOrderList(this.swiperCurrent);
   },
   methods: {
     reachBottom() {
@@ -240,7 +233,9 @@ export default {
       this.swiperCurrent = index;
       this.current = index;
       //重新初始化
-      this.payList = [[], [], [], []];
+      this.haveIncludesIdList = [];
+      this.payOrderIdList = [];
+      this.payList = [[], []];
       this.list[index].pageNum = 1;
       if (index == 1) {
         this.exportFlag = true;
@@ -248,6 +243,7 @@ export default {
         this.exportFlag = false;
       }
       this.orderListArr(this.list[index], index);
+      this.getAllOrderList(index);
     },
     transition({ detail: { dx } }) {
       this.$refs.tabs.setDx(dx);
@@ -263,27 +259,72 @@ export default {
         url: 'pages/index/index'
       });
     },
+    /**
+     * @description: 获取所有订单用于全部缴费
+     * @param {*} index
+     * @return {*}
+     */
+    getAllOrderList(index) {
+      if (index == 0) {
+        this.$u.api
+          .getOrderList({
+            pageSize: 1000,
+            pageNum: 1,
+            paying: true
+          })
+          .then((res) => {
+            if (res.code === 200) {
+              this.allOrderList = res?.data?.pageInfo?.rows ?? [];
+            }
+          });
+      } else {
+        this.$u.api
+          .getRoomParkingApi({
+            pageSize: 1000,
+            pageNum: 1,
+            paying: true
+          })
+          .then((res) => {
+            if (res.code === 200) {
+              this.allOrderList = res?.data?.pageInfo?.rows ?? [];
+            }
+          });
+      }
+    },
+    /**
+     * @description: 分页订单列表
+     * @param {*} orderType
+     * @param {*} index
+     * @return {*}
+     */
     orderListArr(orderType, index) {
       let pageNum = orderType.pageNum; // 页码, 默认从1开始
-      let pageSize = orderType.total; // 页长, 默认每页10条
       if (index == 0) {
         this.$u.api
           .getOrderList({
-            // pageSize: pageSize,
+            pageSize: 10,
             pageNum: pageNum,
             paying: true
           })
           .then((res) => {
+            // 判断重复
+            let newListFlag = true;
             for (const item of res.data.pageInfo.rows) {
-              this.payList[orderType.index].push(item);
+              if (this.haveIncludesIdList.includes(item.orderId)) {
+                newListFlag = false;
+              } else {
+                this.payList[orderType.index].push(item);
+              }
             }
-            this.list[this.current].total = res.data.pageInfo.total;
-            this.list[orderType.index].pageNum++;
-            if (this.payList[this.current].length >= this.list[this.current].total) {
-              this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore');
+            if (newListFlag) {
+              this.list[this.current].total = res.data.pageInfo.total;
+              this.list[orderType.index].pageNum++;
+              if (this.payList[this.current].length >= this.list[this.current].total) {
+                this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore');
+              }
+              this.totalCount = res.data.costInfo.totalCount;
+              this.totalPayAmount = res.data.costInfo.totalPayAmount;
             }
-            this.totalCount = res.data.costInfo.totalCount;
-            this.totalPayAmount = res.data.costInfo.totalPayAmount;
           })
           .catch((err) => {
             this.$refs.uToast.show({
@@ -298,73 +339,44 @@ export default {
             paying: true
           })
           .then((res) => {
+            let newListFlag = true;
             for (const item of res.data.pageInfo.rows) {
-              this.payList[orderType.index].push(item);
+              if (this.haveIncludesIdList.includes(item.orderId)) {
+                newListFlag = false;
+              } else {
+                this.payList[orderType.index].push(item);
+              }
             }
-            this.list[this.current].total = res.data.pageInfo.total;
-            this.list[orderType.index].pageNum++;
-            if (this.payList[this.current].length >= this.list[this.current].total) {
-              this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore');
+            if (newListFlag) {
+              this.list[this.current].total = res.data.pageInfo.total;
+              this.list[orderType.index].pageNum++;
+              if (this.payList[this.current].length >= this.list[this.current].total) {
+                this.loadStatus.splice(this.list[orderType.index].index, 1, 'nomore');
+              }
+              this.totalCount = res.data.costInfo.totalCount;
+              this.totalPayAmount = res.data.costInfo.totalPayAmount;
             }
-            this.totalCount = res.data.costInfo.totalCount;
-            this.totalPayAmount = res.data.costInfo.totalPayAmount;
           });
       }
     },
-    all() {
-      this.payList.forEach((item, index, arr) => {
-        if (item.orderId) {
-          this.orderList.push(item.orderId);
-        }
-      });
-
-      this.$u.api
-        .payGzbank({
-          orderList: this.orderList
-        })
-        .then((res) => {
-          let payUrl = res.data.url;
-          this.currentPayUrl = encodeURIComponent(res.data.url);
-          // console.log('this.currentPayUrl',this.currentPayUrl);
-          // return;
-          this.$u.route({
-            url: 'pages/payLists/pay',
-            params: {
-              currentPayUrl: this.currentPayUrl
-            }
-          });
-        })
-        .catch((err) => {
-          this.$refs.uToast.show({
-            title: err.msg,
-            type: 'error'
-          });
-        });
-    },
     // 去支付,选择支付方式
     choosePayWay(orderId, item) {
-      this.currentItem = [];
-      this.currentItem.push(orderId);
-      // this.payWayPop = true;
+      this.payOrderIdList = [];
+      this.payOrderIdList.push(orderId);
       this.$nextTick(() => {
         this.$refs['choosePayment'].openPopup(item, 'single', this.current === 0 ? 'road' : 'parking');
       });
     },
     // 全部缴费确认
     confirmPrice() {
-      // let orderNum = 0,
-      //   price = 0;
-      // this.currentItem = [];
-      // this.payList[this.current].forEach((item) => {
-      //   if (item.orderStatus !== 4 && item.payStatus !== 1) {
-      //     price += Number(item.payAmount);
-      //     orderNum++;
-      //     this.currentItem.push(item.orderId);
-      //   }
-      // });
-      this.payTipsItem.num = this.totalCount;
-      this.payTipsItem.price = this.totalPayAmount.toFixed(2);
-      if (this.payTipsItem.num !== 0 && this.payTipsItem.price !== 0) {
+      let payOrderIdList = [];
+      this.allOrderList.forEach((item) => {
+        if (item.orderStatus !== 4 && item.payStatus !== 1) {
+          payOrderIdList.push(item.orderId);
+        }
+      });
+      this.payOrderIdList = payOrderIdList;
+      if (this.totalCount !== 0 && this.totalPayAmount !== 0) {
         this.payTipsPop = true;
       } else {
         this.$refs.uToast.show({
@@ -375,30 +387,14 @@ export default {
     },
     // 缴费提示弹框确认
     payTipsPopConfirm() {
-      // this.payWayPop = true;
       this.$nextTick(() => {
         this.$refs['choosePayment'].openPopup(
-          { payAmount: Number(this.payTipsItem.price), ...this.payTipsItem },
+          { payAmount: Number(this.totalPayAmount) },
           'multiple',
           this.current === 0 ? 'road' : 'parking'
         );
       });
     },
-    handleGetOrderinfo(orderId) {
-      this.$u.api
-        .getOrderinfo({
-          id: orderId
-        })
-        .then((res) => {
-          this.orderInfo = res.data;
-        })
-        .catch((err) => {
-          this.$refs.uToast.show({
-            title: err.msg,
-            type: 'error'
-          });
-        });
-    },
     closePaymentMethod() {
       this.payWayPop = false;
     }