sellerCoupon.vue 11 KB

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