| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 |
- <template>
- <view class="container">
- <!-- 分段器区域 -->
- <view class="segmented">
- <view class="segmented_box">
- <uni-segmented-control :current="activeCurrent" :values="headerList" style-type="text" active-color="#096562" @clickItem="onClickItem" />
- </view>
- </view>
- <!-- 领券中心横幅区域 -->
- <view class="banner">
- <img mode="aspectFill" src="../../static/my/banner.png" />
- <view class="banner_title">领券中心</view>
- <view class="banner_msg">
- <view class="msg_top">关注领券中心</view>
- <view>系统会不定时发放代金券</view>
- </view>
- <view class="banner_btn" @click="handleGoPage('/pages/couponCenter/couponCenter')">去逛逛</view>
- </view>
- <!-- 代金券列表区域 -->
- <scroll-view class="body" scroll-y @scrolltolower="handlePull">
- <!-- 每一个代金券区域 -->
- <view class="body_box" v-for="item in list" :key="item.id">
- <!-- 代金券类型区域 -->
- <img src="../../static/my/couponTitle.png" />
- <view class="box_title">
- <view class="title_type">{{ item.type === 1 ? '代金券' : '折扣券' }}</view>
- <!-- <view class="title_num">x{{ item.count }}张</view> -->
- </view>
- <!-- 代金券信息区域 -->
- <view class="box_info">
- <view class="info_left">
- <view class="left_top">{{ item.name }}</view>
- <view class="left_bottom">
- <view class="tag">有限期{{ item.effectiveStartDate.slice(0, 10) }}至{{ item.effectiveEndDate.slice(0, 10) }}</view>
- <!-- <view class="tag">可通用</view> -->
- <view class="tag" v-if="item.hotelIds.includes('-1')">全名宿</view>
- <view class="tag" v-else @click="handleClickTag(item.hotelIds)">
- 指定民宿
- <img src="../../static/index/right2.png" />
- </view>
- </view>
- </view>
- <view class="info_right">
- <view class="right_top">{{ item.type === 1 ? '¥' + item.deductionPrice : item.rebatePrice + '折' }}</view>
- <view class="right_bottom" :class="{ color: item.meetPrice === 0 }">{{ item.meetPrice === 0 ? '无门槛' : '满' + item.meetPrice + '可用' }}</view>
- <view class="right_bottom">{{ item.type === 2 ? '最多减免' + item.maxDeduction : '' }}</view>
- </view>
- </view>
- <!-- 代金券按钮区域 -->
- <view class="box_btn" @click="handleUse(item)">去使用</view>
- </view>
- <view class="noData" v-if="list.length === 0">
- <img lazy-load :lazy-load-margin="0" src="../../static/images/noData.png" />
- 暂无数据
- </view>
- <!-- 指定民宿弹窗区域 -->
- <uni-popup ref="popup" type="center" :is-mask-click="false">
- <view class="popup_body">
- <view class="popup_header">
- <img src="../../static/my/popup_title.png" />
- <view class="header_title">指定民宿</view>
- <img src="../../static/my/popup_title.png" />
- </view>
- <view class="popup_center">{{ hotels }}</view>
- <view class="popup_btn" @click="handleClose">我知道了</view>
- </view>
- </uni-popup>
- </scroll-view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // 分段器当前激活索引
- activeCurrent: 0,
- // 分段器数组
- headerList: ['全部', '代金券', '折扣券'],
- list: [],
- // 当前页
- page: 1,
- // 每页多少条
- rows: 6,
- // 总条数
- total: null,
- types: '1,2',
- // 指定民宿信息
- hotels: ''
- }
- },
- onShow() {
- this.activeCurrent = 0
- this.types = '1,2'
- this.page = 1
- this.list = []
- this.getData()
- },
- // onLoad() {
- // this.getData()
- // },
- methods: {
- async getData() {
- const res = await this.$myRequest({
- url: '/mhotel/hccardCouponPage.action',
- data: {
- userId: uni.getStorageSync('userInfo').id,
- types: this.types,
- page: this.page,
- rows: this.rows
- }
- })
- // console.log(res);
- if (res.code === 200 && res.page.pageList) {
- this.list = [...this.list, ...res.page.pageList]
- this.total = res.page.total
- this.list.forEach((ele) => {
- ele.hotelIds = ele.hotelIds.split(',')
- })
- }
- },
- // 点击指定民宿tag回调
- async handleClickTag(ids) {
- const res = await this.$myRequest({
- url: '/mhotel/hcdesignatedHotel.action',
- data: {
- hotelIds: ids.join()
- }
- })
- // console.log(res);
- if (res.code === 200) {
- this.hotels = res.data.name
- }
- this.$refs.popup.open()
- },
- // 去使用按钮回调
- handleUse(item) {
- if (item.hotelIds.length === 1 && !item.hotelIds.includes('-1')) {
- uni.navigateTo({
- url: `/pages/detail/detail?id=${item.hotelIds[0]}`
- })
- } else {
- uni.switchTab({
- url: '/pages/home3/home3'
- })
- }
- },
- // 切换分段器回调
- onClickItem(e) {
- this.activeCurrent = e.currentIndex
- if (this.activeCurrent === 0) {
- this.types = '1,2'
- } else if (this.activeCurrent === 1) {
- this.types = '1'
- } else if (this.activeCurrent === 2) {
- this.types = '2'
- }
- this.page = 1
- this.list = []
- this.getData()
- },
- // 列表下拉到底部回调
- handlePull() {
- if (this.list.length < this.total) {
- this.page++
- this.getData()
- } else {
- uni.showToast({
- title: '没有更多数据了',
- icon: 'none'
- })
- }
- },
- // 跳转页面回调
- handleGoPage(url) {
- uni.navigateTo({
- url
- })
- },
- // 点击弹窗我知道了按钮回调
- handleClose() {
- this.$refs.popup.close()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- height: 100vh;
- background-color: #f2f3f5;
- overflow: hidden;
- .segmented {
- box-sizing: border-box;
- padding-bottom: 28rpx;
- height: 100rpx;
- background-color: #fff;
- .segmented_box {
- width: 50%;
- }
- }
- .banner {
- position: relative;
- padding: 0 20rpx;
- height: 158rpx;
- img {
- margin-top: 31rpx;
- width: 710rpx;
- height: 95rpx;
- }
- .banner_title {
- position: absolute;
- top: 42rpx;
- left: 55rpx;
- color: #fff;
- font-size: 50rpx;
- font-weight: bold;
- }
- .banner_msg {
- position: absolute;
- top: 46rpx;
- left: 280rpx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- padding-left: 15rpx;
- height: 61rpx;
- color: #fff;
- font-size: 20rpx;
- border-left: 1rpx dotted #fff;
- .msg_top {
- margin-top: -5rpx;
- }
- }
- .banner_btn {
- position: absolute;
- top: 46rpx;
- left: 556rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- width: 133rpx;
- height: 61rpx;
- color: #000;
- font-size: 28rpx;
- border-radius: 12rpx;
- background: linear-gradient(90deg, #ffeb3b 0%, #ffb300 100%);
- }
- }
- .body {
- box-sizing: border-box;
- padding: 0 30rpx 20rpx;
- height: calc(100vh - 258rpx);
- .body_box {
- position: relative;
- padding-bottom: 18rpx;
- margin-bottom: 20rpx;
- // height: 218rpx;
- border-radius: 15rpx;
- background-color: #fff;
- img {
- width: 135rpx;
- height: 36rpx;
- }
- .box_title {
- position: absolute;
- top: 0;
- left: 16rpx;
- display: flex;
- align-items: center;
- color: #fff;
- .title_type {
- font-size: 24rpx;
- font-weight: bold;
- }
- .title_num {
- margin-left: 5rpx;
- margin-top: 10rpx;
- font-size: 16rpx;
- }
- }
- .box_info {
- display: flex;
- padding: 0 30rpx 0 25rpx;
- .info_left {
- flex: 4;
- .left_top {
- margin: 12rpx 0;
- font-size: 36rpx;
- }
- .left_bottom {
- display: flex;
- flex-wrap: wrap;
- color: #808080;
- font-size: 24rpx;
- .tag {
- display: flex;
- align-items: center;
- margin-right: 32rpx;
- margin-bottom: 15rpx;
- img {
- margin-top: 4rpx;
- margin-left: 4rpx;
- width: 28rpx;
- height: 28rpx;
- }
- }
- }
- }
- .info_right {
- flex: 1;
- color: #ff5733;
- .right_top {
- margin: 10rpx 0;
- text-align: end;
- font-size: 36rpx;
- }
- .right_bottom {
- margin-bottom: 8rpx;
- text-align: end;
- font-size: 20rpx;
- }
- .color {
- color: #a6a6a6;
- }
- }
- }
- .box_btn {
- display: flex;
- justify-content: center;
- align-items: center;
- margin-right: 30rpx;
- margin-top: 11rpx;
- margin-left: auto;
- width: 98rpx;
- height: 40rpx;
- color: #fff;
- font-size: 24rpx;
- border-radius: 6rpx;
- background-color: #096562;
- }
- }
- .noData {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- padding-bottom: 20rpx;
- img {
- margin-top: 75rpx;
- width: 600rpx;
- height: 600rpx;
- }
- }
- .popup_body {
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 481rpx;
- // height: 404rpx;
- border-radius: 22.5rpx;
- background-color: #fff;
- .popup_header {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 123rpx;
- font-size: 34rpx;
- font-weight: bold;
- color: #0f194d;
- img {
- width: 16rpx;
- height: 16rpx;
- }
- .header_title {
- margin: 0 10rpx;
- }
- }
- .popup_center {
- box-sizing: border-box;
- padding: 0 20rpx 20rpx;
- max-height: 400rpx;
- line-height: 42rpx;
- // height: 135rpx;
- color: rgba(15, 25, 77, 0.6);
- font-size: 28rpx;
- font-weight: bold;
- overflow-y: auto;
- }
- .popup_btn {
- display: flex;
- justify-content: center;
- align-items: center;
- margin-bottom: 20rpx;
- width: 396rpx;
- height: 76rpx;
- color: #fff;
- font-size: 26rpx;
- border-radius: 43rpx;
- background: linear-gradient(90deg, #0bc196 0%, #096562 100%);
- }
- }
- }
- }
- </style>
|