Files
gxtyzx-uniapp/src/package/user/card.vue
T
2025-03-23 10:10:33 +08:00

468 lines
12 KiB
Vue

<template>
<view>
<uv-tabs :list="list" :current="cardType" :scrollable="false" @click="changeCardType"></uv-tabs>
<view class="card-list">
<block v-if="!hideTools || cardList.length > 0">
<view
class="container"
v-for="(item, index) in cardList"
:key="index"
@click="toDetail(item.id)"
:style="{ background: `url(https://oss.wsdns.cn/20240920/5e3327e1ad97472e942c824ab1776f52.jpg?x-oss-process=image/resize,m_fixed,w_750/quality,Q_90) no-repeat center center`, backgroundSize: '100%', opacity: '0.85' }"
>
<view class="content web-cell">
<!-- <view class="merchant-avatar">-->
<!-- <uv-avatar :src="item.merchantAvatar" size="36" style="border: 3rpx solid #ffffff"></uv-avatar>-->
<!-- </view>-->
<view class="card-info web-cell-content">
<view class="title-bar">
<view class="web-text-heading" style="color: #ffffff; font-size: 20px; font-weight: 600">{{
item.name
}}
</view>
<view class="desc py-3" style="text-align: left;">
{{ item.siteNames }}
</view>
<!-- <block v-if="item.type == 2">
<view class="desc web-text-heading" style="color: #ffffff; font-size: 14px">{{ item.month }}个月</view>
</block> -->
<view v-if="item.type === 2" class="desc web-text-heading" style="color: #ffffff; font-size: 14px">剩余{{
item.num
}}次
</view>
<view v-if="item.type === 5" class="desc web-text-heading" style="color: #ffffff; font-size: 14px">余额¥{{
item.remainingMoney
}}
</view>
<view class="desc web-text-heading" v-if="item.type === 1 || item.type === 3"
style="color: #ffffff; font-size: 14px">
{{ dayjs(item.expireTime * 1000).format('YYYY-MM-DD HH:mm') }}过期
</view>
</view>
<!-- <view class="price">
<text class="web-text-price">{{ `¥${item.price}` }}</text>
</view> -->
</view>
</view>
</view>
</block>
<block v-else>
<uni-card :border="false" :padding="'18px 6px'">
<uv-skeleton rows="2" avatar :loading="hideTools" :title="false"></uv-skeleton>
</uni-card>
<uni-card :border="false" :padding="'18px 6px'">
<uv-skeleton rows="2" avatar :loading="hideTools" :title="false"></uv-skeleton>
</uni-card>
<uni-card :border="false" :padding="'18px 6px'">
<uv-skeleton rows="2" avatar :loading="hideTools" :title="false"></uv-skeleton>
</uni-card>
<uni-card :border="false" :padding="'18px 6px'">
<uv-skeleton rows="2" avatar :loading="hideTools" :title="false"></uv-skeleton>
</uni-card>
<uni-card :border="false" :padding="'18px 6px'">
<uv-skeleton rows="2" avatar :loading="hideTools" :title="false"></uv-skeleton>
</uni-card>
<uni-card :border="false" :padding="'18px 6px'">
<uv-skeleton rows="2" avatar :loading="hideTools" :title="false"></uv-skeleton>
</uni-card>
</block>
<!-- 登录组件 -->
<ws-login ref="login" :logo="logo" @done="reload"/>
</view>
<view v-if="!hideTools && cardList.length == 0">
<uv-empty mode="list" icon="https://cdn.uviewui.com/uview/empty/list.png"></uv-empty>
</view>
</view>
</template>
<script>
import * as Api from '@/api/think/thinkUsersVip';
import {getWeek, getKey} from '@/utils/common';
import dayjs from "dayjs";
import {listThinkUsersVip, pageThinkUsersVip} from "@/api/think/thinkUsersVip";
import {listThinkCard, listUserThinkCard, pageThinkCard} from "@/api/think/thinkCard";
export default {
components: {},
data() {
return {
isRefresh: false,
isLogin: false,
userId: 0,
cardType: 0,
where: {
page: 1
},
canReset: false,
loadMore: 'more',
logo: '',
list: [{name: 'VIP卡'}, {name: 'IC卡'}],
items: ['月/年卡', '次卡', '充值卡'],
cardList: [],
styles: [
{
value: 'button',
text: '按钮',
checked: true
},
{
value: 'text',
text: '文字'
}
],
colors: ['#333333', '#4cd964', '#dd524d'],
current: 0,
colorIndex: 0,
activeColor: '#108001',
styleType: 'text',
getWeek,
// 骨架屏
hideTools: true
};
},
onLoad(option) {
// 判断是否登录
this.openLogin();
// 加载数据
this.reload();
console.log('判断是否刷新: ', option);
if (option.isRefresh) {
this.isRefresh = true;
}
},
onShow(e) {
console.log('判断是否刷新: ', e);
// 判断是否登录
this.openLogin();
// if (this.isRefresh) {
// this.reload();
// }
this.cardType = 0
this.getVipCardList()
},
// 触底函数
onReachBottom() {
const app = this;
const {where} = this;
if (app.canReset) {
app.where.page = ++where.page;
app.reload();
}
},
methods: {
dayjs,
changeCardType({index}) {
this.cardType = index
this.cardList = []
if (index === 0) {
this.getVipCardList()
} else {
this.getIcCardList()
}
},
async getVipCardList() {
this.cardList = await listThinkUsersVip()
},
async getIcCardList() {
this.cardList = await listUserThinkCard()
},
reload() {
const app = this;
const {where, userId} = this;
if (userId === 0) {
app.openLogin();
return;
}
where.uid = uni.getStorageSync('uid');
where.status = 1;
where.sceneType = 'myCardAll';
app.loadMore = 'loading';
Api.pageThinkUsersVip(where)
.then((res) => {
console.log('res: ', res);
const list = res.list.map((d) => {
return d;
});
if (app.cardList.length < res.count) {
app.cardList = app.cardList.concat(list);
app.canReset = true;
app.loadMore = 'no-more';
} else {
app.canReset = false;
app.hideTools = false;
app.loadMore = 'no-more';
}
// uni.hideLoading();
app.isRefresh = false;
})
.catch(() => {
uni.showToast({
title: '请检查您的网络.',
icon: 'none'
});
app.hideTools = false;
app.isRefresh = false;
});
},
onClickItem(e, text) {
const app = this;
const {where, userId} = this;
const index = e.currentIndex;
if (this.current !== e.currentIndex) {
this.current = e.currentIndex;
}
// 全部
if (index == 0) {
where.cardCode = '月/年卡';
}
// 未支付
if (index == 1) {
where.cardCode = '次卡';
}
// 已支付
if (index == 2) {
where.cardCode = '充值卡';
}
this.where.page = 1;
this.cardList = [];
this.hideTools = true;
this.reload();
},
openUrl(url) {
uni.navigateTo({
url
});
},
toPay(orderId) {
uni.navigateTo({
url: '/package/booking/confirm?id=' + orderId
});
},
closeOrder(item) {
uni.showModal({
title: '确定取消此订单?',
success(o) {
if (o.confirm) {
// Api.updateOrder({
// orderStatus: 2,
// orderId: item.orderId
// })
// .then((msg) => {
// uni.showToast({
// title: msg,
// icon: 'none'
// });
// item.orderStatus = 2;
// })
// .catch(() => {
// uni.showToast({
// title: '请检查您的网络.',
// icon: 'none'
// });
// uni.hideLoading();
// });
}
}
});
},
// 弹出登录提示框
async openLogin() {
this.userId = uni.getStorageSync('user_id');
if (!this.userId) {
this.$refs.login.open('bottom');
return false;
}
},
toDetail(id) {
if (this.cardType === 0)
this.openUrl(`/package/user/card-detail?cardId=${id}`)
else
this.openUrl(`/package/user/ic-card-detail?cardId=${id}`)
}
}
};
</script>
<style lang="scss">
.content {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
height: 380rpx;
text-align: center;
}
.segmented {
padding: 0 12rpx;
}
.content-text {
font-size: 14px;
color: #666;
}
.color-tag {
width: 25px;
height: 25px;
}
.uni-list {
flex: 1;
}
.card-list {
.container {
width: 700rpx;
height: 380rpx;
position: relative;
margin: 25rpx auto;
display: flex;
justify-content: space-between;
align-items: center;
border-radius: 20rpx;
box-shadow: 0 0px 6px 0 rgba(0, 0, 0, 0.2);
// background: linear-gradient(to right, #70b915, #008e04);
color: #ffffff;
}
.container::before {
content: '';
display: block;
position: absolute;
border-radius: 20rpx;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #000000;
// background: url('https://oss.wsdns.cn/20240528/cf37a247603f489ba23d7d2a53b8da39.jpeg') no-repeat center bottom;
background-size: 100%;
opacity: 0.25; /* 设置透明度 */
}
.content {
position: relative;
z-index: 1;
width: 700rpx;
display: flex;
justify-content: space-between;
.merchant-avatar {
margin-left: 24rpx;
}
.card-info {
margin-left: 10rpx;
display: flex;
justify-content: space-between;
align-items: center;
.title-bar {
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
}
.web-text-price {
padding-right: 30rpx;
font-size: 36rpx;
color: #fecc66;
}
}
.card-bg {
}
}
.card-item {
width: 700rpx;
margin: 20rpx auto;
border-radius: 20rpx;
position: relative;
// box-shadow: 0 0px 6px 1px rgba($color: #a5a5a5, $alpha: 0.2);
}
// .card-item::before {
// content: ''; /* 伪元素需要内容,即使它是空的 */
// position: absolute;
// top: 0;
// right: 0;
// bottom: 0;
// left: 0;
// background: url('https://oss.wsdns.cn/20240528/d5680e18210544a49dfa79f250f1997d.jpeg');
// background-size: cover; /* 或其他你需要的背景大小 */
// opacity: 0.5; /* 设置透明度 */
// z-index: -1; /* 确保伪元素在内容之下 */
// }
.order-title {
padding: 20rpx 0;
.merchant-avatar {
margin-right: 12rpx;
}
.card-name {
font-weight: 600;
}
.btn-status {
font-size: 30rpx;
display: flex;
}
}
.order-body {
padding: 16px 0;
}
}
.ele-flex {
display: flex;
justify-content: space-between;
}
.card-actions {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
height: 45px;
border-top: 1px #eee solid;
}
.card-actions-item {
display: flex;
flex-direction: row;
align-items: center;
}
.card-actions-item-text {
font-size: 12px;
color: #666;
margin-left: 5px;
}
.close {
top: 60rpx !important;
}
.total-price {
display: flex;
flex-direction: column;
justify-content: flex-start;
font-size: 30rpx;
align-items: flex-start;
padding-left: 6rpx;
margin-left: 450rpx;
.web-text-heading {
font-size: 30rpx !important;
}
}
</style>