diff --git a/api/start/login.js b/api/start/login.js
index aecf0cf..699a30f 100644
--- a/api/start/login.js
+++ b/api/start/login.js
@@ -67,6 +67,36 @@ export const registerApi = (data) => {
})
}
+
+
+/**
+ * 忘记密码校验验证码
+ */
+
+export const verifyCodeApi = (data) => {
+ return http({
+ method: 'POST',
+ url: '/UserLogin/verifyCode',
+ data: data,
+ })
+}
+
+
+
+/**
+ * 忘记密码输入新的密码
+ */
+
+export const forgetApi = (data) => {
+ return http({
+ method: 'POST',
+ url: '/UserLogin/forget',
+ data: data,
+ })
+}
+
+
+
/**
* 修改密码
*
diff --git a/components/deepExploration_header.vue b/components/deepExploration_header.vue
index daae53c..cddab00 100644
--- a/components/deepExploration_header.vue
+++ b/components/deepExploration_header.vue
@@ -72,6 +72,7 @@
{{ item.stockName }}
({{ item.stockCode }})
+ ({{ item.stockCode }})
{{
formatTimeForHistory(item.createdTime)
@@ -98,6 +99,7 @@ const props = defineProps({
},
});
const showHistoryDrawer = ref(false);
+const modelType = ref('');
const drawerOffsetY = ref(0);
// const handleHistory = () => {
// showHistoryDrawer.value = true;
diff --git a/components/login-prompt.vue b/components/login-prompt.vue
index 4d302be..cb13c61 100644
--- a/components/login-prompt.vue
+++ b/components/login-prompt.vue
@@ -15,20 +15,40 @@
diff --git a/pages/start/Registration/Registration.vue b/pages/start/Registration/Registration.vue
index fc07232..1e919e1 100644
--- a/pages/start/Registration/Registration.vue
+++ b/pages/start/Registration/Registration.vue
@@ -198,6 +198,7 @@ import {
SendPhoneCodeApi,
} from "../../../api/start/login";
import { useDeviceStore} from "../../../stores/modules/deviceInfo"
+import { useUserStore} from "../../../stores/modules/userInfo"
const type = ref("");
const email = ref("");
diff --git a/pages/start/recoverPassword/recoverPassword.vue b/pages/start/recoverPassword/recoverPassword.vue
index 1bdca81..97530c5 100644
--- a/pages/start/recoverPassword/recoverPassword.vue
+++ b/pages/start/recoverPassword/recoverPassword.vue
@@ -209,10 +209,10 @@
- 已有账号?
- 登录
-
-
+ 已有账号?
+ 登录
+
@@ -235,7 +235,12 @@ import countryList from "../login/list";
import footerBar from "../../../components/footerBar";
import uniPopup from "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.vue";
import { verificationPhone, verificationEmail } from "../login/verification";
-import { SendEmailCodeApi, SendPhoneCodeApi } from "../../../api/start/login";
+import {
+ SendEmailCodeApi,
+ SendPhoneCodeApi,
+ verifyCodeApi,
+ forgetApi,
+} from "../../../api/start/login";
const type = ref("");
const email = ref("");
@@ -254,6 +259,7 @@ const verifyCode = ref("");
const isRecovering = ref(false);
const newPasswordLookFirst = ref(false);
const newPasswordLookSecond = ref(false);
+const account = ref("");
// 使用从list.js导入的完整国家列表数据
const countries = ref(
@@ -301,7 +307,7 @@ function switchPhone() {
verifyCode.value = "";
}
-function register() {
+async function register() {
if (isRecovering.value) {
if (!newPasswordFirst.value || !newPasswordSecond.value) {
uni.showToast({
@@ -319,6 +325,32 @@ function register() {
return;
}
+ const account = changeAccount();
+
+ const res = await forgetApi({
+ account: account,
+ password: newPasswordSecond.value,
+ });
+
+ console.log("res", res);
+
+ if (res.code !== 200) {
+ uni.showToast({
+ title: res.message,
+ icon: "none",
+ });
+ return;
+ }
+
+ uni.showToast({
+ title: res.message,
+ icon: "none",
+ });
+
+ uni.navigateTo({
+ url: "/pages/start/login/login",
+ });
+
// 密码逻辑
return;
}
@@ -384,13 +416,54 @@ function register() {
console.log("登录:", email.value);
}
+ const account = changeAccount();
+ const loginType = changeLoginType();
+
+ const res = await verifyCodeApi({
+ loginType: loginType, //登录方式EMAIL,PHONE
+ account: account, //登陆账号 手机号/邮箱
+ verifyCode: verifyCode.value,
+ });
+
+ if (res.code !== 200) {
+ uni.showToast({
+ title: res.message,
+ icon: "none",
+ });
+ return;
+ }
+
isRecovering.value = !isRecovering.value;
+}
- // 如果已经同意,则继续登录流程
- // uni.showToast({
- // title: "登录成功",
- // icon: "success",
- // });
+// 请求账户
+function changeAccount() {
+ if (switchType.value === "User") {
+ account.value = deepChartID.value;
+ }
+
+ if (switchType.value === "Phone") {
+ account.value = `${country.value}${phone.value}`;
+ }
+ if (switchType.value === "Email") {
+ account.value = email.value;
+ }
+
+ return account.value;
+}
+
+// 改变请求时的type
+function changeLoginType() {
+ if (switchType.value === "User") {
+ return "DCCODE";
+ }
+
+ if (switchType.value === "Phone") {
+ return "PHONE";
+ }
+ if (switchType.value === "Email") {
+ return "EMAIL";
+ }
}
function goToLogin() {
diff --git a/stores/index.js b/stores/index.js
index ada9fd8..56ec367 100644
--- a/stores/index.js
+++ b/stores/index.js
@@ -10,5 +10,6 @@ pinia.use(persist)
export * from './modules/userInfo'
export * from './modules/deviceInfo'
export * from './modules/deepExploration'
+export * from './modules/login'
// 默认导出,给 main.js 使用
export default pinia
\ No newline at end of file
diff --git a/stores/modules/login.js b/stores/modules/login.js
new file mode 100644
index 0000000..b2041ea
--- /dev/null
+++ b/stores/modules/login.js
@@ -0,0 +1,44 @@
+import { defineStore } from 'pinia'
+import { ref } from 'vue'
+
+// 定义 Store
+export const useLoginStore = defineStore(
+ 'login',
+ () => {
+ // 会员信息
+ const loginInfo = ref("true")
+
+ // 保存会员信息,登录时使用
+ const setLoginInfo = (val) => {
+ loginInfo.value = val
+ }
+
+ // 清理会员信息,退出时使用
+ const clearLoginInfo = () => {
+ loginInfo.value = undefined
+ }
+
+ // 记得 return
+ return {
+ loginInfo,
+ setLoginInfo,
+ clearLoginInfo,
+ }
+ },
+ // TODO: 持久化
+ {
+ // 网页端持久化
+ // persist: true,
+ // 小程序端持久化
+ persist: {
+ storage: {
+ getItem(key) {
+ return uni.getStorageSync(key)
+ },
+ setItem(key, value) {
+ uni.setStorageSync(key, value)
+ },
+ },
+ },
+ },
+)
diff --git a/utils/http.js b/utils/http.js
index 125a156..afaeefa 100644
--- a/utils/http.js
+++ b/utils/http.js
@@ -1,5 +1,6 @@
import { useUserStore } from "../stores/modules/userInfo"
import { useDeviceStore } from "../stores/modules/deviceInfo"
+import { useLoginStore } from "../stores/modules/login"
const baseURL = "https://dbqb.nfdxy.net/testApi"
@@ -28,7 +29,7 @@ const httpInterceptor = {
const sys = uni.getSystemInfoSync();
// 为对齐后端文档示例,client 固定为 ios(如需按平台设置再改回)
- const deviceInfo =useDeviceStore()
+ const deviceInfo = useDeviceStore()
options.header = {
@@ -37,7 +38,7 @@ const httpInterceptor = {
'content-type': 'application/json',
'contentType': 'application/json',
'version': uni.getSystemInfoSync().appVersion,
- 'client': uni.getSystemInfoSync().platform == 'ios' ? 'ios' : 'android',
+ 'client': uni.getSystemInfoSync().platform == 'ios' ? 'ios' : 'android',
'deviceId': deviceInfo.deviceInfo.deviceId
}
//4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致
@@ -64,6 +65,14 @@ export const http = (options) => {
success: (result) => {
if (result.statusCode >= 200 && result.statusCode < 300) {
if (result.data.code === 401) {
+
+ const loginStore = useLoginStore()
+ loginStore.setLoginInfo("true")
+ console.log("1loginStore.loginInfo", loginStore.loginInfo);
+
+ loginStore.setLoginInfo("false")
+ console.log("2loginStore.loginInfo", loginStore.loginInfo);
+
uni.showToast({
title: '请先登录',
icon: 'none'