index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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')">
  5. 未使用</view>
  6. <view class="item acea-row row-center-wrapper" :class="{ on: navOn === 'unusable' }"
  7. @click="onNav('unusable')">已使用/失效</view>
  8. </view>
  9. <view class="coupon-box">
  10. <view class='coupon-list' v-if="couponsList.length">
  11. <navigator url="/pages/activity/couponList/index" class="more-btn" hover-class="none">
  12. <view class="pic_box">
  13. <image :src="urlDomain + 'crmebimage/presets/my_coupon.png'" mode=""></image>
  14. </view>
  15. </navigator>
  16. <view class='item acea-row row-center-wrapper' v-for='(item,index) in couponsList' :key="index"
  17. @click="goCouponsProList(item)">
  18. <view class='money'
  19. :class="item.validStr==='unusable'||item.validStr==='overdue' ? 'moneyGray' : 'main_bg'">
  20. <view class="logo">¥<text class='num'>{{item.money?Number(item.money):''}}</text></view>
  21. <view class="pic-num">满{{ Number(item.minPrice) }}元可用</view>
  22. </view>
  23. <view class='text'>
  24. <view class='condition acea-row'>
  25. <view class="line-title"
  26. :class="item.validStr==='unusable'||item.validStr==='overdue' ? 'bg-color-huic' : 'bg-color-check'">
  27. {{item.category | couponTypeFilter}}</view>
  28. <view class="line2">{{item.name}}</view>
  29. </view>
  30. <view class='data acea-row row-between-wrapper'>
  31. <view v-if="item.startTime && item.endTime && navOn === 'usable'">
  32. {{$util.getCouponTime(item.startTime,item.endTime)}}</view>
  33. <view v-if="navOn === 'unusable'">
  34. <span v-show="item.validStr==='overdue'">该优惠券已失效无法使用</span>
  35. <span v-show="item.validStr==='unusable'">该优惠券已使用</span>
  36. </view>
  37. <span class="iconfont"
  38. :class="{'icon-yilingqu1':item.validStr==='usable'||item.validStr==='notStart',
  39. 'icon-yishiyong':item.validStr==='unusable',
  40. 'icon-yishixiao':item.validStr==='overdue',
  41. 'font-color':item.validStr==='usable'||item.validStr==='notStart'
  42. }
  43. "></span>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <view v-if="couponsList.length" class='loadingicon acea-row row-center-wrapper'>
  49. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  50. </view>
  51. </view>
  52. <view class='noCommodity' v-if="!couponsList.length && !loading">
  53. <view class='pictrue'>
  54. <image :src="urlDomain + 'crmebimage/presets/noCoupon.png'"></image>
  55. <span class="coupon">暂无优惠券可使用哦~</span>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. // +----------------------------------------------------------------------
  62. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  63. // +----------------------------------------------------------------------
  64. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  65. // +----------------------------------------------------------------------
  66. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  67. // +----------------------------------------------------------------------
  68. // | Author: CRMEB Team <admin@crmeb.com>
  69. // +----------------------------------------------------------------------
  70. import {
  71. getUserCoupons
  72. } from '@/api/api.js';
  73. import {
  74. toLogin
  75. } from '@/libs/login.js';
  76. import {
  77. mapGetters
  78. } from "vuex";
  79. let app = getApp();
  80. export default {
  81. data() {
  82. return {
  83. urlDomain: this.$Cache.get("imgHost"),
  84. couponsList: [],
  85. loading: false,
  86. loadend: false,
  87. loadTitle: '加载更多', //提示语
  88. page: 1,
  89. limit: 20,
  90. navOn: 'usable',
  91. theme: app.globalData.theme,
  92. };
  93. },
  94. computed: mapGetters(['isLogin']),
  95. watch: {
  96. isLogin: {
  97. handler: function(newV, oldV) {
  98. if (newV) {
  99. this.getUseCoupons();
  100. }
  101. },
  102. deep: true
  103. }
  104. },
  105. onLoad() {
  106. if (this.isLogin) {
  107. this.getUseCoupons();
  108. } else {
  109. toLogin();
  110. }
  111. },
  112. methods: {
  113. goCouponsProList(item) {
  114. if (this.navOn === 'usable') {
  115. uni.navigateTo({
  116. url: `/pages/goods/coupon_goods_list/index?type=2&userCouponId=${item.id}&money=${item.money}&minPrice=${item.minPrice}&isUserReceive=true`
  117. })
  118. }
  119. },
  120. onNav: function(type) {
  121. this.navOn = type;
  122. this.couponsList = [];
  123. this.page = 1;
  124. this.loadend = false;
  125. this.getUseCoupons();
  126. },
  127. /**
  128. * 获取领取优惠券列表
  129. */
  130. getUseCoupons: function() {
  131. let that = this;
  132. if (this.loadend) return false;
  133. if (this.loading) return false;
  134. this.loading = true;
  135. getUserCoupons({
  136. page: that.page,
  137. limit: that.limit,
  138. type: that.navOn
  139. }).then(res => {
  140. let list = res.data ? res.data.list : [],
  141. loadend = list.length < that.limit;
  142. let couponsList = that.$util.SplitArray(list, that.couponsList);
  143. that.$set(that, 'couponsList', couponsList);
  144. that.loadend = loadend;
  145. that.loadTitle = loadend ? '我也是有底线的' : '加载更多';
  146. that.page = that.page + 1;
  147. that.loading = false;
  148. }).catch(err => {
  149. that.loading = false;
  150. that.loadTitle = '加载更多';
  151. });
  152. }
  153. },
  154. /**
  155. * 页面上拉触底事件的处理函数
  156. */
  157. onReachBottom: function() {
  158. this.getUseCoupons();
  159. }
  160. }
  161. </script>
  162. <style lang="scss" scoped>
  163. .coupon-box {
  164. position: absolute;
  165. }
  166. .navbar {
  167. position: fixed;
  168. top: 0;
  169. left: 0;
  170. width: 100%;
  171. height: 106rpx;
  172. background-color: #FFFFFF;
  173. z-index: 9;
  174. .item {
  175. border-top: 5rpx solid transparent;
  176. border-bottom: 5rpx solid transparent;
  177. font-size: 30rpx;
  178. color: #999999;
  179. &.on {
  180. @include tab_border_bottom(theme);
  181. @include main_color(theme);
  182. }
  183. }
  184. }
  185. .money {
  186. display: flex;
  187. flex-direction: column;
  188. justify-content: center;
  189. font-size: 20rpx !important;
  190. .logo {
  191. font-size: 39rpx;
  192. }
  193. }
  194. .bg_color {
  195. @include main_bg_color(theme);
  196. }
  197. .pic-num {
  198. color: #ffffff;
  199. font-size: 24rpx;
  200. }
  201. .pic_box {
  202. width: 690rpx;
  203. height: 160rpx;
  204. margin: 30rpx auto;
  205. image {
  206. width: 100%;
  207. height: 100%;
  208. }
  209. }
  210. .coupon-list {
  211. margin-top: 122rpx;
  212. }
  213. .coupon-list .item {
  214. overflow: hidden;
  215. }
  216. .coupon-list .item .text {
  217. height: 100%;
  218. position: relative;
  219. .iconfont {
  220. right: -16rpx;
  221. position: absolute;
  222. font-size: 140rpx;
  223. bottom: -20rpx;
  224. z-index: 1;
  225. opacity: 0.15;
  226. }
  227. }
  228. .coupon-list .item .text .data {
  229. border-top: 1px solid #f0f0f0;
  230. }
  231. .bg-color-check {
  232. @include main_color(theme);
  233. @include coupons_border_color(theme);
  234. font-size: 20rpx !important;
  235. }
  236. .noCommodity {
  237. margin-top: 64%;
  238. }
  239. .pictrue {
  240. display: flex;
  241. flex-direction: column;
  242. align-items: center;
  243. img {
  244. width: 414rpx;
  245. height: 305rpx;
  246. }
  247. .coupon {
  248. font-size: 26rpx;
  249. color: #999999;
  250. }
  251. }
  252. </style>