myCoupon.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <!-- 我的优惠券 -->
  2. <template>
  3. <view class="my_coupon">
  4. <view class="my_coupon_nav">
  5. <view class="my_coupon_nav_pre" :class="{active:useState == '1'}" @click="handleNav('1')">{{$L('未使用')}}</view>
  6. <view class="my_coupon_nav_pre" :class="{active:useState == '2'}" @click="handleNav('2')">{{$L('已使用')}}</view>
  7. <view class="my_coupon_nav_pre" :class="{active:useState == '3'}" @click="handleNav('3')">{{$L('已失效')}}</view>
  8. </view>
  9. <view v-if="couponList && !noData" class="coupon_con">
  10. <view class="my_coupon_center" @click="goCouponCenter()">
  11. <image :src="imgUrl + 'coupon/coupon_center_bg.png'" mode=""></image>
  12. </view>
  13. <view class="my_coupon_list">
  14. <view class="my_coupon_pre" v-for="(item,index) in couponList" :key="index">
  15. <view class="coupon_pre_top" :style="{backgroundImage:'url(' + item.couponBg + ')'}">
  16. <view class="coupon_pre_left">
  17. <view class="coupon_pre_price" :class="{grey:item.useState != 1}" v-if="item.couponType != 2">
  18. <text class="unit">¥ </text>
  19. <text class="price_int">{{item.publishValue}}</text>
  20. </view>
  21. <view class="coupon_pre_price" :class="{grey:item.useState != 1}" v-if="item.couponType == 2">
  22. <view class=""></view>
  23. <text class="price_int">{{filters.toSplit(filters.toFixNum(item.publishValue,1))[0]}}</text>.
  24. <text class="price_decimal">{{filters.toSplit(filters.toFixNum(item.publishValue,1))[1]}}</text>
  25. <text class="price_decimal">{{$L('折')}}</text>
  26. </view>
  27. <view class="coupon_pre_active" :class="{grey_con:item.useState != 1}">{{item.couponContent}}</view>
  28. </view>
  29. <view class="coupon_pre_cen">
  30. <view class="coupon_pre_title">{{item.useTypeValue}}</view>
  31. <view class="coupon_pre_time">{{item.effectiveStart}}~{{item.effectiveEnd}}</view>
  32. <view class="coupon_pre_rules" @click="descriptionOpen(item.couponMemberId)">
  33. <text>使用规则</text>
  34. <image :src="item.isOpen ? imgUrl + 'coupon/up.png' : imgUrl + 'coupon/down.png'" mode=""></image>
  35. </view>
  36. </view>
  37. <view class="coupon_pre_right" @click="goGoodsList(item)">
  38. {{item.useState == '1' ? '立即使用' : item.useState == '2' ? '已使用' : '已失效'}}
  39. </view>
  40. </view>
  41. <view class="coupon_rules" v-if="item.isOpen == true">
  42. <view class="coupon_rules_title">{{$L('使用规则')}}:{{item.description}}</view>
  43. </view>
  44. <view class="coupon_type" :class="{grey_type:item.useState != 1}">{{item.couponTypeValue}}</view>
  45. </view>
  46. <loadingState v-if="loadingState == 'first_loading'||couponList.length > 0" :state='loadingState' />
  47. </view>
  48. </view>
  49. <view class="no_data" v-if="noData">
  50. <image :src="imgUrl + 'no_coupon.png'" mode=""></image>
  51. <text>{{$L('暂无优惠券,去领券中心看看吧')}}~</text>
  52. <view class="go_coupon_center" @click="goCouponCenter">{{$L('领券中心')}}</view>
  53. </view>
  54. </view>
  55. </template>
  56. <script module="filters" lang="wxs" src="../../utils/filter.wxs"></script>
  57. <script>
  58. import loadingState from "@/components/loading-state.vue";
  59. import {
  60. mapState
  61. } from 'vuex';
  62. export default {
  63. components: {
  64. loadingState
  65. },
  66. data() {
  67. return {
  68. imgUrl: getApp().globalData.imgUrl,
  69. useState:'1', //使用状态
  70. pageSize: 10,
  71. current: 1,
  72. couponList:[], //优惠券列表
  73. noData:false, //无数据
  74. hasMore: false, //是否还有数据
  75. loadingState: 'first_loading',
  76. goReceiveBg:getApp().globalData.imgUrl + 'coupon/coupon_pre_bg.png', //未使用
  77. finishReceiveBg:getApp().globalData.imgUrl + 'coupon/finishReceiveBg.png', //已使用,已过期
  78. };
  79. },
  80. computed: {
  81. ...mapState(['hasLogin', 'userInfo'])
  82. },
  83. async onLoad(options) {
  84. this.getCouponList();
  85. },
  86. // 触底加载更多
  87. onReachBottom() {
  88. if(this.hasMore){
  89. this.getCouponList();
  90. }
  91. },
  92. onShow() {
  93. this.current = 1;
  94. this.getCouponList();
  95. },
  96. methods: {
  97. //获取优惠券列表
  98. getCouponList() {
  99. let param = {};
  100. param.url = 'v3/promotion/front/coupon/list';
  101. param.method = 'GET';
  102. param.data = {};
  103. param.data.current = this.current;
  104. param.data.pageSize = this.pageSize;
  105. param.data.useState = this.useState;
  106. this.$request(param).then(res => {
  107. if (res.state == 200) {
  108. let result = res.data;
  109. if(result.list.length == 0){
  110. this.couponList = result.list;
  111. this.noData = true;
  112. }else{
  113. if(this.current == 1){
  114. this.couponList = result.list;
  115. }else{
  116. this.couponList = this.couponList.concat(result.list);
  117. }
  118. this.noData = false;
  119. }
  120. this.couponList.forEach((item,index)=>{
  121. if(item.useState == 1){
  122. item.couponBg = this.goReceiveBg;
  123. }else{
  124. item.couponBg = this.finishReceiveBg;
  125. }
  126. })
  127. this.hasMore = this.$checkPaginationHasMore(res.data.pagination); //是否还有数据
  128. if (this.hasMore) {
  129. this.current++;
  130. this.loadingState = 'allow_loading_more';
  131. } else {
  132. this.loadingState = 'no_more_data';
  133. }
  134. } else {
  135. this.$api.msg(res.msg);
  136. }
  137. }).catch((e) => {
  138. //异常处理
  139. })
  140. },
  141. //点击nav导航
  142. handleNav(type){
  143. this.useState = type;
  144. this.current = 1;
  145. this.getCouponList();
  146. },
  147. //去领券中心页面
  148. goCouponCenter(){
  149. uni.navigateTo({
  150. url:'/pages/coupon/couponCenter'
  151. })
  152. },
  153. //规则展开
  154. descriptionOpen(couponMemberId){
  155. this.couponList.map(item=>{
  156. if(item.couponMemberId == couponMemberId){
  157. if(item.description != ''){
  158. item.isOpen = !item.isOpen
  159. this.$forceUpdate()
  160. }
  161. }else{
  162. item.isOpen = false
  163. }
  164. })
  165. },
  166. //去优惠券对应的商品列表
  167. goGoodsList(item){
  168. if(item.useState == '1'){
  169. let params=''
  170. if(item.storeId>0){
  171. params+='&storeId='+item.storeId
  172. }
  173. if(item.useType==2&&item.goodsIds){
  174. params+='&goodsIds='+item.goodsIds
  175. }else if(item.useType==3&&item.cateIds){
  176. params+='&categoryId='+item.cateIds
  177. }
  178. uni.navigateTo({
  179. url:'/pages/product/list?source=coupon'+params
  180. })
  181. }
  182. },
  183. },
  184. }
  185. </script>
  186. <style lang="scss">
  187. page{
  188. background: $bg-color-split;
  189. }
  190. .my_coupon{
  191. width: 750rpx;
  192. margin: 0 auto;
  193. .my_coupon_nav{
  194. padding-left: 39rpx;
  195. padding-right: 35rpx;
  196. display: flex;
  197. align-items: center;
  198. justify-content: space-between;
  199. background: #FFFFFF;
  200. position: fixed;
  201. top: var(--bar-height);
  202. z-index: 100;
  203. width: 750rpx;
  204. box-sizing: border-box;
  205. .my_coupon_nav_pre{
  206. font-size: 32rpx;
  207. font-family: PingFang SC;
  208. font-weight: 500;
  209. color: #333333;
  210. line-height: 39rpx;
  211. padding: 26rpx 0;
  212. }
  213. .active{
  214. font-size: 32rpx;
  215. font-family: PingFang SC;
  216. font-weight: bold;
  217. color: #FC1C1C;
  218. line-height: 39rpx;
  219. border-bottom: 6rpx solid #FC1C1C;
  220. }
  221. }
  222. .coupon_con{
  223. padding-top: 88rpx;
  224. }
  225. .my_coupon_center{
  226. background: #FFFFFF;
  227. image{
  228. width: 717rpx;
  229. height: 245rpx;
  230. }
  231. }
  232. .my_coupon_list{
  233. padding-top: 20rpx;
  234. .my_coupon_pre{
  235. width: 710rpx;
  236. margin-bottom: 20rpx;
  237. position: relative;
  238. margin: 0 auto 20rpx;
  239. .coupon_pre_top{
  240. height: 190rpx;
  241. background-size: 100% 100%;
  242. display: flex;
  243. align-items: center;
  244. .coupon_pre_left{
  245. display: flex;
  246. flex-direction: column;
  247. width: 203rpx;
  248. align-items: center;
  249. .coupon_pre_price{
  250. font-size: 20rpx;
  251. font-family: Source Han Sans CN;
  252. font-weight: bold;
  253. color: #F20C06;
  254. line-height: 31rpx;
  255. text:nth-child(2){
  256. font-size: 48rpx;
  257. font-family: Source Han Sans CN;
  258. font-weight: bold;
  259. color: #F30801;
  260. line-height: 31rpx;
  261. }
  262. }
  263. .coupon_pre_active{
  264. font-size: 24rpx;
  265. font-family: Source Han Sans CN;
  266. font-weight: 400;
  267. color: #F6130E;
  268. line-height: 31rpx;
  269. margin-top: 20rpx;
  270. }
  271. .grey{
  272. color: #333333;
  273. .price_int{
  274. color: #333333!important;
  275. }
  276. }
  277. .grey_con{
  278. color: #999999;
  279. }
  280. }
  281. .coupon_pre_cen{
  282. display: felx;
  283. flex-direction: column;
  284. flex:1;
  285. padding-left: 44rpx;
  286. .coupon_pre_title{
  287. font-size: 30rpx;
  288. font-family: PingFang SC;
  289. font-weight: bold;
  290. color: #111111;
  291. line-height: 31rpx;
  292. }
  293. .coupon_pre_time{
  294. font-size: 24rpx;
  295. font-family: PingFang SC;
  296. font-weight: 500;
  297. color: #333333;
  298. line-height: 31rpx;
  299. margin: 21rpx 0 17rpx;
  300. }
  301. .coupon_pre_rules{
  302. display: flex;
  303. align-items: center;
  304. text{
  305. font-size: 24rpx;
  306. font-family: PingFang SC;
  307. font-weight: 500;
  308. color: #999999;
  309. line-height: 31rpx;
  310. }
  311. image{
  312. width: 12rpx;
  313. height: 7rpx;
  314. margin-left: 20rpx;
  315. }
  316. }
  317. }
  318. .coupon_pre_right{
  319. font-size: 24rpx;
  320. font-family: Source Han Sans CN;
  321. font-weight: 400;
  322. color: #FFFFFF;
  323. width: 130rpx;
  324. text-align: center;
  325. box-sizing: border-box;
  326. height: 190rpx;
  327. line-height: 190rpx;
  328. }
  329. }
  330. .coupon_rules{
  331. width: 710rpx;
  332. padding: 20rpx 0 20rpx 43rpx;
  333. box-sizing: border-box;
  334. font-size: 22rpx;
  335. font-family: PingFang SC;
  336. font-weight: 500;
  337. color: #666666;
  338. line-height: 30rpx;
  339. background: #FFFFFF;
  340. border-top: 1rpx solid #f2f2f2;
  341. border-radius: 0 0 15rpx 15rpx;
  342. .coupon_rules_title{
  343. margin-bottom: 10rpx;
  344. }
  345. }
  346. .coupon_type{
  347. position: absolute;
  348. top: 0;
  349. left: 0;
  350. padding: 0 5rpx;
  351. height: 30rpx;
  352. background: linear-gradient(0deg, #FF3000 0%, #FB3E31 0%, #FF3728 0%, #FF142F 100%);
  353. font-size: 20rpx;
  354. font-family: Source Han Sans CN;
  355. font-weight: 400;
  356. color: #FFFFFF;
  357. line-height: 30rpx;
  358. text-align: center;
  359. border-radius: 15rpx 0 15rpx 0;
  360. }
  361. .grey_type{
  362. background: linear-gradient(0deg, #A9A28C 0%, #B1B7B0 0%, #9EA59D 0%, #9FA19E 0%, #6C6D74 100%);
  363. color: #FFFFFF;
  364. }
  365. }
  366. }
  367. .no_data{
  368. display: flex;
  369. flex-direction: column;
  370. align-items: center;
  371. padding-top: 180rpx;
  372. image{
  373. width: 187rpx;
  374. height: 187rpx;
  375. }
  376. text{
  377. font-size: 26rpx;
  378. font-family: Source Han Sans CN;
  379. font-weight: 400;
  380. color: #999999;
  381. margin: 30rpx 0;
  382. }
  383. .go_coupon_center{
  384. width: 160rpx;
  385. height: 54rpx;
  386. background: #F5EAEA;
  387. border-radius: 27rpx;
  388. font-size: 28rpx;
  389. font-family: PingFang SC;
  390. font-weight: 500;
  391. color: #EF242F;
  392. text-align: center;
  393. line-height: 54rpx;
  394. }
  395. }
  396. }
  397. </style>