首页新增跳转用电查询
This commit is contained in:
		| @@ -258,6 +258,8 @@ Page({ | ||||
|     const { code, message, data } = await getTenementMeterList(id); | ||||
|     if (code !== OK) { | ||||
|       alertInfo(message) | ||||
|       this.setData({ meterList: [], meter: {} }) | ||||
|       wx.setStorageSync('meter', {}) | ||||
|       return; | ||||
|     } | ||||
|     const storageMeter = wx.getStorageSync('meter'); | ||||
| @@ -265,9 +267,14 @@ Page({ | ||||
|       meterList: data || [], | ||||
|       meter: storageMeter || (data?.[0] || {}) | ||||
|     }) | ||||
|     if (!storageMeter) { | ||||
|     // if (!storageMeter) { | ||||
|       wx.setStorageSync('meter', data?.[0]) | ||||
|     } | ||||
|     // } | ||||
|   }, | ||||
|   jumpToElectric() { | ||||
|     wx.navigateTo({ | ||||
|       url: '/pages/electricQuery/index', | ||||
|     }) | ||||
|   }, | ||||
|   async setUser() { | ||||
|     const result = await getUserInfo(); | ||||
|   | ||||
| @@ -93,7 +93,7 @@ | ||||
|         <!-- <van-icon slot="icom" name="balance-list-o" /> --> | ||||
|       </van-grid-item> | ||||
|       <van-grid-item icon="after-sale" text="缴费记录" bind:click="jumpToRecord" /> | ||||
|       <van-grid-item icon="bar-chart-o" text="用电查询" /> | ||||
|       <van-grid-item icon="bar-chart-o" text="用电查询" bind:click="jumpToElectric" /> | ||||
|       <van-grid-item icon="bill-o" text="去开票" bind:click="jumpToInvoice" /> | ||||
|     </van-grid> | ||||
|   </view> | ||||
|   | ||||
| @@ -1,4 +1,5 @@ | ||||
| import { getInvoiceInfoDetail, downloadInvoice } from "../../service/invoice"; | ||||
| import { alertInfo } from "../../utils"; | ||||
| import request from '../../utils/request' | ||||
| const { OK } = request; | ||||
| // pages/invoiceInfo/index.js | ||||
| @@ -40,8 +41,30 @@ Page({ | ||||
|         console.log('res', res.tapIndex) | ||||
|         const { code, message, data } = await downloadInvoice(that.data.id, res.tapIndex); | ||||
|         if (code !== OK) { | ||||
|  | ||||
|           alertInfo(message) | ||||
|           return; | ||||
|         } | ||||
|         const filePath = `${wx.env.USER_DATA_PATH}/发票/${that.data.id}.${res.tapIndex === 0 ? 'xml' : "pdf"}`; | ||||
|         FileSystemManager.writeFile({ | ||||
|           filePath: filePath, | ||||
|           data: res.data, | ||||
|           encoding: 'base64', // 2. base64解密写入, 后台返回的byte[]数组是经过base64编码的,其他方式写入文件打开格式不对 | ||||
|           success: function(res) { | ||||
|             wx.openDocument({ | ||||
|               filePath: filePath, | ||||
|               fileType: [res.tapIndex === 0 ? 'xml' : "pdf"], // 3. 这个必须写合法类型,不然下载不了 !!! | ||||
|               success: function (res) { | ||||
|                 console.log('打开文档成功') | ||||
|               }, | ||||
|               fail: function (e) { | ||||
|                 console.log(e.errMsg); | ||||
|               } | ||||
|             }) | ||||
|           }, | ||||
|           fail: function (e) { | ||||
|             console.log(e.errMsg); | ||||
|           } | ||||
|         }); | ||||
|       } | ||||
|     }) | ||||
|   }, | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import { getInvoiceInfo, makeInvoice } from "../../service/invoice" | ||||
| import { alertInfo, alertSuccess } from "../../utils/index"; | ||||
| import { alertInfo, alertSuccess, loadingFunc } from "../../utils/index"; | ||||
| import request from '../../utils/request' | ||||
| const { OK } = request | ||||
|  | ||||
| @@ -91,14 +91,22 @@ Page({ | ||||
|  | ||||
|   }, | ||||
|   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("开票成功,未完") | ||||
|     loadingFunc(async() => { | ||||
|       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("操作成功") | ||||
|       setTimeout(() => { | ||||
|         wx.redirectTo({ | ||||
|           url: '/pages/invoiceList/index?tab=1', | ||||
|         }) | ||||
|       }, 500) | ||||
|        | ||||
|     }) | ||||
|   }, | ||||
|   changeShow() { | ||||
|     this.setData({ show: true }) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user