sellerCoupon.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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. if(this.$parent.rebatecheck){
  160. this.$util.msg('返佣订单不能使用优惠券',2000)
  161. }else{
  162. this.popupShow = true
  163. }
  164. },
  165. hidePopup(){
  166. this.popupShow = false
  167. let coupon = {
  168. couponAmount:0,
  169. clubCouponId:0,
  170. }
  171. this.dataList.forEach((el,index) => {
  172. if(el.ischecked){
  173. coupon.couponAmount = el.couponAmount
  174. coupon.clubCouponId = el.clubCouponId
  175. }
  176. })
  177. this.coupon = coupon
  178. this.$emit('handleChoiceaCoupon',this.coupon)
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss">
  184. .coupon-template{
  185. width: 100%;
  186. height: auto;
  187. background: #FFFFFF;
  188. float: left;
  189. margin-top: 24rpx;
  190. .coupon-title{
  191. width: 702rpx;
  192. padding: 0 24rpx;
  193. height: 88rpx;
  194. line-height: 88rpx;
  195. position: relative;
  196. .text{
  197. font-size: $font-size-28;
  198. color: $text-color;
  199. font-weight: bold;
  200. }
  201. .text-coupon{
  202. display: inline-block;
  203. float: right;
  204. padding-right: 30rpx;
  205. line-height: 88rpx;
  206. font-size: 28rpx;
  207. color: #f94b4b;
  208. }
  209. .iconfont{
  210. width: 50rpx;
  211. height: 88rpx;
  212. line-height: 88rpx;
  213. color: #999999;
  214. display: block;
  215. position: absolute;
  216. right: 0;
  217. top: 0;
  218. }
  219. }
  220. }
  221. .tui-popup-box {
  222. position: relative;
  223. box-sizing: border-box;
  224. min-height: 220rpx;
  225. padding:24rpx 24rpx 0 24rpx;
  226. .title{
  227. font-size: $font-size-34;
  228. color: $text-color;
  229. line-height: 88rpx;
  230. text-align: center;
  231. float: left;
  232. width: 100%;
  233. height: 88rpx;
  234. display: flex;
  235. box-sizing: border-box;
  236. padding: 0 24rpx;
  237. .title-l{
  238. flex: 1;
  239. text-align: left;
  240. }
  241. .title-r{
  242. flex: 1;
  243. text-align: right;
  244. color: #f94b4b;
  245. }
  246. }
  247. .tui-popup-main{
  248. width: 100%;
  249. float: left;
  250. padding-top: 10rpx;
  251. .tui-popup-scroll{
  252. width: 100%;
  253. height: 600rpx;
  254. .coupon-empty{
  255. width: 100%;
  256. height: 600rpx;
  257. display: flex;
  258. align-items: center;
  259. justify-content: center;
  260. flex-direction: column;
  261. position: fixed;
  262. background: $bg-color;
  263. .empty-container-image{
  264. width: 150rpx;
  265. height: 150rpx;
  266. margin-bottom: 0;
  267. margin-top: 0;
  268. }
  269. .error-text{
  270. font-size: $font-size-28;
  271. color: #999999;
  272. line-height: 88rpx;
  273. }
  274. }
  275. .coupon-list{
  276. width: 100%;
  277. height: 200rpx;
  278. margin-bottom: 24rpx;
  279. box-sizing: border-box;
  280. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-uesb@2x.png);
  281. background-size: cover;
  282. .list-cell-le{
  283. width: 224rpx;
  284. height: 100%;
  285. box-sizing: border-box;
  286. padding: 37rpx 0;
  287. float: left;
  288. .coupon-maxMoney{
  289. width: 100%;
  290. height: 78rpx;
  291. line-height: 78rpx;
  292. font-size: 56rpx;
  293. color: #FFFFFF;
  294. text-align: center;
  295. .small{
  296. font-size: $font-size-24;
  297. }
  298. }
  299. .coupon-minMoney{
  300. width: 100%;
  301. height: 33rpx;
  302. line-height: 33rpx;
  303. font-size: $font-size-24;
  304. color: #FFFFFF;
  305. text-align: center;
  306. }
  307. }
  308. .list-cell-ri{
  309. width: 478rpx;
  310. height: 100%;
  311. box-sizing: border-box;
  312. padding: 20rpx 24rpx 0 24rpx;
  313. float: right;
  314. .list-cell-top{
  315. width: 100%;
  316. height: 121rpx;
  317. float: left;
  318. border-bottom: 1px solid #e1e1e1;
  319. .list-cell-type{
  320. width: 286rpx;
  321. height: 100%;
  322. float: left;
  323. .list-cell-tags{
  324. width: 100%;
  325. height: 32rpx;
  326. margin-bottom: 7rpx;
  327. .tags{
  328. display: inline-block;
  329. padding: 0 10rpx;
  330. height: 32rpx;
  331. line-height: 32rpx;
  332. background-color: #ffdcce;
  333. color: #f94b4b;
  334. font-size: $font-size-20;
  335. border-radius: 8rpx;
  336. text-align: center;
  337. float: left;
  338. }
  339. }
  340. .list-cell-texts{
  341. width: 100%;
  342. height: auto;
  343. line-height:35rpx;
  344. text-overflow:ellipsis;
  345. display: -webkit-box;
  346. word-break: break-all;
  347. -webkit-box-orient: vertical;
  348. -webkit-line-clamp: 2;
  349. overflow: hidden;
  350. font-size: 26rpx;
  351. color: #333333;
  352. }
  353. }
  354. .list-cell-btn{
  355. width: 128rpx;
  356. height: 100%;
  357. float: right;
  358. .list-cell-checkbox{
  359. width: 100%;
  360. height: 50%;
  361. .checkbox{
  362. width: 40rpx;
  363. line-height: 60rpx;
  364. float: right;
  365. box-sizing: border-box;
  366. text-align: center;
  367. text-decoration: none;
  368. -webkit-tap-highlight-color: transparent;
  369. overflow: hidden;
  370. color: #f94b4b;
  371. }
  372. }
  373. }
  374. }
  375. .list-cell-time{
  376. width: 100%;
  377. height: 58rpx;
  378. line-height: 58rpx;
  379. text-align: left;
  380. font-size: $font-size-20;
  381. color: #999999;
  382. }
  383. }
  384. }
  385. }
  386. .tui-popup-coupon{
  387. width: 100%;
  388. height: 500rpx;
  389. box-sizing: border-box;
  390. padding:30rpx 20rpx;
  391. .tui-popup-h1{
  392. width: 100%;
  393. height: 66rpx;
  394. display: flex;
  395. align-items: center;
  396. .tui-popup-text{
  397. flex: 1;
  398. height: 66rpx;
  399. line-height: 66rpx;
  400. font-size: $font-size-30;
  401. color: #333333;
  402. &.red{
  403. color: #f94b4b;
  404. }
  405. &.bold{
  406. font-weight: bold;
  407. }
  408. &.left{
  409. text-align: left;
  410. }
  411. &.right{
  412. text-align: right;
  413. }
  414. }
  415. }
  416. }
  417. }
  418. .tui-popup-btn {
  419. width: 100%;
  420. height: auto;
  421. float: left;
  422. margin-top: 24rpx;
  423. .tui-button{
  424. width: 100%;
  425. height: 88rpx;
  426. background: $btn-confirm;
  427. line-height: 88rpx;
  428. text-align: center;
  429. color: #FFFFFF;
  430. font-size: $font-size-28;
  431. border-radius: 44rpx;
  432. }
  433. }
  434. }
  435. </style>