| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- <template>
- <view class="content">
- <view class="top-wrap">
- <image src="https://hy.liuniu946.com/app/img/yhq-mbg.png" mode="widthFix" style="width: 750rpx;"></image>
- <view class="my-yhq" @click="navTo('/user/page/myCoupon')">
- 我的卡券
- </view>
- </view>
- <scroll-view scroll-y="true" :style="{'height': height}" class="scroll-wrap">
- <!-- 空白页 -->
- <empty v-if="loaded === true && list.length === 0"></empty>
- <view class="kq-wrap flex" v-for="item in list" :class="{'qw':item == 9}">
- <!-- 普通背景 -->
- <image src="https://hy.liuniu946.com/app/img/kq-bg.png" mode="" class="kq-bg" v-if="item != 9"></image>
- <!-- 抢完背景 -->
- <image src="https://hy.liuniu946.com/app/img/kp-bg-1.png" mode="" class="kq-bg" v-if="item == 9"></image>
- <view class="kq-left flex">
- <view class="left-val">
- {{item.coupon_price}}
- </view>
- <view class="left-tit" v-if="item.use_min_price*1 > 0">
- 满{{item.use_min_price*1}}元使用
- </view>
- <view class="left-tit" v-else>
- 无门槛
- </view>
- </view>
- <view class="kp-center flex">
- <view class="center-tit clamp2">
- {{item.title}}
- </view>
- <view class="center-time">
- 有效期至2020-0-10 23:59
- </view>
- </view>
- <view class="kp-right flex">
- <!-- 在抢 -->
- <view class="right-loading flex" v-if="!item.used">
- <image src="../../static/icon/kp-loading.png" mode=""></image>
- <view class="loading-tit">
- 待领取
- </view>
- <!-- <view class="loading-val">
- 88%
- </view> -->
- </view>
- <!-- 已领取 -->
- <view class="right-more" v-if="item.used">
- <image src="../../static/icon/kp-nomore.png" mode=""></image>
- </view>
- <!-- 已抢完 -->
- <view class="right-nomore" v-if="item == 9">
- <image src="../../static/icon/kp-more.png" mode=""></image>
- </view>
- <view class="right-btn" @click="lq(item)">
- {{item.used ?'已领取':'立即领取'}}
- </view>
- </view>
-
- </view>
- <uni-load-more :status="loadingType" v-if="!(list.length == 0 && loaded)">
- </uni-load-more>
- </scroll-view>
- </view>
- </template>
- <script>
- import uniLoadMore from '@/uview-ui/components/u-loadmore/u-loadmore.vue';
- import empty from '@/uview-ui/components/u-empty/u-empty.vue';
- import {
- getCouponList,
- setCoupons
- } from '@/api/functionalUnit.js';
- import {
- spread,
- orderData,
- userinfo
- } from '@/api/user.js';
- export default {
- data() {
- return {
- height: '',
- loadingType: 'more',
- list: [],
- loaded: false,
- iconColor: 'red',
- color: 'red',
- page: 1,
- limit: 10,
-
- }
- },
- components: {
- empty,
- uniLoadMore
- },
- onLoad() {
- let obj = this;
- userinfo({})
- .then(({
- data
- }) => {
- console.log(data, "123456")
- })
- this.getCouponList()
- },
- onShow() {
- },
- onReachBottom() {
- this.getCouponList()
- },
- onReady() {
- var obj = this;
- uni.getSystemInfo({
- success: resu => {
- const query = uni.createSelectorQuery();
- query.select('.scroll-wrap').boundingClientRect();
- query.exec(function(res) {
- obj.height = resu.windowHeight - res[0].top + 'px';
- });
- console.log(obj.height)
- },
- fail: res => {}
- });
- },
- methods: {
- navTo(url) {
- uni.navigateTo({
- url,
- fail() {
- uni.switchTab({
- url
- })
- }
- })
- },
- getCouponList() {
- let obj = this
- if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
- return
- }
- obj.loadingType = 'loading'
- getCouponList({
- page: obj.page,
- limit: obj.limit
- }).then(res => {
- console.log(res)
- obj.list = obj.list.concat(res.data)
- obj.page++
- if (obj.limit == res.data.length) {
- obj.loadingType = 'more'
- } else {
- obj.loadingType = 'noMore'
- }
- obj.loaded = true
- })
- },
- lq(item) {
- if (item.used) {
- return
- }
- setCoupons({
- couponId: item.id
- }).then(res => {
- console.log(res)
- uni.showToast({
- title: '领取成功',
- duration: 2000
- });
- // let s = this.list.indexOf(item);
- // this.list;
- item.used = 1
- })
- }
- }
- }
- </script>
- <style lang="scss">
- page {
- background: #ff4802;
- height: auto;
- min-height: 100%;
- }
- .top-wrap {
- width: 750rpx;
- height: 574rpx;
- position: relative;
- image {
- position: absolute;
- top: 0;
- left: 0;
- }
- .my-yhq {
- width: 174rpx;
- line-height: 54rpx;
- background: #F4DE01;
- border-radius: 27rpx 0px 0px 27rpx;
- position: absolute;
- top: 43rpx;
- right: 0;
- font-size: 28rpx;
- font-weight: bold;
- color: #FF4701;
- text-align: center;
- }
- }
- .kq-wrap {
- width: 663rpx;
- height: 176rpx;
- margin: 0 auto 20rpx;
- position: relative;
- // padding: 20rpx;
- .kq-bg {
- position: absolute;
- top: 0;
- left: 0;
- width: 663rpx;
- height: 176rpx;
- }
- .kq-left {
- width: 180rpx;
- height: 176rpx;
- position: relative;
- // background-color: #bfa;
- flex-direction: column;
- justify-content: center;
- flex-shrink: 0;
- color: #FEB100;
- .left-val {
- font-size: 60rpx;
- font-weight: bold;
- &::before {
- content: '¥';
- font-size: 38rpx;
- font-weight: bold;
- }
- }
- .left-tit {
- font-size: 24rpx;
- font-weight: 500;
- }
- }
- .kp-center {
- position: relative;
- flex-direction: column;
- height: 176rpx;
- padding: 35rpx 20rpx 35rpx 0;
- justify-content: space-between;
- align-items: flex-start;
- flex-grow: 1;
- .center-tit {
- font-size: 30rpx;
- font-weight: 500;
- color: #333333;
- }
- .center-time {
- font-size: 22rpx;
- font-weight: 500;
- color: #666666;
- }
- }
- .kp-right {
- width: 155rpx;
- height: 176rpx;
- position: relative;
- flex-direction: column;
- justify-content: center;
- flex-shrink: 0;
- .right-loading {
- width: 105rpx;
- height: 105rpx;
- position: relative;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- image {
- width: 105rpx;
- height: 105rpx;
- position: absolute;
- top: 0;
- left: 0;
- }
- .loading-tit {
- font-size: 22rpx;
- font-weight: 400;
- color: #FFFFFF;
- }
- .loading-val {
- font-size: 28rpx;
- font-weight: 400;
- color: #FFFFFF;
- }
- }
- .right-more,
- .right-nomore {
- width: 116rpx;
- height: 87rpx;
- image {
- width: 116rpx;
- height: 87rpx;
- }
- }
- .right-btn {
- width: 122rpx;
- height: 31rpx;
- background: #FFFFFF;
- border-radius: 15rpx;
- font-size: 20rpx;
- font-weight: 400;
- color: #E27A01;
- line-height: 31rpx;
- text-align: center;
- margin-top: 10rpx;
- }
- }
- }
- // 抢完样式
- .qw {
- .kq-left {
- color: #CDCBCE;
- }
- .kp-center {
- .center-time {
- color: #CDCBCE;
- }
- .center-tit {
- color: #CDCBCE;
- }
- }
- .kp-right {
- .right-btn {
- background: #B5B5B5;
- color: #fff;
- }
- }
- }
- .scroll-wrap {
- padding-bottom: 20rpx;
- width: 663rpx;
- margin: auto;
- }
- </style>
|