<template>
    <a-form-model ref="form" :model="model" :label-col="{ span: 3 }" :wrapper-col="{ span: 17 }">
        <a-form-item v-show="false"><a-input v-decorator="['id']" /></a-form-item>
        <a-form-model-item label="门头照" >
            <j-image-upload class="avatar-uploader" text="上传" v-model="model.ewm" ></j-image-upload>
          </a-form-model-item>
          <a-form-model-item label="照片" >
            <j-image-upload class="avatar-uploader" text="上传" v-model="model.imgList" :isMultiple="true"></j-image-upload>
          </a-form-model-item>
          <a-button type="primary" @click="submit">确定</a-button>
    </a-form-model>
</template>

<script>
import { editImage} from "../../../api/hotel";

export default {
    created() {
        // alert("这里获取当前缓存门店信息，照片信息");
        var _info = JSON.parse(localStorage.getItem("storeInfo"));
        console.log(_info)
        if(_info){
            this.model.id = _info.id;
            if (_info.ewmLogo){
                this.model.ewm = _info.ewmLogo
            }
            if (_info.imgs){
                this.model.imgList = _info.imgs;
            }
        }
    },
    data() {
        return {
            model: {
                id: 0,
                ewm: null,
                imgList: null
            }
        }
    },
    methods: {
        submit() {
            console.log(this.model)
            var values = {};
            values['id'] = this.model.id
            values['ewmLogo'] = this.model.ewm
            values['imgs'] = this.model.imgList;

            editImage(values).then(res=>{
                // this.$message.success('编辑成功')
                // localStorage.setItem("storeInfo", JSON.stringify(res.result))
                if (res.code == 200){
                    this.$message.success('编辑成功')
                    localStorage.setItem("storeInfo", JSON.stringify(res.result))
                }else{
                    this.$message.error(res.message)
                }
            })
        }
    },
}
</script>

<style scoped>
</style>
