优化代码

This commit is contained in:
Your Name 2023-09-23 11:51:06 +08:00
parent eb06dc6d88
commit 14825927ec

View File

@ -34,12 +34,7 @@
合计{{amount}} 合计{{amount}}
</view> </view>
<view class="btn-group"> <view class="btn-group">
<!-- #ifdef H5 || MP-WEIXIN -->
<button class="cu-btn bg-red shadow-blur lgplus sharp" @click="onPayFee()">提交订单</button> <button class="cu-btn bg-red shadow-blur lgplus sharp" @click="onPayFee()">提交订单</button>
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<button class="cu-btn bg-red shadow-blur lgplus sharp" @click="_payWxApp()">提交订单</button>
<!-- #endif -->
</view> </view>
</view> </view>
</view> </view>
@ -50,6 +45,7 @@
import context from '../../lib/java110/Java110Context.js'; import context from '../../lib/java110/Java110Context.js';
import {getMeterMachine} from '../../api/machine/machineApi.js'; import {getMeterMachine} from '../../api/machine/machineApi.js';
import {getCommunityId} from '@/api/community/communityApi.js'; import {getCommunityId} from '@/api/community/communityApi.js';
import {getUserId} from '../../api/user/userApi.js';
import {payFeeApp,payFeeWechat} from '@/api/fee/feeApi.js'; import {payFeeApp,payFeeWechat} from '@/api/fee/feeApi.js';
export default { export default {
@ -69,13 +65,6 @@
this.machineId = options.machineId; this.machineId = options.machineId;
this.roomId = options.roomId; this.roomId = options.roomId;
this.loadMeterMachine(); this.loadMeterMachine();
// #ifdef MP-WEIXIN
let accountInfo = uni.getAccountInfoSync();
this.appId = accountInfo.miniProgram.appId;
// #endif
// #ifdef H5
this.appId = uni.getStorageSync(constant.mapping.W_APP_ID)
// #endif
}, },
methods: { methods: {
loadMeterMachine: function() { loadMeterMachine: function() {
@ -93,27 +82,7 @@
_that.amount=_data[0].amount; _that.amount=_data[0].amount;
}) })
}, },
_payWxApp: function(_data) {
if(!this.amount){
uni.showToast({
icon:'none',
title:'未填写金额'
});
return ;
}
let _receivedAmount = this.amount;
let _tradeType = 'APP';
payFeeApp(this,{
communityId:getCommunityId(),
roomId: this.roomId,
machineId: this.machineId,
feeName: this.feeConfigName+'充值',
receivedAmount: _receivedAmount,
tradeType: _tradeType,
appId: this.appId,
});
},
onPayFee: function() { onPayFee: function() {
if(!this.amount){ if(!this.amount){
uni.showToast({ uni.showToast({
@ -124,8 +93,7 @@
} }
let _receivedAmount = this.amount; let _receivedAmount = this.amount;
let _tradeType = 'JSAPI'; let _tradeType = 'JSAPI';
let _objData = {
payFeeWechat(this,{
business: "preStoreMeter", business: "preStoreMeter",
communityId:getCommunityId(), communityId:getCommunityId(),
roomId: this.roomId, roomId: this.roomId,
@ -133,7 +101,10 @@
feeName: this.feeConfigName+'充值', feeName: this.feeConfigName+'充值',
receivedAmount: _receivedAmount, receivedAmount: _receivedAmount,
tradeType: _tradeType, tradeType: _tradeType,
appId: this.appId, };
uni.setStorageSync('doing_cashier',_objData);
uni.navigateTo({
url:'/pages/fee/cashier?money='+_receivedAmount+"&business=preStoreMeter&communityId="+getCommunityId()+"&cashierUserId="+getUserId()
}) })
} }
} }