Authored by 李奇

商品列表显示市场价和原价

@@ -4,12 +4,21 @@ Component({ @@ -4,12 +4,21 @@ Component({
4 properties: { 4 properties: {
5 item: { 5 item: {
6 type: Object, 6 type: Object,
7 - value: {} 7 + value: {},
  8 + observer: '_itemChange'
8 } 9 }
9 }, 10 },
  11 + data: {
  12 + showMarketPrice: false
  13 + },
10 methods: { 14 methods: {
11 goDetail: function () { 15 goDetail: function () {
12 router.go('productDetail', {productSkn: this.properties.item.skn}); 16 router.go('productDetail', {productSkn: this.properties.item.skn});
  17 + },
  18 + _itemChange: function (item) {
  19 + this.setData({
  20 + showMarketPrice: +item.marketPrice > 0 && +item.marketPrice > +item.salesPrice
  21 + });
13 } 22 }
14 } 23 }
15 }); 24 });
@@ -4,8 +4,9 @@ @@ -4,8 +4,9 @@
4 <view class="item-detail"> 4 <view class="item-detail">
5 <text class="item-title">{{item.productName}}</text> 5 <text class="item-title">{{item.productName}}</text>
6 <view class="item-price"> 6 <view class="item-price">
7 - <text class="price1">¥{{helper.round(item.salesPrice)}}</text>  
8 - <!--<text class="price2">¥{{helper.round(item.marketPrice)}}</text>--> 7 + <view class="price price1 {{showMarketPrice ? 'before-market-price' : ''}}">
  8 + ¥{{helper.round(item.salesPrice)}}</view>
  9 + <view class="price price2" wx:if="{{showMarketPrice}}">¥{{helper.round(item.marketPrice)}}</view>
9 </view> 10 </view>
10 </view> 11 </view>
11 </view> 12 </view>
@@ -20,6 +20,10 @@ @@ -20,6 +20,10 @@
20 letter-spacing: 0.28rpx; 20 letter-spacing: 0.28rpx;
21 } 21 }
22 22
  23 +.item-price .price {
  24 + display: inline-block;
  25 +}
  26 +
23 .price1.before-market-price { 27 .price1.before-market-price {
24 color: #d0021b!important; 28 color: #d0021b!important;
25 } 29 }