测试支付

This commit is contained in:
weiwei committed 2025-03-20 17:09:23 +08:00
1 parent d2cb43d063
commit 6fcbd00d73
5 files changed
+62 -13

No files matched your search

+11 -12
View File
@@ -1,18 +1,17 @@
import { createSSRApp } from "vue";
import "uno.css";
import * as Pinia from "pinia";
import { createSSRApp } from "vue"
import "uno.css"
import pinia from "../src/sheep/stores/index"
import App from "./App.vue";
import tmUi from "./uni_modules/tm-ui";
import App from "./App.vue"
import tmUi from "./uni_modules/tm-ui"
export function createApp() {
const app = createSSRApp(App);
const app = createSSRApp(App)
app.use(Pinia.createPinia());
app.use(tmUi);
app.use(pinia)
app.use(tmUi)
return {
app,
Pinia,
};
return {
app,
}
}
+28 -1
View File
@@ -8,7 +8,7 @@
<span class="text-3xl font-medium text-[#333]">{{ displayAmount }}</span>
</tm-sheet>
<tm-button class="mt-40" :block="true" @click="">支付</tm-button>
<tm-button class="mt-40" :block="true" @click="disabled ? '' : handlePay()" :disabled="disabled">支付</tm-button>
<view class="bg-[#f5f5f5] px-1 py-2 rounded-4 absolute bottom-0 w-full">
<view class="flex mb-2.5" v-for="(row, rowIndex) in keyboardLayout" :key="rowIndex">
@@ -72,6 +72,8 @@
</template>
<script setup lang="ts">
import { usePayStore } from "@/sheep/stores/pay"
import { onShow } from "@dcloudio/uni-app"
import { ref, computed } from "vue"
const amount = ref("")
@@ -80,6 +82,18 @@ const keyboardLayout = ref([
["4", "5", "6"],
["7", "8", "9"],
])
const scanData = ref("")
const disabled = ref(false)
onShow(() => {
scanData.value = usePayStore().payData
if (scanData.value) {
uni.showToast({ title: `扫码成功:${scanData.value}`, icon: "none" })
} else {
uni.showToast({ title: "扫码信息不存在", icon: "none" })
disabled.value = true
}
})
const displayAmount = computed(() => {
if (!amount.value) return "0.00"
@@ -108,4 +122,17 @@ const handleKeyPress = (key) => {
const handleDelete = () => {
amount.value = amount.value.slice(0, -1)
}
// 点击支付
const handlePay = () => {
if (!amount.value) {
uni.showToast({ title: "请输入金额", icon: "none" })
return
}
if (Number(amount.value) === 0) {
uni.showToast({ title: "金额不能为0", icon: "none" })
return
}
uni.showToast({ title: "支付中。。。", icon: "none" })
}
</script>
+1
View File
@@ -185,6 +185,7 @@ const doScanCode = async () => {
title: res,
icon: "none",
})
router.jump("/pages/pay/scanPay", { query: { data: JSON.stringify(res) } })
} catch (error: any) {
uni.showToast({
title: error,
+8
View File
@@ -0,0 +1,8 @@
// https://pinia.vuejs.org/
import { createPinia } from "pinia"
// 创建
const pinia = createPinia()
// 导出
export default pinia
+14
View File
@@ -0,0 +1,14 @@
import { defineStore } from "pinia"
export const usePayStore = defineStore("pay", {
state: () => {
return {
payData: "",
}
},
actions: {
setPayData(data: any) {
this.payData = data
},
},
})