index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <view :style="viewColor">
  3. <view class="navTabBox">
  4. <view class="longTab">
  5. <view class="tab-item" v-for="(item,index) in tabList" :key="index" :class="{'on':index == tabIndex-1}" @click="bindTab(index)"><text>{{item.title}}</text></view>
  6. </view>
  7. </view>
  8. <view class='coupon-list' v-if="couponsList.length">
  9. <view v-for='(item,index) in couponsList' :key="index">
  10. <view v-if="item.merchant && item.status==0" class="store-info acea-row row-between-wrapper">
  11. <view class="store_name acea-row row-between-wrapper">
  12. <image class="image" :src="item.merchant.mer_avatar"></image>
  13. <text class="name">{{item.merchant.mer_name}}</text>
  14. </view>
  15. <view v-if="hide_mer_status == 0 && item.status == 0" class="store" @click="goStore(item)">进店</view>
  16. </view>
  17. <view class='item acea-row row-center-wrapper'>
  18. <block v-if="item.status == 0">
  19. <view v-if="item.coupon.send_type == 5" class='money vip-coupon'>
  20. <view class="line1 coupon_value">¥<text class='num'>{{item.coupon_price}}</text></view>
  21. <view class="pic-num">满{{ item.use_min_price }}元可用</view>
  22. </view>
  23. <view v-else class='money' :style="{ 'background-image': `url(${domain}/static/diy/couponBg${keyColor}.png)` }">
  24. <view class="line1 coupon_value">¥<text class='num'>{{item.coupon_price}}</text></view>
  25. <view class="pic-num">满{{ item.use_min_price }}元可用</view>
  26. </view>
  27. </block>
  28. <view v-else class='money moneyGray'>
  29. <view>¥<text class='num'>{{item.coupon_price}}</text></view>
  30. <view class="pic-num">满{{ item.use_min_price }}元可用</view>
  31. </view>
  32. <view class='text'>
  33. <view class='condition line1'>
  34. <view class="line-title" :class="item.status === 0 ? 'bg-color-huic' : 'bg-color-check'" v-if="item.coupon && item.coupon.type === 0">店铺券</view>
  35. <view class="line-title" :class="item._type === 0 ? 'bg-color-huic' : 'bg-color-check'" v-else-if="item.coupon && item.coupon.type === 1">商品券</view>
  36. <view class="line-title" :class="item._type === 0 ? 'bg-color-huic' : 'bg-color-check'" v-else-if="item.coupon && item.coupon.type === 11">品类券</view>
  37. <view class="line-title" :class="item._type === 0 ? 'bg-color-huic' : 'bg-color-check'" v-else-if="item.coupon && item.coupon.type === 10">通用券</view>
  38. <view class="line-title" :class="item._type === 0 ? 'bg-color-huic' : 'bg-color-check'" v-else-if="item.coupon && item.coupon.type === 12">跨店券</view>
  39. <view class="line-title" :class="item._type === 0 ? 'bg-color-huic' : 'bg-color-check'" v-else>商品券</view>
  40. <view class="line1 coupon-title">{{item.coupon_title}}</view>
  41. </view>
  42. <view class='data acea-row row-between-wrapper'>
  43. <view>{{item.start_time | timeYMD}}-{{item.end_time | timeYMD}}</view>
  44. <view v-if="item.status==0">
  45. <navigator :url="'/pages/columnGoods/goods_coupon_list/index?coupon_id='+item.coupon_id" class='bnt1 b-color' :class="item.coupon.send_type == 5 ? 'svip-btn' : ''" hover-class="none">
  46. 去使用
  47. </navigator>
  48. </view>
  49. <view class='bnt1 gray' style="position: static;" v-if="item.status==1">已使用</view>
  50. <view class='bnt1 gray' style="position: static;" v-if="item.status==2">已过期</view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class='noCommodity' v-if="!couponsList.length && loading==true">
  57. <view class='pictrue'>
  58. <image :src="`${domain}/static/images/noCoupon.png`"></image>
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. // +----------------------------------------------------------------------
  65. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  66. // +----------------------------------------------------------------------
  67. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  68. // +----------------------------------------------------------------------
  69. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  70. // +----------------------------------------------------------------------
  71. // | Author: CRMEB Team <admin@crmeb.com>
  72. // +----------------------------------------------------------------------
  73. let app = getApp();
  74. import { getUserCoupons } from '@/api/api.js';
  75. import { mapGetters } from "vuex";
  76. import { configMap } from '@/utils';
  77. import { HTTP_REQUEST_URL } from '@/config/app';
  78. import { toLogin } from '@/libs/login.js';
  79. export default {
  80. components: {},
  81. data() {
  82. return {
  83. domain: HTTP_REQUEST_URL,
  84. tabIndex:1,
  85. couponsList: [],
  86. loading: false,
  87. isUsed: 0,
  88. tabList:[
  89. {
  90. title:'未使用'
  91. },
  92. {
  93. title:'已使用/已过期'
  94. }
  95. ],
  96. limit:15,
  97. page:1,
  98. isScroll:true,
  99. moneyBg: '/static/images/couponBg',
  100. };
  101. },
  102. computed: configMap(['hide_mer_status'], mapGetters(['isLogin','viewColor','keyColor'])),
  103. filters: {
  104. timeYMD: function (value) {
  105. if(value){
  106. var newDate=/\d{4}-\d{1,2}-\d{1,2}/g.exec(value)
  107. return newDate[0]
  108. }
  109. }
  110. },
  111. onLoad() {
  112. if (this.isLogin) {
  113. this.getUseCoupons();
  114. } else {
  115. toLogin()
  116. }
  117. },
  118. mounted: function() {
  119. },
  120. methods: {
  121. bindTab(index){
  122. this.tabIndex = index+1
  123. this.page =1
  124. this.isScroll = true
  125. this.couponsList = []
  126. this.getUseCoupons()
  127. },
  128. goStore(item){
  129. if(this.hide_mer_status != 1 && item.status==0){
  130. uni.navigateTo({
  131. url:`/pages/store/home/index?id=${item.mer_id}`
  132. })
  133. }
  134. },
  135. /**
  136. * 获取领取优惠券列表
  137. */
  138. getUseCoupons: function() {
  139. let that = this;
  140. if(!this.isScroll) return
  141. getUserCoupons({
  142. statusTag: this.tabIndex,
  143. page:this.page,
  144. limit:this.limit
  145. }).then(res => {
  146. that.loading = true;
  147. that.couponsList = that.couponsList.concat(res.data.list)
  148. that.isScroll = that.couponsList.length<res.data.count
  149. that.page++
  150. })
  151. }
  152. },
  153. onReachBottom() {
  154. this.getUseCoupons()
  155. }
  156. }
  157. </script>
  158. <style scoped lang="scss">
  159. .navTabBox{
  160. background: #fff;
  161. height: 90rpx;
  162. }
  163. .longTab{
  164. display: flex;
  165. text-align: center;
  166. }
  167. .tab-item{
  168. width: 50%;
  169. display: inline-block;
  170. line-height: 90rpx;
  171. text{
  172. position: relative;
  173. display: inline-block;
  174. }
  175. }
  176. .tab-item.on{
  177. color: var(--view-theme);
  178. text{
  179. &:after{
  180. content: "";
  181. display: inline-block;
  182. width: 90%;
  183. height: 3rpx;
  184. background-color: var(--view-theme);
  185. position: absolute;
  186. left: 5%;
  187. bottom: 0;
  188. }
  189. }
  190. }
  191. .b-color {
  192. background-color: var(--view-theme);
  193. }
  194. .pic-num {
  195. color: #ffffff;
  196. font-size: 20rpx;
  197. }
  198. .coupon-list .item .text .condition {
  199. display: flex;
  200. align-items: center;
  201. }
  202. .condition .line-title {
  203. display: flex;
  204. align-items: center;
  205. justify-content: center;
  206. width: 90rpx;
  207. height: 40rpx !important;
  208. padding: 0 10rpx;
  209. -webkit-box-sizing: border-box;
  210. box-sizing: border-box;
  211. background: var(--view-minorColor);
  212. border: 1px solid var(--view-theme);
  213. opacity: 1;
  214. border-radius: 22rpx;
  215. font-size: 20rpx !important;
  216. color: var(--view-theme);
  217. margin-right: 12rpx;
  218. }
  219. .condition .coupon-title{
  220. width: 280rpx;
  221. }
  222. .store-info{
  223. background: #fff;
  224. padding: 18rpx 20rpx;
  225. position: relative;
  226. &::before,&::after{
  227. content: "";
  228. display: inline-block;
  229. width: 24rpx;
  230. height: 24rpx;
  231. background: #f5f5f5;
  232. border-radius: 100%;
  233. position: absolute;
  234. bottom: -12rpx;
  235. z-index: 10;
  236. }
  237. &::before{
  238. left: -10rpx;
  239. }
  240. &::after{
  241. right: -10rpx;
  242. }
  243. .image{
  244. width: 40rpx;
  245. height: 40rpx;
  246. border-radius: 100%;
  247. margin-right: 9rpx;
  248. }
  249. .name{
  250. color: #282828;
  251. }
  252. .store{
  253. color: var(--view-theme);
  254. font-size: 20rpx;
  255. padding: 2rpx 15rpx;
  256. border: 1px solid var(--view-theme);
  257. border-radius: 16rpx;
  258. }
  259. }
  260. .svip-btn{
  261. background-color: #E8C077;
  262. }
  263. .noCommodity{
  264. width: 100%;
  265. .pictrue{
  266. margin: 0 auto;
  267. }
  268. }
  269. .coupon_value{
  270. max-width: 220rpx;
  271. }
  272. </style>