myCoupon.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <template>
  2. <view class="container">
  3. <!-- 分段器区域 -->
  4. <view class="segmented">
  5. <view class="segmented_box">
  6. <uni-segmented-control :current="activeCurrent" :values="headerList" style-type="text" active-color="#096562" @clickItem="onClickItem" />
  7. </view>
  8. </view>
  9. <!-- 领券中心横幅区域 -->
  10. <view class="banner">
  11. <img mode="aspectFill" src="../../static/my/banner.png" />
  12. <view class="banner_title">领券中心</view>
  13. <view class="banner_msg">
  14. <view class="msg_top">关注领券中心</view>
  15. <view>系统会不定时发放代金券</view>
  16. </view>
  17. <view class="banner_btn" @click="handleGoPage('/pages/couponCenter/couponCenter')">去逛逛</view>
  18. </view>
  19. <!-- 代金券列表区域 -->
  20. <scroll-view class="body" scroll-y @scrolltolower="handlePull">
  21. <!-- 每一个代金券区域 -->
  22. <view class="body_box" v-for="item in list" :key="item.id">
  23. <!-- 代金券类型区域 -->
  24. <img src="../../static/my/couponTitle.png" />
  25. <view class="box_title">
  26. <view class="title_type">{{ item.type === 1 ? '代金券' : '折扣券' }}</view>
  27. <view class="title_num">x{{ item.count }}张</view>
  28. </view>
  29. <!-- 代金券信息区域 -->
  30. <view class="box_info">
  31. <view class="info_left">
  32. <view class="left_top">{{ item.name }}</view>
  33. <view class="left_bottom">
  34. <view class="tag">有限期至{{ item.effectiveEndDate.slice(0, 10) }}</view>
  35. <!-- <view class="tag">可通用</view> -->
  36. <view class="tag" v-if="item.hotelIds.includes('-1')">全名宿</view>
  37. <view class="tag" v-else @click="handleClickTag(item.hotelIds)">
  38. 指定民宿
  39. <img src="../../static/index/right2.png" />
  40. </view>
  41. </view>
  42. </view>
  43. <view class="info_right">
  44. <view class="right_top">{{ item.type === 1 ? '¥' + item.deductionPrice : item.rebatePrice + '折' }}</view>
  45. <view class="right_bottom" :class="{ color: item.meetPrice === 0 }">{{ item.meetPrice === 0 ? '无门槛' : '满' + item.meetPrice + '可用' }}</view>
  46. <view class="right_bottom">{{ item.type === 2 ? '最多减免' + item.maxDeduction : '' }}</view>
  47. </view>
  48. </view>
  49. <!-- 代金券按钮区域 -->
  50. <view class="box_btn" @click="handleUse(item)">去使用</view>
  51. </view>
  52. <view class="noData" v-if="list.length === 0">
  53. <img lazy-load :lazy-load-margin="0" src="../../static/images/noData.png" />
  54. 暂无数据
  55. </view>
  56. <!-- 指定民宿弹窗区域 -->
  57. <uni-popup ref="popup" type="center" :is-mask-click="false">
  58. <view class="popup_body">
  59. <view class="popup_header">
  60. <img src="../../static/my/popup_title.png" />
  61. <view class="header_title">指定民宿</view>
  62. <img src="../../static/my/popup_title.png" />
  63. </view>
  64. <view class="popup_center">{{ hotels }}</view>
  65. <view class="popup_btn" @click="handleClose">我知道了</view>
  66. </view>
  67. </uni-popup>
  68. </scroll-view>
  69. </view>
  70. </template>
  71. <script>
  72. export default {
  73. data() {
  74. return {
  75. // 分段器当前激活索引
  76. activeCurrent: 0,
  77. // 分段器数组
  78. headerList: ['全部', '代金券', '折扣券'],
  79. list: [],
  80. // 当前页
  81. page: 1,
  82. // 每页多少条
  83. rows: 6,
  84. // 总条数
  85. total: null,
  86. types: '1,2',
  87. // 指定民宿信息
  88. hotels: ''
  89. }
  90. },
  91. onShow() {
  92. this.activeCurrent = 0
  93. this.types = '1,2'
  94. this.page = 1
  95. this.list = []
  96. this.getData()
  97. },
  98. // onLoad() {
  99. // this.getData()
  100. // },
  101. methods: {
  102. async getData() {
  103. const res = await this.$myRequest({
  104. url: '/mhotel/hccardCouponPage.action',
  105. data: {
  106. userId: uni.getStorageSync('userInfo').id,
  107. types: this.types,
  108. page: this.page,
  109. rows: this.rows
  110. }
  111. })
  112. // console.log(res);
  113. if (res.code === 200 && res.page.pageList) {
  114. this.list = [...this.list, ...res.page.pageList]
  115. this.total = res.page.total
  116. this.list.forEach((ele) => {
  117. ele.hotelIds = ele.hotelIds.split(',')
  118. })
  119. }
  120. },
  121. // 点击指定民宿tag回调
  122. async handleClickTag(ids) {
  123. const res = await this.$myRequest({
  124. url: '/mhotel/hcdesignatedHotel.action',
  125. data: {
  126. hotelIds: ids.join()
  127. }
  128. })
  129. // console.log(res);
  130. if (res.code === 200) {
  131. this.hotels = res.data.name
  132. }
  133. this.$refs.popup.open()
  134. },
  135. // 去使用按钮回调
  136. handleUse(item) {
  137. if (item.hotelIds.length === 1 && !item.hotelIds.includes('-1')) {
  138. uni.navigateTo({
  139. url: `/pages/detail/detail?id=${item.hotelIds[0]}`
  140. })
  141. } else {
  142. uni.switchTab({
  143. url: '/pages/home3/home3'
  144. })
  145. }
  146. },
  147. // 切换分段器回调
  148. onClickItem(e) {
  149. this.activeCurrent = e.currentIndex
  150. if (this.activeCurrent === 0) {
  151. this.types = '1,2'
  152. } else if (this.activeCurrent === 1) {
  153. this.types = '1'
  154. } else if (this.activeCurrent === 2) {
  155. this.types = '2'
  156. }
  157. this.page = 1
  158. this.list = []
  159. this.getData()
  160. },
  161. // 列表下拉到底部回调
  162. handlePull() {
  163. if (this.list.length < this.total) {
  164. this.page++
  165. this.getData()
  166. } else {
  167. uni.showToast({
  168. title: '没有更多数据了',
  169. icon: 'none'
  170. })
  171. }
  172. },
  173. // 跳转页面回调
  174. handleGoPage(url) {
  175. uni.navigateTo({
  176. url
  177. })
  178. },
  179. // 点击弹窗我知道了按钮回调
  180. handleClose() {
  181. this.$refs.popup.close()
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="scss" scoped>
  187. .container {
  188. height: 100vh;
  189. background-color: #f2f3f5;
  190. overflow: hidden;
  191. .segmented {
  192. box-sizing: border-box;
  193. padding-bottom: 28rpx;
  194. height: 100rpx;
  195. background-color: #fff;
  196. .segmented_box {
  197. width: 50%;
  198. }
  199. }
  200. .banner {
  201. position: relative;
  202. padding: 0 20rpx;
  203. height: 158rpx;
  204. img {
  205. margin-top: 31rpx;
  206. width: 710rpx;
  207. height: 95rpx;
  208. }
  209. .banner_title {
  210. position: absolute;
  211. top: 42rpx;
  212. left: 55rpx;
  213. color: #fff;
  214. font-size: 50rpx;
  215. font-weight: bold;
  216. }
  217. .banner_msg {
  218. position: absolute;
  219. top: 46rpx;
  220. left: 280rpx;
  221. display: flex;
  222. flex-direction: column;
  223. justify-content: space-between;
  224. padding-left: 15rpx;
  225. height: 61rpx;
  226. color: #fff;
  227. font-size: 20rpx;
  228. border-left: 1rpx dotted #fff;
  229. .msg_top {
  230. margin-top: -5rpx;
  231. }
  232. }
  233. .banner_btn {
  234. position: absolute;
  235. top: 46rpx;
  236. left: 556rpx;
  237. display: flex;
  238. justify-content: center;
  239. align-items: center;
  240. width: 133rpx;
  241. height: 61rpx;
  242. color: #000;
  243. font-size: 28rpx;
  244. border-radius: 12rpx;
  245. background: linear-gradient(90deg, #ffeb3b 0%, #ffb300 100%);
  246. }
  247. }
  248. .body {
  249. box-sizing: border-box;
  250. padding: 0 30rpx 20rpx;
  251. height: calc(100vh - 258rpx);
  252. .body_box {
  253. position: relative;
  254. padding-bottom: 18rpx;
  255. margin-bottom: 20rpx;
  256. // height: 218rpx;
  257. border-radius: 15rpx;
  258. background-color: #fff;
  259. img {
  260. width: 135rpx;
  261. height: 36rpx;
  262. }
  263. .box_title {
  264. position: absolute;
  265. top: 0;
  266. left: 16rpx;
  267. display: flex;
  268. align-items: center;
  269. color: #fff;
  270. .title_type {
  271. font-size: 24rpx;
  272. font-weight: bold;
  273. }
  274. .title_num {
  275. margin-left: 5rpx;
  276. margin-top: 10rpx;
  277. font-size: 16rpx;
  278. }
  279. }
  280. .box_info {
  281. display: flex;
  282. padding: 0 30rpx 0 25rpx;
  283. .info_left {
  284. flex: 4;
  285. .left_top {
  286. margin: 12rpx 0;
  287. font-size: 36rpx;
  288. }
  289. .left_bottom {
  290. display: flex;
  291. color: #808080;
  292. font-size: 24rpx;
  293. .tag {
  294. display: flex;
  295. align-items: center;
  296. margin-right: 32rpx;
  297. img {
  298. margin-top: 4rpx;
  299. margin-left: 4rpx;
  300. width: 28rpx;
  301. height: 28rpx;
  302. }
  303. }
  304. }
  305. }
  306. .info_right {
  307. flex: 1;
  308. color: #ff5733;
  309. .right_top {
  310. margin: 10rpx 0;
  311. text-align: end;
  312. font-size: 36rpx;
  313. }
  314. .right_bottom {
  315. margin-bottom: 8rpx;
  316. text-align: end;
  317. font-size: 20rpx;
  318. }
  319. .color {
  320. color: #a6a6a6;
  321. }
  322. }
  323. }
  324. .box_btn {
  325. display: flex;
  326. justify-content: center;
  327. align-items: center;
  328. margin-right: 30rpx;
  329. margin-top: 11rpx;
  330. margin-left: auto;
  331. width: 98rpx;
  332. height: 40rpx;
  333. color: #fff;
  334. font-size: 24rpx;
  335. border-radius: 6rpx;
  336. background-color: #096562;
  337. }
  338. }
  339. .noData {
  340. display: flex;
  341. flex-direction: column;
  342. justify-content: center;
  343. align-items: center;
  344. padding-bottom: 20rpx;
  345. img {
  346. margin-top: 75rpx;
  347. width: 600rpx;
  348. height: 600rpx;
  349. }
  350. }
  351. .popup_body {
  352. display: flex;
  353. flex-direction: column;
  354. align-items: center;
  355. width: 481rpx;
  356. height: 404rpx;
  357. border-radius: 22.5rpx;
  358. background-color: #fff;
  359. .popup_header {
  360. display: flex;
  361. justify-content: center;
  362. align-items: center;
  363. height: 123rpx;
  364. font-size: 34rpx;
  365. font-weight: bold;
  366. color: #0f194d;
  367. img {
  368. width: 16rpx;
  369. height: 16rpx;
  370. }
  371. .header_title {
  372. margin: 0 10rpx;
  373. }
  374. }
  375. .popup_center {
  376. box-sizing: border-box;
  377. padding: 0 20rpx;
  378. height: 135rpx;
  379. color: rgba(15, 25, 77, 0.6);
  380. font-size: 28rpx;
  381. font-weight: bold;
  382. }
  383. .popup_btn {
  384. display: flex;
  385. justify-content: center;
  386. align-items: center;
  387. width: 396rpx;
  388. height: 76rpx;
  389. color: #fff;
  390. font-size: 26rpx;
  391. border-radius: 43rpx;
  392. background: linear-gradient(90deg, #0bc196 0%, #096562 100%);
  393. }
  394. }
  395. }
  396. }
  397. </style>