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.

230 lines
5.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

const {
API_BASE_URL,
IMG_BASE_URL,
entryDetail,
submitContract
} = require('../../../api/api')
Page({
data: {
contractUrl:'',
tenantSignTime:'',
contractNumber:'',
},
/** 获取电站详情 **/
entryDetail(e) {
let that = this
wx.showLoading({
title: "加载中"
})
entryDetail({
userId: wx.getStorageSync('userId'),
entryId: this.data.projectId
}).then((res) => {
wx.hideLoading()
this.setData({
detail: res,
tenant_type: res.tenant_type == '1' ? '个人' : '单位', //1.个人2单位
});
if(res.sign_status == 'g'){
this.setData({
contractUrl:res.contractUrl,
tenantSignTime:res.tenantSignTime,
contractNumber:res.contractNumber,
});
}
})
},
/** 日期选择 **/
datePicker(e){
this.setData({
tenantSignTime: e.detail.value
})
},
/** 上传pdf或图片 **/
upload(e) {
var that = this;
let name = e.currentTarget.dataset.name;
wx.chooseMessageFile({
count: 1,
type: 'all',
success(res) {
//获取文件后缀/jpg|png|jpeg|pdf|dwg
let suffix = res.tempFiles[0].path.substring(res.tempFiles[0].path.lastIndexOf('.') + 1)
if (suffix.search(/jpg|png|jpeg|pdf/) == -1) {
wx.showToast({
title: '请上传pdf或图片文件',
icon: 'none'
})
return
}
wx.showLoading({
title: '选择中',
})
// console.log("执行",res);
// return
wx.uploadFile({
url: API_BASE_URL + 'common/uploadFile_Name?fileName=' + res.tempFiles[0].name,
filePath: res.tempFiles[0].path,
name: 'file',
complete: function (ret) {
wx.hideLoading()
if (ret.statusCode == 200) {
wx.showToast({
title: '选择成功',
icon: 'none'
})
that.setData({
[`${name}`]: JSON.parse(ret.data).path
})
} else {
wx.showToast({
title: '选择失败',
icon: 'none'
})
}
}
})
}
})
},
/** 删除图片 **/
deleteImg(e) {
const name = e.currentTarget.dataset.name
this.setData({
[`${name}`]: ''
})
},
/** 打开文件 **/
openDocument(res) {
console.log('openDocument', res)
let path = res.currentTarget.dataset.path
if (path) {
//获取文件后缀
let suffix = path.substring(path.lastIndexOf('.') + 1) //获取文件后缀
if (suffix.search(/jpg|png|jpeg/) == -1) {
wx.downloadFile({
// 示例 url并非真实存在
url: IMG_BASE_URL + path,
success: function (res) {
const filePath = res.tempFilePath
wx.openDocument({
filePath: filePath,
showMenu: true,
success: function (res) {
console.log('打开文档成功')
}
})
}
})
} else {
wx.previewImage({
urls: [IMG_BASE_URL + path] // 需要预览的图片http链接列表
})
}
}
},
onLoad(options) {
this.setData({
projectId:options.projectId
});
this.entryDetail();
},
/** 取消 **/
cancel(e) {
wx.showModal({
title: '提示',
content: '确定取消?',
complete: (res) => {
if (res.cancel) {}
if (res.confirm) {
wx.navigateBack()
}
}
})
},
/** 提交 **/
submitFrom(){
wx.showLoading({
title: '提交中',
mask: true
});
let data = {
id:this.data.projectId,
contractUrl:this.data.contractUrl,
tenantSignTime:this.data.tenantSignTime,
contractNumber:this.data.contractNumber,
};
console.log("执行",data);
for(let key in data){
if(!data[key]){
wx.showToast({
title: '请完善表单信息',
icon: 'none'
})
return
}
}
submitContract(data).then((res) => {
wx.hideLoading()
if (res.code == 200) {
wx.showToast({
title: "操作成功",
icon: 'none',
success: function () {
setTimeout(function () {
//延时返回上一页面
wx.navigateBack()
}, 1800) //延迟时间
}
})
} else {
wx.showToast({
title: res.errMsg,
icon: 'none'
})
}
});
},
onReady() {
},
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})