Browse Source

强化贵大商户ID

vaecebyZ 1 year ago
parent
commit
4c57324ef2
5 changed files with 121 additions and 71 deletions
  1. 4 0
      my/activityManage/index.vue
  2. 14 2
      my/order/detail.vue
  3. 15 6
      pages/activity/index.vue
  4. 26 10
      signUp/orderDetail.vue
  5. 62 53
      utils/tool.js

+ 4 - 0
my/activityManage/index.vue

@@ -54,6 +54,7 @@
 <script>
 import uniCard from "@/uni_modules/uni-card/components/uni-card/uni-card.vue";
 import { search } from "../../api/activity";
+import { GDZShopiID } from "../../utils/tool";
 export default {
   components: {
     uniCard,
@@ -103,6 +104,9 @@ export default {
     getList(where) {
       console.log('触发了!', where, this.query.currentPage);
       this.listStatus = "loading"
+      if (!this.shopId) {
+        this.shopId = await GDZShopiID()
+      }
       search({
         shopId: this.shopId,
         ...this.query,

+ 14 - 2
my/order/detail.vue

@@ -354,7 +354,8 @@ export default {
             title: "支付中",
           });
           const checkOrder = setInterval(() => {
-            queryPayOrder(that.info.orderNo).then((res1) => {
+            queryPayOrder(that.info.orderNo)
+            .then((res1) => {
               // 支付成功
               if (res1.content.status == "TRADE_SUCCESS") {
                 that.payDetails(that.info.orderNo);
@@ -377,7 +378,18 @@ export default {
                 });
                 uni.hideLoading();
               }
-            });
+            }).catch(() => {
+              if(checkOrder){
+                clearInterval(checkOrder)
+                checkOrder = null
+              }
+              that.btnLoading = false;
+              uni.showToast({
+                title: "订单查询失败",
+                icon: "none",
+              });
+              uni.hideLoading();
+            })
           }, 1000);
         }
       });

+ 15 - 6
pages/activity/index.vue

@@ -41,6 +41,7 @@
 <script>
 import uniCard from "@/uni_modules/uni-card/components/uni-card/uni-card.vue";
 import { getActivityList } from "../../api/activity";
+import { GDZShopiID } from "../../utils/tool";
 export default {
   components: {
     uniCard,
@@ -71,8 +72,14 @@ export default {
     };
   },
   onShow() {
+    this.list = []
+    this.query = {
+      currentPage: 1,
+      pageSize: 3,
+      activityEnable: 1,
+      state: null,
+    }
     this.getList();
-    this.query.state = null;
   },
   created() {
     this.navBarHeight = this.$navHight(1);
@@ -80,13 +87,16 @@ export default {
     this.navBarHeight = this.navBarHeight + 10 + "px";
   },
   methods: {
-    getList() {
-      this.listStatus="loading"
+    async getList() {
+      this.listStatus = "loading"
+      if (!this.shopId) {
+        this.shopId = await GDZShopiID()
+      }
       getActivityList({
         shopId: this.shopId,
         ...this.query,
       }).then(res => {
-        this.list =  this.list.concat(res.content.records);
+        this.list = this.list.concat(res.content.records);
         this.loading = false;
         // this.list = res.content.records;
         let total = this.list.length
@@ -94,7 +104,7 @@ export default {
           this.listStatus = "noMore";
         } else {
           this.listStatus = "more";
-          this.query.currentPage++;
+          this.query.currentPage = this.query.currentPage + 1;
         }
       })
     },
@@ -143,7 +153,6 @@ page {
 }
 </style>
 <style lang="scss" scoped>
-
 ::v-deep .zs-list {
   height: 80vh;
   overflow-y: scroll;

+ 26 - 10
signUp/orderDetail.vue

@@ -113,11 +113,11 @@
         </view>
       </view>
 
-      <view class="item">
+      <view class="item" v-if="info.payAmount != 0">
         <view class="label"> 付款方式 </view>
-        <!-- <view class="value">
+        <view class="value">
           {{ info.payment.pay ? filterPay(info.payment.paymentWay) : "未支付" }}
-        </view> -->
+        </view>
       </view>
       <view class="item">
         <view class="label"> 下单时间 </view>
@@ -130,7 +130,7 @@
 
       <view class="item" v-if="
         info.goodsList[0].goodsState != 'WAIT_PAYMENT' &&
-        info.goodsList[0].goodsState != 'CLOSE'
+        info.goodsList[0].goodsState != 'CLOSE' && info.payAmount != 0
       ">
         <view class="label"> 支付时间 </view>
         <view class="value">
@@ -138,14 +138,14 @@
         </view>
       </view>
 
-      <view class="item">
+      <!-- <view class="item">
         <view class="label"> 订单备注 </view>
         <view class="value">
           {{
             info.extend.remark || "无"
           }}
         </view>
-      </view>
+      </view> -->
     </view>
 
     <view class="content">
@@ -199,7 +199,7 @@
     <view class="content apply-box" v-else-if="
       (info.goodsList[0].goodsState == 'WAIT_USE' ||
         info.goodsList[0].goodsState == 'USED') &&
-      isRefund()
+      isRefund() && info.payAmount != 0
     " @click="apply">
       <view class="label"> 退款申请 </view>
       <view class="value"> 如引发商品争议,可申请平台介入处理 </view>
@@ -281,6 +281,8 @@ export default {
         return "订单已完成";
       } else if (val == "WAIT_PAYMENT") {
         return "待付款";
+      }else if (val == "HAVE_PAID") {
+        return "已付款";
       } else if (val == "WAIT_USE") {
         return "待使用";
       }
@@ -369,7 +371,9 @@ export default {
       payDetails(orderNo).then((res) => {
         this.info = res.content;
         this.$forceUpdate()
-        queryPayOrder(this.info.orderNo)
+        if(this.info.payAmount > 0){
+          queryPayOrder(this.info.orderNo)
+        }
         this.info.extend = JSON.parse(this.info.goodsList[0].extend);
 
         // 查询报名的人数信息
@@ -415,8 +419,9 @@ export default {
           uni.showLoading({
             title: "支付中",
           });
-          const checkOrder = setInterval(() => {
-            queryPayOrder(that.info.orderNo).then((res1) => {
+          let checkOrder = setInterval(() => {
+            queryPayOrder(that.info.orderNo)
+            .then((res1) => {
               // 支付成功
               if (res1.content.status == "TRADE_SUCCESS") {
                 that.payDetails(that.info.orderNo);
@@ -439,6 +444,17 @@ export default {
                 });
                 uni.hideLoading();
               }
+            }).catch(() => {
+              if(checkOrder){
+                clearInterval(checkOrder)
+                checkOrder = null
+              }
+              that.btnLoading = false;
+              uni.showToast({
+                title: "订单查询失败",
+                icon: "none",
+              });
+              uni.hideLoading();
             });
           }, 1000);
         }

+ 62 - 53
utils/tool.js

@@ -1,75 +1,84 @@
+import { getGdShopInfo } from "@/api/study.js";
+
 //防抖debounce代码:
-export function debounce(fn,delay=500) {
+export function debounce(fn, delay = 500) {
   var timeout = null; // 创建一个标记用来存放定时器的返回值
   return function (e) {
-      // 每当用户输入的时候把前一个 setTimeout clear 掉
-      clearTimeout(timeout); 
-      // 然后又创建一个新的 setTimeout, 这样就能保证interval 间隔内如果时间持续触发,就不会执行 fn 函数
-      timeout = setTimeout(() => {
-          fn.apply(this, arguments);
-      }, delay);
+    // 每当用户输入的时候把前一个 setTimeout clear 掉
+    clearTimeout(timeout);
+    // 然后又创建一个新的 setTimeout, 这样就能保证interval 间隔内如果时间持续触发,就不会执行 fn 函数
+    timeout = setTimeout(() => {
+      fn.apply(this, arguments);
+    }, delay);
   };
 }
 
 // 返回两个经纬度之间的距离 单位米
 const earthDistance = function (location1, location2) {
-	    const lat1 = parseFloat(location1.lat);
-	    const lng1 = parseFloat(location1.lng);
-	    const lat2 = parseFloat(location2.lat);
-	    const lng2 = parseFloat(location2.lng);
-	
-	    const EARTH_RADIUS = 6378137.0; //单位M
-	    const PI = Math.PI;
-	
-	    function getRad(d) {
-	        return d * PI / 180.0;
-	    }
-	
-	    let f = getRad((lat1 + lat2) / 2);
-	    let g = getRad((lat1 - lat2) / 2);
-	    let l = getRad((lng1 - lng2) / 2);
-	
-	    let sg = Math.sin(g);
-	    let sl = Math.sin(l);
-	    let sf = Math.sin(f);
-	
-	    let s, c, w, r, d, h1, h2;
-	    let a = EARTH_RADIUS;
-	    let fl = 1 / 298.257;
-	
-	    sg = sg * sg;
-	    sl = sl * sl;
-	    sf = sf * sf;
-	
-	    s = sg * (1 - sl) + (1 - sf) * sl;
-	    c = (1 - sg) * (1 - sl) + sf * sl;
-	
-	    w = Math.atan(Math.sqrt(s / c));
-	    r = Math.sqrt(s * c) / w;
-	    d = 2 * w * a;
-	    h1 = (3 * r - 1) / 2 / c;
-	    h2 = (3 * r + 1) / 2 / s;
-	
-	    return d * (1 + fl * (h1 * sf * (1 - sg) - h2 * (1 - sf) * sg));
-	};
+  const lat1 = parseFloat(location1.lat);
+  const lng1 = parseFloat(location1.lng);
+  const lat2 = parseFloat(location2.lat);
+  const lng2 = parseFloat(location2.lng);
+
+  const EARTH_RADIUS = 6378137.0; //单位M
+  const PI = Math.PI;
+
+  function getRad(d) {
+    return (d * PI) / 180.0;
+  }
+
+  let f = getRad((lat1 + lat2) / 2);
+  let g = getRad((lat1 - lat2) / 2);
+  let l = getRad((lng1 - lng2) / 2);
+
+  let sg = Math.sin(g);
+  let sl = Math.sin(l);
+  let sf = Math.sin(f);
+
+  let s, c, w, r, d, h1, h2;
+  let a = EARTH_RADIUS;
+  let fl = 1 / 298.257;
+
+  sg = sg * sg;
+  sl = sl * sl;
+  sf = sf * sf;
 
+  s = sg * (1 - sl) + (1 - sf) * sl;
+  c = (1 - sg) * (1 - sl) + sf * sl;
+
+  w = Math.atan(Math.sqrt(s / c));
+  r = Math.sqrt(s * c) / w;
+  d = 2 * w * a;
+  h1 = (3 * r - 1) / 2 / c;
+  h2 = (3 * r + 1) / 2 / s;
+
+  return d * (1 + fl * (h1 * sf * (1 - sg) - h2 * (1 - sf) * sg));
+};
 
 //rpx转换px  px=rpx * (屏幕宽度 / 750)
 export const rpxTopx = function (rpx) {
-			let width = uni.getWindowInfo().screenWidth
-			let px = rpx *( width / 750 );
-			return px
-		}
-		
+  let width = uni.getWindowInfo().screenWidth;
+  let px = rpx * (width / 750);
+  return px;
+};
+
 export const getNavHight = function (f) {
   //#ifndef H5 || MP-ALIPAY ||APP-PLUS
   //获取小程序胶囊的高度
   let { bottom, height } = uni.getMenuButtonBoundingClientRect();
   // this.height = height;
   this.navBareight = bottom;
-  if(f){
+  if (f) {
     return bottom;
   }
-  return bottom + 'px';
+  return bottom + "px";
   //#endif
 };
+
+export const GDZShopiID = async function () {
+  const res = await getGdShopInfo();
+  if (res.state == "Success") {
+    uni.setStorageSync("gdShopId", res.content.shopId);
+		return res.content.shopId;
+  }
+};