[支付宝支付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唐明明 * Web唐明明
* 匆匆数载恍如梦,岁月迢迢华发增。 * 匆匆数载恍如梦,岁月迢迢华发增。
@@ -6,7 +5,9 @@
* moduleName: 订单 * moduleName: 订单
*/ */
import { request } from '../index' import {
request
} from '../index'
// 创建,确认订单 // 创建,确认订单
const buy = (data, method) => { const buy = (data, method) => {
@@ -26,22 +27,32 @@ const eb = (no) => {
// 微信支付 // 微信支付
const wxPay = (data) => { const wxPay = (data) => {
return request({ return request({
url: 'mall/pay/' + data.order_no + '/wechat', url: 'mall/pay/' + data.order_no + '/wechat',
data: data, data: data,
method:'get' method: 'get'
}) })
}
//支付宝支付
const aliPay = (data) => {
return request({
url: 'mall/pay/' + data.order_no + '/alipay',
data: data,
method: 'get'
})
} }
// EB支付 // EB支付
const ebPay = (data) => { const ebPay = (data) => {
return request({ return request({
url: 'mall/pay/' + data.order_no + '/eb' url: 'mall/pay/' + data.order_no + '/eb'
}) })
} }
export { export {
buy, buy,
eb, eb,
wxPay, wxPay,
aliPay,
ebPay 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-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> <u-icon v-else name="checkmark-circle-fill" color="#8b64fd" size="50"></u-icon>
</view> </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-select-item" @click="selectPay('1')">
<view class="pay-left"> <view class="pay-left">
<u-icon class="wx-icon" name="integral-fill" color="#fff" size="40"></u-icon> <u-icon class="wx-icon" name="integral-fill" color="#fff" size="40"></u-icon>
@@ -98,6 +109,7 @@
} from '@/apis/interfaces/goods' } from '@/apis/interfaces/goods'
import { import {
wxPay, wxPay,
aliPay,
ebPay ebPay
} from '@/apis/interfaces/order' } from '@/apis/interfaces/order'
export default { export default {
@@ -177,6 +189,12 @@
order_no: this.order_no, order_no: this.order_no,
type: 'app' type: 'app'
} }
} else if (this.selectTypeId === '3') {
apiUrl = aliPay
data = {
order_no: this.order_no,
type: 'app'
}
} else { } else {
apiUrl = ebPay apiUrl = ebPay
data = { data = {
@@ -184,6 +202,9 @@
} }
} }
apiUrl(data).then(res => { apiUrl(data).then(res => {
console.log(res)
debugger;
// 微信支付
if (this.selectTypeId === '2') { if (this.selectTypeId === '2') {
if (typeof res === 'string') { if (typeof res === 'string') {
let payInfo = JSON.parse(res) let payInfo = JSON.parse(res)
@@ -234,6 +255,56 @@
}, 3000); }, 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 => { }).catch(err => {
uni.showToast({ uni.showToast({
title: err.message, title: err.message,
@@ -276,6 +347,8 @@
} }
} else if (id === '2') { } else if (id === '2') {
this.selectTypeId = id this.selectTypeId = id
} else if (id === '3') {
this.selectTypeId = id
} }
}, },

View File

@@ -1,101 +1,102 @@
<template> <template>
<view class="PayStatus"> <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'"
<view class="payTitle">{{success?'支付成功':'支付失败'}}</view> mode="widthFix" />
<view class="payDes">{{success?'您已支付完成,订单稍后配送':'吼吼,您的支付未完成'}}</view> <view class="payTitle">{{success?'支付成功':'支付失败'}}</view>
<view class="payBackCheck"> <view class="payDes">{{success?'您已支付完成,订单稍后配送':'吼吼,您的支付未完成'}}</view>
<!-- <view class="check" v-if='success' @click="check">查看权证</view> --> <view class="payBackCheck">
<view class="back" @click="back">返回首页</view> <!-- <view class="check" v-if='success' @click="check">查看权证</view> -->
</view> <view class="back" @click="back">返回首页</view>
</view> </view>
</view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
success:false,// 支付失败false 支付成功true success: false, // 支付失败false 支付成功true
}; };
}, },
onLoad(e) { onLoad(e) {
if(e.success === 'true'){ if (e.success === 'true') {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title:'支付成功' title: '支付成功'
}) })
this.success=true this.success = true
}else{ } else {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title:'支付失败' title: '支付失败'
}) })
this.success=false this.success = false
}
},
methods: {
check() {
uni.reLaunch({
url: '/pages/property/order/numberWeight'
})
},
back() {
uni.reLaunch({
url: '/pages/equity/index'
})
}
} }
}, }
methods: {
check() {
uni.reLaunch({
url:'/pages/property/order/numberWeight'
})
},
back() {
uni.reLaunch({
url:'/pages/equity/index'
})
}
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.PayStatus { .PayStatus {
width: 100%; width: 100%;
min-height: 100vh; min-height: 100vh;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: flex-start; justify-content: flex-start;
box-sizing: border-box; box-sizing: border-box;
.payStatusImg { .payStatusImg {
width: 300rpx; width: 300rpx;
padding: 50rpx 0; padding: 50rpx 0;
margin-top: 100rpx; margin-top: 100rpx;
} }
.payTitle { .payTitle {
font-size: 34rpx; font-size: 34rpx;
font-weight: bold; font-weight: bold;
color: #353535; color: #353535;
} }
.payDes { .payDes {
font-size: 26rpx; font-size: 26rpx;
color: #666; color: #666;
padding: 20rpx; padding: 20rpx;
margin-bottom: 30rpx; margin-bottom: 30rpx;
} }
.payBackCheck { .payBackCheck {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: space-around; justify-content: space-around;
box-sizing: border-box; box-sizing: border-box;
font-size: 28rpx; font-size: 28rpx;
width: 100%; width: 100%;
.check { .check {
border: $main-color solid 1rpx; border: $main-color solid 1rpx;
color: $main-color; color: $main-color;
padding: 14rpx 50rpx; padding: 14rpx 50rpx;
border-radius: 4rpx; border-radius: 4rpx;
} }
.back { .back {
background-color: $main-color; background-color: $main-color;
color: #fff; color: #fff;
padding: 14rpx 50rpx; padding: 14rpx 50rpx;
border-radius: 4rpx; border-radius: 4rpx;
} }
} }
} }
</style> </style>

View File

@@ -14944,27 +14944,86 @@ var render = function() {
}) })
], ],
1 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( _c(
"view", "view",
{ staticClass: _vm._$s(33, "sc", "actions"), attrs: { _i: 33 } }, { staticClass: _vm._$s(40, "sc", "actions"), attrs: { _i: 40 } },
[ [
_c( _c(
"view", "view",
{ staticClass: _vm._$s(34, "sc", "title"), attrs: { _i: 34 } }, { staticClass: _vm._$s(41, "sc", "title"), attrs: { _i: 41 } },
[ [
_c( _c(
"span", "span",
{ staticClass: _vm._$s(35, "sc", "money"), attrs: { _i: 35 } }, { staticClass: _vm._$s(42, "sc", "money"), attrs: { _i: 42 } },
[_vm._v(_vm._$s(35, "t0-0", _vm._s(_vm.total)))] [_vm._v(_vm._$s(42, "t0-0", _vm._s(_vm.total)))]
) )
] ]
), ),
_c("view", { _c("view", {
staticClass: _vm._$s(36, "sc", "nowPay"), staticClass: _vm._$s(43, "sc", "nowPay"),
attrs: { _i: 36 }, attrs: { _i: 43 },
on: { click: _vm.order } on: { click: _vm.order }
}) })
] ]
@@ -14972,9 +15031,9 @@ var render = function() {
_c( _c(
"u-popup", "u-popup",
{ {
attrs: { mode: "bottom", "border-radius": "14", _i: 37 }, attrs: { mode: "bottom", "border-radius": "14", _i: 44 },
model: { model: {
value: _vm._$s(37, "v-model", _vm.showCouponList), value: _vm._$s(44, "v-model", _vm.showCouponList),
callback: function($$v) { callback: function($$v) {
_vm.showCouponList = $$v _vm.showCouponList = $$v
}, },
@@ -14984,33 +15043,33 @@ var render = function() {
[ [
_c( _c(
"scroll-view", "scroll-view",
{ staticClass: _vm._$s(38, "sc", "scrollView"), attrs: { _i: 38 } }, { staticClass: _vm._$s(45, "sc", "scrollView"), attrs: { _i: 45 } },
[ [
_c("view", { _c("view", {
staticClass: _vm._$s(39, "sc", "coupon-title"), staticClass: _vm._$s(46, "sc", "coupon-title"),
attrs: { _i: 39 } attrs: { _i: 46 }
}), }),
_vm._l(_vm._$s(40, "f", { forItems: _vm.list }), function( _vm._l(_vm._$s(47, "f", { forItems: _vm.list }), function(
item, item,
index, index,
$20, $20,
$30 $30
) { ) {
return _vm._$s("40-" + $30, "i", _vm.list.length > 0) return _vm._$s("47-" + $30, "i", _vm.list.length > 0)
? _c( ? _c(
"view", "view",
{ {
key: _vm._$s(40, "f", { forIndex: $20, key: index }), key: _vm._$s(47, "f", { forIndex: $20, key: index }),
staticClass: _vm._$s( staticClass: _vm._$s(
"40-" + $30, "47-" + $30,
"sc", "sc",
"coupon-list-item" "coupon-list-item"
), ),
attrs: { _i: "40-" + $30 } attrs: { _i: "47-" + $30 }
}, },
[ [
_vm._$s( _vm._$s(
"41-" + $30, "48-" + $30,
"i", "i",
_vm.coupon_grant_id !== item.coupon_grant_id _vm.coupon_grant_id !== item.coupon_grant_id
) )
@@ -15019,7 +15078,7 @@ var render = function() {
name: "checkmark-circle", name: "checkmark-circle",
color: "#cacaca", color: "#cacaca",
size: "50", size: "50",
_i: "41-" + $30 _i: "48-" + $30
} }
}) })
: _c("u-icon", { : _c("u-icon", {
@@ -15027,23 +15086,23 @@ var render = function() {
name: "checkmark-circle-fill", name: "checkmark-circle-fill",
color: "#8b64fd", color: "#8b64fd",
size: "50", size: "50",
_i: "42-" + $30 _i: "49-" + $30
} }
}), }),
_c("couponTemplate", { _c("couponTemplate", {
attrs: { attrs: {
item: Object.assign({}, item), item: Object.assign({}, item),
showUse: false, showUse: false,
_i: "43-" + $30 _i: "50-" + $30
} }
}), }),
_c("view", { _c("view", {
staticClass: _vm._$s( staticClass: _vm._$s(
"44-" + $30, "51-" + $30,
"sc", "sc",
"coupon-list-item" "coupon-list-item"
), ),
attrs: { _i: "44-" + $30 }, attrs: { _i: "51-" + $30 },
on: { on: {
click: function($event) { click: function($event) {
return _vm.selectCoupon(item) return _vm.selectCoupon(item)
@@ -15055,12 +15114,12 @@ var render = function() {
) )
: _vm._e() : _vm._e()
}), }),
_vm._$s(45, "i", _vm.list.length === 0) _vm._$s(52, "i", _vm.list.length === 0)
? _c("no-list", { ? _c("no-list", {
attrs: { attrs: {
name: "no-counpon", name: "no-counpon",
txt: "没有任何可用券哦", txt: "没有任何可用券哦",
_i: 45 _i: 52
} }
}) })
: _vm._e() : _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 1
) )
@@ -17227,7 +17286,18 @@ __webpack_require__.r(__webpack_exports__);
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "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: { var _default = { name: 'OrderInfo', components: { couponTemplate: _couponTemplate.default }, data: function data() {return { // box: {
// min: 1, // min: 1,
// max: 100 // max: 100
@@ -17437,9 +17518,8 @@ var _default = { name: 'OrderInfo', components: { couponTemplate: _couponTemplat
}, methods: { // 确认商品详情页get下单页面post }, 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 });});}, // 提交订单 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');}, // 触发支付 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; // 微信支付
icon: 'none' }); 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 () { setTimeout(function () {
uni.reLaunch({ uni.reLaunch({
url: '/pages/goods/payStatus?success=false' }); url: '/pages/goods/payStatus?success=false' });
@@ -17463,6 +17543,56 @@ var _default = { name: 'OrderInfo', components: { couponTemplate: _couponTemplat
}, 3000); }, 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 () {
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);
}
}
}).catch(function (err) { }).catch(function (err) {
uni.showToast({ uni.showToast({
title: err.message, title: err.message,
@@ -17505,8 +17635,11 @@ var _default = { name: 'OrderInfo', components: { couponTemplate: _couponTemplat
} }
} else if (id === '2') { } else if (id === '2') {
this.selectTypeId = id; this.selectTypeId = id;
} else if (id === '3') {
this.selectTypeId = id;
} }
} } };exports.default = _default; } } };exports.default = _default;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/vue-cli-plugin-uni/lib/format-log.js */ 39)["default"]))
/***/ }), /***/ }),
/* 149 */ /* 149 */
@@ -17936,8 +18069,7 @@ exports.exchangeGoods = exchangeGoods;var getQrcodeByGrantId = function getQrcod
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {
"use strict"; "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: 订单 * 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 }); 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支付 // EB支付
exports.wxPay = wxPay;var ebPay = function ebPay(data) { exports.aliPay = aliPay;var ebPay = function ebPay(data) {
return (0, _index.request)({ return (0, _index.request)({
url: 'mall/pay/' + data.order_no + '/eb' }); url: 'mall/pay/' + data.order_no + '/eb' });
@@ -18155,6 +18298,7 @@ Object.defineProperty(exports, "__esModule", { value: true });exports.default =
// //
// //
// //
//
var _default = var _default =
{ {
data: function data() { data: function data() {