完善发票和充值

This commit is contained in:
2024-03-21 09:38:10 +08:00
parent 7648ace524
commit c102434221
19 changed files with 388 additions and 16 deletions

View File

@@ -1,3 +1,7 @@
import { deleteInvoiceInfo, getInvoiceInfoList } from "../../service/invoice";
import { alertInfo, alertSuccess, wxModal } from "../../utils/index";
import request from '../../utils/request'
const { OK } = request
// pages/invoiceList/index.js
Page({
@@ -5,7 +9,14 @@ Page({
* 页面的初始数据
*/
data: {
list: [],
show: false,
actions: [
{ name: '查看', },
{ name: '编辑', },
{ name: '删除', },
],
selectData: {}
},
/**
@@ -26,9 +37,53 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
this.init();
},
async init() {
const { data, code, message } = await getInvoiceInfoList()
this.setData({ list: data })
},
operate(e) {
const { data } = e.currentTarget.dataset;
this.setData({
show: true,
selectData: data
})
},
onClose() {
this.setData({ show: false, selectData: {} });
},
onSelect(e) {
const type = e.detail.name;
switch(type) {
case "编辑":
break;
case "查看":
wx.navigateTo({
url: '/pages/invoiceDetail/index?id=' + this.data.selectData.id,
})
break;
case "删除":
this.handleDelete();
break;
}
},
async handleDelete() {
const { id } = this.data.selectData;
await wxModal({ content: "确定要删除当前记录吗?" })
const { code, message } = await deleteInvoiceInfo(id)
if (code !== OK) {
alertInfo(message)
return;
}
alertSuccess("删除成功")
this.init();
},
handleCreate() {
wx.navigateTo({
url: '/pages/editInvoice/index?id=-1',
})
},
/**
* 生命周期函数--监听页面隐藏
*/

View File

@@ -1,4 +1,7 @@
{
"usingComponents": {},
"usingComponents": {
"van-action-sheet": "@vant/weapp/action-sheet/index",
"van-button": "@vant/weapp/button/index"
},
"navigationBarTitleText": "开票信息"
}

View File

@@ -1,2 +1,27 @@
<!--pages/invoiceList/index.wxml-->
<text>pages/invoiceList/index.wxml</text>
<view class="wrapper">
<view
wx:for="{{list}}"
wx:key="index"
class="item"
>
<view style="flex: 1"> {{ item.tenement.name }} </view>
<view class="operate">
<view class="primaryTextBtn" data-data="{{item}}" bind:tap="operate"> 操作 </view>
<!-- <view class="primaryTextBtn" style="margin-left: 24rpx;"> 编辑 </view>
<view class="dangerTextBtn" style="margin-left: 24rpx;"> 删除 </view> -->
</view>
</view>
<view style="margin-top: 10vh;">
<van-button type="info" block bind:click="handleCreate">创建一个</van-button>
</view>
</view>
<van-action-sheet
show="{{ show }}"
actions="{{ actions }}"
bind:close="onClose"
bind:select="onSelect"
cancel-text="取消"
/>

View File

@@ -1 +1,15 @@
/* pages/invoiceList/index.wxss */
/* pages/invoiceList/index.wxss */
.wrapper {
margin-left: 24rpx;
margin-right: 24rpx;
}
.item {
display: flex;
align-items: center;
margin: 10rpx 0;
}
.operate {
display: flex;
}