websoft-uniapp仓库模板
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

422 lines
9.4 KiB

<template>
<view>
<!-- <view class="segmented">
<uni-segmented-control :current="current" :values="items" :styleType="styleType" :activeColor="activeColor" inActiveColor="#808080" @clickItem="onClickItem" />
</view> -->
<view class="card-list">
<block v-if="!hideTools || cardList.length > 0">
<view
class="container"
v-for="(item, index) in cardList"
:key="index"
@click="openUrl('/package/user/card-detail?cardId=' + item.id)"
:style="{ background: `url(${item.image}) 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: 17px; font-weight: 600">{{ item.name }}</view>
<!-- <block v-if="item.type == 2">
<view class="desc web-text-heading" style="color: #ffffff; font-size: 14px">{{ item.month }}个月</view>
</block> -->
<block v-if="item.type == 2">
<view class="desc web-text-heading" style="color: #ffffff; font-size: 14px">剩余{{ item.number }}次</view>
</block>
<block v-if="item.type == 1 || item.type == 3 || item.type == 5">
<view class="desc web-text-heading" style="color: #ffffff; font-size: 14px">余额¥{{ item.remainingMoney }}</view>
</block>
</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/booking/userCard';
import { pageWechatDeposit } from '@/api/shop/wechatDeposit';
import { getWeek, getKey } from '@/utils/common';
export default {
components: {},
data() {
return {
isRefresh: false,
isLogin: false,
userId: 0,
where: {
page: 1
},
canReset: false,
loadMore: 'more',
logo: '',
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();
}
},
// 触底函数
onReachBottom() {
const app = this;
const { where } = this;
if (app.canReset) {
app.where.page = ++where.page;
app.reload();
}
},
methods: {
reload() {
const app = this;
const { where, userId } = this;
if (userId == 0) {
app.openLogin();
return;
}
where.userId = userId;
where.payStatus = 1;
app.loadMore = 'loading';
Api.pageUserCard(where)
.then((res) => {
console.log('res: ', res);
const list = res.list.map((d) => {
console.log(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;
}
}
}
};
</script>
<style lang="scss">
.content {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
height: 150px;
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: 200rpx;
position: relative;
margin: 25rpx auto;
display: flex;
justify-content: space-between;
align-items: center;
border-radius: 20rpx;
position: relative;
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>