goodList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <template>
  2. <!-- 商品列表 -->
  3. <view v-show="!isSortType" :style="{padding:'0 '+prConfig+'px'}">
  4. <view class="index-product-wrapper" :class="bgStyle===0?'':'borderRadius15'"
  5. :style="{ marginTop: mbConfig*2 + 'rpx', background: themeColor }" v-if="tempArr.length">
  6. <!-- 单列 -->
  7. <block v-if="itemStyle == 0">
  8. <view class="list-box listA" :class="tempArr.length > 0 ? 'fadeIn on' : ''">
  9. <view class="item" :class="conStyle?'borderRadius15':''" v-for="(item, index) in tempArr"
  10. :key="index" @click="goDetail(item)">
  11. <view class="pictrue">
  12. <span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor"
  13. v-if="item.activity && item.activity.type === '1'">秒杀</span>
  14. <span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor"
  15. v-if="item.activity && item.activity.type === '2'">砍价</span>
  16. <span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor"
  17. v-if="item.activity && item.activity.type === '3'">拼团</span>
  18. <image :src="item.image" mode="aspectFill"></image>
  19. </view>
  20. <view class="text-info text-add">
  21. <view>
  22. <view class="title line2" v-if="titleShow">{{ item.store_name }}</view>
  23. <slot name="center"></slot>
  24. <view class="old-price" v-if="opriceShow" :style="'color:'+fontColor">
  25. <text>¥</text>
  26. {{ item.ot_price }}
  27. </view>
  28. </view>
  29. <view class="price" :style="'color:'+fontColor">
  30. <view v-if="priceShow">
  31. <text>¥</text>
  32. {{ item.price }}
  33. </view>
  34. <view class="txt" :style="'border:1px solid '+labelColor+';color:'+labelColor"
  35. :class="priceShow?'':'on'" v-if="item.checkCoupon && couponShow">券</view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </block>
  41. <!-- 两列 -->
  42. <block v-if="itemStyle == 1">
  43. <view class="list-box listC" :class="tempArr.length > 0 ? 'fadeIn on' : ''">
  44. <view class="item" :class="conStyle?'borderRadius15':''" v-for="(item, index) in tempArr"
  45. :key="index" @click="goDetail(item)">
  46. <view class="pictrue">
  47. <span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor"
  48. v-if="item.activity && item.activity.type === '1'">秒杀</span>
  49. <span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor"
  50. v-if="item.activity && item.activity.type === '2'">砍价</span>
  51. <span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor"
  52. v-if="item.activity && item.activity.type === '3'">拼团</span>
  53. <image :src="item.image" mode="aspectFill"></image>
  54. </view>
  55. <view class="text-info">
  56. <view class="title line1" v-if="titleShow">{{ item.store_name }}</view>
  57. <slot name="center"></slot>
  58. <view class="old-price" v-if="opriceShow" :style="'color:'+fontColor">
  59. <text>¥</text>
  60. {{ item.ot_price }}
  61. </view>
  62. <view class="price" :style="'color:'+fontColor">
  63. <view v-if="priceShow">
  64. <text>¥</text>
  65. {{ item.price }}
  66. </view>
  67. <view class="txt" :style="'border:1px solid '+labelColor+';color:'+labelColor"
  68. :class="priceShow?'':'on'" v-if="item.checkCoupon && couponShow">券</view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </block>
  74. <!-- 三列 -->
  75. <block v-if="itemStyle == 2">
  76. <view class="list-box listB" :class="tempArr.length > 0 ? 'fadeIn on' : ''">
  77. <view class="item" :class="conStyle?'borderRadius15':''" v-for="(item, index) in tempArr"
  78. :key="index" @click="goDetail(item)">
  79. <view class="pictrue">
  80. <span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor"
  81. v-if="item.activity && item.activity.type === '1'">秒杀</span>
  82. <span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor"
  83. v-if="item.activity && item.activity.type === '2'">砍价</span>
  84. <span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor"
  85. v-if="item.activity && item.activity.type === '3'">拼团</span>
  86. <image :src="item.image" mode="aspectFill"></image>
  87. </view>
  88. <view class="text-info text-add">
  89. <view>
  90. <view class="title line1" v-if="titleShow">{{ item.store_name }}</view>
  91. <slot name="center"></slot>
  92. <view class="old-price" v-if="opriceShow">
  93. <text>¥</text>
  94. {{ item.ot_price }}
  95. </view>
  96. </view>
  97. <view class="price" :style="'color:'+fontColor">
  98. <view v-if="priceShow">
  99. <text>¥</text>
  100. {{ item.price }}
  101. </view>
  102. <view class="txt" :style="'border:1px solid '+labelColor+';color:'+labelColor"
  103. :class="priceShow?'':'on'" v-if="item.checkCoupon && couponShow">券</view>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. </block>
  109. </view>
  110. <!-- 大图 -->
  111. <block v-if="itemStyle == 3 && tempArr.length" :style="{ marginTop: mbConfig + 'rpx' }">
  112. <view class="listBig" :class="bgStyle===0?'':'borderRadius15'" :style="{ background: themeColor }">
  113. <view class="itemBig" :class="conStyle?'borderRadius15':''" v-for="(item,index) in tempArr" :key="index"
  114. @click="goDetail(item)">
  115. <view class="img-box">
  116. <span class="pictrue_log_big pictrue_log_class" :style="'background-color:'+labelColor"
  117. v-if="item.activity && item.activity.type === '1'">秒杀</span>
  118. <span class="pictrue_log_big pictrue_log_class" :style="'background-color:'+labelColor"
  119. v-if="item.activity && item.activity.type === '2'">砍价</span>
  120. <span class="pictrue_log_big pictrue_log_class" :style="'background-color:'+labelColor"
  121. v-if="item.activity && item.activity.type === '3'">拼团</span>
  122. <image :src="item.recommend_image" mode="aspectFill" v-if="item.recommend_image"></image>
  123. <image :src="item.image" mode="aspectFill" v-else></image>
  124. </view>
  125. <view class="name line2"><span class="coupon"
  126. :style="'border:1px solid '+labelColor+';color:'+labelColor"
  127. v-if="item.checkCoupon && couponShow">券</span><span
  128. v-if="titleShow">{{item.store_name}}</span></view>
  129. <slot name="center"></slot>
  130. <view class="price" :style="'color:'+fontColor"><span v-if="priceShow">¥<span
  131. class="num">{{item.price}}</span></span><span class="old-price"
  132. v-if="opriceShow">¥{{item.ot_price}}</span></view>
  133. </view>
  134. </view>
  135. </block>
  136. </view>
  137. </template>
  138. <script>
  139. import {
  140. getProductslist
  141. } from '@/api/store.js';
  142. export default {
  143. name: 'goodList',
  144. props: {
  145. dataConfig: {
  146. type: Object,
  147. default: () => {}
  148. },
  149. isSortType: {
  150. type: String | Number,
  151. default: 0
  152. }
  153. },
  154. data() {
  155. return {
  156. tempArr: [],
  157. // scrollTop:0,
  158. mbConfig: this.dataConfig.mbConfig.val,
  159. numConfig: this.dataConfig.numConfig.val,
  160. themeColor: this.dataConfig.themeColor.color[0].item,
  161. itemStyle: this.dataConfig.itemStyle.type,
  162. sortType: this.dataConfig.goodsSort.type,
  163. type: this.dataConfig.tabConfig.tabVal || 0,
  164. selectId: this.dataConfig.selectConfig.activeValue,
  165. productIds: this.dataConfig.goodsList.ids || [],
  166. opriceShow: this.dataConfig.opriceShow.val, //商品原价
  167. priceShow: this.dataConfig.priceShow.val, //商品价格
  168. titleShow: this.dataConfig.titleShow.val, //商品名称
  169. couponShow: this.dataConfig.couponShow.val, //商品优惠券
  170. prConfig: this.dataConfig.prConfig.val, //左右边距
  171. bgStyle: this.dataConfig.bgStyle.type, //背景样式
  172. conStyle: this.dataConfig.conStyle.type, //内容样式
  173. fontColor: this.dataConfig.fontColor.color ? this.dataConfig.fontColor.color[0].item : '',
  174. labelColor: this.dataConfig.labelColor.color ? this.dataConfig.labelColor.color[0].item : ''
  175. };
  176. },
  177. created() {},
  178. mounted() {
  179. this.productslist();
  180. },
  181. // onPageScroll({scrollTop}) {
  182. // // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  183. // this.scrollTop = scrollTop;
  184. // },
  185. methods: {
  186. productslist() {
  187. let limit = this.$config.LIMIT;
  188. let data = {};
  189. if (this.type == 1) {
  190. data = {
  191. ids: this.productIds.join(','),
  192. };
  193. } else {
  194. data = {
  195. priceOrder: this.sortType == 2 ? 'desc' : '',
  196. salesOrder: this.sortType == 1 ? 'desc' : '',
  197. selectId: this.selectId[this.selectId.length - 1] || 0,
  198. limit: this.numConfig
  199. };
  200. }
  201. getProductslist(data).then(res => {
  202. this.tempArr = res.data;
  203. });
  204. },
  205. goDetail(item) {
  206. this.$emit('detail', item);
  207. }
  208. }
  209. };
  210. </script>
  211. <style lang="scss">
  212. .text-add {
  213. display: flex;
  214. flex-direction: column;
  215. justify-content: space-between;
  216. }
  217. .listBig {
  218. padding: 1px 20rpx 20rpx 20rpx;
  219. .borderRadius15 {
  220. image {
  221. border-radius: 20rpx 20rpx 0 0;
  222. }
  223. }
  224. .itemBig {
  225. width: 100%;
  226. margin-top: 20rpx;
  227. background-color: #fff;
  228. padding-bottom: 15rpx;
  229. .img-box {
  230. width: 100%;
  231. height: 284rpx;
  232. position: relative;
  233. .pictrue_log_big {
  234. border-radius: 20rpx 0 20rpx 0;
  235. }
  236. image {
  237. width: 100%;
  238. height: 100%;
  239. }
  240. }
  241. .name {
  242. font-size: 28rpx;
  243. font-weight: bold;
  244. margin-top: 16rpx;
  245. padding: 0 8px;
  246. .coupon {
  247. display: inline-block;
  248. text-align: center;
  249. width: 32rpx;
  250. border-radius: 4rpx;
  251. font-size: 20rpx;
  252. font-weight: normal;
  253. margin-right: 10rpx;
  254. }
  255. }
  256. .price {
  257. font-weight: bold;
  258. font-size: 12px;
  259. margin-top: 10rpx;
  260. padding: 0 8px;
  261. .num {
  262. font-size: 32rpx;
  263. margin-right: 10rpx;
  264. }
  265. .old-price {
  266. color: #aaa;
  267. font-weight: normal;
  268. text-decoration: line-through;
  269. }
  270. }
  271. }
  272. }
  273. .index-product-wrapper {
  274. .list-box {
  275. display: flex;
  276. flex-wrap: wrap;
  277. justify-content: space-between;
  278. padding: 20rpx 20rpx 0;
  279. .item {
  280. width: 345rpx;
  281. margin-bottom: 20rpx;
  282. background-color: #fff;
  283. overflow: hidden;
  284. position: relative;
  285. &.on {
  286. border-radius: 0;
  287. }
  288. .pictrue {
  289. width: 347rpx;
  290. height: 347rpx;
  291. }
  292. .pictrue_log {
  293. width: 92rpx;
  294. height: 44rpx;
  295. font-size: 26rpx;
  296. line-height: 44rpx;
  297. border-radius: 0 0 20rpx 0 !important;
  298. }
  299. image {
  300. width: 100%;
  301. // height: 346rpx;
  302. height: 100%;
  303. display: block;
  304. }
  305. .text-info {
  306. padding: 10rpx 20rpx 15rpx;
  307. .title {
  308. color: #222222;
  309. }
  310. .old-price {
  311. margin-top: 4rpx;
  312. font-size: 26rpx;
  313. color: #aaaaaa;
  314. text-decoration: line-through;
  315. text {
  316. margin-right: 2px;
  317. font-size: 20rpx;
  318. }
  319. }
  320. .price {
  321. display: flex;
  322. align-items: flex-end;
  323. font-size: 36rpx;
  324. font-weight: 550;
  325. text {
  326. padding-bottom: 4rpx;
  327. font-size: 26rpx;
  328. font-weight: normal;
  329. }
  330. .txt {
  331. display: flex;
  332. align-items: center;
  333. justify-content: center;
  334. width: 28rpx;
  335. height: 28rpx;
  336. margin-left: 15rpx;
  337. margin-bottom: 10rpx;
  338. border-radius: 4rpx;
  339. font-size: 20rpx;
  340. font-weight: normal;
  341. &.on {
  342. margin-left: 0;
  343. }
  344. }
  345. }
  346. }
  347. }
  348. &.on {
  349. display: flex;
  350. }
  351. &.listA {
  352. .item {
  353. display: flex;
  354. width: 100%;
  355. .pictrue {
  356. width: 220rpx;
  357. height: 220rpx;
  358. }
  359. .text-info {
  360. // width: 490rpx;
  361. flex: 1
  362. }
  363. }
  364. }
  365. &.listC {
  366. .item {
  367. width: 48.5%;
  368. }
  369. .pictrue {
  370. width: 100%;
  371. height: 345rpx;
  372. }
  373. }
  374. &.listB {
  375. justify-content: inherit;
  376. .item {
  377. width: 31.6%;
  378. margin-right: 16rpx;
  379. .pictrue {
  380. width: 100%;
  381. height: 220rpx;
  382. }
  383. &:nth-child(3n) {
  384. margin-right: 0;
  385. }
  386. }
  387. }
  388. }
  389. }
  390. </style>