couponCenter.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <view class="container">
  3. <!-- 优惠券列表区域 -->
  4. <view class="body">
  5. <!-- 每一张优惠券区域 -->
  6. <view class="body_item" v-for="item in list" :key="item.id">
  7. <img src="../../static/my/couponTitle.png" />
  8. <view class="item_type" v-if="item.type === 2">折扣卷</view>
  9. <view class="item_type" v-if="item.type === 1">代金卷</view>
  10. <view class="item_box">
  11. <view class="box_left">
  12. <view class="left_title">{{ item.name }}</view>
  13. <view class="left_time">{{ item.effectiveStartDate.slice(0, 16) }} - {{ item.effectiveEndDate.slice(0, 16) }} 可领取</view>
  14. <view class="left_tags">
  15. <view class="tag" v-if="item.hotelIds.includes('-1')">全名宿</view>
  16. <view class="tag" v-else @click="handleClickTag(item.hotelIds)">
  17. 指定民宿
  18. <img src="../../static/index/right2.png" />
  19. </view>
  20. </view>
  21. </view>
  22. <view class="box_right">
  23. <view class="right_info">
  24. <view class="info_top">{{ item.type === 1 ? '¥' + item.deductionPrice : item.rebatePrice + '折' }}</view>
  25. <view class="info_bottom" :class="{ color: item.meetPrice === 0 }">{{ item.meetPrice === 0 ? '无门槛' : '满' + item.meetPrice + '可用' }}</view>
  26. <view class="info_bottom">
  27. {{ item.type === 2 ? '最多减免' + item.maxDeduction : '' }}
  28. </view>
  29. <view class="info_btn" v-if="item.claimStatus === 1" @click="handleGet(item.id, item.effectiveEndDate)">立即领取</view>
  30. <view class="info_btn2" v-else>已领取</view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="noData" v-if="list.length === 0">
  37. <img lazy-load :lazy-load-margin="0" src="../../static/images/noData.png" />
  38. 暂无数据
  39. </view>
  40. <!-- 指定民宿弹窗区域 -->
  41. <uni-popup ref="popup" type="center" :is-mask-click="false">
  42. <view class="popup_body">
  43. <view class="popup_header">
  44. <img src="../../static/my/popup_title.png" />
  45. <view class="header_title">指定民宿</view>
  46. <img src="../../static/my/popup_title.png" />
  47. </view>
  48. <view class="popup_center">{{ hotels }}</view>
  49. <view class="popup_btn" @click="handleClose">我知道了</view>
  50. </view>
  51. </uni-popup>
  52. </view>
  53. </template>
  54. <script>
  55. var dayjs = require('dayjs')
  56. export default {
  57. data() {
  58. return {
  59. // 优惠券列表数据
  60. list: [],
  61. // 当前页
  62. page: 1,
  63. // 每页多少条
  64. rows: 6,
  65. // 总条数
  66. total: null,
  67. // 指定民宿信息
  68. hotels: ''
  69. }
  70. },
  71. onLoad() {
  72. this.getData()
  73. },
  74. onReachBottom() {
  75. if (this.list.length < this.total) {
  76. this.page++
  77. this.getData()
  78. } else {
  79. uni.showToast({
  80. title: '没有更多数据了',
  81. icon: 'none'
  82. })
  83. }
  84. },
  85. methods: {
  86. async getData() {
  87. const res = await this.$myRequest({
  88. url: '/mhotel/hccouponCollection.action',
  89. data: {
  90. page: this.page,
  91. rows: this.rows
  92. }
  93. })
  94. // console.log(res);
  95. if (res.code === 200 && res.page.pageList) {
  96. this.list = [...this.list, ...res.page.pageList]
  97. this.total = res.page.total
  98. this.list.forEach((ele) => {
  99. ele.hotelIds = ele.hotelIds.split(',')
  100. })
  101. }
  102. },
  103. // 点击指定民宿tag回调
  104. async handleClickTag(ids) {
  105. const res = await this.$myRequest({
  106. url: '/mhotel/hcdesignatedHotel.action',
  107. data: {
  108. hotelIds: ids.join()
  109. }
  110. })
  111. // console.log(res);
  112. if (res.code === 200) {
  113. this.hotels = res.data.name
  114. }
  115. this.$refs.popup.open()
  116. },
  117. // 领取优惠券请求
  118. async handleGet(id, endTime) {
  119. let time = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss')
  120. const res = await this.$myRequest({
  121. url: '/mhotel/hcgetCoupon.action',
  122. method: 'POST',
  123. data: {
  124. complaintId: id,
  125. userId: uni.getStorageSync('userInfo').id,
  126. createId: uni.getStorageSync('userInfo').id,
  127. createDate: time,
  128. modifyDate: time,
  129. lapseDate: endTime
  130. }
  131. })
  132. // console.log(res);
  133. if (res.code === 200) {
  134. uni.showToast({
  135. title: res.message,
  136. icon: 'success',
  137. mask: true
  138. })
  139. setTimeout(() => {
  140. uni.navigateBack(1)
  141. }, 1500)
  142. }
  143. },
  144. // 点击弹窗我知道了按钮回调
  145. handleClose() {
  146. this.$refs.popup.close()
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. .container {
  153. box-sizing: border-box;
  154. padding: 20rpx 30rpx;
  155. height: 100vh;
  156. overflow-y: auto;
  157. background-color: #f2f3f5;
  158. .body {
  159. .body_item {
  160. position: relative;
  161. margin-bottom: 20rpx;
  162. padding-bottom: 22rpx;
  163. width: 690rpx;
  164. border-radius: 15rpx;
  165. background-color: #fff;
  166. img {
  167. width: 100rpx;
  168. height: 36rpx;
  169. }
  170. .item_type {
  171. position: absolute;
  172. top: 0;
  173. left: 14rpx;
  174. font-size: 24rpx;
  175. font-weight: bold;
  176. color: #fff;
  177. }
  178. .item_box {
  179. padding: 0 25rpx;
  180. display: flex;
  181. .box_left {
  182. flex: 6;
  183. overflow: hidden;
  184. .left_title {
  185. margin: 12rpx 0;
  186. font-size: 36rpx;
  187. font-weight: bold;
  188. overflow: hidden;
  189. text-overflow: ellipsis;
  190. white-space: nowrap;
  191. }
  192. .left_time {
  193. display: flex;
  194. flex-wrap: wrap;
  195. color: #808080;
  196. font-size: 20rpx;
  197. }
  198. .left_tags {
  199. display: flex;
  200. align-items: center;
  201. margin-top: 20rpx;
  202. color: #808080;
  203. font-size: 20rpx;
  204. .tag {
  205. display: flex;
  206. align-items: center;
  207. margin-right: 44rpx;
  208. img {
  209. margin-top: 4rpx;
  210. margin-left: 4rpx;
  211. width: 28rpx;
  212. height: 28rpx;
  213. }
  214. }
  215. }
  216. }
  217. .box_right {
  218. flex: 2;
  219. display: flex;
  220. .right_info {
  221. flex: 1;
  222. display: flex;
  223. flex-direction: column;
  224. align-items: flex-end;
  225. width: 100rpx;
  226. color: #ff5733;
  227. .info_top {
  228. margin-top: 10rpx;
  229. font-size: 36rpx;
  230. }
  231. .info_bottom {
  232. margin-top: 10rpx;
  233. font-size: 20rpx;
  234. }
  235. .color {
  236. color: #a6a6a6;
  237. }
  238. .info_btn {
  239. display: flex;
  240. justify-content: center;
  241. align-items: center;
  242. margin-top: 25rpx;
  243. width: 122rpx;
  244. height: 48rpx;
  245. color: #fff;
  246. font-size: 24rpx;
  247. border-radius: 6rpx;
  248. background-color: #096562;
  249. }
  250. .info_btn2 {
  251. display: flex;
  252. justify-content: center;
  253. align-items: center;
  254. margin-top: 25rpx;
  255. width: 122rpx;
  256. height: 48rpx;
  257. color: #fff;
  258. font-size: 24rpx;
  259. border-radius: 6rpx;
  260. background-color: #cccccc;
  261. }
  262. }
  263. }
  264. }
  265. }
  266. }
  267. .noData {
  268. display: flex;
  269. flex-direction: column;
  270. justify-content: center;
  271. align-items: center;
  272. padding-bottom: 20rpx;
  273. img {
  274. margin-top: 220rpx;
  275. width: 600rpx;
  276. height: 600rpx;
  277. }
  278. }
  279. .popup_body {
  280. display: flex;
  281. flex-direction: column;
  282. align-items: center;
  283. width: 481rpx;
  284. height: 404rpx;
  285. border-radius: 22.5rpx;
  286. background-color: #fff;
  287. .popup_header {
  288. display: flex;
  289. justify-content: center;
  290. align-items: center;
  291. height: 123rpx;
  292. font-size: 34rpx;
  293. font-weight: bold;
  294. color: #0f194d;
  295. img {
  296. width: 16rpx;
  297. height: 16rpx;
  298. }
  299. .header_title {
  300. margin: 0 10rpx;
  301. }
  302. }
  303. .popup_center {
  304. box-sizing: border-box;
  305. padding: 0 20rpx;
  306. height: 135rpx;
  307. color: rgba(15, 25, 77, 0.6);
  308. font-size: 28rpx;
  309. font-weight: bold;
  310. }
  311. .popup_btn {
  312. display: flex;
  313. justify-content: center;
  314. align-items: center;
  315. width: 396rpx;
  316. height: 76rpx;
  317. color: #fff;
  318. font-size: 26rpx;
  319. border-radius: 43rpx;
  320. background: linear-gradient(90deg, #0bc196 0%, #096562 100%);
  321. }
  322. }
  323. }
  324. </style>