sellerCoupon.vue 10 KB

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