智能柜扫码钱包余额检查和开门授权
This commit is contained in:
1 parent
7af87b8e80
commit
19934052da
5 files changed
+133
-15
No files matched your search
+88
-12
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<crud-layout bg="/static/page/blue-bg.png">
|
||||
<view class="bg-white rounded-16rpx my-40rpx animate-both">
|
||||
<view class="bg-white rounded-16rpx mx-2 my-40rpx animate-both">
|
||||
<z-tabs
|
||||
:list="[
|
||||
{ name: '浙政钉支付', value: 1 },
|
||||
@@ -23,7 +23,7 @@
|
||||
:inactive-style="{
|
||||
width: '300rpx',
|
||||
height: '70rpx',
|
||||
color: '#ffffff',
|
||||
color: '#000000',
|
||||
textAlign: 'center',
|
||||
lineHeight: '70rpx',
|
||||
fontWeight: 'light',
|
||||
@@ -35,9 +35,9 @@
|
||||
/>
|
||||
</view>
|
||||
|
||||
<tm-sheet v-if="true" borderWidth="2" margin="40" padding="10" color="#0094FF22">
|
||||
<tm-sheet v-if="!state.isUseDoor && state.isUseDoorTip" borderWidth="2" margin="40" padding="10" color="#0094FF22">
|
||||
<view class="flex items-center justify-between pl-4">
|
||||
<tm-text font-size="30 " color="#0779FD">钱包余额不足100元</tm-text>
|
||||
<tm-text font-size="30 " color="#0779FD">{{ state.isUseDoorTip }}</tm-text>
|
||||
<tm-button size="m" @click="goRecharge">去充值</tm-button>
|
||||
</view>
|
||||
</tm-sheet>
|
||||
@@ -69,30 +69,73 @@
|
||||
|
||||
<template #main-bottom>
|
||||
<view class="m-30rpx">
|
||||
<tm-button block @click="openDoor" :disabled="state.disabled">开 门</tm-button>
|
||||
<tm-button block @click="openDoor" :disabled="!state.isUseDoor">开 门</tm-button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<tm-modal
|
||||
v-model:show="state.show"
|
||||
:overlayClick="false"
|
||||
title="你是否同意授权"
|
||||
position="bottom"
|
||||
:showCancel="true"
|
||||
height="800rpx"
|
||||
cancelText="拒绝"
|
||||
confirmText="同意"
|
||||
@confirm="appAuthHardDoorConfirm"
|
||||
>
|
||||
<tm-text color="#999999">{{ state.authDesc }}</tm-text>
|
||||
</tm-modal>
|
||||
</crud-layout>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive } from "vue"
|
||||
import { onLoad } from "@dcloudio/uni-app"
|
||||
import { onLoad, onShow } from "@dcloudio/uni-app"
|
||||
import zTabs from "@@/components/other/z-tabs/z-tabs.vue"
|
||||
import { router } from "@/sheep"
|
||||
import walletApi from "@/sheep/api/wallet"
|
||||
import hardApi from "@/sheep/api/hard"
|
||||
|
||||
const state = reactive({
|
||||
disabled: true,
|
||||
isUseDoor: false,
|
||||
isUseDoorTip: "",
|
||||
show: false,
|
||||
hardDoorId: "",
|
||||
cabinetNo: "",
|
||||
authDesc: "",
|
||||
authId: "",
|
||||
})
|
||||
|
||||
onLoad((options: any) => {
|
||||
if (!options) return
|
||||
const { hardDoorId, cabinetNo } = options
|
||||
if (!hardDoorId || !cabinetNo) return
|
||||
state.hardDoorId = hardDoorId
|
||||
state.cabinetNo = cabinetNo
|
||||
})
|
||||
|
||||
onShow(async () => {
|
||||
// 检查钱包余额
|
||||
|
||||
state.disabled = false
|
||||
try {
|
||||
uni.showLoading({ title: "加载中", mask: true })
|
||||
const res = await walletApi.isUseDoor()
|
||||
if (res.code == 0) {
|
||||
if (res.data) {
|
||||
state.isUseDoor = false
|
||||
state.isUseDoorTip = res.data
|
||||
} else {
|
||||
state.isUseDoor = true
|
||||
}
|
||||
return
|
||||
}
|
||||
state.isUseDoor = false
|
||||
} catch (error: any) {
|
||||
uni.showToast({ title: error, icon: "none" })
|
||||
state.isUseDoor = false
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
})
|
||||
|
||||
// 去充值
|
||||
@@ -101,11 +144,44 @@ const goRecharge = () => {
|
||||
}
|
||||
|
||||
// 开门
|
||||
const openDoor = () => {
|
||||
if (state.disabled) return
|
||||
console.log("芝麻开门")
|
||||
const openDoor = async () => {
|
||||
if (!state.isUseDoor) return
|
||||
|
||||
// 获取协议内容
|
||||
try {
|
||||
uni.showLoading({ title: "加载中", mask: true })
|
||||
const res = await hardApi.appGetAuthHardDoor({ doorHardId: state.hardDoorId, cabinetNo: state.cabinetNo })
|
||||
if (res.code == 0) {
|
||||
state.show = true
|
||||
state.authDesc = res.data.authDesc
|
||||
state.authId = res.data.authId
|
||||
}
|
||||
} catch (error: any) {
|
||||
uni.showToast({ title: error, icon: "none" })
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
// 支付方式tab改变
|
||||
const payMethodTabChange = (e: number) => {}
|
||||
|
||||
// 确认协议
|
||||
const appAuthHardDoorConfirm = async () => {
|
||||
try {
|
||||
uni.showLoading({ title: "授权中", mask: true })
|
||||
const res = await hardApi.appAuthHardDoor({
|
||||
authId: state.authId,
|
||||
authStatus: 1,
|
||||
})
|
||||
if (res.code == 0) {
|
||||
uni.showToast({ title: "授权成功", icon: "none" })
|
||||
state.show = false
|
||||
}
|
||||
} catch (error: any) {
|
||||
uni.showToast({ title: error, icon: "none" })
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -249,8 +249,6 @@ const scanCode = {
|
||||
usePayStore().setPayData({})
|
||||
try {
|
||||
const decodedString = await scanCode.getScanResult()
|
||||
console.log("二维码解码结果:", decodedString)
|
||||
|
||||
if (decodedString) {
|
||||
scanCode.processScanResult(decodedString)
|
||||
}
|
||||
@@ -314,7 +312,9 @@ const scanCode = {
|
||||
}
|
||||
const decoder = new TextDecoder("utf-8")
|
||||
const decodedString = decoder.decode(uint8Array)
|
||||
console.log("解码结果", decodedString)
|
||||
|
||||
// console.log("解码结果", decodedString)
|
||||
|
||||
return decodedString
|
||||
} catch (error) {
|
||||
console.error("Base64 解码失败:", error)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import request from "@/sheep/utils/request"
|
||||
|
||||
export default {
|
||||
appGetAuthHardDoor: (data: { doorHardId: any; cabinetNo: any }): Promise<any> =>
|
||||
request({
|
||||
url: "hard/hard-auth/app/get-auth-hard-door",
|
||||
method: "POST",
|
||||
data,
|
||||
custom: {
|
||||
showLoading: false,
|
||||
},
|
||||
}),
|
||||
/**
|
||||
* app获取智能柜授权信息
|
||||
* @param authId 授权id
|
||||
* @param authStatus 是否授权
|
||||
* @returns
|
||||
*/
|
||||
appAuthHardDoor: (data: { authId: any; authStatus: any }): Promise<any> =>
|
||||
request({
|
||||
url: "hard/hard-auth/app/auth-hard-door",
|
||||
method: "POST",
|
||||
data,
|
||||
custom: {
|
||||
showLoading: false,
|
||||
},
|
||||
}),
|
||||
}
|
||||
@@ -27,3 +27,5 @@ export { default as shopApi } from "./shop"
|
||||
export { default as flowStatisticsApi } from "./flowStatistics"
|
||||
|
||||
export { default as individualOrderApi } from "./individualOrder"
|
||||
|
||||
export { default as hardApi } from "./hard"
|
||||
@@ -90,4 +90,16 @@ export default {
|
||||
showLoading: false,
|
||||
},
|
||||
}),
|
||||
/**
|
||||
* 是够能够使用智能柜
|
||||
*/
|
||||
isUseDoor: (): Promise<any> =>
|
||||
request({
|
||||
url: "wallet/wallet-manage/app/is-use-door",
|
||||
method: "GET",
|
||||
data: {},
|
||||
custom: {
|
||||
showLoading: false,
|
||||
},
|
||||
}),
|
||||
}
|
||||
Reference in new issue
Block a user