// pages/mine/shop/shopauthenticationdetail.js
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        shopId: '',
        shopCertificationId: '',
        shopLicensePhotos: [], //店铺营业执照图片
        certificationName: '', //企业名称
        certificationType: '', //企业类型
        certificationNumber: '', //证书编号
        certificationId: '', //统一信用代码
        certificationComposition: '', //企业组成形式
        certificationLegalPerson: '', //法定代表人
        certificationBusiness: '', //企业营业范围
        certificationCapital: '', //企业注册资本
        certificationFoundTime: '', //企业注册时间
        certificationLicenseTerm: '', //营业期限
        certificationAddress: '', //企业地址
        certificationAuthority: '', //登记机关
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.setData({
            shopId: options.shopId,
            shopCertificationId: options.certificationId
        })
        this.getAuthenticationInfo()
    },
    getAuthenticationInfo() {
        let _self = this
        wx.showLoading({
            title: '加载中...',
        })
        app.http.get(app.urls.getShopAuthenticationInfo.format({
                shopCertificationId: _self.data.shopCertificationId
            }), {
                header: {
                    token: app.globalData.token
                }
            })
            .then(res => {
                wx.hideLoading({})
                _self.setDataToView(res.data)
            })
            .catch(err => {
                wx.hideLoading({})
            })
    },
    setDataToView(data) {
        let _self = this
        if (data.certificationImage != '') {
            let ids = data.certificationImage
            _self.data.shopLicensePhotos.push({
                id: ids,
                path: app.baseUrls.tradeUrl + app.baseImgUrl + ids
            })
        }
        _self.setData({
            certificationName: data.certificationName, //企业名称
            certificationType: data.certificationType, //企业类型
            certificationNumber: data.certificationNumber, //证书编号
            certificationId: data.certificationId, //统一信用代码
            certificationComposition: data.certificationComposition, //企业组成形式
            certificationLegalPerson: data.certificationLegalPerson, //法定代表人
            certificationBusiness: data.certificationBusiness, //企业营业范围
            certificationCapital: data.certificationCapital, //企业注册资本
            certificationFoundTime: data.certificationFoundTime, //企业注册时间
            certificationLicenseTerm: data.certificationLicenseTerm, //营业期限
            certificationAddress: data.certificationAddress, //企业地址
            certificationAuthority: data.certificationAuthority, //登记机关
            shopLicensePhotos: _self.data.shopLicensePhotos
        })
    },
    ViewLicImg(e) {
        var tempList = [e.currentTarget.dataset.url]
        wx.previewImage({
            urls: tempList,
            current: e.currentTarget.dataset.url
        });
    }
})