<template>
	<view>
		<view v-if="list.length > 0">
			<view class="display" v-for="(item,index) in list">
				<view class="store-content" @click="handleClick(item)">
					<image :src="image(item.goodsPic)" mode="" class="store-image"></image>
					<view class="text-content">
						<view class="font-thirty-two font-color2">
							{{item.goodsName}}
						</view>
						<view class="font-twenty font-color5" style="margin-top: 20rpx;">
							类别：商品信息修改
						</view>
					</view>
				</view>
				<view class="button-dis">
					<button type="default" class="btn" @click="show(item.goodsId,item.shopsId, '通过')">通过</button>
					<button type="default" class="btn color" @click="show(item.goodsId,item.shopsId, '不通过')">不通过</button>
				</view>
			</view>
		</view>
		<view v-else style="padding-top: 200rpx;">
			<u-empty text="暂无数据" mode="list"></u-empty>
		</view>
		<ming-pop ref="statement" direction="below" :is_mask="true" :width="100" height="50%" :maskFun="true">
			<pop @close="close()" @noPass='handle' ref="pop"></pop>
		</ming-pop>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import server from "@/api/index";
	import http from '@/common/http.js'
	export default {
		data() {
			return {
				id: null,
				list: [],
				userInfo: {},
				type: null,
				shopsId: null
			}
		},
		mounted() {
			this.userInfo = uni.getStorageSync('userInfo');
			this.getList();
		},
		methods: {
			showMOdel(){
				this.userInfo = uni.getStorageSync('userInfo');
				this.getList();
			},
			image(e) {
				return http.webUrl + e
			},
			getList(){
				server.getShenGoodsList({goodsStatus :'1'}).then(res =>{
					this.list = [];
					if(res){
						this.list = res
					}
				})
			},
			handleClick(item){
				uni.navigateTo({
					url: '/pages/manage/modifyInfo/addToOrder?id=' + item.goodsId
				})
			},
			handlePass(data, id){
				let _this = this;
				uni.showModal({
					title: '提示',
					content: '确定通过审核吗?',
					success: function (res) {
						if (res.confirm) {
							let params ={
								goodsId: id,
								goodsStatus: '2',
								goodsReviewer: _this.userInfo.userId,
								reviewerName: _this.userInfo.nickName,
								remark: data,
								shopsId: _this.shopsId
							}
							server.getUodateGoods(params).then(res =>{
								_this.$refs.uToast.show({
									title: '通过成功!',
									type: 'default',
								})
								_this.getList();
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			handle(data){
				if(this.type === '不通过'){
					this.handleNoPass(data)
				}else if(this.type === '通过'){
					console.log('this.id', this.id)
					this.handlePass(data, this.id)
				}
			},
			handleNoPass(data){
				let _this = this;
				let params ={
					goodsId: _this.id,
					goodsStatus: '3',
					goodsReviewer: _this.userInfo.userId,
					reviewerName: _this.userInfo.nickName,
					remark: data,
					shopsId: _this.shopsId
				}
				server.getUodateGoods(params).then(res =>{
					_this.$refs.uToast.show({
						title: '操作成功!',
						type: 'default',
					})
					_this.getList();
				})
			},
			show(id, shopsId, type) {
				this.$refs.statement.show(type);
				this.$refs.pop.show(type);
				this.id = id;
				this.type = type;
				this.shopsId = shopsId;
			},
			close() {
				this.$refs.statement.close();
				this.id = null
			}
		}
	}
</script>

<style lang="scss" scoped>
	.display {
		margin: 30rpx 30rpx 0;
		padding: 30rpx;
		background: #FFFFFF;
		opacity: 1;
		border-radius: 8rpx;

		.store-content {
			display: flex;
			align-items: center;
			padding-bottom: 30rpx;
			border-bottom: 2rpx solid #DEDEDE;

			.store-image {
				width: 220rpx;
				height: 150rpx;
			}

			.text-content {
				margin-left: 30rpx;
			}
		}

		.button-dis {
			display: flex;
			margin-top: 30rpx;

			.btn {
				width: 300rpx;
				background: #2E4F1C;
				color: #FFFFFF;
				border-radius: 48rpx;
			}

			.color {
				background: #CC1019;
			}
		}
	}
</style>
