<!-- 新增供应商和客户 -->
<template>
	<view>
		<view class="formBox">
			<uni-forms-item label="店铺地址" name="productName" labelWidth="170rpx">
				<uni-easyinput type="text" v-model="formData.address" placeholder="请输入店铺地址" trim="all" />
			</uni-forms-item>
			<uni-forms-item label="店铺备注" name="address" labelWidth="170rpx">
				<uni-easyinput type="textarea" v-model="formData.remark" />
			</uni-forms-item>
			<uni-forms-item label="打印方式" name="type" labelWidth="170rpx">
				<uni-data-select style="width: 100%" v-model="formData.printingMethod" :localdata="typeList"></uni-data-select>
			</uni-forms-item>
			<uni-forms-item label="是否需要入库确认" name="type" labelWidth="170rpx">
				<uni-data-select style="width: 100%" v-model="formData.storeFlag" :localdata="storeList"></uni-data-select>
			</uni-forms-item>
			<!-- <uni-forms-item label="微信加好友" name="address" labelWidth="220rpx">
				<uni-icons type="checkbox-filled" color="green" size="24"></uni-icons>
				<view>上传二维码图片</view>
			</uni-forms-item>
			<uni-forms-item label="微信收款码" name="address" labelWidth="220rpx">
				<uni-icons type="checkbox-filled" color="green" size="24"></uni-icons>
				<view>上传二维码图片</view>
			</uni-forms-item>
			<uni-forms-item label="银行收款码" name="address" labelWidth="220rpx">
				<uni-icons type="checkbox-filled" color="green" size="24"></uni-icons>
				<view>上传二维码图片</view>
			</uni-forms-item>
			<uni-forms-item label="支付宝收款码" name="address" labelWidth="220rpx">
				<uni-icons type="checkbox-filled" color="green" size="24"></uni-icons>
				<view>上传二维码图片</view>
			</uni-forms-item> -->
			<view class="tui-tabbar">
				<view class="tui-btn-mr" @tap.stop="submit()">提交</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				formData:{
					remark:'',
					shopIcon:'',
					address:'',
					printingMethod:"0",
					storeFlag:0
				},
				typeList: [{
						value: '0',
						text: "竖排打印"
					},
					{
						value: '1',
						text: "横排打印"
					},
					{
						value: '2',
						text: "简易打印"
					}
				],
				storeList: [{
						value: '0',
						text: "不需要"
					},
					{
						value: '1',
						text: "需要"
					}
				]
			};
		},

		onLoad(option) {
			this.getShopMsg()
		},
		methods: {
			getShopMsg(){
				this.tui.request("/app/shop/getShopInfoById", "post", {
					id: uni.getStorageSync('shopId')
				}, false, true).then((res) => {
					if (res.code == 200) {
						this.formData.remark = res.result.remark
						this.formData.address = res.result.shopAddress
						this.formData.printingMethod = res.result.printingMethod
						this.formData.storeFlag = res.result.storeFlag
					}
				})
			},
			// 触发提交表单
			submit() {
				let that = this;
				that.tui.request("/app/shop/updateShopIconAndRemark", "post", {
					id: uni.getStorageSync('shopId'),
					remark: this.formData.remark,
					shopAddress:this.formData.address,
					storeFlag:this.formData.storeFlag,
					printingMethod: this.formData.printingMethod
				}, false, false).then((res) => {
					if (res.code == 200) {
						uni.setStorageSync('storeFlag',this.formData.storeFlag)
						uni.showToast({
							title: "更新成功",
							icon: 'none'
						})
						setTimeout(res=>{
							uni.navigateBack({
								delta: 1
							})
						},1000)
						
					} else {
						uni.showToast({
							title: "更新失败",
							icon: 'none'
						})
					}
				})	
			}
		}
	}
</script>

<style lang="scss">

	.formBox {
		margin: 20rpx;
		padding: 20rpx;
		background-color: #fff;
	}

	.tui-tabbar {
		width: 100%;
		height: 98rpx;
		background: #fff;
		position: fixed;
		left: 0;
		bottom: 0;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		font-size: 26rpx;
		box-shadow: 0 0 1px rgba(0, 0, 0, .3);
		padding-bottom: env(safe-area-inset-bottom);
		z-index: 996;
		padding: 0 20rpx;

		.tui-btn-mr {
			width: 130rpx;
			height: 60rpx;
			background: #088FEB;
			color: #fff;
			border-radius: 10px;
			line-height: 60rpx;
			text-align: center;
			margin-right: 30rpx;
		}
	}
</style>