dl_uniapp/pages/mine/card/my-card.vue

392 lines
8.3 KiB
Vue
Raw Normal View History

2025-04-01 10:18:22 +08:00
<template>
2025-04-02 17:35:06 +08:00
<view :class="['my-card-box',ifChoose?'has-footer':'']">
<view class="opt-box" v-if="!ifChoose">
<view v-if="!ifEdit" class="item-dom" @click="manager(true)"><uni-icons type="bars" color="#FC1F3E"
size="16"></uni-icons><text></text></view>
<view v-if="!ifEdit" class="item-dom" @click="addCard()">
<uni-icons type="plusempty" color="#FC1F3E" size="16"></uni-icons>
<text>新增名片</text>
2025-04-01 10:18:22 +08:00
</view>
2025-04-02 17:35:06 +08:00
<view v-if="ifEdit" class="item-dom" @click="manager(false)"><uni-icons type="closeempty" color="#FC1F3E"
size="16"></uni-icons><text>退</text></view>
</view>
<view class="addr-list-box">
<view class="card-dom " v-for="item in busiCardList">
<!-- 多选框--管理状态或者选择名片时使用 -->
2025-04-03 13:40:26 +08:00
<view class="choose-dom" v-if="ifChoose">
2025-04-02 17:35:06 +08:00
<uni-data-checkbox v-model="item.choosed" :disabled="1!=item.approvalStatus" multiple
:localdata="checkboxArray" />
</view>
<view :class="['right-content',item.choosed.length>0?'click':'']">
<view class="card-title">
<!-- 需要根据平台code取对应的图片 TODO -->
<image :src="'/static/platform/'+item.platformCode+'.png'" mode="aspectFit"></image>
<text>{{item.platformName}}博主</text>
<view class="edit-text" @click="edit()">
<text v-if="1==item.approvalStatus" style="color:#5986F2;">已审核</text>
<text v-else-if="0==item.approvalStatus" style="color:#FC1F3E ;">审核中</text>
<text v-else>未通过</text>
2025-04-01 10:54:00 +08:00
</view>
</view>
2025-04-02 17:35:06 +08:00
<view class="card-content">
<view class="card-person-info">
<view class="card-name">
<view>{{ item.nickname }}</view>
</view>
<view class="detail-text">
<view class="fans-dom">
粉丝{{ formatNumberWithUnits(item.fansNum) }}
</view>
<view class="nickname-dom">
昵称{{ item.accountName }}
</view>
</view>
</view>
</view>
<view v-if="ifEdit" @click="del(item)" :class="['edit-dom',item.choosed.length>0?'':'no-choose']">删除
</view>
<view v-else :class="['edit-dom',item.choosed.length>0?'':'no-choose']" @click="edit(item)">编辑
2025-04-01 10:54:00 +08:00
</view>
</view>
</view>
</view>
2025-04-02 17:35:06 +08:00
<view v-if="ifChoose" class="footer-box">
<view class="left-radio">
<uni-data-checkbox @change="chooseAllFun()" multiple :localdata="chooseAll" />
</view>
<view class="right-button">
<text>已选择{{getChooseNum}}</text>
<view class="button-dom">保存</view>
</view>
2025-04-01 10:18:22 +08:00
</view>
</view>
</template>
<script>
2025-04-02 17:35:06 +08:00
import {
formatNumberWithUnits
} from '@/utils/common.js'
import {
getUserBusiCard
} from '@/api/business/member.js'
2025-04-01 10:18:22 +08:00
export default {
data() {
return {
2025-04-02 17:35:06 +08:00
//是否是管理模式
ifEdit: false,
2025-04-03 13:40:26 +08:00
//是否是选择模式(默认值为false管理页面)
ifChoose: false,
2025-04-02 17:35:06 +08:00
checkboxArray: [{
text: '',
value: true
}],
chooseAll: [{
text: '全选',
value: true
}],
busiCardList: [],
}
},
computed: {
getChooseNum() {
return this.busiCardList.filter((item) => item.choosed.length > 0).length
2025-04-01 10:18:22 +08:00
}
},
2025-04-02 17:35:06 +08:00
onLoad() {
this.initData();
},
2025-04-01 10:18:22 +08:00
methods: {
2025-04-02 17:35:06 +08:00
/**
* 数值单位转换
* @param {Object} number
*/
formatNumberWithUnits(number) {
return formatNumberWithUnits(number)
},
//查询名片列表
initData() {
getUserBusiCard().then(res => {
if (res.data.length > 0) {
res.data.map((item) => {
item.choosed = []
this.busiCardList.push(item)
})
}
}).catch((e) => {
uni.showToast({
icon: 'error',
duration: 2000,
title: e
});
})
},
/**
* 全选
* @param {Object} e
*/
chooseAllFun(e) {
if (e.detail.value.length > 0) {
this.busiCardList.map((item) => {
if ("1" == item.approvalStatus) {
item.choosed = [true]
}
})
} else {
this.busiCardList.map((item) => {
if ("1" == item.approvalStatus) {
item.choosed = []
}
})
}
},
/**
* 删除名片
* @param {Object} item
*/
del(item) {},
2025-04-01 10:54:00 +08:00
//名片编辑
2025-04-02 17:35:06 +08:00
edit(item) {
2025-04-01 10:54:00 +08:00
this.$tab.navigateTo('/pages/mine/card/card-detail')
},
addCard() {
this.$tab.navigateTo('/pages/mine/card/card-detail')
2025-04-02 17:35:06 +08:00
},
/**
* 进入管理
*/
manager(flag) {
this.ifEdit = flag
},
2025-04-02 10:22:56 +08:00
2025-04-01 10:18:22 +08:00
}
}
</script>
<style lang="scss">
2025-04-02 17:35:06 +08:00
.has-footer {
padding-bottom: calc(var(--window-bottom) + 85rpx);
}
2025-04-01 10:18:22 +08:00
.my-card-box {
border-top: 1rpx solid #F4F4F4;
width: 100%;
color: #363636;
2025-04-02 17:35:06 +08:00
font-size: 32rpx;
2025-04-01 10:18:22 +08:00
height: 100%;
display: flex;
flex-direction: column;
2025-04-02 17:35:06 +08:00
align-items: self-start;
2025-04-01 10:18:22 +08:00
justify-content: center;
position: relative;
2025-04-02 17:35:06 +08:00
.opt-box {
width: 100%;
display: flex;
color: #FC1F3E;
padding: 25rpx;
align-items: center;
justify-content: center;
border-bottom: 1rpx solid #F2F2F2;
2025-04-01 10:54:00 +08:00
2025-04-02 17:35:06 +08:00
.item-dom {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
text {
margin-left: 10rpx;
}
2025-04-01 10:54:00 +08:00
}
}
2025-04-02 17:35:06 +08:00
.addr-list-box {
height: 100%;
padding: 20rpx 30rpx;
background-color: #F2F2F2;
2025-04-01 10:18:22 +08:00
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
2025-04-02 17:35:06 +08:00
justify-content: start;
2025-04-01 10:18:22 +08:00
2025-04-02 17:35:06 +08:00
.card-dom {
2025-04-01 10:54:00 +08:00
width: 100%;
2025-04-02 17:35:06 +08:00
font-size: 30rpx;
2025-04-01 10:18:22 +08:00
display: flex;
align-items: center;
2025-04-02 17:35:06 +08:00
justify-content: start;
position: relative;
2025-04-01 10:18:22 +08:00
2025-04-02 17:35:06 +08:00
.choose-dom {
width: 60rpx;
2025-04-01 10:54:00 +08:00
display: flex;
align-items: center;
2025-04-02 17:35:06 +08:00
justify-content: start;
2025-04-01 10:54:00 +08:00
}
2025-04-02 17:35:06 +08:00
.edit-dom {
right: 0;
bottom: 0;
position: absolute;
padding: 10rpx 30rpx;
font-size: 25rpx;
color: white;
background-color: #FC1F3E;
border-radius: 15rpx 0 15rpx 0;
}
2025-04-01 10:54:00 +08:00
2025-04-02 17:35:06 +08:00
.no-choose {
right: -3rpx !important;
bottom: -3rpx !important;
padding: 10rpx 33rpx 13rpx 30rpx !important;
border-radius: 15rpx 0 20rpx 0 !important;
2025-04-01 10:18:22 +08:00
}
2025-04-01 10:54:00 +08:00
2025-04-02 17:35:06 +08:00
.right-content {
2025-04-01 10:54:00 +08:00
flex: 1;
2025-04-02 17:35:06 +08:00
width: 100%;
border: 3rpx solid white;
padding: 20rpx;
border-radius: 20rpx;
background-color: white;
position: relative;
z-index: 10;
2025-04-01 10:54:00 +08:00
display: flex;
flex-direction: column;
2025-04-02 17:35:06 +08:00
align-items: center;
justify-content: center;
margin-bottom: 20rpx;
.card-title {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
image {
width: 40rpx;
height: 40rpx;
}
2025-04-01 10:54:00 +08:00
2025-04-02 17:35:06 +08:00
text {
padding-left: 10rpx;
flex: 1;
}
.edit-text {
display: flex;
align-items: center;
justify-content: flex-end;
text-align: right;
width: 150rpx;
}
2025-04-01 10:54:00 +08:00
}
2025-04-02 17:35:06 +08:00
.card-content {
margin-top: 20rpx;
width: 100%;
display: flex;
align-items: center;
justify-content: flex-start;
image {
width: 120rpx;
height: 120rpx;
border-radius: 15rpx;
}
.card-person-info {
padding-left: 20rpx;
flex: 1;
display: flex;
align-items: self-start;
justify-content: center;
flex-direction: column;
.card-name {
font-weight: bold;
font-size: 32rpx;
}
image {
margin-left: 10rpx;
width: 20rpx;
height: 20rpx;
}
.detail-text {
width: 100%;
display: flex;
color: #363636;
align-items: center;
justify-content: start;
font-size: 24rpx;
padding: 5rpx 0;
.fans-dom {
width: 30%;
}
.nickname-dom {
flex: 1;
}
}
}
2025-04-01 10:54:00 +08:00
}
}
2025-04-02 17:35:06 +08:00
2025-04-01 10:54:00 +08:00
}
}
2025-04-02 17:35:06 +08:00
.click {
border: 3rpx solid #FC1F3E !important;
2025-04-01 10:54:00 +08:00
position: relative;
2025-04-02 17:35:06 +08:00
.choosed {
width: 80rpx;
height: 80rpx;
position: absolute;
right: 0;
bottom: -4rpx;
}
}
.footer-box {
z-index: 999;
padding: 20rpx 30rpx;
background-color: white;
width: 100%;
2025-04-01 10:54:00 +08:00
display: flex;
align-items: center;
2025-04-02 17:35:06 +08:00
justify-content: start;
position: fixed;
bottom: var(--window-bottom);
.left-radio {
text-align: left;
width: 30%;
}
.right-button {
flex: 1;
display: flex;
align-items: center;
justify-content: flex-end;
text {
margin-right: 15rpx;
font-size: 24rpx;
}
.button-dom {
padding: 10rpx 40rpx;
background-color: #FC1F3E;
border-radius: 15rpx;
color: white;
}
2025-04-01 10:54:00 +08:00
2025-04-01 10:18:22 +08:00
}
}
}
</style>