zhashaonan 7 jaren geleden
bovenliggende
commit
de38893bd0

+ 6 - 6
pages/addAddress/addAddress.wxml

@@ -5,7 +5,7 @@
     <view class="info_cell vux-1px-b">
       <view class="info_cell_lable">收件人:</view>
       <view class="info_cell_content">
-        <input auto-focus placeholder="请输入收件人" value="{{name}}" bindinput="bindKeyInput" data-value="name" />
+        <input auto-focus placeholder="请输入收件人" bindinput="bindKeyInput" data-value="name" />
       </view>
     </view>
   </view>
@@ -14,7 +14,7 @@
     <view class="info_cell vux-1px-b">
       <view class="info_cell_lable">手机号码:</view>
       <view class="info_cell_content">
-        <input placeholder="请输入手机号码" value="{{mob_phone}}" bindinput="bindKeyInput" data-value="phone" />
+         <input placeholder="请输入手机号码" type="number" bindinput="bindKeyInput" data-value="phone" /> 
       </view>
     </view>
   </view>
@@ -35,7 +35,7 @@
     <view class="info_cell">
       <view class="info_cell_lable">详细地址:</view>
       <view class="info_cell_content">
-        <input  placeholder="请输入详细地址" value="{{address}}" bindinput="bindKeyInput" data-value="address" />
+         <input  placeholder="请输入详细地址" bindinput="bindKeyInput" data-value="address" /> 
       </view>
     </view>
   </view>
@@ -64,13 +64,13 @@
     <view class="bacfff" style="text-align:center">
       <picker-view indicator-style="" style="width: 100%; height: 300rpx;" value="{{value}}" bindchange="bindChange">
         <picker-view-column>
-          <view wx:for="{{tree}}" wx:key="*this" style="line-height: 68rpx" data-sign="province">{{item.n}}</view>
+          <view wx:for="{{tree}}" wx:index="province" wx:key="province" style="line-height: 68rpx">{{item.n}}</view>
         </picker-view-column>
         <picker-view-column>
-          <view wx:for="{{citys}}" wx:key="*this" style="line-height: 68rpx">{{item.n}}</view>
+          <view wx:for="{{citys}}" wx:index="city" wx:key="city" style="line-height: 68rpx">{{item.n}}</view>
         </picker-view-column>
         <picker-view-column>
-          <view wx:for="{{districts}}" wx:key="*this" style="line-height: 68rpx">{{item.n}}</view>
+          <view wx:for="{{districts}}" wx:index="district" wx:key="district" style="line-height: 68rpx">{{item.n}}</view>
         </picker-view-column>
       </picker-view>
     </view>

+ 2 - 2
pages/address/address.wxml

@@ -7,8 +7,8 @@
       <text class="ml8">{{item.mob_phone}}</text>
     </view>
     <view class="address_line mt8">
-      <text class="coleb4e4f" wx:if="{{item.is_default == 1}}">[默认地址]</text>
-      <text class="ml16">{{item.area_info}}{{item.address}}</text>
+      <text class="coleb4e4f mr16" wx:if="{{item.is_default == 1}}">[默认地址]</text>
+      <text >{{item.area_info}}{{item.address}}</text>
     </view>
   </view>
   <navigator url="/pages/addAddress/addAddress">

+ 13 - 3
pages/comments/comments.js

