promotionList.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <!-- 促销列表 -->
  3. <view class="index-product-wrapper" :class="iSshowH?'on':''" :style="'margin-top:'+mbConfig*2+'rpx;'" v-show="!isSortType">
  4. <view class="nav-bd" :style="{justifyContent:titleConfig===0?'flex-start':titleConfig===1?'space-around':'flex-end'}">
  5. <view class="item" v-for="(item,index) in explosiveMoney" :index="index" @click="ProductNavTab(item.link.activeVal,index)">
  6. <view class="txt" :style="{ 'color': index==ProductNavindex ? themeColor : txtColor }">{{item.chiild[0].val}}</view>
  7. <view class="label" :style="{ 'background': index==ProductNavindex ? themeColor : '','color': index==ProductNavindex ? '#fff' : infoColor }">{{item.chiild[1].val}}</view>
  8. </view>
  9. </view>
  10. <view class="list-box animated" :class='tempArr.length > 0?"fadeIn on":""'>
  11. <view class="item" v-for="(item,index) in tempArr" :key="index" @click="goDetail(item)">
  12. <view class="pictrue">
  13. <span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor" v-if="item.activity && item.activity.type === '1'">秒杀</span>
  14. <span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor" v-if="item.activity && item.activity.type === '2'">砍价</span>
  15. <span class="pictrue_log pictrue_log_class" :style="'background-color:'+labelColor" v-if="item.activity && item.activity.type === '3'">拼团</span>
  16. <image :src="item.image" mode="aspectFill"></image>
  17. </view>
  18. <view class="text-info">
  19. <view class="title line1" v-if="titleShow">{{item.store_name}}</view>
  20. <!-- #ifdef H5 || APP-PLUS -->
  21. <slot name="center" :item="item"></slot>
  22. <!-- #endif -->
  23. <!-- #ifdef MP -->
  24. <slot name="center{{index}}"></slot>
  25. <!-- #endif -->
  26. <view class="old-price" v-if="opriceShow"><text>¥</text>{{item.ot_price}}</view>
  27. <view class="price" :style="{color:fontColor}">
  28. <view v-if="priceShow">
  29. <text>¥</text>{{item.price}}
  30. </view>
  31. <view class="txt" :style="'border:1px solid '+labelColor+';color:'+labelColor" :class="priceShow?'':'on'" v-if="item.checkCoupon && couponShow">券</view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import {
  40. getGroomList
  41. } from '@/api/store.js';
  42. export default {
  43. name: 'promotionList',
  44. props: {
  45. dataConfig: {
  46. type: Object,
  47. default: () => {}
  48. },
  49. isSortType:{
  50. type: String | Number,
  51. default:0
  52. }
  53. },
  54. data() {
  55. return {
  56. tempArr: [],
  57. iSshowH: false,
  58. ProductNavindex: 0,
  59. explosiveMoney: this.dataConfig.tabConfig.list,
  60. numConfig: this.dataConfig.numConfig.val,
  61. // imgStyle: this.dataConfig.imgStyle.type,
  62. mbConfig: this.dataConfig.mbConfig.val,
  63. themeColor: this.dataConfig.themeColor.color[0].item,
  64. titleShow: this.dataConfig.titleShow.val, //标题是否显示
  65. opriceShow: this.dataConfig.opriceShow.val, //原价是否显示
  66. priceShow: this.dataConfig.priceShow.val, //价格是否显示
  67. couponShow: this.dataConfig.couponShow.val,//优惠券标签是否显示
  68. titleConfig: this.dataConfig.titleConfig.type, //标题位置
  69. fontColor: this.dataConfig.fontColor.color?this.dataConfig.fontColor.color[0].item:'',
  70. labelColor: this.dataConfig.labelColor.color?this.dataConfig.labelColor.color[0].item:'',
  71. txtColor: this.dataConfig.txtColor.color?this.dataConfig.txtColor.color[0].item:'',
  72. infoColor: this.dataConfig.infoColor.color?this.dataConfig.infoColor.color[0].item:'',
  73. goodType: this.dataConfig.tabConfig.list[0].link.activeVal || 3,
  74. loadend: false,
  75. loading: false,
  76. limit: this.$config.LIMIT,
  77. page:1
  78. };
  79. },
  80. created() {
  81. },
  82. mounted(){
  83. this.getGroomList();
  84. },
  85. methods: {
  86. // 促销列表的点击事件;
  87. changeTab(type) {
  88. this.goodType = type;
  89. this.tempArr = [];
  90. this.page = 1;
  91. this.loadend = false;
  92. let onloadH = true;
  93. this.getGroomList(onloadH);
  94. },
  95. // 精品推荐
  96. getGroomList(onloadH) {
  97. let that = this;
  98. let type = that.goodType == 0?3:that.goodType;
  99. if (that.loadend) return false;
  100. if (that.loading) return false;
  101. if (onloadH) {
  102. that.$set(that, 'iSshowH', true);
  103. }
  104. getGroomList(type, {
  105. page: that.page,
  106. limit: this.numConfig
  107. })
  108. .then(({
  109. data
  110. }) => {
  111. that.$set(that, 'iSshowH', false);
  112. let maxPage = Math.ceil(this.numConfig / this.limit);
  113. let list = data.list,
  114. loadend = list.length < that.limit || that.page >= maxPage;
  115. let tempArr = that.$util.SplitArray(list, that.tempArr);
  116. that.$set(that, 'tempArr', tempArr.slice(0, this.numConfig));
  117. that.loadend = loadend;
  118. that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  119. that.page = that.page + 1;
  120. that.loading = false;
  121. })
  122. .catch(res => {
  123. that.loading = false;
  124. that.loadTitle = '加载更多';
  125. });
  126. },
  127. // 首发新品切换
  128. ProductNavTab(type, index) {
  129. this.ProductNavindex = index;
  130. this.changeTab(type);
  131. },
  132. goDetail(item){
  133. this.$emit('detail',item);
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss">
  139. .index-product-wrapper {
  140. margin: 30rpx 20rpx 0 20rpx;
  141. &.on {
  142. min-height: 1500rpx;
  143. }
  144. .nav-bd {
  145. display: flex;
  146. align-items: center;
  147. margin-top: 30rpx;
  148. .item {
  149. display: flex;
  150. flex-direction: column;
  151. align-items: center;
  152. justify-content: center;
  153. width: 25%;
  154. &.on{
  155. border-radius: 0;
  156. }
  157. .txt {
  158. font-size: 32rpx;
  159. color: #282828;
  160. }
  161. .label {
  162. display: flex;
  163. align-items: center;
  164. justify-content: center;
  165. width: 124rpx;
  166. height: 32rpx;
  167. margin-top: 5rpx;
  168. font-size: 24rpx;
  169. color: #999;
  170. border-radius: 16rpx;
  171. }
  172. }
  173. }
  174. .list-box {
  175. display: flex;
  176. flex-wrap: wrap;
  177. justify-content: space-between;
  178. margin-top: 30rpx;
  179. .item {
  180. width: 345rpx;
  181. margin-bottom: 20rpx;
  182. background-color: #fff;
  183. border-radius: 20rpx;
  184. overflow: hidden;
  185. position: relative;
  186. .pictrue_log {
  187. width: 92rpx;
  188. height: 44rpx;
  189. font-size: 26rpx;
  190. line-height: 44rpx;
  191. }
  192. image {
  193. width: 100%;
  194. height: 346rpx;
  195. display: block;
  196. }
  197. .text-info {
  198. padding: 10rpx 20rpx 15rpx;
  199. .title {
  200. color: #222222;
  201. }
  202. .old-price {
  203. margin-top: 4rpx;
  204. font-size: 26rpx;
  205. color: #AAAAAA;
  206. text-decoration: line-through;
  207. text {
  208. margin-right: 2px;
  209. font-size: 20rpx;
  210. }
  211. }
  212. .price {
  213. display: flex;
  214. align-items: flex-end;
  215. font-size: 36rpx;
  216. font-weight: 550;
  217. text {
  218. padding-bottom: 4rpx;
  219. font-size: 26rpx;
  220. font-weight: normal;
  221. }
  222. .txt {
  223. display: flex;
  224. align-items: center;
  225. justify-content: center;
  226. width: 28rpx;
  227. height: 28rpx;
  228. margin-left: 15rpx;
  229. margin-bottom: 10rpx;
  230. border-radius: 4rpx;
  231. font-size: 20rpx;
  232. font-weight: normal;
  233. &.on{
  234. margin-left: 0;
  235. }
  236. }
  237. }
  238. }
  239. }
  240. &.on {
  241. display: flex;
  242. }
  243. }
  244. }
  245. </style>