Files
pupil/packageMy/myRelease/myRelease.vue
2023-02-28 00:02:59 +08:00

256 lines
6.7 KiB
Vue

<template>
<view>
<view>
<u-tabs :list="tabsList" :scrollable="false" lineColor="#0A994A" color="#969696"
activeStyle="color:#15CA65;font-weight: bold;" :current="tabCurrent" @change="tabChange"></u-tabs>
</view>
<view v-if="tabCurrent == 0" style="background-color: #fff;">
<view v-for="(item,index) in needsList" :key="index" class="my_line"
style="padding: 24rpx 19rpx;border-bottom: 1px solid #EEEEEE;">
<text class="needs_text">{{item.desc}}</text>
<view class="time_line">
<view class="release_time">
<text v-if="updateIndex==0||updateIndex==1">{{item.update_time}}</text>
<text v-else>{{item.update_time}}</text>
</view>
<view style="display: flex;">
<view class="btn" @click="viewIdeasOrNeeds(item)" v-if="item.status==1">
<u-icon name="eye" color="#15CA65" size="20"></u-icon>
<text class="btn_text">查看</text>
</view>
<view class="btn" @click="editIdeasAndNeeds(item)" v-if="item.status==0">
<u-icon name="edit-pen" color="#15CA65" size="20"></u-icon>
<text class="btn_text">修改</text>
</view>
<view class="btn" @click="deleteIdeasAndNeeds(item)" v-if="item.status==0">
<u-icon name="trash" color="#15CA65" size="20"></u-icon>
<text class="btn_text">删除</text>
</view>
</view>
</view>
</view>
</view>
<view v-if="tabCurrent == 1" style="background-color: #fff;">
<view v-for="(item,index) in ideasList" :key="index" class="my_line"
style="padding: 24rpx 19rpx;border-bottom: 1px solid #EEEEEE;">
<text class="needs_text">{{item.pname}}</text>
<view class="time_line">
<view class="release_time">
<text v-if="updateIndex==0||updateIndex==1">{{item.update_time}}</text>
<text v-else>{{item.update_time}}</text>
</view>
<view style="display: flex;">
<view class="btn" @click="viewIdeasOrNeeds(item)" v-if="item.status==1">
<u-icon name="eye" color="#15CA65" size="20"></u-icon>
<text class="btn_text">查看</text>
</view>
<view class="btn" @click="editIdeasAndNeeds(item)" v-if="item.status==0">
<u-icon name="edit-pen" color="#15CA65" size="20"></u-icon>
<text class="btn_text">修改</text>
</view>
<view class="btn" @click="deleteIdeasAndNeeds(item)" v-if="item.status==0">
<u-icon name="trash" color="#15CA65" size="20"></u-icon>
<text class="btn_text">删除</text>
</view>
</view>
</view>
</view>
</view>
<view style="font-size: 24rpx;color: #A3A3A3;text-align: center;padding: 26rpx 0;"
v-if="needsList.length==0&&tabCurrent == 0">
暂无更多记录</view>
<view style="font-size: 24rpx;color: #A3A3A3;text-align: center;padding: 26rpx 0;"
v-if="ideasList.length==0&&tabCurrent == 1">
暂无更多记录</view>
</view>
</template>
<script>
import {
dateFormatXwDetail
} from '../../utills/date.js'
export default {
data() {
return {
// id: '',
// showM: false,
content: '您确定删除吗?',
tabCurrent: 0,
type: 1,
tabsList: [{
name: '需求发布'
}, {
name: '创意发布'
}],
needsList: [],
ideasList: [],
updateIndex: ''
}
},
onLoad(options) {
if (options && options.index) {
options.index = options.index - 1
this.updateIndex = options.index
this.tabChange(options)
return
}
this.getIdeasAndNeeds()
},
methods: {
//获取创意发布或需求发布
getIdeasAndNeeds() {
this.$apiServe.getIdeasAndNeeds(this.type).then(res => {
let data = res.data.data
console.log('创意需求发布数据', res.data);
for (const item of data) {
item.pub_time = dateFormatXwDetail(item.pub_time)
item.update_time = dateFormatXwDetail(item.update_time)
const imagesList = item.images && item.images.length > 0 ? item.images.split(';') : []
item.images = imagesList.map(item1 => {
item1 = uni.getStorageSync('img_url') + '/' + item1
return item1
})
}
if (this.type == 1) {
this.needsList = data
} else if (this.type == 2) {
this.ideasList = data
}
}).finally(_ => {
})
},
//切换需求发布和创意发布
tabChange(data) {
this.tabCurrent = data.index
if (data.index == 0) {
this.type = 1
} else if (data.index == 1) {
this.type = 2
}
this.getIdeasAndNeeds()
},
//查看需求发布或创意发布
viewIdeasOrNeeds(item) {
const tabCurrent = this.tabCurrent
uni.removeStorage({ //删除Storage
key: 'update_item',
success: () => {
uni.setStorageSync('update_item', item);
uni.reLaunch({
url: '/pages/ideasAndNeeds/ideasAndNeeds?item=update_item' + '&index=' +
tabCurrent + '&view=' + 11
})
}
})
},
//修改我的需求
editIdeasAndNeeds(item) {
const tabCurrent = this.tabCurrent
uni.removeStorage({ //删除Storage
key: 'update_item',
success: () => {
uni.setStorageSync('update_item', item);
uni.reLaunch({
url: '/pages/ideasAndNeeds/ideasAndNeeds?item=update_item' + '&index=' +
tabCurrent
})
}
})
},
//二次确认删除我的需求或创意
deleteIdeasAndNeeds(item) {
var that = this
uni.showModal({
title: '提示',
content: '你确定要删除吗',
success: function(res) {
if (res.confirm) {
that.$apiServe.deleteIdeasAndNeeds(item.id).then(res => {
if (res.data.code == 1) {
that.$toast.warn('删除成功')
}
that.getIdeasAndNeeds()
}).finally(_ => {
})
} else if (res.cancel) {
that.$toast.warn('取消删除')
}
}
})
}
}
}
</script>
<style lang="scss">
.u-modal__content {
padding: 43rpx 104rpx !important;
text-indent: 25rpx;
}
.u-tabs {
margin-bottom: 10rpx;
.u-tabs__wrapper__nav {
background-color: #FFFFFF;
.u-tabs__wrapper__nav__item {
padding: 0 !important;
flex: 1;
}
}
}
.my_line:last-child {
border: none !important;
}
.needs_text {
font-size: 30rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #3E3E3E;
line-height: 42rpx;
-webkit-line-clamp: 2;
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.time_line {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 14rpx;
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
.release_time {
color: #969696;
}
.btn {
display: flex;
align-items: center;
justify-content: center;
margin-left: 40rpx;
.u-icon__icon {
top: 1px !important;
}
.btn_text {
color: #15CA65;
}
}
}
</style>