couponCenter.vue 8.0 KB

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