electricity_bill_calc_wx/pages/invoicing/index.js
2024-04-26 09:45:59 +08:00

102 lines
1.9 KiB
JavaScript

import { getInvoiceInfo, makeInvoice } from "../../service/invoice"
import { alertInfo, alertSuccess } from "../../utils/index";
import request from '../../utils/request'
const { OK } = request
// pages/invoicing/index.js
Page({
/**
* 页面的初始数据
*/
data: {
money: 0,
tenement: "",
ids: [],
count: 0,
show: false,
remark: ""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const { money = 10, tenement, ids = 'q', count = 10 } = options;
this.setData({ money, tenement, ids: ids.split(","), count })
this.getDetail();
},
async getDetail() {
const { code, message, data } = await getInvoiceInfo()
if (code !== OK) {
alertInfo(message)
return;
}
this.setData({ detail: {...data, }, remark: data.remark })
},
changeRemark(e) {
this.setData({ remark: e.detail })
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
onSubmit() {
console.log('----------')
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
async onSubmit() {
const {ids = [], remark } = this.data;
const tenement = wx.getStorageSync('tenement')
const { code, message, data } = await makeInvoice({ ids, tenement: tenement.id, remark })
if (code !== OK) {
alertInfo(message)
return;
}
alertSuccess("开票成功,未完")
},
changeShow() {
this.setData({ show: true })
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})