app-product-list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <view :class="[!listStyle ? 'list-padding' : '', 'page-width', 'product-list', 'dir-top-nowrap']">
  3. <view class="f-swipe-content" @click="routeGo(item)" v-if="listStyle" v-for="(item, index) in goods_list" :key="item.id">
  4. <view class="f-item dir-left-nowrap" >
  5. <view class="f-out-dialog" v-if="item.goods_stock == 0 && appSetting.is_show_stock == '1'">
  6. <image :src="appSetting.is_use_stock == '1' ? appImg.plugins_out : appSetting.sell_out_pic"></image>
  7. </view>
  8. <image class="f-img" :src="item.cover_pic" :lazy-load="true" mode="aspectFill"></image>
  9. <!-- 此层wrap在此为必写的,否则可能会出现标题定位错误 -->
  10. <view class="f-content dir-top-wrap main-between">
  11. <text class="t-omit-two f-title">{{ item.name }}</text>
  12. <view>
  13. <!-- 会员价 -->
  14. <view class="member-price" v-if="item.is_level == 1 && item.is_negotiable != 1">
  15. <app-member-price
  16. :price="item.level_price"
  17. :theme="themeObject"
  18. :sign="sign"
  19. ></app-member-price>
  20. </view>
  21. <!-- 超级会员卡 -->
  22. <view class="app-sup-vip" v-if="item.vip_card_appoint.discount && item.is_negotiable != 1">
  23. <app-sup-vip
  24. :discount="item.vip_card_appoint.discount"
  25. :is_vip_card_user="item.vip_card_appoint.is_vip_card_user"
  26. ></app-sup-vip>
  27. </view>
  28. <view class="dir-left-nowrap main-between">
  29. <view class="dir-top-wrap main-between">
  30. <text class="f-price" :class="sign === 'gift' ? theme + '-color' : theme + '-m-text ' + theme">{{item.price_content}}</text>
  31. <text class="f-scale" v-if="item.is_negotiable != 1 && isShowSalesNum == 1">{{item.sales}}</text>
  32. </view>
  33. <view v-if="sign !== 'gift' && item.is_negotiable != 1 && isShowCart == 1 && item.goods_stock > 0">
  34. <image class="f-cat-icon"
  35. @click.stop="specification(item)"
  36. :class="theme +'-m-back ' + theme"
  37. src="/static/image/icon/cats.png"></image>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view v-if="!listStyle" class="page-width dir-left-wrap main-between" >
  45. <view @click="routeGo(item)"
  46. class="u-goods box-grow-0 dir-top-nowrap main-between"
  47. v-for="(item, index) in goods_list"
  48. :class="'index-'+index"
  49. :key="index">
  50. <view class="image-name dir-top-nowrap main-left" >
  51. <view class="out-dialog" v-if="item.goods_stock == 0 && appSetting.is_show_stock == '1'">
  52. <image :src="appSetting.is_use_stock == '1' ? appImg.plugins_out : appSetting.sell_out_pic"></image>
  53. </view>
  54. <image class="image" :src="item.cover_pic" :lazy-load="true" mode="aspectFill"></image>
  55. <view class="name t-omit-two" v-if="is_name && isShowGoodsName == 1">{{item.name}}</view>
  56. </view>
  57. <view class="content dir-top-nowrap main-right" :style="{height: is_name ? 'calc(100% - #{426rpx})': 'height: calc(100% - #{384rpx});'}" >
  58. <!-- 会员价 -->
  59. <view class="member-price" v-if="(item.is_level == 1 || (sign === 'exchange' && item.level_show != 0)) && item.is_negotiable != 1">
  60. <app-member-price
  61. :price="item.level_price"
  62. :theme="themeObject"
  63. :sign="sign"
  64. ></app-member-price>
  65. </view>
  66. <!-- 超级会员卡 -->
  67. <view class="app-sup-vip" v-if="item.vip_card_appoint.discount && item.is_negotiable != 1">
  68. <app-sup-vip
  69. :discount="item.vip_card_appoint.discount"
  70. :is_vip_card_user="item.vip_card_appoint.is_vip_card_user"
  71. ></app-sup-vip>
  72. </view>
  73. <!-- 价格 销量 -->
  74. <view v-if="sign !== 'exchange'"
  75. class="price-total page-width dir-left-nowrap main-between cross-bottom"
  76. >
  77. <view>
  78. <view class="price" :class="sign === 'gift' ? theme + '-color' : theme + '-m-text ' + theme">
  79. {{item.price_content}}
  80. </view>
  81. <view class="origin-price" v-if="isListUnderlinePrice == 1">
  82. ¥{{item.original_price}}
  83. </view>
  84. </view>
  85. <template v-if="sign === 'gift'">
  86. <text v-if="item.is_negotiable != 1" class="gray sales">{{item.sales}}</text>
  87. </template>
  88. <template v-else>
  89. <text v-if="item.is_negotiable != 1 && isShowSalesNum == 1" class="gray sales">{{item.sales}}</text>
  90. <view class="box-grow-1" style="position: relative;" v-if="item.is_negotiable != 1 && isShowCart == 1 && item.goods_stock > 0">
  91. <!-- #ifdef MP-ALIPAY -->
  92. <div class="cart-box" @click.stop="specification(item)" style="-webkit-background-origin: content-box;background-origin: content-box;">
  93. <app-cart-image class="goods-cart" :sign="sign" :theme="theme"></app-cart-image>
  94. </div>
  95. <!-- #endif -->
  96. <!-- #ifndef MP-ALIPAY -->
  97. <div class="cart-box" @click.stop="specification(item)">
  98. <app-cart-image class="goods-cart" :sign="sign" :theme="theme"></app-cart-image>
  99. </div>
  100. <!-- #endif -->
  101. </view>
  102. </template>
  103. </view>
  104. <view v-if="sign === 'exchange'" class="price-total exchange page-width">
  105. <template>
  106. <text class="price" :class="theme + '-m-text ' + theme">
  107. {{item.price_content}}
  108. </text>
  109. <view class="dir-left-nowrap cross-center sales-box box-grow-0">
  110. <view class="sales">{{item.sales}}</view>
  111. </view>
  112. <view class="dir-left-nowrap cross-center sales-box box-grow-0">
  113. <view class="sales">库存:{{item.goods_stock}}{{item.unit}}</view>
  114. </view>
  115. </template>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. <u-attr
  121. v-model="attrGoods.attrShow"
  122. :checked="attrGoods.select"
  123. :goods="attrGoods.goods"
  124. :theme-object="themeObject"
  125. @check="checkClick"
  126. ></u-attr>
  127. </view>
  128. </template>
  129. <script>
  130. import { mapState } from "vuex";
  131. import appAttr from '../../../components/page-component/app-attr/app-attr.vue';
  132. import uAttr from '../../../components/page-component/goods/u-attr.vue';
  133. export default {
  134. name: 'product-list',
  135. props: {
  136. goods_list: Array,
  137. theme: String,
  138. is_name: {
  139. type: Boolean,
  140. default: true,
  141. },
  142. is_cart: {
  143. type: Boolean,
  144. default: true,
  145. },
  146. sign: String,
  147. listStyle: {
  148. type: Boolean,
  149. default: false
  150. },
  151. isShowAttr: {
  152. type: Boolean,
  153. default: true
  154. },
  155. themeObject: {
  156. type: Object
  157. }
  158. },
  159. computed: {
  160. ...mapState({
  161. appImg: state => state.mallConfig.__wxapp_img.mall,
  162. isShowCart: state => state.mallConfig.mall.setting.is_show_cart,
  163. isShowGoodsName: state => state.mallConfig.mall.setting.is_show_goods_name,
  164. isShowSalesNum: state => state.mallConfig.mall.setting.is_show_sales_num,
  165. appSetting: state => state.mallConfig.mall.setting,
  166. isListUnderlinePrice: state => state.mallConfig.mall.setting.is_list_underline_price
  167. })
  168. },
  169. methods: {
  170. routeGo(data) {
  171. this.$emit('routeGo', data);
  172. },
  173. specification(goods) {
  174. this.attrGoods.select = null;
  175. if (this.isShowAttr) {
  176. this.attrGoods.goods = goods;
  177. this.attrGoods.attrShow = true;
  178. } else {
  179. uni.showLoading({
  180. text: '',
  181. mask: true
  182. });
  183. this.$request({
  184. url: this.$api.goods.attr,
  185. data: {
  186. id: goods.id,
  187. mch_id: goods.mch_id
  188. }
  189. }).then(e => {
  190. uni.hideLoading();
  191. if (e.code === 0) {
  192. this.attrGoods.goods = Object.assign(goods, e.data);
  193. this.attrGoods.attrShow = true;
  194. } else {
  195. uni.showToast({
  196. title: e.msg,
  197. icon: 'none'
  198. })
  199. }
  200. })
  201. }
  202. },
  203. checkClick(select) {
  204. this.attrGoods.select = select;
  205. }
  206. },
  207. data() {
  208. return {
  209. attrGoods: {
  210. goods: null,
  211. attrShow: 0,
  212. select: null
  213. }
  214. }
  215. },
  216. components: {
  217. 'app-attr': appAttr,
  218. uAttr
  219. }
  220. }
  221. </script>
  222. <style scoped lang="scss">
  223. .product-list {
  224. position: relative;
  225. .u-goods {
  226. margin-top: #{15upx};
  227. background-color: #ffffff;
  228. width: #{344upx};
  229. border-radius: #{15upx};
  230. }
  231. }
  232. .list-padding {
  233. padding: #{0 20upx};
  234. }
  235. /*图片名字*/
  236. .image-name {
  237. width: 100%;
  238. border-top-left-radius: #{15upx};
  239. border-top-right-radius: #{15upx};
  240. position: relative;
  241. .out-dialog {
  242. border-top-left-radius: #{15upx};
  243. border-top-right-radius: #{15upx};
  244. width: #{344upx};
  245. height: #{344upx};
  246. position: absolute;
  247. top: 0;
  248. z-index: 10;
  249. left: 0;
  250. background-color: rgba(0,0,0,.5);
  251. image {
  252. width: #{344upx};
  253. height: #{344upx};
  254. }
  255. }
  256. .image {
  257. width: 100%;
  258. height: #{344upx};
  259. border-top-left-radius: #{15upx};
  260. border-top-right-radius: #{15upx};
  261. }
  262. .name {
  263. font-size: #{26upx};
  264. color: #353535;
  265. padding: #{0 24upx};
  266. margin-top: #{20upx};
  267. line-height: #{36upx};
  268. }
  269. }
  270. .content-name {
  271. height: calc(100% - #{426upx});
  272. }
  273. .content-no {
  274. height: calc(100% - #{384upx});
  275. }
  276. /*复杂内容*/
  277. .content {
  278. padding: #{0 24upx};
  279. .price-total {
  280. margin: #{16upx 0 30upx 0};
  281. &.exchange {
  282. margin-top: #{6upx};
  283. margin-bottom: #{16upx};
  284. }
  285. .sales {
  286. font-size: #{20rpx};
  287. margin-left:#{12rpx};
  288. }
  289. .sales-box {
  290. color: #999999;
  291. .sales {
  292. margin-left: 0;
  293. }
  294. }
  295. .price {
  296. font-size: #{28rpx};
  297. }
  298. }
  299. /*会员价组件*/
  300. .member-price {
  301. margin-top: #{12upx};
  302. }
  303. /*超级会员卡组件*/
  304. .app-sup-vip {
  305. margin-top: #{9upx};
  306. }
  307. }
  308. /*默认文字颜色*/
  309. .default-color {
  310. color: #ff4544;
  311. }
  312. .cart-box {
  313. width: #{92upx};
  314. height: #{92upx};
  315. position: absolute;
  316. padding: #{32upx};
  317. right: #{-24rpx};
  318. top: #{-60rpx};
  319. }
  320. .goods-cart {
  321. width: #{28rpx};
  322. height: #{28rpx};
  323. }
  324. .f-swipe-content {
  325. background-color: #ffffff;
  326. .f-item {
  327. padding: 24upx;
  328. border-bottom: 1upx solid #e2e2e2;
  329. position: relative;
  330. .f-img {
  331. width: 200upx;
  332. height: 200upx;
  333. border-radius: 23upx;
  334. margin-right: 24upx;
  335. }
  336. .f-out-dialog {
  337. width: 200upx;
  338. height: 200upx;
  339. border-radius: 23upx;
  340. margin-right: 24upx;
  341. position: absolute;
  342. z-index: 10;
  343. background-color: rgba(0,0,0,.5);
  344. image {
  345. width: #{200upx};
  346. height: #{200upx};
  347. }
  348. }
  349. .f-content {
  350. width: 478upx;
  351. }
  352. .f-title {
  353. font-size: 26upx;
  354. line-height: 36upx;
  355. color: #353535;
  356. }
  357. .f-invalid {
  358. width: 128upx;
  359. height: 42upx;
  360. line-height: 42upx;
  361. background-color: #f7f7f7;
  362. padding: 0 27upx 0 18upx;
  363. >text {
  364. font-size: 23upx;
  365. color: #999999;
  366. }
  367. >image {
  368. width: 24upx;
  369. height: 24upx;
  370. }
  371. }
  372. .f-low-stock {
  373. width: 148upx;
  374. height: 42upx;
  375. line-height: 42upx;
  376. background-color: #ffecec;
  377. padding: 0 27upx 0 18upx;
  378. >text {
  379. font-size: 23upx;
  380. color: #ff4544;
  381. }
  382. >image {
  383. width: 24upx;
  384. height: 24upx;
  385. }
  386. }
  387. .f-low-price {
  388. height: 42upx;
  389. display: inline-block;
  390. background-color: #ffecec;
  391. padding: 0 27upx 0 18upx;
  392. position: relative;
  393. >text {
  394. font-size: 23upx;
  395. color: #ff4544;
  396. }
  397. >image {
  398. width: 24upx;
  399. margin-right: 14upx;
  400. height: 24upx;
  401. }
  402. }
  403. .f-cat-icon {
  404. width: 56upx;
  405. height: 56upx;
  406. }
  407. .f-price {
  408. font-size: 24upx;
  409. margin-top: 12upx;
  410. }
  411. .f-scale {
  412. font-size: 21upx;
  413. color: #b0b0b0;
  414. }
  415. }
  416. }
  417. .origin-price {
  418. font-size: 21upx;
  419. color: #999999;
  420. text-decoration:line-through;
  421. }
  422. </style>