goodList.vue 11 KB

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