coupon.vue 12 KB

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