feat: remove backbtn and create weixin adapter

master
xjs 2025-07-31 11:49:55 +08:00
parent bc74f4a11a
commit aa8239bc3d
6 changed files with 33 additions and 29 deletions

View File

@ -1,12 +1,12 @@
<template>
<nut-drag direction="y" attract :style="{bottom:'15vh'}" class="rounded-full bg-[#fff] border-solid border-black border-[3rpx] left-[30rpx]" style="z-index: 999 !important;">
<ChevronLeft class="w-[88rpx] h-[88rpx] text-black" :stroke-width="2" @click="goBack"/>
<ChevronLeft class="w-[88rpx] h-[88rpx] text-black" :stroke-width="2" @click="adapterHandleBack"/>
</nut-drag>
</template>
<script lang="ts" setup>
import { ChevronLeft } from 'lucide-vue-next';
import { useRouter } from 'vue-router';
import { adapterHandleBack } from '@/utils/adapterWX';
defineProps({
bottom:{
@ -19,9 +19,6 @@ defineProps({
}
})
const router = useRouter()
const goBack = () => {
router.back();
}
</script>

17
src/utils/adapterWX.ts Normal file
View File

@ -0,0 +1,17 @@
import { useRouter } from "vue-router";
export const adapterHandleBack = () => {
const router = useRouter();
if (typeof uni !== "undefined") {
uni.getEnv((res) => {
if (res.miniprogram) {
uni.navigateBack({delta:1});
} else {
router.back();
}
});
} else {
router.back();
}
return false;
};

View File

@ -78,7 +78,7 @@
<div class="rounded-[20rpx] bg-[#28BEBB] text-[44rpx] text-white font-600 flex items-center justify-center py-[28rpx]">保存地址</div>
<div
class="rounded-[20rpx] bg-white text-[44rpx] text-[#28BEBB] font-600 flex items-center justify-center py-[28rpx] border-[#28BEBB] border-[4rpx] border-solid mt-[38rpx]"
@click="goBack">
@click="adapterHandleBack">
返回
</div>
</div>
@ -88,6 +88,7 @@
<script lang="ts" setup>
import { Check } from "lucide-vue-next";
import {adapterHandleBack} from '@/utils/adapterWX'
import { useRouter } from "vue-router";
const router = useRouter();
@ -107,9 +108,7 @@
router.push({ path: "/location/map" });
};
const goBack = () => {
router.back();
};
</script>
<style lang="scss" scoped>

View File

@ -79,7 +79,7 @@
<div class="rounded-[20rpx] bg-[#28BEBB] text-[44rpx] text-white font-600 flex items-center justify-center py-[28rpx]">保存</div>
<div
class="rounded-[20rpx] bg-white text-[44rpx] text-[#28BEBB] font-600 flex items-center justify-center py-[28rpx] border-[#28BEBB] border-[4rpx] border-solid mt-[38rpx]"
@click="goBack">
@click="adapterHandleBack">
返回
</div>
</div>
@ -89,9 +89,8 @@
<script lang="ts" setup>
import { Check } from "lucide-vue-next";
import { useRouter } from "vue-router";
import {adapterHandleBack} from '@/utils/adapterWX'
const router = useRouter();
const formData = reactive<Record<string, any>>({
name: "",
gender: 1,
@ -125,9 +124,6 @@
// router.push({ path: "/location/map" });
// };
const goBack = () => {
router.back();
};
</script>
<style lang="scss" scoped>

View File

@ -42,7 +42,7 @@
</nut-radio-group>
</ul>
<div class="flex items-center text-[44rpx] font-600 px-[30rpx] py-[16rpx] justify-between bg-white">
<div class="rounded-[20rpx] border-[4rpx] border-solid border-[#28BEBB] px-[46rpx] py-[24rpx] text-[#28BEBB]" @click="handleBack"></div>
<div class="rounded-[20rpx] border-[4rpx] border-solid border-[#28BEBB] px-[46rpx] py-[24rpx] text-[#28BEBB]" @click="adapterHandleBack"></div>
<div class="flex items-center justify-between bg-[#28BEBB] rounded-[20rpx] px-[80rpx] py-[28rpx]" @click="toAddAddressPage">
<CirclePlus class="text-white mr-[16rpx]" />
<span class="text-white">新增收货地址</span>
@ -60,15 +60,13 @@
import { setUserDefaultAddress } from "@/api/interfaceDocument";
import { showToast } from "@nutui/nutui";
import { useUserStore } from "@/store/user";
import { adapterHandleBack } from "@/utils/adapterWX";
useGetUserAddressList();
const router = useRouter();
const userStore = useUserStore();
const handleBack = () => {
router.back();
};
const handleRemoveAddress = (index: number) => {
address.value.splice(index, 1);
@ -89,7 +87,7 @@
postRequest(setUserDefaultAddress()).then(() => {
userStore.setDefaultAddress(item);
showToast.text("修改成功");
handleBack();
adapterHandleBack();
});
};
</script>

View File

@ -33,27 +33,24 @@
</ul>
<div class="button-group px-[30rpx] grid gap-[40rpx] mt-[40rpx]">
<nut-button class="w-full! submit-btn rounded-[20rpx]!" shape="square" @click="handleCancel"></nut-button>
<nut-button class="w-full! cancel-btn rounded-[20rpx]!" shape="square" @click="handleCancel"></nut-button>
<nut-button class="w-full! submit-btn rounded-[20rpx]!" shape="square" @click="adapterHandleBack"></nut-button>
<nut-button class="w-full! cancel-btn rounded-[20rpx]!" shape="square" @click="adapterHandleBack"></nut-button>
</div>
</div>
</template>
<script lang="ts" setup>
import { Camera, Mars, Venus } from "lucide-vue-next";
import { useRouter } from "vue-router";
import { adapterHandleBack } from "@/utils/adapterWX";
const gender = ref("male");
const router = useRouter();
const formData = ref({
name: "",
identify: "",
});
const handleCancel = () => {
router.go(-1);
};
</script>
<style lang="scss" scoped>