配置智能柜锁
This commit is contained in:
parent
a42638c17b
commit
52a0b9761b
4
.env
4
.env
|
@ -1,10 +1,10 @@
|
||||||
# 所有环境的环境变量(命名必须以 VITE_ 开头)
|
# 所有环境的环境变量(命名必须以 VITE_ 开头)
|
||||||
|
|
||||||
## 项目标题
|
## 项目标题
|
||||||
VITE_APP_TITLE = 微商店
|
VITE_APP_TITLE = 借还柜
|
||||||
|
|
||||||
## 路由模式 hash 或 html5
|
## 路由模式 hash 或 html5
|
||||||
VITE_ROUTER_HISTORY = hash
|
VITE_ROUTER_HISTORY = hash
|
||||||
|
|
||||||
## 是否开启 console 调试工具
|
## 是否开启 console 调试工具
|
||||||
VITE_CONSOLE = true
|
VITE_CONSOLE = false
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
],
|
],
|
||||||
"marscode.chatLanguage": "cn",
|
"marscode.chatLanguage": "cn",
|
||||||
"marscode.codeCompletionPro": {
|
"marscode.codeCompletionPro": {
|
||||||
"enableCodeCompletionPro": true
|
"enableCodeCompletionPro": false
|
||||||
},
|
},
|
||||||
"marscode.enableInlineCommand": true
|
"marscode.enableInlineCommand": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { request } from "@/http/axios"
|
import { request } from "@/http/axios"
|
||||||
import { ShopGoodsResponseData, SubmitOrderRequestData, SubmitOrderResponseData } from './type'
|
import { GetOrdersByOpenIdDTO, ShopGoodsResponseData, SubmitOrderRequestData, SubmitOrderResponseData } from './type'
|
||||||
import { GetOpenIdRequestParams } from './type'
|
import { GetOpenIdRequestParams } from './type'
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,9 +22,17 @@ export function submitOrderApi(data: SubmitOrderRequestData) {
|
||||||
|
|
||||||
/** 获取微信openid */
|
/** 获取微信openid */
|
||||||
export function getOpenIdApi(params: GetOpenIdRequestParams) {
|
export function getOpenIdApi(params: GetOpenIdRequestParams) {
|
||||||
return request<string>({
|
return request<ApiResponseData<string>>({
|
||||||
url: "payment/getOpenId",
|
url: "payment/getOpenId",
|
||||||
method: "get",
|
method: "get",
|
||||||
params // 使用params传递code参数,对应Java的@RequestParam
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 根据openid获取用户订单信息 */
|
||||||
|
export function getOrdersByOpenIdApi(openid: string) {
|
||||||
|
return request<ApiResponseData<GetOrdersByOpenIdDTO>>({
|
||||||
|
url: `order/user/${openid}`,
|
||||||
|
method: "get"
|
||||||
})
|
})
|
||||||
}
|
}
|
|
@ -38,8 +38,7 @@ export interface WxJsApiPreCreateResponse {
|
||||||
appId: string
|
appId: string
|
||||||
timeStamp: string
|
timeStamp: string
|
||||||
nonceStr: string
|
nonceStr: string
|
||||||
/** @JsonProperty("package") */
|
package: string
|
||||||
packageValue: string
|
|
||||||
signType: string
|
signType: string
|
||||||
paySign: string
|
paySign: string
|
||||||
}
|
}
|
||||||
|
@ -47,3 +46,29 @@ export interface WxJsApiPreCreateResponse {
|
||||||
export interface GetOpenIdRequestParams {
|
export interface GetOpenIdRequestParams {
|
||||||
code: string
|
code: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ShopOrderEntity {
|
||||||
|
orderId: number
|
||||||
|
openid: string
|
||||||
|
totalAmount: number
|
||||||
|
status: number
|
||||||
|
payStatus: number
|
||||||
|
paymentMethod: string
|
||||||
|
payTime: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ShopOrderGoodsEntity {
|
||||||
|
orderGoodsId: number
|
||||||
|
orderId: number
|
||||||
|
goodsId: number
|
||||||
|
quantity: number
|
||||||
|
price: number
|
||||||
|
totalAmount: number
|
||||||
|
status: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetOrdersByOpenIdDTO {
|
||||||
|
orders: ShopOrderEntity[]
|
||||||
|
orderGoods: ShopOrderGoodsEntity[]
|
||||||
|
goods: Goods[]
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
|
const orderId = route.query.orderId as any
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function backToHome() {
|
||||||
|
router.push('/')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="success-container">
|
||||||
|
<van-nav-bar title="支付成功" left-arrow @click-left="backToHome" />
|
||||||
|
|
||||||
|
<div class="content-wrapper">
|
||||||
|
<van-cell-group class="success-info">
|
||||||
|
<van-cell title="订单号" :value="orderId" class="orderid-cell" />
|
||||||
|
</van-cell-group>
|
||||||
|
|
||||||
|
<div class="action-buttons">
|
||||||
|
<van-button
|
||||||
|
type="primary"
|
||||||
|
block
|
||||||
|
@click="backToHome"
|
||||||
|
class="home-button"
|
||||||
|
>
|
||||||
|
返回首页
|
||||||
|
</van-button>
|
||||||
|
<van-button
|
||||||
|
type="default"
|
||||||
|
block
|
||||||
|
class="detail-button"
|
||||||
|
>
|
||||||
|
查看订单详情
|
||||||
|
</van-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.success-container {
|
||||||
|
padding: 12px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-wrapper {
|
||||||
|
padding-top: 46px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-info {
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-cell :deep(.van-cell__value) {
|
||||||
|
color: #07c160;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-buttons {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 30px;
|
||||||
|
left: 16px;
|
||||||
|
right: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-button {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -28,9 +28,9 @@ function callWxJsApi(paymentInfo: WxJsApiPreCreateResponse) {
|
||||||
appId: paymentInfo.appId,
|
appId: paymentInfo.appId,
|
||||||
timeStamp: paymentInfo.timeStamp,
|
timeStamp: paymentInfo.timeStamp,
|
||||||
nonceStr: paymentInfo.nonceStr,
|
nonceStr: paymentInfo.nonceStr,
|
||||||
package: paymentInfo.packageValue.startsWith('prepay_id=')
|
package: paymentInfo.package.startsWith('prepay_id=')
|
||||||
? paymentInfo.packageValue
|
? paymentInfo.package
|
||||||
: `prepay_id=${paymentInfo.packageValue}`,
|
: `prepay_id=${paymentInfo.package}`,
|
||||||
signType: paymentInfo.signType,
|
signType: paymentInfo.signType,
|
||||||
paySign: paymentInfo.paySign
|
paySign: paymentInfo.paySign
|
||||||
},
|
},
|
||||||
|
@ -81,16 +81,21 @@ async function handleSubmit() {
|
||||||
// 调用提交订单接口
|
// 调用提交订单接口
|
||||||
const { data } = await submitOrderApi(requestData)
|
const { data } = await submitOrderApi(requestData)
|
||||||
|
|
||||||
await showConfirmDialog({
|
// await showConfirmDialog({
|
||||||
title: "提交成功",
|
// title: "提交成功",
|
||||||
message: `订单号:${data.orderId},正在跳转支付...`
|
// message: `订单号:${data.orderId},正在跳转支付...`
|
||||||
})
|
// })
|
||||||
|
|
||||||
// 调用微信支付
|
// 调用微信支付
|
||||||
if (data.paymentInfo) {
|
if (data.paymentInfo) {
|
||||||
await callWxJsApi(data.paymentInfo);
|
await callWxJsApi(data.paymentInfo);
|
||||||
// 支付成功后跳转
|
// 支付成功后跳转
|
||||||
router.push('/order-success');
|
router.push({
|
||||||
|
path: '/order-success',
|
||||||
|
query: {
|
||||||
|
orderId: data.orderId
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
throw new Error('无法获取支付信息');
|
throw new Error('无法获取支付信息');
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,8 @@ export const useWxStore = defineStore("wx", () => {
|
||||||
// 调用获取 openid 的接口
|
// 调用获取 openid 的接口
|
||||||
const res = await getOpenIdApi({ code: params.code })
|
const res = await getOpenIdApi({ code: params.code })
|
||||||
console.log('获取 openid 成功:', res)
|
console.log('获取 openid 成功:', res)
|
||||||
if (res) {
|
if (res && res.code == 0) {
|
||||||
openid.value = res
|
openid.value = res.data
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('获取 openid 失败:', err)
|
console.error('获取 openid 失败:', err)
|
||||||
|
|
|
@ -29,6 +29,14 @@ export const systemRoutes: RouteRecordRaw[] = [
|
||||||
|
|
||||||
/** 业务页面 */
|
/** 业务页面 */
|
||||||
export const routes: RouteRecordRaw[] = [
|
export const routes: RouteRecordRaw[] = [
|
||||||
|
{
|
||||||
|
path: '/order-success',
|
||||||
|
name: 'OrderSuccess',
|
||||||
|
component: () => import('@/pages/order/Success.vue'),
|
||||||
|
meta: {
|
||||||
|
requiresAuth: true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/product/checkout",
|
path: "/product/checkout",
|
||||||
component: () => import("@/pages/product/components/checkout.vue"),
|
component: () => import("@/pages/product/components/checkout.vue"),
|
||||||
|
@ -55,6 +63,14 @@ export const routes: RouteRecordRaw[] = [
|
||||||
]
|
]
|
||||||
|
|
||||||
/* export const routes: RouteRecordRaw[] = [
|
/* export const routes: RouteRecordRaw[] = [
|
||||||
|
{
|
||||||
|
path: '/order-success',
|
||||||
|
name: 'OrderSuccess',
|
||||||
|
component: () => import('@/pages/order/Success.vue'),
|
||||||
|
meta: {
|
||||||
|
requiresAuth: true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/login",
|
path: "/login",
|
||||||
component: () => import("@/pages/login/index.vue"),
|
component: () => import("@/pages/login/index.vue"),
|
||||||
|
|
Loading…
Reference in New Issue