ufutx_love_mp/src/components/dynamicOperation.wpy

227 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">
<!--管理员才有的操作功能 && 父组件来自首页动态列表时才有-->
<block v-if="admin == 1 && from == 'dynamic'">
<view @tap="deleteDynamic">删除</view>
<view @tap="conceal">隐藏动态</view>
<view v-if="dynamicTabsIndex == 1" @tap="hotDynamic(1)">设置为推荐动态</view>
<view v-else @tap="hotDynamic(0)">取消推荐</view>
<view v-if="selectData.is_top == 0" @tap="topDynamic(1)">设置为置顶</view>
<view v-else @tap="topDynamic(0)">取消置顶</view>
</block>
<!--来自个人中心我的发布-->
<view v-if="from == 'myDynamic'" @tap="deleteDynamic">删除</view>
<block v-else>
<view @tap="lose">不感兴趣</view>
<view @tap="jumpPath(`/pages/user/report?id=${selectData.id}&type=dynamic`)">举报</view>
</block>
<view @tap="hideModal">取消</view>
</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: {
type: String,
default: ''
},
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.$post({url: `${service.host}/moments/${vm.selectData.id}`}).then(({code, data}) => {
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
wx.showModal({
title: '温馨提示',
content: '是否确认隐藏该动态?',
success: function (res) {
if (res.confirm) {
vm.$showLoading('')
vm.$post({url: `${service.host}/rbac/hide/moment/${vm.selectData.id}`}).then(({code, data}) => {
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
wx.showModal({
title: '温馨提示',
content: `是否${e == 1 ? '设置该动态为推荐动态' : '取消该推荐动态'}`,
success: function (res) {
if (res.confirm) {
vm.$showLoading('')
vm.$post({url: `${service.host}/rbac/set/hot/moments?moment_id=${vm.selectData.id}&is_hot=${e}`}).then(({code, data}) => {
if (code == 0) {
vm.$showToast(`${e == 1 ? '设置成功' : '取消成功'}`)
if (e == 0) {
vm.$emit('changeOperation', 'hot')
}
vm.hideModal()
}
wx.hideLoading()
}).catch(() => {
wx.hideLoading()
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
// 设置为置顶或取消置顶动态
topDynamic(e) {
let vm = this
let url = ``
if (e == 0) {
url = `${service.host}/rbac/remove/top/${vm.selectData.id}/moment`
} else {
url = `${service.host}/rbac/top/${vm.selectData.id}/moment`
}
wx.showModal({
title: '温馨提示',
content: `是否${e == 1 ? '设置该动态为置顶动态' : '取消该置顶动态'}`,
success: function (res) {
if (res.confirm) {
vm.$showLoading('')
vm.$post({url: url}).then(({code, data}) => {
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}/unlike/moments/${vm.selectData.id}`}).then(({code, data}) => {
if (code == 0) {
vm.$emit('changeOperation', 'lose')
vm.$showToast('标记成功')
vm.hideModal()
}
wx.hideLoading()
}).catch(() => {
wx.hideLoading()
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
jumpPath(url) {
wx.navigateTo({url: url})
},
hideModal() {
let vm = this
vm.$emit('hideModal')
}
},
created() {
}
})
</script>