收藏牌位1.0
This commit is contained in:
parent
f478fc00a7
commit
ad30e079bc
|
|
@ -25,3 +25,32 @@ export function searchDeceased(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="location">{{ memorialDetail ? memorialDetail.name : '加载中...' }}</view>
|
||||
<view class="collection-btn">收藏牌位</view>
|
||||
<view
|
||||
:class="['collection-btn', { 'collected': isCollected }]"
|
||||
@click="handleCollect"
|
||||
>
|
||||
{{ isCollected ? '已收藏' : '收藏牌位' }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 刻铭标题 -->
|
||||
|
|
@ -131,7 +136,7 @@
|
|||
<script>
|
||||
import {CommonEnum} from '@/enum/common.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 StatusDisplay from "../../components/status-display/status-display.vue"
|
||||
import EnshrinedList from "./compositons/enshrinedList.vue"
|
||||
|
|
@ -167,7 +172,9 @@ export default {
|
|||
// 滚动相关
|
||||
scrollTop: 0,
|
||||
// 供奉弹窗显示状态
|
||||
showOfferingModal: false
|
||||
showOfferingModal: false,
|
||||
// 收藏状态
|
||||
isCollected: false
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
|
|
@ -242,9 +249,9 @@ export default {
|
|||
}
|
||||
|
||||
// 如果有搜索关键词,添加到参数中
|
||||
if (this.searchName) {
|
||||
params.keyword = this.searchName
|
||||
}
|
||||
// if (this.searchName) {
|
||||
// params.keyword = this.searchName
|
||||
// }
|
||||
|
||||
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) {
|
||||
console.log('搜索内容:', value)
|
||||
|
|
@ -411,6 +468,33 @@ export default {
|
|||
height: 56rpx;
|
||||
background: #A24242;
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user