couponCenter.vue 7.7 KB

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