diff --git a/apis/interfaces/order.js b/apis/interfaces/order.js index b23871a..ffcfb75 100644 --- a/apis/interfaces/order.js +++ b/apis/interfaces/order.js @@ -1,4 +1,3 @@ - /** * Web唐明明 * 匆匆数载恍如梦,岁月迢迢华发增。 @@ -6,7 +5,9 @@ * moduleName: 订单 */ -import { request } from '../index' +import { + request +} from '../index' // 创建,确认订单 const buy = (data, method) => { @@ -26,22 +27,32 @@ const eb = (no) => { // 微信支付 const wxPay = (data) => { - return request({ - url: 'mall/pay/' + data.order_no + '/wechat', - data: data, - method:'get' - }) + return request({ + url: 'mall/pay/' + data.order_no + '/wechat', + data: data, + method: 'get' + }) +} + +//支付宝支付 +const aliPay = (data) => { + return request({ + url: 'mall/pay/' + data.order_no + '/alipay', + data: data, + method: 'get' + }) } // EB支付 const ebPay = (data) => { - return request({ - url: 'mall/pay/' + data.order_no + '/eb' - }) + return request({ + url: 'mall/pay/' + data.order_no + '/eb' + }) } export { buy, eb, wxPay, + aliPay, ebPay } diff --git a/pages/goods/confirmOrder.vue b/pages/goods/confirmOrder.vue index 91ff876..ade69fc 100644 --- a/pages/goods/confirmOrder.vue +++ b/pages/goods/confirmOrder.vue @@ -48,6 +48,17 @@ + + + + + 支付宝支付 + 推荐支付宝用户使用 + + + + + - 返回首页 - - + + + {{success?'支付成功':'支付失败'}} + {{success?'您已支付完成,订单稍后配送':'吼吼,您的支付未完成'}} + + + 返回首页 + + diff --git a/unpackage/dist/dev/app-plus/app-service.js b/unpackage/dist/dev/app-plus/app-service.js index dac67d6..4b3250a 100644 --- a/unpackage/dist/dev/app-plus/app-service.js +++ b/unpackage/dist/dev/app-plus/app-service.js @@ -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,9 +17518,8 @@ 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, - icon: 'none' }); - + 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' }); @@ -17463,6 +17543,56 @@ var _default = { name: 'OrderInfo', components: { couponTemplate: _couponTemplat }, 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) { uni.showToast({ title: err.message, @@ -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() {