Sfoglia il codice sorgente

Merge branch 'master' of https://gitee.com/huangg/panda_beauty_makeup_small_program

zhashaonan 7 anni fa
parent
commit
1fbead1f11

+ 1 - 4
app.wxss

@@ -1,12 +1,9 @@
 /**app.wxss**/
 
-body {
-  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", 微软雅黑, Arial, sans-serif;
-}
 page {
+  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", 微软雅黑, Arial, sans-serif;
   background-color: #f9f9f9;
 }
-
 .container {
   height: 100%;
   display: flex;

+ 4 - 1
pages/components/blocks/search/search.wxml

@@ -1,3 +1,6 @@
 <view class='search_box' bindtap='skipSearch'>
-  <text>搜索商品 品牌 功效 规格</text>
+  <view>
+    <icon type='search' size='16'></icon>
+    <text>搜索商品 品牌 功效 规格</text>
+    </view>
 </view>

+ 6 - 1
pages/components/blocks/search/search.wxss

@@ -8,7 +8,7 @@
   z-index: 10;
   background: #ffffff;
 }
-.search_box text {
+.search_box view {
   width:720rpx;
   height:70rpx;
   line-height:70rpx;
@@ -20,3 +20,8 @@
   box-sizing:border-box;
   margin-left:15rpx;
 }
+.search_box icon {
+  position: relative;
+  top: 8rpx;
+  right: 8rpx;  
+}

+ 51 - 32
pages/shopCart/shopCart.js

@@ -1,15 +1,9 @@
 const getReq = require('./../../config.js').getReq;
 Page({
   data: {
-    free_info: {
-      type: Array
-    },
-    summary: {
-      type: Array
-    },
-    cart_list: {
-      type: Array
-    },
+    free_info: [],
+    summary: [],
+    cart_list: [],
     all_checked: false,
     allPrice: 0,
     allGoodsPrice: 0,
@@ -20,19 +14,31 @@ Page({
 
   },
   onShow: function () {
+    this.req_datas();
+  },
+  req_datas(){
     let self = this;
+    wx.showLoading({
+      title: '加载中',
+    });
     getReq({
       act: 'cart',
       op: 'list',
-      minest_cartid: this.data.curpage
+      minest_cartid: self.data.curpage
     }, function (res) {
       if (res.code == 200) {
         let hasmore = res.datas.mobile_page.hasmore;
         let free_info = res.datas.free_info;
         let summary_datas = res.datas.summary;
         let cart_list = res.datas.cart_list;
-        let lashCartListId = cart_list[cart_list.length - 1].cart_id;
         let summary = [];
+        if (cart_list.length <= 0) {
+          self.setData({
+            free_info: free_info || self.data.free_info
+          });
+          wx.hideLoading();
+          return;
+        }
         for (let item of cart_list) {
           item.checked = false;
         }
@@ -40,24 +46,33 @@ Page({
           for (let j = 0; j < summary_datas.length; j++) {
             if (cart_list[i].goods_id == summary_datas[j].goods_id) {
               summary.push(summary_datas[j]);
+              continue;
             }
           }
         }
         if (hasmore) {
+          let lastCartListId = cart_list[cart_list.length - 1].cart_id;
           self.setData({
             hasmore: true,
-            curpage: lashCartListId
+            curpage: lastCartListId
+          })
+        }
+        else {
+          self.setData({
+            hasmore: false
           })
-        }  
+        }
+        let localSummary = self.data.summary;
+        let localCartList = self.data.cart_list;
         self.setData({
-          free_info,
-          summary,
-          cart_list
+          free_info: free_info || self.data.free_info,
+          summary: localSummary.concat(summary),
+          cart_list: localCartList.concat(cart_list)
         });
+        wx.hideLoading();
       }
     })
   },
-
   goods_checked(e) {
     let goods_id = e.currentTarget.dataset.goodsid;
     let cart_list = this.data.cart_list;
@@ -146,17 +161,7 @@ Page({
     else {
       quantity = num - quantity;
       if (quantity <= 0) {
-        wx.showModal({
-          title: "提示",
-          content: "确定要删除吗?",
-          success: function (res) {
-            if (res.confirm) {
-              self.req_goods_num(cart_id, quantity, self.del_cart(cart_id, goods_id));
-            } else if (res.cancel) {
-              return;
-            }
-          }
-        })
+        this.cancal_cart(e,goods_id, cart_id);
       }
       else {
         self.req_goods_num(cart_id, quantity);
@@ -181,6 +186,22 @@ Page({
       cart_list
     })
   },
+  cancal_cart(e,goodsid,cartid){
+    let self = this;
+    let goods_id = e.target.dataset.goodsid || goodsid;
+    let cart_id = e.target.dataset.cartid || cartid;
+    wx.showModal({
+      title: "提示",
+      content: "确定要删除吗?",
+      success: function (res) {
+        if (res.confirm) {
+          self.req_goods_num(cart_id, 0, self.del_cart(cart_id, goods_id));
+        } else if (res.cancel) {
+          return;
+        }
+      }
+    })
+  },
   total(){
     let self = this;
     let cart_item = [];
@@ -217,16 +238,14 @@ Page({
     let self = this;
     let hasmore = this.data.hasmore;
     if(hasmore) {
+      
       let req_curpage = this.data.curpage;
       getReq({
         act: 'cart',
         op: 'list',
         minest_cartid: req_curpage
       }, function (res) {
-        self.setData({
-          curpage: req_curpage
-        })
-        console.log(res);
+        self.req_datas();
       })
     }
   },

+ 2 - 1
pages/shopCart/shopCart.wxml

@@ -10,9 +10,10 @@
 <view class='cart_list'>
   <block wx:for="{{summary}}" wx:key="{{index}}">
     <view class='cart_item'>
+      <icon class='cancal_btn' type="cancel" size="22" color="#ff4e4e" bindtap='cancal_cart' data-goodsid="{{cart_list[index]['goods_id']}}" data-cartid="{{cart_list[index]['cart_id']}}"></icon>
       <view class='check_btn' data-goodsid="{{cart_list[index]['goods_id']}}" bindtap='goods_checked'>
         <block wx:if="{{cart_list[index]['checked']}}">
-          <icon type="success" size="15" color="#ff4e4e"></icon>
+          <icon type="success" size="18" color="#ff4e4e"></icon>
         </block>
         <block wx:else>
           <view class="icon_empty"></view>

+ 8 - 0
pages/shopCart/shopCart.wxss

@@ -152,4 +152,12 @@
 }
 .clear_fixed {
   height: 88rpx;
+}
+.cancal_btn {
+  position: absolute;
+  right: 10rpx;
+  top: 15rpx;
+  width: 40rpx;
+  height: 40rpx;
+  z-index: 10;
 }

+ 1 - 1
project.config.json

@@ -30,7 +30,7 @@
 			"list": []
 		},
 		"miniprogram": {
-			"current": 2,
+			"current": -1,
 			"list": [
 				{
 					"id": 0,