123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- // pages/zzdy/components/index/index.js
- import {
- getInvoice
- } from "../../../../api/zzdy"
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- uuid: {
- type: String,
- value: ""
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- menus: [{
- name: "从微信上传",
- introduce: "支持以下文档格式:",
- text: "pdf、docx、xlsx、pptx",
- bg: "../../../../icon/zzdy/wxsc.png",
- path: "./pages/wxsc/wxsc"
- },
- {
- name: "从相册上传",
- introduce: "支持以下文档格式:",
- text: "jpg、png、gif",
- bg: "../../../../icon/zzdy/xcsc.png",
- path: "./pages/xcsc/xcsc"
- },
- {
- name: "从卡包上传",
- introduce: "将会从微信卡包选择",
- text: "您要打印的票据",
- bg: "../../../../icon/zzdy/kbsc.png",
- path: "kb"
- }
- ]
- },
- /**
- * 组件的方法列表
- */
- methods: {
- // 菜单点击
- menuBtn(e) {
- let that = this
- var path = e.currentTarget.dataset.item.path
- if (this.data.uuid.length > 0) {
- if (path == 'kb') {
- wx.chooseInvoice({
- success: res => {
- var fpInfo = JSON.parse(res.invoiceInfo)
- let newInfo = []
- fpInfo.map(item => {
- var obj = {
- cardId: item.card_id,
- encryptCode: item.encrypt_code
- }
- newInfo.push(obj)
- })
- that.getFpPDF(newInfo)
- }
- })
- } else {
- wx.navigateTo({
- url: path + '?uuid=' + that.data.uuid,
- })
- }
- } else {
- wx.showModal({
- title: '提示',
- content: '请扫描自助机上的二维码进入后再上传文件。',
- showCancel: false
- })
- }
- },
- // 获取pdf文件
- async getFpPDF(e) {
- wx.showLoading({
- title: '正在获取发票pdf文件....',
- })
- let that = this
- let pdfList = []
- for (let i = 0; i < e.length; i++) {
- let pdf = await that.getPdf(e[i])
- pdfList.push(pdf)
- }
- that.getFpFiles(pdfList)
- wx.hideLoading()
- },
- getPdf(e) {
- let that = this
- return new Promise((resolve, reject) => {
- getInvoice(e).then(res => {
- if (res.code == 200) {
- resolve(res.url)
- } else {
- reject()
- }
- })
- })
- },
- // 获取发票文件
- getFpFiles(e) {
- let that = this
- wx.setStorage({
- key: "FPLIST",
- data: e
- })
- wx.navigateTo({
- url: './pages/scList/scList?uuid=' + that.data.uuid,
- })
- }
- }
- })
|