完善余额功能
This commit is contained in:
@ -100,17 +100,17 @@ __webpack_require__.r(__webpack_exports__);
|
||||
var components
|
||||
try {
|
||||
components = {
|
||||
uIcon: function () {
|
||||
return __webpack_require__.e(/*! import() | components/uview-ui/components/u-icon/u-icon */ "components/uview-ui/components/u-icon/u-icon").then(__webpack_require__.bind(null, /*! @/components/uview-ui/components/u-icon/u-icon.vue */ 335))
|
||||
},
|
||||
uRadioGroup: function () {
|
||||
return Promise.all(/*! import() | components/uview-ui/components/u-radio-group/u-radio-group */[__webpack_require__.e("common/vendor"), __webpack_require__.e("components/uview-ui/components/u-radio-group/u-radio-group")]).then(__webpack_require__.bind(null, /*! @/components/uview-ui/components/u-radio-group/u-radio-group.vue */ 520))
|
||||
return Promise.all(/*! import() | components/uview-ui/components/u-radio-group/u-radio-group */[__webpack_require__.e("common/vendor"), __webpack_require__.e("components/uview-ui/components/u-radio-group/u-radio-group")]).then(__webpack_require__.bind(null, /*! @/components/uview-ui/components/u-radio-group/u-radio-group.vue */ 528))
|
||||
},
|
||||
uImage: function () {
|
||||
return __webpack_require__.e(/*! import() | components/uview-ui/components/u-image/u-image */ "components/uview-ui/components/u-image/u-image").then(__webpack_require__.bind(null, /*! @/components/uview-ui/components/u-image/u-image.vue */ 364))
|
||||
},
|
||||
uRadio: function () {
|
||||
return __webpack_require__.e(/*! import() | components/uview-ui/components/u-radio/u-radio */ "components/uview-ui/components/u-radio/u-radio").then(__webpack_require__.bind(null, /*! @/components/uview-ui/components/u-radio/u-radio.vue */ 527))
|
||||
return __webpack_require__.e(/*! import() | components/uview-ui/components/u-radio/u-radio */ "components/uview-ui/components/u-radio/u-radio").then(__webpack_require__.bind(null, /*! @/components/uview-ui/components/u-radio/u-radio.vue */ 535))
|
||||
},
|
||||
uButton: function () {
|
||||
return __webpack_require__.e(/*! import() | components/uview-ui/components/u-button/u-button */ "components/uview-ui/components/u-button/u-button").then(__webpack_require__.bind(null, /*! @/components/uview-ui/components/u-button/u-button.vue */ 342))
|
||||
return __webpack_require__.e(/*! import() | components/uview-ui/components/u-button/u-button */ "components/uview-ui/components/u-button/u-button").then(__webpack_require__.bind(null, /*! @/components/uview-ui/components/u-button/u-button.vue */ 350))
|
||||
},
|
||||
}
|
||||
} catch (e) {
|
||||
@ -134,6 +134,15 @@ var render = function () {
|
||||
var _vm = this
|
||||
var _h = _vm.$createElement
|
||||
var _c = _vm._self._c || _h
|
||||
var g0 = _vm.paywayList.length
|
||||
_vm.$mp.data = Object.assign(
|
||||
{},
|
||||
{
|
||||
$root: {
|
||||
g0: g0,
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
var recyclableRender = false
|
||||
var staticRenderFns = []
|
||||
@ -167,18 +176,14 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
/* WEBPACK VAR INJECTION */(function(uni) {
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
var _app = __webpack_require__(/*! @/api/app */ 50);
|
||||
var _pay = __webpack_require__(/*! @/utils/pay */ 736);
|
||||
//
|
||||
//
|
||||
//
|
||||
@ -231,14 +236,147 @@ var _default = {
|
||||
pay: {
|
||||
weixin: 0,
|
||||
alipay: 0
|
||||
}
|
||||
},
|
||||
from: '',
|
||||
// 订单来源
|
||||
order_id: '',
|
||||
// 订单ID
|
||||
amount: 0,
|
||||
// 支付金额
|
||||
timeout: 0,
|
||||
// 倒计时间戳
|
||||
payway: '',
|
||||
// 支付方式
|
||||
paywayList: [] // 支付方式列表
|
||||
};
|
||||
},
|
||||
onLoad: function onLoad(options) {
|
||||
var from = options.from;
|
||||
var order_id = options.order_id;
|
||||
try {
|
||||
if (!from && !order_id) throw new Error('页面参数有误');
|
||||
this.from = from;
|
||||
this.order_id = order_id;
|
||||
this.initPageData();
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
uni.navigateBack();
|
||||
}
|
||||
},
|
||||
onUnload: function onUnload() {
|
||||
this.handPayResult('fail');
|
||||
},
|
||||
methods: {
|
||||
pay: function pay() {}
|
||||
// 更改支付方式
|
||||
changePayway: function changePayway(value) {
|
||||
this.$set(this, 'payway', value);
|
||||
},
|
||||
// 初始化页面数据
|
||||
initPageData: function initPageData() {
|
||||
var _this = this;
|
||||
// 获取支付方式
|
||||
(0, _app.getPayway)({
|
||||
from: this.from,
|
||||
order_id: this.order_id
|
||||
}).then(function (res) {
|
||||
if (res.code != 1) throw new Error(res.msg);
|
||||
return res.data;
|
||||
}).then(function (data) {
|
||||
var _this$paywayList$;
|
||||
_this.loadingSkeleton = false;
|
||||
_this.amount = data.order_amount;
|
||||
_this.paywayList = data.pay;
|
||||
_this.payway = (_this$paywayList$ = _this.paywayList[0]) === null || _this$paywayList$ === void 0 ? void 0 : _this$paywayList$.pay_way;
|
||||
// 倒计时
|
||||
var startTimestamp = new Date().getTime() / 1000;
|
||||
var endTimestamp = data.cancel_time * 1;
|
||||
_this.timeout = endTimestamp - startTimestamp;
|
||||
}).catch(function (err) {
|
||||
throw new Error(err);
|
||||
});
|
||||
},
|
||||
// 预支付处理
|
||||
handlePrepay: function handlePrepay() {
|
||||
var _this2 = this;
|
||||
if (this.loadingPay) return;
|
||||
this.loadingPay = true;
|
||||
(0, _app.prepay)({
|
||||
from: this.from,
|
||||
order_id: this.order_id,
|
||||
pay_way: this.payway
|
||||
}).then(function (_ref) {
|
||||
var code = _ref.code,
|
||||
data = _ref.data;
|
||||
switch (code) {
|
||||
case 1:
|
||||
_this2.handleWechatPay(data);
|
||||
break;
|
||||
case 10001:
|
||||
_this2.handleAlipayPay(data);
|
||||
break;
|
||||
case 20001:
|
||||
_this2.handleWalletPay();
|
||||
break;
|
||||
}
|
||||
}).catch(function (err) {}).finally(function () {
|
||||
setTimeout(function () {
|
||||
_this2.loadingPay = false;
|
||||
}, 500);
|
||||
});
|
||||
},
|
||||
// 微信支付
|
||||
handleWechatPay: function handleWechatPay(data) {
|
||||
var _this3 = this;
|
||||
(0, _pay.wxpay)(data).then(function (res) {
|
||||
console.log("wechat res>>>", res);
|
||||
_this3.handPayResult(res);
|
||||
});
|
||||
},
|
||||
// 支付宝支付
|
||||
handleAlipayPay: function handleAlipayPay(data) {
|
||||
var _this4 = this;
|
||||
(0, _pay.alipay)(data).then(function (res) {
|
||||
console.log("alipay res>>>", res);
|
||||
_this4.handPayResult(res);
|
||||
});
|
||||
},
|
||||
// 钱包余额支付
|
||||
handleWalletPay: function handleWalletPay() {
|
||||
console.log('支付成功');
|
||||
//余额支付成功
|
||||
this.handPayResult('success');
|
||||
},
|
||||
// 支付后处理
|
||||
handPayResult: function handPayResult(result) {
|
||||
switch (result) {
|
||||
case 'success':
|
||||
uni.$emit('payment', {
|
||||
result: true,
|
||||
order_id: this.order_id
|
||||
});
|
||||
break;
|
||||
case 'fail':
|
||||
default:
|
||||
uni.$emit('payment', {
|
||||
result: false,
|
||||
order_id: this.order_id
|
||||
});
|
||||
}
|
||||
// // 页面出栈
|
||||
// uni.showLoading({
|
||||
// title: '加载中',
|
||||
// mask: true
|
||||
// })
|
||||
// //记录支付结果
|
||||
// setTimeout(() => {
|
||||
// uni.hideLoading()
|
||||
// uni.navigateBack()
|
||||
// }, 500)
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.default = _default;
|
||||
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"]))
|
||||
|
||||
/***/ }),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user