goodList.vue 11 KB

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