index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <view class='my-coupon' :data-theme="theme">
  3. <view class='header'>
  4. <view class='nav acea-row row-around'>
  5. <view class='item' :class='type==0 ? "on": ""' @click="statusClick(0)">
  6. <view>全部</view>
  7. </view>
  8. <view class='item' :class='type==3 ? "on": ""' @click="statusClick(3)">
  9. <view>通用</view>
  10. </view>
  11. <view class='item' :class='type==4 ? "on": ""' @click="statusClick(4)">
  12. <view>品类</view>
  13. </view>
  14. <view class='item' :class='type==2 ? "on": ""' @click="statusClick(2)">
  15. <view>商品</view>
  16. </view>
  17. <view class='item' :class='type==5 ? "on": ""' @click="statusClick(5)">
  18. <view>品牌</view>
  19. </view>
  20. <view class='item' :class='type==6 ? "on": ""' @click="statusClick(6)">
  21. <view>跨店</view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="listBox">
  26. <view v-for="item in list" :key='item.id'>
  27. <view class="list acea-row row-around"
  28. :style="{'background-image': `url(${urlDomain}crmebimage/presets/get_coupon_bg.png)`}">
  29. <view class="left cross" v-if="item.productVoList.length == 1" @click="goList(item)">
  30. <view class="cross-left" v-for="(items,index) in item.productVoList" :key='index'>
  31. <image :src="items.image" mode=""></image>
  32. </view>
  33. <view class="tips cross-right">
  34. <view class="title line2">{{item.name || ''}}</view>
  35. <view class="couponlogo">{{item.category | couponTypeFilter}}</view>
  36. <view class="time"></view>
  37. </view>
  38. </view>
  39. <view class="left" v-else-if="item.productVoList.length > 1" @click="goList(item)">
  40. <view class="acea-row row-middle">
  41. <view class="couponlogo">{{item.category | couponTypeFilter}}</view>
  42. <view class="tips line1">{{item.name || ''}}</view>
  43. </view>
  44. <view class="info">
  45. <view class="info-box" v-for="(items,index) in item.productVoList" :key='index'>
  46. <view class="relative">
  47. <view v-show="items.stock===0" class="sellOut">已售罄</view>
  48. <image :src="items.image" mode=""></image>
  49. </view>
  50. <view class="money">¥ {{items.price}}</view>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="left cross" v-if="!item.productVoList.length">
  55. <view class="cross-left">
  56. <view class="_empty acea-row row-column row-center-wrapper">
  57. <text class="iconfont icon-fengmian"></text>
  58. <text>暂无商品</text>
  59. </view>
  60. </view>
  61. <view class="tips cross-right acea-row row-column row-between">
  62. <view class="title line2">{{item.name}}</view>
  63. <view class="couponlogo">{{item.category | couponTypeFilter}}</view>
  64. <view class="time"></view>
  65. </view>
  66. </view>
  67. <view class="right" :style="{'background-image': `url(${rightBg})`}">
  68. <view class="title"
  69. :class="item.lastTotal === 0 && item.isLimited?'text--w111-ccc':'font-color'">
  70. <view>
  71. <p>
  72. <text class='font1'>¥</text>
  73. <text class='font2'>{{parsePrice(item.money)}}</text>
  74. </p>
  75. <p>
  76. <text class='font3' v-if="item.minPrice == 0">无使用门槛</text>
  77. <text class='font3' v-else>满{{parsePrice(item.minPrice)}}元可用</text>
  78. </p>
  79. </view>
  80. <!-- isLimited是true限量,false不限量-->
  81. <view v-if="item.lastTotal === 0 && item.isLimited">
  82. <view class='btn bg-color-hui'>已领完</view>
  83. <span class="iconfont icon-yilingwan1"></span>
  84. </view>
  85. <view v-else>
  86. <view class="btn bg-color" v-if="!item.isUserReceive" @click="receiveCoupon(item)">立即领取
  87. </view>
  88. <view v-if="item.lastTotal > 0 && item.isUserReceive">
  89. <view class='btn bg-color' @click="goList(item)">去使用</view>
  90. <span class="iconfont icon-yilingqu"></span>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. <view class="loadingicon acea-row row-center-wrapper">
  99. <text class="loading iconfont icon-jiazai" :hidden="loading == false" style="color:#33;"></text>
  100. </view>
  101. <view class="empty-boxs noContent" v-if="!list.length && loaded">
  102. <emptyPage title="暂无优惠券可领取哦~" mTop="13%" :imgSrc="urlDomain + 'crmebimage/presets/noCoupon.png'">
  103. </emptyPage>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. import {
  109. getCouponLstApi,
  110. couponReceiveApi
  111. } from '@/api/activity.js';
  112. import emptyPage from '@/components/emptyPage.vue';
  113. let app = getApp();
  114. export default {
  115. components: {
  116. emptyPage
  117. },
  118. data() {
  119. return {
  120. type: '',
  121. urlDomain: this.$Cache.get("imgHost"),
  122. list: [],
  123. loading: false,
  124. loaded: false,
  125. page: 1,
  126. limit: 15,
  127. theme: app.globalData.theme,
  128. }
  129. },
  130. onLoad: function() {
  131. this.statusClick(0);
  132. },
  133. computed: {
  134. rightBg() {
  135. let theme = this.$Cache.get('theme');
  136. switch (theme) {
  137. case 'theme1':
  138. return this.urlDomain + 'crmebimage/presets/right_red.png'
  139. break;
  140. case 'theme2':
  141. return this.urlDomain + 'crmebimage/presets/right_orange.png'
  142. break;
  143. case 'theme3':
  144. return this.urlDomain + 'crmebimage/presets/right_green.png'
  145. break;
  146. case 'theme4':
  147. return this.urlDomain + 'crmebimage/presets/right_blue.png'
  148. break;
  149. case 'theme5':
  150. return this.urlDomain + 'crmebimage/presets/right_pink.png'
  151. break;
  152. default:
  153. break;
  154. }
  155. },
  156. gray_bg() {
  157. return this.urlDomain + 'crmebimage/presets/right_gray.png'
  158. }
  159. },
  160. methods: {
  161. parsePrice(price) {
  162. if (price >= 100) {
  163. return parseFloat(price)
  164. } else {
  165. return price
  166. }
  167. },
  168. // 领取优惠券
  169. receiveCoupon(item) {
  170. let that = this;
  171. couponReceiveApi(item.id).then(res => {
  172. item.isUserReceive = true;
  173. uni.showToast({
  174. title: '领取成功',
  175. icon: 'none'
  176. })
  177. }).catch(err => {
  178. uni.showToast({
  179. title: err,
  180. icon: 'none'
  181. })
  182. })
  183. },
  184. getList() {
  185. if (this.loading || this.loaded) return;
  186. this.loading = true;
  187. getCouponLstApi({
  188. category: this.type,
  189. page: this.page,
  190. limit: this.limit
  191. }).then(res => {
  192. this.list = this.list.concat(res.data.list);
  193. this.loading = false;
  194. this.loaded = res.data.list.length != this.limit;
  195. this.page++;
  196. })
  197. },
  198. //切换类型
  199. statusClick: function(status) {
  200. if (status === this.type) return;
  201. this.loaded = false;
  202. this.loading = false;
  203. this.page = 1;
  204. this.list = [];
  205. this.type = status;
  206. this.getList()
  207. },
  208. goList(item) {
  209. uni.navigateTo({
  210. url: `/pages/goods/coupon_goods_list/index?type=1&userCouponId=${item.id}&money=${item.money}&minPrice=${item.minPrice}&isUserReceive=${item.isUserReceive}`
  211. })
  212. }
  213. },
  214. onReachBottom: function() {
  215. this.getList();
  216. }
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. /deep/.sellOut {
  221. width: 96rpx;
  222. height: 32rpx;
  223. line-height: 28rpx;
  224. font-size: 20rpx;
  225. }
  226. .header {
  227. height: 200rpx;
  228. @include main_bg_color(theme);
  229. border-bottom-left-radius: 10%;
  230. border-bottom-right-radius: 10%;
  231. .nav {
  232. border-radius: 6rpx;
  233. padding-top: 30rpx;
  234. position: fixed;
  235. width: 100%;
  236. z-index: 9999999;
  237. @include main_bg_color(theme);
  238. padding-bottom: 16rpx;
  239. .item {
  240. text-align: center;
  241. font-size: 30rpx;
  242. color: #FFFFFF;
  243. padding: 29rpx 0;
  244. opacity: 0.7;
  245. line-height: 2rpx;
  246. .num {
  247. margin-top: 18rpx;
  248. }
  249. }
  250. .item.on {
  251. opacity: 1;
  252. font-weight: bold;
  253. border-bottom: 5rpx solid #FFFFFF;
  254. }
  255. }
  256. }
  257. .listBox {
  258. margin: -73rpx auto 0 auto;
  259. padding: 0 24rpx;
  260. .list {
  261. width: 100%;
  262. height: 260rpx;
  263. overflow: hidden;
  264. background-size: cover;
  265. border-radius: 12rpx;
  266. margin-bottom: 25rpx;
  267. text-align: center;
  268. .cross {
  269. display: flex;
  270. .cross-left {
  271. margin-top: 6rpx;
  272. image {
  273. width: 200rpx;
  274. height: 200rpx;
  275. border-radius: 12rpx;
  276. }
  277. ._empty {
  278. width: 200rpx;
  279. height: 200rpx;
  280. border-radius: 12rpx;
  281. @include cate-two-btn(theme);
  282. @include main_color(theme);
  283. font-size: 24rpx;
  284. .iconfont {
  285. font-size: 48rpx;
  286. padding-top: 10rpx;
  287. }
  288. }
  289. }
  290. .cross-right {
  291. margin-left: 20rpx;
  292. margin-top: 6rpx;
  293. margin-bottom: 14rpx;
  294. display: flex;
  295. flex-direction: column;
  296. justify-content: space-between;
  297. .title {
  298. width: 234rpx;
  299. overflow: hidden;
  300. text-overflow: ellipsis;
  301. display: -webkit-box;
  302. -webkit-box-orient: vertical;
  303. -webkit-line-clamp: 2;
  304. }
  305. .time {
  306. font-size: 20rpx;
  307. font-weight: 400;
  308. color: #666666;
  309. }
  310. .couponlogo {
  311. padding: 0 !important;
  312. /* #ifdef MP */
  313. width: 66rpx;
  314. height: 30rpx;
  315. border-radius: 14rpx;
  316. /* #endif */
  317. /* #ifdef H5 */
  318. width: 72rpx;
  319. /* #endif */
  320. /* #ifdef APP */
  321. width: 66rpx;
  322. /* #endif */
  323. text-align: center;
  324. }
  325. }
  326. }
  327. .left {
  328. width: 502rpx;
  329. height: 210rpx;
  330. margin-top: 20rpx;
  331. text-align: left;
  332. padding-left: 30rpx;
  333. background-color: #FFFFFF;
  334. .couponlogo {
  335. display: inline-table;
  336. height: 32rpx;
  337. line-height: 30rpx;
  338. border-radius: 16rpx;
  339. padding: 0 10rpx;
  340. font-size: 20rpx;
  341. margin-right: 12rpx;
  342. font-weight: 400;
  343. @include main_color(theme);
  344. @include coupons_border_color(theme);
  345. @include cate-two-btn(theme);
  346. }
  347. .tips {
  348. width: 360rpx;
  349. font-size: 26rpx;
  350. font-weight: 600;
  351. color: #282828;
  352. }
  353. .info {
  354. margin-top: 18rpx;
  355. display: flex;
  356. justify-content: flex-start;
  357. .info-box {
  358. margin-right: 25rpx;
  359. image {
  360. display: inline-block;
  361. width: 130rpx;
  362. height: 130rpx;
  363. border-radius: 8rpx;
  364. }
  365. .money {
  366. text-align: center;
  367. font-size: 24rpx;
  368. font-weight: 400;
  369. color: #666666;
  370. margin-top: 4rpx;
  371. }
  372. }
  373. }
  374. }
  375. .right {
  376. /* #ifdef APP */
  377. width: 188rpx;
  378. /* #endif */
  379. /* #ifndef APP */
  380. width: 200rpx;
  381. /* #endif */
  382. height: 100%;
  383. background-size: 100% 100%;
  384. position: relative;
  385. .icon-yilingqu,
  386. .icon-yilingwan1 {
  387. position: absolute;
  388. opacity: 0.4;
  389. font-size: 122rpx;
  390. top: -34rpx;
  391. }
  392. .title {
  393. width: 100%;
  394. height: 169rpx;
  395. margin: 30rpx auto 0;
  396. .font1 {
  397. font-size: 34rpx;
  398. font-weight: 600;
  399. }
  400. .font2 {
  401. font-size: 60rpx;
  402. font-weight: 600;
  403. }
  404. .font3 {
  405. font-size: 20rpx;
  406. font-weight: 400;
  407. }
  408. p {
  409. margin-top: 10rpx;
  410. }
  411. .btn {
  412. width: 142rpx;
  413. // @include linear-gradient(theme);
  414. border-radius: 26rpx;
  415. font-size: 24rpx;
  416. font-weight: 400;
  417. color: #FFFFFF;
  418. line-height: 44rpx;
  419. text-align: center;
  420. margin: 20rpx auto 0;
  421. &.disabled {
  422. pointer-events: none;
  423. background: #ccc;
  424. color: #fff;
  425. border-color: #ccc;
  426. cursor: not-allowed;
  427. }
  428. }
  429. .shiyong {
  430. border: 2rpx solid #E93323;
  431. background: none;
  432. color: #E93323;
  433. border-radius: 26rpx;
  434. &.disabled {
  435. pointer-events: none;
  436. color: #ccc;
  437. border-color: #ccc;
  438. cursor: not-allowed;
  439. background: none;
  440. }
  441. }
  442. }
  443. }
  444. }
  445. .list:nth-child(1) {
  446. .right {
  447. &::after {
  448. background-color: #E93323;
  449. }
  450. }
  451. }
  452. }
  453. .noCommodity {
  454. width: 100%;
  455. margin: -72rpx auto 0 auto;
  456. padding: 0 30rpx;
  457. .pictrue {
  458. width: 100%;
  459. height: 600rpx;
  460. background-color: #fff;
  461. border-radius: 6px;
  462. margin-bottom: 12px;
  463. text-align: center;
  464. color: #999;
  465. image {
  466. width: 400rpx;
  467. }
  468. }
  469. }
  470. </style>