product-list.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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="themeObject" :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.discount"
  18. :discount="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" :class="theme+ '-m-text ' + theme">{{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" :class="theme">
  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 :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. }),
  67. themeObject:function() {
  68. return {
  69. back: this.theme + '-m-back ' + this.theme,
  70. theme: this.theme,
  71. color: this.theme + '-m-text ' + this.theme,
  72. sBack: this.theme + '-s-back ' + this.theme
  73. }
  74. }
  75. },
  76. methods: {
  77. specification(goods) {
  78. if (goods.sign === 'mch') {
  79. this.previewUrl = this.$api.mch.order_preview;
  80. this.submitUrl = this.$api.mch.order_submit;
  81. } else {
  82. this.previewUrl = '';
  83. this.submitUrl = '';
  84. }
  85. uni.showLoading({
  86. text: '',
  87. mask: true
  88. });
  89. this.$request({
  90. url: this.$api.goods.attr,
  91. data: {
  92. id: goods.id,
  93. mch_id: goods.mch_id
  94. }
  95. }).then(e => {
  96. uni.hideLoading();
  97. if (e.code === 0) {
  98. let data = Object.assign(goods, e.data);
  99. this.$emit('attr', this.previewUrl, this.submitUrl, goods.attr_groups, data);
  100. } else {
  101. uni.showToast({
  102. title: e.msg,
  103. icon: 'none'
  104. })
  105. }
  106. })
  107. },
  108. route_go(item) {
  109. // #ifndef MP-BAIDU
  110. if (item.video_url && this.getVideo == 1) {
  111. uni.navigateTo({
  112. url: `/pages/goods/video?goods_id=${item.id}&sign=${item.sign}`
  113. });
  114. } else {
  115. uni.navigateTo({
  116. url: item.page_url
  117. });
  118. }
  119. // #endif
  120. // #ifdef MP-BAIDU
  121. uni.navigateTo({
  122. url: item.page_url
  123. });
  124. // #endif
  125. },
  126. onAttr(data) {
  127. this.selectAttr = data;
  128. }
  129. }
  130. }
  131. </script>
  132. <style scoped lang="scss">
  133. .cover-pic {
  134. position: relative;
  135. border-radius: #{8upx};
  136. margin-right: #{20upx};
  137. }
  138. .out-dialog {
  139. width: #{150upx};
  140. height: #{150upx};
  141. position: absolute;
  142. top: 0;
  143. left: 0;
  144. z-index: 10;
  145. background-color: rgba(0,0,0,.5);
  146. image {
  147. width: #{150upx};
  148. height: #{150upx};
  149. }
  150. }
  151. .item {
  152. width: #{504upx};
  153. border-bottom: #{1upx} solid #e2e2e2;
  154. margin: #{20upx 0 0 0};
  155. }
  156. .cover-pic {
  157. width: #{150upx};
  158. height: #{150upx};
  159. border-radius: #{8upx};
  160. margin-right: #{20upx};
  161. position: relative;
  162. }
  163. .pic {
  164. width: #{150upx};
  165. height: #{150upx};
  166. }
  167. .out-dialog {
  168. width: #{150rpx};
  169. height: #{150rpx};
  170. position: absolute;
  171. top: 0;
  172. left: 0;
  173. z-index: 10;
  174. background-color: rgba(0,0,0,.5);
  175. image {
  176. width: #{150rpx};
  177. height: #{150rpx};
  178. }
  179. }
  180. .cont {
  181. width: #{334upx};
  182. }
  183. .name {
  184. font-size: 28upx;
  185. line-height: 38upx;
  186. color: #353535;
  187. margin-top: #{5upx};
  188. }
  189. .margin-vip {
  190. margin: #{8upx 0 0 0};
  191. }
  192. .price-but {
  193. margin-bottom: #{20upx};
  194. margin-top: #{8upx};
  195. }
  196. .price_content {
  197. font-size: #{28upx};
  198. line-height: 1;
  199. text-align: left;
  200. }
  201. .cart-box {
  202. width:#{56rpx};
  203. height:#{56rpx};
  204. border-radius: 50%;
  205. position: relative;
  206. overflow: hidden;
  207. transform: rotateZ(360deg);
  208. }
  209. .sales {
  210. font-size: #{20upx};
  211. line-height: 1;
  212. color: #999999;
  213. margin-top: #{5upx};
  214. padding-left: #{5upx};
  215. }
  216. .goods-cart {
  217. width:#{56rpx};
  218. height:#{56rpx};
  219. /*position: absolute;*/
  220. /*top: 50%;*/
  221. /*left: 50%;*/
  222. border:none;
  223. }
  224. .origin-price {
  225. font-size: 21upx;
  226. color: #999999;
  227. text-decoration:line-through;
  228. }
  229. </style>