市北人才赋能平台 --小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

1558 lines
44 KiB

// pages/service/settle/settle.js
import { store } from '../../../utils/store.js'
import { config } from '../../../config.js'
import { ServiceModel } from '../../../models/service.js'
let serviceModel = new ServiceModel()
Page({
/**
* 页面的初始数据
*/
data: {
info:'',
code:'',
tp:'',
index:'',
departIndex:'',
department:[],
departArray:[],
hospitalIndex:'',
hospitalArray:[],
doctorIndex:'', // 预约专家
doctorArray:[],
demand:'', // 服务需求
calendar:false,
date:'',
start:'',
end:'',
holiday:[],
files: [],
imgUrl:[],
img:[],
method:1,
educationCostProve:[], // 学费证明 / 费用证明
educationCostProveUrl:[],
educationExperienceProve:[], // 入学证明 / 参加活动证明
educationExperienceProveUrl:[],
contractProve:[], // 合同
contractProveUrl:[],
invoiceProve:[], // 发票
invoiceProveUrl:[],
businessLicense:[], // 企业执照
businessLicenseUrl:[],
postProve:[], // 到岗证明
postProveUrl:[],
salaryProve:[], // 薪酬证明
salaryProveUrl:[],
attendance:'', // 参会人数
type:'',
carNumber:'', // 车牌
phone:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options.code)
console.log(options.tp)
this.setData({
uplaodFile: this.uplaodFile.bind(this),
uplaodEducationCostProve: this.uplaodEducationCostProve.bind(this),
uplaodEducationExperienceProve: this.uplaodEducationExperienceProve.bind(this),
uplaodContractProve: this.uplaodContractProve.bind(this),
uplaodInvoiceProve: this.uplaodInvoiceProve.bind(this),
uplaodPostProve: this.uplaodPostProve.bind(this),
uplaodBusinessLicense: this.uplaodBusinessLicense.bind(this),
uplaodSalaryProve: this.uplaodSalaryProve.bind(this),
})
// console.log(new Date(2010, 0, 1).getTime())
// var date = new Date();
// console.log(nowTime)
// var year = date.getFullYear();
// var month = date.getMonth() + 1;
// var day = date.getDate();
// if(month < 10){
// month = '0'+ month.toString()
// }
// if(day < 10){
// day = '0'+ month.toString()
// }
// var start = year + '-' + month + '-' + day
// this.setData({
// start:start
// })
// console.log(start)
this.setData({
code:options.code,
tp:options.tp
})
if(this.data.tp){
this.setData({
type:this.data.tp
})
}else{
this.setData({
type:this.data.code
})
}
serviceModel.getUserInfo(res=>{
this.setData({
info:res.result,
phone:res.result.phone
})
})
serviceModel.timeRange(this.data.code,res=>{
this.setData({
start:new Date(res.result.startTime.replace(/-/g, "/")).getTime(),
end:new Date(res.result.endTime.replace(/-/g, "/")).getTime(),
holiday:res.result.holidays
})
})
if(this.data.code == 'zwfw' || this.data.code == 'whly' || this.data.code == 'tycg' || this.data.code == 'cjkf' || this.data.code == 'jgtc' || this.data.code == 'flwf'){
serviceModel.getDepartList(this.data.code,res=>{
var departArray = []
for(let i = 0;i < res.result.length; i++){
departArray.push(res.result[i]['depart_name'])
}
this.setData({
department:res.result,
departArray:departArray
})
})
}
if(this.data.code == 'ylbj'){
serviceModel.getHosptialList(res=>{
this.setData({
hospitalArray:res.result
})
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
photo:function(){
var th = this;
var img = th.data.img;
var count = img.length;
var num = 9 - count;
if(num <= 0){
wx.showToast({
title: '最多能选9张图片',
icon: 'none',
duration: 2000
})
return;
}
wx.chooseImage({
count: num,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
console.log(tempFilePaths);
img = img.concat(tempFilePaths);
th.setData({
img: img
})
}
})
},
del:function(e){
// console.log(e);
var id = e.currentTarget.dataset.id;
var th = this;
var img = th.data.img;
img.splice(id,1);
th.setData({
img:img
})
},
educationCostProve:function(){
var th = this;
var img = th.data.educationCostProve;
var count = img.length;
var num = 9 - count;
if(num <= 0){
wx.showToast({
title: '最多能选9张图片',
icon: 'none',
duration: 2000
})
return;
}
wx.chooseImage({
count: num,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
console.log(tempFilePaths);
img = img.concat(tempFilePaths);
th.setData({
educationCostProve: img
})
}
})
},
educationCostProveDel:function(e){
// console.log(e);
var id = e.currentTarget.dataset.id;
var th = this;
var img = th.data.educationCostProve;
img.splice(id,1);
th.setData({
educationCostProve:img
})
},
educationExperienceProve:function(){
var th = this;
var img = th.data.educationExperienceProve;
var count = img.length;
var num = 9 - count;
if(num <= 0){
wx.showToast({
title: '最多能选9张图片',
icon: 'none',
duration: 2000
})
return;
}
wx.chooseImage({
count: num,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
console.log(tempFilePaths);
img = img.concat(tempFilePaths);
th.setData({
educationExperienceProve: img
})
}
})
},
educationExperienceProveDel:function(e){
// console.log(e);
var id = e.currentTarget.dataset.id;
var th = this;
var img = th.data.educationExperienceProve;
img.splice(id,1);
th.setData({
educationExperienceProve:img
})
},
contractProve:function(){
var th = this;
var img = th.data.contractProve;
var count = img.length;
var num = 9 - count;
if(num <= 0){
wx.showToast({
title: '最多能选9张图片',
icon: 'none',
duration: 2000
})
return;
}
wx.chooseImage({
count: num,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
console.log(tempFilePaths);
img = img.concat(tempFilePaths);
th.setData({
contractProve: img
})
}
})
},
contractProveDel:function(e){
// console.log(e);
var id = e.currentTarget.dataset.id;
var th = this;
var img = th.data.contractProve;
img.splice(id,1);
th.setData({
contractProve:img
})
},
businessLicense:function(){
var th = this;
var img = th.data.businessLicense;
var count = img.length;
var num = 9 - count;
if(num <= 0){
wx.showToast({
title: '最多能选9张图片',
icon: 'none',
duration: 2000
})
return;
}
wx.chooseImage({
count: num,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
console.log(tempFilePaths);
img = img.concat(tempFilePaths);
th.setData({
businessLicense: img
})
}
})
},
businessLicenseDel:function(e){
// console.log(e);
var id = e.currentTarget.dataset.id;
var th = this;
var img = th.data.businessLicense;
img.splice(id,1);
th.setData({
businessLicense:img
})
},
invoiceProve:function(){
var th = this;
var img = th.data.invoiceProve;
var count = img.length;
var num = 9 - count;
if(num <= 0){
wx.showToast({
title: '最多能选9张图片',
icon: 'none',
duration: 2000
})
return;
}
wx.chooseImage({
count: num,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
console.log(tempFilePaths);
img = img.concat(tempFilePaths);
th.setData({
invoiceProve: img
})
}
})
},
invoiceProveDel:function(e){
// console.log(e);
var id = e.currentTarget.dataset.id;
var th = this;
var img = th.data.invoiceProve;
img.splice(id,1);
th.setData({
invoiceProve:img
})
},
postProve:function(){
var th = this;
var img = th.data.postProve;
var count = img.length;
var num = 9 - count;
if(num <= 0){
wx.showToast({
title: '最多能选9张图片',
icon: 'none',
duration: 2000
})
return;
}
wx.chooseImage({
count: num,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
console.log(tempFilePaths);
img = img.concat(tempFilePaths);
th.setData({
postProve: img
})
}
})
},
postProveDel:function(e){
// console.log(e);
var id = e.currentTarget.dataset.id;
var th = this;
var img = th.data.postProve;
img.splice(id,1);
th.setData({
postProve:img
})
},
salaryProve:function(){
var th = this;
var img = th.data.salaryProve;
var count = img.length;
var num = 9 - count;
if(num <= 0){
wx.showToast({
title: '最多能选9张图片',
icon: 'none',
duration: 2000
})
return;
}
wx.chooseImage({
count: num,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
console.log(tempFilePaths);
img = img.concat(tempFilePaths);
th.setData({
salaryProve: img
})
}
})
},
salaryProveDel:function(e){
// console.log(e);
var id = e.currentTarget.dataset.id;
var th = this;
var img = th.data.salaryProve;
img.splice(id,1);
th.setData({
salaryProve:img
})
},
inputDemand:function(e){
console.log(e)
this.setData({
demand:e.detail.value
})
},
bindDepartChange:function(e){ // 办理部门
console.log(e)
this.setData({
departIndex:e.detail.value
})
},
bindHospitalChange:function(e){
if(e.detail.value != this.data.hospitalIndex){
this.setData({
hospitalIndex:e.detail.value,
doctorIndex:'',
doctorArray:[]
})
this.getDoctorList()
}
},
bindDoctorChange:function(e){
this.setData({
doctorIndex:e.detail.value
})
},
calendar:function(e){
this.setData({
calendar:true
})
},
onClose:function(){
this.setData({
calendar:false
})
},
onConfirm:function(e){
this.setData({
calendar:false
})
var year = e.detail.getFullYear();
var month = e.detail.getMonth() + 1;
var day = e.detail.getDate();
var date = year + '-' + month + '-' + day
this.setData({
date:date
})
},
getDoctorList:function(){
var hospital = this.data.hospitalArray[this.data.hospitalIndex]
serviceModel.getDoctorList(hospital,res=>{
var doctorArray = []
for(var i = 0;i < res.result.length;i++){
doctorArray.push(res.result[i]['deptType'] + ' '+ res.result[i]['doctor_name'])
}
this.setData({
doctorArray:doctorArray
})
})
},
submit:function(){
// console.log(this.data.files)
// return
// var len = this.data.img.length;
// console.log(this.data.img)
// this.uploadImg(0,len)
var method = this.data.method
var type = this.data.type
if(this.data.phone == ''){
wx.showModal({
title: '提示',
content: '请填写手机号',
showCancel:false,
})
return
}
if(type == 'jylsqd'){ // 就医绿色通道
if(this.data.hospitalIndex == ''){
wx.showModal({
title: '提示',
content: '请选择医疗机构',
showCancel:false,
})
return
}
// if(this.data.doctorIndex == ''){
// wx.showModal({
// title: '提示',
// content: '请选择预约专家',
// showCancel:false,
// })
// return
// }
if(this.data.date == '' || !this.data.date){
wx.showModal({
title: '提示',
content: '请选择就诊时间',
showCancel:false,
})
return
}
if(this.data.demand == '' || !this.data.demand){
wx.showModal({
title: '提示',
content: '请填写服务需求',
showCancel:false,
})
return
}
}else if(type == 'zwfw'){ // 政务服务
if(this.data.date == '' || !this.data.date){
wx.showModal({
title: '提示',
content: '请选择办理时间',
showCancel:false,
})
return
}
if(this.data.departIndex == ''){
wx.showModal({
title: '提示',
content: '请选择办理机构',
showCancel:false,
})
return
}
if(this.data.demand == '' || !this.data.demand){
wx.showModal({
title: '提示',
content: '请填写办理事项',
showCancel:false,
})
return
}
}else if(type == 'whly'){ // 文化旅游
if(this.data.departIndex == ''){
wx.showModal({
title: '提示',
content: '请选择参观景点',
showCancel:false,
})
return
}
if(this.data.date == '' || !this.data.date){
wx.showModal({
title: '提示',
content: '请选择参观时间',
showCancel:false,
})
return
}
if(this.data.demand == '' || !this.data.demand){
wx.showModal({
title: '提示',
content: '请填写服务需求',
showCancel:false,
})
return
}
if(this.data.attendance == '' || !this.data.attendance){
wx.showModal({
title: '提示',
content: '请填写参观人数',
showCancel:false,
})
return
}
}else if(type == 'tycg'){ // 体育场馆
// if(this.data.departIndex == ''){
// wx.showModal({
// title: '提示',
// content: '请选择体育场馆',
// showCancel:false,
// })
// return
// }
// if(this.data.date == '' || !this.data.date){
// wx.showModal({
// title: '提示',
// content: '请选择使用时间',
// showCancel:false,
// })
// return
// }
}else if(type == 'zzxljy'){ // 在职学历教育
method = 2
if(this.data.educationCostProve.length <= 0){
wx.showModal({
title: '提示',
content: '请上传学费证明',
showCancel:false,
})
return
}
if(this.data.educationExperienceProve.length <= 0){
wx.showModal({
title: '提示',
content: '请上传入学证明',
showCancel:false,
})
return
}
}else if(type == 'jypxxsjl'){ // 教育培训 学术交流
method = 2
if(this.data.educationCostProve.length <= 0){
wx.showModal({
title: '提示',
content: '请上传费用证明',
showCancel:false,
})
return
}
if(this.data.educationExperienceProve.length <= 0){
wx.showModal({
title: '提示',
content: '请上传参加活动证明',
showCancel:false,
})
return
}
}
else if(type == 'cjkf'){ // 场景开放
if(this.data.departIndex == ''){
wx.showModal({
title: '提示',
content: '请选择预约场馆',
showCancel:false,
})
return
}
if(this.data.date == '' || !this.data.date){
wx.showModal({
title: '提示',
content: '请选择使用时间',
showCancel:false,
})
return
}
if(this.data.attendance == '' || !this.data.attendance){
wx.showModal({
title: '提示',
content: '请填写参会人数',
showCancel:false,
})
return
}
if(this.data.demand == '' || !this.data.demand){
wx.showModal({
title: '提示',
content: '请填写用途',
showCancel:false,
})
return
}
}else if(type == 'jgtc'){ // 机关停车
if(this.data.carNumber == '' || !this.data.carNumber){
wx.showModal({
title: '提示',
content: '请填写车牌号',
showCancel:false,
})
return
}
if(this.data.departIndex == ''){
wx.showModal({
title: '提示',
content: '请选择停车地点',
showCancel:false,
})
return
}
if(this.data.date == '' || !this.data.date){
wx.showModal({
title: '提示',
content: '请选择停车时间',
showCancel:false,
})
return
}
}else if(type == 'lpbt' || type == 'qyfwbt'){ // 猎聘补贴
method = 2
if(this.data.contractProve.length <= 0){
wx.showModal({
title: '提示',
content: '请上传合同',
showCancel:false,
})
return
}
if(this.data.invoiceProve.length <= 0){
wx.showModal({
title: '提示',
content: '请上传发票',
showCancel:false,
})
return
}
if(this.data.businessLicense.length <= 0){
wx.showModal({
title: '提示',
content: '请上传企业执照',
showCancel:false,
})
return
}
// if(this.data.postProve.length <= 0){
// wx.showModal({
// title: '提示',
// content: '请上传到岗证明',
// showCancel:false,
// })
// return
// }
if(type == 'lpbt'){
if(this.data.salaryProve.length <= 0){
wx.showModal({
title: '提示',
content: '请上传薪酬证明',
showCancel:false,
})
return
}
}
}
else{
if(type == 'zybj'){ // 中医保健
if(this.data.date == '' || !this.data.date){
wx.showModal({
title: '提示',
content: '请选择预约时间',
showCancel:false,
})
return
}
}
if(type == 'flwf'){
if(this.data.departIndex == ''){
wx.showModal({
title: '提示',
content: '请选择办理部门',
showCancel:false,
})
return
}
}
if(this.data.demand == '' || !this.data.demand){
wx.showModal({
title: '提示',
content: '请填写服务需求',
showCancel:false,
})
return
}
}
// educationCostProve:[], // 学费证明 / 费用证明
// educationExperienceProve:[], // 入学证明 / 参加活动证明
// contractProve:[], // 合同
// invoiceProve:[], // 发票
// businessLicense:[], // 企业执照
// postProve:[], // 到岗证明
// salaryProve:[], // 薪酬证明
this.setData({
method:method
})
if(method == 2){
this.uploadData()
// if(this.data.code == 'xljy'){
// if(this.data.educationCostProve.length > 0){
// this.uploadImg(this.data.educationCostProve,'educationCostProveUrl')
// }
// // if(this.data.educationExperienceProve.length > 0){
// // this.uploadImg(this.data.img,'educationExperienceProveUrl')
// // }
// }else{
// if(this.data.contractProve.length > 0){
// this.uploadImg(this.data.contractProve,'contractProveUrl')
// }
// // if(this.data.invoiceProve.length > 0){
// // this.uploadImg(this.data.img,'invoiceProveUrl')
// // }
// // if(this.data.businessLicense.length > 0){
// // this.uploadImg(this.data.img,'businessLicenseUrl')
// // }
// // if(this.data.postProve.length > 0){
// // this.uploadImg(this.data.img,'postProveUrl')
// // }
// // if(this.data.salaryProve.length > 0){
// // this.uploadImg(this.data.img,'salaryProveUrl')
// // }
// }
}else{
this.uploadData()
// if(this.data.img.length > 0){
// this.uploadImg(this.data.img,'imgUrl')
// }else{
// this.uploadData()
// }
// var params = {}
// if(this.data.demand != ''){
// params.demand = this.data.demand
// }
// if(this.data.departIndex != ''){
// params.sysOrgCode = this.data.department[this.data.departIndex]['org_code']
// }
// if(this.data.imgUrl.length > 0){
// params.picList = this.data.imgUrl.join(',')
// }
// serviceModel.serviceOrder(params,res=>{
// })
}
},
uploadData:function(){
var params = {}
params.serverCode = this.data.code
if(this.data.tp){
params.serverCodeSmall = this.data.tp
}
params.phone = this.data.phone
if(this.data.demand != ''){
params.demand = this.data.demand
}
if(this.data.carNumber != ''){
params.carNumber = this.data.carNumber
}
if(this.data.date != ''){
params.appointmentTime = this.data.date
}
if(this.data.attendance != ''){
params.attendance = this.data.attendance
}
if(this.data.departIndex != ''){
params.sysOrgCode = this.data.department[this.data.departIndex]['org_code']
}
if(this.data.hospitalIndex != ''){
params.medicalInstitutions = this.data.hospitalArray[this.data.hospitalIndex]
}
// if(this.data.doctorIndex != ''){
// params.medicalExpert = this.data.doctorArray[this.data.doctorIndex]
// }
// console.log(this.imageUrl(this.data.files))
// return
if(this.data.files.length > 0){
params.picList = this.imageUrl(this.data.files)
}
// console.log(this.data.educationCostProve)
// console.log(this.imageUrl(this.data.educationCostProve))
// console.log(this.data.educationExperienceProve)
// console.log(this.imageUrl(this.data.educationExperienceProve))
// return
if(this.data.educationCostProve.length > 0){
params.educationCostProve = this.imageUrl(this.data.educationCostProve)
}
if(this.data.educationExperienceProve.length > 0){
params.educationExperienceProve = this.imageUrl(this.data.educationExperienceProve)
}
if(this.data.contractProve.length > 0){
params.contractProve = this.imageUrl(this.data.contractProve)
}
if(this.data.invoiceProve.length > 0){
params.invoiceProve = this.imageUrl(this.data.invoiceProve)
}
if(this.data.businessLicense.length > 0){
params.businessLicense = this.imageUrl(this.data.businessLicense)
}
if(this.data.postProve.length > 0){
params.postProve = this.imageUrl(this.data.postProve)
}
if(this.data.salaryProve.length > 0){
params.salaryProve = this.imageUrl(this.data.salaryProve)
}
if(this.data.method == 1){
serviceModel.serviceOrder(params,res=>{
if(res.code == 200){
wx.showToast({
title: '提交成功',
icon: 'success',
duration: 1500,
mask:"true"
})
setTimeout(function(){
wx.redirectTo({
url: '/pages/service/service',
})
},1500)
}
})
}else{
console.log(params)
// return
serviceModel.apply(params,res=>{
if(res.code == 200){
wx.showToast({
title: '提交成功',
icon: 'success',
duration: 1500,
mask:"true"
})
setTimeout(function(){
wx.redirectTo({
url: '/pages/service/service',
})
},1500)
}
})
}
},
uploadImg:function(files,str,i = 0){
const token = store.readToken()
// return new Promise((resolve, reject) => {
// files.forEach(item => {
wx.uploadFile({
url: config.api_url + "/api/common/upload",
filePath: files[i],
header: {
'token': token,
'content-type': 'application/json',
},
name: 'files',
success: (res) => {
const data = JSON.parse(res.data)
var url = config.api_url + '/' + data.result.imgUrl;
var imgUrl = this.data[str];
imgUrl.push(url);
this.setData({
str: imgUrl
})
i = i + 1
if(i == files.length){
if(str == 'educationCostProveUrl'){
this.uploadImg(this.data.educationExperienceProve,'educationExperienceProveUrl')
}
else if(str == 'contractProveUrl'){
this.uploadImg(this.data.invoiceProve,'invoiceProveUrl')
}
else if(str == 'invoiceProveUrl'){
this.uploadImg(this.data.businessLicense,'businessLicenseUrl')
}
else if(str == 'businessLicenseUrl'){
this.uploadImg(this.data.postProve,'postProveUrl')
}
else if(str == 'postProveUrl' && this.data.tp == 'lpbt'){
this.uploadImg(this.data.salaryProve,'salaryProveUrl')
}
else{
this.uploadData()
}
}else{
this.uploadImg(files,str,i)
}
}
})
// })
// })
},
uplaodFile(files) {
console.log('upload files', files)
// 文件上传的函数,返回一个promise
const token = store.readToken()
console.log(token)
return new Promise((resolve, reject) => {
files.tempFilePaths.forEach(item => {
wx.uploadFile({
url: config.api_url + "/api/common/upload",
filePath: item,
header: {
'token': token,
'content-type': 'application/json',
},
name: 'files',
success: (res) => {
console.log(res);
const data = JSON.parse(res.data)
const image = {
url: config.api_url + '/' + data.result.imgUrl,
}
this.setData({
files: [...this.data.files, image]
})
resolve(this.data.files)
}
})
})
})
},
deleteFile(e) {
console.log(e)
let tempImages = this.data.files
const index = e.detail.index
tempImages.splice(index, 1);
this.setData({
files: tempImages
})
},
formInputChange(e){
console.log(e)
this.setData({
attendance:e.detail.value
})
},
formCarNumberChange(e){
this.setData({
carNumber:e.detail.value
})
},
formPhoneChange(e){
this.setData({
phone:e.detail.value
})
},
uplaodFile(files) {
console.log('upload files', files)
// 文件上传的函数,返回一个promise
const token = store.readToken()
console.log(token)
return new Promise((resolve, reject) => {
files.tempFilePaths.forEach(item => {
console.log('item',item)
wx.uploadFile({
url: config.api_url + "/api/common/upload",
filePath: item,
header: {
'token': token,
'content-type': 'application/json',
},
name: 'files',
success: (res) => {
console.log(res);
const data = JSON.parse(res.data)
const image = {
url: config.api_url + '/' + data.result.imgUrl,
}
this.setData({
files: [...this.data.files, image]
})
resolve(this.data.files)
}
})
})
})
},
deleteFile(e) {
console.log(e)
let tempImages = this.data.files
const index = e.detail.index
tempImages.splice(index, 1);
this.setData({
files: tempImages
})
},
uplaodSalaryProve(files) {
console.log('upload files', files)
// 文件上传的函数,返回一个promise
const token = store.readToken()
console.log(token)
return new Promise((resolve, reject) => {
files.tempFilePaths.forEach(item => {
console.log('item',item)
wx.uploadFile({
url: config.api_url + "/api/common/upload",
filePath: item,
header: {
'token': token,
'content-type': 'application/json',
},
name: 'files',
success: (res) => {
console.log(res);
const data = JSON.parse(res.data)
const image = {
url: config.api_url + '/' + data.result.imgUrl,
}
this.setData({
salaryProve: [...this.data.salaryProve, image]
})
resolve(this.data.salaryProve)
}
})
})
})
},
deleteSalaryProve(e) {
console.log(e)
let tempImages = this.data.salaryProve
const index = e.detail.index
tempImages.splice(index, 1);
this.setData({
salaryProve: tempImages
})
},
uplaodEducationCostProve(files) {
console.log('upload files', files)
// 文件上传的函数,返回一个promise
const token = store.readToken()
console.log(token)
return new Promise((resolve, reject) => {
files.tempFilePaths.forEach(item => {
console.log('item',item)
wx.uploadFile({
url: config.api_url + "/api/common/upload",
filePath: item,
header: {
'token': token,
'content-type': 'application/json',
},
name: 'files',
success: (res) => {
console.log(res);
const data = JSON.parse(res.data)
const image = {
url: config.api_url + '/' + data.result.imgUrl,
}
this.setData({
educationCostProve: [...this.data.educationCostProve, image]
})
resolve(this.data.educationCostProve)
}
})
})
})
},
deleteEducationCostProve(e) {
console.log(e)
let tempImages = this.data.educationCostProve
const index = e.detail.index
tempImages.splice(index, 1);
this.setData({
educationCostProve: tempImages
})
},
uplaodEducationExperienceProve(files) {
console.log('upload files', files)
// 文件上传的函数,返回一个promise
const token = store.readToken()
console.log(token)
return new Promise((resolve, reject) => {
files.tempFilePaths.forEach(item => {
console.log('item',item)
wx.uploadFile({
url: config.api_url + "/api/common/upload",
filePath: item,
header: {
'token': token,
'content-type': 'application/json',
},
name: 'files',
success: (res) => {
console.log(res);
const data = JSON.parse(res.data)
const image = {
url: config.api_url + '/' + data.result.imgUrl,
}
this.setData({
educationExperienceProve: [...this.data.educationExperienceProve, image]
})
resolve(this.data.educationExperienceProve)
}
})
})
})
},
deleteEducationExperienceProve(e) {
console.log(e)
let tempImages = this.data.educationExperienceProve
const index = e.detail.index
tempImages.splice(index, 1);
this.setData({
educationExperienceProve: tempImages
})
},
uplaodContractProve(files) {
console.log('upload files', files)
// 文件上传的函数,返回一个promise
const token = store.readToken()
console.log(token)
return new Promise((resolve, reject) => {
files.tempFilePaths.forEach(item => {
console.log('item',item)
wx.uploadFile({
url: config.api_url + "/api/common/upload",
filePath: item,
header: {
'token': token,
'content-type': 'application/json',
},
name: 'files',
success: (res) => {
console.log(res);
const data = JSON.parse(res.data)
const image = {
url: config.api_url + '/' + data.result.imgUrl,
}
this.setData({
contractProve: [...this.data.contractProve, image]
})
resolve(this.data.contractProve)
}
})
})
})
},
deleteContractProve(e) {
console.log(e)
let tempImages = this.data.contractProve
const index = e.detail.index
tempImages.splice(index, 1);
this.setData({
contractProve: tempImages
})
},
uplaodInvoiceProve(files) {
console.log('upload files', files)
// 文件上传的函数,返回一个promise
const token = store.readToken()
console.log(token)
return new Promise((resolve, reject) => {
files.tempFilePaths.forEach(item => {
console.log('item',item)
wx.uploadFile({
url: config.api_url + "/api/common/upload",
filePath: item,
header: {
'token': token,
'content-type': 'application/json',
},
name: 'files',
success: (res) => {
console.log(res);
const data = JSON.parse(res.data)
const image = {
url: config.api_url + '/' + data.result.imgUrl,
}
this.setData({
invoiceProve: [...this.data.invoiceProve, image]
})
resolve(this.data.invoiceProve)
}
})
})
})
},
deleteInvoiceProve(e) {
console.log(e)
let tempImages = this.data.invoiceProve
const index = e.detail.index
tempImages.splice(index, 1);
this.setData({
invoiceProve: tempImages
})
},
uplaodPostProve(files) {
console.log('upload files', files)
// 文件上传的函数,返回一个promise
const token = store.readToken()
console.log(token)
return new Promise((resolve, reject) => {
files.tempFilePaths.forEach(item => {
console.log('item',item)
wx.uploadFile({
url: config.api_url + "/api/common/upload",
filePath: item,
header: {
'token': token,
'content-type': 'application/json',
},
name: 'files',
success: (res) => {
console.log(res);
const data = JSON.parse(res.data)
const image = {
url: config.api_url + '/' + data.result.imgUrl,
}
this.setData({
postProve: [...this.data.postProve, image]
})
resolve(this.data.postProve)
}
})
})
})
},
deletePostProve(e) {
console.log(e)
let tempImages = this.data.postProve
const index = e.detail.index
tempImages.splice(index, 1);
this.setData({
postProve: tempImages
})
},
uplaodBusinessLicense(files) {
console.log('upload files', files)
// 文件上传的函数,返回一个promise
const token = store.readToken()
console.log(token)
return new Promise((resolve, reject) => {
files.tempFilePaths.forEach(item => {
console.log('item',item)
wx.uploadFile({
url: config.api_url + "/api/common/upload",
filePath: item,
header: {
'token': token,
'content-type': 'application/json',
},
name: 'files',
success: (res) => {
console.log(res);
const data = JSON.parse(res.data)
const image = {
url: config.api_url + '/' + data.result.imgUrl,
}
this.setData({
businessLicense: [...this.data.businessLicense, image]
})
resolve(this.data.businessLicense)
}
})
})
})
},
deleteBusinessLicense(e) {
console.log(e)
let tempImages = this.data.businessLicense
const index = e.detail.index
tempImages.splice(index, 1);
this.setData({
businessLicense: tempImages
})
},
imageUrl:function(files){
var filesArr = []
files.forEach(item => {
filesArr.push(item.url)
})
return filesArr.join('')
}
})