ufutx_love_mp/src/components/dynamicOperation.wpy

228 lines
6.8 KiB
Plaintext
Raw Normal View History

2024-09-10 15:16:50 +08:00
<style lang="less">
.dialog {
width: 100%;
background: white;
height: auto;
z-index: 1111;
border-radius: 30rpx 30rpx 0rpx 0rpx !important;
view {
height: 90rpx;
text-align: center;
line-height: 100rpx;
margin: 0 30rpx;
color: #333333;
}
view:last-of-type {
border-top: 1rpx solid #f5f5f5;
color: #999999;
}
}
</style>
<template>
<view class="~cu-modal ~bottom-modal" :class="{'~show': chooseShow}" @tap="hideModal">
<view class="~cu-dialog dialog">
<!--管理员才有的操作功能 && 父组件来自首页动态列表时才有-->
2024-10-29 11:07:29 +08:00
<block v-if="admin && from == 'dynamic'">
2024-09-29 09:32:27 +08:00
<view @tap.stop="deleteDynamic">删除</view>
<view @tap.stop="conceal">隐藏动态</view>
<view v-if="selectData.is_hot == 0" @tap.stop="hotDynamic(1)">设置为推荐动态</view>
<view v-else @tap.stop="hotDynamic(0)">取消推荐</view>
<view v-if="selectData.is_top == 0" @tap.stop="topDynamic(1)">设置为置顶</view>
<view v-else @tap.stop="topDynamic(0)">取消置顶</view>
2024-09-10 15:16:50 +08:00
</block>
<!--来自个人中心我的发布-->
2024-09-29 09:32:27 +08:00
<view v-if="from == 'myDynamic'" @tap.stop="deleteDynamic">删除</view>
2024-09-10 15:16:50 +08:00
<block v-else>
2024-09-29 09:32:27 +08:00
<view @tap.stop="lose">不感兴趣</view>
<view @tap.stop="jumpPath(`/pages/users/report?id=${selectData.id}&type=dynamic`)">举报</view>
2024-09-10 15:16:50 +08:00
</block>
2024-09-29 09:32:27 +08:00
<view @tap.stop="hideModal">取消</view>
2024-09-10 15:16:50 +08:00
</view>
</view>
</template>
<script>
import wepy from '@wepy/core'
import base from '../mixins/base'
import https from '../mixins/https'
import {service} from '../config'
wepy.component({
props: {
selectData: {
type: Object,
default: {}
},
selectIndex: {
type: Number,
default: null
},
chooseShow: {
type: Boolean,
default: false
},
admin: {
2024-10-29 11:07:29 +08:00
type: Boolean,
default: false
2024-09-10 15:16:50 +08:00
},
from: {
type: String,
default: ''
}
},
data: {
},
mixins: [https, base],
methods: {
// 删除动态
deleteDynamic() {
let vm = this
wx.showModal({
title: '温馨提示',
content: '是否确认删除该动态?',
success: function (res) {
if (res.confirm) {
vm.$showLoading('')
vm.$delete({url: `${service.host}/moment/${vm.selectData.id}/delete`}).then(({code, data}) => {
2024-09-10 15:16:50 +08:00
if (code == 0) {
vm.$showToast('动态已删除')
vm.$emit('changeOperation', 'delete')
vm.hideModal()
}
wx.hideLoading()
}).catch(() => {
wx.hideLoading()
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
// 隐藏动态
conceal() {
let vm = this
2024-09-29 09:32:27 +08:00
let data = {
is_show: 0
}
2024-09-10 15:16:50 +08:00
wx.showModal({
title: '温馨提示',
content: '是否确认隐藏该动态?',
success: function (res) {
if (res.confirm) {
vm.$showLoading('')
2024-09-29 09:32:27 +08:00
vm.$post({url: `${service.host}/moment/${vm.selectData.id}/hidden`, data}).then(({code, data}) => {
2024-09-10 15:16:50 +08:00
if (code == 0) {
vm.$showToast('动态已隐藏')
vm.$emit('changeOperation', 'conceal')
vm.hideModal()
}
wx.hideLoading()
}).catch(() => {
wx.hideLoading()
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
// 设置为热门或取消热门动态
hotDynamic(e) {
let vm = this
let data = {
is_hot: e
}
2024-09-10 15:16:50 +08:00
wx.showModal({
title: '温馨提示',
content: `是否${e == 1 ? '设置该动态为推荐动态' : '取消该推荐动态'}`,
success: function (res) {
if (res.confirm) {
vm.$showLoading('')
vm.$post({url: `${service.host}/moment/${vm.selectData.id}/hot`, data}).then(({code, data}) => {
2024-09-10 15:16:50 +08:00
if (code == 0) {
vm.$showToast(`${e == 1 ? '设置成功' : '取消成功'}`)
2024-09-29 09:32:27 +08:00
vm.$emit('changeOperation', 'hot')
2024-09-10 15:16:50 +08:00
vm.hideModal()
}
wx.hideLoading()
}).catch(() => {
wx.hideLoading()
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
// 设置为置顶或取消置顶动态
topDynamic(e) {
let vm = this
let data = {
is_top: e
2024-09-10 15:16:50 +08:00
}
wx.showModal({
title: '温馨提示',
content: `是否${e == 1 ? '设置该动态为置顶动态' : '取消该置顶动态'}`,
success: function (res) {
if (res.confirm) {
vm.$showLoading('')
vm.$post({url: `${service.host}/moment/${vm.selectData.id}/top`, data}).then(({code, data}) => {
2024-09-10 15:16:50 +08:00
if (code == 0) {
vm.$showToast(`${e == 1 ? '设置成功' : '取消成功'}`)
if (e == 0) {
vm.$emit('changeOperation', 'cancelTop')
} else {
vm.$emit('changeOperation', 'isTop')
}
vm.hideModal()
}
wx.hideLoading()
}).catch(() => {
wx.hideLoading()
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
// 不感兴趣
lose() {
let vm = this
wx.showModal({
title: '温馨提示',
content: '是否标记该动态为不感兴趣?',
success: function (res) {
if (res.confirm) {
vm.$showLoading('')
vm.$post({url: `${service.host}/moment/${vm.selectData.id}/unlike`}).then(({code, data}) => {
2024-09-10 15:16:50 +08:00
if (code == 0) {
vm.$emit('changeOperation', 'lose')
vm.$showToast('标记成功')
vm.hideModal()
}
wx.hideLoading()
}).catch(() => {
wx.hideLoading()
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
jumpPath(url) {
2024-09-29 09:32:27 +08:00
console.log(url, '*********')
2024-09-10 15:16:50 +08:00
wx.navigateTo({url: url})
},
hideModal() {
let vm = this
vm.$emit('hideModal')
}
},
2024-10-29 11:07:29 +08:00
created() {}
2024-09-10 15:16:50 +08:00
})
</script>