product-list.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view class="product-list">
  3. <view class="item dir-left-nowrap" 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 class="box-grow-0 cross-bottom"
  13. v-if="item.is_level == 1 && item.is_negotiable != 1">
  14. <app-member-price :theme="theme" :price="item.level_price"></app-member-price>
  15. </view>
  16. <app-sup-vip class="margin-vip" :is_vip_card_user="item.vip_card_appoint.is_vip_card_user"
  17. v-if="item.vip_card_appoint && item.vip_card_appoint.discount"
  18. :discount="item.vip_card_appoint && item.vip_card_appoint.discount">
  19. </app-sup-vip>
  20. <view class="price-but dir-left-nowrap main-between cross-center">
  21. <view class="price dir-top-nowrap">
  22. <text class="price_content" :style="{'color': theme.color}">{{item.price_content}}</text>
  23. <text class="sales">{{item.sales}}</text>
  24. <text class="origin-price" v-if="isListUnderlinePrice == 1">¥{{item.original_price}}</text>
  25. </view>
  26. <view class="but">
  27. <view v-if="item.is_negotiable != 1 && isShowCart == 1 && item.goods_stock > 0" class="box-grow-0 cart-box">
  28. <view class="goods-cart" >
  29. <cats-image v-if="isShowCart == 1" :theme="theme" @click.stop.native="specification(item)" ></cats-image>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import {mapGetters, mapState} from 'vuex';
  40. import catsImage from './cats-image.vue';
  41. export default {
  42. name: "product-list",
  43. props : [`goods_list`, `theme`],
  44. components: {
  45. catsImage
  46. },
  47. data() {
  48. return {
  49. previewUrl: '',
  50. submitUrl: '',
  51. attrGroup: [],
  52. selectAttr: {},
  53. item: {},
  54. show: 0
  55. }
  56. },
  57. computed: {
  58. ...mapGetters('mallConfig', {
  59. getVideo: 'getVideo',
  60. isShowCart: 'getShowCart'
  61. }),
  62. ...mapState({
  63. appSetting: state => state.mallConfig.mall.setting,
  64. appImg: state => state.mallConfig.__wxapp_img.mall,
  65. isListUnderlinePrice: state => state.mallConfig.mall.setting.is_list_underline_price,
  66. platform: function(state) {
  67. return state.gConfig.systemInfo.platform;
  68. }
  69. })
  70. },
  71. methods: {
  72. specification(goods) {
  73. if (goods.sign === 'mch') {
  74. this.previewUrl = this.$api.mch.order_preview;
  75. this.submitUrl = this.$api.mch.order_submit;
  76. } else {
  77. this.previewUrl = '';
  78. this.submitUrl = '';
  79. }
  80. uni.showLoading({
  81. text: '',
  82. mask: true
  83. });
  84. this.$request({
  85. url: this.$api.goods.attr,
  86. data: {
  87. id: goods.id,
  88. mch_id: goods.mch_id
  89. }
  90. }).then(e => {
  91. uni.hideLoading();
  92. if (e.code === 0) {
  93. let data = Object.assign(goods, e.data);
  94. this.$emit('attr', {
  95. previewUrl: this.previewUrl, submitUrl: this.submitUrl, attr_groups: goods.attr_groups, goods: data
  96. });
  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: #{150upx};
  144. height: #{150upx};
  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: #{150upx};
  152. height: #{150upx};
  153. }
  154. }
  155. .item {
  156. width: #{504upx};
  157. border-bottom: #{1upx} solid #e2e2e2;
  158. margin: #{20upx 0 0 0};
  159. }
  160. .cover-pic {
  161. width: #{150upx};
  162. height: #{150upx};
  163. border-radius: #{8upx};
  164. margin-right: #{20upx};
  165. position: relative;
  166. }
  167. .pic {
  168. width: #{150upx};
  169. height: #{150upx};
  170. }
  171. .out-dialog {
  172. width: #{150rpx};
  173. height: #{150rpx};
  174. position: absolute;
  175. top: 0;
  176. left: 0;
  177. z-index: 10;
  178. background-color: rgba(0,0,0,.5);
  179. image {
  180. width: #{150rpx};
  181. height: #{150rpx};
  182. }
  183. }
  184. .cont {
  185. width: #{334upx};
  186. }
  187. .name {
  188. font-size: 28upx;
  189. line-height: 38upx;
  190. color: #353535;
  191. margin-top: #{5upx};
  192. }
  193. .margin-vip {
  194. margin: #{8upx 0 0 0};
  195. }
  196. .price-but {
  197. margin-bottom: #{20upx};
  198. margin-top: #{8upx};
  199. }
  200. .price_content {
  201. font-size: #{28upx};
  202. line-height: 1;
  203. text-align: left;
  204. }
  205. .cart-box {
  206. width:#{56rpx};
  207. height:#{56rpx};
  208. border-radius: 50%;
  209. position: relative;
  210. overflow: hidden;
  211. transform: rotateZ(360deg);
  212. }
  213. .sales {
  214. font-size: #{20upx};
  215. line-height: 1;
  216. color: #999999;
  217. margin-top: #{5upx};
  218. padding-left: #{5upx};
  219. }
  220. .goods-cart {
  221. width:#{56rpx};
  222. height:#{56rpx};
  223. /*position: absolute;*/
  224. /*top: 50%;*/
  225. /*left: 50%;*/
  226. border:none;
  227. }
  228. .origin-price {
  229. font-size: 21upx;
  230. color: #999999;
  231. text-decoration:line-through;
  232. }
  233. </style>