goodList.vue 12 KB

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