sellerCoupon.vue 10 KB

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