app-product-list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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="theme"
  18. :sign="sign"
  19. ></app-member-price>
  20. </view>
  21. <!-- 超级会员卡 -->
  22. <view class="app-sup-vip" v-if="item.vip_card_appoint && 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" :style="{'color': sign === 'gift' ?theme.color : ''}" :class="sign === 'gift' ? theme + '-color' : ''">{{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. :style="{'background-color': item.buy_goods_auth ? theme.background : '#999999'}"
  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="theme"
  63. :sign="sign"
  64. ></app-member-price>
  65. </view>
  66. <!-- 超级会员卡 -->
  67. <view class="app-sup-vip" v-if="item.vip_card_appoint && 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" :style="{'color': sign !== 'gift' ?theme.color : ''}" :class="sign === 'gift' ? theme + '-color' : ''">
  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" :goods="item"></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" :goods="item"></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" :style="{'color': theme.color}">
  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-if="attrGoods.attrShow || attrGoods.goods"
  122. v-model="attrGoods.attrShow"
  123. :checked="attrGoods.select"
  124. :goods="attrGoods.goods"
  125. :theme="theme"
  126. @check="checkClick"
  127. ></u-attr>
  128. </view>
  129. </template>
  130. <script>
  131. import { mapState } from "vuex";
  132. import appAttr from '../../../components/page-component/app-attr/app-attr.vue';
  133. import uAttr from '../../../components/page-component/goods/u-attr.vue';
  134. export default {
  135. name: 'product-list',
  136. props: {
  137. goods_list: Array,
  138. theme: [Object,String],
  139. is_name: {
  140. type: Boolean,
  141. default: true,
  142. },
  143. is_cart: {
  144. type: Boolean,
  145. default: true,
  146. },
  147. sign: String,
  148. listStyle: {
  149. type: Boolean,
  150. default: false
  151. },
  152. isShowAttr: {
  153. type: Boolean,
  154. default: true
  155. },
  156. },
  157. computed: {
  158. ...mapState({
  159. appImg: state => state.mallConfig.__wxapp_img.mall,
  160. isShowCart: state => state.mallConfig.mall.setting.is_show_cart,
  161. isShowGoodsName: state => state.mallConfig.mall.setting.is_show_goods_name,
  162. isShowSalesNum: state => state.mallConfig.mall.setting.is_show_sales_num,
  163. appSetting: state => state.mallConfig.mall.setting,
  164. isListUnderlinePrice: state => state.mallConfig.mall.setting.is_list_underline_price
  165. })
  166. },
  167. methods: {
  168. routeGo(data) {
  169. this.$emit('routeGo', data);
  170. },
  171. specification(goods) {
  172. this.attrGoods.select = null;
  173. if (this.isShowAttr) {
  174. this.attrGoods.goods = goods;
  175. this.attrGoods.attrShow = true;
  176. } else {
  177. uni.showLoading({
  178. text: '',
  179. mask: true
  180. });
  181. this.$request({
  182. url: this.$api.goods.attr,
  183. data: {
  184. id: goods.id,
  185. mch_id: goods.mch_id
  186. }
  187. }).then(e => {
  188. uni.hideLoading();
  189. if (e.code === 0) {
  190. this.attrGoods.goods = Object.assign(goods, e.data);
  191. this.attrGoods.attrShow = true;
  192. } else {
  193. uni.showToast({
  194. title: e.msg,
  195. icon: 'none'
  196. })
  197. }
  198. })
  199. }
  200. },
  201. checkClick({item}) {
  202. this.attrGoods.select = item;
  203. }
  204. },
  205. data() {
  206. return {
  207. attrGoods: {
  208. goods: null,
  209. attrShow: 0,
  210. select: null,
  211. disable: 'disable'
  212. }
  213. }
  214. },
  215. components: {
  216. 'app-attr': appAttr,
  217. uAttr
  218. }
  219. }
  220. </script>
  221. <style scoped lang="scss">
  222. .product-list {
  223. position: relative;
  224. .u-goods {
  225. margin-top: #{15upx};
  226. background-color: #ffffff;
  227. width: #{344upx};
  228. border-radius: #{15upx};
  229. }
  230. }
  231. .list-padding {
  232. padding: #{0 20upx};
  233. }
  234. /*图片名字*/
  235. .image-name {
  236. width: 100%;
  237. border-top-left-radius: #{15upx};
  238. border-top-right-radius: #{15upx};
  239. position: relative;
  240. .out-dialog {
  241. border-top-left-radius: #{15upx};
  242. border-top-right-radius: #{15upx};
  243. width: #{344upx};
  244. height: #{344upx};
  245. position: absolute;
  246. top: 0;
  247. z-index: 10;
  248. left: 0;
  249. background-color: rgba(0,0,0,.5);
  250. image {
  251. width: #{344upx};
  252. height: #{344upx};
  253. }
  254. }
  255. .image {
  256. width: 100%;
  257. height: #{344upx};
  258. border-top-left-radius: #{15upx};
  259. border-top-right-radius: #{15upx};
  260. }
  261. .name {
  262. font-size: #{26upx};
  263. color: #353535;
  264. padding: #{0 24upx};
  265. margin-top: #{20upx};
  266. line-height: #{36upx};
  267. }
  268. }
  269. .content-name {
  270. height: calc(100% - #{426upx});
  271. }
  272. .content-no {
  273. height: calc(100% - #{384upx});
  274. }
  275. /*复杂内容*/
  276. .content {
  277. padding: #{0 24upx};
  278. .price-total {
  279. margin: #{16upx 0 30upx 0};
  280. &.exchange {
  281. margin-top: #{6upx};
  282. margin-bottom: #{16upx};
  283. }
  284. .sales {
  285. font-size: #{20rpx};
  286. margin-left:#{12rpx};
  287. }
  288. .sales-box {
  289. color: #999999;
  290. .sales {
  291. margin-left: 0;
  292. }
  293. }
  294. .price {
  295. font-size: #{28rpx};
  296. }
  297. }
  298. /*会员价组件*/
  299. .member-price {
  300. margin-top: #{12upx};
  301. }
  302. /*超级会员卡组件*/
  303. .app-sup-vip {
  304. margin-top: #{9upx};
  305. }
  306. }
  307. /*默认文字颜色*/
  308. .default-color {
  309. color: #ff4544;
  310. }
  311. .cart-box {
  312. width: #{92upx};
  313. height: #{92upx};
  314. position: absolute;
  315. padding: #{32upx};
  316. right: #{-24rpx};
  317. top: #{-60rpx};
  318. }
  319. .goods-cart {
  320. width: #{28rpx};
  321. height: #{28rpx};
  322. }
  323. .f-swipe-content {
  324. background-color: #ffffff;
  325. .f-item {
  326. padding: 24upx;
  327. border-bottom: 1upx solid #e2e2e2;
  328. position: relative;
  329. .f-img {
  330. width: 200upx;
  331. height: 200upx;
  332. border-radius: 23upx;
  333. margin-right: 24upx;
  334. }
  335. .f-out-dialog {
  336. width: 200upx;
  337. height: 200upx;
  338. border-radius: 23upx;
  339. margin-right: 24upx;
  340. position: absolute;
  341. z-index: 10;
  342. background-color: rgba(0,0,0,.5);
  343. image {
  344. width: #{200upx};
  345. height: #{200upx};
  346. }
  347. }
  348. .f-content {
  349. width: 478upx;
  350. }
  351. .f-title {
  352. font-size: 26upx;
  353. line-height: 36upx;
  354. color: #353535;
  355. }
  356. .f-invalid {
  357. width: 128upx;
  358. height: 42upx;
  359. line-height: 42upx;
  360. background-color: #f7f7f7;
  361. padding: 0 27upx 0 18upx;
  362. >text {
  363. font-size: 23upx;
  364. color: #999999;
  365. }
  366. >image {
  367. width: 24upx;
  368. height: 24upx;
  369. }
  370. }
  371. .f-low-stock {
  372. width: 148upx;
  373. height: 42upx;
  374. line-height: 42upx;
  375. background-color: #ffecec;
  376. padding: 0 27upx 0 18upx;
  377. >text {
  378. font-size: 23upx;
  379. color: #ff4544;
  380. }
  381. >image {
  382. width: 24upx;
  383. height: 24upx;
  384. }
  385. }
  386. .f-low-price {
  387. height: 42upx;
  388. display: inline-block;
  389. background-color: #ffecec;
  390. padding: 0 27upx 0 18upx;
  391. position: relative;
  392. >text {
  393. font-size: 23upx;
  394. color: #ff4544;
  395. }
  396. >image {
  397. width: 24upx;
  398. margin-right: 14upx;
  399. height: 24upx;
  400. }
  401. }
  402. .f-cat-icon {
  403. width: 56upx;
  404. height: 56upx;
  405. }
  406. .f-price {
  407. font-size: 24upx;
  408. margin-top: 12upx;
  409. }
  410. .f-scale {
  411. font-size: 21upx;
  412. color: #b0b0b0;
  413. }
  414. }
  415. }
  416. .origin-price {
  417. font-size: 21upx;
  418. color: #999999;
  419. text-decoration:line-through;
  420. }
  421. </style>