Browse Source

Merge branch 'wangyi/feature-20251026183100-deepmate王毅' into milestone-20251031-简版功能开发

lihuilin/feature-20251024095243-我的
wangyi 4 weeks ago
parent
commit
c926bc38fb
  1. 30
      api/start/login.js
  2. 2
      components/deepExploration_header.vue
  3. 25
      components/login-prompt.vue
  4. 10
      pages/deepMate/deepMate.vue
  5. 1
      pages/start/Registration/Registration.vue
  6. 93
      pages/start/recoverPassword/recoverPassword.vue
  7. 1
      stores/index.js
  8. 44
      stores/modules/login.js
  9. 11
      utils/http.js

30
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,
})
}
/**
* 修改密码
*

2
components/deepExploration_header.vue

@ -72,6 +72,7 @@
<view class="history-main" @click="itemClick(item)">
<text class="history-query">{{ item.stockName }}</text>
<text class="history-query">{{ item.stockCode }}</text>
<text class="history-query">{{ item.stockCode }}</text>
</view>
<text class="history-time">{{
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;

25
components/login-prompt.vue

@ -15,20 +15,40 @@
</template>
<script setup>
import { ref, nextTick, onMounted } from "vue";
import { ref, nextTick, onMounted, watch } from "vue";
import { useUserStore } from "../stores/modules/userInfo";
import { useDeviceStore } from "../stores/modules/deviceInfo";
import { useLoginStore } from "../stores/modules/login";
import { LoginApi } from "../api/start/login";
const deviceId = ref("");
const userStore = useUserStore();
const deviceStore = useDeviceStore();
const loginStore = useLoginStore();
//
onMounted(() => {
if (!userStore.userInfo) {
show();
}
});
}),
// watch(
// () => loginStore.loginInfo,
// (newVal, oldVal) => {
// console.log("");
// if (newVal === "false") {
// console.log("");
// show();
// loginStore.setLoginInfo("true");
// }
// }
// );
loginStore.$subscribe(() => {
if (loginStore.loginInfo === "false") {
console.log("登录失败");
show();
}
});
//
const showPrompt = ref(false);
@ -84,6 +104,7 @@ const continueAsVisitor = async () => {
if (res.code === 200) {
userStore.setUserInfo(res.data);
console.log("0loginStore.loginInfo", loginStore.loginInfo);
hide();
}
};

10
pages/deepMate/deepMate.vue

@ -297,6 +297,13 @@ import {
postHistory,
postHistoryDetail,
} from "../../api/deepMate/deepMate";
const renderer = new marked.Renderer();
renderer.heading = function(text, level) {
return `<p>${text}</p>`;
};
// marked
marked.setOptions({
renderer: new marked.Renderer(),
@ -926,7 +933,10 @@ async function itemClick(item) {
isTyping: false,
isThinking: false,
};
onDrawerBackClick()
messages.value.push(botMsg);
}
}
</script>

1
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("");

93
pages/start/recoverPassword/recoverPassword.vue

@ -209,9 +209,9 @@
</text>
<!-- 或者 -->
<text class="or-text" @click="goToLogin">已有账号
<text class="link">登录
</text>
<text class="or-text" @click="goToLogin"
>已有账号
<text class="link">登录 </text>
</text>
<!-- 同意弹窗 -->
@ -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() {

1
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

44
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)
},
},
},
},
)

11
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 = {
@ -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'

Loading…
Cancel
Save