[支付宝支付0元支付和有金额支付两种,]

This commit is contained in:
2021-10-29 11:54:17 +08:00
parent efdd8e61cb
commit 8b5ff33e31
4 changed files with 358 additions and 129 deletions

View File

@@ -1,4 +1,3 @@
/**
* Web唐明明
* 匆匆数载恍如梦,岁月迢迢华发增。
@@ -6,7 +5,9 @@
* moduleName: 订单
*/
import { request } from '../index'
import {
request
} from '../index'
// 创建,确认订单
const buy = (data, method) => {
@@ -33,6 +34,15 @@ const wxPay = (data) => {
})
}
//支付宝支付
const aliPay = (data) => {
return request({
url: 'mall/pay/' + data.order_no + '/alipay',
data: data,
method: 'get'
})
}
// EB支付
const ebPay = (data) => {
return request({
@@ -43,5 +53,6 @@ export {
buy,
eb,
wxPay,
aliPay,
ebPay
}

View File

@@ -48,6 +48,17 @@
<u-icon v-if="selectTypeId!== '2'" name="checkmark-circle" color="#f7f7f7" size="50"></u-icon>
<u-icon v-else name="checkmark-circle-fill" color="#8b64fd" size="50"></u-icon>
</view>
<view class="pay-select-item" @click="selectPay('3')">
<view class="pay-left">
<u-icon class="wx-icon" name="zhifubao" color="#fff" size="40"></u-icon>
<view class="pay-wx-title">
支付宝支付
<span>推荐支付宝用户使用</span>
</view>
</view>
<u-icon v-if="selectTypeId!== '3'" name="checkmark-circle" color="#f7f7f7" size="50"></u-icon>
<u-icon v-else name="checkmark-circle-fill" color="#8b64fd" size="50"></u-icon>
</view>
<!-- <view class="pay-select-item" @click="selectPay('1')">
<view class="pay-left">
<u-icon class="wx-icon" name="integral-fill" color="#fff" size="40"></u-icon>
@@ -98,6 +109,7 @@
} from '@/apis/interfaces/goods'
import {
wxPay,
aliPay,
ebPay
} from '@/apis/interfaces/order'
export default {
@@ -177,6 +189,12 @@
order_no: this.order_no,
type: 'app'
}
} else if (this.selectTypeId === '3') {
apiUrl = aliPay
data = {
order_no: this.order_no,
type: 'app'
}
} else {
apiUrl = ebPay
data = {
@@ -184,6 +202,9 @@
}
}
apiUrl(data).then(res => {
console.log(res)
debugger;
// 微信支付
if (this.selectTypeId === '2') {
if (typeof res === 'string') {
let payInfo = JSON.parse(res)
@@ -234,6 +255,56 @@
}, 3000);
}
}
// 支付宝支付
else if (this.selectTypeId === '3') {
if (typeof res === 'string') {
uni.requestPayment({
provider: "alipay",
orderInfo: res,
success: res => {
uni.showToast({
title: '支付成功',
duration: 3000,
mask: true,
icon: 'none'
})
setTimeout(() => {
uni.reLaunch({
url: '/pages/goods/payStatus?success=true'
})
this.canPay = true
}, 3000);
},
fail: (err) => {
uni.showToast({
title: '支付失败',
duration: 3000,
mask: true,
icon: 'none'
})
setTimeout(() => {
uni.reLaunch({
url: '/pages/goods/payStatus?success=false'
})
this.canPay = true
}, 3000);
}
})
} else {
uni.showToast({
title: '创建订单成功',
duration: 3000,
mask: true,
icon: 'none'
})
setTimeout(() => {
this.canPay = true
uni.reLaunch({
url: '/pages/goods/payStatus?success=true'
})
}, 3000);
}
}
}).catch(err => {
uni.showToast({
title: err.message,
@@ -276,6 +347,8 @@
}
} else if (id === '2') {
this.selectTypeId = id
} else if (id === '3') {
this.selectTypeId = id
}
},

View File

@@ -1,6 +1,7 @@
<template>
<view class="PayStatus">
<image class="payStatusImg" :src="success?'/static/imgs/paySuccess.png':'/static/imgs/payFail.png'" mode="widthFix" />
<image class="payStatusImg" :src="success?'/static/imgs/paySuccess.png':'/static/imgs/payFail.png'"
mode="widthFix" />
<view class="payTitle">{{success?'支付成功':'支付失败'}}</view>
<view class="payDes">{{success?'您已支付完成,订单稍后配送':'吼吼,您的支付未完成'}}</view>
<view class="payBackCheck">

View File

@@ -14944,27 +14944,86 @@ var render = function() {
})
],
1
),
_c(
"view",
{
staticClass: _vm._$s(33, "sc", "pay-select-item"),
attrs: { _i: 33 },
on: {
click: function($event) {
return _vm.selectPay("3")
}
}
},
[
_c(
"view",
{
staticClass: _vm._$s(34, "sc", "pay-left"),
attrs: { _i: 34 }
},
[
_c("u-icon", {
staticClass: _vm._$s(35, "sc", "wx-icon"),
attrs: {
name: "zhifubao",
color: "#fff",
size: "40",
_i: 35
}
}),
_c(
"view",
{
staticClass: _vm._$s(36, "sc", "pay-wx-title"),
attrs: { _i: 36 }
},
[_c("span")]
)
],
1
),
_vm._$s(38, "i", _vm.selectTypeId !== "3")
? _c("u-icon", {
attrs: {
name: "checkmark-circle",
color: "#f7f7f7",
size: "50",
_i: 38
}
})
: _c("u-icon", {
attrs: {
name: "checkmark-circle-fill",
color: "#8b64fd",
size: "50",
_i: 39
}
})
],
1
)
]
),
_c(
"view",
{ staticClass: _vm._$s(33, "sc", "actions"), attrs: { _i: 33 } },
{ staticClass: _vm._$s(40, "sc", "actions"), attrs: { _i: 40 } },
[
_c(
"view",
{ staticClass: _vm._$s(34, "sc", "title"), attrs: { _i: 34 } },
{ staticClass: _vm._$s(41, "sc", "title"), attrs: { _i: 41 } },
[
_c(
"span",
{ staticClass: _vm._$s(35, "sc", "money"), attrs: { _i: 35 } },
[_vm._v(_vm._$s(35, "t0-0", _vm._s(_vm.total)))]
{ staticClass: _vm._$s(42, "sc", "money"), attrs: { _i: 42 } },
[_vm._v(_vm._$s(42, "t0-0", _vm._s(_vm.total)))]
)
]
),
_c("view", {
staticClass: _vm._$s(36, "sc", "nowPay"),
attrs: { _i: 36 },
staticClass: _vm._$s(43, "sc", "nowPay"),
attrs: { _i: 43 },
on: { click: _vm.order }
})
]
@@ -14972,9 +15031,9 @@ var render = function() {
_c(
"u-popup",
{
attrs: { mode: "bottom", "border-radius": "14", _i: 37 },
attrs: { mode: "bottom", "border-radius": "14", _i: 44 },
model: {
value: _vm._$s(37, "v-model", _vm.showCouponList),
value: _vm._$s(44, "v-model", _vm.showCouponList),
callback: function($$v) {
_vm.showCouponList = $$v
},
@@ -14984,33 +15043,33 @@ var render = function() {
[
_c(
"scroll-view",
{ staticClass: _vm._$s(38, "sc", "scrollView"), attrs: { _i: 38 } },
{ staticClass: _vm._$s(45, "sc", "scrollView"), attrs: { _i: 45 } },
[
_c("view", {
staticClass: _vm._$s(39, "sc", "coupon-title"),
attrs: { _i: 39 }
staticClass: _vm._$s(46, "sc", "coupon-title"),
attrs: { _i: 46 }
}),
_vm._l(_vm._$s(40, "f", { forItems: _vm.list }), function(
_vm._l(_vm._$s(47, "f", { forItems: _vm.list }), function(
item,
index,
$20,
$30
) {
return _vm._$s("40-" + $30, "i", _vm.list.length > 0)
return _vm._$s("47-" + $30, "i", _vm.list.length > 0)
? _c(
"view",
{
key: _vm._$s(40, "f", { forIndex: $20, key: index }),
key: _vm._$s(47, "f", { forIndex: $20, key: index }),
staticClass: _vm._$s(
"40-" + $30,
"47-" + $30,
"sc",
"coupon-list-item"
),
attrs: { _i: "40-" + $30 }
attrs: { _i: "47-" + $30 }
},
[
_vm._$s(
"41-" + $30,
"48-" + $30,
"i",
_vm.coupon_grant_id !== item.coupon_grant_id
)
@@ -15019,7 +15078,7 @@ var render = function() {
name: "checkmark-circle",
color: "#cacaca",
size: "50",
_i: "41-" + $30
_i: "48-" + $30
}
})
: _c("u-icon", {
@@ -15027,23 +15086,23 @@ var render = function() {
name: "checkmark-circle-fill",
color: "#8b64fd",
size: "50",
_i: "42-" + $30
_i: "49-" + $30
}
}),
_c("couponTemplate", {
attrs: {
item: Object.assign({}, item),
showUse: false,
_i: "43-" + $30
_i: "50-" + $30
}
}),
_c("view", {
staticClass: _vm._$s(
"44-" + $30,
"51-" + $30,
"sc",
"coupon-list-item"
),
attrs: { _i: "44-" + $30 },
attrs: { _i: "51-" + $30 },
on: {
click: function($event) {
return _vm.selectCoupon(item)
@@ -15055,12 +15114,12 @@ var render = function() {
)
: _vm._e()
}),
_vm._$s(45, "i", _vm.list.length === 0)
_vm._$s(52, "i", _vm.list.length === 0)
? _c("no-list", {
attrs: {
name: "no-counpon",
txt: "没有任何可用券哦",
_i: 45
_i: 52
}
})
: _vm._e()
@@ -15069,7 +15128,7 @@ var render = function() {
)
]
),
_c("u-toast", { ref: "uToast", attrs: { _i: 46 } })
_c("u-toast", { ref: "uToast", attrs: { _i: 53 } })
],
1
)
@@ -17227,7 +17286,18 @@ __webpack_require__.r(__webpack_exports__);
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;
/* WEBPACK VAR INJECTION */(function(__f__) {Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;
@@ -17418,6 +17488,17 @@ var _order = __webpack_require__(/*! @/apis/interfaces/order */ 155);function _i
//
//
//
//
//
//
//
//
//
//
//
//
//
//
var _default = { name: 'OrderInfo', components: { couponTemplate: _couponTemplate.default }, data: function data() {return { // box: {
// min: 1,
// max: 100
@@ -17437,7 +17518,56 @@ var _default = { name: 'OrderInfo', components: { couponTemplate: _couponTemplat
}, methods: { // 确认商品详情页get下单页面post
mallBuyGoods: function mallBuyGoods(params, method) {var _this = this;params.coupon_grant_id = this.coupon_grant_id;(0, _goods.mallBuyGoods)(params, method).then(function (res) {if (method === 'get') {_this.amount = res.amount;_this.account = res.account;_this.total = res.total;_this.list = res.coupons;_this.shop = res.detail[0].shop;_this.info = res.detail[0].items[0];_this.coupon_price = res.coupon_price;} else {_this.order_no = res.order_no;_this.nowPay();}}).catch(function (err) {_this.$refs.uToast.show({ title: err.message, type: 'primary', duration: 3000 });});}, // 提交订单
order: function order() {var params = this.params;params.coupon_grant_id = this.coupon_grant_id;params.remark = this.remark;params.channel = 'app';this.mallBuyGoods(params, 'post');}, // 触发支付
nowPay: function nowPay() {var _this2 = this;this.canPay = false;var apiUrl = '';var data = {};if (this.selectTypeId === '2') {apiUrl = _order.wxPay;data = { order_no: this.order_no, type: 'app' };} else {apiUrl = _order.ebPay;data = { order_no: this.order_no };}apiUrl(data).then(function (res) {if (_this2.selectTypeId === '2') {if (typeof res === 'string') {var payInfo = JSON.parse(res);uni.requestPayment({ provider: "wxpay", orderInfo: payInfo, success: function success(res) {uni.showToast({ title: '支付成功', duration: 3000, mask: true, icon: 'none' });setTimeout(function () {uni.reLaunch({ url: '/pages/goods/payStatus?success=true' });_this2.canPay = true;}, 3000);}, fail: function fail(err) {uni.showToast({ title: '支付失败', duration: 3000, mask: true,
nowPay: function nowPay() {var _this2 = this;this.canPay = false;var apiUrl = '';var data = {};if (this.selectTypeId === '2') {apiUrl = _order.wxPay;data = { order_no: this.order_no, type: 'app' };} else if (this.selectTypeId === '3') {apiUrl = _order.aliPay;data = { order_no: this.order_no, type: 'app' };} else {apiUrl = _order.ebPay;data = { order_no: this.order_no };}apiUrl(data).then(function (res) {__f__("log", res, " at pages/goods/confirmOrder.vue:205");debugger; // 微信支付
if (_this2.selectTypeId === '2') {if (typeof res === 'string') {var payInfo = JSON.parse(res);uni.requestPayment({ provider: "wxpay", orderInfo: payInfo, success: function success(res) {uni.showToast({ title: '支付成功', duration: 3000, mask: true, icon: 'none' });setTimeout(function () {uni.reLaunch({ url: '/pages/goods/payStatus?success=true' });_this2.canPay = true;}, 3000);}, fail: function fail(err) {uni.showToast({ title: '支付失败', duration: 3000, mask: true, icon: 'none' });
setTimeout(function () {
uni.reLaunch({
url: '/pages/goods/payStatus?success=false' });
_this2.canPay = true;
}, 3000);
} });
} else {
uni.showToast({
title: '创建订单成功',
duration: 3000,
mask: true,
icon: 'none' });
setTimeout(function () {
_this2.canPay = true;
uni.reLaunch({
url: '/pages/goods/payStatus?success=true' });
}, 3000);
}
}
// 支付宝支付
else if (_this2.selectTypeId === '3') {
if (typeof res === 'string') {
uni.requestPayment({
provider: "alipay",
orderInfo: res,
success: function success(res) {
uni.showToast({
title: '支付成功',
duration: 3000,
mask: true,
icon: 'none' });
setTimeout(function () {
uni.reLaunch({
url: '/pages/goods/payStatus?success=true' });
_this2.canPay = true;
}, 3000);
},
fail: function fail(err) {
uni.showToast({
title: '支付失败',
duration: 3000,
mask: true,
icon: 'none' });
setTimeout(function () {
@@ -17505,8 +17635,11 @@ var _default = { name: 'OrderInfo', components: { couponTemplate: _couponTemplat
}
} else if (id === '2') {
this.selectTypeId = id;
} else if (id === '3') {
this.selectTypeId = id;
}
} } };exports.default = _default;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/vue-cli-plugin-uni/lib/format-log.js */ 39)["default"]))
/***/ }),
/* 149 */
@@ -17936,8 +18069,7 @@ exports.exchangeGoods = exchangeGoods;var getQrcodeByGrantId = function getQrcod
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });exports.ebPay = exports.wxPay = exports.eb = exports.buy = void 0;
Object.defineProperty(exports, "__esModule", { value: true });exports.ebPay = exports.aliPay = exports.wxPay = exports.eb = exports.buy = void 0;
@@ -17950,7 +18082,9 @@ var _index = __webpack_require__(/*! ../index */ 25); /**
* 碌碌无为枉半生一朝惊醒万事空
* moduleName: 订单
*/ // 创建确认订单
var buy = function buy(data, method) {return (0, _index.request)({ url: 'mall/buy/goods', method: method,
var buy = function buy(data, method) {return (0, _index.request)({
url: 'mall/buy/goods',
method: method,
data: data });
};
@@ -17971,8 +18105,17 @@ exports.eb = eb;var wxPay = function wxPay(data) {
};
//支付宝支付
exports.wxPay = wxPay;var aliPay = function aliPay(data) {
return (0, _index.request)({
url: 'mall/pay/' + data.order_no + '/alipay',
data: data,
method: 'get' });
};
// EB支付
exports.wxPay = wxPay;var ebPay = function ebPay(data) {
exports.aliPay = aliPay;var ebPay = function ebPay(data) {
return (0, _index.request)({
url: 'mall/pay/' + data.order_no + '/eb' });
@@ -18155,6 +18298,7 @@ Object.defineProperty(exports, "__esModule", { value: true });exports.default =
//
//
//
//
var _default =
{
data: function data() {