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

第三方商户库存共享pt模块修改

hyq 6 роки тому
батько
коміт
444d7f169d

+ 1 - 1
pom.xml

@@ -28,7 +28,7 @@
         <mybatis-spring-version>1.3.0</mybatis-spring-version>
         <mysql-version>5.1.39</mysql-version>
         <hibernate-validator-version>5.4.1.Final</hibernate-validator-version>
-        <druid-version>1.0.28</druid-version>
+        <druid-version>1.1.14</druid-version>
         <mariadb-version>2.0.2</mariadb-version>
         <HikariCP-version>2.6.3</HikariCP-version>
         <commons-lang-version>2.6</commons-lang-version>

+ 2 - 1
wx-mall/app.js

@@ -26,6 +26,7 @@ App({
       avatarUrl: 'http://120.76.26.84:80/group1/M00/00/01/rBJEdVvr17OACigOAAAB_us54MA744.png'
     },
     token: '',
-    appGoodsBizType: '00'
+    appGoodsBizType: '00',
+    appCheckCart: '00'
   }
 })

+ 1 - 1
wx-mall/app.wxss

@@ -208,7 +208,7 @@ view, text {
   border-radius: 40rpx;
   background-color: #4d4d4e;
   position: fixed;
-  bottom: 20rpx;
+  bottom: 8rpx;
   z-index: 499;
   left: 50%;
   margin-left: -350rpx;

+ 64 - 20
wx-mall/pages/cart/cart.js

@@ -36,9 +36,11 @@ Page({
     retailPrice: '',
     stockNum: 0,
     cartNumber: 0,
-    checkCart: '00',
+    checkCart: app.globalData.appCheckCart,
     total00: 0,
-    total11: 0
+    total11: 0,
+    page: 1,
+    size: 4
   },
   onLoad: function(options) {
     // 页面初始化 options为页面跳转所带来的参数
@@ -49,6 +51,9 @@ Page({
   },
   onShow: function () {
     let that = this;
+    that.setData({
+      checkCart: app.globalData.appCheckCart
+    });
     // 页面显示
     if (wx.getStorageSync('userInfo') || wx.getStorageSync('token')) {
       if (wx.getStorageSync('storeId')) {
@@ -62,6 +67,10 @@ Page({
             that.reLoad();
           }
         });
+        that.setData({
+          footprintList: [],
+          page: 1
+        });
         that.getCartList();
         that.getFootprintList();
       }else{
@@ -81,23 +90,32 @@ Page({
     switch (currentId) {
       case 'defaultActivity':
         that.setData({
-          'checkCart': '00'
+          'checkCart': '00',
+          footprintList: [],
+          page: 1
         });
+        app.globalData.appCheckCart = '00';
         this.getCartList();
         this.getFootprintList();
         break;
       case 'ordActivity':
         that.setData({
-          'checkCart': '11'
+          'checkCart': '11',
+          footprintList: [],
+          page: 1
         });
+        app.globalData.appCheckCart = '11';
         this.getCartList();
         this.getFootprintList();
         break;
       default:
         //综合排序
         that.setData({
-          'checkCart': '00'
+          'checkCart': '00',
+          footprintList: [],
+          page: 1
         });
+        app.globalData.appCheckCart = '00';
         this.getCartList();
         this.getFootprintList();
     }
@@ -484,19 +502,6 @@ Page({
       }
     });
   },
-  getFootprintList() {
-    let that = this;
-    util.request(api.GuessFootprintList, {
-      storeId: wx.getStorageSync('storeId'),
-      checkCart: that.data.checkCart
-    }, ).then(function(res) {
-      if (res.errno === 0) {
-        that.setData({
-          footprintList: res.data.list
-        });
-      }
-    });
-  },
   switchAttrPop: function() {
     this.setData({
       openAttr: !this.data.openAttr
@@ -552,12 +557,22 @@ Page({
       goodsId: goodsId
     }).then(function(res) {
       if (res.errno === 0 && null != res.data) {
+        let stockNumbers = 0;
+        if (res.data.goodsVo.goodsBizType=='00') {
+          if (res.data.goodsVo.isStockShare == 1) {
+            stockNumbers = res.data.goodsVo.goods_number;
+          } else {
+            stockNumbers = res.data.goodsVo.stockNum;
+          }
+        } else {
+          stockNumbers = res.data.goodsVo.stockNum;
+        }
         that.setData({
           goodsVo: res.data.goodsVo,
           specificationList: res.data.specificationList,
           productList: res.data.productList,
           openAttr: !that.data.openAttr,
-          stockNum: res.data.productList[0].stock_num,
+          stockNum: stockNumbers,
           cartNumber: res.data.cartNumber,
           checkedSpecText: res.data.specificationList[0].valueList[0].value
         });
@@ -612,7 +627,9 @@ Page({
           mask: true
         });
         that.setData({
-          openAttr: !that.data.openAttr
+          openAttr: !that.data.openAttr,
+          footprintList:[],
+          page:1
         })
         // 页面显示
         that.getCartList();
@@ -645,5 +662,32 @@ Page({
         }
       }
     });
+  },
+  getFootprintList() {
+    let that = this;
+    util.request(api.GuessFootprintList, {
+      storeId: wx.getStorageSync('storeId'),
+      checkCart: that.data.checkCart, page: that.data.page, size: that.data.size
+    }).then(function (res) {
+      if (res.errno === 0) {
+        let goodsList = that.data.footprintList.concat(res.data.list);
+        that.setData({
+          footprintList: goodsList
+        });
+        wx.hideLoading();
+      }
+    });
+  },
+  onReachBottom() {
+    var that = this;
+    if(!that.data.footprintList){
+      // wx.showLoading({
+      //   title: '加载中...',
+      // })
+    }
+    that.setData({
+      page: that.data.page + 1
+    });
+    that.getFootprintList();
   }
 })

+ 4 - 3
wx-mall/pages/cart/cart.wxml

@@ -16,7 +16,7 @@
     <!-- <view class="item">30分钟速达</view>
     <view class="item">每日优选生鲜</view>
     <view class="item">满88元免配送费</view> -->
-    <view class="item">新用户可领取5元优惠券</view>
+    <!-- <view class="item">新用户可领取5元优惠券</view> -->
   </view> 
   <view class="no-cart" wx:if="{{cartGoods.length <= 0}}" bindtap="hideSwitchAttrPop">
     <view class="c">
@@ -66,8 +66,8 @@
                   <view class="selnum">
                     <view class="cut" data-goods-id="{{item.id}}" data-item-index="{{index}}" data-product-id="{{item.product_id}}" bindtap="cutNumber"></view>
                     <input value="{{item.number}}" class="number" disabled="true" type="number" />
-                    
-                    <image class="add2" src="{{item.number < item.stockNum ? '/static/images/service-hsjh.png':'/static/images/service-ehsjh.png'}}" data-goods-id="{{item.id}}" data-item-index="{{index}}" data-product-id="{{item.product_id}}" catchtap="{{item.number < item.stockNum ?  'addNumber' : ''}}"></image>
+                    <image wx:if="{{item.isStockShare==1}}" class="add2" src="{{item.number < item.goodsNumber ? '/static/images/service-hsjh.png':'/static/images/service-ehsjh.png'}}" data-goods-id="{{item.id}}" data-item-index="{{index}}" data-product-id="{{item.product_id}}" catchtap="{{item.number < item.goodsNumber ?  'addNumber' : ''}}"></image>
+                    <image wx:if="{{item.isStockShare==0}}" class="add2" src="{{item.number < item.stockNum ? '/static/images/service-hsjh.png':'/static/images/service-ehsjh.png'}}" data-goods-id="{{item.id}}" data-item-index="{{index}}" data-product-id="{{item.product_id}}" catchtap="{{item.number < item.stockNum ?  'addNumber' : ''}}"></image>
                     
                   </view>
                 </view>
@@ -263,6 +263,7 @@
                   <view class="c">
                     <view class="p">价格:¥{{goodsVo.retail_price}}</view>
                     <view class="a" wx:if="{{productList.length>0}}">已选择:{{checkedSpecText}}</view>
+                    <view class="a">库存{{goodsVo.goodsBizType==00 && goodsVo.isStockShare==1?goodsVo.goods_number:goodsVo.stockNum}}件</view>
                   </view>
                 </view>
               </view>

+ 1 - 1
wx-mall/pages/cart/cart.wxss

@@ -531,7 +531,7 @@ page {
 }
 
 .attr-pop .info {
-  float: left;
+  /* float: left; */
   height: 177rpx;
   display: flex;
   align-items: flex-start;

+ 79 - 14
wx-mall/pages/catalog/catalog.js

@@ -22,12 +22,14 @@ Page({
     filterDiscount: 0,// 0不限 1特价 2活动
     goodsBizType: app.globalData.appGoodsBizType,//业务类型
     page: 1,
-    size: 50,
+    size: 4,
     showNavList: false,
     footCart: {},
     referrer: 0,
     sourceKey: '',
-    openCoupon: false
+    openCoupon: false,
+    refresh: false,
+    hidden: false
   },
   toggleNav() {
     this.setData({
@@ -59,6 +61,9 @@ Page({
     });
   },
   getCatalog: function () {
+    wx.showLoading({
+      title: '加载中...',
+    })
     //CatalogList
     let that = this;
     util.request(api.CatalogList).then(function (res) {
@@ -85,7 +90,11 @@ Page({
           });
         }
       }
-      that.getCategoryData();
+
+      if (that.data.goodsList.length == 0) {
+        that.getCategoryData();
+      }
+      wx.hideLoading();
     });
     util.request(api.GoodsCount).then(function (res) {
       that.setData({
@@ -99,7 +108,9 @@ Page({
       .then(function (res) {
         that.setData({
           currentCategory: res.data.currentCategory,
-          brandList: res.data.brandList
+          brandList: res.data.brandList,
+          goodsList: [],
+          page: 1
         });
         // console.log(res.data.brandList);
         that.getGoodsList();
@@ -194,12 +205,15 @@ Page({
   //
   getCategoryData: function () {
     let that = this;
+    that.setData({
+      goodsList: []
+    });
     that.getGoodsList();
   },
   getGoodsList() {
-    wx.showLoading({
-      title: '加载中...',
-    });
+    // wx.showLoading({
+    //   title: '加载中...',
+    // });
     var that = this;
     if (that.data.currentCategory){
       util.request(api.CatalogProductList, {
@@ -213,11 +227,17 @@ Page({
       })
         .then(function (res) {
           if (res.errno === 0) {
+            let goodsList = that.data.goodsList.concat(res.data.data);
             that.setData({
-              goodsList: res.data.data,
-              filterCategory: res.data.filterCategory
+              goodsList: goodsList,
+              filterCategory: res.data.filterCategory,
+              refresh: true
             });
-            wx.hideLoading();
+            if(that.data.page == 4){
+              that.setData({refresh: true});
+            }else{
+              that.setData({hidden: true })
+            }
           }
         });
     }
@@ -302,28 +322,36 @@ Page({
     switch (currentId) {
       case 'defaultActivity':
         that.setData({
-          'goodsBizType': '00'
+          'goodsBizType': '00',
+          goodsList: [],
+          page: 1
         });
         app.globalData.appGoodsBizType = '00';
         this.getGoodsList();
         break;
       case 'discountActivity':
         that.setData({
-          'goodsBizType': '02'
+          'goodsBizType': '02',
+          goodsList: [],
+          page: 1
         });
         app.globalData.appGoodsBizType = '02';
         this.getGoodsList();
         break;
       case 'groupActivity':
         that.setData({
-          'goodsBizType': '10'
+          'goodsBizType': '10',
+          goodsList: [],
+          page: 1
         });
         app.globalData.appGoodsBizType = '10';
         this.getGoodsList();
         break;
       case 'ordActivity':
         that.setData({
-          'goodsBizType': '11'
+          'goodsBizType': '11',
+          goodsList: [],
+          page: 1
         });
         app.globalData.appGoodsBizType = '11';
         this.getGoodsList();
@@ -336,6 +364,8 @@ Page({
         this.setData({
           'currentSortType': 'sell',
           'currentSortOrder': tmpSortOrder,
+          goodsList: [],
+          page: 1
         });
         this.getGoodsList();
         break;
@@ -347,6 +377,8 @@ Page({
         this.setData({
           'currentSortType': 'price',
           'currentSortOrder': tmpSortOrder,
+          goodsList: [],
+          page: 1
         });
 
         this.getGoodsList();
@@ -356,6 +388,8 @@ Page({
         this.setData({
           'currentSortType': 'default',
           'currentSortOrder': 'desc',
+          goodsList: [],
+          page: 1
         });
         this.getGoodsList();
     }
@@ -423,5 +457,36 @@ Page({
     wx.navigateTo({
       url: '/pages/categoryBrand/categoryBrand?brandId=' + replyType + '&&goodsBizType=' + that.data.goodsBizType + '&&currentIndex=' + currentIndex
     })
+  },
+  // onReachBottom() {
+  //   var that = this;
+  //   wx.showLoading({
+  //     title: '加载中...',
+  //   })
+  //   that.setData({
+  //     page: that.data.page + 1
+  //   });
+  //   if(that.data.page > that.data.total){
+  //     that.setData({
+  //       hidden: false
+  //     });
+  //   }
+  //   that.getGoodsList();
+  // },
+  onLoaderMoreMovies: function () {
+    var that = this;
+    wx.showNavigationBarLoading();
+    if (that.data.goodsList.length > 0) {
+      wx.showLoading({
+        title: '加载中...',
+      });
+      that.setData({
+        page: that.data.page + 1
+      });
+    }
+    console.log('加载');
+    that.getGoodsList();
+    wx.hideNavigationBarLoading()
   }
+
 })

+ 4 - 1
wx-mall/pages/catalog/catalog.json

@@ -1,3 +1,6 @@
 {
-  "navigationBarTitleText": "分类"
+  "navigationBarTitleText": "分类",
+  "enablePullDownRefresh": true,
+  "backgroundColor": "#f0145a",
+  "onReachBottomDistance": 50
 }

+ 27 - 24
wx-mall/pages/catalog/catalog.wxml

@@ -79,7 +79,7 @@
           </button>
       </view> -->
     </scroll-view>
-    <scroll-view class="cate" scroll-y="true">
+    <scroll-view class="cate" scroll-y="true" bindscrolltolower='onLoaderMoreMovies'>
       <navigator url="url" class="banner">
         <image class="image" wx:if="{{currentCategory.wap_banner_url}}" src="{{currentCategory.wap_banner_url}}"></image>
         <view class="txt">{{currentCategory.front_name?currentCategory.front_name:""}}</view>
@@ -123,48 +123,51 @@
       </view>
       <view class="cate-item">
         <view wx:if="{{goodsList != null && goodsList.length == 0}}" class="item-text">未找到相关商品</view>
+
+        <!-- 商品开始 -->
         <view class="item" wx:for="{{goodsList}}" wx:for-index="index" wx:for-item="item" wx:key="{{item.id}}">
           <navigator url="/pages/goods/goods?id={{item.id}}">
             <view class="left">
               <image class="img" wx:if="{{item.list_pic_url}}" src="{{item.list_pic_url}}"></image>
             </view>
           </navigator>
-
+          <!-- 文字开始 -->
           <view class="right">
             <view class="text">
-
-          <navigator url="/pages/goods/goods?id={{item.id}}">
-            <text class="name" bindtap="bindtapGoodsDetail" data-item-id="{{filterDiscount != 2?item.id:item.group_id}}">{{item.name?item.name:""}}</text>
-            <text class="desc" bindtap="bindtapGoodsDetail" data-item-id="{{filterDiscount != 2?item.id:item.group_id}}">{{item.goods_brief?item.goods_brief:""}}</text>
-          </navigator>
-
-
-          <view class="goods-do">
             <navigator url="/pages/goods/goods?id={{item.id}}">
-              <text class="price">{{item.retail_price?"¥"+item.retail_price:"¥0"}}</text>
-              <text class="org-price line-through">{{item.market_price?"¥"+item.market_price:""}}</text>
+              <text class="name" bindtap="bindtapGoodsDetail" data-item-id="{{filterDiscount != 2?item.id:item.group_id}}">{{item.name?item.name:""}}</text>
+              <text class="desc" bindtap="bindtapGoodsDetail" data-item-id="{{filterDiscount != 2?item.id:item.group_id}}">{{item.goods_brief?item.goods_brief:""}}</text>
             </navigator>
-            <!-- //数量加减 -->
-            <view class="number-item">
-                  <view class="selnum">
-                    <view class="cut" data-goods-id="{{item.id}}" data-product-id="{{item.product_id}}" bindtap="cutNumber"></view>
+
+            <!-- 描述开始 -->
+            <view class="goods-do">
+              <navigator url="/pages/goods/goods?id={{item.id}}">
+                <text class="price">{{item.retail_price?"¥"+item.retail_price:"¥0"}}</text>
+                <text class="org-price line-through">{{item.market_price?"¥"+item.market_price:""}}</text>
+              </navigator>
+              <!-- //数量加减 -->
+              <!-- <view class="number-item">
+                <view class="selnum">
+                  <view class="cut" data-goods-id="{{item.id}}" data-product-id="{{item.product_id}}" bindtap="cutNumber"></view>
                     <input value="{{item.cart_num}}" class="number" disabled="true" type="number" />
-                    <!-- <view class="add" data-goods-id="{{item.id}}" data-product-id="{{item.product_id}}" bindtap="addNumber"></view> -->
-                    <image class="add2" src="{{item.cart_num < item.stockNum ? '/static/images/service-hsjh.png':'/static/images/service-ehsjh.png'}}" data-goods-id="{{item.id}}" data-product-id="{{item.product_id}}"  catchtap="{{item.cart_num < item.stockNum ?  'addNumber' : ''}}"></image>
+                    <image wx:if="{{item.goodsBizType==11}}" class="add2" src="{{item.cart_num < item.stockNum ? '/static/images/service-hsjh.png':'/static/images/service-ehsjh.png'}}" data-goods-id="{{item.id}}" data-product-id="{{item.product_id}}"  catchtap="{{item.cart_num < item.stockNum ?  'addNumber' : ''}}"></image>
+                    <image wx:if="{{item.goodsBizType!=11}}" class="add2" src="{{item.cart_num < item.goods_number ? '/static/images/service-hsjh.png':'/static/images/service-ehsjh.png'}}" data-goods-id="{{item.id}}" data-product-id="{{item.product_id}}"  catchtap="{{item.cart_num < item.goods_number ?  'addNumber' : ''}}"></image>
                   </view>
-                </view>
+                </view> -->
               </view>
             </view>
-
+            <!-- 描述结束 -->
           </view>
-
+          <!-- 文字结束 -->
         </view>
+          <!-- 商品结束 -->
+        <view wx:if="{{hidden && goodsList != null && goodsList.length > 0}}" class="item-text">加载完成</view>
       </view>
     </scroll-view>
   </view>
 
   <view class="coupon" wx:if="{{openCoupon}}">
-     <view class="attr-close" bindtap="closeCoupon">X</view>
-      <image class="img" src="/static/imgys/coupon-gun.png" bindtap="takeShareCoupon"/>
-    </view>
+    <view class="attr-close" bindtap="closeCoupon">X</view>
+    <image class="img" src="/static/imgys/coupon-gun.png" bindtap="takeShareCoupon"/>
+  </view>
 </view>

+ 1 - 1
wx-mall/pages/catalog/catalog.wxss

@@ -252,7 +252,7 @@ page {
   overflow: hidden;
   border-top: 1rpx solid #f4f4f4;
   margin-top: 20rpx;
-  margin-bottom: 100rpx;
+  margin-bottom: 200rpx;
 }
 
 .cate-item .item {

+ 87 - 57
wx-mall/pages/category/category.js

@@ -16,14 +16,16 @@ Page({
     scrollTop: 0,
     scrollHeight: 0,
     page: 1,
-    size: 10,
+    size: 4,
     showNavList: false,
     footCart: {},
     openAttr: false,
     productList: {},
     specificationList: {},
     checkedSpecText: '请选择规格数量',
-    number: 1
+    number: 1,
+    stockNum: 0,
+    cartNumber: 0,
   },
   toggleNav() {
     this.setData({
@@ -158,17 +160,22 @@ Page({
           //显示错误信息
         }
       });
-    },
-    onReady: function () {
-        // 页面渲染完成
-    },
-    onShow: function () {
-        // 页面显示
-        this.getFootCart();
-    },
-    onHide: function () {
-        // 页面隐藏
-    },
+  },
+  onReady: function () {
+    // 页面渲染完成
+  },
+  onShow: function () {
+    // 页面显示
+    this.getFootCart();
+  },
+  onHide: function () {
+    // 页面隐藏
+  },
+  hideSwitchAttrPop: function () {
+    this.setData({
+      openAttr: false
+    })
+  },
   getGoodsList: function () {
     var that = this;
     wx.showLoading({
@@ -194,31 +201,46 @@ Page({
     ,
     //购物车增加
     addCart: function (e) {
-        let that = this;
-        var goodsId = e.currentTarget.dataset.goodsId;
-        util.request(api.GoodsSku, {goodsId: goodsId}).then(function (res) {
-            if (res.errno === 0 && null != res.data) {
-                that.setData({
-                    goodsVo: res.data.goodsVo,
-                    specificationList: res.data.specificationList,
-                    productList: res.data.productList,
-                    openAttr: !that.data.openAttr,
-                    checkedSpecText: res.data.specificationList[0].valueList[0].value
-                });
-                //
-                let _specificationList = res.data.specificationList;
-                for (let i = 0; i < _specificationList.length; i++) {
-                    if (_specificationList[i].valueList.length == 1) {
-                        //如果已经选中,则反选
-                        _specificationList[i].valueList[0].checked = true;
-                    }
-                }
-                that.setData({
-                    'specificationList': _specificationList
-                });
-
+      let that = this;
+      that.setData({
+        number: 1
+      });
+      var goodsId = e.currentTarget.dataset.goodsId;
+      util.request(api.GoodsSku, { goodsId: goodsId }).then(function (res) {
+        if (res.errno === 0 && null != res.data) {
+          let stockNumbers = 0;
+          if (res.data.goodsVo.goodsBizType == '00') {
+            if (res.data.goodsVo.isStockShare == 1) {
+              stockNumbers = res.data.goodsVo.goods_number;
+            } else {
+              stockNumbers = res.data.goodsVo.stockNum;
             }
-        });
+          } else {
+            stockNumbers = res.data.goodsVo.stockNum;
+          }
+          that.setData({
+            goodsVo: res.data.goodsVo,
+            specificationList: res.data.specificationList,
+            productList: res.data.productList,
+            stockNum: stockNumbers,
+            openAttr: !that.data.openAttr,
+            cartNumber: res.data.cartNumber,
+            checkedSpecText: res.data.specificationList[0].valueList[0].value
+          });
+          //
+          let _specificationList = res.data.specificationList;
+          for (let i = 0; i < _specificationList.length; i++) {
+            if (_specificationList[i].valueList.length == 1) {
+              //如果已经选中,则反选
+              _specificationList[i].valueList[0].checked = true;
+            }
+          }
+          that.setData({
+            'specificationList': _specificationList
+          });
+
+        }
+      });
     }
     ,
     clickSkuValue: function (event) {
@@ -280,26 +302,29 @@ Page({
         if (checkedProduct.stock_num < this.data.number) {
             //找不到对应的product信息,提示没有库存
             return false;
+      }
+      util.request(api.CartAdd, {
+        goodsId: goodsId,
+        productId: checkedProduct[0].id,
+        number: this.data.number
+      }, 'POST').then(function (res) {
+        if (res.errno === 0 && null != res.data) {
+          wx.showToast({
+            title: '添加成功',
+            icon: 'success',
+            mask: true
+          });
+          that.setData({
+            openAttr: !that.data.openAttr
+          })
+          that.getFootCart();
+        } else {
+          wx.showToast({
+            title: res.errmsg,
+            icon: 'none'
+          })
         }
-        util.request(api.CartAdd, {
-            goodsId: goodsId,
-            productId: checkedProduct[0].id,
-            number: this.data.number
-        }, 'POST').then(function (res) {
-            if (res.errno === 0 && null != res.data) {
-                wx.showToast({
-                    title: '添加成功',
-                    icon: 'success',
-                    mask: true
-                });
-                that.setData({
-                    openAttr: !that.data.openAttr
-                })
-                that.getFootCart();
-            } else {
-                util.showErrorToast(res.errmsg)
-            }
-        });
+      });
     },
   switchCate: function (event) {
     console.log(this.data.scrollLeft);
@@ -332,8 +357,13 @@ Page({
   },
   onReachBottom() {
     var that = this;
+    if (!that.data.goodsList) {
+      wx.showLoading({
+        title: '加载中...',
+      })
+    }
     that.setData({
-      page: that.data.page + 1,
+      page: that.data.page + 1
     });
     that.getGoodsList();
   }

+ 3 - 2
wx-mall/pages/category/category.json

@@ -1,4 +1,5 @@
 {
-  "onReachBottomDistance": 450,
-  "navigationBarTitleText": "分类"
+  "onReachBottomDistance": 50,
+  "navigationBarTitleText": "分类",
+  "enablePullDownRefresh": true
 }

+ 26 - 5
wx-mall/pages/category/category.wxml

@@ -1,5 +1,5 @@
 <view class="container">
-  <view class="cart-panel" wx:if="{{footCart.goodsCount>0}}">
+  <view class="cart-panel" wx:if="{{footCart.goodsCount>0}}" bindtap="hideSwitchAttrPop">
     <view class="cart-icon">
       <navigator class="nav-cell" open-type='switchTab' url="/pages/cart/cart">
         <image src="../../static/images/cart-fixed.png">
@@ -49,15 +49,34 @@
     </view>
     <view wx:if="{{showNavList}}" class="close" bindtap="toggleNav">X</view>
   </view>
-  <view class="cate-nav">
+  <view class="cate-nav" bindtap="hideSwitchAttrPop">
     <scroll-view scroll-x="true" class="cate-nav-body" style="width: 750rpx;" scroll-left="{{scrollLeft}}" >
       <view wx:for="{{navList}}" class="item {{ id == item.id ? 'active' : ''}}" data-current="{{index}}" data-id="{{item.id}}" bindtap="switchCate" wx:key="{{index}}">
         <view class="name">{{item.name}}</view>
       </view>
     </scroll-view>
   </view>
+  <scroll-view scroll-y="true" class="cate-item" bindtap="hideSwitchAttrPop">
+    <view class="h">
+      <text class="name">{{currentCategory.name}}</text>
+      <text class="desc">{{currentCategory.front_name?currentCategory.front_name:""}}</text>
+    </view>
+    <view class="b">
+      <block wx:for="{{goodsList}}" wx:for-index="iindex" wx:for-item="iitem" wx:key="unique">
+        <view class="item {{iindex % 2 == 0 ? 'item-b' : '' }}">
+         <navigator url="../goods/goods?id={{iitem.id}}&&currentIndex={{navIndex}}">
+            <image class="img" src="{{iitem.list_pic_url}}"></image>
+            <text class="name">{{iitem.name}}</text>
+          </navigator>
+          <view class="price">¥{{iitem.retail_price == null?'':iitem.retail_price}}
+            <image class="cart" src="/static/images/cart.png" data-goods-id="{{iitem.id}}" data-product-id="{{iitem.product_id}}" bindtap='addCart' background-size="cover"></image>
+          </view>
+        </view>
+      </block>
+    </view>
+  </scroll-view>
   <!-- bindchange="switchTab" -->
-  <swiper class="" current="{{currentTab}}" scroll-top="{{scrollTop}}" style="height:{{scrollHeight}}px;">
+  <!-- <swiper class="" current="{{currentTab}}" scroll-top="{{scrollTop}}" style="height:{{scrollHeight}}px;">
     <swiper-item wx:for="{{navList}}"  wx:key="{{navIndex}}">
       <scroll-view scroll-y="true" class="cate-item">
         <view class="h">
@@ -81,7 +100,7 @@
         </view>
       </scroll-view>
     </swiper-item>
-  </swiper>
+  </swiper> -->
 
    <view wx:if="{{openAttr}}" class="attr-pop">
           <view class="attr-close" bindtap="switchAttrPop">X</view>
@@ -91,6 +110,7 @@
               <view class="c">
                 <view class="p">价格:¥{{goodsVo.retail_price}}</view>
                 <view class="a" wx:if="{{productList.length>0}}">已选择:{{checkedSpecText}}</view>
+                <view class="a">库存{{goodsVo.goodsBizType==00 && goodsVo.isStockShare==1?goodsVo.goods_number:goodsVo.stockNum}}件</view>
               </view>
             </view>
           </view>
@@ -107,7 +127,8 @@
               <view class="selnum">
                 <view class="cut" bindtap="cutNumber">-</view>
                 <input value="{{number}}" class="number" disabled="true" type="number" />
-                <view class="add" bindtap="addNumber">+</view>
+                <!-- <view class="add" bindtap="addNumber">+</view> -->
+                <view class="{{number+cartNumber>= stockNum? 'addEnabel':'add'}}" bindtap="{{number+cartNumber>= stockNum ? '':'addNumber'}}">+</view>
               </view>
             </view>
           </view>

+ 10 - 2
wx-mall/pages/category/category.wxss

@@ -83,7 +83,8 @@ color: transparent;
   padding: 0 6.25rpx;
   height: auto;
   overflow: hidden;
-  margin-bottom: 400rpx;
+  /* margin-bottom: 400rpx; */
+  margin-bottom: 250rpx;
 }
 
 .cate-item .b .item{
@@ -170,7 +171,7 @@ color: transparent;
 }
 
 .attr-pop .info {
-  float: left;
+  /* float: left; */
   height: 177rpx;
   display: flex;
   align-items: flex-start;
@@ -288,4 +289,11 @@ color: transparent;
   flex: 1;
   text-align: center;
   color: #fff;
+}
+.addEnabel {
+  width: 93.75rpx;
+  height: 100%;
+  text-align: center;
+  line-height: 65rpx;
+  color: #ccc;
 }

+ 39 - 16
wx-mall/pages/goods/goods.js

@@ -40,7 +40,10 @@ Page({
     startX:0,
     curr_id: '',
     videoHiddenName: true,
-    imgHiddenName: false
+    imgHiddenName: false,
+    page: 1,
+    size: 4,
+    detailContent: ''
   },
   toggleNav() {
     this.setData({
@@ -53,11 +56,20 @@ Page({
       url: `/pages/${name}/${name}`,
     });
   },
+  //小程序里的转义方法
+  escape2Html: function (str) {
+    var arrEntities = { 'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"' };
+    return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) { return arrEntities[t]; });
+  },
+//调用在需要的地方直接调用即可。如:this.escape2Html(contents)
   getGoodsInfo: function () {
     wx.showLoading({
       title: '加载中...',
     });
+    setTimeout(function () {
+    }, 350)
     let that = this;
+    const regex = new RegExp('<img', 'gi');
     util.request(api.GoodsDetail, { id: that.data.id, referrer: this.data.referrer, 
       merchSn: wx.getStorageSync('merchSn') }).then(function (res) {
       if (res.errno === 0) {
@@ -74,7 +86,8 @@ Page({
           stockNum: res.data.stockNum,
           cartNumber: res.data.cartNumber,
           defaultFreight: res.data.defaultFreight,
-          checkedSpecText: res.data.specificationList[0].valueList[0].value
+          checkedSpecText: res.data.specificationList[0].valueList[0].value,
+          detailContent: that.escape2Html(res.data.info.goods_desc).replace(regex, `<img style="width: 100%;"`)
         });
 
         if (res.data.userHasCollect == 1) {
@@ -87,7 +100,7 @@ Page({
           });
         }
 
-        WxParse.wxParse('goodsDetail', 'html', res.data.info.goods_desc, that);
+        // WxParse.wxParse('goodsDetail', 'html', res.data.info.goods_desc, that);
 
         that.getGoodsRelated();
 
@@ -138,18 +151,6 @@ Page({
       }
     });
   },
-
-  getGoodsRelated: function () {
-    let that = this;
-    util.request(api.GoodsRelated, { id: that.data.id }).then(function (res) {
-      if (res.errno === 0) {
-        that.setData({
-          relatedGoods: res.data.goodsList,
-        });
-      }
-    });
-
-  },
   clickSkuValue: function (event) {
     let that = this;
     let specNameId = event.currentTarget.dataset.nameId;
@@ -387,9 +388,9 @@ Page({
         //找不到对应的product信息,提示没有库存
         return false;
       }
-
       // //根据选中的规格,判断是否有对应的sku信息
       let checkedProduct = goodsUtil.getCheckedProductItem(goodsUtil.getCheckedSpecKey(that), that);
+      console.log(checkedProduct)
       if (!checkedProduct || checkedProduct.length <= 0) {
         wx.showToast({
           title: '库存不足',
@@ -574,5 +575,27 @@ Page({
       videoHiddenName: true
     })
     this.videoContext.pause();
+  },
+  getGoodsRelated: function () {
+    let that = this;
+    util.request(api.GoodsRelated, { id: that.data.id, page: that.data.page, size: that.data.size }).then(function (res) {
+      if (res.errno === 0) {
+        let goodsList = that.data.relatedGoods.concat(res.data.goodsList);
+        that.setData({
+          relatedGoods: goodsList,
+        });
+      }
+    });
+
+  },
+  onReachBottom() {
+    var that = this;
+    wx.showLoading({
+      title: '加载中...',
+    })
+    that.setData({
+      page: that.data.page + 1
+    });
+    that.getGoodsRelated();
   }
 })

+ 6 - 3
wx-mall/pages/goods/goods.wxml

@@ -206,8 +206,11 @@
     </view>
     <view class="detail"  bindtap="hideSwitchAttrPop">
       <view class="t">商品详情</view>
-      <import src="../../lib/wxParse/wxParse.wxml"/>
-      <template is="wxParse" data="{{wxParseData:goodsDetail.nodes}}" />
+      <view style="margin-left: 20rpx;" x:if="{{detailContent != ''}}">
+        <rich-text nodes="{{detailContent}}"></rich-text>
+      </view>
+      <!-- <import src="../../lib/wxParse/wxParse.wxml"/>
+      <template is="wxParse" data="{{wxParseData:goodsDetail.nodes}}" /></view> -->
     </view>
 
 
@@ -251,7 +254,7 @@
   <view wx:if="{{openAttr}}" class="attr-pop">
     <view class="attr-close" bindtap="switchAttrPop">X</view>
     <view class="img-info">
-      <image class="img" src="{{goods.list_pic_url}}"></image>
+      <view><image class="img" src="{{goods.list_pic_url}}"></image></view>
       <view class="info">
         <view class="c">
           <view class="p">价格:¥{{goods.retail_price}}</view>

+ 1 - 1
wx-mall/pages/goods/goods.wxss

@@ -897,7 +897,7 @@
 }
 
 .attr-pop .info {
-  float: left;
+  /* float: left; */
   height: 177rpx;
   display: flex;
   align-items: center;

+ 40 - 9
wx-mall/pages/hotGoods/hotGoods.js

@@ -13,10 +13,10 @@ Page({
     filterCategory: [],
     goodsList: [],
     categoryId: 0,
-    currentSortType: 'default',
-    currentSortOrder: 'desc',
+    currentSortType: 'desc',
+    currentSortOrder: 'a.create_time',
     page: 1,
-    size: 1000,
+    size: 4,
     showNavList: false,
     footCart: {},
     openAttr: false,
@@ -27,6 +27,7 @@ Page({
     retailPrice: '',
     stockNum: 0,
     cartNumber: 0,
+    totalPages: 0
   },
   toggleNav() {
     this.setData({
@@ -36,9 +37,11 @@ Page({
   getData: function () {
     let that = this;
     util.request(api.GoodsHot).then(function (res) {
-      if (res.errno === 0) {
+      if (res.errno == 0) {
         that.setData({
           bannerInfo: res.data.bannerInfo,
+          goodsList: [],
+          page: 1
         });
         that.getGoodsList();
       }
@@ -53,9 +56,11 @@ Page({
     util.request(api.HotGoodsList, { isHot: 1, page: that.data.page, size: that.data.size, order: that.data.currentSortOrder, sort: that.data.currentSortType, categoryId: that.data.categoryId})
       .then(function (res) {
         if (res.errno === 0) {
+          let goodsList = that.data.goodsList.concat(res.data.goodsList);
           that.setData({
-            goodsList: res.data.goodsList,
-            filterCategory: res.data.filterCategory
+            goodsList: goodsList,
+            filterCategory: res.data.filterCategory,
+            totalPages: 0
           });
           wx.hideLoading();
           if(that.data.categoryId>0){
@@ -118,7 +123,9 @@ Page({
         this.setData({
           'currentSortType': 'price',
           'currentSortOrder': tmpSortOrder,
-          'categoryFilter': false
+          'categoryFilter': false,
+          goodsList: [],
+          page: 1
         });
 
         this.getData();
@@ -128,7 +135,9 @@ Page({
         this.setData({
           'currentSortType': 'default',
           'currentSortOrder': 'desc',
-          'categoryFilter': false
+          'categoryFilter': false,
+          goodsList: [],
+          page: 1
         });
         this.getData();
     }
@@ -174,13 +183,23 @@ Page({
       goodsId: goodsId
     }).then(function (res) {
       if (res.errno === 0 && null != res.data) {
+        let stockNumbers = 0;
+        if (res.data.goodsVo.goodsBizType == '00') {
+          if (res.data.goodsVo.isStockShare == 1) {
+            stockNumbers = res.data.goodsVo.goods_number;
+          } else {
+            stockNumbers = res.data.goodsVo.stockNum;
+          }
+        } else {
+          stockNumbers = res.data.goodsVo.stockNum;
+        }
         that.setData({
           goodsVo: res.data.goodsVo,
           specificationList: res.data.specificationList,
           productList: res.data.productList,
           openAttr: !that.data.openAttr,
           retailPrice: retailPrice,
-          stockNum: res.data.productList[0].stock_num,
+          stockNum: stockNumbers,
           cartNumber: res.data.cartNumber,
           checkedSpecText: res.data.specificationList[0].valueList[0].value
         });
@@ -279,4 +298,16 @@ Page({
       }
     });
   },
+  onReachBottom() {
+    var that = this;
+    if (!that.data.goodsList) {
+      wx.showLoading({
+        title: '加载中...',
+      })
+    }
+    that.setData({
+      page: that.data.page + 1,
+    });
+    that.getGoodsList();
+  }
 })

+ 1 - 0
wx-mall/pages/hotGoods/hotGoods.wxml

@@ -102,6 +102,7 @@
         <view class="c">
           <view class="p">价格:¥{{retailPrice}}</view>
           <view class="a" wx:if="{{productList.length>0}}">已选择:{{checkedSpecText}}</view>
+          <view class="a">库存{{goodsVo.goodsBizType==00 && goodsVo.isStockShare==1?goodsVo.goods_number:goodsVo.stockNum}}件</view>
         </view>
       </view>
     </view>

+ 1 - 1
wx-mall/pages/hotGoods/hotGoods.wxss

@@ -221,7 +221,7 @@ page{
 }
 
 .attr-pop .info {
-  float: left;
+  /* float: left; */
   height: 177rpx;
   display: flex;
   align-items: flex-start;

+ 125 - 22
wx-mall/pages/index/index.js

@@ -17,7 +17,11 @@ Page({
     storeName: '',
     showPop: false,//活动弹窗
     couponVo: {},
-    storeId: ''
+    storeId: '',
+    page: 1,
+    size: 3,
+    list: [],
+    openAttr: false,
   },
   showCouponPop() {
     let that = this;
@@ -42,13 +46,18 @@ Page({
     }
   },
   getIndexData: function () {
+    setTimeout(function () {
+    }, 350)
+    wx.showLoading({
+      title: '加载中...',
+    })
     let that = this;
     util.request(api.IndexUrl).then(function (res) {
       if (res.errno === 0) {
         // console.log(res.data.banner);
         that.setData({
           // newGoods: res.data.newGoodsList,
-          hotGoods: res.data.hotGoodsList,
+          // hotGoods: res.data.hotGoodsList,
           // topics: res.data.topicList,
           // brand: res.data.brandList,
           // floorGoods: res.data.categoryList,
@@ -56,6 +65,28 @@ Page({
           // groupBanner: res.data.groupBanner,
           channel: res.data.channel
         });
+        if (that.data.hotGoods.length==0){
+          that.getGoodsList();
+        }
+      }
+      wx.hideLoading();
+    });
+  },
+  getGoodsList: function(){
+    let that = this;
+    util.request(api.GoodsHot).then(function (res) {
+      if (res.errno == 0) {
+        util.request(api.HotGoodsList, { isHot: 1, page: that.data.page, size: that.data.size, categoryId: 0 })
+          .then(function (res) {
+            if (res.errno == 0) {
+              let goodsList = that.data.hotGoods.concat(res.data.goodsList);
+              that.setData({
+                hotGoods: goodsList,
+                list: res.data.goodsList
+              });
+            }
+          });
+        wx.hideLoading();
       }
     });
   },
@@ -120,7 +151,7 @@ Page({
     // console.log('dataset.goodsBizType:' + e.currentTarget.dataset.goodsBizType);
     app.globalData.appGoodsBizType = e.currentTarget.dataset.goodsBizType;
     // console.log('appgoodsBizType1:' + app.globalData.appGoodsBizType);
-    
+
     wx.switchTab({
       url: '/pages/catalog/catalog',
     });
@@ -139,11 +170,11 @@ Page({
   },
   reLoad: function () {
     let that = this;
-      // console.log(wx.getStorageSync('userId'));
-      // console.log(wx.getStorageSync('storeId'));
-      // console.log(wx.getStorageSync('merchSn'));
+    // console.log(wx.getStorageSync('userId'));
+    // console.log(wx.getStorageSync('storeId'));
+    // console.log(wx.getStorageSync('merchSn'));
     if (wx.getStorageSync('storeId')) {
-      if (wx.getStorageSync('userId')){
+      if (wx.getStorageSync('userId')) {
         wx.request({
           url: api.updateLoginUser,
           data: {
@@ -215,10 +246,10 @@ Page({
         }
       })
     });
-    
+
   },
   // 更新门店Id
-  chooseStore: function (storeId,merchSn) {
+  chooseStore: function (storeId, merchSn) {
     let that = this;
     util.request(api.ChooseStoreId, { storeId: storeId, merchSn: merchSn }, 'POST').then(function (res) {
       if (res.errno === 0) {
@@ -342,7 +373,7 @@ Page({
           // var goodId = that.value.substring(18, that.value.length);
           var scanArray = that.value.split('&');
           // console.log(scanArray.length);
-          if (scanArray.length < 2){
+          if (scanArray.length < 2) {
             wx.showModal({
               title: '',
               content: '您所扫描的商品无效',
@@ -375,21 +406,23 @@ Page({
               content: '该商品不属于当前门店',
               showCancel: false
             });
-            return;         
+            return;
           }
           util.request(api.GoodsDetail, { id: goodId, referrer: '' }).then(function (res) {
             if (res.errno === 0) {
               console.log(res);
               // 跳转页面
-              wx.navigateTo({
-                url: that.value,
-                success: function (e) {
-                  console.log('跳转成功');
-                },
-                fail: function (e) {
-                  console.log('跳转失败');
-                }
-              })
+              setTimeout(function () {
+                wx.navigateTo({
+                  url: that.value,
+                  success: function (e) {
+                    console.log('跳转成功');
+                  },
+                  fail: function (e) {
+                    console.log('跳转失败');
+                  }
+                })
+              }, 350)
             } else {
               wx.showModal({
                 title: '扫描结果',
@@ -398,7 +431,7 @@ Page({
               });
             }
           });
-        }else{//其他码
+        } else {//其他码
           //弹框显示结果
           wx.showModal({
             title: '扫描结果',
@@ -418,7 +451,7 @@ Page({
       }
 
     })
-  }, 
+  },
   imgOnLoad: function (e) {
     let that = this;
     // console.log('图片加载完成');
@@ -433,11 +466,81 @@ Page({
     //   })
     // }
   },
+  switchAttrPop: function () {
+    this.setData({
+      openAttr: !this.data.openAttr
+    })
+  },
+  hideSwitchAttrPop: function () {
+    this.setData({
+      openAttr: false
+    })
+  },
+  //购物车增加
+  addCart: function (e) {
+    let that = this;
+    that.setData({
+      number: 1
+    });
+    var goodsId = e.currentTarget.dataset.goodsId;
+    var retailPrice = e.currentTarget.dataset.retailPrice;
+    util.request(api.GoodsSku, {
+      goodsId: goodsId
+    }).then(function (res) {
+      if (res.errno === 0 && null != res.data) {
+        let stockNumbers = 0;
+        if (res.data.goodsVo.goodsBizType == '00') {
+          if (res.data.goodsVo.isStockShare == 1) {
+            stockNumbers = res.data.goodsVo.goods_number;
+          } else {
+            stockNumbers = res.data.goodsVo.stockNum;
+          }
+        } else {
+          stockNumbers = res.data.goodsVo.stockNum;
+        }
+        that.setData({
+          goodsVo: res.data.goodsVo,
+          specificationList: res.data.specificationList,
+          productList: res.data.productList,
+          openAttr: !that.data.openAttr,
+          retailPrice: retailPrice,
+          stockNum: stockNumbers,
+          cartNumber: res.data.cartNumber,
+          checkedSpecText: res.data.specificationList[0].valueList[0].value
+        });
+        //
+        let _specificationList = res.data.specificationList;
+        for (let i = 0; i < _specificationList.length; i++) {
+          if (_specificationList[i].valueList.length == 1) {
+            //如果已经选中,则反选
+            _specificationList[i].valueList[0].checked = true;
+          }
+        }
+        that.setData({
+          'specificationList': _specificationList
+        });
+
+      }
+    });
+  },
 
   shows: function (e) {
 
     wx.redirectTo({
       url: '/pages/images/images'
     })
+  },
+  onReachBottom() {
+    var that = this; 
+    if (that.data.list.length > 0) {
+      console.log(that.data.list)
+      wx.showLoading({
+        title: '加载中...',
+      })
+    }
+    that.setData({
+      page: that.data.page + 1
+    });
+    that.getGoodsList();
   }
 })

+ 9 - 3
wx-mall/pages/index/index.wxml

@@ -30,9 +30,11 @@
 
   <swiper class="banner" indicator-dots="true" autoplay="true" interval="15000" duration="750">
     <swiper-item wx:for="{{banner}}" wx:key="{{item.id}}">
+    <scroll-view class='contents fade_in}}'>
       <navigator url="{{item.link}}">
-        <image class="swiper-item" src="{{item.imageUrl}}" bindload="imgOnLoad"  mode="aspectFill" background-size="cover"></image>
+        <image lazy-load="true" class="swiper-item" src="{{item.imageUrl}}" bindload="imgOnLoad"  mode="aspectFill" background-size="cover"></image>
       </navigator>
+    </scroll-view>
     </swiper-item>
   </swiper>
   <view class="m-menu">
@@ -56,6 +58,10 @@
       <image src="../../static/images/service-smgw.png" background-size="cover"></image>
       <text>扫码购物</text>
     </navigator>
+    <!-- <navigator class="itemb" bindtap="shows">
+      <image src="../../static/images/service-smgw.png" background-size="cover"></image>
+      <text>图片</text>
+    </navigator> -->
 
   </view>
   <!-- <view class="m-menu">
@@ -175,13 +181,13 @@
               <text class="price">{{item.retail_price?"¥"+item.retail_price:"0"}}</text>
               <text class="org-price line-through">{{item.market_price?"¥"+item.market_price:""}}</text>
               <!-- //数量加减 -->
-              <view class="number-item">
+              <!-- <view class="number-item">
                 <view class="selnum">
                   <view class="cut" data-goods-id="{{item.id}}" data-product-id="{{item.product_id}}" bindtap="cutNumber"></view>
                   <input value="{{item.cart_num}}" class="number" disabled="true" type="number" />
                   <view class="add" data-goods-id="{{item.id}}" data-product-id="{{item.product_id}}" bindtap="addNumber"></view>
                 </view>
-              </view>
+              </view> -->
             </view>
           </view>
         </view>

+ 200 - 179
wx-mall/pages/search/search.js

@@ -3,203 +3,224 @@ var api = require('../../config/api.js');
 
 var app = getApp()
 Page({
-    data: {
-        keywrod: '',
-        searchStatus: false,
-        goodsList: [],
-        helpKeyword: [],
-        historyKeyword: [],
-        categoryFilter: false,
-        filterCategory: [],
-        defaultKeyword: {},
-        hotKeyword: [],
-        page: 1,
-        size: 1000,
-        currentSortType: 'id',
-        currentSortOrder: 'desc',
-        categoryId: 0,
-        showNavList: false,
-        footCart: {}
-    },
-    toggleNav() {
-        this.setData({
-            showNavList: !this.data.showNavList
-        })
-    },
-    switchNav(event) {
-        let name = event.currentTarget.dataset.name;
-        wx.switchTab({
-            url: `/pages/${name}/${name}`,
-        });
-    },
-    //事件处理函数
-    closeSearch: function () {
-        wx.navigateBack()
-    },
-    clearKeyword: function () {
-        this.setData({
-            keyword: '',
-            searchStatus: false
-        });
-    },
-    onLoad: function () {
-        this.getSearchKeyword();
-        this.getFootCart();
-    },
+  data: {
+    keywrod: '',
+    searchStatus: false,
+    goodsList: [],
+    helpKeyword: [],
+    historyKeyword: [],
+    categoryFilter: false,
+    filterCategory: [],
+    defaultKeyword: {},
+    hotKeyword: [],
+    page: 1,
+    size: 1000,
+    currentSortType: 'id',
+    currentSortOrder: 'desc',
+    categoryId: 0,
+    showNavList: false,
+    footCart: {},
+    page: 1,
+    size: 6
+  },
+  toggleNav() {
+    this.setData({
+      showNavList: !this.data.showNavList
+    })
+  },
+  switchNav(event) {
+    let name = event.currentTarget.dataset.name;
+    wx.switchTab({
+      url: `/pages/${name}/${name}`,
+    });
+  },
+  //事件处理函数
+  closeSearch: function () {
+    wx.navigateBack()
+  },
+  clearKeyword: function () {
+    this.setData({
+      keyword: '',
+      searchStatus: false
+    });
+  },
+  onLoad: function () {
+    this.getSearchKeyword();
+    this.getFootCart();
+  },
 
-    getFootCart: function () {
-        let that = this;
-        util.request(api.GetFootCart).then(function (res) {
-            if (res.errno === 0) {
-                that.setData({
-                    footCart: res.data,
-                });
-            }
+  getFootCart: function () {
+    let that = this;
+    util.request(api.GetFootCart).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          footCart: res.data,
         });
-    },
-    getSearchKeyword() {
-        let that = this;
-        util.request(api.SearchIndex).then(function (res) {
-            if (res.errno === 0) {
-                that.setData({
-                    historyKeyword: res.data.historyKeywordList,
-                    defaultKeyword: res.data.defaultKeyword,
-                    hotKeyword: res.data.hotKeywordList
-                });
-            }
+      }
+    });
+  },
+  getSearchKeyword() {
+    let that = this;
+    util.request(api.SearchIndex).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          historyKeyword: res.data.historyKeywordList,
+          defaultKeyword: res.data.defaultKeyword,
+          hotKeyword: res.data.hotKeywordList
         });
-    },
+      }
+    });
+  },
 
-    inputChange: function (e) {
+  inputChange: function (e) {
 
-        this.setData({
-            keyword: e.detail.value,
-            searchStatus: false
-        });
-        this.getHelpKeyword();
-    },
-    getHelpKeyword: function () {
-        let that = this;
-        util.request(api.SearchHelper, { keyword: that.data.keyword }).then(function (res) {
-            if (res.errno === 0) {
-                that.setData({
-                    helpKeyword: res.data
-                });
-            }
-        });
-    },
-    inputFocus: function () {
-        this.setData({
-            searchStatus: false,
-            goodsList: []
+    this.setData({
+      keyword: e.detail.value,
+      searchStatus: false
+    });
+    this.getHelpKeyword();
+  },
+  getHelpKeyword: function () {
+    let that = this;
+    util.request(api.SearchHelper, { keyword: that.data.keyword }).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          helpKeyword: res.data
         });
+      }
+    });
+  },
+  inputFocus: function () {
+    this.setData({
+      searchStatus: false,
+      goodsList: []
+    });
 
-        if (this.data.keyword) {
-            this.getHelpKeyword();
-        }
-    },
-    clearHistory: function () {
-        this.setData({
-            historyKeyword: []
-        })
+    if (this.data.keyword) {
+      this.getHelpKeyword();
+    }
+  },
+  clearHistory: function () {
+    this.setData({
+      historyKeyword: []
+    })
 
-        util.request(api.SearchClearHistory, {}, 'POST')
-            .then(function (res) {
-                console.log('清除成功');
-            });
-    },
-    getGoodsList: function () {
-      let that = this;
-      wx.showLoading({
-        title: '加载中...',
+    util.request(api.SearchClearHistory, {}, 'POST')
+      .then(function (res) {
+        console.log('清除成功');
       });
-        util.request(api.GoodsList, { keyword: that.data.keyword, page: that.data.page, size: that.data.size, sort: that.data.currentSortType, order: that.data.currentSortOrder, categoryId: that.data.categoryId,
-        storeId:wx.getStorageSync("storeId")}).then(function (res) {
-            if (res.errno === 0) {
-                that.setData({
-                    searchStatus: true,
-                    categoryFilter: false,
-                    goodsList: res.data.data,
-                    filterCategory: res.data.filterCategory,
-                    page: res.data.currentPage,
-                    size: res.data.numsPerPage
-              });
-              wx.hideLoading();
-            }
-
-            //重新获取关键词
-            that.getSearchKeyword();
+  },
+  getGoodsList: function () {
+    let that = this;
+    wx.showLoading({
+      title: '加载中...',
+    });
+    util.request(api.GoodsList, {
+      keyword: that.data.keyword, page: that.data.page, size: that.data.size, sort: that.data.currentSortType, order: that.data.currentSortOrder, categoryId: that.data.categoryId,
+      storeId: wx.getStorageSync("storeId")
+    }).then(function (res) {
+      if (res.errno === 0) {
+        let goodsList = that.data.goodsList.concat(res.data.data);
+        that.setData({
+          searchStatus: true,
+          categoryFilter: false,
+          goodsList: goodsList,
+          filterCategory: res.data.filterCategory,
+          page: res.data.currentPage,
+          size: res.data.numsPerPage
         });
-    },
-    onKeywordTap: function (event) {
+        wx.hideLoading();
+      }
+
+      //重新获取关键词
+      that.getSearchKeyword();
+    });
+  },
+  onKeywordTap: function (event) {
 
-        this.getSearchResult(event.target.dataset.keyword);
+    this.getSearchResult(event.target.dataset.keyword);
 
-    },
-    getSearchResult(keyword) {
+  },
+  getSearchResult(keyword) {
+    this.setData({
+      keyword: keyword,
+      categoryId: 0,
+      page: 1,
+      goodsList: []
+    });
+
+    this.getGoodsList();
+  },
+  openSortFilter: function (event) {
+    let currentId = event.currentTarget.id;
+    switch (currentId) {
+      case 'categoryFilter':
         this.setData({
-            keyword: keyword,
-            page: 1,
-            categoryId: 0,
-            goodsList: []
+          'categoryFilter': !this.data.categoryFilter,
+          'currentSortOrder': 'asc'
+        });
+        break;
+      case 'priceSort':
+        let tmpSortOrder = 'asc';
+        if (this.data.currentSortOrder == 'asc') {
+          tmpSortOrder = 'desc';
+        }
+        this.setData({
+          'currentSortType': 'price',
+          'currentSortOrder': tmpSortOrder,
+          'categoryFilter': false,
+          page: 1,
+          goodsList: []
         });
 
         this.getGoodsList();
-    },
-    openSortFilter: function (event) {
-        let currentId = event.currentTarget.id;
-        switch (currentId) {
-            case 'categoryFilter':
-                this.setData({
-                    'categoryFilter': !this.data.categoryFilter,
-                    'currentSortOrder': 'asc'
-                });
-                break;
-            case 'priceSort':
-                let tmpSortOrder = 'asc';
-                if (this.data.currentSortOrder == 'asc') {
-                    tmpSortOrder = 'desc';
-                }
-                this.setData({
-                    'currentSortType': 'price',
-                    'currentSortOrder': tmpSortOrder,
-                    'categoryFilter': false
-                });
-
-                this.getGoodsList();
-                break;
-            default:
-                //综合排序
-                this.setData({
-                    'currentSortType': 'default',
-                    'currentSortOrder': 'desc',
-                    'categoryFilter': false
-                });
-                this.getGoodsList();
-        }
-    },
-    selectCategory: function (event) {
-        let currentIndex = event.target.dataset.categoryIndex;
-        let filterCategory = this.data.filterCategory;
-        let currentCategory = null;
-        for (let key in filterCategory) {
-            if (key == currentIndex) {
-                filterCategory[key].selected = true;
-                currentCategory = filterCategory[key];
-            } else {
-                filterCategory[key].selected = false;
-            }
-        }
+        break;
+      default:
+        //综合排序
         this.setData({
-            'filterCategory': filterCategory,
-            'categoryFilter': false,
-            categoryId: currentCategory.id,
-            page: 1,
-            goodsList: []
+          'currentSortType': 'default',
+          'currentSortOrder': 'desc',
+          'categoryFilter': false,
+          page: 1,
+          goodsList: []
         });
         this.getGoodsList();
-    },
-    onKeywordConfirm(event) {
-        this.getSearchResult(event.detail.value);
     }
+  },
+  selectCategory: function (event) {
+    let currentIndex = event.target.dataset.categoryIndex;
+    let filterCategory = this.data.filterCategory;
+    let currentCategory = null;
+    for (let key in filterCategory) {
+      if (key == currentIndex) {
+        filterCategory[key].selected = true;
+        currentCategory = filterCategory[key];
+      } else {
+        filterCategory[key].selected = false;
+      }
+    }
+    this.setData({
+      'filterCategory': filterCategory,
+      'categoryFilter': false,
+      categoryId: currentCategory.id,
+      page: 1,
+      goodsList: []
+    });
+    this.getGoodsList();
+  },
+  onKeywordConfirm(event) {
+    this.getSearchResult(event.detail.value);
+  },
+  onReachBottom() {
+    var that = this;
+    if (!that.data.goodsList) {
+      wx.showLoading({
+        title: '加载中...',
+      })
+    }
+    that.setData({
+      page: that.data.page + 1
+    });
+    that.getGoodsList();
+  }
 })

+ 21 - 7
wx-mall/pages/ucenter/addressAdd/addressAdd.js

@@ -420,7 +420,7 @@ Page({
     var that = this;
     wx.chooseLocation({
       success: function (res) {
-        console.log("res:" + res);
+        // console.log("res:" + res);
         let address = that.data.address;
         if(null==res.latitude){
           return;
@@ -431,8 +431,18 @@ Page({
         if (!(province = regex.exec(res.address))) {
           regex = /^(.*?(省|自治区))(.*?)$/;
           province = regex.exec(res.address);
-          address.provinceName = province[1];
-          address = that.regexAddress(province[3], address, res.name);
+          if (province != null) {
+            address.provinceName = province[1];
+            // console.log("试试:" + province[3]);
+            // console.log("试试:" + res.name);
+            // console.log(address);
+            address = that.regexAddress(province[3], address, res.name);
+          }else{
+            wx.showToast({
+              title: '收货地址请详细区县/区镇',
+              icon: 'none'
+            })
+          }
         } else {
           address.provinceName = province[1];
           address = that.regexAddress(res.address, address, res.name);
@@ -448,11 +458,15 @@ Page({
     })
   },
   regexAddress: function (address, addressBean, name) {
-    var regex = /^(.*?[市州]|.*?地区|.*?特别行政区)(.*?[市区县])(.*?)$/g;
+    // var regex = /^(.*?[市州]|.*?地区|.*?特别行政区)(.*?[市区县])(.*?)$/g;
+    var regex = /^(.*?[市州]|.*?地区|.*?特别行政区.*?区|.+盟|市辖区|.*?市|.*?县)(.*?[市区县]|.*?镇|.+海域|.+岛|.*?街|.*?路|.*?道)(.*?)$/g;
+    // var regex = /^(.*?)(.*?)(.*?)$/g;
     var addxress = regex.exec(address);
-    addressBean.cityName = addxress[1];
-    addressBean.countyName = addxress[2];
-    addressBean.detailInfo = addxress[3] + "(" + name + ")";
+    if (addxress != null) {
+      addressBean.cityName = addxress[1];
+      addressBean.countyName = addxress[2];
+      addressBean.detailInfo = addxress[3] + "(" + name + ")";
+    }
     return addressBean;
   }
 })

+ 15 - 12
wx-mall/pages/ucenter/order/order.js

@@ -1,5 +1,7 @@
 var util = require('../../../utils/util.js');
 var api = require('../../../config/api.js');
+//获取应用实例
+const app = getApp();
 
 Page({
     data: {
@@ -104,18 +106,19 @@ Page({
       //   });
       //   return;
       // }
-        util.request(api.CartAddByOrder, {orderId: orderId}).then(function (res) {
-            if (res.errno === 0) {
-                wx.switchTab({
-                    url: '/pages/cart/cart',
-                });
-            } else {
-                wx.showToast({
-                    title: res.errmsg,
-                    image: '/static/images/icon_error.png',
-                    duration: 2000
-                });
-            }
+      util.request(api.CartAddByOrder, { orderId: orderId }).then(function (res) {
+        if (res.errno === 0) {
+          app.globalData.appCheckCart = '00';
+          wx.switchTab({
+            url: '/pages/cart/cart',
+          });
+        } else {
+          wx.showToast({
+            title: res.errmsg,
+            image: '/static/images/icon_error.png',
+            duration: 2000
+          });
+        }
         });
   },
   againBuyDisabel(event) {