You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

463 lines
11 KiB

3 months ago
  1. <template>
  2. <!-- 优惠券 -->
  3. <view v-if="couponList.length">
  4. <view :style="[...boxStyle]">
  5. <template v-if="listStyle == 0">
  6. <view class="scroll_box">
  7. <scroll-view scroll-x="true" class="scroll_view acea-row">
  8. <view class="no-warp acea-row row-middle">
  9. <view class="couponBg acea-row row-middle style1" v-for="(item, index) in couponList" :key="index"
  10. :style="[...contentConfig]">
  11. <view class="left">
  12. <view :style="[...priceColorStyle]"><text class="price-icon"></text><text
  13. class="price"
  14. :class="item.money.length>6?'sizePrice':''">{{item.money}}</text></view>
  15. <view class="title" :class="item.minPrice.length>6?'sizeTitle':''">
  16. {{item.minPrice}}元可用</view>
  17. </view>
  18. <view class="right" @click="getCoupon(item.isUse,item.id)">
  19. {{item.isUse?'已 领 取':'领 取'}}
  20. </view>
  21. </view>
  22. </view>
  23. </scroll-view>
  24. </view>
  25. </template>
  26. <template v-if="listStyle == 1">
  27. <view class="coupon1 acea-row row-middle">
  28. <scroll-view scroll-x="true" class="scroll_view">
  29. <view class="list acea-row row-middle">
  30. <view class="item" v-for="(item, index) in couponList" :key="index"
  31. :style="[...contentConfig]">
  32. <view class="money" :style="[...priceColorStyle]">
  33. <view :class="item.money.length>=6?'sizePrice-two':''"><text class="lable"
  34. :class="item.money.length>=6?'sizeLable-two':''">¥</text>{{item.money}}
  35. </view>
  36. <view class="tips">{{item.minPrice}}可用</view>
  37. </view>
  38. <view class="sill" :style="[...btnColorStyle]" @click="getCoupon(item.isUse,item.id)">
  39. {{item.isUse?'已领取':'去领取'}}
  40. </view>
  41. <image src="../../static/images/newVip02.png" />
  42. </view>
  43. </view>
  44. </scroll-view>
  45. </view>
  46. </template>
  47. <template v-if="listStyle == 2">
  48. <view class="scroll_box">
  49. <scroll-view scroll-x="true" class="scroll_view acea-row">
  50. <view class="no-warp acea-row row-middle">
  51. <view class="couponBg acea-row row-middle couponBg-new" v-for="(item, index) in couponList" :key="index"
  52. :style="[...contentConfig]">
  53. <view class="left">
  54. <view :style="[...priceColorStyle]"><text class="price-icon"></text><text
  55. class="price"
  56. :class="item.money.length>6?'sizePrice':''">{{item.money}}</text></view>
  57. <view class="title" :class="item.minPrice.length>6?'sizeTitle':''">
  58. {{item.minPrice}}元可用</view>
  59. </view>
  60. <view class="right" @click="getCoupon(item.isUse,item.id)" v-if="!item.isUse">
  61. 立即领取
  62. </view>
  63. <view class="right" @click="getCoupon(item.isUse,item.id)" v-else>
  64. 立即使用
  65. </view>
  66. </view>
  67. </view>
  68. </scroll-view>
  69. </view>
  70. </template>
  71. <template v-if="listStyle == 3">
  72. <view class="coupon5 acea-row row-middle" :style="[...boxBg]">
  73. <scroll-view scroll-x="true" style="white-space: nowrap; display: flex">
  74. <view class="list acea-row row-middle">
  75. <view class="item acea-row row-middle" v-for="(item, index) in couponList" :key="index"
  76. :style="[...contentConfig]">
  77. <view class="left">
  78. <view :class="item.money.length>=6?'sizePrice-four':''"
  79. :style="[...priceColorStyle]" class="money"><text
  80. class="label">¥</text>{{item.money}}
  81. </view>
  82. <view class="tips">{{item.minPrice}}可用</view>
  83. </view>
  84. <view class="right acea-row row-center">
  85. <view class="rightCon" @click="getCoupon(item.isUse,item.id)">
  86. {{item.isUse?'已 领 取':'领 取'}}
  87. </view>
  88. </view>
  89. <view class="roll" :style="[...boxBg]"></view>
  90. </view>
  91. </view>
  92. </scroll-view>
  93. </view>
  94. </template>
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. // +----------------------------------------------------------------------
  100. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  101. // +----------------------------------------------------------------------
  102. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  103. // +----------------------------------------------------------------------
  104. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  105. // +----------------------------------------------------------------------
  106. // | Author: CRMEB Team <admin@crmeb.com>
  107. // +----------------------------------------------------------------------
  108. import {
  109. getCoupons,
  110. setCouponReceive
  111. } from "@/api/api.js"
  112. let app = getApp();
  113. export default {
  114. name: 'homeCoupon',
  115. props: {
  116. dataConfig: {
  117. type: Object,
  118. default: () => {}
  119. }
  120. },
  121. data() {
  122. return {
  123. urlDomain: this.$Cache.get("imgHost"),
  124. couponList: [],
  125. listStyle: 0,
  126. themeColor:this.$options.filters.filterTheme(app.globalData.theme)
  127. };
  128. },
  129. computed: {
  130. //最外层盒子的样式
  131. boxStyle() {
  132. return [{
  133. 'border-radius': 2 * this.dataConfig.bgStyle.val ? 2 * this.dataConfig.bgStyle.val + 'rpx' :
  134. '0'
  135. },
  136. {
  137. background: this.listStyle != 3 ?
  138. `linear-gradient(to right,${this.dataConfig.bgColor.color[0].item}, ${this.dataConfig.bgColor.color[1].item})` :
  139. this.dataConfig.bgColorNew.color[0].item,
  140. },
  141. {
  142. 'margin': 2 * this.dataConfig.mbConfig.val + 'rpx' + ' ' + 2 * this.dataConfig.lrConfig.val +
  143. 'rpx' +
  144. ' ' + 0
  145. },
  146. {
  147. 'padding': 2 * this.dataConfig.upConfig.val + 'rpx' + ' ' + '20rpx' + ' ' + 2 * this.dataConfig
  148. .downConfig
  149. .val + 'rpx'
  150. },
  151. ];
  152. },
  153. boxBg() {
  154. return [{
  155. background: this.dataConfig.bgColorNew.color[0].item,
  156. }, ];
  157. },
  158. //内容边距
  159. contentConfig() {
  160. return [{
  161. 'margin-right': this.dataConfig.contentConfig.val ? 2 * this.dataConfig.contentConfig.val +
  162. 'rpx' : '0'
  163. },
  164. {
  165. 'background': this.listStyle == 1 ?
  166. (this.dataConfig.themeStyleConfig.tabVal?this.dataConfig.itemBgColor.color[0].item:this.themeColor) : this.listStyle == 3 ?
  167. `linear-gradient(180deg,${this.dataConfig.btnColor.color[0].item}, ${this.dataConfig.themeStyleConfig.tabVal?this.dataConfig.btnColor.color[1].item:this.themeColor})` :
  168. '',
  169. },
  170. ];
  171. },
  172. //优惠金额颜色
  173. priceColorStyle() {
  174. return [{
  175. 'color': this.dataConfig.themeStyleConfig.tabVal?this.dataConfig.priceColor.color[0].item:this.themeColor
  176. }];
  177. },
  178. //领取按钮
  179. btnColorStyle() {
  180. return [{
  181. 'background': `linear-gradient(90deg,${this.dataConfig.themeStyleConfig.tabVal?this.dataConfig.btnColor.color[0].item:'#FF7931'}, ${this.dataConfig.themeStyleConfig.tabVal?this.dataConfig.btnColor.color[1].item:this.themeColor})`,
  182. }, ];
  183. },
  184. //展示数量
  185. limit() {
  186. return this.dataConfig.numConfig.val
  187. },
  188. },
  189. mounted() {
  190. this.getList();
  191. this.setConfig()
  192. },
  193. methods: {
  194. getCoupon(isUse, id) {
  195. let that = this
  196. if (!isUse) {
  197. setCouponReceive(id).then(res => {
  198. that.getList();
  199. })
  200. }
  201. },
  202. setConfig(data) {
  203. this.listStyle = this.dataConfig.tabConfig.tabVal;
  204. },
  205. //优惠券列表
  206. getList() {
  207. getCoupons({
  208. page: 1,
  209. limit: this.limit
  210. }).then(res => {
  211. this.couponList = res.data.list;
  212. })
  213. },
  214. //去更多
  215. goPage() {
  216. this.$util.navigateTo(this.dataConfig.linkConfig.val ? this.dataConfig.linkConfig.val :
  217. '/pages/activity/couponList/index')
  218. }
  219. }
  220. };
  221. </script>
  222. <style lang="scss" scoped>
  223. .scroll_box {
  224. display: flex;
  225. overflow: hidden;
  226. }
  227. .couponBg.style1{
  228. width: 254rpx;
  229. height: 144rpx;
  230. background: url('../../static/images/couponBg.png');
  231. background-repeat: no-repeat;
  232. }
  233. .couponBg {
  234. background-size: contain;
  235. background-repeat: no-repeat;
  236. flex-shrink: 0;
  237. color: #fff;
  238. .left {
  239. width: 80%;
  240. text-align: center;
  241. .price-icon {
  242. font-weight: 500;
  243. font-size: 30rpx;
  244. }
  245. .price {
  246. font-weight: 500;
  247. font-size: 52rpx;
  248. }
  249. .sizePrice {
  250. font-size: 38rpx !important;
  251. }
  252. .sizeTitle {
  253. font-size: 20rpx !important;
  254. }
  255. .title {
  256. font-weight: 400;
  257. font-size: 26rpx;
  258. }
  259. }
  260. .right {
  261. /* #ifdef H5 */
  262. margin-left: 10rpx;
  263. /* #endif */
  264. font-size: 26rpx;
  265. text-align: center;
  266. writing-mode: tb-rl;
  267. }
  268. }
  269. .couponBg-new.couponBg {
  270. width: 137px;
  271. height: 75px;
  272. background: url('../../static/images/couponBg2.png') !important;
  273. .right {
  274. width: 13%;
  275. color: #e93323;
  276. font-weight: 400;
  277. font-size: 13px;
  278. }
  279. .title {
  280. color: #e93323;
  281. }
  282. .sizePrice {
  283. font-size: 36rpx !important;
  284. margin-right: 10rpx;
  285. }
  286. }
  287. .coupon1 {
  288. flex-shrink: 0;
  289. overflow: hidden;
  290. .list {
  291. margin-top: 16rpx;
  292. display: inline-flex;
  293. flex-wrap: nowrap;
  294. .item {
  295. width: 156rpx;
  296. height: 152rpx;
  297. background: #f12a13;
  298. position: relative;
  299. border-radius: 12rpx 12rpx 30rpx 30rpx;
  300. .money {
  301. width: 140rpx;
  302. height: 106rpx;
  303. background: #ffffff;
  304. border: 2rpx solid #fceae9;
  305. position: absolute;
  306. left: 9rpx;
  307. top: -16rpx;
  308. text-align: center;
  309. font-size: 40rpx;
  310. font-family: D-DIN-PRO, D-DIN-PRO;
  311. font-weight: 600;
  312. color: #e93323;
  313. padding-top: 6px;
  314. border-radius: 12rpx 12rpx 0 0;
  315. .lable {
  316. font-size: 28rpx;
  317. }
  318. .tips {
  319. font-size: 18rpx;
  320. color: #999999;
  321. font-weight: 500;
  322. }
  323. .sizePrice {
  324. // font-size: 24rpx;
  325. }
  326. }
  327. .sill {
  328. position: absolute;
  329. bottom: -2rpx;
  330. left: 0;
  331. width: 100%;
  332. height: 78rpx;
  333. // background: linear-gradient(90deg, #e93323 0%, #ff7931 100%);
  334. color: #fff;
  335. line-height: 92rpx;
  336. border-radius: 0 0 30rpx 30rpx;
  337. font-size: 20rpx;
  338. text-align: center;
  339. }
  340. image {
  341. position: absolute;
  342. left: 0;
  343. width: 156rpx;
  344. height: 20rpx;
  345. bottom: 58rpx;
  346. }
  347. }
  348. }
  349. }
  350. .coupon5 {
  351. flex-shrink: 0;
  352. background: #ffffff;
  353. border-radius: 16rpx;
  354. width: 100%;
  355. overflow: hidden;
  356. .list {
  357. flex-wrap: nowrap;
  358. .item {
  359. flex-shrink: 0;
  360. width: 228rpx;
  361. height: 108rpx;
  362. border-radius: 12rpx;
  363. position: relative;
  364. .roll {
  365. width: 16rpx;
  366. height: 16rpx;
  367. background: #fff;
  368. border-radius: 50%;
  369. position: absolute;
  370. left: -8rpx;
  371. }
  372. .right {
  373. flex: 1;
  374. .rightCon {
  375. font-size: 22rpx;
  376. color: #fff;
  377. text-align: center;
  378. writing-mode: tb-rl;
  379. }
  380. }
  381. .left {
  382. width: 172rpx;
  383. height: 100%;
  384. background: linear-gradient(0deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.8) 100%);
  385. border-radius: 12rpx;
  386. text-align: center;
  387. color: #e93323;
  388. display: flex;
  389. flex-direction: column;
  390. justify-content: center;
  391. .money {
  392. font-size: 42rpx;
  393. font-family: D-DIN-PRO, D-DIN-PRO;
  394. font-weight: 600;
  395. .label {
  396. font-size: 28rpx;
  397. }
  398. }
  399. .tips {
  400. font-size: 22rpx;
  401. }
  402. }
  403. }
  404. }
  405. }
  406. .no-warp {
  407. flex-wrap: nowrap;
  408. }
  409. .scroll_view {
  410. white-space: nowrap;
  411. }
  412. .sizePrice-two {
  413. font-size: 24rpx;
  414. margin-top: 5px;
  415. }
  416. .sizeLable-two {
  417. font-size: 18rpx !important;
  418. }
  419. .sizePrice-three {
  420. font-size: 32rpx !important;
  421. }
  422. .sizePrice-three-tips {
  423. font-size: 22rpx !important;
  424. margin-left: 6rpx !important;
  425. }
  426. .sizePrice-four {
  427. font-size: 30rpx !important;
  428. }
  429. </style>