Преглед изворни кода

Merge branch 'liuxiangxin' into jun

jun пре 2 недеља
родитељ
комит
dfa64e9aac
3 измењених фајлова са 64 додато и 13 уклоњено
  1. 30 0
      pages/index/index.vue
  2. 11 2
      pages/orders/lottery.vue
  3. 23 11
      pages/product/index.vue

+ 30 - 0
pages/index/index.vue

@@ -176,8 +176,12 @@ export default {
       this.isReqing = false;
       // 成功结果
       if (re.code == "success") {
+		// 如果是最后一页
         if (re.data.last_page <= this.requestParam.page) this.isLast = true;
+		// 赋值
         this.productList = re.data.data;
+		// 获取下一页
+		this.getMore(re);
       }
     });
   },
@@ -196,8 +200,12 @@ export default {
       this.isReqing = false;
       // 成功结果
       if (re.code == "success") {
+		// 如果是最后一页
         if (re.data.last_page <= this.requestParam.page) this.isLast = true;
+		// 赋值
         this.productList = re.data.data;
+		// 获取下一页
+		this.getMore(re);
       }
     });
     uni.stopPullDownRefresh();
@@ -227,6 +235,28 @@ export default {
     });
   },
   methods: {
+	// 请求加载下一页
+	getMore(callback){
+		// 首页不足10个,并且下一页存在大于当前页
+		if( this.productList.length < 10 && callback.data.last_page > this.requestParam.page ){
+			// 最后一页不再请求
+			if (this.isLast) return;
+			// 增加一页
+			this.requestParam.page = this.requestParam.page + 1;
+			// 请求列表
+			this.$http.request("api/product/get_list", this.requestParam).then((re) => {
+			  // 成功结果
+			  if (re.code == "success") {
+			    // 最后一页
+			    if (re.data.last_page <= this.requestParam.page) this.isLast = true;
+			    // 追加数据
+			    this.productList.push(...re.data.data);
+				// 获取下一页
+				this.getMore(re);
+			  }
+			});
+		}
+	},
     searchChange(e) {
       // 如果没有搜索词
       if (!this.requestParam.name) {

+ 11 - 2
pages/orders/lottery.vue

@@ -110,6 +110,7 @@ export default {
         id: 0,
       },
       checkedAddr: {},
+	  isReqing:false,
     };
   },
   onLoad(param) {
@@ -196,6 +197,8 @@ export default {
       });
     },
     onClick() {
+	  // 没有数据的话,或者请求中,不允许刷新
+	  if (this.isReqing) return;
       // 活动是否开始
       if (!this.lotteryInfo.id) {
         uni.showToast({
@@ -228,8 +231,8 @@ export default {
         });
         return;
       }
-      // 次数操作
-      this.lotteryInfo.join_num = this.lotteryInfo.join_num - 1;
+	  // 设置请求中
+	  this.isReqing = true;
       // 请求列表
       this.$http.request('/api/lottery_order/get_reward', { lottery_id: this.lotteryInfo.id }).then((re) => {
         // 设置非请求中
@@ -238,6 +241,8 @@ export default {
         if (re.code == 'success') {
           // 奖品列表更新
           this.prizeList = re.data.reward_list;
+		  // 次数操作
+		  this.lotteryInfo.join_num = this.lotteryInfo.join_num - 1;
           // 奖品的索引
           return this.$refs.dialer.run(re.data.reward_index);
         } else {
@@ -256,8 +261,12 @@ export default {
       this.$refs.lotteryRule.close();
     },
     showRecord() {
+      // 没有数据的话,或者请求中,不允许刷新
+	  if (this.isReqing) return;
       // 活动是否开始
       if (this.lotteryInfo.id) {
+	    // 设置请求中
+		this.isReqing = true;
         // 请求列表
         this.$http.request('/api/lottery_order_record/get_list', { lottery_id: this.lotteryInfo.id }).then((re) => {
           // 设置非请求中

+ 23 - 11
pages/product/index.vue

@@ -267,7 +267,7 @@
     <uni-popup ref="regiment" type="bottom" class="popup" background-color="#FFFFFF">
       <view class="popup_title">可参与的拼单</view>
       <view class="regiment_popup_list">
-        <view class="regiment_popup_item" v-for="(item, index) in productInfo.regiment_list" @click="checkedCoupon(index, false)" :key="index">
+        <view class="regiment_popup_item" v-for="(item, index) in productInfo.regiment_list" :key="index">
           <view class="username">
             <image class="user_image" :src="item.userpic"></image>
             <text class="username_text">{{ item.username }}</text>
@@ -509,15 +509,27 @@ export default {
       this.priceHandler();
       // 显示下单弹出层
       this.$refs.specPopup.open("bottom");
-      // 结果
-      this.$http.request("api/custom_coupon/get_checked", this.requestParam).then((re) => {
-        if (re.code == "success") {
-          // 赋值
-          this.couponList = re.data;
-          // 优惠券是否可用
-          this.checkCoupon();
-        }
-      });
+	  // 如果非团购的话,查询优惠券
+	  if( type == 3 || type == 4 ){
+		  // 选择优惠券重置
+		  this.couponList = [];
+		  // 已经选择的优惠券ID
+		  this.customCoupon = 0;
+		  // 计算扣减
+		  this.couponRebate();
+		  // 计算价格
+		  this.priceHandler();
+	  }else{
+		  // 结果
+		  this.$http.request("api/custom_coupon/get_checked", this.requestParam).then((re) => {
+		    if (re.code == "success") {
+		      // 赋值
+		      this.couponList = re.data;
+		      // 优惠券是否可用
+		      this.checkCoupon();
+		    }
+		  });
+	  }
       // 地址列表
       this.getAddrList();
       //只有一组sku时是否下架
@@ -672,7 +684,7 @@ export default {
             "api/orders/create_regiment",
             {
               product_list: productList,
-              custom_coupon_id: this.customCoupon,
+              // custom_coupon_id: this.customCoupon,
               addr_id: this.checkedAddr.id,
               btn_type: this.specBtnType,
               regiment_id: this.regiment_id,