活动按钮状态流转

This commit is contained in:
2026-03-25 15:53:37 +08:00
commit 37346e790f
2762 changed files with 240282 additions and 0 deletions

162
pagesCard/mine/custom.vue Normal file
View File

@@ -0,0 +1,162 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
+----------------------------------------------------------------------
| 沃德商协会系统并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
+----------------------------------------------------------------------
| 自定义背景图 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->
<template>
<view class="container" :style="{'--theme-color': themeColor}">
<!-- 标题栏 -->
<title-bar :showBack="true" title="自定义背景"></title-bar>
<!-- 内容区 -->
<view class="container-main">
<view class="main-upload" @click="chooseImage()">
<image class="upload-icon" src="/static/card/image.png" mode="aspectFit"></image>
<view class="upload-text">点击上传背景</view>
<view class="upload-text">(建议上传尺寸686*400上传格式JPG/JPEG/PNG)</view>
</view>
<view class="main-tips">
<view class="tips-title">温馨提示</view>
<view class="tips-content">自定义图片只能上传一张后续可点击进行重新上传</view>
<view class="tips-bg"></view>
</view>
</view>
</view>
</template>
<script>
import { mapState } from "vuex"
export default {
computed: {
...mapState({
themeColor: state => state.app.themeColor,
})
},
methods: {
// 选择图片
chooseImage() {
// #ifdef MP-WEIXIN
uni.chooseMedia({
count: 1,
mediaType: ['image'],
sourceType: ['album', 'camera'],
sizeType: ['compressed'],
success: (res) => {
const imagePath = res.tempFiles[0].tempFilePath
this.uploadImage(imagePath)
}
})
// #endif
// #ifndef MP-WEIXIN
uni.chooseImage({
count: 1,
sourceType: ['album', 'camera'],
sizeType: ['compressed'],
success: (res) => {
const imagePath = res.tempFilePaths[0]
this.uploadImage(imagePath)
}
});
// #endif
},
// 上传图片
uploadImage(image) {
uni.showLoading({
mask: true,
title: "上传中"
})
this.$util.uploadFile(image).then(result => {
if (result.code == 1) {
uni.hideLoading()
let pages = getCurrentPages()
let prevPage = pages[pages.length - 2]
prevPage.$vm.selectBackground = result.data
uni.navigateBack()
} else {
uni.showToast({
title: result?.msg || "上传失败",
icon: 'none'
})
}
}).catch(error => {
uni.hideLoading()
console.error('上传图片 ', error)
})
},
}
}
</script>
<style lang="scss">
page {
background: #FFF;
}
.container {
.container-main {
padding: 32rpx;
.main-upload {
display: flex;
flex-direction: column;
align-items: center;
border-radius: 16rpx;
border: 1px dashed #8D929C;
padding: 92rpx 32rpx;
.upload-icon {
width: 112rpx;
height: 112rpx;
}
.upload-text {
margin-top: 16rpx;
color: #8D929C;
text-align: center;
font-size: 28rpx;
line-height: 40rpx;
}
}
.main-tips {
margin-top: 32rpx;
padding: 32rpx;
position: relative;
z-index: 1;
border-radius: 16rpx;
overflow: hidden;
.tips-title {
color: var(--theme-color);
font-size: 28rpx;
font-weight: 600;
line-height: 40rpx;
}
.tips-content {
margin-top: 24rpx;
color: var(--theme-color);
font-size: 24rpx;
line-height: 34rpx;
}
.tips-bg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: -1;
background: var(--theme-color);
opacity: 0.1;
}
}
}
}
</style>

268
pagesCard/mine/details.vue Normal file
View File

