index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <view>
  3. <view class="navbar acea-row row-around">
  4. <view class="item acea-row row-center-wrapper" :class="{ on: navOn === 1 }" @click="onNav(1)">未使用</view>
  5. <view class="item acea-row row-center-wrapper" :class="{ on: navOn === 2 }" @click="onNav(2)">已使用/过期</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" :class="{svip: item.receive_type === 4}">
  9. <view class='money' :class='item._type == 0 ? "moneyGray" : ""'>
  10. <view>¥<text class='num'>{{item.coupon_price}}</text></view>
  11. <view class="pic-num" v-if="item.use_min_price > 0">满{{item.use_min_price}}元可用</view>
  12. <view class="pic-num" v-else>无门槛券</view>
  13. </view>
  14. <view class='text'>
  15. <view class='condition'>
  16. <view class="name line2">
  17. <view class="line-title" :class="item._type === 0 ? 'bg-color-huic' : 'bg-color-check'" v-if="item.applicable_type === 0">通用劵</view>
  18. <view class="line-title" :class="item._type === 0 ? 'bg-color-huic' : 'bg-color-check'" v-else-if="item.applicable_type === 1">品类券</view>
  19. <view class="line-title" :class="item._type === 0 ? 'bg-color-huic' : 'bg-color-check'" v-else>商品券</view>
  20. <image src="../../../static/images/fvip.png" class="pic" v-if="item.receive_type===4"></image>
  21. <text>{{item.coupon_title}}</text>
  22. </view>
  23. </view>
  24. <view class='data acea-row row-between-wrapper'>
  25. <view>{{item.add_time}}-{{item.end_time}}</view>
  26. <view class='bnt gray' v-if="item._type==0">{{item._msg}}</view>
  27. <view class='bnt bg-color' v-else>{{item._msg}}</view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class='noCommodity' v-if="!couponsList.length && page === 2">
  33. <view class='pictrue'>
  34. <image src='../../../static/images/noCoupon.png'></image>
  35. </view>
  36. </view>
  37. <!-- #ifdef MP -->
  38. <!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
  39. <!-- #endif -->
  40. <home></home>
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. getUserCoupons
  46. } from '@/api/api.js';
  47. import {
  48. toLogin
  49. } from '@/libs/login.js';
  50. import {
  51. mapGetters
  52. } from "vuex";
  53. // #ifdef MP
  54. import authorize from '@/components/Authorize';
  55. // #endif
  56. import home from '@/components/home';
  57. export default {
  58. components: {
  59. // #ifdef MP
  60. authorize,
  61. // #endif
  62. home
  63. },
  64. data() {
  65. return {
  66. couponsList: [],
  67. loading: false,
  68. isAuto: false, //没有授权的不会自动授权
  69. isShowAuth: false, //是否隐藏授权
  70. navOn: 1,
  71. page: 1,
  72. limit: 15,
  73. finished: false
  74. };
  75. },
  76. computed: mapGetters(['isLogin']),
  77. watch: {
  78. isLogin: {
  79. handler: function(newV, oldV) {
  80. if (newV) {
  81. this.getUseCoupons();
  82. }
  83. },
  84. deep: true
  85. }
  86. },
  87. onLoad() {
  88. if (this.isLogin) {
  89. this.getUseCoupons();
  90. } else {
  91. toLogin();
  92. }
  93. },
  94. onReachBottom() {
  95. this.getUseCoupons();
  96. },
  97. methods: {
  98. onNav: function(type) {
  99. this.navOn = type;
  100. this.couponsList = [];
  101. this.page = 1;
  102. this.finished = false;
  103. this.getUseCoupons();
  104. },
  105. /**
  106. * 授权回调
  107. */
  108. onLoadFun: function() {
  109. this.getUseCoupons();
  110. },
  111. // 授权关闭
  112. authColse: function(e) {
  113. this.isShowAuth = e
  114. },
  115. /**
  116. * 获取领取优惠券列表
  117. */
  118. getUseCoupons: function() {
  119. let that = this;
  120. if (that.loading || that.finished) {
  121. return;
  122. }
  123. that.loading = true;
  124. uni.showLoading({
  125. title: '正在加载…'
  126. });
  127. getUserCoupons(this.navOn, {
  128. page: this.page,
  129. limit: this.limit
  130. }).then(res => {
  131. that.loading = false;
  132. uni.hideLoading();
  133. that.couponsList = that.couponsList.concat(res.data);
  134. that.finished = res.data.length < that.limit;
  135. that.page += 1;
  136. }).catch(err => {
  137. that.loading = false;
  138. uni.showToast({
  139. title: err,
  140. icon: 'none'
  141. });
  142. });
  143. }
  144. }
  145. }
  146. </script>
  147. <style>
  148. .money {
  149. display: flex;
  150. flex-direction: column;
  151. justify-content: center;
  152. }
  153. .pic-num {
  154. color: #ffffff;
  155. font-size: 24rpx;
  156. }
  157. .coupon-list .item .text .condition {
  158. display: flex;
  159. align-items: center;
  160. }
  161. .coupon-list .item .text .condition .name {
  162. font-size: 26rpx;
  163. font-weight: 500;
  164. }
  165. .coupon-list .item .text .condition .pic {
  166. width: 30rpx;
  167. height: 30rpx;
  168. display: block;
  169. margin-right: 10rpx;
  170. display: inline-block;
  171. vertical-align: middle;
  172. }
  173. .condition .line-title {
  174. width: 70rpx;
  175. height: 32rpx !important;
  176. line-height: 30rpx;
  177. text-align: center;
  178. box-sizing: border-box;
  179. background: rgba(255, 247, 247, 1);
  180. border: 1px solid rgba(232, 51, 35, 1);
  181. opacity: 1;
  182. border-radius: 20rpx;
  183. font-size: 18rpx !important;
  184. color: #e83323;
  185. margin-right: 12rpx;
  186. text-align: center;
  187. display: inline-block;
  188. vertical-align: middle;
  189. }
  190. .condition .line-title.bg-color-huic {
  191. border-color: #BBB!important;
  192. color: #bbb!important;
  193. background-color: #F5F5F5!important;
  194. }
  195. </style>
  196. <style lang="scss" scoped>
  197. .navbar {
  198. position: fixed;
  199. top: 0;
  200. left: 0;
  201. width: 100%;
  202. height: 106rpx;
  203. background-color: #FFFFFF;
  204. z-index: 9;
  205. .item {
  206. border-top: 5rpx solid transparent;
  207. border-bottom: 5rpx solid transparent;
  208. font-size: 30rpx;
  209. color: #999999;
  210. &.on {
  211. border-bottom-color: #E93323;
  212. color: #282828;
  213. }
  214. }
  215. }
  216. .coupon-list {
  217. margin-top: 122rpx;
  218. }
  219. .noCommodity {
  220. margin-top: 300rpx;
  221. }
  222. </style>