coupon.vue 9.6 KB

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