Browse Source

【Mod】优化首页列表问题

liuxiangxin 1 month ago
parent
commit
1a2d1891fc
3 changed files with 54 additions and 12 deletions
  1. 30 0
      pages/index/index.vue
  2. 1 1
      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) {

+ 1 - 1
pages/orders/lottery.vue

@@ -266,7 +266,7 @@ export default {
       // 活动是否开始
       if (this.lotteryInfo.id) {
 	    // 设置请求中
-		this.isReqing = false;
+		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,