coupon.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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. data.forEach((el,index) => {
  126. this.dataList.push(Object.assign({},el,{ischecked:false}))
  127. })
  128. this.coupon.couponAmount = data[0].couponAmount
  129. this.dataList[0].ischecked = true
  130. },
  131. checkedCoupon(idx){// 选择优惠券
  132. this.checkedIndex = idx;
  133. this.dataList.forEach((el,index) => {
  134. if(this.checkedIndex == index){
  135. el.ischecked = !el.ischecked;
  136. }else{
  137. el.ischecked = false
  138. }
  139. })
  140. },
  141. showExchangePopup(){
  142. this.popupShow = false
  143. this.$parent.isExchangePopup = true
  144. },
  145. showPopup(){
  146. this.popupShow = true
  147. },
  148. hidePopup(){
  149. this.popupShow = false
  150. let coupon = {
  151. couponAmount:0,
  152. clubCouponId:0,
  153. };
  154. this.dataList.forEach((el,index) => {
  155. if(el.ischecked){
  156. coupon.couponAmount = el.couponAmount
  157. coupon.clubCouponId = el.clubCouponId
  158. }
  159. })
  160. this.coupon = coupon
  161. this.$emit('handleChoiceaCoupon',this.coupon);
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang="scss">
  167. .coupon-template{
  168. width: 100%;
  169. height: auto;
  170. background: #FFFFFF;
  171. float: left;
  172. margin-top: 24rpx;
  173. .coupon-title{
  174. width: 702rpx;
  175. padding: 0 24rpx;
  176. height: 88rpx;
  177. line-height: 88rpx;
  178. position: relative;
  179. .text{
  180. font-size: $font-size-28;
  181. color: $text-color;
  182. }
  183. .text-coupon{
  184. display: inline-block;
  185. float: right;
  186. padding-right: 30rpx;
  187. line-height: 88rpx;
  188. font-size: 28rpx;
  189. color: #f94b4b;
  190. }
  191. .iconfont{
  192. width: 50rpx;
  193. height: 88rpx;
  194. line-height: 88rpx;
  195. color: #999999;
  196. display: block;
  197. position: absolute;
  198. right: 0;
  199. top: 0;
  200. }
  201. }
  202. }
  203. .tui-popup-box {
  204. position: relative;
  205. box-sizing: border-box;
  206. min-height: 220rpx;
  207. padding:24rpx 24rpx 0 24rpx;
  208. .title{
  209. font-size: $font-size-34;
  210. color: $text-color;
  211. line-height: 88rpx;
  212. text-align: center;
  213. float: left;
  214. width: 100%;
  215. height: 88rpx;
  216. display: flex;
  217. box-sizing: border-box;
  218. padding: 0 24rpx;
  219. .title-l{
  220. flex: 1;
  221. text-align: left;
  222. }
  223. .title-r{
  224. flex: 1;
  225. text-align: right;
  226. color: #f94b4b;
  227. }
  228. }
  229. .tui-popup-main{
  230. width: 100%;
  231. float: left;
  232. padding-top: 10rpx;
  233. .tui-popup-scroll{
  234. width: 100%;
  235. height: 600rpx;
  236. .coupon-list{
  237. width: 100%;
  238. height: 200rpx;
  239. margin-bottom: 24rpx;
  240. box-sizing: border-box;
  241. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-uesb@2x.png);
  242. background-size: cover;
  243. .list-cell-le{
  244. width: 224rpx;
  245. height: 100%;
  246. box-sizing: border-box;
  247. padding: 37rpx 0;
  248. float: left;
  249. .coupon-maxMoney{
  250. width: 100%;
  251. height: 78rpx;
  252. line-height: 78rpx;
  253. font-size: 56rpx;
  254. color: #FFFFFF;
  255. text-align: center;
  256. .small{
  257. font-size: $font-size-24;
  258. }
  259. }
  260. .coupon-minMoney{
  261. width: 100%;
  262. height: 33rpx;
  263. line-height: 33rpx;
  264. font-size: $font-size-24;
  265. color: #FFFFFF;
  266. text-align: center;
  267. }
  268. }
  269. .list-cell-ri{
  270. width: 478rpx;
  271. height: 100%;
  272. box-sizing: border-box;
  273. padding: 20rpx 24rpx 0 24rpx;
  274. float: right;
  275. .list-cell-top{
  276. width: 100%;
  277. height: 121rpx;
  278. float: left;
  279. border-bottom: 1px solid #e1e1e1;
  280. .list-cell-type{
  281. width: 286rpx;
  282. height: 100%;
  283. float: left;
  284. .list-cell-tags{
  285. width: 100%;
  286. height: 32rpx;
  287. margin-bottom: 7rpx;
  288. .tags{
  289. display: inline-block;
  290. padding: 0 10rpx;
  291. height: 32rpx;
  292. line-height: 32rpx;
  293. background-color: #ffdcce;
  294. color: #f94b4b;
  295. font-size: $font-size-20;
  296. border-radius: 8rpx;
  297. text-align: center;
  298. float: left;
  299. }
  300. }
  301. .list-cell-texts{
  302. width: 100%;
  303. height: auto;
  304. line-height:35rpx;
  305. text-overflow:ellipsis;
  306. display: -webkit-box;
  307. word-break: break-all;
  308. -webkit-box-orient: vertical;
  309. -webkit-line-clamp: 2;
  310. overflow: hidden;
  311. font-size: 26rpx;
  312. color: #333333;
  313. }
  314. }
  315. .list-cell-btn{
  316. width: 128rpx;
  317. height: 100%;
  318. float: right;
  319. .list-cell-checkbox{
  320. width: 100%;
  321. height: 50%;
  322. .checkbox{
  323. width: 40rpx;
  324. line-height: 60rpx;
  325. float: right;
  326. box-sizing: border-box;
  327. text-align: center;
  328. text-decoration: none;
  329. -webkit-tap-highlight-color: transparent;
  330. overflow: hidden;
  331. color: #f94b4b;
  332. }
  333. }
  334. }
  335. }
  336. .list-cell-time{
  337. width: 100%;
  338. height: 58rpx;
  339. line-height: 58rpx;
  340. text-align: left;
  341. font-size: $font-size-20;
  342. color: #999999;
  343. }
  344. }
  345. }
  346. }
  347. .tui-popup-coupon{
  348. width: 100%;
  349. height: 500rpx;
  350. box-sizing: border-box;
  351. padding:30rpx 20rpx;
  352. .tui-popup-h1{
  353. width: 100%;
  354. height: 66rpx;
  355. display: flex;
  356. align-items: center;
  357. .tui-popup-text{
  358. flex: 1;
  359. height: 66rpx;
  360. line-height: 66rpx;
  361. font-size: $font-size-30;
  362. color: #333333;
  363. &.red{
  364. color: #f94b4b;
  365. }
  366. &.bold{
  367. font-weight: bold;
  368. }
  369. &.left{
  370. text-align: left;
  371. }
  372. &.right{
  373. text-align: right;
  374. }
  375. }
  376. }
  377. }
  378. }
  379. .tui-popup-btn {
  380. width: 100%;
  381. height: auto;
  382. float: left;
  383. margin-top: 24rpx;
  384. .tui-button{
  385. width: 100%;
  386. height: 88rpx;
  387. background: $btn-confirm;
  388. line-height: 88rpx;
  389. text-align: center;
  390. color: #FFFFFF;
  391. font-size: $font-size-28;
  392. border-radius: 44rpx;
  393. }
  394. }
  395. }
  396. </style>