365 lines
13 KiB
JavaScript
365 lines
13 KiB
JavaScript
|
// pages/mine/shop/shopauthentication.js
|
||
|
const app = getApp()
|
||
|
Page({
|
||
|
/**
|
||
|
* 页面的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
shopId: '',
|
||
|
shopCertificationId: '',
|
||
|
shopLicensePhotos: [], //店铺营业执照图片
|
||
|
certificationName: '', //企业名称
|
||
|
certificationType: '', //企业类型
|
||
|
certificationNumber: '', //证书编号
|
||
|
certificationId: '', //统一信用代码
|
||
|
certificationComposition: '', //企业组成形式
|
||
|
certificationLegalPerson: '', //法定代表人
|
||
|
certificationBusiness: '', //企业营业范围
|
||
|
certificationCapital: '', //企业注册资本
|
||
|
certificationFoundTime: '', //企业注册时间
|
||
|
certificationLicenseTerm: '', //营业期限
|
||
|
certificationAddress: '', //企业地址
|
||
|
certificationAuthority: '', //登记机关
|
||
|
auditResult: '', //不通过原因
|
||
|
auditStatus: 0, //状态
|
||
|
},
|
||
|
// certificationImage: '', //照片
|
||
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
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({})
|
||
|
})
|
||
|
},
|
||
|
ViewLicImg(e) {
|
||
|
var tempList = [e.currentTarget.dataset.url]
|
||
|
wx.previewImage({
|
||
|
urls: tempList,
|
||
|
current: e.currentTarget.dataset.url
|
||
|
});
|
||
|
},
|
||
|
//选择营业执照
|
||
|
ChooseLicenseP() {
|
||
|
let _self = this
|
||
|
wx.chooseImage({
|
||
|
count: 1, //默认9
|
||
|
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
||
|
sourceType: ['album', 'camera'], //从相册选择
|
||
|
success: (res) => {
|
||
|
res.tempFilePaths.forEach(element => {
|
||
|
_self.doUploadImg(1, element)
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
//删除营业执照
|
||
|
DelLicenseP(e) {
|
||
|
let _self = this
|
||
|
wx.showModal({
|
||
|
title: '提示',
|
||
|
content: '确定要删除该图片吗?',
|
||
|
cancelText: '取消',
|
||
|
confirmText: '确定',
|
||
|
success: res => {
|
||
|
if (res.confirm) {
|
||
|
this.data.shopLicensePhotos.splice(e.currentTarget.dataset.index, 1)
|
||
|
this.setData({
|
||
|
shopLicensePhotos: this.data.shopLicensePhotos
|
||
|
})
|
||
|
let _self = this
|
||
|
_self.setData({
|
||
|
certificationName: '', //企业名称
|
||
|
certificationType: '', //企业类型
|
||
|
certificationNumber: '', //证书编号
|
||
|
certificationId: '', //统一信用代码
|
||
|
certificationComposition: '', //企业组成形式
|
||
|
certificationLegalPerson: '', //法定代表人
|
||
|
certificationBusiness: '', //企业营业范围
|
||
|
certificationCapital: '', //企业注册资本
|
||
|
certificationFoundTime: '', //企业注册时间
|
||
|
certificationLicenseTerm: '', //营业期限
|
||
|
certificationAddress: '', //企业地址
|
||
|
certificationAuthority: '', //登记机关
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
//进行图片上传 type 1 营业执照 2 logo
|
||
|
doUploadImg(type, path) {
|
||
|
wx.showLoading({
|
||
|
title: '上传中...',
|
||
|
})
|
||
|
let _self = this
|
||
|
app.http.upload(app.urls.doUploadImg, {
|
||
|
name: 'image',
|
||
|
path: path,
|
||
|
header: {
|
||
|
token: app.globalData.token
|
||
|
}
|
||
|
})
|
||
|
.then(res => {
|
||
|
let pathStr = app.urls.baseImgUrl + JSON.parse(res).data
|
||
|
let item = {
|
||
|
id: JSON.parse(res).data,
|
||
|
path: pathStr
|
||
|
}
|
||
|
//营业执照
|
||
|
let tempList = _self.data.shopLicensePhotos.concat(item)
|
||
|
_self.getAuthInfo(tempList)
|
||
|
})
|
||
|
.catch(err => {
|
||
|
wx.hideLoading({})
|
||
|
if (data.msg) {
|
||
|
app.dialog.msg(data.msg)
|
||
|
} else {
|
||
|
wx.showToast({
|
||
|
title: '网络错误',
|
||
|
icon: 'error'
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
getAuthInfo(templist) {
|
||
|
let _self = this
|
||
|
app.restAjax.get(app.restAjax.path(app.apis.getAuthenticationInfo, [app.baseUrls.tradeUrl, templist[0].id]), {}, {
|
||
|
headers: {
|
||
|
token: app.globalData.token
|
||
|
}
|
||
|
}, (code, data) => {
|
||
|
wx.hideLoading({})
|
||
|
if (code == 200) {
|
||
|
_self.setData({
|
||
|
shopLicensePhotos: templist,
|
||
|
})
|
||
|
_self.setDataToView(data)
|
||
|
}
|
||
|
}, (code, error) => {
|
||
|
wx.hideLoading({})
|
||
|
if (error.msg) {
|
||
|
app.dialog.msg(error.msg)
|
||
|
} else {
|
||
|
wx.showToast({
|
||
|
title: '网络错误',
|
||
|
icon: 'error'
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
inputWatch(e) {
|
||
|
let key = e.currentTarget.dataset.model
|
||
|
this.setData({
|
||
|
[key]: e.detail.value
|
||
|
})
|
||
|
},
|
||
|
textAreaInput(e) {
|
||
|
let key = e.currentTarget.dataset.model
|
||
|
this.setData({
|
||
|
[key]: e.detail.value
|
||
|
})
|
||
|
},
|
||
|
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,
|
||
|
auditResult: data.auditResult,
|
||
|
auditStatus: data.auditStatus
|
||
|
})
|
||
|
},
|
||
|
//进行认证
|
||
|
authShop() {
|
||
|
let _self = this
|
||
|
if (_self.checkParams()) {
|
||
|
wx.showLoading({
|
||
|
title: '认证中...',
|
||
|
})
|
||
|
app.http.get(app.urls.doUpdateAuthenticationInfo.format({
|
||
|
shopCertificationId: _self.data.shopCertificationId
|
||
|
}), {
|
||
|
header: {
|
||
|
token: app.globalData.token
|
||
|
},
|
||
|
data: {
|
||
|
certificationAddress: _self.data.certificationAddress,
|
||
|
certificationAuthority: _self.data.certificationAuthority,
|
||
|
certificationBusiness: _self.data.certificationBusiness,
|
||
|
certificationCapital: _self.data.certificationCapital,
|
||
|
certificationComposition: _self.data.certificationComposition,
|
||
|
certificationFoundTime: _self.data.certificationFoundTime,
|
||
|
certificationId: _self.data.certificationId,
|
||
|
certificationImage: _self.data.shopLicensePhotos[0].id,
|
||
|
certificationLegalPerson: _self.data.certificationLegalPerson,
|
||
|
certificationLicenseTerm: _self.data.certificationLicenseTerm,
|
||
|
certificationName: _self.data.certificationName,
|
||
|
certificationNumber: _self.data.certificationNumber,
|
||
|
certificationType: _self.data.certificationType,
|
||
|
shopId: _self.data.shopId
|
||
|
}
|
||
|
})
|
||
|
.then(res => {
|
||
|
wx.hideLoading({})
|
||
|
wx.showModal({
|
||
|
title: '提示',
|
||
|
content: '信息审核中,(1至3个工作日完成),请耐心等待.',
|
||
|
success(res) {
|
||
|
wx.navigateBack({
|
||
|
delta: 1,
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
})
|
||
|
.catch(err => {
|
||
|
wx.hideLoading({})
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
//校验参数
|
||
|
checkParams() {
|
||
|
if (this.data.shopLicensePhotos.length <= 0) {
|
||
|
wx.showToast({
|
||
|
title: '请上传营业执照相片',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return false
|
||
|
}
|
||
|
// certificationName: '', //企业名称
|
||
|
if (this.data.certificationName == '') {
|
||
|
wx.showToast({
|
||
|
title: '请输入企业名称',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return false
|
||
|
}
|
||
|
// certificationType: '', //企业类型
|
||
|
if (this.data.certificationType == '') {
|
||
|
wx.showToast({
|
||
|
title: '请输入企业类型',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return false
|
||
|
}
|
||
|
// certificationNumber: '', //证书编号
|
||
|
if (this.data.certificationNumber == '') {
|
||
|
wx.showToast({
|
||
|
title: '请输入证书编号',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return false
|
||
|
}
|
||
|
// certificationId: '', //统一信用代码
|
||
|
if (this.data.certificationId == '') {
|
||
|
wx.showToast({
|
||
|
title: '请输入统一信用代码',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return false
|
||
|
}
|
||
|
// certificationComposition: '', //企业组成形式
|
||
|
if (this.data.certificationComposition == '') {
|
||
|
wx.showToast({
|
||
|
title: '请输入企业组成形式',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return false
|
||
|
}
|
||
|
// certificationLegalPerson: '', //法定代表人
|
||
|
if (this.data.certificationLegalPerson == '') {
|
||
|
wx.showToast({
|
||
|
title: '请输入法定代表人',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return false
|
||
|
}
|
||
|
// certificationBusiness: '', //企业营业范围
|
||
|
if (this.data.certificationBusiness == '') {
|
||
|
wx.showToast({
|
||
|
title: '请输入企业营业范围',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return false
|
||
|
}
|
||
|
// certificationCapital: '', //企业注册资本
|
||
|
if (this.data.certificationCapital == '') {
|
||
|
wx.showToast({
|
||
|
title: '请输入企业注册资本',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return false
|
||
|
}
|
||
|
// certificationFoundTime: '', //企业注册时间
|
||
|
if (this.data.certificationFoundTime == '') {
|
||
|
wx.showToast({
|
||
|
title: '请输入企业注册时间',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return false
|
||
|
}
|
||
|
// certificationLicenseTerm: '', //营业期限
|
||
|
if (this.data.certificationLicenseTerm == '') {
|
||
|
wx.showToast({
|
||
|
title: '请输入营业期限',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return false
|
||
|
}
|
||
|
// certificationAddress: '', //企业地址
|
||
|
if (this.data.certificationAddress == '') {
|
||
|
wx.showToast({
|
||
|
title: '请输入企业地址',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return false
|
||
|
}
|
||
|
// certificationAuthority: '', //登记机关
|
||
|
if (this.data.certificationAuthority == '') {
|
||
|
wx.showToast({
|
||
|
title: '请输入登记机关',
|
||
|
icon: 'none'
|
||
|
})
|
||
|
return false
|
||
|
}
|
||
|
return true
|
||
|
},
|
||
|
})
|