<template>
	<view class="page">
		<view class="page">
			<view class="notHave" v-if="isShow" style="transform: translateX(-50%);
			left: 50%;
			position: fixed;
			top: 350px;">
					暂时还未有信息
				</view>
			<view v-else class="item-box" v-for="(it,index) in appealList" :key="index" @click="toReponse(it.id)">
				<view class="lef">
					{{it.content}}
				</view>
				<view class="rig">
					<view class="status" v-if="it.status == null" style="color: red;">
						未处理
					</view>
					<view class="status" v-else>
						{{it.status}}
					</view>
					<view class="button">
						<button >查看/处理</button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '@/utils/request.js'
	export default {
		data() {
			return {
				TypeArray: ['行政审批', '生产运营', '金融服务', '其他'],
				TypeIndex: 0,
				// 填写诉求内容
				requires:'',
				type:"",
				lastModifyUserId:'',
				userCode:'',
				list:[{
				    name: '未处理',
				    value: 0,
				}, {
				    name: '已处理',
				    value: 1,
				}, {
				    name: '忽略',
				    value: 2,
				}, {
				    name: '无效',
				    value: 3,
				}],
				appealList:[],
				isShow:false,
				isAdmin:false,
			}
		},
		onShow() {
			this.getUser()
			let user = uni.getStorageSync('user')
			this.lastModifyUserId = user.userInfo.userId
			if(this.isAdmin){
				this.getAdminAppealList()
			}else{
				this.getAppealList()
			}
		},
		// onLoad() {
		// 	this.getUser()
		// 	let user = uni.getStorageSync('user')
		// 	this.lastModifyUserId = user.userInfo.userId
		// 	if(this.isAdmin){
		// 		this.getAdminAppealList()
		// 	}else{
		// 		this.getAppealList()
		// 	}
		// },
		methods:{
			// 获取用户信息
			getUser(){
				if (uni.getStorageSync('user')) {
					let userCode = uni.getStorageSync('user').userInfo.userId
					console.log('this.userCode',userCode)
					this.userCode = userCode
					if(this.userCode == 'admin'){
						this.isAdmin = true
					}
					// this.userInfo = this.userCode.userAccount
					// this.userInfo = '123456'
					console.log('用户已登录！')
				} else {
					uni.showToast({
						title: '请登录',
						icon: 'none'
					})
					setTimeout(() => {
						uni.reLaunch({
							url: '/pages/login/index'
						})
					})
				}
			},
			// 获取诉求列表
			getAppealList(){
				request({
					url:'/api/Extend/baseappealinformation/GetListByCurrent',
					method:'get',
					data:{
						pageSize:10000,
						// status:status
					}
				}).then(res=>{
					console.log(res)
					if(res.code === 200){
						this.appealList = res.data.list
						if(this.appealList.length == 0){
							this.isShow = true
						}else{
							this.isShow = false
						}
					}
				})
			},
			// 获取诉求列表
			getAdminAppealList(){
				request({
					url:'/api/Extend/baseappealinformation',
					method:'get',
					data:{
						pageSize:10000,
						// status:status
					}
				}).then(res=>{
					console.log(res)
					if(res.code === 200){
						this.appealList = res.data.list
						if(this.appealList.length == 0){
							this.isShow = true
						}else{
							this.isShow = false
						}
					}
				})
			},
			// 跳转到查看和修改页面
			toReponse(id){
				console.log("ssss")
				if(!this.isAdmin){
					uni.navigateTo({
						url:'/pages/Feedback/userAppeal/userAppeal?data=' + JSON.stringify(id)
					})
				}else{
					uni.navigateTo({
						url:'/pages/Feedback/reponseAppeal/reponseAppeal?data=' + JSON.stringify(id)
					})
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	@import 'Feedback.scss';
</style>
