goods-list.vue 7.6 KB

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