app-product-list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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. console.log(180)
  172. console.log(data)
  173. this.$emit('routeGo', data);
  174. },
  175. specification(goods) {
  176. this.attrGoods.select = null;
  177. if (this.isShowAttr) {
  178. this.attrGoods.goods = goods;
  179. this.attrGoods.attrShow = true;
  180. } else {
  181. uni.showLoading({
  182. text: '',
  183. mask: true
  184. });
  185. this.$request({
  186. url: this.$api.goods.attr,
  187. data: {
  188. id: goods.id,
  189. mch_id: goods.mch_id
  190. }
  191. }).then(e => {
  192. uni.hideLoading();
  193. if (e.code === 0) {
  194. this.attrGoods.goods = Object.assign(goods, e.data);
  195. this.attrGoods.attrShow = true;
  196. } else {
  197. uni.showToast({
  198. title: e.msg,
  199. icon: 'none'
  200. })
  201. }
  202. })
  203. }
  204. },
  205. checkClick(select) {
  206. this.attrGoods.select = select;
  207. }
  208. },
  209. data() {
  210. return {
  211. attrGoods: {
  212. goods: null,
  213. attrShow: 0,
  214. select: null
  215. }
  216. }
  217. },
  218. components: {
  219. 'app-attr': appAttr,
  220. uAttr
  221. }
  222. }
  223. </script>
  224. <style scoped lang="scss">
  225. .product-list {
  226. position: relative;
  227. .u-goods {
  228. margin-top: #{15upx};
  229. background-color: #ffffff;
  230. width: #{344upx};
  231. border-radius: #{15upx};
  232. }
  233. }
  234. .list-padding {
  235. padding: #{0 20upx};
  236. }
  237. /*图片名字*/
  238. .image-name {
  239. width: 100%;
  240. border-top-left-radius: #{15upx};
  241. border-top-right-radius: #{15upx};
  242. position: relative;
  243. .out-dialog {
  244. border-top-left-radius: #{15upx};
  245. border-top-right-radius: #{15upx};
  246. width: #{344upx};
  247. height: #{344upx};
  248. position: absolute;
  249. top: 0;
  250. z-index: 10;
  251. left: 0;
  252. background-color: rgba(0,0,0,.5);
  253. image {
  254. width: #{344upx};
  255. height: #{344upx};
  256. }
  257. }
  258. .image {
  259. width: 100%;
  260. height: #{344upx};
  261. border-top-left-radius: #{15upx};
  262. border-top-right-radius: #{15upx};
  263. }
  264. .name {
  265. font-size: #{26upx};
  266. color: #353535;
  267. padding: #{0 24upx};
  268. margin-top: #{20upx};
  269. line-height: #{36upx};
  270. }
  271. }
  272. .content-name {
  273. height: calc(100% - #{426upx});
  274. }
  275. .content-no {
  276. height: calc(100% - #{384upx});
  277. }
  278. /*复杂内容*/
  279. .content {
  280. padding: #{0 24upx};
  281. .price-total {
  282. margin: #{16upx 0 30upx 0};
  283. &.exchange {
  284. margin-top: #{6upx};
  285. margin-bottom: #{16upx};
  286. }
  287. .sales {
  288. font-size: #{20rpx};
  289. margin-left:#{12rpx};
  290. }
  291. .sales-box {
  292. color: #999999;
  293. .sales {
  294. margin-left: 0;
  295. }
  296. }
  297. .price {
  298. font-size: #{28rpx};
  299. }
  300. }
  301. /*会员价组件*/
  302. .member-price {
  303. margin-top: #{12upx};
  304. }
  305. /*超级会员卡组件*/
  306. .app-sup-vip {
  307. margin-top: #{9upx};
  308. }
  309. }
  310. /*默认文字颜色*/
  311. .default-color {
  312. color: #ff4544;
  313. }
  314. .cart-box {
  315. width: #{92upx};
  316. height: #{92upx};
  317. position: absolute;
  318. padding: #{32upx};
  319. right: #{-24rpx};
  320. top: #{-60rpx};
  321. }
  322. .goods-cart {
  323. width: #{28rpx};
  324. height: #{28rpx};
  325. }
  326. .f-swipe-content {
  327. background-color: #ffffff;
  328. .f-item {
  329. padding: 24upx;
  330. border-bottom: 1upx solid #e2e2e2;
  331. position: relative;
  332. .f-img {
  333. width: 200upx;
  334. height: 200upx;
  335. border-radius: 23upx;
  336. margin-right: 24upx;
  337. }
  338. .f-out-dialog {
  339. width: 200upx;
  340. height: 200upx;
  341. border-radius: 23upx;
  342. margin-right: 24upx;
  343. position: absolute;
  344. z-index: 10;
  345. background-color: rgba(0,0,0,.5);
  346. image {
  347. width: #{200upx};
  348. height: #{200upx};
  349. }
  350. }
  351. .f-content {
  352. width: 478upx;
  353. }
  354. .f-title {
  355. font-size: 26upx;
  356. line-height: 36upx;
  357. color: #353535;
  358. }
  359. .f-invalid {
  360. width: 128upx;
  361. height: 42upx;
  362. line-height: 42upx;
  363. background-color: #f7f7f7;
  364. padding: 0 27upx 0 18upx;
  365. >text {
  366. font-size: 23upx;
  367. color: #999999;
  368. }
  369. >image {
  370. width: 24upx;
  371. height: 24upx;
  372. }
  373. }
  374. .f-low-stock {
  375. width: 148upx;
  376. height: 42upx;
  377. line-height: 42upx;
  378. background-color: #ffecec;
  379. padding: 0 27upx 0 18upx;
  380. >text {
  381. font-size: 23upx;
  382. color: #ff4544;
  383. }
  384. >image {
  385. width: 24upx;
  386. height: 24upx;
  387. }
  388. }
  389. .f-low-price {
  390. height: 42upx;
  391. display: inline-block;
  392. background-color: #ffecec;
  393. padding: 0 27upx 0 18upx;
  394. position: relative;
  395. >text {
  396. font-size: 23upx;
  397. color: #ff4544;
  398. }
  399. >image {
  400. width: 24upx;
  401. margin-right: 14upx;
  402. height: 24upx;
  403. }
  404. }
  405. .f-cat-icon {
  406. width: 56upx;
  407. height: 56upx;
  408. }
  409. .f-price {
  410. font-size: 24upx;
  411. margin-top: 12upx;
  412. }
  413. .f-scale {
  414. font-size: 21upx;
  415. color: #b0b0b0;
  416. }
  417. }
  418. }
  419. .origin-price {
  420. font-size: 21upx;
  421. color: #999999;
  422. text-decoration:line-through;
  423. }
  424. </style>