From d23ad0114fa4732408aedf24d881e7110a968554 Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Mon, 15 Apr 2024 10:50:24 +0800 Subject: [PATCH] 1 --- api/product.js | 16 +++++++ pages/cashier/cashier.vue | 97 ++++++++++++++++++++++++++++++++++----- 2 files changed, 101 insertions(+), 12 deletions(-) diff --git a/api/product.js b/api/product.js index ee62028..847fb7e 100644 --- a/api/product.js +++ b/api/product.js @@ -53,6 +53,22 @@ export function productLstApi(merId, data) { login: true }); } +/** + * 检测收银状态 + */ +export function micropayQueryApi(data) { + return request.get(`micropay_query`, data, { + login: true + }); +} +/** + * 支付失败后进行提单 + */ +export function orderLadingApi(data) { + return request.get(`order_lading`, data, { + login: true + }); +} /** * 商品列表 -- 删除 diff --git a/pages/cashier/cashier.vue b/pages/cashier/cashier.vue index d44447e..5ae0dea 100644 --- a/pages/cashier/cashier.vue +++ b/pages/cashier/cashier.vue @@ -85,7 +85,8 @@ {{loadTitle}} --> - + PC收银台网址: {{PC_URL}} + ¥{{selectCountPrice}} @@ -124,8 +125,7 @@ - + 平台订单 - - - + + + @@ -226,7 +226,8 @@ cartDel, cartProductAttr, createOrder, - getOrderConfirm + getOrderConfirm, + orderPay } from '@/api/order.js'; import { getCoupons, @@ -237,7 +238,9 @@ collectAll } from '@/api/store.js'; import { - productLstApi + productLstApi, + micropayQueryApi, + orderLadingApi } from "@/api/product.js"; import { getOrderList @@ -251,6 +254,7 @@ configMap } from '@/utils'; import { ENV } from "@/config/app.js" + import { Toast } from '../../libs/uniApi'; const app = getApp(); export default { props: { @@ -316,7 +320,7 @@ newData: {}, activeRouter: '', userInfo: '', - navTab: 2, + navTab: 1, orderList: [] }; }, @@ -661,6 +665,69 @@ updatePrice() { console.log('改价'); }, + // 重新支付 + reOrderPay(item) { + uni.scanCode({ + onlyFromCamera: true, + hideAlbum: true, + success: (res) => { + if (res.result) { + const regexWechat = /^(10|11|12|13|14|15)\d{16}$/; //微信条码正则 10-15开头18位 + const regexPay = /^(25|26|27|28|29|30)\d{14,22}$/; //支付宝条码正则 25-30开头16-24位 + let pay_type; + if (regexWechat.test(res.result)) pay_type = "micropay"; + else if (regexPay.test(res.result)) pay_type = "alipayBar"; + else { + return uni.showToast({ + icon: 'none', + title: '请输入正确的支付码' + }) + } + orderPay(item.group_order_id, { + type: pay_type, + auth_code: res.result + }).then(res => { + uni.showToast({ + title: '支付成功', + icon: 'success' + }) + }).catch(err => { + console.log(err); + Toast(err) + }) + } + } + }) + }, + // 检测支付状态 + micropayQuery(item) { + console.log(item); + micropayQueryApi({ + order_sn: item.order_sn + }).then(res => { + uni.showToast({ + title: '支付成功', + icon: 'success' + }) + }).catch(err => { + console.log(err); + Toast(err) + }) + }, + // 提单 + orderLading(item) { + orderLadingApi({ + order_sn: item.order_sn, + staff_id: this.$store.state.app.userInfo.service.service_id + }).then(res => { + console.log(res); + Toast(res.message); + this.changeNavTab(1); + }).catch(err => { + console.log(err); + Toast(err); + }) + }, // 添加购物车 scanShopCode() { productLstApi(this.$store.state.app.userInfo.service.mer_id, { @@ -670,6 +737,8 @@ staff_id: this.$store.state.app.userInfo.service.service_id }).then(({ data }) => { console.log(data); + }).catch(err => { + console.error(err); }) uni.scanCode({ success: (res) => { @@ -686,6 +755,7 @@ }, // 立即下单 subOrder: function(event) { + if (this.cartList.valid.length == 0) return Toast('请先添加商品') let selectValue = [] this.cartList.valid.forEach(el => { el.list.forEach(goods => { @@ -1065,7 +1135,8 @@ } }); }, - navTo(item){ + navTo(item) { + if (item.paid == 0) return Toast('订单未支付!'); uni.navigateTo({ url: `/pages/admin/orderDetail/index?id=${item.order_id}&mer_id=${this.userInfo.service.mer_id}` }) @@ -1690,11 +1761,13 @@ font-size: 26rpx; color: #777; } - .b-button{ + + .b-button { display: flex; justify-content: flex-end; margin-top: 20rpx; - button{ + + button { font-size: 26rpx; background-color: #2ec479; color: #fff;