mirror of
https://gitee.com/java110/WechatOwnerService.git
synced 2026-02-23 21:36:38 +08:00
优化代码
This commit is contained in:
parent
a98a37c8b3
commit
29fb7c43cf
@ -110,6 +110,13 @@
|
|||||||
const context = require("../../context/Java110Context.js");
|
const context = require("../../context/Java110Context.js");
|
||||||
const constant = context.constant;
|
const constant = context.constant;
|
||||||
import {addMonth,formatDate} from '../../utils/DateUtil.js'
|
import {addMonth,formatDate} from '../../utils/DateUtil.js'
|
||||||
|
|
||||||
|
|
||||||
|
// #ifdef H5
|
||||||
|
|
||||||
|
const WexinPayFactory = require('../../factory/WexinPayFactory.js');
|
||||||
|
|
||||||
|
// #endif
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@ -304,7 +311,7 @@
|
|||||||
console.log(res);
|
console.log(res);
|
||||||
if (res.statusCode == 200 && res.data.code == '0') {
|
if (res.statusCode == 200 && res.data.code == '0') {
|
||||||
let data = res.data;
|
let data = res.data;
|
||||||
//成功情况下跳转
|
// #ifdef MP-WEIXIN
|
||||||
uni.requestPayment({
|
uni.requestPayment({
|
||||||
'timeStamp': data.timeStamp,
|
'timeStamp': data.timeStamp,
|
||||||
'nonceStr': data.nonceStr,
|
'nonceStr': data.nonceStr,
|
||||||
@ -316,17 +323,23 @@
|
|||||||
title: "支付成功",
|
title: "支付成功",
|
||||||
duration: 2000
|
duration: 2000
|
||||||
});
|
});
|
||||||
let pages = getCurrentPages();
|
|
||||||
let prevPage = pages[pages.length - 2]; //上一个页面
|
|
||||||
//直接调用上一个页面的setData()方法,把数据存到上一个页面中去
|
|
||||||
prevPage.needFefresh = true;
|
|
||||||
uni.navigateBack({});
|
uni.navigateBack({});
|
||||||
},
|
},
|
||||||
'fail': function(res) {
|
'fail': function(res) {
|
||||||
console.log('fail:' + JSON.stringify(res));
|
console.log('fail:' + JSON.stringify(res));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
uni.hideLoading();
|
// #endif
|
||||||
|
// #ifdef H5
|
||||||
|
WexinPayFactory.wexinPay(data,function(){
|
||||||
|
uni.showToast({
|
||||||
|
title: "支付成功",
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
uni.navigateBack({});
|
||||||
|
});
|
||||||
|
// #endif
|
||||||
|
wx.hideLoading();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -355,7 +355,14 @@ var context = __webpack_require__(/*! ../../context/Java110Context.js */ 8);var
|
|||||||
//直接调用上一个页面的setData()方法,把数据存到上一个页面中去
|
//直接调用上一个页面的setData()方法,把数据存到上一个页面中去
|
||||||
prevPage.needFefresh = false;}, /**
|
prevPage.needFefresh = false;}, /**
|
||||||
* 用户点击右上角分享
|
* 用户点击右上角分享
|
||||||
*/onShareAppMessage: function onShareAppMessage() {}, methods: { dateChange: function dateChange(e) {console.log("onConfirm", e);var _feeMonthName = null;_feeMonthName = this.feeMonthList[e.detail.value];var _feeMonth = _feeMonthName.replace("个月", "");;var _receivableAmount = _feeMonth * this.feePrice;var _lastDate = new Date(this.ordEndTime);var _newDate = (0, _DateUtil.addMonth)(_lastDate, _feeMonth);this.showFeeMonth = false;this.feeMonthName = _feeMonthName;this.receivableAmount = _receivableAmount;this.feeMonth = _feeMonth;this.endTime = (0, _DateUtil.formatDate)(_newDate);}, onFeeMonthCancel: function onFeeMonthCancel(e) {this.showFeeMonth = false;}, _payWxApp: function _payWxApp(_data) {var _receivedAmount = this.receivableAmount;wx.showLoading({ title: '支付中' });var _tradeType = 'APP';var _objData = { cycles: this.feeMonth, communityId: this.communityId, feeId: this.feeId, feeName: '停车费', receivedAmount: _receivedAmount, tradeType: _tradeType, appId: this.appId };context.request({
|
*/onShareAppMessage: function onShareAppMessage() {}, methods: { dateChange: function dateChange(e) {console.log("onConfirm", e);var _feeMonthName = null;_feeMonthName = this.feeMonthList[e.detail.value];var _feeMonth = _feeMonthName.replace("个月", "");;var _receivableAmount = _feeMonth * this.feePrice;var _lastDate = new Date(this.ordEndTime);var _newDate = (0, _DateUtil.addMonth)(_lastDate, _feeMonth);this.showFeeMonth = false;this.feeMonthName = _feeMonthName;this.receivableAmount = _receivableAmount;this.feeMonth = _feeMonth;this.endTime = (0, _DateUtil.formatDate)(_newDate);}, onFeeMonthCancel: function onFeeMonthCancel(e) {this.showFeeMonth = false;}, _payWxApp: function _payWxApp(_data) {var _receivedAmount = this.receivableAmount;wx.showLoading({ title: '支付中' });var _tradeType = 'APP';var _objData = { cycles: this.feeMonth, communityId: this.communityId,
|
||||||
|
feeId: this.feeId,
|
||||||
|
feeName: '停车费',
|
||||||
|
receivedAmount: _receivedAmount,
|
||||||
|
tradeType: _tradeType,
|
||||||
|
appId: this.appId };
|
||||||
|
|
||||||
|
context.request({
|
||||||
url: constant.url.preOrder,
|
url: constant.url.preOrder,
|
||||||
header: context.getHeaders(),
|
header: context.getHeaders(),
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@ -436,7 +443,7 @@ var context = __webpack_require__(/*! ../../context/Java110Context.js */ 8);var
|
|||||||
console.log(res);
|
console.log(res);
|
||||||
if (res.statusCode == 200 && res.data.code == '0') {
|
if (res.statusCode == 200 && res.data.code == '0') {
|
||||||
var data = res.data;
|
var data = res.data;
|
||||||
//成功情况下跳转
|
|
||||||
uni.requestPayment({
|
uni.requestPayment({
|
||||||
'timeStamp': data.timeStamp,
|
'timeStamp': data.timeStamp,
|
||||||
'nonceStr': data.nonceStr,
|
'nonceStr': data.nonceStr,
|
||||||
@ -448,17 +455,23 @@ var context = __webpack_require__(/*! ../../context/Java110Context.js */ 8);var
|
|||||||
title: "支付成功",
|
title: "支付成功",
|
||||||
duration: 2000 });
|
duration: 2000 });
|
||||||
|
|
||||||
var pages = getCurrentPages();
|
|
||||||
var prevPage = pages[pages.length - 2]; //上一个页面
|
|
||||||
//直接调用上一个页面的setData()方法,把数据存到上一个页面中去
|
|
||||||
prevPage.needFefresh = true;
|
|
||||||
uni.navigateBack({});
|
uni.navigateBack({});
|
||||||
},
|
},
|
||||||
'fail': function fail(res) {
|
'fail': function fail(res) {
|
||||||
console.log('fail:' + JSON.stringify(res));
|
console.log('fail:' + JSON.stringify(res));
|
||||||
} });
|
} });
|
||||||
|
|
||||||
uni.hideLoading();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wx.hideLoading();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user