coupon.vue 9.2 KB

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