收藏牌位1.0
This commit is contained in:
parent
f478fc00a7
commit
ad30e079bc
|
|
@ -25,3 +25,32 @@ export function searchDeceased(params) {
|
||||||
params
|
params
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 收藏牌位 (使用 x-www-form-urlencoded 格式)
|
||||||
|
export function collectMemorial(data) {
|
||||||
|
// 将数据转换为 x-www-form-urlencoded 格式
|
||||||
|
|
||||||
|
|
||||||
|
return request({
|
||||||
|
url: '/app/collect',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
header: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// // 收藏牌位 (使用 form-data 格式,可选)
|
||||||
|
// export function collectMemorialFormData(data) {
|
||||||
|
// return request({
|
||||||
|
// url: '/app/collect',
|
||||||
|
// method: 'post',
|
||||||
|
// data,
|
||||||
|
// header: {
|
||||||
|
|
||||||
|
|
||||||
|
// 'Content-Type': 'multipart/form-data'
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
|
@ -21,7 +21,12 @@
|
||||||
<!-- 顶部信息 -->
|
<!-- 顶部信息 -->
|
||||||
<view class="memorial-header">
|
<view class="memorial-header">
|
||||||
<view class="location">{{ memorialDetail ? memorialDetail.name : '加载中...' }}</view>
|
<view class="location">{{ memorialDetail ? memorialDetail.name : '加载中...' }}</view>
|
||||||
<view class="collection-btn">收藏牌位</view>
|
<view
|
||||||
|
:class="['collection-btn', { 'collected': isCollected }]"
|
||||||
|
@click="handleCollect"
|
||||||
|
>
|
||||||
|
{{ isCollected ? '已收藏' : '收藏牌位' }}
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 刻铭标题 -->
|
<!-- 刻铭标题 -->
|
||||||
|
|
@ -131,7 +136,7 @@
|
||||||
<script>
|
<script>
|
||||||
import {CommonEnum} from '@/enum/common.js'
|
import {CommonEnum} from '@/enum/common.js'
|
||||||
import { getDeceasedList, getMemorialDetail } from '@/api/memorial/index.js'
|
import { getDeceasedList, getMemorialDetail } from '@/api/memorial/index.js'
|
||||||
import { getEnshrinedList } from '@/api/memorial/memorial.js'
|
import { getEnshrinedList, collectMemorial } from '@/api/memorial/memorial.js'
|
||||||
import SearchBox from "../../components/search-box/search-box.vue"
|
import SearchBox from "../../components/search-box/search-box.vue"
|
||||||
import StatusDisplay from "../../components/status-display/status-display.vue"
|
import StatusDisplay from "../../components/status-display/status-display.vue"
|
||||||
import EnshrinedList from "./compositons/enshrinedList.vue"
|
import EnshrinedList from "./compositons/enshrinedList.vue"
|
||||||
|
|
@ -167,7 +172,9 @@ export default {
|
||||||
// 滚动相关
|
// 滚动相关
|
||||||
scrollTop: 0,
|
scrollTop: 0,
|
||||||
// 供奉弹窗显示状态
|
// 供奉弹窗显示状态
|
||||||
showOfferingModal: false
|
showOfferingModal: false,
|
||||||
|
// 收藏状态
|
||||||
|
isCollected: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
|
@ -242,9 +249,9 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果有搜索关键词,添加到参数中
|
// 如果有搜索关键词,添加到参数中
|
||||||
if (this.searchName) {
|
// if (this.searchName) {
|
||||||
params.keyword = this.searchName
|
// params.keyword = this.searchName
|
||||||
}
|
// }
|
||||||
|
|
||||||
const response = await getDeceasedList(params)//api
|
const response = await getDeceasedList(params)//api
|
||||||
|
|
||||||
|
|
@ -267,6 +274,56 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 处理收藏
|
||||||
|
async handleCollect() {
|
||||||
|
if (!this.selectedUnitId) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '无法获取牌位信息',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果已经收藏,提示用户
|
||||||
|
if (this.isCollected) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '已经收藏过了',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '收藏中...'
|
||||||
|
})
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
messageId: this.selectedUnitId.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await collectMemorial(data)
|
||||||
|
|
||||||
|
if (response.code === 200) {
|
||||||
|
this.isCollected = true
|
||||||
|
uni.showToast({
|
||||||
|
title: '收藏成功',
|
||||||
|
icon: 'success'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
throw new Error(response.msg || '收藏失败')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('收藏失败:', error)
|
||||||
|
uni.showToast({
|
||||||
|
title: error.message || '收藏失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 处理搜索
|
// 处理搜索
|
||||||
async handleSearch(value) {
|
async handleSearch(value) {
|
||||||
console.log('搜索内容:', value)
|
console.log('搜索内容:', value)
|
||||||
|
|
@ -411,6 +468,33 @@ export default {
|
||||||
height: 56rpx;
|
height: 56rpx;
|
||||||
background: #A24242;
|
background: #A24242;
|
||||||
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
background: #8B3A3A;
|
||||||
|
transform: scale(0.95);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #B85A5A;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 已收藏状态样式
|
||||||
|
&.collected {
|
||||||
|
background: #4CAF50;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: #45A049;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
background: #3D8B40;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.title {
|
.title {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user