goods-list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <view class="goods-list">
  3. <view v-if="type == 'waterfall'" class="goods-waterfall">
  4. <router-link v-for="(item, index) in list" :key="index"
  5. :to="{ path: '/pages/goods_details/goods_details', query: { id: item.goods_id || item.id } }">
  6. <view :style="{ width: width }" class="item bg-white m-t-20">
  7. <view class="goods-img"><u-image :width="width" :height="width" :border-radius="10"
  8. :src="item.image"></u-image></view>
  9. <view class="goods-info">
  10. <view class="goods-name line-2">{{ item.name }}</view>
  11. <view class="price mt10 row">
  12. <price-format :color="colorConfig.primary" class="m-r-10" :first-size="34" :second-size="36"
  13. :subscript-size="26" :price="item.min_price" :weight="600"></price-format>
  14. <!-- <price-format class="muted" :firstSize="24" :secondSize="24" :subscript-size="24"
  15. line-through :price="item.market_price || item.price"></price-format> -->
  16. <!-- <text >售{{item.sales_actual+item.sales_virtual}}件</text> -->
  17. </view>
  18. <view class="tags d-flex align-items-center">
  19. <view class="item text-center jf"
  20. v-if="item.max_give_integral != 0 || item.min_give_integral != 0">
  21. 赠送:{{ item.min_give_integral == item.max_give_integral ? item.min_give_integral : item.min_give_integral + '~' + item.max_give_integral }}券
  22. </view>
  23. <view v-if="item.max_give_integral == 0 && item.min_give_integral == 0">
  24. <view class="item text-center jf"
  25. v-show="item.given_integral && item.given_integral > 0">
  26. 赠送:{{ item.given_integral }}券</view>
  27. </view>
  28. <text class="item text-center other">七天包换</text>
  29. </view>
  30. <view class="power-tags" v-show="item.use_energy > 0">
  31. 可用{{ ((item.min_price * item.use_energy) / 100 / appConfig.energyprice).toFixed(6) }}抵用券抵扣¥{{
  32. ((item.min_price * item.use_energy) / 100).toFixed(2)
  33. }}
  34. </view>
  35. </view>
  36. </view>
  37. </router-link>
  38. </view>
  39. <view v-if="type == 'double'" class="goods-double double flex flex-wrap row-between col-stretch p-l-20 p-r-20">
  40. <router-link class="m-t-20" v-for="(item, index) in list" :key="index"
  41. :to="{ path: '/pages/goods_details/goods_details', query: { id: item.goods_id || item.id } }">
  42. <view class="item bg-white" :style="{ width: width, height: '100%' }">
  43. <view class="goods-img"><u-image :width="width" :height="width" :border-radius="10"
  44. :src="item.image"></u-image></view>
  45. <view class="goods-info">
  46. <view class="goods-name line-2">{{ item.name }}</view>
  47. <view class="price mt10 row">
  48. <price-format :color="colorConfig.primary" class="m-r-10" :first-size="34" :second-size="26"
  49. :subscript-size="26" :price="item.activity_price || item.min_price"
  50. :weight="500"></price-format>
  51. <price-format class="muted" :firstSize="24" :secondSize="24" :subscript-size="24"
  52. line-through :price="item.market_price || item.price"></price-format>
  53. </view>
  54. <view class="tags d-flex align-items-center">
  55. <view class="item text-center jf"
  56. v-if="item.max_give_integral != 0 || item.min_give_integral != 0">
  57. 赠送:{{ item.min_give_integral == item.max_give_integral ? item.min_give_integral : item.min_give_integral + '~' + item.max_give_integral }}券
  58. </view>
  59. <view v-if="item.max_give_integral == 0 && item.min_give_integral == 0">
  60. <view class="item text-center jf"
  61. v-show="item.given_integral && item.given_integral > 0">
  62. 赠送:{{ item.given_integral }}券</view>
  63. </view>
  64. <text class="item text-center other">七天包换</text>
  65. </view>
  66. <view class="power-tags" v-show="item.use_energy > 0">
  67. 可用{{ ((item.min_price * item.use_energy) / 100 / appConfig.energyprice).toFixed(6) }}抵用券抵扣¥{{
  68. ((item.min_price * item.use_energy) / 100).toFixed(2)
  69. }}
  70. </view>
  71. </view>
  72. </view>
  73. </router-link>
  74. </view>
  75. <view v-if="type === 'one' && list.length" class="goods-one m-t-20">
  76. <router-link v-for="(item, index) in list" :key="index"
  77. :to="{ path: '/pages/goods_details/goods_details', query: { id: item.goods_id || item.id } }">
  78. <view class="item bg-white flex">
  79. <view class="goods-img"><u-image width="120rpx" height="120rpx" :border-radius="10"
  80. :src="item.image"></u-image></view>
  81. <view class="goods-info m-l-20 flex-1">
  82. <view class="goods-name line-2 m-b-10">{{ item.name }}</view>
  83. <view class="flex row-between m-t-10">
  84. <view class="price m-t-10 flex">
  85. <price-format :color="colorConfig.primary" class="m-r-10" :first-size="34"
  86. :second-size="26" :subscript-size="26" :price="item.min_price || item.price"
  87. :weight="500"></price-format>
  88. <price-format class="muted" :firstSize="24" :secondSize="24" :subscript-size="24"
  89. line-through :price="item.market_price || item.price"></price-format>
  90. </view>
  91. </view>
  92. <view class="power-tags" v-show="item.use_energy > 0">
  93. 可用{{ ((item.min_price * item.use_energy) / 100 / appConfig.energyprice).toFixed(6) }}抵用券抵扣¥{{
  94. ((item.min_price * item.use_energy) / 100).toFixed(2)
  95. }}
  96. </view>
  97. </view>
  98. </view>
  99. </router-link>
  100. </view>
  101. <view v-if="type.includes('row')" class="goods-row flex">
  102. <router-link class="item" v-for="(item, index) in list" :key="index"
  103. :to="{ path: '/pages/goods_details/goods_details', query: { id: item.goods_id || item.id } }">
  104. <view :class="[{ 'bg-white': showBg }]">
  105. <view class="goods-img"><u-image width="120rpx" height="120rpx" :border-radius="10"
  106. :src="item.image"></u-image></view>
  107. <view class="goods-info">
  108. <view class="goods-name line-1 sm">{{ item.name }}</view>
  109. <view class="price m-t-10 row">
  110. <price-format :color="colorConfig.primary" class="m-r-10" :first-size="28" :second-size="22"
  111. :subscript-size="22" :price="item.min_price" :weight="500"></price-format>
  112. <price-format class="muted" :firstSize="22" :secondSize="22" :subscript-size="22"
  113. line-through :price="item.market_price || item.price"></price-format>
  114. </view>
  115. <view class="power-tags" v-show="item.use_energy > 0">
  116. 可用{{ ((item.min_price * item.use_energy) / 100 / appConfig.energyprice).toFixed(6) }}抵用券抵扣¥{{
  117. ((item.min_price * item.use_energy) / 100).toFixed(2)
  118. }}
  119. </view>
  120. </view>
  121. <image v-if="index < 3 && type == 'row-hot'" class="paixu"
  122. :src="'/static/images/No.' + index + '.png'"></image>
  123. </view>
  124. </router-link>
  125. </view>
  126. <view v-if="type == 'new'" class="goods-new">
  127. <router-link v-for="(item, index) in list" :key="index"
  128. :to="{ path: '/pages/goods_details/goods_details', query: { id: item.goods_id || item.id } }">
  129. <view class="item flex" :class="[{ 'bg-white': showBg }]">
  130. <view class="goods-img"><u-image width="107rpx" height="107rpx" :border-radius="10"
  131. :src="item.image"></u-image></view>
  132. <view class="goods-info flex-1 m-l-20 flex-1">
  133. <view class="goods-name line-2">{{ item.name }}</view>
  134. <view class="price m-t-20 flex row-between">
  135. <view class="muted xxs">
  136. 原价
  137. <price-format :first-size="24" :second-size="24" :subscript-size="24"
  138. :price="item.market_price"></price-format>
  139. </view>
  140. <view class="muted xxs"></view>
  141. <!-- <view class="muted xxs">{{ item.sales_total }}人购买</view> -->
  142. </view>
  143. <view class="btn flex row-between m-t-20">
  144. <price-format :color="colorConfig.primary" class="m-r-10" :first-size="34" :second-size="26"
  145. :subscript-size="26" :price="item.min_price" :weight="500"></price-format>
  146. <button class="bg-primary br60 white btn" size="xs">去购买</button>
  147. </view>
  148. </view>
  149. </view>
  150. </router-link>
  151. </view>
  152. <view v-if="type == 'hot'" class="goods-hot">
  153. <router-link v-for="(item, index) in list" :key="index"
  154. :to="{ path: '/pages/goods_details/goods_details', query: { id: item.goods_id || item.id } }">
  155. <view class="item flex bg-white m-t-20">
  156. <view class="goods-img"><u-image :lazy-load="true" width="90rpx" height="90rpx" border-radius="6rpx"
  157. :src="item.image" /></view>
  158. <view class="goods-info m-l-20 flex-1">
  159. <view class="goods-name line-2 m-b-10">{{ item.name }}</view>
  160. <!-- <text class="sale br60 xxs">已有{{ item.sales_total }}人购买</text> -->
  161. <view class="row-between flex m-t-10">
  162. <view class="price m-t-10 flex">
  163. <price-format :color="colorConfig.primary" class="m-r-10" :first-size="34"
  164. :second-size="26" :subscript-size="26" :price="item.min_price"
  165. :weight="500"></price-format>
  166. <price-format class="muted" :firstSize="24" :secondSize="24" :subscript-size="24"
  167. line-through :price="item.market_price"></price-format>
  168. </view>
  169. <button class="bg-primary br60 white btn" size="xs">立即抢购</button>
  170. </view>
  171. </view>
  172. <image v-if="index < 3" class="paixu" :src="'/static/images/No.' + index + '.png'"></image>
  173. </view>
  174. </router-link>
  175. </view>
  176. <view v-if="type == 'activity'" class="goods-hot">
  177. <router-link v-for="(item, index) in list" :key="index"
  178. :to="{ path: '/pages/goods_details/goods_details', query: { id: item.goods_id || item.id } }">
  179. <view class="item flex bg-white m-t-20">
  180. <view class="goods-img"><u-image :lazy-load="true" width="90rpx" height="90rpx" border-radius="6rpx"
  181. :src="item.image" /></view>
  182. <view class="goods-info m-l-20 flex-1">
  183. <view class="goods-name line-2 m-b-10">{{ item.name }}</view>
  184. <text class="views br60 xxs">{{ item.views }}浏览量</text>
  185. <view class="row-between flex m-t-10">
  186. <view class="price m-t-10 flex">
  187. <price-format :color="colorConfig.primary" class="m-r-10" :first-size="34"
  188. :second-size="26" :subscript-size="26" :price="item.price"
  189. :weight="500"></price-format>
  190. <price-format class="muted" :firstSize="24" :secondSize="24" :subscript-size="24"
  191. line-through :price="item.market_price"></price-format>
  192. </view>
  193. <button class="bg-primary br60 white btn" size="xs">立即抢购</button>
  194. </view>
  195. </view>
  196. </view>
  197. </router-link>
  198. </view>
  199. </view>
  200. </template>
  201. <script>
  202. import {
  203. mapGetters
  204. } from 'vuex';
  205. export default {
  206. props: {
  207. type: {
  208. type: String,
  209. default: 'double'
  210. },
  211. list: {
  212. type: Array,
  213. default: () => []
  214. },
  215. isBargain: {
  216. type: Boolean,
  217. default: false
  218. },
  219. // 两行时有效
  220. width: {
  221. type: String,
  222. default: '347rpx'
  223. },
  224. showBg: {
  225. type: Boolean,
  226. default: true
  227. }
  228. },
  229. data() {
  230. return {};
  231. },
  232. computed: {
  233. ...mapGetters(['appConfig'])
  234. }
  235. };
  236. </script>
  237. <style lang="scss" scoped>
  238. .goods-list {
  239. .power-tags {
  240. font-size: 20rpx;
  241. color: #0eb5f1;
  242. margin: 20rpx auto 0;
  243. text-align: center;
  244. border-radius: 8rpx;
  245. background-color: #ddf6ff;
  246. height: 36rpx;
  247. line-height: 36rpx;
  248. white-space: nowrap;
  249. }
  250. .goods-waterfall {
  251. .item {
  252. width: 347rpx;
  253. border-radius: 10rpx;
  254. overflow: hidden;
  255. .goods-info {
  256. padding: 20rpx 10rpx;
  257. }
  258. .goods-name {
  259. color: #040404;
  260. font-weight: 600;
  261. font-size: 28rpx;
  262. }
  263. .price {
  264. margin: 6rpx auto;
  265. }
  266. .tags {
  267. font-size: 20upx;
  268. .item {
  269. width: auto;
  270. }
  271. .jf {
  272. border: 1px solid #ff0b0b;
  273. color: #ff0b0b;
  274. border-radius: 4rpx;
  275. padding: 0 6rpx;
  276. }
  277. .other {
  278. border: 1px solid #616161;
  279. color: #616161;
  280. border-radius: 4rpx;
  281. padding: 0 6rpx;
  282. margin-left: 10rpx;
  283. }
  284. }
  285. }
  286. }
  287. .goods-double {
  288. .item {
  289. width: 347rpx;
  290. border-radius: 10rpx;
  291. overflow: hidden;
  292. .goods-info {
  293. padding: 10rpx;
  294. .goods-name {
  295. font-weight: 600;
  296. line-height: 40rpx;
  297. }
  298. }
  299. }
  300. .tags {
  301. font-size: 20upx;
  302. .item {
  303. width: auto;
  304. }
  305. .jf {
  306. border: 1px solid #ff0b0b;
  307. color: #ff0b0b;
  308. border-radius: 4rpx;
  309. padding: 0 6rpx;
  310. }
  311. .other {
  312. border: 1px solid #616161;
  313. color: #616161;
  314. border-radius: 4rpx;
  315. padding: 0 6rpx;
  316. margin-left: 10rpx;
  317. }
  318. }
  319. }
  320. .goods-one .item {
  321. padding: 20rpx;
  322. &:not(:last-of-type) {
  323. margin-bottom: 20rpx;
  324. }
  325. }
  326. .goods-seckill .item {
  327. padding: 20rpx;
  328. }
  329. .goods-new .item {
  330. padding: 0 20rpx 20rpx;
  331. border-radius: 10rpx;
  332. }
  333. .goods-row {
  334. .item {
  335. position: relative;
  336. width: 120rpx;
  337. border-radius: 16rpx;
  338. overflow: hidden;
  339. &:not(:last-of-type) {
  340. margin-right: 20rpx;
  341. }
  342. .goods-info {
  343. padding: 10rpx;
  344. }
  345. }
  346. }
  347. .goods-hot {
  348. .item {
  349. position: relative;
  350. padding: 30rpx 20rpx;
  351. border-radius: 10rpx;
  352. .goods-info {
  353. width: 450rpx;
  354. .sale {
  355. padding: 4rpx 18rpx;
  356. color: #f79c0c;
  357. background-color: rgba(247, 156, 12, 0.1);
  358. }
  359. .views {
  360. padding: 4rpx 18rpx;
  361. color: #ff2c3c;
  362. background-color: rgba(237, 83, 73, 0.1);
  363. }
  364. }
  365. }
  366. }
  367. .goods-row,
  368. .goods-hot {
  369. .paixu {
  370. position: absolute;
  371. top: 0;
  372. left: 20rpx;
  373. width: 48rpx;
  374. height: 60rpx;
  375. }
  376. }
  377. }
  378. </style>