cm-coupon-popup.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template name="coupon">
  2. <view class="coupon-template">
  3. <view class="coupon-title" @tap.stop="showPopup">
  4. <text class="text">优惠券:</text> <text class="text-coupon">-¥{{ coupon.couponAmount | NumFormat }}</text>
  5. <text class="iconfont icon-xiayibu"></text>
  6. </view>
  7. <!-- 优惠券 -->
  8. <tui-bottom-popup :radius="true" :show="popupShow" @close="hidePopup">
  9. <view class="tui-popup-box clearfix">
  10. <view class="title">
  11. <view class="title-l">优惠券</view>
  12. <view class="title-r" @click="showExchangePopup">兑换优惠券</view>
  13. </view>
  14. <div class="tui-popup-main coupon">
  15. <scroll-view class="tui-popup-scroll" scroll-y="true">
  16. <view class="coupon-empty" v-if="isCouponEmpty">
  17. <image
  18. class="empty-container-image"
  19. :src="StaticUrl + '/icon/icon-coupon-empty@2x.png'"
  20. ></image>
  21. <text class="error-text">暂无可用优惠券~</text>
  22. </view>
  23. <template>
  24. <view
  25. v-for="(coupon, index) in dataList"
  26. :key="index"
  27. class="coupon-list"
  28. @click.stop="checkedCoupon(index)"
  29. v-if="dataList.length > 0"
  30. >
  31. <view class="list-cell-le">
  32. <template v-if="coupon.couponTextFlag === 2">
  33. <view class="coupon-maxMoney six"> <text class="small">¥</text> {{ coupon.couponText }} </view>
  34. </template>
  35. <template v-else>
  36. <view class="coupon-maxMoney"> <text class="small">¥</text> {{ coupon.couponAmount }} </view>
  37. <view class="coupon-minMoney"> 满{{ coupon.touchPrice }}可用 </view>
  38. </template>
  39. </view>
  40. <view class="list-cell-ri">
  41. <view class="list-cell-top">
  42. <view class="list-cell-type">
  43. <view class="list-cell-tags">
  44. <template v-if="coupon.moneyCouponFlag == 1">
  45. <text class="tags" v-if="coupon.moneyCouponType == 1"
  46. >意向{{ coupon.couponType | TypeFormat }}</text
  47. >
  48. <text class="tags" v-else
  49. >定向{{ coupon.couponType | TypeFormat }}</text
  50. >
  51. </template>
  52. <template v-else>
  53. <text class="tags">{{ coupon.couponType | TypeFormat }}</text>
  54. </template>
  55. </view>
  56. <view class="list-cell-texts">
  57. <text v-if="coupon.couponType == 0">
  58. {{
  59. coupon.productType && coupon.productType == 1
  60. ? '全商城商品通用'
  61. : coupon.couponName
  62. }}
  63. </text>
  64. <text v-if="coupon.couponType == 1">
  65. {{
  66. coupon.categoryType == 1
  67. ? coupon.couponName
  68. : coupon.couponName
  69. }}
  70. </text>
  71. <text v-if="coupon.couponType == 3"
  72. >仅限购买店铺【{{ coupon.shopName }}】的商品</text
  73. >
  74. <text v-if="coupon.couponType == 4 || coupon.couponType == 2"
  75. >全商城商品通用</text
  76. >
  77. </view>
  78. </view>
  79. <view class="list-cell-btn">
  80. <view class="list-cell-checkbox">
  81. <view
  82. class="checkbox iconfont"
  83. :class="[coupon.ischecked ? 'icon-yixuanze' : 'icon-weixuanze']"
  84. >
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <view class="list-cell-time">{{ coupon.startDate }} - {{ coupon.endDate }}</view>
  90. </view>
  91. </view>
  92. </template>
  93. </scroll-view>
  94. </div>
  95. <view class="tui-right-flex tui-popup-btn" :style="{ paddingBottom: isIphoneX ? '68rpx' : '34rpx' }">
  96. <view class="tui-flex-1"> <view class="tui-button" @click="hidePopup">确定</view> </view>
  97. </view>
  98. </view>
  99. </tui-bottom-popup>
  100. </view>
  101. </template>
  102. <script>
  103. export default {
  104. name: 'coupon',
  105. props: {
  106. couponList: {
  107. type: Array
  108. }
  109. },
  110. data() {
  111. return {
  112. StaticUrl: this.$Static, //静态图片路径
  113. isIphoneX: this.$store.state.isIphoneX,
  114. popupShow: false,
  115. isCouponEmpty: false,
  116. checkedIndex: null,
  117. dataList: [],
  118. coupon: {
  119. couponAmount: 0,
  120. clubCouponId: 0
  121. }
  122. }
  123. },
  124. filters: {
  125. NumFormat(value) {
  126. //处理金额
  127. return Number(value).toFixed(2)
  128. },
  129. TypeFormat(value) {
  130. switch (value) {
  131. case 0:
  132. return '活动券'
  133. break
  134. case 1:
  135. return '品类券'
  136. break
  137. case 2:
  138. return '用户专享券'
  139. break
  140. case 3:
  141. return '店铺券'
  142. break
  143. case 4:
  144. return '新用户券'
  145. break
  146. }
  147. }
  148. },
  149. created() {
  150. this.initData(this.couponList)
  151. },
  152. watch: {
  153. couponList: {
  154. handler: function(el) {
  155. //监听对象的变换使用 function,箭头函数容易出现this指向不正确
  156. console.log(el)
  157. this.couponList = el
  158. },
  159. deep: true
  160. }
  161. },
  162. methods: {
  163. initData(data) {
  164. if (data.length > 0) {
  165. data.forEach((el, index) => {
  166. this.dataList.push(Object.assign({}, el, { ischecked: false }))
  167. })
  168. this.coupon.couponAmount = data[0].couponAmount
  169. this.dataList[0].ischecked = true
  170. this.isCouponEmpty = false
  171. } else {
  172. this.isCouponEmpty = true
  173. }
  174. },
  175. checkedCoupon(idx) {
  176. // 选择优惠券
  177. this.checkedIndex = idx
  178. this.dataList.forEach((el, index) => {
  179. if (this.checkedIndex == index) {
  180. el.ischecked = !el.ischecked
  181. } else {
  182. el.ischecked = false
  183. }
  184. })
  185. },
  186. showExchangePopup() {
  187. this.popupShow = false
  188. this.$parent.isExchangePopup = true
  189. },
  190. showPopup() {
  191. if (this.$parent.rebatecheck) {
  192. this.$util.msg('返佣订单不能使用优惠券', 2000)
  193. } else {
  194. this.popupShow = true
  195. }
  196. },
  197. hidePopup() {
  198. this.popupShow = false
  199. let coupon = {
  200. couponAmount: 0,
  201. clubCouponId: 0
  202. }
  203. this.dataList.forEach((el, index) => {
  204. if (el.ischecked) {
  205. coupon.couponAmount = el.couponAmount
  206. coupon.clubCouponId = el.clubCouponId
  207. }
  208. })
  209. this.coupon = coupon
  210. this.$emit('handleChoiceaCoupon', this.coupon)
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss">
  216. .coupon-template {
  217. width: 100%;
  218. height: auto;
  219. background: #ffffff;
  220. float: left;
  221. margin-top: 24rpx;
  222. .coupon-title {
  223. width: 702rpx;
  224. padding: 0 24rpx;
  225. height: 88rpx;
  226. line-height: 88rpx;
  227. position: relative;
  228. .text {
  229. font-size: $font-size-28;
  230. color: $text-color;
  231. font-weight: bold;
  232. }
  233. .text-coupon {
  234. display: inline-block;
  235. float: right;
  236. padding-right: 40rpx;
  237. line-height: 88rpx;
  238. font-size: 28rpx;
  239. color: #f94b4b;
  240. }
  241. .iconfont {
  242. width: 50rpx;
  243. height: 88rpx;
  244. line-height: 88rpx;
  245. color: #999999;
  246. display: block;
  247. position: absolute;
  248. right: 0;
  249. top: 0;
  250. }
  251. }
  252. }
  253. .tui-popup-box {
  254. position: relative;
  255. box-sizing: border-box;
  256. min-height: 220rpx;
  257. padding: 24rpx 24rpx 0 24rpx;
  258. .title {
  259. font-size: $font-size-34;
  260. color: $text-color;
  261. line-height: 88rpx;
  262. text-align: center;
  263. float: left;
  264. width: 100%;
  265. height: 88rpx;
  266. display: flex;
  267. box-sizing: border-box;
  268. padding: 0 24rpx;
  269. .title-l {
  270. flex: 1;
  271. text-align: left;
  272. }
  273. .title-r {
  274. flex: 1;
  275. text-align: right;
  276. color: #f94b4b;
  277. }
  278. }
  279. .tui-popup-main {
  280. width: 100%;
  281. float: left;
  282. padding-top: 10rpx;
  283. .tui-popup-scroll {
  284. width: 100%;
  285. height: 600rpx;
  286. .coupon-empty {
  287. width: 100%;
  288. height: 600rpx;
  289. display: flex;
  290. align-items: center;
  291. justify-content: center;
  292. flex-direction: column;
  293. position: fixed;
  294. background: $bg-color;
  295. .empty-container-image {
  296. width: 150rpx;
  297. height: 150rpx;
  298. margin-bottom: 0;
  299. margin-top: 0;
  300. }
  301. .error-text {
  302. font-size: $font-size-28;
  303. color: #999999;
  304. line-height: 88rpx;
  305. }
  306. }
  307. .coupon-list {
  308. width: 100%;
  309. height: 200rpx;
  310. margin-bottom: 24rpx;
  311. box-sizing: border-box;
  312. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-uesb@2x.png);
  313. background-size: cover;
  314. .list-cell-le {
  315. width: 224rpx;
  316. height: 100%;
  317. box-sizing: border-box;
  318. padding: 37rpx 0;
  319. float: left;
  320. .coupon-maxMoney {
  321. width: 100%;
  322. height: 78rpx;
  323. line-height: 78rpx;
  324. font-size: 56rpx;
  325. color: #ffffff;
  326. text-align: center;
  327. &.six{
  328. margin-top: 20rpx;
  329. }
  330. .small {
  331. font-size: $font-size-24;
  332. }
  333. }
  334. .coupon-minMoney {
  335. width: 100%;
  336. height: 33rpx;
  337. line-height: 33rpx;
  338. font-size: $font-size-24;
  339. color: #ffffff;
  340. text-align: center;
  341. }
  342. }
  343. .list-cell-ri {
  344. width: 478rpx;
  345. height: 100%;
  346. box-sizing: border-box;
  347. padding: 20rpx 24rpx 0 24rpx;
  348. float: right;
  349. .list-cell-top {
  350. width: 100%;
  351. height: 121rpx;
  352. float: left;
  353. border-bottom: 1px solid #e1e1e1;
  354. .list-cell-type {
  355. width: 286rpx;
  356. height: 100%;
  357. float: left;
  358. .list-cell-tags {
  359. width: 100%;
  360. height: 32rpx;
  361. margin-bottom: 7rpx;
  362. .tags {
  363. display: inline-block;
  364. padding: 0 10rpx;
  365. height: 32rpx;
  366. line-height: 32rpx;
  367. background-color: #ffdcce;
  368. color: #f94b4b;
  369. font-size: $font-size-20;
  370. border-radius: 8rpx;
  371. text-align: center;
  372. float: left;
  373. }
  374. }
  375. .list-cell-texts {
  376. width: 100%;
  377. height: auto;
  378. line-height: 35rpx;
  379. text-overflow: ellipsis;
  380. display: -webkit-box;
  381. word-break: break-all;
  382. -webkit-box-orient: vertical;
  383. -webkit-line-clamp: 2;
  384. overflow: hidden;
  385. font-size: 26rpx;
  386. color: #333333;
  387. }
  388. }
  389. .list-cell-btn {
  390. width: 128rpx;
  391. height: 100%;
  392. float: right;
  393. .list-cell-checkbox {
  394. width: 100%;
  395. height: 50%;
  396. .checkbox {
  397. width: 40rpx;
  398. line-height: 60rpx;
  399. float: right;
  400. box-sizing: border-box;
  401. text-align: center;
  402. text-decoration: none;
  403. -webkit-tap-highlight-color: transparent;
  404. overflow: hidden;
  405. color: #f94b4b;
  406. }
  407. }
  408. }
  409. }
  410. .list-cell-time {
  411. width: 100%;
  412. height: 58rpx;
  413. line-height: 58rpx;
  414. text-align: left;
  415. font-size: $font-size-20;
  416. color: #999999;
  417. }
  418. }
  419. }
  420. }
  421. .tui-popup-coupon {
  422. width: 100%;
  423. height: 500rpx;
  424. box-sizing: border-box;
  425. padding: 30rpx 20rpx;
  426. .tui-popup-h1 {
  427. width: 100%;
  428. height: 66rpx;
  429. display: flex;
  430. align-items: center;
  431. .tui-popup-text {
  432. flex: 1;
  433. height: 66rpx;
  434. line-height: 66rpx;
  435. font-size: $font-size-30;
  436. color: #333333;
  437. &.red {
  438. color: #f94b4b;
  439. }
  440. &.bold {
  441. font-weight: bold;
  442. }
  443. &.left {
  444. text-align: left;
  445. }
  446. &.right {
  447. text-align: right;
  448. }
  449. }
  450. }
  451. }
  452. }
  453. .tui-popup-btn {
  454. width: 100%;
  455. height: auto;
  456. float: left;
  457. margin-top: 24rpx;
  458. .tui-button {
  459. width: 100%;
  460. height: 88rpx;
  461. background: $btn-confirm;
  462. line-height: 88rpx;
  463. text-align: center;
  464. color: #ffffff;
  465. font-size: $font-size-28;
  466. border-radius: 44rpx;
  467. }
  468. }
  469. }
  470. </style>