@@ -0,0 +1,268 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
+----------------------------------------------------------------------
| 沃德商协会系统并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
+----------------------------------------------------------------------
| 名片详情 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->
<template>
<view class="container" :style="{'--theme-color': themeColor}">
<!-- 标题栏 -->
<title-bar :showBack="true" title="名片详情"></title-bar>
<!-- 内容区 -->
<view class="container-main" v-if="loadEnd">
<view class="main-card">
<card-item :show-data="cardDetails"></card-item>
</view>
<view class="main-record" v-if="cardDetails.visitor_count > 0">
<view class="record-title">
<view class="title">访客记录</view>
<view class="label">已有{{cardDetails.visitor_count}}人访问</view>
</view>
<view class="record-list">
<view class="list-item" v-for="(item, index) in cardDetails.visitor_list" :key="index">
<image class="item-avatar" :src="item.avatar" mode="aspectFill"></image>
</view>
<view class="list-item" v-if="cardDetails.visitor_count > 23">
<view class="item-more">
<view class="point"></view>
<view class="point"></view>
<view class="point"></view>
</view>
</view>
</view>
</view>
<view class="main-introduce">
<view class="introduce-title">公司介绍</view>
<view class="introduce-content">
<mp-html :content="cardDetails.company_introduction || '暂未完善'"></mp-html>
</view>
</view>
</view>
</view>
</template>
<script>
import { mapState } from "vuex"
import cardItem from "../component/card/item.vue"
// #ifdef H5
import wx from 'weixin-js-sdk';
// #endif
export default {
components: {
cardItem,
},
data() {
return {
// 加载完成
loadEnd: false,
// 名片id
cardId: null,
// 名片信息
cardDetails: {},
};
},
computed: {
...mapState({
themeColor: state => state.app.themeColor,
})
},
onLoad(option) {
uni.showLoading({
title: "加载中"
})
this.cardId = option.id
this.getCardDetails(() => {
uni.hideLoading()
this.loadEnd = true
})
// #ifdef H5
this.initConfig()
// #endif
},
onShareAppMessage() {
return {
title: this.cardDetails.share_title,
path: "/pagesCard/card/details?id=" + this.cardDetails.id,
imageUrl: this.cardDetails.image,
}
},
onShareTimeline() {
return {
title: this.cardDetails.share_title,
path: "/pagesCard/card/details?id=" + this.cardDetails.id,
imageUrl: this.cardDetails.image,
}
},
methods: {
// #ifdef H5
// 微信公众号初始化方法
initConfig() {
this.$util.request("main.WeChatConfig", {
url: location.href.split('#')[0]
}).then(res => {
if (res.code == 1) {
wx.config({
debug: false,
appId: res.data.appId,
timestamp: Number(res.data.timestamp),
nonceStr: res.data.nonceStr,
signature: res.data.signature,
jsApiList: ["updateAppMessageShareData", "updateTimelineShareData"],
openTagList: ["updateAppMessageShareData", "updateTimelineShareData"],
})
wx.ready(() => {
wx.updateAppMessageShareData({
title: this.shareTitle,
desc: "",
link: window.location.href,
imgUrl: this.shareImage,
});
wx.updateTimelineShareData({
title: this.shareTitle,
link: window.location.href,
imgUrl: this.shareImage,
});
});
} else {
uni.hideLoading()
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
uni.hideLoading()
console.error('通过config接口注入权限验证配置 ', error)
})
},
// #endif
// 获取名片详情
getCardDetails(fn) {
this.$util.request("card.details", {
id: this.cardId
}).then(res => {
if (fn) fn()
if (res.code == 1) {
this.cardDetails = res.data
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
if (fn) fn()
console.error('获取名片详情 ', error)
})
},
}
}
</script>
<style lang="scss">
.container {
.container-main {
padding: 32rpx;
.main-record {
padding: 32rpx;
border-radius: 16rpx;
background: #ffffff;
margin-top: 32rpx;
.record-title {
display: flex;
justify-content: space-between;
align-items: center;
.title {
color: #5A5B6E;
font-size: 32rpx;
font-weight: 600;
line-height: 44rpx;
}
.label {
color: var(--theme-color);
font-size: 24rpx;
line-height: 34rpx;
}
}
.record-list {
padding-top: 8rpx;
margin-left: -2rpx;
display: flex;
flex-wrap: wrap;
.list-item {
width: calc((100% / 12) - 4rpx);
height: 0;
padding-top: calc((100% / 12) - 4rpx);
border-radius: 50%;
overflow: hidden;
position: relative;
margin-left: 4rpx;
margin-top: 16rpx;
background: #eee;
.item-avatar {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.item-more {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: var(--theme-color);
padding: 0 6rpx;
display: flex;
justify-content: space-around;
align-items: center;
.point {
width: 6rpx;
height: 6rpx;
background: #ffffff;
border-radius: 50%;
}
}
}
}
}
.main-introduce {
padding: 32rpx;
border-radius: 16rpx;
background: #ffffff;
margin-top: 32rpx;
.introduce-title {
color: #5A5B6E;
font-size: 32rpx;
font-weight: 600;
line-height: 44rpx;
}
.introduce-content {
margin-top: 24rpx;
color: #5A5B6E;
font-size: 28rpx;
line-height: 48rpx;
}
}
}
}
</style>

1088
pagesCard/mine/edit.vue Normal file

File diff suppressed because it is too large Load Diff

112
pagesCard/mine/editor.vue Normal file
View File

@@ -0,0 +1,112 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
+----------------------------------------------------------------------
| 沃德商协会系统并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
+----------------------------------------------------------------------
| 编辑器 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->
<template>
<view class="container">
<!-- 标题栏 -->
<title-bar :showBack="true" :title="cardId ? '编辑名片' : '新建名片'"></title-bar>
<!-- 内容区 -->
<view class="container-main">
<sp-editor :toolbar-config="toolbarConfig" @init="initEditor" @upinImage="upinImage" @overMax="overMax" @exportHtml="exportHtml"></sp-editor>
</view>
<view class="safe-padding"></view>
</view>
</template>
<script>
import { mapState } from "vuex"
export default {
data() {
return {
// 编辑器实例
editorIns: null,
// 编辑器配置
toolbarConfig: {
excludeKeys: ['direction', 'date', 'lineHeight', 'letterSpacing', 'listCheck'],
iconSize: '18px'
}
}
},
computed: {
...mapState({
editorContent: state => state.app.editorContent,
})
},
methods: {
// 超出最大内容限制
overMax(e) {
uni.showToast({
icon: "none",
title: "输入内容已超过最大字数限制"
})
},
// 初始化编辑器
initEditor(editor) {
this.editorIns = editor
this.editorIns.setContents({
html: this.editorContent || ""
})
},
// 上传图片
upinImage(tempFiles, editorCtx) {
let imageList = []
// #ifdef MP-WEIXIN
imageList = tempFiles.map(item => item.tempFilePath)
// #endif
// #ifndef MP-WEIXIN
imageList = tempFiles.map(item => item.path)
// #endif
uni.showLoading({
title: '上传中请稍后',
mask: true
})
this.$util.uploadFileMultiple(imageList, [], 2).then(result => {
result.forEach((item) => {
editorCtx.insertImage({
src: item,
width: '80%',
success: () => {
uni.hideLoading()
}
})
});
}).catch(error => {
console.error('上传图片 ', error)
})
},
// 完成编辑
exportHtml(e) {
let pages = getCurrentPages()
let prevPage = pages[pages.length - 2]
prevPage.$vm.editorContent = e
uni.navigateBack()
},
}
}
</script>
<style lang="scss">
page {
padding-bottom: 0;
}
.container {
height: 100vh;
display: flex;
flex-direction: column;
.container-main {
flex: 1;
overflow: hidden;
}
}
</style>

486
pagesCard/mine/index.vue Normal file
View File

@@ -0,0 +1,486 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
+----------------------------------------------------------------------
| 沃德商协会系统并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
+----------------------------------------------------------------------
| 我的名片 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->
<template>
<view class="container" :style="{'--theme-color': themeColor}">
<!-- 标题栏 -->
<title-bar title="我的名片"></title-bar>
<!-- 统计数据 -->
<view class="container-statistics" :style="{top: titleBarHeight + 'px'}">
<view class="statistics-item">
<view class="item-name">访客数据</view>
</view>
<view class="statistics-line"></view>
<view class="statistics-item">
<view class="item-value">{{cardStatistics.total_count || 0}}</view>
<view class="item-title">总访问人数</view>
</view>
<view class="statistics-line"></view>
<view class="statistics-item">
<view class="item-value">{{cardStatistics.today_count || 0}}</view>
<view class="item-title">今日访问人数</view>
</view>
<view class="statistics-bg"></view>
</view>
<!-- 内容区 -->
<view class="container-main" v-if="loadEnd">
<view class="main-list" v-if="cardList.length">
<card-item :show-data="cardList" @setShareData="setShareData" @getList="resetCardList"></card-item>
</view>
<view class="main-empty" v-else>
<image class="empty-image" src="/static/empty.png" mode="widthFix"></image>
<view class="empty-text">暂无相关内容~</view>
</view>
<view class="main-footer">
<view class="footer-box">
<view class="box-create" @click="handleAdd()">
<view class="create-icon">
<image class="icon" src="/static/card/create.png" mode="aspectFit"></image>
<view class="add">
<image src="/static/card/add.png" mode="aspectFit"></image>
</view>
</view>
<view class="create-text">新建</view>
</view>
<view class="box-manage" @click="toCardManage()">
<view class="manage-bg"></view>
<view class="manage-text">名片管理</view>
</view>
<button open-type="share" class="box-btn" @click="setShareData(defaultCard)" v-if="defaultCard && defaultCard.id">
递交名片<text>(默认名片)</text>
</button>
<view class="box-btn" @click="setShareTips()" v-else>
递交名片<text>(默认名片)</text>
</view>
</view>
<view class="safe-padding"></view>
</view>
</view>
<!-- 底部导航 -->
<tab-bar></tab-bar>
</view>
</template>
<script>
import { mapState } from "vuex"
import cardItem from "../component/card/index.vue"
// #ifdef H5
import wx from 'weixin-js-sdk';
// #endif
export default {
components: {
cardItem
},
data() {
return {
// 加载完成
loadEnd: false,
// 标题栏高度
titleBarHeight: 0,
// 统计数据
cardStatistics: {},
// 名片列表
cardList: [],
// 默认名片
defaultCard: {},
// 分享数据
shareData: {},
};
},
computed: {
...mapState({
themeColor: state => state.app.themeColor,
shareImage: state => state.app.shareImage,
shareTitle: state => state.app.shareTitle,
})
},
mounted() {
// #ifdef MP-WEIXIN
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight
let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
this.titleBarHeight = statusBarHeight + (menuButtonInfo.top - statusBarHeight) * 2 + menuButtonInfo.height
// #endif
},
onLoad() {
uni.showLoading({
title: "加载中"
})
this.getCardStatistics()
this.getDefaultCard()
this.getCardList(() => {
uni.hideLoading()
this.loadEnd = true
})
// #ifdef H5
this.initConfig()
// #endif
},
onShow() {
if (this.loadEnd) {
this.getCardStatistics()
this.getDefaultCard()
this.getCardList()
}
},
onPullDownRefresh() {
this.getCardStatistics()
this.getDefaultCard()
this.getCardList(() => {
uni.stopPullDownRefresh()
})
},
onShareAppMessage(res) {
if (res.from == "button") {
return {
title: this.shareData.share_title,
path: "/pagesCard/card/details?id=" + this.shareData.id,
imageUrl: this.shareData.image,
}
} else if (res.from == "menu") {
return {
title: this.shareTitle,
imageUrl: this.shareImage,
}
}
},
onShareTimeline() {
return {
title: this.shareTitle,
imageUrl: this.shareImage,
}
},
methods: {
// #ifdef H5
// 微信公众号初始化方法
initConfig() {
this.$util.request("main.WeChatConfig", {
url: location.href.split('#')[0]
}).then(res => {
if (res.code == 1) {
wx.config({
debug: false,
appId: res.data.appId,
timestamp: Number(res.data.timestamp),
nonceStr: res.data.nonceStr,
signature: res.data.signature,
jsApiList: ["updateAppMessageShareData", "updateTimelineShareData"],
openTagList: ["updateAppMessageShareData", "updateTimelineShareData"],
})
wx.ready(() => {
wx.updateAppMessageShareData({
title: this.shareTitle,
desc: "",
link: window.location.href,
imgUrl: this.shareImage,
});
wx.updateTimelineShareData({
title: this.shareTitle,
link: window.location.href,
imgUrl: this.shareImage,
});
});
} else {
uni.hideLoading()
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
uni.hideLoading()
console.error('通过config接口注入权限验证配置 ', error)
})
},
// #endif
// 获取名片统计
getCardStatistics() {
this.$util.request("card.statistics").then(res => {
if (res.code == 1) {
this.cardStatistics = res.data
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
console.error('获取名片统计 ', error)
})
},
// 获取名片列表
getCardList(fn) {
this.$util.request("card.list").then(res => {
if (fn) fn()
if (res.code == 1) {
this.cardList = res.data
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
if (fn) fn()
console.error('获取名片列表 ', error)
})
},
// 获取默认名片
getDefaultCard() {
this.$util.request("card.getDefault").then(res => {
if (res.code == 1) {
this.defaultCard = res.data
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
console.error('获取默认名片 ', error)
})
},
// 新建名片
handleAdd() {
this.$util.toPage({
mode: 1,
path: "/pagesCard/mine/edit"
})
},
// 设置分享数据
setShareData(data) {
this.shareData = data
},
// 重新获取名片列表
resetCardList() {
this.getDefaultCard()
this.getCardList()
},
// 设置分享提示
setShareTips() {
uni.showToast({
icon: "none",
title: "请先设置默认名片后操作",
})
},
// 前往卡片管理
toCardManage() {
this.$util.toPage({
mode: 1,
path: "/pagesCard/mine/manage"
})
},
}
}
</script>
<style lang="scss">
.container {
.container-statistics {
position: sticky;
top: 0;
z-index: 99;
display: flex;
align-items: center;
background: #FFF;
.statistics-item {
width: 100%;
padding: 30rpx 20rpx 28rpx;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
.item-name {
color: #5A5B6E;
font-size: 28rpx;
font-weight: 600;
line-height: 40rpx;
}
.item-value {
color: #5A5B6E;
font-size: 32rpx;
font-weight: 600;
line-height: 44rpx;
}
.item-title {
margin-top: 8rpx;
color: #8D929C;
font-size: 24rpx;
line-height: 34rpx;
}
}
.statistics-line {
background: var(--theme-color);
opacity: 0.3;
width: 1px;
height: 72rpx;
}
.statistics-bg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: -1;
background: var(--theme-color);
opacity: 0.1;
}
}
.container-main {
padding: 32rpx 32rpx 144rpx;
.main-empty {
text-align: center;
padding: 32rpx;
margin-top: 25%;
.empty-image {
width: 260rpx;
height: 100%;
display: block;
margin: 0 auto 32rpx;
}
.empty-text {
color: #888;
font-size: 32rpx;
line-height: 1.4;
display: flex;
justify-content: center;
}
}
.main-footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 99;
padding: 12rpx 32rpx;
background: #ffffff;
border-top: 1rpx solid #F6F7FB;
.footer-box {
display: flex;
align-items: center;
.box-create {
border-radius: 16rpx;
background: #F4F4F4;
margin-right: 16rpx;
width: 88rpx;
height: 88rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
.create-icon {
position: relative;
width: 48rpx;
height: 48rpx;
display: flex;
justify-content: center;
align-items: center;
.icon {
width: 40rpx;
height: 36rpx;
}
.add {
position: absolute;
right: 2rpx;
bottom: 2rpx;
border-radius: 50%;
background: var(--theme-color);
width: 16rpx;
height: 16rpx;
line-height: 16rpx;
text-align: center;
}
}
.create-text {
color: #5A5B6E;
text-align: center;
font-size: 20rpx;
line-height: 28rpx;
}
}
.box-manage {
width: 240rpx;
padding: 22rpx 24rpx;
border-radius: 16rpx;
margin-right: 16rpx;
position: relative;
z-index: 1;
.manage-text {
color: var(--theme-color);
font-size: 32rpx;
line-height: 44rpx;
text-align: center;
}
.manage-bg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: -1;
background: var(--theme-color);
opacity: 0.1;
}
}
.box-btn {
flex: 1;
color: #ffffff;
font-size: 32rpx;
line-height: 44rpx;
padding: 22rpx 24rpx;
border-radius: 16rpx;
background: var(--theme-color);
text-align: center;
margin: 0;
border: none;
&::after {
display: none;
}
text {
font-size: 24rpx;
}
}
}
.safe-padding {
width: 100%;
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
}
}
}
}
</style>

251
pagesCard/mine/manage.vue Normal file
View File

@@ -0,0 +1,251 @@
<!-- +----------------------------------------------------------------------
| 麦沃德科技赋能开发者助力商协会发展
+----------------------------------------------------------------------
| Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
+----------------------------------------------------------------------
| 沃德商协会系统并不是自由软件不加密并不代表开源未经许可不可自由转售和商用
+----------------------------------------------------------------------
| Author: MY WORLD Team <bd@maiwd.cn> www.maiwd.cn
+----------------------------------------------------------------------
| 名片管理 开发者: 麦沃德科技-半夏
+---------------------------------------------------------------------- -->
<template>
<view class="container" :style="{'--theme-color': themeColor}">
<!-- 标题栏 -->
<title-bar title="名片管理"></title-bar>
<!-- 内容区 -->
<view class="container-main" v-if="loadEnd">
<view class="main-list" v-if="cardList.length">
<view class="list-item" v-for="item in cardList" :key="item.id" @click="changeSelectCard(item.id)">
<view class="item-radio" :class="{select: selectCard.includes(item.id)}">
<image class="icon" src="/static/card/tick.png" mode="aspectFit"></image>
</view>
<view class="item-image">
<image class="image" :src="item.image" mode="widthFix"></image>
</view>
</view>
</view>
<view class="main-empty" v-else>
<image class="empty-image" src="/static/empty.png" mode="widthFix"></image>
<view class="empty-text">暂无相关内容~</view>
</view>
<view class="main-footer">
<view class="footer-btn" @click="handleDelete()">删除名片</view>
<view class="safe-padding"></view>
</view>
</view>
</view>
</template>
<script>
import { mapState } from "vuex"
import cardItem from "../component/card/index.vue"
export default {
components: {
cardItem
},
data() {
return {
// 加载完成
loadEnd: false,
// 名片列表
cardList: [],
// 已选名片
selectCard: [],
};
},
computed: {
...mapState({
themeColor: state => state.app.themeColor,
})
},
onLoad() {
uni.showLoading({
title: "加载中"
})
this.getCardList(() => {
uni.hideLoading()
this.loadEnd = true
})
},
onPullDownRefresh() {
this.getCardList(() => {
uni.stopPullDownRefresh()
})
},
methods: {
// 获取名片列表
getCardList(fn) {
this.$util.request("card.list").then(res => {
if (fn) fn()
if (res.code == 1) {
this.cardList = res.data
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
if (fn) fn()
console.error('获取名片列表 ', error)
})
},
// 改变已选名片
changeSelectCard(id) {
if (this.selectCard.includes(id)) {
const index = this.selectCard.findIndex(item => item == id)
this.$delete(this.selectCard, index)
} else {
this.selectCard.push(id)
}
},
// 删除名片
handleDelete() {
if (!this.selectCard.length) {
uni.showToast({
icon: "none",
title: "请选择要删除的名片"
})
return
}
uni.showModal({
title: "提示",
content: "确认删除所选名片?删除后无法恢复",
confirmText: "确认删除",
cancelText: "我再想想",
confirmColor: "#FF626E",
cancelColor: "#999999",
success: (res) => {
if (res.confirm) {
uni.showLoading({
mask: true,
title: "加载中"
})
this.$util.request("card.delete", { ids: this.selectCard.join() }).then(res => {
uni.hideLoading()
if (res.code == 1) {
uni.showToast({
icon: "success",
title: "删除成功",
duration: 2000
})
this.getCardList()
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
}).catch(error => {
uni.hideLoading()
console.error('删除名片 ', error)
})
}
}
})
},
}
}
</script>
<style lang="scss">
.container {
.container-main {
padding: 32rpx 32rpx 144rpx;
.main-list {
.list-item {
margin-top: 32rpx;
display: flex;
justify-content: space-between;
align-items: center;
&:first-child {
margin-top: 0;
}
.item-radio {
width: 40rpx;
height: 40rpx;
background: #D6DBDE;
border-radius: 50%;
.icon {
display: none;
}
&.select {
background: var(--theme-color);
.icon {
display: block;
}
}
}
.item-image {
width: 624rpx;
height: 364rpx;
border-radius: 16rpx;
overflow: hidden;
.image {
width: 100%;
height: 100%;
}
}
}
}
.main-empty {
text-align: center;
padding: 32rpx;
margin-top: 25%;
.empty-image {
width: 260rpx;
height: 100%;
display: block;
margin: 0 auto 32rpx;
}
.empty-text {
color: #888;
font-size: 32rpx;
line-height: 1.4;
display: flex;
justify-content: center;
}
}
.main-footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 99;
padding: 12rpx 32rpx;
background: #ffffff;
.footer-btn {
color: #ffffff;
font-size: 32rpx;
line-height: 44rpx;
padding: 22rpx 24rpx;
border-radius: 16rpx;
background: #FF5360;
text-align: center;
}
.safe-padding {
width: 100%;
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
}
}
}
}
</style>