@@ -12,7 +12,8 @@ Page({
     common_id: '',
     addtimes: [],
     show_carousel: false,
-    carouselImgs: []
+    carouselImgs: [],
+    current: 0
   },
 
   /**
@@ -44,6 +45,13 @@ Page({
           hasmore: res.datas.mobile_page.hasmore
         })
       }
+      else {
+        wx.showToast({
+          icon: 'none',
+          title: res.message,
+          duration: 2000
+        })
+      }
     })
   },
   getAddTimes(comments) {
@@ -65,9 +73,11 @@ Page({
   },
   showCarousel(e) {
     let carouselImgs = e.currentTarget.dataset.images
+    let current = e.currentTarget.dataset.current
     this.setData({
       show_carousel: true,
-      carouselImgs
+      carouselImgs,
+      current
     })
   },
   hideCarousel() {
@@ -118,7 +128,7 @@ Page({
       return
     }
     this.data.curpage++
-    this.getDatas(3398, this.data.curpage)
+    this.getDatas(this.data.common_id, this.data.curpage) 
   },
 
   /**

+ 2 - 2
pages/comments/comments.wxml

@@ -18,9 +18,9 @@
     <view class="spec">规格:{{item.goods_spec}}</view>
     <view class="content">{{item.content}}</view>
     <view wx:if="{{item.images.length}}">
-      <image bindtap='showCarousel' mode="widthFix" data-images="{{item.images}}" class="content_img" src="{{imgItem}}" wx:for-item="imgItem" wx:for="{{item.images}}" wx:for-index="imgIndex" wx:key="imgIndex"></image>
+      <image bindtap='showCarousel' mode="widthFix" data-images="{{item.images}}" data-current="{{imgIndex}}" class="content_img" src="{{imgItem}}" wx:for-item="imgItem" wx:for="{{item.images}}" wx:for-index="imgIndex" wx:key="imgIndex"></image>
     </view>
     <view class="content" wx:if="{{item.explain}}">{{item.explain}}</view>
   </view>
-  <commentsCarousel wx:if="{{show_carousel}}" bind:hideCarousel="hideCarousel" carouselImgs="{{carouselImgs}}"> </commentsCarousel>
+  <commentsCarousel wx:if="{{show_carousel}}" bind:hideCarousel="hideCarousel" current="{{current}}" carouselImgs="{{carouselImgs}}"> </commentsCarousel>
 </view>

+ 3 - 0
pages/components/blocks/commentsCarousel/commentsCarousel.js

@@ -6,6 +6,9 @@ Component({
   properties: {
     carouselImgs: {
       type: Array
+    },
+    current: {
+      type: Number
     }
   },
 

+ 3 - 3
pages/components/blocks/commentsCarousel/commentsCarousel.wxml

@@ -1,9 +1,9 @@
 <!--pages/components/blocks/commentsCarousel/commentsCarousel.wxml-->
- <view class="carousel_container">
-  <swiper class="comments_swiper" indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
+ <view class="carousel_container" catchtap="hideCarousel">
+  <swiper class="comments_swiper" current="{{current}}" indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
     <block wx:for="{{carouselImgs}}" wx:key="*this">
       <swiper-item class="flex_center;">
-        <image bindtap="hideCarousel" src="{{item}}" class="slide-image" mode="widthFix" style="width: 100%;" />
+        <image catchtap="hideCarousel" src="{{item}}" class="slide-image" mode="widthFix" style="width: 100%;" />
       </swiper-item>
     </block>
   </swiper>

+ 10 - 6
pages/confirmOrder/confirmOrder.js

@@ -55,9 +55,15 @@ Page({
       wx.hideLoading()
       if (res.code == 200) {
         let datas = res.datas
-        console.log('datas')
-        console.log(datas)
         let goods_list = self.getGoodsList(datas.summary, datas.goods_list)
+        let { true_name, mob_phone, area_info, address, address_id } = datas.address
+        appInstance.checkDefaultAddress({
+          true_name,
+          mob_phone,
+          area_info,
+          address,
+          address_id
+        })
         self.setData({
           datas,
           goods_list,
@@ -121,8 +127,8 @@ Page({
       wx.hideLoading()
       console.log(res)
       if (res.code == 200) {
-        
-        
+
+
 
       }
       else {
@@ -134,7 +140,6 @@ Page({
         wx.navigateBack()
       }
     }, function (err) {
-      console.log(err)
       wx.navigateBack()
     })
   },
@@ -149,7 +154,6 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-    console.log('show')
     if (!this.data.firstLoad) {
       let defaultAddress = appInstance.globalData.defaultAddress
       console.log(defaultAddress)

+ 1 - 1
pages/confirmOrder/confirmOrder.wxml

@@ -8,7 +8,7 @@
           <text>{{defaultAddress.true_name}}</text>
           <text class="ml8">{{defaultAddress.mob_phone}}</text>
         </view>
-        <view class="mt10">{{defaultAddress.area_info}}{{defaultAddress.address}}</view>
+        <view class="mt10"><text>{{defaultAddress.area_info}}</text><text class="ml8">{{defaultAddress.address}}</text></view>
       </view>
     </view>
     <view wx:else class="address_none">

+ 47 - 12
pages/details/details.js

@@ -16,10 +16,11 @@ Page({
     autoplay: true,
     interval: 2000,
     duration: 500,
-    animation_flag: false,
+    animation_flag: true,
     sec_index: 0,
     goodsNumber: 1,
-    cartOrBuy: ''
+    cartOrBuy: '',
+    getgift: ''
   },
 
   /**
@@ -30,8 +31,8 @@ Page({
     this.setData({
       webViewUrl
     })
-    // this.getDatas(options.goods_id)
-    this.getDatas(6779)
+    this.getDatas(options.goods_id)
+    // this.getDatas(6779)
   },
   getDatas(goods_id) {
     wx.showLoading({
@@ -46,10 +47,12 @@ Page({
       wx.hideLoading()
       if (res.code == 200) {
         let oneSummary = self.getOneSummary(res.datas.summary, goods_id)
+        let getgift = self.getgift(res.datas.summary, goods_id)
         self.setData({
           datas: res.datas,
           getOneSummary: oneSummary,
-          imgUrls: res.datas.common_info.images
+          imgUrls: res.datas.common_info.images,
+          getgift
         })
 
       }
@@ -57,7 +60,7 @@ Page({
         wx.showToast({
           icon: 'none',
           title: res.message,
-          duration: 2000
+          duration: 1500
         })
       }
     })
@@ -75,10 +78,20 @@ Page({
       return
     }
     let getOneSummary = this.getOneSummary(this.data.datas.summary, goodsId)
+    let getgift = this.getgift(this.data.datas.summary, goodsId)
+    if (getOneSummary.goods_storage < 1) {
+      wx.showToast({
+        title: '客官!暂时没有库存!',
+        icon: 'none',
+        duration: 1500
+      })
+      return
+    }
     this.setData({
       sec_index,
       getOneSummary,
-      goodsNumber: 1
+      goodsNumber: 1,
+      getgift
     })
   },
   goodsNumHandle(e) {
@@ -88,7 +101,7 @@ Page({
         wx.showToast({
           title: '客官!不能再少了!',
           icon: 'none',
-          duration: 2000
+          duration: 1500
         })
         return
       }
@@ -103,7 +116,7 @@ Page({
         wx.showToast({
           title: '客官!只有这么多了!',
           icon: 'none',
-          duration: 2000
+          duration: 1500
         })
         return
       }
@@ -133,19 +146,19 @@ Page({
         if (res.code == 200) {
           wx.showToast({
             title: '添加成功!',
-            duration: 2000
+            duration: 1500
           })
         }
         else {
           wx.showToast({
             icon: 'none',
             title: res.message,
-            duration: 2000
+            duration: 1500
           })
         }
       })
     }
-    else if (cartOrBuy == 'isBuy') {     
+    else if (cartOrBuy == 'isBuy') {
       wx.navigateTo({
         url: `/pages/confirmOrder/confirmOrder?goods_id=${this.data.getOneSummary.goods_id}&iscart=0&num=${this.data.goodsNumber}`
       })
@@ -170,6 +183,28 @@ Page({
       cartOrBuy
     })
   },
+  getgift(sumarys, goods_id) {
+    let goods = this.getOneSummary(sumarys, goods_id)
+    let giftSummary = ''
+    if (goods.have_gift) {
+      giftSummary = this.getGiftSummary(sumarys, goods.gifts)
+    }
+    return giftSummary
+  },
+  getGiftSummary(sumarys, gifts) {
+    let arr = []
+    gifts.map(item => {
+      sumarys.filter(sum => {
+        if(item.gift_goods_id == sum.goods_id) {
+          arr.push({
+            sum,
+            gifts: item
+          })
+        }
+      })
+    })
+    return arr
+  },
 
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 11 - 4
pages/details/details.wxml

@@ -1,7 +1,7 @@
 <!--pages/details/details.wxml-->
 <view class="bacfff">
   <view class="pos_rel">
-    <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" style="height:750rpx">
+    <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" indicator-color="rgba(208, 205, 209, 1)" circular="true" indicator-active-color="#eb4e4f" style="height:750rpx">
       <block wx:for="{{imgUrls}}" wx:key="*this">
         <swiper-item>
           <image src="{{item}}" class="slide-image" mode="widthFix" style="width: 100%;" />
@@ -79,7 +79,7 @@
       <view class="f28 f_left">{{datas.comment.nickname}}</view>
       <view class="scores f_right">
         <view class="flex-stars">
-          <image class="star" src="../../image/star.png" wx:for="{{datas.comment.scores}}" wx:key="*this"></image>
+          <image class="star" src="../../image/star.png" wx:for="{{datas.comment.scores}}" wx:index="starindex" wx:key="starindex"></image>
         </view>
         <view class="comment_time">{{datas.comment.comment_time}}</view>
       </view>
@@ -96,7 +96,7 @@
   </view>
 
   <view class="vux-1px-b">
-    <view class="attr_list_item" wx:for="{{datas.common_info.attrs}}" wx:key="*this">
+    <view class="attr_list_item" wx:for="{{datas.common_info.attrs}}" wx:index="attrindex" wx:key="attrindex">
       <text>{{item.name}}</text>
       <text class="col333">{{item.value}}</text>
     </view>
@@ -104,7 +104,6 @@
 
   <view class="place-bac247"></view>
 
-  <!-- <button style="width: 40%; margin: 160rpx auto;" type="primary" plain="true" bindtap="toWebView">查看更多详情</button>  -->
   <view class="see_more_details" bindtap="toWebView">查看更多详情</view>
   <view class="place_details_tabbar"></view>
 
@@ -133,6 +132,14 @@
           <text class="goods_original_price">{{getOneSummary.goods_price}}</text>
         </view>
         <view class="f24">已售{{getOneSummary.goods_salenum}}件/库存{{getOneSummary.goods_storage}}件</view>
+        <block wx:if="{{getgift}}">
+          <navigator url="/pages/details/details?goods_id={{item.gifts.gift_goods_id}}" wx:for="{{getgift}}" wx:index="giftindex" wx:key="giftindex">
+            <view class="gifts_wrap one_line_hidden">
+              <text class="gift_tag">赠品</text>
+              <text class="gift_underline ml8">{{item.sum.goods_mobile_name}}</text>
+            </view>
+          </navigator>
+        </block>
       </view>
     </view>
 

+ 18 - 0
pages/details/details.wxss

@@ -494,3 +494,21 @@
   -webkit-transform: rotate(-45deg);
   transform: rotate(-45deg);
 }
+
+.gifts_wrap {
+  font-size: 20rpx;
+  background: #ffe3c6;
+  border-radius: 5rpx;
+  padding:10rpx;
+  margin-right: 18rpx;
+  margin-top: 10rpx;
+}
+.gift_tag {
+  background: #eb4e4f;
+  border-radius: 4rpx;
+  padding: 2rpx;
+  color: #fff;
+}
+.gift_underline {
+  text-decoration: underline;
+}