228 lines
6.8 KiB
Plaintext
228 lines
6.8 KiB
Plaintext
<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 && from == 'dynamic'">
|
||
<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>
|
||
</block>
|
||
<!--来自个人中心我的发布-->
|
||
<view v-if="from == 'myDynamic'" @tap.stop="deleteDynamic">删除</view>
|
||
<block v-else>
|
||
<view @tap.stop="lose">不感兴趣</view>
|
||
<view @tap.stop="jumpPath(`/pages/users/report?id=${selectData.id}&type=dynamic`)">举报</view>
|
||
</block>
|
||
<view @tap.stop="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: Boolean,
|
||
default: false
|
||
},
|
||
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}) => {
|
||
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
|
||
let data = {
|
||
is_show: 0
|
||
}
|
||
wx.showModal({
|
||
title: '温馨提示',
|
||
content: '是否确认隐藏该动态?',
|
||
success: function (res) {
|
||
if (res.confirm) {
|
||
vm.$showLoading('')
|
||
vm.$post({url: `${service.host}/moment/${vm.selectData.id}/hidden`, data}).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
|
||
let data = {
|
||
is_hot: e
|
||
}
|
||
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}) => {
|
||
if (code == 0) {
|
||
vm.$showToast(`${e == 1 ? '设置成功' : '取消成功'}`)
|
||
vm.$emit('changeOperation', 'hot')
|
||
vm.hideModal()
|
||
}
|
||
wx.hideLoading()
|
||
}).catch(() => {
|
||
wx.hideLoading()
|
||
})
|
||
} else if (res.cancel) {
|
||
console.log('用户点击取消')
|
||
}
|
||
}
|
||
})
|
||
},
|
||
// 设置为置顶或取消置顶动态
|
||
topDynamic(e) {
|
||
let vm = this
|
||
let data = {
|
||
is_top: e
|
||
}
|
||
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}) => {
|
||
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}) => {
|
||
if (code == 0) {
|
||
vm.$emit('changeOperation', 'lose')
|
||
vm.$showToast('标记成功')
|
||
vm.hideModal()
|
||
}
|
||
wx.hideLoading()
|
||
}).catch(() => {
|
||
wx.hideLoading()
|
||
})
|
||
} else if (res.cancel) {
|
||
console.log('用户点击取消')
|
||
}
|
||
}
|
||
})
|
||
},
|
||
jumpPath(url) {
|
||
console.log(url, '*********')
|
||
wx.navigateTo({url: url})
|
||
},
|
||
hideModal() {
|
||
let vm = this
|
||
vm.$emit('hideModal')
|
||
}
|
||
},
|
||
created() {}
|
||
})
|
||
</script>
|