<template>
	<view>
		<view style="margin-top: 60rpx;">
			<u-form :model="form" ref="uForm" :rules="rules">
				<view class="store">
					<u-form-item label="店铺信息" :leftIconStyle="{color: '#2E4F1C', fontSize: '40rpx'}" label-width="180">
						<u-input input-align='right' disabled=true
							v-model="form.shopsName"></u-input>
					</u-form-item>
				</view>
				<view class="store">
					<u-form-item label="店铺电话" :leftIconStyle="{color: '#2E4F1C', fontSize: '40rpx'}" label-width="180">
						<u-input input-align='right' disabled=true
							 v-model="form.shopsTel"></u-input>
					</u-form-item>
				</view>
				<view class="store">
					<u-form-item label="店铺地址" :leftIconStyle="{color: '#2E4F1C', fontSize: '40rpx'}" label-width="180">
						<u-input input-align='right' disabled=true
							 v-model="form.shopsAddress"></u-input>
					</u-form-item>
				</view>
			</u-form>
			<view class="store">
				<view class="font-color3 font-twenty distance">
					店铺简介
				</view>
				<textarea v-model="form.shopsIntroduce" disabled=true />
			</view>
			<view class="store">
				<view class="font-color2 font-twenty distance">
					照片修改（重新上传一张新照片，否则默认之前）
				</view>
				<view style="padding-bottom:40rpx;">
					<image :src="image(form.shopsPic)" class="img"></image>
				</view>
			</view>
			<view class="store" v-if="!flag">
				<view class="font-color3 font-twenty distance">
					审核意见
				</view>
				<textarea v-model="form.remark" disabled=true />
			</view>
			<view class="btn-display" v-if="flag">
				<button type="default" class="button btn-color1" @click="show('通过')">通过</button>
				<button type="default" class="button btn-color2" @click="show('不通过')">不通过</button>
			</view>
		</view>
		<ming-pop ref="statement" direction="below" :is_mask="true" :width="100" height="42%" :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 {
		onLoad() {},
		data() {
			return {
				width: '240rpx',
				height: '135rpx',
				flag: true,
				form:{
					storeName: '店铺名称', //店铺名称
					storeTel: '15045178945', //店铺电话
					storeAddress: '长春市', //店铺地址
					action: '',
					shopsDiscount:'',
					pic:[]
				},
				remark: '', //不通过原因
				id:null,
				userInfo: {},
				type: null
			}
		},
		onLoad(e) {
			console.log(e)
			this.id = e.id;
			if(e.flag){
				this.flag = false
			}else{
				this.flag = true
			}
			this.getListFn();
			this.userInfo = uni.getStorageSync('userInfo');
		},
		methods: {
			image(e) {
				return http.webUrl + e
			},
			handlePass(data){
				let _this = this;
				uni.showModal({
					title: '提示',
					content: '确定通过审核吗?',
					success: function (res) {
						if (res.confirm) {
							let params ={
								shopsId: _this.id,
								shopsStatus: '2',
								shopsReviewer: _this.userInfo.userId,
								reviewerName: _this.userInfo.nickName,
								remark: data
							}
							server.getIndexData(params).then(res =>{
								_this.$refs.uToast.show({
									title: '通过审核成功!',
									type: 'default',
								})
								setTimeout(function()  {
									uni.navigateBack({
									    delta: 1
									});
								}, 2000);
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			handle(data){
				if(this.type === '不通过'){
					this.handleNoPass(data)
				}else if(this.type === '通过'){
					this.handlePass(data)
				}
			},
			handleNoPass(data){
				let _this = this;
				let params ={
					shopsId: this.id,
					shopsStatus: '3',
					shopsReviewer: _this.userInfo.userId,
					reviewerName: _this.userInfo.nickName,
					remark: data
				}
				server.getIndexData(params).then(res =>{
					_this.$refs.uToast.show({
						title: '操作成功!',
						type: 'default',
					})
					setTimeout(function()  {
						uni.navigateBack({
						    delta: 1
						});
					}, 2000);
				})
			},
			getListFn(){
				server.getInfonew(this.id).then(res =>{
					if(res){
						this.form = res
					}
				})
			},
			show(type) {
				this.$refs.statement.show(type);
				this.$refs.pop.show(type);
				this.type = type;
			},
			close() {
				this.$refs.statement.close();
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #F8F8F8;
	}

	.store {
		width: 690rpx;
		background: rgba(46, 79, 28, 0.13);
		border-radius: 16rpx;
		margin: 20rpx auto;
		padding: 0 35rpx;
		.img{
			width: 200rpx;
			height: 135rpx;
			margin-right: 10rpx;
		}
	}

	.distance {
		padding: 20rpx 0rpx;
	}

	.btn-display {
		display: flex;
		justify-content: space-between;
		margin-top: 60rpx;

		.button {
			width: 330rpx;
			border-radius: 48rpx;
			color: #ffffff;
		}

		.btn-color1 {
			background: #2E4F1C
		}

		.btn-color2 {
			background: #CC1019
		}
	}
</style>
