sellerCoupon.vue 10 KB

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