diff --git a/src/App.vue b/src/App.vue index 75f3258..ab4bab0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -67,181 +67,179 @@ const tabbar = [ ] export default { - onLaunch() { + async onLaunch() { + if (isDevEnv()) return + console.log("环境判断") // 诗画浦江获取用户信息进行环境判断 - ;(window as any).CP2.getAppInfo().then(async (res) => { - if (res.code !== 0) { - // 不是诗画环境 - const launchParam = new URL(window.location.href).searchParams.get("launchParam") - console.log("app launch 启动路径参数", launchParam) - switch (launchParam) { - case "canteen": - uni.switchTab({ url: "/pages/tabbar/canteen" }) - break - case "selfMerchant": - uni.switchTab({ url: "/pages/tabbar/selfMerchant" }) - break - default: - break + const res = await (window as any).CP2.getAppInfo() + if (res.code == 0) { + // 不是诗画环境 + const launchParam = new URL(window.location.href).searchParams.get("launchParam") + console.log("app launch 启动路径参数", launchParam) + switch (launchParam) { + case "canteen": + uni.switchTab({ url: "/pages/tabbar/canteen" }) + break + case "selfMerchant": + uni.switchTab({ url: "/pages/tabbar/selfMerchant" }) + break + default: + break + } + } else { + // 是诗画环境 + const userRole = uni.getStorageSync("userRole") + if (userRole && userRole == "user") uni.switchTab({ url: "/pages/tabbar/coopMerchant" }) + if (userRole && userRole == "merchant") uni.switchTab({ url: "/pages/tabbar/individualOrder" }) + + const res = await user.isMerchant() + if (res.code == 0) { + if (res.data) { + return uni.redirectTo({ url: "/pages/user/userRole" }) + } else { + uni.setStorageSync("userRole", "user") + uni.switchTab({ url: "/pages/tabbar/coopMerchant" }) } } else { - // 是诗画环境 - const userRole = uni.getStorageSync("userRole") - if (userRole && userRole == "user") uni.switchTab({ url: "/pages/tabbar/coopMerchant" }) - if (userRole && userRole == "merchant") uni.switchTab({ url: "/pages/tabbar/individualOrder" }) - - const res = await user.isMerchant() - if (res.code == 0) { - if (res.data) { - return uni.redirectTo({ url: "/pages/user/userRole" }) - } else { - uni.setStorageSync("userRole", "user") - uni.switchTab({ url: "/pages/tabbar/coopMerchant" }) - } - } else { - uni.showToast({ title: "角色身份判断失败", icon: "none" }) - } + uni.showToast({ title: "角色身份判断失败", icon: "none" }) } - }) + } }, onShow() {}, onHide() {}, methods: { - _initTabbar() { - // const launchPath = uni.getLaunchOptionsSync().path - // console.log("启动路径", launchPath) + async _initTabbar() { + if (isDevEnv()) { + tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath, auth }, index) => { + uni.setTabBarItem({ + index, + pagePath, + text, + iconPath, + selectedIconPath, + visible: true, + }) + }) + return + } const launchParam = new URL(window.location.href).searchParams.get("launchParam") console.log("tabbar launch 启动路径参数", launchParam) // 诗画浦江获取用户信息进行环境判断 - ;(window as any).CP2.getAppInfo().then((res) => { - if (res.code == 0) { - // 不是诗画环境 - if (isDevEnv()) { - tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath, auth }, index) => { - uni.setTabBarItem({ - index, - pagePath, - text, - iconPath, - selectedIconPath, - visible: true, - }) + const res = await (window as any).CP2.getAppInfo() + if (res.code == 0) { + // 不是诗画环境 + switch (launchParam) { + case "canteen": + tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath }, index) => { + if (authPath.includes("pages/tabbar/canteen")) { + uni.setTabBarItem({ + index, + pagePath, + text, + iconPath, + selectedIconPath, + visible: true, + }) + } else { + uni.setTabBarItem({ + index, + pagePath, + text, + iconPath, + selectedIconPath, + visible: false, + }) + } }) - } else { - switch (launchParam) { - case "canteen": - tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath }, index) => { - if (authPath.includes("pages/tabbar/canteen")) { - uni.setTabBarItem({ - index, - pagePath, - text, - iconPath, - selectedIconPath, - visible: true, - }) - } else { - uni.setTabBarItem({ - index, - pagePath, - text, - iconPath, - selectedIconPath, - visible: false, - }) - } + break + case "selfMerchant": + tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath }, index) => { + if (authPath.includes("pages/tabbar/selfMerchant")) { + uni.setTabBarItem({ + index, + pagePath, + text, + iconPath, + selectedIconPath, + visible: true, }) - break - case "selfMerchant": - tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath }, index) => { - if (authPath.includes("pages/tabbar/selfMerchant")) { - uni.setTabBarItem({ - index, - pagePath, - text, - iconPath, - selectedIconPath, - visible: true, - }) - } else { - uni.setTabBarItem({ - index, - pagePath, - text, - iconPath, - selectedIconPath, - visible: false, - }) - } + } else { + uni.setTabBarItem({ + index, + pagePath, + text, + iconPath, + selectedIconPath, + visible: false, }) - break - default: - uni.hideTabBar() - uni.showToast({ title: "启动参数不合法", icon: "none" }) - break - } - } - } else { - // 是诗画环境 - const userRole = uni.getStorageSync("userRole") - switch (userRole) { - case "user": - tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath, auth }, index) => { - if (auth.includes("user")) { - uni.setTabBarItem({ - index, - pagePath, - text, - iconPath, - selectedIconPath, - visible: true, - }) - } else { - uni.setTabBarItem({ - index, - pagePath, - text, - iconPath, - selectedIconPath, - visible: false, - }) - } - }) - break - case "merchant": - tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath, auth }, index) => { - if (auth.includes("merchant")) { - uni.setTabBarItem({ - index, - pagePath, - text, - iconPath, - selectedIconPath, - visible: true, - }) - } else { - uni.setTabBarItem({ - index, - pagePath, - text, - iconPath, - selectedIconPath, - visible: false, - }) - } - }) - break - default: - uni.hideTabBar() - uni.showToast({ title: "用户身份未确认", icon: "none" }) - break - } + } + }) + break + default: + uni.hideTabBar() + uni.showToast({ title: "启动参数不合法", icon: "none" }) + break } - }) + } else { + // 是诗画环境 + const userRole = uni.getStorageSync("userRole") + switch (userRole) { + case "user": + tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath, auth }, index) => { + if (auth.includes("user")) { + uni.setTabBarItem({ + index, + pagePath, + text, + iconPath, + selectedIconPath, + visible: true, + }) + } else { + uni.setTabBarItem({ + index, + pagePath, + text, + iconPath, + selectedIconPath, + visible: false, + }) + } + }) + break + case "merchant": + tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath, auth }, index) => { + if (auth.includes("merchant")) { + uni.setTabBarItem({ + index, + pagePath, + text, + iconPath, + selectedIconPath, + visible: true, + }) + } else { + uni.setTabBarItem({ + index, + pagePath, + text, + iconPath, + selectedIconPath, + visible: false, + }) + } + }) + break + default: + uni.hideTabBar() + uni.showToast({ title: "用户身份未确认", icon: "none" }) + break + } + } }, }, } diff --git a/src/pages.json b/src/pages.json index b193088..d49c846 100644 --- a/src/pages.json +++ b/src/pages.json @@ -313,6 +313,13 @@ "navigationBarTitleText": "支付完成", "disableScroll": true } + }, + { + "path": "transferMoney", + "style": { + "navigationBarTitleText": "转账", + "disableScroll": true + } } ] } diff --git a/src/pages/pay/scanPay.vue b/src/pages/pay/scanPay.vue index 2ff1389..dffa552 100644 --- a/src/pages/pay/scanPay.vue +++ b/src/pages/pay/scanPay.vue @@ -9,63 +9,7 @@ 支付 - - - - {{ key }} - - - - - . - - - 0 - - - - - - - - - - + @@ -78,13 +22,9 @@ import payApi from "@@/api/pay" import { storePrice } from "@/sheep/utils/formatMoney" import { router } from "@/sheep" import { merchantApi } from "@/sheep/api" +import numberKeyboard from "@/sheep/components/numberKeyboard.vue" const amount = ref("") -const keyboardLayout = ref([ - ["1", "2", "3"], - ["4", "5", "6"], - ["7", "8", "9"], -]) const scanData = ref<{ id?: string; name?: string }>({}) const disabled = ref(false) @@ -113,27 +53,6 @@ const displayAmount = computed(() => { ) }) -// 按下键盘 -const handleKeyPress = (key) => { - if (key === "." && amount.value.includes(".")) return - if (key === "." && !amount.value) { - amount.value = "0." - return - } - - if (amount.value.includes(".")) { - const decimalPlaces = amount.value.split(".")[1] - if (decimalPlaces && decimalPlaces.length >= 2) return - } - - amount.value += key -} - -// 点击删除 -const handleDelete = () => { - amount.value = amount.value.slice(0, -1) -} - // 点击支付 const handlePay = () => { if (!scanData.value.id || !scanData.value.name) return uni.showToast({ title: "扫码信息不存在", icon: "none" }) diff --git a/src/pages/pay/transferMoney.vue b/src/pages/pay/transferMoney.vue new file mode 100644 index 0000000..4c76a70 --- /dev/null +++ b/src/pages/pay/transferMoney.vue @@ -0,0 +1,197 @@ + + + diff --git a/src/pages/wallet/detail.vue b/src/pages/wallet/detail.vue index ce5c934..7d8cb23 100644 --- a/src/pages/wallet/detail.vue +++ b/src/pages/wallet/detail.vue @@ -71,6 +71,7 @@ const doTab = (e: any) => { {{ v.title }} {{ v.title }} {{ v.title }} + {{ v.title }} {{ hooks.useMoney(v.price) }}元 diff --git a/src/pages/wallet/list.vue b/src/pages/wallet/list.vue index cec451c..5b7926f 100644 --- a/src/pages/wallet/list.vue +++ b/src/pages/wallet/list.vue @@ -8,6 +8,7 @@ import { hooks, router } from "@@/index" import { merchantApi, walletApi } from "@@/api" import { filePath } from "@@/utils/file" +import { useTransferMoney } from "@/sheep/stores/transferMoney" const state = reactive({ showBindDialog: false, @@ -119,6 +120,16 @@ const doFreeze = async () => { uni.hideLoading() } } + +// 转账 +const doTransferMoney = (v: any) => { + if (v.walletTypeId) { + useTransferMoney().setSourceWalletType(v) + router.jump("/pages/pay/transferMoney") + return + } + uni.showToast({ title: "钱包类型id不存在", icon: "none" }) +}