Lufaneng 11 months ago
parent 2cdd13090a
commit f43fc7b4ca

@ -107,7 +107,6 @@
import { computed, onMounted, ref } from "vue";
import { onShow } from "@dcloudio/uni-app";
import { useAuthStore, useUserStore } from "@/store";
import { regions } from "/static/json/regions.js";
import HeaderCustom from "/components/HeaderCustom/HeaderCustom.vue";
import RPC from "@/utils/request";

@ -85,6 +85,9 @@
</view>
</view>
</uv-popup>
<a style="display: none;" ref="ToLoginRef" href="weixin://dl/business/?appid=wxc504638e03981812&path=pages/login/login?from=h5ToWechat">
打开小程序并登录
</a>
</view>
</template>
@ -145,6 +148,8 @@
},
});
const ToLoginRef = ref(null)
const tips = ref("获取验证码");
const codeChange = (text) => {
tips.value = text;
@ -209,6 +214,9 @@
if (options.redirect && removeQueryString(options.redirect) !== LOGIN_PATH) {
redirect = decodeURIComponent(options.redirect);
}
if(options.from && options.from === 'h5ToWechat') {
XcxLogin()
}
});
//
@ -231,47 +239,60 @@
// #endif
};
const XcxLogin = () => {
uni.showLoading({
title: "登录中...",
});
uni.login({
success: function(loginRes) {
console.log('loginRes', loginRes);
RPC.post('/login/wechat_mini', {
js_code: loginRes.code
}).then(res => {
console.log('phonelogin', res)
authStore.setAccessToken(res.token)
userStore.setUserInfo(res.user)
if(!res.user.phone) {
uni.showToast({
title: "登录成功",
icon: "success",
});
uni.$uv.route({
type: isTabBarPath(redirect) ? "switchTab" : "redirectTo",
url: redirect,
});
} else {
popup.value.open()
}
}).catch(() => {
uni.showToast({
title: "登录失败",
icon: "error",
});
})
},
fail: () => {
uni.hideLoading();
}
})
}
//
const wechatLogin = () => {
// #ifdef MP-WEIXIN
//
// uni.login({
// provider: "weixin",
// success: (loginRes) => {
// console.log(":", loginRes);
// //
// uni.getUserProfile({
// desc: "",
// success: (userRes) => {
// console.log(":", userRes);
// //
// showBindPhoneModal.value = true;
// },
// fail: (err) => {
// console.error(":", err);
// uni.showToast({
// title: "",
// icon: "none",
// });
// },
// });
// },
// fail: (err) => {
// console.error(":", err);
// uni.showToast({
// title: "",
// icon: "none",
// });
// },
// });
popup.value.open();
XcxLogin()
// popup.value.open();
// #endif
// #ifdef H5
// H5
if (typeof WeixinJSBridge !== "undefined") {
// 使JS-SDK
wechatH5Login();
// wechatH5Login();
ToLoginRef.value.click()
} else {
uni.showToast({
title: "请在微信中打开",
@ -349,7 +370,7 @@
const wechatH5Login = () => {
// #ifdef H5
// URL
const appId = "YOUR_WECHAT_APP_ID"; // AppID
const appId = "wxc504638e03981812"; // AppID
const redirectUri = encodeURIComponent(
window.location.origin + "/pages/login/login"
); //
@ -390,32 +411,56 @@
// const result = await RPC.post('/api/wechat/h5-login', {
// code: code
// });
RPC.post('/login/wechat_mini', {
js_code: loginRes.code
}).then(res => {
console.log('phonelogin', res)
authStore.setAccessToken(res.token)
userStore.setUserInfo(res.user)
if(!res.user.phone) {
uni.showToast({
title: "登录成功",
icon: "success",
});
uni.$uv.route({
type: isTabBarPath(redirect) ? "switchTab" : "redirectTo",
url: redirect,
});
} else {
popup.value.open()
}
}).catch(() => {
uni.showToast({
title: "登录失败",
icon: "error",
});
})
//
setTimeout(() => {
uni.hideLoading();
// setTimeout(() => {
// uni.hideLoading();
//
const userInfo = {
openid: "mock_openid_" + Date.now(),
nickname: "微信用户",
headimgurl: "/static/imgs/avatar.png",
};
console.log("微信H5登录成功用户信息:", userInfo);
// //
// const userInfo = {
// openid: "mock_openid_" + Date.now(),
// nickname: "",
// headimgurl: "/static/imgs/avatar.png",
// };
//
popup.value.open();
// console.log("H5:", userInfo);
// URLcode
const url = new URL(window.location);
url.searchParams.delete("code");
url.searchParams.delete("state");
window.history.replaceState({},
document.title,
url.pathname + url.search
);
}, 1500);
// //
// popup.value.open();
// // URLcode
// const url = new URL(window.location);
// url.searchParams.delete("code");
// url.searchParams.delete("state");
// window.history.replaceState({},
// document.title,
// url.pathname + url.search
// );
// }, 1500);
} catch (error) {
uni.hideLoading();
console.error("微信H5登录失败:", error);
@ -559,11 +604,13 @@
onMounted(() => {
checkEnvironment();
// #ifdef H5
// #ifdef MP-WEIXIN
//
const urlParams = new URLSearchParams(window.location.search);
const code = urlParams.get("code");
if (code && showWechatLogin.value) {
const from = urlParams.get("from");
console.log('from',from)
if (from && from === 'h5') {
handleWechatH5Callback(code);
}

@ -138,9 +138,6 @@
useAuthStore,
useUserStore
} from "@/store";
import {
regions
} from '/static/json/regions.js'
import HeaderCustom from '/components/HeaderCustom/HeaderCustom.vue'
import RPC from "@/utils/request";

@ -19,30 +19,30 @@
<view class="profile-item" @click="editUsername">
<view class="item-label">用户名</view>
<view class="item-content">
<text class="item-value">{{ userInfo.username }}</text>
<text class="item-value">{{ userStore.userInfo.username }}</text>
<uv-icon name="arrow-right" size="16" color="#ccc"></uv-icon>
</view>
</view>
<!-- 电话 -->
<!-- <view class="profile-item" @click="editPhone">
<view class="item-label">电话</view>
<view class="item-content">
<text class="item-value">{{ userInfo.phone }}</text>
<uv-icon name="arrow-right" size="16" color="#ccc"></uv-icon>
</view>
</view> -->
<!-- 邮箱 -->
<view class="profile-item" @click="editEmail">
<view class="item-label">邮箱</view>
<view class="item-content">
<text class="item-value">{{ userInfo.email }}</text>
<text class="item-value">{{ userStore.userInfo.email }}</text>
<uv-icon name="arrow-right" size="16" color="#ccc"></uv-icon>
</view>
</view>
<!-- 电话 -->
<view class="profile-item">
<view class="item-label">手机号</view>
<view class="item-content">
<text class="item-value">{{ userStore.userInfo.phone }}</text>
</view>
</view>
</view>
<!-- 应用设置 -->
<view class="app-section">
<!-- 缓存 -->
@ -152,6 +152,7 @@
import { ref, onMounted } from "vue";
import { onShow } from "@dcloudio/uni-app";
import { useAuthStore, useUserStore } from "@/store";
import RPC from "@/utils/request";
const authStore = useAuthStore();
const userStore = useUserStore();
@ -219,21 +220,21 @@ const selectAvatarSource = (source) => {
//
const editUsername = () => {
editType.value = "username";
editValue.value = userInfo.value.username;
editValue.value = userStore.userInfo.username;
editPopup.value.open();
};
//
const editPhone = () => {
editType.value = "phone";
editValue.value = userInfo.value.phone;
editValue.value = userStore.userInfo.phone;
editPopup.value.open();
};
//
const editEmail = () => {
editType.value = "email";
editValue.value = userInfo.value.email;
editValue.value = userStore.userInfo.email;
editPopup.value.open();
};
@ -267,49 +268,49 @@ const saveEdit = async () => {
});
return;
}
//
if (editType.value === "phone" && !/^1[3-9]\d{9}$/.test(editValue.value)) {
if(editType.value === 'username') {
RPC.post('/user/update',{id:userStore.userInfo.id,username:editValue.value}).then(() => {
uni.showToast({
title: "请输入正确的手机号",
icon: "none",
title: "保存成功",
icon: "success",
});
return;
userStore.setUserInfo({...userStore.userInfo,username:editValue.value})
closeEditModal()
})
}
if (
editType.value === "email" &&
!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(editValue.value)
) {
if(editType.value === 'email') {
RPC.post('/user/update',{id:userStore.userInfo.id,email:editValue.value}).then(() => {
uni.showToast({
title: "请输入正确的邮箱地址",
icon: "none",
title: "保存成功",
icon: "success",
});
return;
userStore.setUserInfo({...userStore.userInfo,email:editValue.value})
closeEditModal()
})
}
try {
// API
// await RPC.post('/api/user/update', {
// [editType.value]: editValue.value
// })
// try {
// // API
// // await RPC.post('/api/user/update', {
// // [editType.value]: editValue.value
// // })
//
userInfo.value[editType.value] = editValue.value;
// //
// userInfo.value[editType.value] = editValue.value;
uni.showToast({
title: "保存成功",
icon: "success",
});
// uni.showToast({
// title: "",
// icon: "success",
// });
closeEditModal();
} catch (error) {
console.error("保存失败:", error);
uni.showToast({
title: "保存失败,请重试",
icon: "none",
});
}
// closeEditModal();
// } catch (error) {
// console.error(":", error);
// uni.showToast({
// title: "",
// icon: "none",
// });
// }
};
//

@ -125,16 +125,16 @@ const downloadRecord = (record) => {
icon: "success",
});
// #endif
// #ifndef H5
// #ifdef MP-WEIXIN
// App使uni.downloadFile
uni.downloadFile({
url: record.result_url,
url: 'https://ksdt-1255846884.cos.ap-shanghai.myqcloud.com/lift-result/2025/09/24/d6180add4cd94875a1854a4febce8966.pdf',
success: (res) => {
console.log(res);
if (res.statusCode === 200) {
uni.saveFile({
tempFilePath: res.tempFilePath,
uni.openDocument({
filePath: res.tempFilePath,
showMenu: true,
success: () => {
uni.hideLoading();
uni.showToast({

@ -25,7 +25,7 @@
@click="selectAmount(item.value)"
>
<view class="amount-value">¥{{ item.value }}</view>
<view v-if="item.bonus" class="amount-bonus">{{ item.bonus }}</view>
<!-- <view v-if="item.bonus" class="amount-bonus">{{ item.bonus }}</view> -->
</view>
</view>
@ -116,7 +116,7 @@
<view class="bottom-section">
<view class="recharge-info">
<text class="recharge-text">充值金额¥{{ finalAmount }}</text>
<text v-if="bonusAmount > 0" class="bonus-text">¥{{ bonusAmount }}</text>
<!-- <text v-if="bonusAmount > 0" class="bonus-text">¥{{ bonusAmount }}</text> -->
</view>
<uv-button
type="primary"
@ -152,10 +152,10 @@ const showAlipay = ref(true);
const rechargeAmounts = ref([
{ value: 10, bonus: 0 },
{ value: 50, bonus: 0 },
{ value: 100, bonus: 5 },
{ value: 200, bonus: 15 },
{ value: 500, bonus: 50 },
{ value: 1000, bonus: 120 }
{ value: 100, bonus: 0 },
{ value: 200, bonus: 0 },
{ value: 500, bonus: 0 },
{ value: 1000, bonus: 0 }
]);
//

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save