|
| 1 | +<template> |
| 2 | + <view> |
| 3 | + <u-cell title="读取微信开票信息" isLink @click="chooseInvoiceTitle"></u-cell> |
| 4 | + <view class="form-box"> |
| 5 | + <u-form ref="uForm" label-width="130rpx" :model="form"> |
| 6 | + <u-form-item v-if="merchantId == 951" label="手机号码" prop="mobile" required> |
| 7 | + <u-input v-model="form.mobile" type="number" clearable placeholder="注册api工厂的手机号码"></u-input> |
| 8 | + </u-form-item> |
| 9 | + <u-form-item label="发票抬头" prop="comName" required> |
| 10 | + <u-input v-model="form.comName" type="text" clearable placeholder="公司名称"></u-input> |
| 11 | + </u-form-item> |
| 12 | + <u-form-item label="税号" prop="tfn" required> |
| 13 | + <u-input v-model="form.tfn" type="text" clearable placeholder="填写税号"></u-input> |
| 14 | + </u-form-item> |
| 15 | + <u-form-item label="发票内容" prop="consumption" required> |
| 16 | + <u-input v-model="form.consumption" type="text" clearable placeholder="发票上填写的服务内容"></u-input> |
| 17 | + </u-form-item> |
| 18 | + <u-form-item label="发票金额" prop="amount" required> |
| 19 | + <u-input v-model="form.amount" type="digit" clearable placeholder="申请开票金额"></u-input> |
| 20 | + </u-form-item> |
| 21 | + <u-form-item label="地址电话" prop="address"> |
| 22 | + <u-input v-model="form.address" type="digit" clearable placeholder="发票栏目处填写的地址与电话"></u-input> |
| 23 | + </u-form-item> |
| 24 | + <u-form-item label="银行账号" prop="bank"> |
| 25 | + <u-input v-model="form.bank" type="text" clearable placeholder="发票栏目处填写的开户行与账号"></u-input> |
| 26 | + </u-form-item> |
| 27 | + <u-form-item label="电子邮箱" prop="email" required> |
| 28 | + <u-input v-model="form.email" type="text" clearable placeholder="发票将通过邮件发送给你"></u-input> |
| 29 | + </u-form-item> |
| 30 | + <u-form-item label="备注" prop="remark"> |
| 31 | + <u-input v-model="form.remark" type="text" clearable placeholder="如有特殊说明,请告诉我们"></u-input> |
| 32 | + </u-form-item> |
| 33 | + </u-form> |
| 34 | + </view> |
| 35 | + <view class="submit-btn"> |
| 36 | + <u-button type="success" @click="submit">申请发票</u-button> |
| 37 | + </view> |
| 38 | + <view class="bottom"> |
| 39 | + <u-cell title="发票管理" isLink url="/pages/invoice/list"></u-cell> |
| 40 | + </view> |
| 41 | + </view> |
| 42 | +</template> |
| 43 | + |
| 44 | +<script> |
| 45 | + export default { |
| 46 | + data() { |
| 47 | + return { |
| 48 | + merchantId: undefined, |
| 49 | + rules: { |
| 50 | + mobile: [{ |
| 51 | + required: true, |
| 52 | + message: '不能为空', |
| 53 | + // 可以单个或者同时写两个触发验证方式 |
| 54 | + trigger: ['change', 'blur'], |
| 55 | + }], |
| 56 | + comName: [{ |
| 57 | + required: true, |
| 58 | + message: '不能为空', |
| 59 | + // 可以单个或者同时写两个触发验证方式 |
| 60 | + trigger: ['change', 'blur'], |
| 61 | + }], |
| 62 | + tfn: [{ |
| 63 | + required: true, |
| 64 | + message: '不能为空', |
| 65 | + // 可以单个或者同时写两个触发验证方式 |
| 66 | + trigger: ['change', 'blur'], |
| 67 | + }], |
| 68 | + consumption: [{ |
| 69 | + required: true, |
| 70 | + message: '不能为空', |
| 71 | + // 可以单个或者同时写两个触发验证方式 |
| 72 | + trigger: ['change', 'blur'], |
| 73 | + }], |
| 74 | + amount: [{ |
| 75 | + required: true, |
| 76 | + message: '不能为空', |
| 77 | + // 可以单个或者同时写两个触发验证方式 |
| 78 | + trigger: ['change', 'blur'], |
| 79 | + }], |
| 80 | + email: [{ |
| 81 | + required: true, |
| 82 | + message: '不能为空', |
| 83 | + // 可以单个或者同时写两个触发验证方式 |
| 84 | + trigger: ['change', 'blur'], |
| 85 | + }], |
| 86 | + }, |
| 87 | + form: { |
| 88 | + mobile: null, |
| 89 | + comName: null, |
| 90 | + tfn: null, |
| 91 | + consumption: '服务费', |
| 92 | + amount: null, |
| 93 | + address: null, |
| 94 | + bank: null, |
| 95 | + email: null, |
| 96 | + remark: null, |
| 97 | + orderId: '', |
| 98 | + }, |
| 99 | + } |
| 100 | + }, |
| 101 | + created() { |
| 102 | +
|
| 103 | + }, |
| 104 | + mounted() { |
| 105 | +
|
| 106 | + }, |
| 107 | + onReady() { |
| 108 | + this.$refs.uForm.setRules(this.rules); |
| 109 | + }, |
| 110 | + onLoad(e) { |
| 111 | + this.merchantId = getApp().globalData.merchantId |
| 112 | + if (e.orderId) { |
| 113 | + this.form.orderId = e.orderId |
| 114 | + this.orderDetail(e.orderId) |
| 115 | + } |
| 116 | + }, |
| 117 | + onShow() { |
| 118 | +
|
| 119 | + }, |
| 120 | + onShareAppMessage(e) { |
| 121 | + return { |
| 122 | + title: '申请开票', |
| 123 | + path: '/pages/invoice/apply?inviter_id=' + this.uid |
| 124 | + } |
| 125 | + }, |
| 126 | + methods: { |
| 127 | + async orderDetail(orderId) { |
| 128 | + const res = await this.$wxapi.orderDetail(this.token, orderId) |
| 129 | + if (res.code == 0) { |
| 130 | + this.form.amount = res.data.orderInfo.amountReal + '' |
| 131 | + } |
| 132 | + }, |
| 133 | + chooseInvoiceTitle() { |
| 134 | + uni.chooseInvoiceTitle({ |
| 135 | + success: (res) => { |
| 136 | + this.form.comName = res.title |
| 137 | + this.form.tfn = res.taxNumber |
| 138 | + this.form.address = res.companyAddress + res.telephone |
| 139 | + this.form.bank = res.bankName + res.bankAccount |
| 140 | + }, |
| 141 | + fail: err => { |
| 142 | + console.error(err); |
| 143 | + uni.showToast({ |
| 144 | + title: '读取失败', |
| 145 | + icon: 'none' |
| 146 | + }) |
| 147 | + } |
| 148 | + }) |
| 149 | + }, |
| 150 | + submit() { |
| 151 | + this.$refs.uForm.validate().then(res => { |
| 152 | + this._submit() |
| 153 | + }).catch(errors => { |
| 154 | + uni.showToast({ |
| 155 | + title: '表单请填写完整', |
| 156 | + icon: 'none' |
| 157 | + }) |
| 158 | + }) |
| 159 | + }, |
| 160 | + async _submit() { |
| 161 | + const extJsonStr = {} |
| 162 | + extJsonStr['api工厂账号'] = this.form.mobile |
| 163 | + extJsonStr['地址与电话'] = this.form.address |
| 164 | + extJsonStr['开户行与账号'] = this.form.bank |
| 165 | + const res = await this.$wxapi.invoiceApply({ |
| 166 | + token: this.token, |
| 167 | + ...this.form, |
| 168 | + extJsonStr: JSON.stringify(extJsonStr) |
| 169 | + }) |
| 170 | + if (res.code == 0) { |
| 171 | + uni.showModal({ |
| 172 | + title: '成功', |
| 173 | + content: '提交成功,请耐心等待我们处理!', |
| 174 | + showCancel: false, |
| 175 | + confirmText: '我知道了', |
| 176 | + success(res) { |
| 177 | + uni.navigateTo({ |
| 178 | + url: "/pages/invoice/list" |
| 179 | + }) |
| 180 | + } |
| 181 | + }) |
| 182 | + } else { |
| 183 | + uni.showModal({ |
| 184 | + title: '失败', |
| 185 | + content: res.msg, |
| 186 | + showCancel: false, |
| 187 | + confirmText: '我知道了' |
| 188 | + }) |
| 189 | + } |
| 190 | + }, |
| 191 | + } |
| 192 | + } |
| 193 | +</script> |
| 194 | +<style scoped lang="scss"> |
| 195 | +.bottom { |
| 196 | + padding-bottom: 48rpx; |
| 197 | +} |
| 198 | +</style> |
0 commit comments