123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666 |
- <template>
- <view class="content">
- <view class="navbar">
- <view v-for="(item, index) in navList" :key="index" class="nav-item"
- :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
- </view>
- <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
- <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
- <!-- 空白页 -->
- <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
- <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData()">
- <view v-for="(item, index) in tabItem.orderList" :key="index" class="main-item">
- <view class="main-item-top flex">
- <view class="main-item-top-bg">
- <image src="../../static/img/cardTop.png" mode=""></image>
- </view>
- <view class="main-item-top-left">
- <view class="main-item-title">{{ item.name }}</view>
- <view class="main-item-time">购买时间{{ item.create_time }}</view>
- </view>
- <view class="main-item-type">{{ item.type == 1 ? '时效卡' : '次卡' }}</view>
- </view>
- <view class="main-item-bottom">
- <view class="main-item-bottom-bg">
- <image src="../../static/img/cardbottom.png" mode=""></image>
- </view>
- <view class="flex">
- <view class="main-item-price">
- <text class="fh">卡券码:</text>
- {{ item.card }}
- <text class="time" @click="copy(item.card)">复制</text>
- </view>
- <view class="main-item-bottom-type" v-if="tabCurrentIndex == 2">已过期</view>
- <view class="main-item-info-right" v-if="tabCurrentIndex == 0">
- <view class="main-item-info-font"
- @click="navTo('/pages/user/mycardDetail?id=' + item.id)">查看详情</view>
- <view class="main-item-info-icon">
- <image src="../../static/img/img39.png" mode=""></image>
- </view>
- </view>
- </view>
- <view class="main-item-info flex">
- <view class="main-item-info-left" v-if="tabCurrentIndex == 1 && item.type == 1">
- {{ item.end_time }}后失效</view>
- <view class="main-item-info-left" v-if="tabCurrentIndex == 1 && item.type == 2">
- 总使用次数{{ item.number }}</view>
- <view class="flex" v-if="tabCurrentIndex == 0 && !item.show">
- <view class="info">
- 激活密码:
- <text v-for="l in item.pwd.length">*</text>
- </view>
- <image class="image" src="../../static/img/img43.png" @click="showPick(item)">
- </image>
- <!-- <view class="copy">复制</view> -->
- </view>
- <view class="flex" v-if="tabCurrentIndex == 0 && item.show">
- <view class="info">激活密码:{{ item.pwd }}</view>
- <image class="image" src="../../static/img/img29.png" @click="showPick(item)">
- </image>
- <view class="copy" @click="copy(item.pwd)">复制</view>
- </view>
- <view class="main-item-info-left" v-if="tabCurrentIndex == 2">卡券已被激活</view>
- <view class="main-item-info-btn" @click="jihuo(item)" v-if="tabCurrentIndex == 0">一键激活
- </view>
- <view class="main-item-info-right" v-if="tabCurrentIndex != 0">
- <view class="main-item-info-font"
- @click="navTo('/pages/user/mycardDetail?id=' + item.id)">查看详情</view>
- <view class="main-item-info-icon">
- <image src="../../static/img/img39.png" mode=""></image>
- </view>
- </view>
- </view>
- </view>
- </view>
- <uni-load-more :status="tabItem.loadingType"></uni-load-more>
- </scroll-view>
- </swiper-item>
- </swiper>
- <view class="btn" @click="openPopup()">卡券激活</view>
- <uni-popup ref="popup" type="center">
- <view class="img1">
- <image src="../../static/img/jh3.png" mode=""></image>
- </view>
- <view class="popup-box">
- <view class="img">
- <image src="../../static/img/jh1.png" mode=""></image>
- </view>
- <view class="mian">
- <view class="delivery">
- <view class="title">卡券激活</view>
- </view>
- <view class="comfirm-box">
- <view class="input"><input type="text" v-model="card" placeholder="请输入卡号" /></view>
- <view class="input"><input type="text" v-model="pwd" placeholder="请输入密码" /></view>
- </view>
- <view class="popup-btn" @click="jihuo()">立即激活</view>
- </view>
- </view>
- <view class="x" @click="cancel()">
- <image src="../../static/img/jh2.png" mode=""></image>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
- import empty from '@/components/empty';
- import {
- getCouponsList,
- use_card
- } from '@/api/jdr.js';
- import uniCopy from '@/utils/uni-copy.js';
- import {
- getTime
- } from '@/utils/rocessor.js';
- export default {
- components: {
- uniLoadMore,
- empty
- },
- data() {
- return {
- tabCurrentIndex: 0,
- pwd: '',
- card: '',
- navList: [{
- state: 1,
- text: '未使用',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 2,
- text: '使用中',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 3,
- text: '已失效',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- }
- ]
- };
- },
- onLoad(options) {
- this.loadData();
- },
- methods: {
- //返回首页
- navTo(url) {
- uni.navigateTo({
- url
- });
- },
- showPick(item) {
- item.show = !item.show;
- },
- //获取订单列表
- loadData(source) {
- //将订单挂载到tab列表下
- let index = this.tabCurrentIndex;
- let navItem = this.navList[index];
- let state = navItem.state;
- if (source === 'shua') {
- navItem.loaded = false;
- navItem.page = 1;
- navItem.limit = 10;
- navItem.loadingType = 'more';
- navItem.orderList = [];
- }
- if (source === 'tabChange' && navItem.loaded === true) {
- //tab切换只有第一次需要加载数据
- return;
- }
- if (navItem.loadingType === 'loading' || navItem.loadingType === 'noMore') {
- //防止重复加载
- return;
- }
- console.log(navItem.loadingType, '状态');
- //修改当前对象状态为加载中
- navItem.loadingType = 'loading';
- getCouponsList({
- page: navItem.page,
- limit: navItem.limit,
- status: state
- })
- .then(({
- data
- }) => {
- data.forEach(e => {
- e.show = false;
- e.end_time = getTime(e.end_time);
- });
- navItem.orderList = navItem.orderList.concat(data);
- console.log(navItem.orderList);
- navItem.page++;
- if (navItem.limit == data.length) {
- // 判断是否还有数据,有改为more,没有改为noMore
- navItem.loadingType = 'more';
- return;
- } else {
- navItem.loadingType = 'noMore';
- }
- uni.hideLoading();
- this.$set(navItem, 'loaded', true);
- })
- .catch(e => {
- console.log(e);
- });
- },
- //swiper 切换
- changeTab(e) {
- this.tabCurrentIndex = e.target.current;
- this.loadData('tabChange');
- },
- //顶部tab点击
- tabClick(index) {
- this.tabCurrentIndex = index;
- },
- copy(value) {
- let content = value; //需要复制的内容
- console.log('复制的内容:', content);
- // content = typeof content === 'string' ? content : content.toString(); // 复制内容,必须字符串,数字需要转换为字符串
- const result = uniCopy({
- content
- });
- if (result === false) {
- uni.showToast({
- title: '不支持'
- });
- } else {
- uni.showToast({
- title: '复制成功',
- icon: 'none'
- });
- }
- },
- openPopup() {
- this.$refs.popup.open();
- },
- // 弹窗 - 取消
- cancel() {
- this.card = '';
- this.pwd = '';
- this.$refs.popup.close();
- },
- jihuo(item) {
- const obj = this;
- let card = '';
- let pwd = '';
- if (item) {
- card = item.card;
- pwd = item.pwd;
- } else {
- card = this.card;
- pwd = this.pwd;
- }
- if (card == '') {
- return this.$api.msg('请填写卡号');
- }
- if (pwd == '') {
- return this.$api.msg('请填写密码');
- }
- uni.showModal({
- title: '提示',
- content: '是否激活该卡?',
- success: function(res) {
- if (res.confirm) {
- use_card({
- card: card,
- pwd: pwd
- }).then(e => {
- uni.showModal({
- title: '提示',
- content: '激活卡片成功'
- });
- obj.loadData('shua');
- });
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- }
- }
- };
- </script>
- <style lang="scss">
- // 卡卷可用时颜色
- $card-color-action: #fc4141;
- page,
- .content {
- background: $page-color-base;
- height: 100%;
- }
- .navbar {
- display: flex;
- height: 40px;
- background: #fff;
- box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
- position: relative;
- z-index: 10;
- .nav-item:first-child {
- border-left: none;
- }
- .nav-item {
- border-left: 1px solid #e7e7e7;
- flex: 1;
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100%;
- font-size: 15px;
- color: $font-color-dark;
- position: relative;
- &.current {
- color: #24a17d;
- }
- }
- }
- .swiper-box {
- height: calc(100% - 100px);
- .tab-content {
- padding: 25rpx;
- }
- }
- // uni-load-more
- .uni-load-more {
- display: flex;
- flex-direction: row;
- height: 80rpx;
- align-items: center;
- justify-content: center;
- }
- .main-item {
- .main-item-top {
- align-items: flex-start;
- width: 702rpx;
- height: 150rpx;
- position: relative;
- .main-item-top-bg {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- width: 702rpx;
- height: 150rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .main-item-top-left {
- position: relative;
- z-index: 2;
- padding: 40rpx 0 0 30rpx;
- line-height: 1;
- .main-item-title {
- font-size: 42rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #c99f62;
- }
- .main-item-time {
- margin-top: 20rpx;
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #d6d1d1;
- }
- }
- .main-item-type {
- padding: 56rpx 24rpx 0 0;
- position: relative;
- z-index: 2;
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #d6d1d1;
- }
- }
- .main-item-bottom {
- width: 702rpx;
- height: 176rpx;
- position: relative;
- padding: 30rpx 30rpx 0;
- line-height: 1;
- .main-item-bottom-bg {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- width: 702rpx;
- height: 176rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .main-item-price {
- width: 100%;
- position: relative;
- z-index: 2;
- font-size: 30rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #ff6f0f;
- .fh {
- color: #333333;
- }
- .time {
- display: inline-block;
- margin-left: 4rpx;
- color: #333333;
- text-decoration: underline;
- }
- }
- .main-item-bottom-type {
- position: relative;
- z-index: 2;
- flex-shrink: 0;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #333333;
- }
- .main-item-info-right {
- position: relative;
- z-index: 2;
- flex-shrink: 0;
- display: flex;
- align-items: center;
- line-height: 1;
- .main-item-info-font {
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #999999;
- margin-right: 10rpx;
- }
- .main-item-info-icon {
- position: relative;
- top: -10rpx;
- width: 19rpx;
- height: 19rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- }
- .main-item-info {
- position: relative;
- z-index: 2;
- margin-top: 20rpx;
- .main-item-info-left {
- width: 100%;
- font-size: 24rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #666666;
- }
- .main-item-info-btn {
- width: 127rpx;
- height: 44rpx;
- background: #ff6f0f;
- border-radius: 22rpx;
- font-size: 22rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #ffffff;
- line-height: 44rpx;
- text-align: center;
- }
- }
- }
- }
- .image {
- width: 44rpx;
- height: 30rpx;
- }
- .info {
- width: 350rpx;
- margin-right: 10rpx;
- font-size: 26rpx;
- font-weight: 500;
- color: #666666;
- }
- .copy {
- margin-left: 10rpx;
- font-size: 22rpx;
- font-family: PingFang SC;
- font-weight: 500;
- text-decoration: underline;
- color: #333333;
- }
- .list-scroll-content {
- height: 100%;
- }
- .btn {
- margin: 10rpx auto 0;
- width: 622rpx;
- height: 85rpx;
- background: #ff6f0f;
- border-radius: 15rpx;
- line-height: 85rpx;
- text-align: center;
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #ffffff;
- }
- .img1 {
- width: 560rpx;
- height: 182rpx;
- display: flex;
- justify-content: center;
- image {
- width: 462rpx;
- height: 182rpx;
- }
- }
- .popup-box {
- margin-top: -50rpx;
- width: 560rpx;
- background: #ffffff;
- border-radius: 30rpx;
- position: relative;
- padding-bottom: 50rpx;
- .img {
- position: relative;
- top: -80rpx;
- left: 0;
- width: 560rpx;
- height: 186rpx;
- display: flex;
- justify-content: center;
- image {
- width: 177rpx;
- height: 186rpx;
- }
- }
- .mian {
- margin-top: -44rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- // padding: 32rpx 32rpx;
- background-color: #ffffff;
- border-radius: 0 0 20rpx 20rpx;
- text-align: center;
- .delivery {
- font-size: 40rpx;
- color: #333333;
- display: flex;
- align-items: center;
- flex-direction: column;
- .title {}
- image {
- margin-top: 48rpx;
- width: 172rpx;
- height: 160rpx;
- }
- }
- .comfirm-box {
- margin-top: 30rpx;
- display: flex;
- flex-direction: column;
- justify-content: center;
- .input {
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #999999;
- text-align: left;
- width: 439rpx;
- background: #f5f5f5;
- border-radius: 10rpx;
- margin-top: 20rpx;
- padding: 20rpx 26rpx;
- }
- }
- .popup-btn {
- width: 403rpx;
- height: 83rpx;
- background: #24a17d;
- border-radius: 42rpx;
- margin: 45rpx auto 0;
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #ffffff;
- line-height: 83rpx;
- text-align: center;
- }
- }
- }
- .x {
- margin: 35rpx auto 0;
- width: 80rpx;
- height: 80rpx;
- image {
- width: 80rpx;
- height: 80rpx;
- }
- }
- </style>
|