Compare commits
9 Commits
09452bf600
...
b7fbe99cd0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7fbe99cd0 | ||
| 5027abc239 | |||
| a2ff08f090 | |||
| 37192b0ba4 | |||
| 8be21f8307 | |||
| 296781c506 | |||
| 9eb1dc6747 | |||
| 364e47b641 | |||
| a3c363cbc9 |
@@ -3,8 +3,8 @@ import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
|
|||||||
import { getEvnUrl } from "@/request/api/config";
|
import { getEvnUrl } from "@/request/api/config";
|
||||||
import { refreshToken } from "@/hooks/useGoLogin";
|
import { refreshToken } from "@/hooks/useGoLogin";
|
||||||
|
|
||||||
onLaunch(() => {
|
onLaunch(async () => {
|
||||||
getEvnUrl({ versionValue: "1.0.1" });
|
await getEvnUrl({ versionValue: "1.0.3" });
|
||||||
refreshToken();
|
refreshToken();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -352,6 +352,14 @@ const handleSingleSelect = (dateInfo) => {
|
|||||||
|
|
||||||
// 处理范围选择
|
// 处理范围选择
|
||||||
const handleRangeSelection = (dateInfo) => {
|
const handleRangeSelection = (dateInfo) => {
|
||||||
|
if (dateInfo.price === undefined || dateInfo.price === null || dateInfo.stock === '' || dateInfo.price === '-') {
|
||||||
|
uni.showToast({
|
||||||
|
title: "所选日期不可预订,请重新选择",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!rangeStart.value || (rangeStart.value && rangeEnd.value)) {
|
if (!rangeStart.value || (rangeStart.value && rangeEnd.value)) {
|
||||||
// 开始新的范围选择
|
// 开始新的范围选择
|
||||||
rangeStart.value = dateInfo.date;
|
rangeStart.value = dateInfo.date;
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ const refundTitle = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const commodityPurchaseInstruction = computed(() => {
|
const commodityPurchaseInstruction = computed(() => {
|
||||||
if (props.orderData.commodityPurchaseInstruction) {
|
if (props.orderData.commodityPurchaseInstruction &&
|
||||||
|
props.orderData.commodityPurchaseInstruction.refundContent) {
|
||||||
// 以换行符为分隔符,将字符串转换为数组
|
// 以换行符为分隔符,将字符串转换为数组
|
||||||
return props.orderData.commodityPurchaseInstruction.refundContent.split(
|
return props.orderData.commodityPurchaseInstruction.refundContent.split(
|
||||||
"\n"
|
"\n"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<view class="inner-card bg-white">
|
<view class="inner-card bg-white">
|
||||||
<!-- 商品大图部分:自适应剩余空间 -->
|
<!-- 商品大图部分:自适应剩余空间 -->
|
||||||
<view class="goods-image-wrapper relative">
|
<view class="goods-image-wrapper relative">
|
||||||
<image class="w-full h-full" :src="card.commodityPhoto" />
|
<image class="w-full h-full" :src="card.commodityPhoto" mode="aspectFill"/>
|
||||||
<view
|
<view
|
||||||
class="goods-title absolute left-0 right-0 bottom-0 border-box p-12"
|
class="goods-title absolute left-0 right-0 bottom-0 border-box p-12"
|
||||||
>
|
>
|
||||||
|
|||||||
19
src/constant/token.js
Normal file
19
src/constant/token.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { appId, clientId } from "@/constant/base";
|
||||||
|
|
||||||
|
/// 存储在本地的认证 token 键名
|
||||||
|
export const clientAuthToken = "AUTH_TOKEN_" + clientId + "_" + appId;
|
||||||
|
|
||||||
|
/// 设置本地存储的认证 token
|
||||||
|
export const setStorageSyncToken = (token) => {
|
||||||
|
uni.setStorageSync(clientAuthToken, token);
|
||||||
|
};
|
||||||
|
|
||||||
|
/// 获取本地存储的认证 token
|
||||||
|
export const getStorageSyncToken = () => {
|
||||||
|
return uni.getStorageSync(clientAuthToken);
|
||||||
|
};
|
||||||
|
|
||||||
|
/// 移除本地存储的认证 token
|
||||||
|
export const removeStorageSyncToken = () => {
|
||||||
|
uni.setStorageSync(clientAuthToken, "");
|
||||||
|
};
|
||||||
@@ -2,6 +2,7 @@ import { wxLogin } from "../request/api/LoginApi";
|
|||||||
import { loginAuth, bindPhone, checkPhone } from "@/manager/LoginManager";
|
import { loginAuth, bindPhone, checkPhone } from "@/manager/LoginManager";
|
||||||
import { clientId } from "@/constant/base";
|
import { clientId } from "@/constant/base";
|
||||||
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
||||||
|
import { getStorageSyncToken, setStorageSyncToken } from "../constant/token";
|
||||||
|
|
||||||
// 跳转登录
|
// 跳转登录
|
||||||
export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" });
|
export const goLogin = () => uni.navigateTo({ url: "/pages/login/index" });
|
||||||
@@ -47,7 +48,7 @@ export const onLogin = async (e) => {
|
|||||||
|
|
||||||
// 检测token
|
// 检测token
|
||||||
export const checkToken = () => {
|
export const checkToken = () => {
|
||||||
const token = uni.getStorageSync("token");
|
const token = getStorageSyncToken();
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
@@ -61,30 +62,29 @@ export const checkToken = () => {
|
|||||||
|
|
||||||
// 刷新token
|
// 刷新token
|
||||||
export const refreshToken = () => {
|
export const refreshToken = () => {
|
||||||
const token = uni.getStorageSync("token");
|
return new Promise((resolve) => {
|
||||||
|
uni.login({
|
||||||
|
provider: "weixin", //使用微信登录
|
||||||
|
success: async ({ code }) => {
|
||||||
|
console.log("refreshToken", code);
|
||||||
|
const params = {
|
||||||
|
openIdCode: [code],
|
||||||
|
grant_type: "wechat",
|
||||||
|
scope: "server",
|
||||||
|
clientId: clientId,
|
||||||
|
};
|
||||||
|
console.log("获取到的微信授权params:", JSON.stringify(params));
|
||||||
|
const response = await wxLogin(params);
|
||||||
|
|
||||||
if (!token) {
|
if (response.access_token) {
|
||||||
return;
|
setStorageSyncToken(response.access_token);
|
||||||
}
|
// 登录成功后,触发登录成功事件
|
||||||
|
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
||||||
uni.login({
|
resolve(false)
|
||||||
provider: "weixin", //使用微信登录
|
} else {
|
||||||
success: async ({ code }) => {
|
resolve(true)
|
||||||
console.log("refreshToken", code);
|
}
|
||||||
const params = {
|
},
|
||||||
openIdCode: [code],
|
});
|
||||||
grant_type: "wechat",
|
|
||||||
scope: "server",
|
|
||||||
clientId: clientId,
|
|
||||||
};
|
|
||||||
console.log("获取到的微信授权params:", JSON.stringify(params));
|
|
||||||
const response = await wxLogin(params);
|
|
||||||
|
|
||||||
if (response.access_token) {
|
|
||||||
uni.setStorageSync("token", response.access_token);
|
|
||||||
// 登录成功后,触发登录成功事件
|
|
||||||
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ app.$mount();
|
|||||||
import { createSSRApp } from "vue";
|
import { createSSRApp } from "vue";
|
||||||
import * as Pinia from "pinia";
|
import * as Pinia from "pinia";
|
||||||
import { createUnistorage } from "pinia-plugin-unistorage";
|
import { createUnistorage } from "pinia-plugin-unistorage";
|
||||||
import noclick from "./utils/noclick";
|
|
||||||
|
|
||||||
export function createApp() {
|
export function createApp() {
|
||||||
const app = createSSRApp(App);
|
const app = createSSRApp(App);
|
||||||
@@ -25,7 +24,6 @@ export function createApp() {
|
|||||||
pinia.use(createUnistorage());
|
pinia.use(createUnistorage());
|
||||||
app.use(pinia);
|
app.use(pinia);
|
||||||
app.use(share);
|
app.use(share);
|
||||||
app.use(noclick);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
app,
|
app,
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ import { getWeChatAuthCode } from "./AuthManager";
|
|||||||
import { useAppStore } from "@/store";
|
import { useAppStore } from "@/store";
|
||||||
import { clientId } from "@/constant/base";
|
import { clientId } from "@/constant/base";
|
||||||
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
import { NOTICE_EVENT_LOGIN_SUCCESS } from "@/constant/constant";
|
||||||
|
import { removeStorageSyncToken, setStorageSyncToken } from "../constant/token";
|
||||||
|
|
||||||
const loginAuth = (e) => {
|
const loginAuth = (e) => {
|
||||||
uni.setStorageSync("token", "");
|
removeStorageSyncToken();
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
|
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
@@ -26,7 +27,7 @@ const loginAuth = (e) => {
|
|||||||
console.log("获取到的微信授权response:", response);
|
console.log("获取到的微信授权response:", response);
|
||||||
|
|
||||||
if (response.access_token) {
|
if (response.access_token) {
|
||||||
uni.setStorageSync("token", response.access_token);
|
setStorageSyncToken(response.access_token);
|
||||||
// 登录成功后,触发登录成功事件
|
// 登录成功后,触发登录成功事件
|
||||||
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
uni.$emit(NOTICE_EVENT_LOGIN_SUCCESS);
|
||||||
resolve();
|
resolve();
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
/>
|
/>
|
||||||
<text
|
<text
|
||||||
class="font-size-16 font-500 color-white"
|
class="font-size-16 font-500 color-white"
|
||||||
@click="$onMultipleClicks(() => emit('payClick', orderData))"
|
|
||||||
>立即支付</text
|
>立即支付</text
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
@@ -29,7 +28,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, defineProps, defineEmits } from "vue";
|
import { computed, defineProps, defineEmits, ref, onMounted, watch } from "vue";
|
||||||
|
import { DebounceUtils } from "@/utils";
|
||||||
|
import { preOrder } from "@/request/api/OrderApi";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
@@ -54,11 +55,39 @@ const count = computed({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const totalAmt = computed(() => {
|
watch(
|
||||||
const { totalDays } = props.selectedDate;
|
() => count.value,
|
||||||
const { specificationPrice } = props.orderData;
|
(newVal, oldVal) => {
|
||||||
return count.value * Number(specificationPrice) * totalDays;
|
if (newVal !== oldVal) {
|
||||||
|
preOrderPay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
preOrderPay();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const totalAmt = ref(props.orderData.specificationPrice);
|
||||||
|
|
||||||
|
const preOrderPay = async () => {
|
||||||
|
preOrder({
|
||||||
|
"commodityId": props.orderData.commodityId,
|
||||||
|
"purchaseAmount": count.value,
|
||||||
|
"checkInData": props.selectedDate.startDate,
|
||||||
|
"checkOutData": props.selectedDate.endDate,
|
||||||
|
}).then((res) => {
|
||||||
|
console.log("预支付金额计算结果:", res);
|
||||||
|
totalAmt.value = res.data.payAmt;
|
||||||
|
}).catch((err) => {
|
||||||
|
console.error("预支付金额计算失败:", err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleBooking = DebounceUtils.createDebounce(() => {
|
||||||
|
emit("payClick", props.orderData);
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -79,6 +79,7 @@
|
|||||||
|
|
||||||
<!-- 底部 -->
|
<!-- 底部 -->
|
||||||
<FooterSection
|
<FooterSection
|
||||||
|
v-if="Object.keys(orderData).length"
|
||||||
v-model="quantity"
|
v-model="quantity"
|
||||||
:selectedDate="selectedDate"
|
:selectedDate="selectedDate"
|
||||||
:orderData="orderData"
|
:orderData="orderData"
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
'bg-2D91FF': ['1', '2', '3', '4', '5', '6'].includes(statusCode),
|
'bg-2D91FF': ['1', '2', '3', '4', '5', '6'].includes(statusCode),
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
@click="$onmultipleClicks(() => handleButtonClick(orderData))"
|
@click="handleButtonClick(orderData)"
|
||||||
>
|
>
|
||||||
{{ buttonText }}
|
{{ buttonText }}
|
||||||
</button>
|
</button>
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { defineProps, defineEmits, computed } from "vue";
|
import { defineProps, defineEmits, computed } from "vue";
|
||||||
import { orderPayNow } from "@/request/api/OrderApi";
|
import { orderPayNow } from "@/request/api/OrderApi";
|
||||||
|
import { DebounceUtils } from "@/utils";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
orderData: {
|
orderData: {
|
||||||
@@ -64,7 +65,7 @@ const buttonText = computed(() => {
|
|||||||
const emit = defineEmits(["refund", "refresh"]);
|
const emit = defineEmits(["refund", "refresh"]);
|
||||||
|
|
||||||
// 处理按钮点击事件
|
// 处理按钮点击事件
|
||||||
const handleButtonClick = async (orderData) => {
|
const handleButtonClick = DebounceUtils.createDebounce(async (orderData) => {
|
||||||
try {
|
try {
|
||||||
// 再次预定跳转商品详情
|
// 再次预定跳转商品详情
|
||||||
if (["1", "2", "3", "4", "5", "6"].includes(statusCode.value)) {
|
if (["1", "2", "3", "4", "5", "6"].includes(statusCode.value)) {
|
||||||
@@ -130,7 +131,7 @@ const handleButtonClick = async (orderData) => {
|
|||||||
console.error("操作失败:", error);
|
console.error("操作失败:", error);
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
}
|
}
|
||||||
};
|
}, 1000);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -1,21 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<view
|
<view class="card bg-white border-box p-8 rounded-12 flex flex-items-start m-12" @click.stop="handleClick(item)">
|
||||||
class="card bg-white border-box p-8 rounded-12 flex flex-items-start m-12"
|
<image class="left rounded-10" :src="item.commodityPhoto" mode="aspectFill" />
|
||||||
@click.stop="handleClick(item)"
|
|
||||||
>
|
|
||||||
<image
|
|
||||||
class="left rounded-10"
|
|
||||||
:src="item.commodityPhoto"
|
|
||||||
mode="aspectFill"
|
|
||||||
/>
|
|
||||||
<view class="right border-box flex-full pl-12">
|
<view class="right border-box flex-full pl-12">
|
||||||
<view class="font-size-16 line-height-24 color-171717 mb-4">
|
<view class="font-size-16 line-height-24 color-171717 mb-4">
|
||||||
{{ item.commodityName }}
|
{{ item.commodityName }}
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view v-if="item.commodityFacility" class="font-size-12 line-height-16 color-99A0AE mb-4 ellipsis-1">
|
||||||
v-if="item.commodityFacility"
|
|
||||||
class="font-size-12 line-height-16 color-99A0AE mb-4 ellipsis-1"
|
|
||||||
>
|
|
||||||
{{ item.commodityFacility.join(" ") }}
|
{{ item.commodityFacility.join(" ") }}
|
||||||
</view>
|
</view>
|
||||||
<view class="font-size-12 line-height-18 color-43669A">
|
<view class="font-size-12 line-height-18 color-43669A">
|
||||||
@@ -23,19 +13,13 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="flex flex-items-center flex-justify-end">
|
<view class="flex flex-items-center flex-justify-end">
|
||||||
<text
|
<text class="amt font-size-18 font-500 font-family-misans-vf line-height-24 color-FF3D60 mr-4">
|
||||||
class="amt font-size-18 font-500 font-family-misans-vf line-height-24 color-FF3D60 mr-4"
|
|
||||||
>
|
|
||||||
{{ item.specificationPrice }}
|
{{ item.specificationPrice }}
|
||||||
</text>
|
</text>
|
||||||
<text class="font-size-12 line-height-16 color-99A0AE">
|
<text class="font-size-12 line-height-16 color-99A0AE">
|
||||||
/{{ item.stockUnitLabel }}
|
/{{ item.stockUnitLabel }}
|
||||||
</text>
|
</text>
|
||||||
<text
|
<text class="btn border-box rounded-10 color-white ml-16" @click.stop="handleBooking(item)">订</text>
|
||||||
class="btn border-box rounded-10 color-white ml-16"
|
|
||||||
@click.stop="handleBooking(item)"
|
|
||||||
>订</text
|
|
||||||
>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -64,24 +48,22 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
selectedDate: {
|
selectedDate: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {},
|
default: () => { },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleClick = ({ commodityId }) => {
|
|
||||||
uni.navigateTo({ url: `/pages/goods/index?commodityId=${commodityId}` });
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectedDateStore = useSelectedDateStore();
|
const selectedDateStore = useSelectedDateStore();
|
||||||
const handleBooking = ({ commodityId }) => {
|
|
||||||
const { startDate, endDate, totalDays } = props.selectedDate;
|
|
||||||
|
|
||||||
|
const navigateToPage = (commodityId, path) => {
|
||||||
|
const { startDate, endDate, totalDays } = props.selectedDate;
|
||||||
selectedDateStore.setData({ startDate, endDate, totalDays });
|
selectedDateStore.setData({ startDate, endDate, totalDays });
|
||||||
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({ url: `${path}?commodityId=${commodityId}` });
|
||||||
url: `/pages-booking/index?commodityId=${commodityId}`,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleClick = ({ commodityId }) => navigateToPage(commodityId, "/pages/goods/index")
|
||||||
|
|
||||||
|
const handleBooking = ({ commodityId }) => navigateToPage(commodityId, "/pages-booking/index")
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ import WebSocketManager from "@/utils/WebSocketManager";
|
|||||||
import { ThrottleUtils, IdUtils } from "@/utils";
|
import { ThrottleUtils, IdUtils } from "@/utils";
|
||||||
import { checkToken } from "@/hooks/useGoLogin";
|
import { checkToken } from "@/hooks/useGoLogin";
|
||||||
import { useAppStore } from "@/store";
|
import { useAppStore } from "@/store";
|
||||||
|
import { getStorageSyncToken } from "@/constant/token";
|
||||||
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
/// 导航栏相关
|
/// 导航栏相关
|
||||||
@@ -346,7 +347,7 @@ onLoad(() => {
|
|||||||
// token存在,初始化数据
|
// token存在,初始化数据
|
||||||
const initHandler = () => {
|
const initHandler = () => {
|
||||||
console.log("initHandler");
|
console.log("initHandler");
|
||||||
const token = uni.getStorageSync("token");
|
const token = getStorageSyncToken();
|
||||||
|
|
||||||
if (!token) return;
|
if (!token) return;
|
||||||
loadRecentConversation();
|
loadRecentConversation();
|
||||||
@@ -414,7 +415,7 @@ const initWebSocket = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 使用配置的WebSocket服务器地址
|
// 使用配置的WebSocket服务器地址
|
||||||
const token = uni.getStorageSync("token");
|
const token = getStorageSyncToken();
|
||||||
const wsUrl = `${appStore.serverConfig.wssUrl}?access_token=${token}`;
|
const wsUrl = `${appStore.serverConfig.wssUrl}?access_token=${token}`;
|
||||||
|
|
||||||
// 初始化WebSocket管理器
|
// 初始化WebSocket管理器
|
||||||
|
|||||||
@@ -38,20 +38,11 @@
|
|||||||
<!-- 同意隐私协议并获取手机号按钮 -->
|
<!-- 同意隐私协议并获取手机号按钮 -->
|
||||||
|
|
||||||
<button
|
<button
|
||||||
v-if="!isAgree"
|
|
||||||
class="login-btn"
|
class="login-btn"
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="handleAgreeAndGetPhone"
|
:open-type="needWxLogin ? 'getPhoneNumber' : ''"
|
||||||
>
|
|
||||||
手机号快捷登录
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
|
||||||
v-if="isAgree && !appStore.tokenExpired"
|
|
||||||
class="login-btn"
|
|
||||||
type="primary"
|
|
||||||
open-type="getPhoneNumber"
|
|
||||||
@getphonenumber="getPhoneNumber"
|
@getphonenumber="getPhoneNumber"
|
||||||
|
@click="handleAgreeAndGetPhone"
|
||||||
>
|
>
|
||||||
手机号快捷登录
|
手机号快捷登录
|
||||||
</button>
|
</button>
|
||||||
@@ -67,19 +58,19 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { onShow } from "@dcloudio/uni-app";
|
||||||
import { ref, computed } from "vue";
|
import { ref, computed } from "vue";
|
||||||
import {
|
import {
|
||||||
getServiceAgreement,
|
getServiceAgreement,
|
||||||
getPrivacyAgreement,
|
getPrivacyAgreement,
|
||||||
} from "@/request/api/LoginApi";
|
} from "@/request/api/LoginApi";
|
||||||
import { onLogin, goBack } from "@/hooks/useGoLogin";
|
import { onLogin, goBack, refreshToken } from "@/hooks/useGoLogin";
|
||||||
import CheckBox from "@/components/CheckBox/index.vue";
|
import CheckBox from "@/components/CheckBox/index.vue";
|
||||||
import AgreePopup from "./components/AgreePopup/index.vue";
|
import AgreePopup from "./components/AgreePopup/index.vue";
|
||||||
import { zniconsMap } from "@/static/fonts/znicons.js";
|
import { zniconsMap } from "@/static/fonts/znicons.js";
|
||||||
import { getCurrentConfig } from "@/constant/base";
|
import { getCurrentConfig } from "@/constant/base";
|
||||||
import { useAppStore } from "@/store";
|
|
||||||
const appStore = useAppStore();
|
|
||||||
|
|
||||||
|
const needWxLogin = ref(false);
|
||||||
const isAgree = ref(false);
|
const isAgree = ref(false);
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
const serviceAgreement = ref("");
|
const serviceAgreement = ref("");
|
||||||
@@ -90,6 +81,11 @@ const logo = computed(() => getCurrentConfig().logo);
|
|||||||
|
|
||||||
// 同意隐私协议并获取手机号
|
// 同意隐私协议并获取手机号
|
||||||
const handleAgreeAndGetPhone = () => {
|
const handleAgreeAndGetPhone = () => {
|
||||||
|
// 如果需要微信登录,直接返回
|
||||||
|
if (needWxLogin.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!isAgree.value) {
|
if (!isAgree.value) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "请先同意服务协议和隐私协议",
|
title: "请先同意服务协议和隐私协议",
|
||||||
@@ -97,6 +93,8 @@ const handleAgreeAndGetPhone = () => {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshToken().then(() => goBack());
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPhoneNumber = (e) => {
|
const getPhoneNumber = (e) => {
|
||||||
@@ -141,6 +139,13 @@ const getPrivacyAgreementData = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getPrivacyAgreementData();
|
getPrivacyAgreementData();
|
||||||
|
|
||||||
|
// 页面显示时刷新token
|
||||||
|
onShow(async () => {
|
||||||
|
const res = await refreshToken();
|
||||||
|
|
||||||
|
needWxLogin.value = res;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { goLogin } from "@/hooks/useGoLogin";
|
import { goLogin } from "@/hooks/useGoLogin";
|
||||||
import { useAppStore } from "@/store";
|
import { useAppStore } from "@/store";
|
||||||
|
import { getStorageSyncToken } from "@/constant/token";
|
||||||
|
import { removeStorageSyncToken } from "@/constant/token";
|
||||||
|
|
||||||
/// 请求流式数据的API
|
/// 请求流式数据的API
|
||||||
const API = "/agent/assistant/chat";
|
const API = "/agent/assistant/chat";
|
||||||
@@ -72,7 +74,7 @@ const stopAbortTask = () => {
|
|||||||
|
|
||||||
const agentChatStream = (params, onChunk) => {
|
const agentChatStream = (params, onChunk) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const token = uni.getStorageSync("token");
|
const token = getStorageSyncToken();
|
||||||
const requestId = Date.now().toString(); // 生成唯一请求ID
|
const requestId = Date.now().toString(); // 生成唯一请求ID
|
||||||
|
|
||||||
// 重置状态
|
// 重置状态
|
||||||
@@ -130,7 +132,7 @@ const agentChatStream = (params, onChunk) => {
|
|||||||
res.statusCode
|
res.statusCode
|
||||||
);
|
);
|
||||||
if (res.statusCode === 424) {
|
if (res.statusCode === 424) {
|
||||||
uni.setStorageSync("token", "");
|
removeStorageSyncToken();
|
||||||
goLogin();
|
goLogin();
|
||||||
}
|
}
|
||||||
if (onChunk) {
|
if (onChunk) {
|
||||||
@@ -144,8 +146,7 @@ const agentChatStream = (params, onChunk) => {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(
|
console.log(
|
||||||
`❌ 请求 [${requestId}] ${
|
`❌ 请求 [${requestId}] ${isAborted ? "已终止" : "已过期"
|
||||||
isAborted ? "已终止" : "已过期"
|
|
||||||
},忽略complete回调`
|
},忽略complete回调`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -240,7 +241,7 @@ const weAtob = (string) => {
|
|||||||
r2,
|
r2,
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for (; i < string.length; ) {
|
for (; i < string.length;) {
|
||||||
bitmap =
|
bitmap =
|
||||||
(b64.indexOf(string.charAt(i++)) << 18) |
|
(b64.indexOf(string.charAt(i++)) << 18) |
|
||||||
(b64.indexOf(string.charAt(i++)) << 12) |
|
(b64.indexOf(string.charAt(i++)) << 12) |
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { removeStorageSyncToken } from "@/constant/token";
|
||||||
import request from "../base/request";
|
import request from "../base/request";
|
||||||
|
|
||||||
const wxLogin = (args) => {
|
const wxLogin = (args) => {
|
||||||
@@ -8,7 +9,7 @@ const wxLogin = (args) => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
uni.setStorageSync("token", "");
|
removeStorageSyncToken();
|
||||||
|
|
||||||
return request.post("/auth/oauth2/token", args, config);
|
return request.post("/auth/oauth2/token", args, config);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { getCurrentConfig } from "@/constant/base";
|
import { getCurrentConfig } from "@/constant/base";
|
||||||
import { useAppStore } from "@/store";
|
import { useAppStore } from "@/store";
|
||||||
|
import { getStorageSyncToken } from "@/constant/token";
|
||||||
|
|
||||||
export const updateImageFile = (file) => {
|
export const updateImageFile = (file) => {
|
||||||
const { serverConfig } = useAppStore();
|
const { serverConfig } = useAppStore();
|
||||||
const url = serverConfig.baseUrl + "/hotelBiz/hotBizCommon/upload";
|
const url = serverConfig.baseUrl + "/hotelBiz/hotBizCommon/upload";
|
||||||
const token = uni.getStorageSync("token");
|
const token = getStorageSyncToken();
|
||||||
const clientId = getCurrentConfig().clientId;
|
const clientId = getCurrentConfig().clientId;
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|||||||
@@ -3,14 +3,11 @@ import { isProd } from "@/constant/base";
|
|||||||
import { useAppStore } from "@/store";
|
import { useAppStore } from "@/store";
|
||||||
|
|
||||||
// 获取服务地址
|
// 获取服务地址
|
||||||
const getEvnUrl = (args) => {
|
const getEvnUrl = async (args) => {
|
||||||
if (isProd) {
|
const res = await request.post("https://biz.nianxx.cn/hotelBiz/mainScene/getServiceUrl", args)
|
||||||
|
if (res && res.code == 0 && res.data) {
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
request
|
appStore.setServerConfig(res.data);
|
||||||
.post("https://biz.nianxx.cn/hotelBiz/mainScene/getServiceUrl", args)
|
|
||||||
.then(({ data }) => {
|
|
||||||
appStore.setServerConfig(data);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { goLogin } from "../../hooks/useGoLogin";
|
|||||||
import { getCurrentConfig } from "@/constant/base";
|
import { getCurrentConfig } from "@/constant/base";
|
||||||
import { useAppStore } from "@/store";
|
import { useAppStore } from "@/store";
|
||||||
import { NOTICE_EVENT_LOGOUT } from "@/constant/constant";
|
import { NOTICE_EVENT_LOGOUT } from "@/constant/constant";
|
||||||
|
import { getStorageSyncToken } from "@/constant/token";
|
||||||
|
|
||||||
const clientId = getCurrentConfig().clientId;
|
const clientId = getCurrentConfig().clientId;
|
||||||
const defaultConfig = {
|
const defaultConfig = {
|
||||||
@@ -19,7 +20,7 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
|
|||||||
url = appStore.serverConfig?.baseUrl + url;
|
url = appStore.serverConfig?.baseUrl + url;
|
||||||
}
|
}
|
||||||
// 动态获取 token
|
// 动态获取 token
|
||||||
const token = uni.getStorageSync("token");
|
const token = getStorageSyncToken();
|
||||||
|
|
||||||
let header = {
|
let header = {
|
||||||
...defaultConfig.header,
|
...defaultConfig.header,
|
||||||
@@ -58,9 +59,9 @@ function request(url, args = {}, method = "POST", customConfig = {}) {
|
|||||||
resolve(res.data);
|
resolve(res.data);
|
||||||
if (res.statusCode && res.statusCode === 424) {
|
if (res.statusCode && res.statusCode === 424) {
|
||||||
console.log("424错误,重新登录");
|
console.log("424错误,重新登录");
|
||||||
uni.setStorageSync("token", "");
|
// removeStorageSyncToken();
|
||||||
uni.$emit(NOTICE_EVENT_LOGOUT);
|
uni.$emit(NOTICE_EVENT_LOGOUT);
|
||||||
goLogin();
|
// goLogin();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
// 防止处理多次点击
|
|
||||||
// methods是需要点击后需要执行的函数, info是点击需要传的参数
|
|
||||||
export function noMultipleClicks(fn, info, delay = 2000) {
|
|
||||||
if (typeof fn !== 'function') return;
|
|
||||||
// this 会是组件实例(因为通过 globalProperties 调用时 Vue 会把组件实例作为上下文)
|
|
||||||
const ctx = this || {};
|
|
||||||
if (!ctx.__noClickMap) ctx.__noClickMap = new WeakMap();
|
|
||||||
|
|
||||||
const map = ctx.__noClickMap;
|
|
||||||
if (map.get(fn)) {
|
|
||||||
console.log('请勿重复点击:', fn.name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
map.set(fn, true);
|
|
||||||
// 保留组件上下文调用方法
|
|
||||||
fn.call(ctx, info);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
map.set(fn, false);
|
|
||||||
}, delay);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
install(app) {
|
|
||||||
app.config.globalProperties.$noMultipleClicks = noMultipleClicks;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user