暂存
This commit is contained in:
119
pages/publicTransfer/index.js
Normal file
119
pages/publicTransfer/index.js
Normal file
@@ -0,0 +1,119 @@
|
||||
// pages/publicTransfer/index.js
|
||||
import { getMeterDetail, getMeterList, getTenementMeterList } from "../../service/meter";
|
||||
import { uploadFile } from "../../service/public";
|
||||
import { alertInfo, loadingFunc, getFileName } from "../../utils/index";
|
||||
import request from '../../utils/request';
|
||||
|
||||
const { OK } = request;
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
const { money, meterId, tenementId, tenementName } = options;
|
||||
console.log('money', money, 'meterId', meterId)
|
||||
this.init({ money, meterId, tenementId, tenementName });
|
||||
},
|
||||
async init({ money, meterId, tenementId, tenementName }) {
|
||||
const { code, message, data } = await getMeterDetail({ tenement: tenementId, id: meterId });
|
||||
if (code !== OK) {
|
||||
alertInfo(message);
|
||||
return;
|
||||
}
|
||||
this.setData({
|
||||
meter: data,
|
||||
money,
|
||||
tenementName,
|
||||
tenementId,
|
||||
})
|
||||
},
|
||||
onUpload() {
|
||||
const that = this;
|
||||
wx.chooseMedia({
|
||||
count: 1, // 可以选择文件的数量
|
||||
mediaType: ['image'], // 可以选择文件的类型,这里只允许上传文件
|
||||
sourceType: ['album', 'camera'],
|
||||
success: (res) => {
|
||||
(loadingFunc(async () => {
|
||||
const result = await uploadFile(res.tempFiles[0]?.tempFilePath)
|
||||
console.log('result', result)
|
||||
if (result.statusCode !== 200) {
|
||||
alertInfo("上传失败")
|
||||
return;
|
||||
}
|
||||
const data = JSON.parse(result.data)
|
||||
this.setData({
|
||||
fileList: [{ url: data.data, name: getFileName(data.data) }]
|
||||
})
|
||||
}))()
|
||||
}
|
||||
});
|
||||
},
|
||||
handleSubmit() {
|
||||
const { fileList } = this.data;
|
||||
if (!fileList.length) {
|
||||
alertInfo("请上传凭证")
|
||||
return;
|
||||
}
|
||||
},
|
||||
handleDelete() {
|
||||
this.setData({ fileList: [] })
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
Reference in New Issue
Block a user