暂存工作台修改
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
|
||||
import { handleRecharge } from "../../../../service/recharge";
|
||||
import { alertInfo, alertSuccess } from "../../../../utils/index";
|
||||
import request from '../../../../utils/request'
|
||||
const { OK } = request;
|
||||
|
||||
// pages/workBench/components/recharge/index.js
|
||||
Component({
|
||||
|
||||
@@ -12,13 +18,114 @@ Component({
|
||||
* 组件的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
show: false,
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
|
||||
onParkFocus(e) {
|
||||
this.setData({
|
||||
show: true,
|
||||
title: "园区",
|
||||
type: 'park'
|
||||
})
|
||||
},
|
||||
onMeterFocus(e) {
|
||||
const { park } = this.data;
|
||||
if (!park) {
|
||||
alertInfo("请先选择园区")
|
||||
return;
|
||||
}
|
||||
this.setData({
|
||||
show: true,
|
||||
title: "电表",
|
||||
type: 'meter'
|
||||
})
|
||||
},
|
||||
onConfirm(e) {
|
||||
// console.log('e', e)
|
||||
const { data, type, way } = e.detail;
|
||||
console.log('e.detail', e.detail)
|
||||
switch(type) {
|
||||
case "park":
|
||||
this.setData({
|
||||
parkName: data.name,
|
||||
park: data.id,
|
||||
})
|
||||
break;
|
||||
case "meter":
|
||||
this.setData({
|
||||
meterName: `${data.meterNo}-${data.address}${data.tenement?.name ? '-' + data.tenement?.name : ''}`,
|
||||
meter: data.id,
|
||||
})
|
||||
break;
|
||||
case "pay":
|
||||
this.setData({
|
||||
payName: data,
|
||||
way: way,
|
||||
});
|
||||
break;
|
||||
}
|
||||
this.onConcal();
|
||||
},
|
||||
onConcal() {
|
||||
this.setData({
|
||||
show: false,
|
||||
title: "",
|
||||
type: "",
|
||||
})
|
||||
},
|
||||
onPayFocus() {
|
||||
this.setData({
|
||||
show: true,
|
||||
title: "付款方式",
|
||||
type: 'pay'
|
||||
})
|
||||
},
|
||||
onChangeMoney(e) {
|
||||
console.log('e', e)
|
||||
this.setData({ money: e.detail })
|
||||
},
|
||||
onChangeVoucherNo(e) {
|
||||
console.log('e', e)
|
||||
this.setData({ voucherNo: e.detail })
|
||||
},
|
||||
async handleSubmit() {
|
||||
const { park, meter, money, way, voucherNo } = this.data;
|
||||
if (!park) {
|
||||
alertInfo("请选择园区");
|
||||
return;
|
||||
}
|
||||
if (!meter) {
|
||||
alertInfo("请选择电表")
|
||||
return;
|
||||
}
|
||||
if (!money) {
|
||||
alertInfo("请输入金额")
|
||||
return
|
||||
}
|
||||
if (!way && way !== 0) {
|
||||
alertInfo("请选择付款方式")
|
||||
return
|
||||
}
|
||||
if (!voucherNo) {
|
||||
alertInfo("请输入凭证号")
|
||||
return
|
||||
}
|
||||
const { code, message } = await handleRecharge(park, {
|
||||
amount: `${money || ''}`,
|
||||
meter,
|
||||
paymentType: way,
|
||||
voucherNo,
|
||||
type: "0"
|
||||
})
|
||||
if (code !== OK) {
|
||||
alertInfo(message)
|
||||
return
|
||||
}
|
||||
alertSuccess("充值成功")
|
||||
}
|
||||
}
|
||||
})
|
@@ -1,6 +1,9 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-popup": "@vant/weapp/popup/index"
|
||||
"van-popup": "@vant/weapp/popup/index",
|
||||
"search-select": "/components/searchSelect/index",
|
||||
"van-field": "@vant/weapp/field/index",
|
||||
"van-button": "@vant/weapp/button/index"
|
||||
}
|
||||
}
|
@@ -1,3 +1,80 @@
|
||||
<!--pages/workBench/components/recharge/index.wxml-->
|
||||
充值
|
||||
<searchSelect />
|
||||
<van-cell-group>
|
||||
<van-field
|
||||
value="{{ parkName }}"
|
||||
placeholder="请选择园区"
|
||||
label="园区"
|
||||
readonly
|
||||
border="{{ false }}"
|
||||
use-button-slot
|
||||
title-width="70rpx"
|
||||
>
|
||||
<van-button slot="button" size="small" type="primary" bind:click="onParkFocus">
|
||||
选择
|
||||
</van-button>
|
||||
</van-field>
|
||||
<van-field
|
||||
value="{{ meterName }}"
|
||||
placeholder="请选择电表"
|
||||
label="电表"
|
||||
readonly
|
||||
border="{{ false }}"
|
||||
use-button-slot
|
||||
title-width="70rpx"
|
||||
>
|
||||
<van-button slot="button" size="small" type="primary" bind:click="onMeterFocus">
|
||||
选择
|
||||
</van-button>
|
||||
</van-field>
|
||||
<van-field
|
||||
value="{{ money }}"
|
||||
placeholder="请输入金额"
|
||||
label="金额"
|
||||
type="number"
|
||||
border="{{ false }}"
|
||||
use-button-slot
|
||||
title-width="70rpx"
|
||||
bind:change="onChangeMoney"
|
||||
>
|
||||
</van-field>
|
||||
<van-field
|
||||
value="{{ payName }}"
|
||||
placeholder="请选择付款方式"
|
||||
label="付款方式"
|
||||
readonly
|
||||
border="{{ false }}"
|
||||
use-button-slot
|
||||
title-width="140rpx"
|
||||
>
|
||||
<van-button
|
||||
slot="button"
|
||||
size="small"
|
||||
type="primary"
|
||||
bind:click="onPayFocus"
|
||||
>
|
||||
选择
|
||||
</van-button>
|
||||
</van-field>
|
||||
<van-field
|
||||
value="{{ voucherNo }}"
|
||||
placeholder="请输入凭证"
|
||||
label="凭证"
|
||||
border="{{ false }}"
|
||||
use-button-slot
|
||||
title-width="70rpx"
|
||||
bind:change="onChangeVoucherNo"
|
||||
/>
|
||||
</van-cell-group>
|
||||
|
||||
<view style="margin-top: 60rpx;display: flex; justify-content: center; align-items: center;">
|
||||
<van-button type="info" size="small" style="margin-right: 30rpx;" bind:click="handleSubmit"> 确认 </van-button>
|
||||
<van-button size="small"> 取消 </van-button>
|
||||
</view>
|
||||
<search-select
|
||||
show="{{show}}"
|
||||
title="{{title}}"
|
||||
type="{{type}}"
|
||||
park="{{park}}"
|
||||
bindconfirm="onConfirm"
|
||||
bindcancel="onConcal"
|
||||
/>
|
||||
|
Reference in New Issue
Block a user