<template>
	<view class="code main-bg">
		<view class="header">
			<view class="name font-color3 font-thirty-two">{{list.name ? list.name : ''}}</view>
			<image class="img" v-if="flag" :src="list.url"></image>
			<image class="img" v-else :src="image(list.url)"></image>
		</view>
		<view class="footer">
			<view class="footer-btn">
				<view class="btn1 font-color2 font-thirty" @click="gotoShop">优待证结算</view>
				<view class="btn1 font-color2 font-thirty" @click="show">唯一识别码结算</view>
			</view>
			<view class="btn2 font-color2 font-thirty" @click="goto">查看优惠记录</view>
		</view>
		<ming-pop ref="statement" direction="below" :is_mask="true" :width="100" height="42%" :maskFun="true">
			<money @close="close()" @add="submit"></money>
		</ming-pop>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import money from '@/components/pop/money.vue'
	import server from "@/api/index";
	import http from '@/common/http.js'
	export default {
		components:{
			money
		},
		data() {
			return {
				list: {
					name: '店铺',
					url: '',
				},
				id: null,
				userInfo: null,
				flag: false,
			}
		},
		onLoad(e) {
			this.userInfo = uni.getStorageSync('userInfo');
			this.id = e.id;
			this.list.name = e.name;
			if(e.img){
				this.list.url = e.img
			}
		},
		methods:{
			image(e) {
				return http.webUrl + e
			},
			submit(e){
				if(e){
					server.getCode({orderPriceOld: e, shopsId: this.userInfo.nickName}).then(res =>{
							// this.$refs.uToast.show({
							// 	title: '修改成功!',
							// 	type: 'default',
							// })
						console.log(res)
						this.flag = true;
						this.list.url = res;
					})
				}
			},
			gotoShop(){
				uni.navigateTo({
					url: '/pages/merchant/home/shop'
				})
			},
			show(){
				uni.navigateTo({
					url: '/pages/soldier/user/scanning'
				})
			},
			// show() {
			// 	this.$refs.statement.show();
			// },
			// close() {
			// 	this.$refs.statement.close();
			// },
			goto(url){
				uni.navigateTo({
					url: '/pages/merchant/home/record?id=' + this.id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.code{
		width: 100%;
		height: auto;
		min-height: 100vh;
		padding: 30rpx;
		.header{
			width: 100%;
			height: 575rpx;
			background: #FFFFFF;
			border-radius: 24rpx;
			text-align: center;
			.name{
				width: 100%;
				height: 135rpx;
				line-height: 135rpx;
				text-align: center;
				letter-spacing: 2rpx;
			}
			.img{
				width: 400rpx;
				height: 400rpx;
			}
		}
		.footer{
			.btn1{
				margin-top: 30rpx;
				width: 100%;
				height: 96rpx;
				line-height: 96rpx;
				background: rgba(46, 79, 28, 0.13);
				border-radius: 16rpx;
				text-align: center;
			}
			.btn2{
				margin-top: 30rpx;
				width: 100%;
				height: 96rpx;
				line-height: 96rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				border: 2rpx solid #2E4F1C;
				text-align: center;
			}
		}
	}
</style>
