|
|
// pages/my/approve/approve.js
|
|
|
const app = getApp();
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
proData:{
|
|
|
company_id:'',
|
|
|
name:'',
|
|
|
mobile:'',
|
|
|
images:[]
|
|
|
proData: {
|
|
|
company_id: '',
|
|
|
name: '',
|
|
|
mobile: '',
|
|
|
images: [],
|
|
|
},
|
|
|
companyName:''
|
|
|
companyName: '',
|
|
|
seach: false,
|
|
|
keyword: "",
|
|
|
companyList: []
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
onLoad: function(options) {
|
|
|
|
|
|
},
|
|
|
btn_approve() {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/my/approveInfo/approveInfo',
|
|
|
|
|
|
// btn_approve() {
|
|
|
// wx.navigateTo({
|
|
|
// url: '/pages/my/approveInfo/approveInfo',
|
|
|
// })
|
|
|
// },
|
|
|
|
|
|
// 点击查询公司名称
|
|
|
companyFun: function() {
|
|
|
this.setData({
|
|
|
seach: true
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 搜索公司名称
|
|
|
seachFun: function() {
|
|
|
let url = '/api/Company/index', b = this;
|
|
|
if(b.data.keyword == "") {
|
|
|
wx.showToast({
|
|
|
title: '请输入要搜索的公司名称',
|
|
|
icon: "none",
|
|
|
duration: 1300
|
|
|
})
|
|
|
return false;
|
|
|
}else {
|
|
|
let params = {
|
|
|
keyword: b.data.keyword
|
|
|
}
|
|
|
app.post(url, params).then((res) => {
|
|
|
// console.log(res);
|
|
|
b.setData({
|
|
|
companyList: res.data
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
// 公司名称同步到data
|
|
|
keywordFun: function(e) {
|
|
|
this.setData({
|
|
|
keyword: e.detail.value.replace(/\s+/g, ''),
|
|
|
})
|
|
|
this.seachFun();
|
|
|
},
|
|
|
|
|
|
// 选择公司名称同步到页面
|
|
|
companySelect(e) {
|
|
|
this.setData({
|
|
|
companyName: e.currentTarget.dataset.name,
|
|
|
seach: false,
|
|
|
"proData.company_id": e.currentTarget.dataset.id
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 姓名同步到data
|
|
|
work(e) {
|
|
|
this.setData({
|
|
|
"proData.name": e.detail.value.replace(/\s+/g, ''),
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 联系电话同步到data
|
|
|
getPhone(e) {
|
|
|
this.setData({
|
|
|
"proData.mobile": e.detail.value.replace(/\s+/g, ''),
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 上传图片
|
|
|
selectCameraFun: function () {
|
|
|
let that = this;
|
|
|
wx.chooseImage({
|
|
|
sizeType: ['original', 'compressed'],
|
|
|
sourceType: ['album', 'camera'],
|
|
|
success(res) {
|
|
|
// tempFilePath可以作为img标签的src属性显示图片
|
|
|
// console.log(res);
|
|
|
let successUp = 0; //成功个数
|
|
|
let failUp = 0; //失败个数
|
|
|
let i = 0; //第几个
|
|
|
let tempFilePaths = res.tempFilePaths //总文件
|
|
|
let length = res.tempFilePaths.length //总共个数
|
|
|
wx.showNavigationBarLoading()
|
|
|
wx.showLoading({
|
|
|
title: '上传中',
|
|
|
})
|
|
|
|
|
|
that.uploadAllfile(tempFilePaths, successUp, failUp, i, length);
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
console.log(res);
|
|
|
},
|
|
|
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 上传图片至后台
|
|
|
uploadAllfile(filePaths, successUp, failUp, i, length) {
|
|
|
let that = this;
|
|
|
// console.log(filePaths)
|
|
|
// console.log(successUp)
|
|
|
// console.log(failUp)
|
|
|
// console.log(i)
|
|
|
// console.log(length)
|
|
|
let url = 'http://lqz.w.brotop.cn/api/common/upload';
|
|
|
let headers = {
|
|
|
"token": wx.getStorageSync("token"),
|
|
|
'content-type': 'multipart/form-data'
|
|
|
}
|
|
|
wx.uploadFile({
|
|
|
url: url, //仅为示例,非真实的接口地址
|
|
|
header: headers,
|
|
|
filePath: filePaths[i],
|
|
|
name: 'file',
|
|
|
formData: {
|
|
|
act: "Index_upload",
|
|
|
file: '',
|
|
|
filetype: 'image'
|
|
|
},
|
|
|
success: function (res) {
|
|
|
// console.log(res)
|
|
|
wx.hideNavigationBarLoading()
|
|
|
wx.hideLoading()
|
|
|
if (res.statusCode == 200) {
|
|
|
// console.log(res)
|
|
|
let dat = JSON.parse(res.data);
|
|
|
// console.log(dat);
|
|
|
that.setData({
|
|
|
"proData.images": that.data.proData.images.concat(dat.data.url)
|
|
|
})
|
|
|
// console.log(that.data.proData.images);
|
|
|
|
|
|
} else {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: res.msg,
|
|
|
showCancel: false
|
|
|
})
|
|
|
}
|
|
|
//do something 返回图片地址
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
wx.hideNavigationBarLoading()
|
|
|
wx.hideLoading()
|
|
|
|
|
|
// console.log(res);
|
|
|
},
|
|
|
complete() {
|
|
|
i++;
|
|
|
let img = that.data.img
|
|
|
if (i == length) {
|
|
|
// console.log('总共' + successUp + '张上传成功,' + failUp + '张上传失败!');
|
|
|
}
|
|
|
else { //递归调用uploadDIY函数
|
|
|
that.uploadAllfile(filePaths, successUp, failUp, i, length);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 删除图片重新上传
|
|
|
delFun: function (e) {
|
|
|
let that = this;
|
|
|
let imgUrlList = that.data.proData.images;
|
|
|
imgUrlList.splice(e.currentTarget.dataset.i, 1);
|
|
|
that.setData({
|
|
|
"proData.images": imgUrlList
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 上传认证
|
|
|
subFun() {
|
|
|
let b = this;
|
|
|
let url = "/api/user/setCertificationInfo";
|
|
|
// console.log(b.data.proData.images.length)
|
|
|
if(b.data.companyName == "" || b.data.proData.name == "" || b.data.proData.mobile == "" || b.data.proData.images.length == 0) {
|
|
|
wx.showToast({
|
|
|
title: '请输入必填项',
|
|
|
icon: "none",
|
|
|
duration: 1300
|
|
|
})
|
|
|
return false;
|
|
|
}else {
|
|
|
b.setData({
|
|
|
"proData.header": true
|
|
|
})
|
|
|
app.post(url, b.data.proData).then((res) => {
|
|
|
// console.log(res);
|
|
|
wx.redirectTo({
|
|
|
url: '../approveInfo/approveInfo',
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
onReady: function () {
|
|
|
onReady: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
onShow: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function () {
|
|
|
onHide: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload: function () {
|
|
|
onUnload: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh: function () {
|
|
|
onPullDownRefresh: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function () {
|
|
|
onReachBottom: function() {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage: function () {
|
|
|
onShareAppMessage: function() {
|
|
|
|
|
|
}
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|