promotion.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view class="">
  3. <view class="index-wrapper">
  4. <view class='wrapper' v-if="isShow && benefit.length">
  5. <view class='title acea-row row-between-wrapper'>
  6. <view class='text'>
  7. <view class='name line1'><text class="iconfont icon-cuxiaodanpin"></text>{{$t(titleInfo[0].val)}}</view>
  8. <view class='line1 txt-btn'>{{$t(titleInfo[1].val)}}</view>
  9. </view>
  10. <view class='more' @click="gopage(titleInfo[2].val)">{{$t(`更多`)}}<text class='iconfont icon-jiantou'></text>
  11. </view>
  12. </view>
  13. <promotionGood :benefit="benefit"></promotionGood>
  14. </view>
  15. <view class='wrapper' v-if="!isShow && isIframe && benefit.length">
  16. <view class='title acea-row row-between-wrapper'>
  17. <view class='text'>
  18. <view class='name line1'><text class="iconfont icon-cuxiaodanpin"></text>{{titleInfo[0].val}}</view>
  19. <view class='line1 txt-btn'>{{titleInfo[1].val}}</view>
  20. </view>
  21. <view class='more' @click="gopage(titleInfo[1].val)">{{$t(`更多`)}}<text class='iconfont icon-jiantou'></text>
  22. </view>
  23. </view>
  24. <promotionGood :benefit="benefit"></promotionGood>
  25. </view>
  26. <view class='wrapper' v-if="isIframe && !benefit.length">
  27. <view class='title acea-row row-between-wrapper'>
  28. <view class='text'>
  29. <view class='name line1'><text class="iconfont icon-cuxiaodanpin"></text>{{titleInfo[0].val}}</view>
  30. <view class='line1 txt-btn'>{{titleInfo[1].val}}</view>
  31. </view>
  32. <view class='more' @click="gopage(titleInfo[1].val)">{{$t(`更多`)}}<text class='iconfont icon-jiantou'></text>
  33. </view>
  34. </view>
  35. <view class="empty-img">{{$t(`促销单品,暂无数据`)}}</view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. let app = getApp()
  42. import {
  43. mapState
  44. } from 'vuex'
  45. import {
  46. goPage
  47. } from '@/libs/order.js'
  48. import {
  49. getHomeProducts
  50. } from '@/api/store.js';
  51. import promotionGood from '@/components/promotionGood/index.vue';
  52. export default {
  53. name: 'goodList',
  54. props: {
  55. dataConfig: {
  56. type: Object,
  57. default: () => {}
  58. }
  59. },
  60. components: {
  61. promotionGood
  62. },
  63. watch: {
  64. dataConfig: {
  65. immediate: true,
  66. handler(nVal, oVal) {
  67. if (nVal) {
  68. this.isShow = nVal.isShow.val;
  69. this.selectType = nVal.tabConfig.tabVal;
  70. this.$set(this, 'selectId', nVal.selectConfig.activeValue || '');
  71. this.$set(this, 'type', nVal.selectSortConfig.activeValue);
  72. this.salesOrder = nVal.goodsSort.type == 1 ? 'desc' : '';
  73. this.newsOrder = nVal.goodsSort.type == 2 ? 'news' : '';
  74. this.ids = nVal.ids ? nVal.ids.join(',') : '';
  75. this.numConfig = nVal.numConfig.val;
  76. this.titleInfo = nVal.titleInfo.list;
  77. this.productslist();
  78. }
  79. }
  80. }
  81. },
  82. created() {
  83. this.isIframe = app.globalData.isIframe;
  84. },
  85. mounted() {},
  86. data() {
  87. return {
  88. benefit: [],
  89. salesInfo: this.$t(`库存商品优惠促销活动`),
  90. name: this.$options.name,
  91. isShow: true,
  92. isIframe: app.globalData.isIframe,
  93. selectType: 0,
  94. selectId: '',
  95. salesOrder: '',
  96. newsOrder: '',
  97. ids: '',
  98. page: 1,
  99. limit: this.$config.LIMIT,
  100. type: '',
  101. numConfig: 0,
  102. titleInfo: []
  103. }
  104. },
  105. methods: {
  106. // 产品列表
  107. productslist: function() {
  108. let that = this;
  109. let data = {};
  110. if (that.selectType) {
  111. data = {
  112. page: that.page,
  113. limit: that.limit,
  114. type: that.type,
  115. ids: that.ids,
  116. selectType: that.selectType
  117. }
  118. } else {
  119. data = {
  120. page: that.page,
  121. limit: that.numConfig <= that.limit ? that.numConfig : that.limit,
  122. type: that.type,
  123. newsOrder: that.newsOrder,
  124. salesOrder: that.salesOrder,
  125. selectId: that.selectId,
  126. selectType: that.selectType
  127. }
  128. }
  129. getHomeProducts(data).then(res => {
  130. that.benefit = res.data.list;
  131. }).catch(err => {
  132. that.$util.Tips({
  133. title: err
  134. });
  135. });
  136. },
  137. gopage(url) {
  138. goPage().then(res => {
  139. uni.navigateTo({
  140. url: url
  141. })
  142. })
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss">
  148. .index-wrapper {
  149. background-color: $uni-bg-color;
  150. margin: $uni-index-margin-row $uni-index-margin-col 5rpx $uni-index-margin-col;
  151. border-radius: $uni-border-radius-index;
  152. // box-shadow: $uni-index-box-shadow;
  153. }
  154. .text {
  155. display: flex;
  156. .name {
  157. font-size: $uni-index-title-font-size;
  158. font-weight: bold;
  159. }
  160. .txt-btn {
  161. display: flex;
  162. align-items: flex-end;
  163. margin-bottom: 8rpx;
  164. margin-left: 12rpx;
  165. }
  166. }
  167. .empty-img {
  168. width: 690rpx;
  169. height: 300rpx;
  170. border-radius: 14rpx;
  171. margin: 26rpx auto 0 auto;
  172. background-color: #ccc;
  173. text-align: center;
  174. line-height: 300rpx;
  175. .iconfont {
  176. font-size: 50rpx;
  177. }
  178. }
  179. </style>