128 lines
3.8 KiB
JavaScript
128 lines
3.8 KiB
JavaScript
|
// pages/copyright/publicPay/publicPay.js
|
|||
|
import PayApi from '../../../net/api/payApi'
|
|||
|
import {
|
|||
|
request,
|
|||
|
uploadImgUrl
|
|||
|
} from "../../../net/http";
|
|||
|
const dateTimePicker = require('../../../utils/util');
|
|||
|
const Cache = require('../../../utils/storage')
|
|||
|
Page({
|
|||
|
/**
|
|||
|
* 页面的初始数据
|
|||
|
*/
|
|||
|
data: {
|
|||
|
incomeEnterprise: {},
|
|||
|
showError: false,
|
|||
|
errorHint: '',
|
|||
|
dateTimeArray: null,
|
|||
|
dateTime: null,
|
|||
|
startYear: 2000,
|
|||
|
endYear: 2050,
|
|||
|
files: []
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面加载
|
|||
|
*/
|
|||
|
onLoad(options) {
|
|||
|
console.log(options.packageId)
|
|||
|
// 获取完整的年月日时分秒,以及默认显示的数组
|
|||
|
const obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear);
|
|||
|
this.setData({
|
|||
|
dateTimeArray: obj.dateTimeArray,
|
|||
|
dateTime: obj.dateTime,
|
|||
|
selectFile: this.selectFile.bind(this),
|
|||
|
uploadFile: this.uploadFile.bind(this),
|
|||
|
});
|
|||
|
this.getEnterpriseAccountInfo()
|
|||
|
},
|
|||
|
changeDateTime(e) {
|
|||
|
// 处理日期时间选择变化的逻辑
|
|||
|
console.log('选择的日期时间发生变化:', e.detail.value);
|
|||
|
this.setData({
|
|||
|
dateTime: e.detail.value
|
|||
|
});
|
|||
|
},
|
|||
|
changeDateTimeColumn(e) {
|
|||
|
// 处理日期时间选择器列变化的逻辑
|
|||
|
console.log('选择器的列发生变化:', e.detail.column, e.detail.value);
|
|||
|
},
|
|||
|
//获取收款方信息
|
|||
|
getEnterpriseAccountInfo() {
|
|||
|
const _self = this
|
|||
|
wx.showLoading({
|
|||
|
title: '加载中...',
|
|||
|
})
|
|||
|
PayApi.doGetEnterpriseAccountInfo()
|
|||
|
.then(res => {
|
|||
|
wx.hideLoading()
|
|||
|
console.log(res)
|
|||
|
_self.setData({
|
|||
|
incomeEnterprise: res
|
|||
|
})
|
|||
|
}, err => {
|
|||
|
wx.hideLoading()
|
|||
|
_self.setData({
|
|||
|
showError: true,
|
|||
|
errorHint: err.msg ? err.msg : '网络错误,请重试'
|
|||
|
})
|
|||
|
console.log(err)
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
previewImage(e) {
|
|||
|
wx.previewImage({
|
|||
|
current: e.currentTarget.id, // 当前显示图片的http链接
|
|||
|
urls: this.data.files // 需要预览的图片http链接列表
|
|||
|
})
|
|||
|
},
|
|||
|
selectFile(files) {
|
|||
|
console.log('files', files)
|
|||
|
// 返回false可以阻止某次文件上传
|
|||
|
},
|
|||
|
uploadFile(files) {
|
|||
|
const tempFilePaths = files.tempFilePaths;
|
|||
|
const token = Cache.get('token')
|
|||
|
const header = {}
|
|||
|
if (token) {
|
|||
|
header.Auth = `Bearer ${token}`;
|
|||
|
}
|
|||
|
|
|||
|
var that = this
|
|||
|
for (let i = 0; i < tempFilePaths.length; i++) {
|
|||
|
wx.uploadFile({
|
|||
|
url: uploadImgUrl,
|
|||
|
header: header,
|
|||
|
filePath: tempFilePaths[i],
|
|||
|
name: 'image',
|
|||
|
success(res) {
|
|||
|
console.log(res)
|
|||
|
let result = JSON.parse(res.data)
|
|||
|
that.data.files.push(result.data)
|
|||
|
// do something,例如把上传成功后的图片地址保存起来
|
|||
|
},
|
|||
|
fail(err) {
|
|||
|
console.log(err);
|
|||
|
// do something when upload failed
|
|||
|
}
|
|||
|
})
|
|||
|
}
|
|||
|
|
|||
|
// 文件上传的函数,返回一个promise
|
|||
|
return new Promise((resolve, reject) => {
|
|||
|
var result = {};
|
|||
|
result['urls'] = tempFilePaths;
|
|||
|
resolve(result);
|
|||
|
})
|
|||
|
},
|
|||
|
deleteImage: function (e) {
|
|||
|
var index = e.detail.index;
|
|||
|
this.data.files.splice(index, 1);
|
|||
|
},
|
|||
|
uploadError(e) {
|
|||
|
console.log('upload error', e.detail)
|
|||
|
},
|
|||
|
uploadSuccess(e) {
|
|||
|
console.log('upload success', e.detail)
|
|||
|
}
|
|||
|
})
|