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

小程序新增品牌查询、以及购物车修改

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

+ 4 - 3
wx-mall/config/api.js

@@ -2,13 +2,13 @@
 //var NewApiRootUrl = 'http://localhost:8080/api/';
 //var NewApiRootUrl = 'http://192.168.1.138:8080/api/';
 // var NewApiRootUrl = 'http://qhdswl.f3322.net:9001/platform-framework/api/';//hyq
-var NewApiRootUrl = 'http://qhdswl.f3322.net:9002/api/';
+// var NewApiRootUrl = 'http://qhdswl.f3322.net:9003/api/';
 
 //测试环境
-//var NewApiRootUrl = 'https://mp-test.k1net.cn/api/';
+// var NewApiRootUrl = 'https://mp-test.k1net.cn/api/';
 
 //生产环境
-//var NewApiRootUrl = 'https://mp.k1net.cn/api/';
+var NewApiRootUrl = 'https://mp.k1net.cn/api/';
 
 module.exports = {
 
@@ -29,6 +29,7 @@ module.exports = {
     GoodsCount: NewApiRootUrl + 'goods/count',  //统计商品总数
     GoodsList: NewApiRootUrl + 'goods/list',  //获得商品列表
     GoodsCategory: NewApiRootUrl + 'goods/category',  //获得分类数据
+    GoodsCategoryBrand: NewApiRootUrl + 'goods/brand',  //获得分类品牌数据
     GoodsDetail: NewApiRootUrl + 'goods/detail',  //获得商品的详情
     GoodsHot: NewApiRootUrl + 'goods/hot',  //热门
     GoodsRelated: NewApiRootUrl + 'goods/related',  //商品详情页的关联商品(大家都在看)

+ 2 - 2
wx-mall/lib/wxParse/wxParse.wxml

@@ -19,7 +19,7 @@
 </template>
 
 <template name="wxParseImg">
-    <image class="{{item.classStr}} wxParse-{{item.tag}}" data-from="{{item.from}}" data-src="{{item.attr.src}}"  data-idx="{{item.imgIndex}}"  src="{{item.attr.src}}" mode="aspectFit" bindload="wxParseImgLoad" bindtap="wxParseImgTap" style="width:{{item.width}}px;height:{{item.height}}px;{{item.attr.style}}"   />
+    <image lazy-load="true" class="{{item.classStr}} wxParse-{{item.tag}}" data-from="{{item.from}}" data-src="{{item.attr.src}}"  data-idx="{{item.imgIndex}}"  src="{{item.attr.src}}" mode="aspectFit" bindload="wxParseImgLoad" bindtap="wxParseImgTap" style="width:{{item.width}}px;height:{{item.height}}px;{{item.attr.style}}"   />
 </template>
 
 <template name="WxEmojiView">
@@ -27,7 +27,7 @@
     <block wx:for="{{item.textArray}}" wx:key="">
       <block class="{{item.text == '\\n' ? 'wxParse-hide':''}}" wx:if="{{item.node == 'text'}}">{{item.text}}</block>
       <block wx:elif="{{item.node == 'element'}}">
-        <image class="wxEmoji" src="{{item.baseSrc}}{{item.text}}" />
+        <image lazy-load="true" class="wxEmoji" src="{{item.baseSrc}}{{item.text}}" />
       </block>
     </block>
   </view>

+ 9 - 0
wx-mall/lib/wxParse/wxParse.wxss

@@ -9,6 +9,15 @@
  * for: 微信小程序富文本解析
  * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
  */
+ @keyframes fadeIn {
+  0% {
+    opacity: 0;
+  }
+  100% {
+    opacity: 1;
+  }
+}
+
 
 .wxParse{
     margin: 0 5px;

+ 40 - 10
wx-mall/pages/cart/cart.js

@@ -201,11 +201,16 @@ Page({
   },
   checkedItem: function(event) {
     let itemIndex = event.target.dataset.itemIndex;
+    let goodsBizType = event.target.dataset.goodsBizType;
+    let goodsId = event.target.dataset.goodsId;
+    let checked = event.target.dataset.checked;
     let that = this;
-
+    // console.log(goodsBizType);
+    // console.log(goodsId);
+    // console.log(that.data.cartGoods[itemIndex].checked);
     util.request(api.CartChecked, {
-      productIds: that.data.cartGoods[itemIndex].product_id,
-      isChecked: that.data.cartGoods[itemIndex].checked ? 0 : 1,
+      goodsIds: goodsId,
+      isChecked: checked ? 0 : 1,
       checkCart: that.data.checkCart
     }, 'POST').then(function(res) {
       if (res.errno === 0) {
@@ -222,16 +227,15 @@ Page({
         checkedGoodsCount += v.number;
       }
     });
-    console.log(checkedGoodsCount);
     return checkedGoodsCount;
   },
   checkedAll: function() {
     let that = this;
-    var productIds = this.data.cartGoods.map(function(v) {
-      return v.product_id;
+    var goodsIds = this.data.cartGoods.map(function(v) {
+      return v.goodsIds;
     });
     util.request(api.CartChecked, {
-      productIds: productIds.join(','),
+      goodsIds: goodsIds.join(','),
       isChecked: that.isCheckedAll() ? 0 : 1
     }, 'POST').then(function(res) {
       if (res.errno === 0) {
@@ -244,26 +248,52 @@ Page({
     let that = this;
     let goodsBizType = e.target.dataset.goodsBizType;
     let isCheckedTypeStatu;
+    let checkCart;
     if (goodsBizType == '00') {
       isCheckedTypeStatu = that.isCheckedTypeStatus00();
+      checkCart = '00';
     }
     if (goodsBizType == '02') {
       isCheckedTypeStatu = that.isCheckedTypeStatus02();
+      checkCart = '00';
     }
     if (goodsBizType == '10') {
       isCheckedTypeStatu = that.isCheckedTypeStatus10();
+      checkCart = '00';
     }
     if (goodsBizType == '11') {
       isCheckedTypeStatu = that.isCheckedTypeStatus11();
+      checkCart = '11';
     }
     util.request(api.CartChecked, {
       isChecked: isCheckedTypeStatu ? 0 : 1,
-      goodsBizType: goodsBizType
+      goodsBizType: goodsBizType, 
+      checkCart: checkCart
     }, 'POST').then(function(res) {
       if (res.errno === 0) {
-        that.setCommonData(res);
+        // that.setCommonData(res);
+        that.setData({
+          validCartList: res.data.validCartList,
+          couponInfoList: res.data.couponInfoList,
+        });
+        if (goodsBizType == '11') {
+          that.setData({
+            cartGoods: res.data.cartList,
+            cartTotal: res.data.cartTotal,
+            cartGoods11: res.data.cart11List,
+            total11: res.data.total11
+          });
+        } else {
+          that.setData({
+            cartGoods: res.data.cartList,
+            cartTotal: res.data.cartTotal,
+            cartGoods00: res.data.cart00List,
+            cartGoods02: res.data.cart02List,
+            cartGoods10: res.data.cart10List,
+            total00: res.data.total00
+          });
+        }
       }
-
       if (goodsBizType == '00') {
         that.setData({
           checkedTypeStatus00: that.isCheckedTypeStatus00()

+ 8 - 8
wx-mall/pages/cart/cart.wxml

@@ -43,8 +43,8 @@
           <view wx:if="{{cartGoods00.length != 0}}" class="checkbox-biz-type {{checkedTypeStatus00 ? 'checked' : ''}}" bindtap="checkedAllGoodType" data-goods-Biz-Type="00">
           <image src="../../../static/images/service-bao.png" class="search-icon-shop"></image>
           <text class="title-name ">保税仓</text></view>
-          <view class="item" wx:for="{{cartGoods}}" wx:if="{{item.goodsBizType == 00}}" wx:key="{{item.id}}">
-            <view class="checkbox {{item.checked ? 'checked' : ''}}" bindtap="checkedItem" data-item-index="{{index}}"></view>
+          <view class="item" wx:for="{{cartGoods00}}" wx:if="{{item.goodsBizType == 00}}" wx:key="{{item.id}}">
+            <view class="checkbox {{item.checked ? 'checked' : ''}}" bindtap="checkedItem" data-item-index="{{index}}"  data-goods-Biz-Type="00" data-goods-Id="{{item.goods_id}}" data-checked="{{item.checked}}"></view>
             <view class="cart-goods">
               <navigator url="/pages/goods/goods?id={{item.goods_id}}">
                 <image class="img" src="{{item.list_pic_url}}"></image>
@@ -83,8 +83,8 @@
           <text class="title-name">保税展示</text>
         </view>
 
-          <view class="item" wx:for="{{cartGoods}}" wx:if="{{item.goodsBizType == 02}}" wx:key="{{item.id}}">
-            <view class="checkbox {{item.checked ? 'checked' : ''}}" bindtap="checkedItem" data-item-index="{{index}}"></view>
+          <view class="item" wx:for="{{cartGoods02}}" wx:if="{{item.goodsBizType == 02}}" wx:key="{{item.id}}">
+            <view class="checkbox {{item.checked ? 'checked' : ''}}" bindtap="checkedItem" data-item-index="{{index}}" data-goods-Biz-Type="00" data-goods-Id="{{item.goods_id}}" data-checked="{{item.checked}}"></view>
             <view class="cart-goods">
               <navigator url="/pages/goods/goods?id={{item.goods_id}}">
                 <image class="img" src="{{item.list_pic_url}}"></image>
@@ -124,8 +124,8 @@
             <text class="title-name">现场速递</text>
           </view>
 
-          <view class="item" wx:for="{{cartGoods}}" wx:if="{{item.goodsBizType == 10}}" wx:key="{{item.id}}">
-            <view class="checkbox {{item.checked ? 'checked' : ''}}" bindtap="checkedItem" data-item-index="{{index}}"></view>
+          <view class="item" wx:for="{{cartGoods10}}" wx:if="{{item.goodsBizType == 10}}" wx:key="{{item.id}}">
+            <view class="checkbox {{item.checked ? 'checked' : ''}}" bindtap="checkedItem" data-item-index="{{index}}" data-goods-Biz-Type="00" data-goods-Id="{{item.goods_id}}" data-checked="{{item.checked}}"></view>
             <view class="cart-goods">
               <navigator url="/pages/goods/goods?id={{item.goods_id}}">
                 <image class="img" src="{{item.list_pic_url}}"></image>
@@ -165,8 +165,8 @@
             <text class="title-name">普通商品</text>
           </view>
 
-          <view class="item" wx:for="{{cartGoods}}" wx:if="{{item.goodsBizType == 11}}" wx:key="{{item.id}}">
-            <view class="checkbox {{item.checked ? 'checked' : ''}}" bindtap="checkedItem" data-item-index="{{index}}"></view>
+          <view class="item" wx:for="{{cartGoods11}}" wx:if="{{item.goodsBizType == 11}}" wx:key="{{item.id}}">
+            <view class="checkbox {{item.checked ? 'checked' : ''}}" bindtap="checkedItem" data-item-index="{{index}}" data-goods-Biz-Type="00" data-goods-Id="{{item.goods_id}}" data-checked="{{item.checked}}"></view>
             <view class="cart-goods">
               <navigator url="/pages/goods/goods?id={{item.goods_id}}">
                 <image class="img" src="{{item.list_pic_url}}"></image>

+ 21 - 5
wx-mall/pages/catalog/catalog.js

@@ -8,6 +8,7 @@ Page({
     navList: [],
     categoryList: [],
     currentCategory: {},
+    brandList:[],
     scrollLeft: 0,
     scrollTop: 0,
     goodsCount: 0,
@@ -65,9 +66,11 @@ Page({
       if (!wx.getStorageSync('currentCategory')) {
         that.setData({
           navList: res.data.categoryList,
-          currentCategory: res.data.currentCategory
+          currentCategory: res.data.currentCategory,
+          brandList: res.data.brandList
         });
         wx.setStorageSync('currentCategory', res.data.currentCategory);
+        // console.log(that.data.brandList);
       } else {
         if (that.data.currentCategory && that.data.currentCategory.id > 0) {
           that.setData({
@@ -76,7 +79,8 @@ Page({
         } else {
           that.setData({
             navList: res.data.categoryList,
-            currentCategory: res.data.currentCategory
+            currentCategory: res.data.currentCategory,
+            brandList: res.data.brandList
           });
         }
       }
@@ -93,9 +97,10 @@ Page({
     util.request(api.CatalogCurrent, { id: id })
       .then(function (res) {
         that.setData({
-          currentCategory: res.data.currentCategory
+          currentCategory: res.data.currentCategory,
+          brandList: res.data.brandList
         });
-        console.log(that.data.currentCategory);
+        // console.log(res.data.brandList);
         that.getGoodsList();
       });
   },
@@ -364,6 +369,17 @@ Page({
     wx.navigateTo({
       url: '/pages/category/category?id=' + replyType + '&&goodsBizType=' + that.data.goodsBizType + '&&currentIndex=' + currentIndex
     })
-
+  },
+  sercherCategoryByBrand: function (e) {
+    var that = this;
+    let url = '';
+    var replyType = e.currentTarget.dataset.replyType;
+    var currentIndex = e.currentTarget.dataset.currentIndex;
+    console.log('replyType:' + replyType);
+    console.log('goodsBizType:' + that.data.goodsBizType);
+    // 跳转页面
+    wx.navigateTo({
+      url: '/pages/categoryBrand/categoryBrand?brandId=' + replyType + '&&goodsBizType=' + that.data.goodsBizType + '&&currentIndex=' + currentIndex
+    })
   }
 })

+ 13 - 0
wx-mall/pages/catalog/catalog.wxml

@@ -95,6 +95,19 @@
           <text class="txt">{{item.name?item.name:""}}</text>
         </navigator>
       </view>
+
+      <view class="hd" wx:if="{{currentCategory}}">
+        <text class="line"></text>
+        <text class="txt">{{currentCategory.name?currentCategory.name:""}}品牌</text>
+        <text class="line"></text>
+      </view>
+      <view class="bd">
+        <navigator bindtap="sercherCategoryByBrand" data-reply-Type="{{item.id}}" data-current-Index="{{index}}" class="item {{(index+1) % 3 == 0 ? 'last' : ''}}" wx:for="{{brandList}}" wx:key="{{item.id}}">
+          <image class="icon" wx:if="{{item.app_list_pic_url}}" src="{{item.app_list_pic_url}}"></image>
+          <text class="txt">{{item.name?item.name:""}}</text>
+        </navigator>
+      </view>
+      
       <view class="sort" wx:if="{{goodsList.length > 0 }}">
         <view class="sort-box">
           <view class="item {{currentSortType == 'default' ? 'active' : ''}}" bindtap="openSortFilter" id="defaultSort">

+ 5 - 4
wx-mall/pages/catalog/catalog.wxss

@@ -134,12 +134,13 @@ page {
   height: auto;
   width: 100%;
   overflow: hidden;
+  text-align:center;
 }
 
 .catalog .bd .item {
   display: block;
   float: left;
-  height: 246rpx;
+  /* height: 246rpx; */
   /* width: 170rpx; */
   margin-right: 54rpx;
 }
@@ -149,14 +150,14 @@ page {
 }
 
 .catalog .bd .item .icon {
-  height: 144rpx;
-  width: 144rpx;
+  height: 90rpx;
+  width: 100rpx;
 }
 
 .catalog .bd .item .txt {
   display: block;
   text-align: center;
-  font-size: 24rpx;
+  font-size: 22rpx;
   color: #333;
   height: 72rpx;
   width: 144rpx;

+ 4 - 1
wx-mall/pages/goods/goods.js

@@ -248,7 +248,10 @@ Page({
           mask: true
         });
       } else {
-        util.showErrorToast(res.errmsg)
+        wx.showToast({
+          title: res.errmsg,
+          icon: 'none'
+        })
       }
     });
   },

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

@@ -54,7 +54,7 @@
                   </view>
 
                 <view style="width: 750rpx;height: calc(9 * 750rpx / 16);" hidden="{{imgHiddenName}}">
-                  <image class="model-img" style="width: 750rpx;height: calc(9 * 750rpx / 16);background-size:650rpx 321rpx;" mode="aspectFill" src="{{gallery[1].img_url}}" background-size="cover"></image>
+                  <image lazy-load="true" class="model-img" style="width: 750rpx;height: calc(9 * 750rpx / 16);background-size:650rpx 321rpx;" mode="aspectFill" src="{{gallery[1].img_url}}" background-size="cover"></image>
                   <view class="model-btn">
                     <view class="play-icon"></view>
                   </view>
@@ -62,7 +62,7 @@
               </view>
               <!-- 视频播放结束 -->
               <view wx:else >
-                <image src="{{item.img_url}}" class="imageClass" mode='aspectFill' catchtap='preview' data-url="{{item.img_url}}"/>
+                <image lazy-load="true" src="{{item.img_url}}?x-oss-process=image/resize,h_500" class="imageClass" mode='aspectFill' catchtap='preview' data-url="{{item.img_url}}"/>
               </view>
               </view>
               
@@ -206,7 +206,7 @@
     </view>
     <view class="detail"  bindtap="hideSwitchAttrPop">
       <view class="t">商品详情</view>
-      <import src="../../lib/wxParse/wxParse.wxml" />
+      <import src="../../lib/wxParse/wxParse.wxml"/>
       <template is="wxParse" data="{{wxParseData:goodsDetail.nodes}}" />
     </view>
 

+ 9 - 0
wx-mall/pages/goods/goods.wxss

@@ -1,3 +1,12 @@
+@keyframes fadeIn {
+  0% {
+    opacity: 0;
+  }
+  100% {
+    opacity: 1;
+  }
+}
+
 .container {
   margin-bottom: 100rpx;
 }

+ 20 - 3
wx-mall/pages/index/index.js

@@ -174,13 +174,16 @@ Page({
     //获取附件门店信息
     util.getLocation((lng, lat) => {
       wx.setStorageSync('location', JSON.stringify({ lng, lat }));
-      util.request(api.NearbyList, { longitude: lng, latitude: lat, storeId: 7 }).then((res) => {
+      util.request(api.NearbyList, { longitude: lng, latitude: lat, storeId: that.data.storeId }).then((res) => {
         let nlist = res.data;
         // console.log(nlist);
         wx.removeStorageSync('nearStoreList');
         wx.removeStorageSync('storeId');
         wx.removeStorageSync('storeVo');
-        wx.removeStorageSync('currentCategory');
+        // console.log('sasas:' + wx.getStorageSync('currentCategory'));
+        if (!wx.getStorageSync('currentCategory')) {
+          wx.removeStorageSync('currentCategory');
+        }
         if (!nlist.length) {
           wx.removeStorageSync('nearStoreList');
         } else {
@@ -414,5 +417,19 @@ Page({
       }
 
     })
-  }
+  }, 
+  imgOnLoad: function (e) {
+    let that = this;
+    // console.log('图片加载完成');
+    // var realthumb = e.target.dataset.thumb;
+    // let list = that.data.list
+    // for (var i = 0; i < list.length; i++) {
+    //   if (list[i].thumb == realthumb) {
+    //     list[i].loaded = true
+    //   }
+    //   that.setData({
+    //     list: list
+    //   })
+    // }
+  },
 })

+ 6 - 4
wx-mall/pages/index/index.wxml

@@ -31,7 +31,7 @@
   <swiper class="banner" indicator-dots="true" autoplay="true" interval="15000" duration="750">
     <swiper-item wx:for="{{banner}}" wx:key="{{item.id}}">
       <navigator url="{{item.link}}">
-        <image class="swiper-item" src="{{item.imageUrl}}" background-size="cover"></image>
+        <image class="swiper-item" src="{{item.imageUrl}}" bindload="imgOnLoad"  mode="aspectFill" background-size="cover"></image>
       </navigator>
     </swiper-item>
   </swiper>
@@ -160,9 +160,11 @@
     </view>
     <view class="b">
       <view class="item" wx:for="{{hotGoods}}" wx:for-index="index" wx:for-item="item" wx:key="{{item.id}}">
-        <navigator url="/pages/goods/goods?id={{item.id}}">
-          <image class="img" src="{{item.list_pic_url}}"></image>
-        </navigator>
+        <view class="c">
+          <navigator url="/pages/goods/goods?id={{item.id}}">
+            <image class="img" src="{{item.list_pic_url}}" mode="aspectFill"></image>
+          </navigator>
+        </view>
         <view class="right">
           <view class="text">
             <navigator url="/pages/goods/goods?id={{item.id}}">

+ 6 - 1
wx-mall/pages/index/index.wxss

@@ -272,10 +272,15 @@
   margin: 0 10rpx;
   height: 254rpx;
   width: 710rpx;
+  margin-top: 12rpx;
 }
+/* .a-popular .c {
+  width: 240rpx;
+  height: 240rpx;
+} */
 
 .a-popular .b .img {
-  margin-top: 12rpx;
+  margin-top: 10rpx;
   margin-right: 15rpx;
   float: left;
   width: 240rpx;

+ 1 - 1
wx-mall/project.config.json

@@ -9,7 +9,7 @@
 		"uglifyFileName": true
 	},
 	"compileType": "miniprogram",
-	"libVersion": "2.4.3",
+	"libVersion": "2.6.0",
 	"appid": "wxb6b30b1b14ee502a",
 	"projectname": "kmall-mp",
 	"condition": {