promotionList.vue 7.2 KB

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