cm-coupon-popup.vue 9.7 KB

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