index.vue 6.8 KB

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