goods-list.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view class="goods-list">
  3. <view class="item dir-left-nowrap" :class="key !== goods_list.length ? 'item-border' : ''" v-for="(item, key) in goods_list" :key="key" @click="route_go(item)">
  4. <view class="box-grow-0 cover-pic">
  5. <image class="pic" :src="item.cover_pic"></image>
  6. <view class="out-dialog" v-if="item.goods_stock == 0 && appSetting.is_show_stock == '1'">
  7. <image mode="aspectFill" :src="appSetting.is_use_stock == '1' ? appImg.plugins_out : appSetting.sell_out_pic"></image>
  8. </view>
  9. </view>
  10. <view class="cont dir-top-nowrap main-between">
  11. <text class="name t-omit-two">{{item.name}}</text>
  12. <view>
  13. <view class="box-grow-0 cross-bottom"
  14. v-if="item.is_level == 1 && item.is_negotiable != 1">
  15. <app-member-price :theme="theme" :price="item.level_price"></app-member-price>
  16. </view>
  17. <app-sup-vip class="margin-vip" :is_vip_card_user="item.vip_card_appoint.is_vip_card_user"
  18. v-if="item.vip_card_appoint && item.vip_card_appoint.discount"
  19. :discount="item.vip_card_appoint && item.vip_card_appoint.discount">
  20. </app-sup-vip>
  21. <view class="price-but dir-left-nowrap main-between cross-center">
  22. <view class="price dir-top-nowrap">
  23. <text class="price_content" :style="{'color': theme.color}">{{item.price_content}}</text>
  24. <text class="sales">{{item.sales}}</text>
  25. <text class="origin-price" v-if="isListUnderlinePrice == 1">¥{{item.original_price}}</text>
  26. </view>
  27. <view class="but">
  28. <view v-if="item.is_negotiable != 1 && isShowCart == 1 && item.goods_stock > 0" class="box-grow-0 cart-box">
  29. <view class="goods-cart" >
  30. <cats-image @click.stop.native="specification(item)" :theme="theme"></cats-image>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import { mapGetters, mapState } from 'vuex';
  42. import catsImage from './cats-image.vue';
  43. export default {
  44. name: "goods-list",
  45. props : [`goods_list`, `theme`],
  46. components: {
  47. catsImage
  48. },
  49. data() {
  50. return {
  51. previewUrl: '',
  52. submitUrl: '',
  53. attrGroup: [],
  54. selectAttr: {},
  55. item: {},
  56. show: 0
  57. }
  58. },
  59. computed: {
  60. ...mapGetters('mallConfig', {
  61. getVideo: 'getVideo',
  62. isShowCart: 'getShowCart'
  63. }),
  64. ...mapState({
  65. appSetting: state => state.mallConfig.mall.setting,
  66. appImg: state => state.mallConfig.__wxapp_img.mall,
  67. isListUnderlinePrice: state => state.mallConfig.mall.setting.is_list_underline_price,
  68. platform: function(state) {
  69. return state.gConfig.systemInfo.platform;
  70. }
  71. })
  72. },
  73. methods: {
  74. specification(goods) {
  75. if (goods.sign === 'mch') {
  76. this.previewUrl = this.$api.mch.order_preview;
  77. this.submitUrl = this.$api.mch.order_submit;
  78. } else {
  79. this.previewUrl = '';
  80. this.submitUrl = '';
  81. }
  82. uni.showLoading({
  83. text: '',
  84. mask: true
  85. });
  86. this.$request({
  87. url: this.$api.goods.attr,
  88. data: {
  89. id: goods.id,
  90. mch_id: goods.mch_id
  91. }
  92. }).then(e => {
  93. uni.hideLoading();
  94. if (e.code === 0) {
  95. let data = Object.assign(goods, e.data);
  96. this.$emit('attr', this.previewUrl, this.submitUrl, goods.attr_groups, data);
  97. } else {
  98. uni.showToast({
  99. title: e.msg,
  100. icon: 'none'
  101. })
  102. }
  103. })
  104. },
  105. route_go(item) {
  106. // #ifndef MP-BAIDU
  107. if (item.video_url && this.getVideo == 1) {
  108. // #ifdef MP
  109. uni.navigateTo({
  110. url: `/pages/goods/video?goods_id=${item.id}&sign=${item.sign}`
  111. });
  112. // #endif
  113. // #ifdef H5
  114. uni.navigateTo({
  115. url: item.page_url
  116. });
  117. // #endif
  118. } else {
  119. uni.navigateTo({
  120. url: item.page_url
  121. });
  122. }
  123. // #endif
  124. // #ifdef MP-BAIDU
  125. uni.navigateTo({
  126. url: item.page_url
  127. });
  128. // #endif
  129. },
  130. onAttr(data) {
  131. this.selectAttr = data;
  132. },
  133. }
  134. }
  135. </script>
  136. <style scoped lang="scss">
  137. .cover-pic {
  138. position: relative;
  139. border-radius: #{8upx};
  140. margin-right: #{20upx};
  141. }
  142. .out-dialog {
  143. width: #{200upx};
  144. height: #{200upx};
  145. position: absolute;
  146. top: 0;
  147. left: 0;
  148. z-index: 10;
  149. background-color: rgba(0,0,0,.5);
  150. image {
  151. width: #{200upx};
  152. height: #{200upx};
  153. }
  154. }
  155. .goods-list {
  156. background-color: #ffffff;
  157. }
  158. .item {
  159. width: #{750upx};
  160. padding: #{0 24upx};
  161. background-color: #ffffff;
  162. margin: #{20upx 0};
  163. }
  164. .item-border {
  165. border-bottom: #{1upx} solid #e2e2e2;
  166. }
  167. .cover-pic {
  168. width: #{200upx};
  169. height: #{200upx};
  170. border-radius: #{8upx};
  171. margin-right: #{20upx};
  172. position: relative;
  173. }
  174. .out-dialog {
  175. width: #{200rpx};
  176. height: #{200rpx};
  177. position: absolute;
  178. top: 0;
  179. left: 0;
  180. z-index: 10;
  181. background-color: rgba(0,0,0,.5);
  182. image {
  183. width: #{200rpx};
  184. height: #{200rpx};
  185. }
  186. }
  187. .pic {
  188. width: #{200upx};
  189. height: #{200upx};
  190. }
  191. .cont {
  192. width: #{480upx};
  193. min-height: #{200upx};
  194. margin-bottom: #{20upx};
  195. }
  196. .name {
  197. font-size: #{28upx};
  198. line-height: 38upx;
  199. color: #353535;
  200. margin-top: #{5upx};
  201. }
  202. .margin-vip {
  203. margin: #{8upx 0 0 0};
  204. }
  205. .price-but {
  206. margin-top: #{8upx};
  207. }
  208. .price_content {
  209. font-size: #{32upx};
  210. line-height: 1;
  211. }
  212. .cart-box {
  213. width:#{56rpx};
  214. height:#{56rpx};
  215. border-radius: 50%;
  216. position: relative;
  217. transform: rotateZ(360deg);
  218. }
  219. .sales {
  220. font-size: #{20upx};
  221. line-height: 1;
  222. color: #999999;
  223. }
  224. .goods-cart {
  225. width:#{56rpx};
  226. height:#{56rpx};
  227. border:none;
  228. background: transparent;
  229. }
  230. .origin-price {
  231. font-size: 21upx;
  232. color: #999999;
  233. text-decoration:line-through;
  234. }
  235. </style>