coupon.vue 12 KB

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