You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

195 lines
5.4 KiB

3 months ago
  1. <template>
  2. <view :data-theme="theme">
  3. <view class="navbar acea-row row-around">
  4. <view class="item acea-row row-center-wrapper" :class="{ on: navOn === 'usable' }" @click="onNav('usable')">未使用</view>
  5. <view class="item acea-row row-center-wrapper" :class="{ on: navOn === 'unusable' }" @click="onNav('unusable')">已使用/过期</view>
  6. </view>
  7. <view class='coupon-list' v-if="couponsList.length">
  8. <view class='item acea-row row-center-wrapper' v-for='(item,index) in couponsList' :key="index">
  9. <view class='money' :class="item.validStr==='unusable'||item.validStr==='overdue'||item.validStr==='notStart' ? 'moneyGray' : 'main_bg'">
  10. <view><text class='num':style="[{'font-size':item.money.length>=7?'42rpx':'60rpx'}]" >{{item.money?Number(item.money):''}}</text></view>
  11. <view class="pic-num">{{ item.minPrice?Number(item.minPrice):'' }}元可用</view>
  12. </view>
  13. <view class='text'>
  14. <view class='condition line2'>
  15. <span class="line-title" :class="item.validStr==='unusable'||item.validStr==='overdue'||item.validStr==='notStart' ? 'bg-color-huic' : 'bg-color-check'" v-if="item.useType === 1">通用</span>
  16. <span class="line-title" :class="item.validStr==='unusable'||item.validStr==='overdue'||item.validStr==='notStart' ? 'bg-color-huic' : 'bg-color-check'" v-else-if="item.useType === 2">商品</span>
  17. <span class="line-title" :class="item.validStr==='unusable'||item.validStr==='overdue'||item.validStr==='notStart' ? 'bg-color-huic' : 'bg-color-check'" v-else-if="item.useType === 3">品类</span>
  18. <span>{{item.name}}</span>
  19. </view>
  20. <view class='data acea-row row-between-wrapper'>
  21. <view>{{item.useStartTimeStr}}~{{item.useEndTimeStr}}</view>
  22. <view class='bnt' :class="item.validStr==='unusable'||item.validStr==='overdue'||item.validStr==='notStart'?'gray':'bg_color'">{{item.validStr | validStrFilter}}</view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class='loadingicon acea-row row-center-wrapper' v-if="couponsList.length">
  28. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  29. </view>
  30. <view class='noCommodity' v-if="!couponsList.length">
  31. <view class='pictrue'>
  32. <image :src="urlDomain+'crmebimage/perset/staticImg/noCoupon.png'"></image>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import {
  39. getUserCoupons
  40. } from '@/api/api.js';
  41. import {
  42. toLogin
  43. } from '@/libs/login.js';
  44. import {
  45. mapGetters
  46. } from "vuex";
  47. let app = getApp();
  48. export default {
  49. filters: {
  50. validStrFilter(status) {
  51. const statusMap = {
  52. 'usable': '可用',
  53. 'unusable': '已用',
  54. 'overdue': '过期',
  55. 'notStart': '未开始'
  56. }
  57. return statusMap[status]
  58. }
  59. },
  60. data() {
  61. return {
  62. urlDomain: this.$Cache.get("imgHost"),
  63. couponsList: [],
  64. loading: false,
  65. loadend: false,
  66. loadTitle: '加载更多',//提示语
  67. page: 1,
  68. limit: 20,
  69. navOn: 'usable',
  70. theme:app.globalData.theme,
  71. };
  72. },
  73. computed: mapGetters(['isLogin']),
  74. watch: {
  75. isLogin: {
  76. handler: function(newV, oldV) {
  77. if (newV) {
  78. this.getUseCoupons();
  79. }
  80. },
  81. deep: true
  82. }
  83. },
  84. onLoad() {
  85. if (this.isLogin) {
  86. this.getUseCoupons();
  87. } else {
  88. toLogin();
  89. }
  90. },
  91. methods: {
  92. onNav: function(type) {
  93. this.navOn = type;
  94. this.couponsList = [];
  95. this.page = 1;
  96. this.loadend = false;
  97. this.getUseCoupons();
  98. },
  99. /**
  100. * 获取领取优惠券列表
  101. */
  102. getUseCoupons: function() {
  103. let that = this;
  104. if(this.loadend) return false;
  105. if(this.loading) return false;
  106. getUserCoupons({ page: that.page, limit: that.limit, type: that.navOn}).then(res => {
  107. let list= res.data ? res.data.list : [],loadend=list.length < that.limit;
  108. let couponsList = that.$util.SplitArray(list, that.couponsList);
  109. that.$set(that,'couponsList',couponsList);
  110. that.loadend = loadend;
  111. that.loadTitle = loadend ? '我也是有底线的~' : '加载更多';
  112. that.page = that.page + 1;
  113. that.loading = false;
  114. }).catch(err=>{
  115. that.loading = false;
  116. that.loadTitle = '加载更多';
  117. });
  118. }
  119. },
  120. /**
  121. * 页面上拉触底事件的处理函数
  122. */
  123. onReachBottom: function () {
  124. this.getUseCoupons();
  125. }
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .navbar {
  130. position: fixed;
  131. top: 0;
  132. left: 0;
  133. width: 100%;
  134. height: 106rpx;
  135. background-color: #FFFFFF;
  136. z-index: 9;
  137. .item {
  138. border-top: 5rpx solid transparent;
  139. border-bottom: 5rpx solid transparent;
  140. font-size: 30rpx;
  141. color: #999999;
  142. &.on{
  143. @include tab_border_bottom(theme);
  144. @include main_color(theme);
  145. }
  146. }
  147. }
  148. .money {
  149. display: flex;
  150. flex-direction: column;
  151. justify-content: center;
  152. }
  153. .bg_color{
  154. @include main_bg_color(theme);
  155. }
  156. .pic-num {
  157. color: #ffffff;
  158. font-size: 24rpx;
  159. }
  160. .coupon-list {
  161. margin-top: 122rpx;
  162. }
  163. .coupon-list .item .text{
  164. height: 100%;
  165. }
  166. .coupon-list .item .text .condition{
  167. /* display: flex;
  168. align-items: center; */
  169. }
  170. .condition .line-title {
  171. width: 90rpx;
  172. height: 40rpx !important;
  173. line-height: 40rpx !important;
  174. padding: 2rpx 10rpx;
  175. -webkit-box-sizing: border-box;
  176. box-sizing: border-box;
  177. @include coupons_border_color(theme);
  178. opacity: 1;
  179. border-radius: 20rpx;
  180. font-size: 18rpx !important;
  181. @include main_color(theme);
  182. margin-right: 12rpx;
  183. }
  184. .noCommodity {
  185. margin-top: 300rpx;
  186. }
  187. .main_bg{
  188. @include main_bg_color(theme);
  189. }
  190. </style>