index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <view class='my-coupon' :style="viewColor">
  3. <view class='header'>
  4. <view class='nav acea-row row-around'>
  5. <view class='item' :class='type==-1 ? "on": ""' @click="statusClick(-1)">
  6. <view>全部</view>
  7. </view>
  8. <view class='item' :class='type==10 ? "on": ""' @click="statusClick(10)">
  9. <view>通用券</view>
  10. </view>
  11. <view class='item' :class='type==11 ? "on": ""' @click="statusClick(11)">
  12. <view>品类券</view>
  13. </view>
  14. <view class='item' :class='type==12 ? "on": ""' @click="statusClick(12)">
  15. <view>跨店券</view>
  16. </view>
  17. <view class='item' :class='type==0 ? "on": ""' @click="statusClick(0)">
  18. <view>店铺券</view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="listBox">
  23. <block v-for="(item) in list" :key='item.coupon_id'>
  24. <view class="list acea-row row-around">
  25. <view class="left cross" v-if="item.ProductLst.length == 1 || item.ProductLst.length == 0">
  26. <view v-if="item.ProductLst.length == 1" class="cross-left" v-for="(items,index) in item.ProductLst" :key='index'>
  27. <easyLoadimage :image-src="items.image"></easyLoadimage>
  28. </view>
  29. <view v-if="item.ProductLst.length == 0" class="cross-left">
  30. <image src="../static/images/no_product.png"></image>
  31. </view>
  32. <view class="tips cross-right">
  33. <view class="title line2">{{item.title || ''}}</view>
  34. <view class="time">{{item.create_time}}</view>
  35. </view>
  36. </view>
  37. <view class="left" v-else>
  38. <view class="tips line1">{{item.title || ''}}</view>
  39. <view class="info">
  40. <view class="info-box" v-for="(items,index) in item.ProductLst" :key='index'>
  41. <easyLoadimage :image-src="items.image"></easyLoadimage>
  42. <view class="money">¥ {{items.price}}</view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="right">
  47. <view class="couponlogo" v-if="item.type == 10" :style="{ 'background-image': `url(${domain}/static/images/couponlogo.png)`}">通用券</view>
  48. <view class="couponlogo" v-if="item.type == 11" :style="{ 'background-image': `url(${domain}/static/images/couponlogo.png)`}">品类券</view>
  49. <view class="couponlogo" v-if="item.type == 12" :style="{ 'background-image': `url(${domain}/static/images/couponlogo.png)`}">跨店券</view>
  50. <view class="couponlogo" v-if="item.type == 0" :style="{ 'background-image': `url(${domain}/static/images/couponlogo.png)`}">店铺券</view>
  51. <view class="title">
  52. <view>
  53. <p><text class='font1'>¥</text><text class='font2'>{{parsePrice(item.coupon_price)}}</text></p>
  54. <p>
  55. <text class='font3' v-if="item.use_min_price == 0">无使用门槛</text>
  56. <text class='font3' v-else>满{{parsePrice(item.use_min_price)}}元可用</text>
  57. </p>
  58. </view>
  59. <view class="btn" :class="item.ProductLst.length == 0 ? 'disabled' : ''" v-if="!item.issue" @click="receiveCoupon(item)">立即领取</view>
  60. <navigator :url="'/pages/columnGoods/goods_coupon_list/index?coupon_id='+item.coupon_id" class='btn shiyong' hover-class="none" v-if="item.issue && item.ProductLst.length > 0">
  61. 去使用
  62. </navigator>
  63. <view v-if="item.issue && item.ProductLst.length == 0" class='btn shiyong disabled'>去使用</view>
  64. </view>
  65. </view>
  66. </view>
  67. </block>
  68. </view>
  69. <view class="loadingicon acea-row row-center-wrapper">
  70. <text class="loading iconfont icon-jiazai" :hidden="loading == false" style="color:#33;"></text>
  71. </view>
  72. <view class='noCommodity' v-if="!list.length && loaded">
  73. <view class='pictrue'>
  74. <image :src="`${domain}/static/images/noCoupon.png`"></image>
  75. </view>
  76. </view>
  77. </view>
  78. </template>
  79. <script>
  80. // +----------------------------------------------------------------------
  81. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  82. // +----------------------------------------------------------------------
  83. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  84. // +----------------------------------------------------------------------
  85. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  86. // +----------------------------------------------------------------------
  87. // | Author: CRMEB Team <admin@crmeb.com>
  88. // +----------------------------------------------------------------------
  89. import {getCouponLst} from '@/api/activity.js';
  90. import {setCouponReceive} from '@/api/api.js';
  91. import { mapGetters } from "vuex";
  92. import easyLoadimage from '@/components/easy-loadimage/easy-loadimage.vue';
  93. import { HTTP_REQUEST_URL } from '@/config/app';
  94. export default {
  95. computed: mapGetters(['viewColor']),
  96. components: {
  97. easyLoadimage
  98. },
  99. data() {
  100. return {
  101. domain: HTTP_REQUEST_URL,
  102. type: '',
  103. list:[],
  104. loading: false,
  105. loaded: false,
  106. page: 1,
  107. limit: 15,
  108. }
  109. },
  110. onLoad: function() {
  111. this.statusClick(-1)
  112. },
  113. methods: {
  114. parsePrice(price){
  115. if(price >= 100){
  116. return parseFloat(price)
  117. }else{
  118. return price
  119. }
  120. },
  121. // 领取优惠券
  122. receiveCoupon(item) {
  123. let that = this;
  124. setCouponReceive(item.coupon_id).then(res => {
  125. item.issue = 1
  126. uni.showToast({
  127. title: res.message,
  128. icon: 'none'
  129. })
  130. }).catch(err => {
  131. uni.showToast({
  132. title: err,
  133. icon: 'none'
  134. })
  135. })
  136. },
  137. getList(){
  138. if(this.loading || this.loaded) return ;
  139. this.loading = true;
  140. getCouponLst({
  141. product:1,
  142. type: this.type == -1 ? '' : this.type,
  143. page: this.page,
  144. limit: this.limit
  145. }).then(res=>{
  146. this.list = this.list.concat(res.data.list);
  147. this.loading = false;
  148. this.loaded = res.data.list.length != this.limit;
  149. this.page ++;
  150. })
  151. },
  152. //切换类型
  153. statusClick: function(status) {
  154. if (status == this.type) return;
  155. this.loaded = false;
  156. this.loading = false;
  157. this.page = 1;
  158. this.list = [];
  159. this.type = status;
  160. this.getList()
  161. },
  162. },
  163. // 滚动监听
  164. onPageScroll(e) {
  165. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  166. uni.$emit('scroll');
  167. },
  168. onReachBottom: function() {
  169. this.getList();
  170. }
  171. }
  172. </script>
  173. <style lang="scss">
  174. .my-coupon .header {
  175. height: 200rpx;
  176. padding: 0 15rpx;
  177. background-color: var(--view-theme);
  178. border-bottom-left-radius: 10%;
  179. border-bottom-right-radius: 10%;
  180. .nav {
  181. border-radius: 6rpx;
  182. padding-top: 30rpx;
  183. .item {
  184. text-align: center;
  185. font-size: 26rpx;
  186. color: #FFFFFF;
  187. padding: 29rpx 0;
  188. opacity: 0.7;
  189. line-height: 2rpx;
  190. .num {
  191. margin-top: 18rpx;
  192. }
  193. }
  194. .item.on {
  195. opacity: 1;
  196. font-weight: bold;
  197. border-bottom: 5rpx solid #FFFFFF;
  198. }
  199. }
  200. }
  201. .my-coupon .listBox {
  202. margin: -73rpx auto 0 auto;
  203. padding: 0 30rpx;
  204. .list {
  205. width: 100%;
  206. height: 260rpx;
  207. overflow: hidden;
  208. background: #FFFFFF;
  209. border-radius: 12rpx;
  210. margin-bottom: 25rpx;
  211. text-align: center;
  212. .cross{
  213. display: flex;
  214. .cross-left{
  215. margin-top: 6rpx;
  216. .easy-loadimage,image{
  217. width: 200rpx;
  218. height: 200rpx;
  219. border-radius: 12rpx;
  220. }
  221. }
  222. .cross-right{
  223. margin-left: 20rpx;
  224. margin-top: 6rpx;
  225. .title{
  226. overflow:hidden;
  227. text-overflow:ellipsis;
  228. display:-webkit-box;
  229. -webkit-box-orient:vertical;
  230. -webkit-line-clamp:2;
  231. }
  232. .time{
  233. margin-top: 40rpx;
  234. font-size: 22rpx;
  235. font-weight: 400;
  236. color: #666666;
  237. }
  238. }
  239. }
  240. .left{
  241. width: 75%;
  242. height: 210rpx;
  243. margin-top: 20rpx;
  244. border-right: 2rpx dashed #E5E5E5;
  245. text-align: left;
  246. padding-left: 30rpx;
  247. .tips{
  248. font-size: 26rpx;
  249. font-weight: 600;
  250. color: #282828;
  251. display: block;
  252. overflow: auto;
  253. }
  254. .info{
  255. margin-top: 18rpx;
  256. display: flex;
  257. justify-content: flex-start;
  258. .info-box{
  259. margin-right: 25rpx;
  260. .easy-loadimage{
  261. display: inline-block;
  262. width: 130rpx;
  263. height: 130rpx;
  264. border-radius: 8rpx;
  265. }
  266. .money{
  267. text-align: center;
  268. font-size: 24rpx;
  269. font-weight: 400;
  270. color: #666666;
  271. margin-top: 4rpx;
  272. }
  273. }
  274. }
  275. }
  276. .right{
  277. width: 25%;
  278. height: 100%;
  279. position: relative;
  280. &::before,&::after{
  281. content: "";
  282. display: inline-block;
  283. width: 24rpx;
  284. height: 24rpx;
  285. background: #f5f5f5;
  286. border-radius: 100%;
  287. position: absolute;
  288. bottom: -12rpx;
  289. }
  290. &::before{
  291. left: -12rpx;
  292. }
  293. &::after{
  294. top: -12rpx;
  295. left: -12rpx;
  296. }
  297. .couponlogo{
  298. width: 112rpx;
  299. height: 32rpx;
  300. margin: 0 auto;
  301. font-size: 20rpx;
  302. font-weight: 400;
  303. line-height: 38rpx;
  304. color: #9B5434;
  305. background-size: 112rpx 32rpx;
  306. }
  307. .title{
  308. width: 146rpx;
  309. height:169rpx;
  310. margin: 30rpx auto 0;
  311. color: var(--view-priceColor);
  312. font-weight: 600;
  313. .font1{
  314. font-size: 26rpx;
  315. }
  316. .font2{
  317. font-size: 32rpx;
  318. }
  319. .font3{
  320. font-size: 24rpx;
  321. font-weight: 400;
  322. color: var(--view-theme);
  323. }
  324. p{
  325. margin-top: 10rpx;
  326. }
  327. .btn{
  328. width: 142rpx;
  329. background: linear-gradient(270deg, var(--view-bntColor21) 0%, var(--view-bntColor22) 100%);
  330. border-radius: 26rpx;
  331. font-size: 24rpx;
  332. font-weight: 400;
  333. color: #FFFFFF;
  334. line-height: 44rpx;
  335. text-align: center;
  336. margin-top: 20rpx;
  337. &.disabled{
  338. pointer-events: none;
  339. background: #ccc;
  340. color: #fff;
  341. border-color: #ccc;
  342. cursor: not-allowed;
  343. }
  344. }
  345. .shiyong{
  346. border: 2rpx solid var(--view-theme);
  347. background: none;
  348. color: var(--view-theme);
  349. border-radius: 26rpx;
  350. &.disabled{
  351. pointer-events: none;
  352. color: #ccc;
  353. border-color: #ccc;
  354. cursor: not-allowed;
  355. background: none;
  356. }
  357. }
  358. }
  359. }
  360. }
  361. .list:nth-child(1){
  362. .right{
  363. &::after{
  364. background-color: var(--view-theme);
  365. }
  366. }
  367. }
  368. }
  369. .noCommodity{
  370. width: 100%;
  371. margin-top: 4rpx;
  372. background-color: #f5f5f5;
  373. .pictrue{
  374. margin: 0 auto;
  375. }
  376. }
  377. </style>