myCom.vue 2.87 KB
<template>
	<view class="page">
		<view class="notHave" v-if="isShow" style="transform: translateX(-50%);
		left: 50%;
		position: fixed;
		top: 350px;">
				暂时还未发布招聘
			</view>
		<view class="item" v-else v-for="(it,index) in proList" :key="index">
			<view class="top">
				<view class="title">
					{{it.enterpriseName}}
				</view>
				<view class="time">
					<!-- 2024-02-19 16:36:53 -->
					{{it.creatorTime}}
				</view>
			</view>
			<view class="bottom">
				<button type="primary" @click="GoodsDetails(it.id)">详情</button>
				<button type="warn" @click="deletePro(it.id)">删除</button>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '@/utils/request.js'
import utils from '../../../service/utils'
	export default {
		data() {
			return {
				proList:[],
				baseUrl: 'http://deyanggaoxin.fengshiyun.com',
				isShow:false
			}
		},
		onLoad() {
			this.getSelfProCount()
		},
		methods: {
			// 获取自己发布的产品
			getSelfProCount() {
				request({
					url: this.baseUrl + '/api/SubDev/baseenterprisemanager',
					method: 'get',
					data: {}
				}).then(res => {
					if (res.code === 200) {
						console.log(res)
						this.proList = res.data.list.map(it=>{
							return {
								...it,
								creatorTime:utils.formatTime(it.creatorTime)
							}
						})
						if (this.proList.length === 0) {
							this.isShow = true
						}
					} else {
						uni.showToast({
							icon: "error",
							title: res.msg
						})
					}
				})
			},
			// 跳转到产品详情页面
			GoodsDetails(item) {
				uni.navigateTo({
					url: `/pages/my/myComdetail/myComdetail?data=${JSON.stringify(item)}`
				})
			},
			// 删除该产品
			deletePro(id){
				uni.showModal({
					title:"提示",
					content:"确定删除该产品吗?",
					success: (res) => {
						request({
							url:this.baseUrl + `/api/Extend/baseproduct/${id}`,
							method:'delete',
							data:{}
						}).then(res=>{
							console.log(res)
							if(res.code === 200){
								uni.showToast({
									icon:"success",
									title:'删除产品成功!'
								}).then(res=>{
									this.getSelfProCount()
								})
								
							}
							
						})
					}
				})
				
			}
		}
	}
</script>

<style lang="scss" scoped>
.page{
	width: 100%;
	height: 100vh;
	background-color: #f3f3f3;
	margin: 0 auto;
	border-radius: 20rpx;
	overflow-y: scroll;
}
.item{
	width: 96%;
	margin: 0 auto;
	background-color: white;
	margin-top: 20rpx;
	padding-bottom: 40rpx;
	border-radius: 20rpx;
	overflow: hidden;
	// height: 150rpx;
	.top{
		width: 96%;
		margin: 0 auto;
		display: flex;
		margin-top: 40rpx;
		.title{
			width: 50%;
			text-align: center;
			font-weight: bold;
		}
		.time{
			text-align: center;
			width: 50%;
		}
	}
	.bottom{
		display: flex;
		margin-top: 20rpx;
		button{
			width: 240rpx;
			font-size: 30rpx;
			height: 70rpx;
			line-height: 70rpx;
		}
	}
}
</style>