From 19061b17591c3a2310348033eb51194f5a9a4527 Mon Sep 17 00:00:00 2001
From: zzzz <690498789@qq.com>
Date: Tue, 09 Apr 2024 11:40:10 +0800
Subject: [PATCH] first commit
---
src/page/login/login.vue | 4 +
src/store/index.js | 25 ++++++++++--
src/page/trading/buy.vue | 28 +++++--------
src/App.vue | 23 ++---------
4 files changed, 40 insertions(+), 40 deletions(-)
diff --git a/src/App.vue b/src/App.vue
index 3b9ab13..c49c629 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -40,7 +40,8 @@
// 引入css
import "@/assets/iconfont/iconfont.css";
import "@/assets/iconfont/iconfont.ttf";
-import { getUserInfodata } from "./axios/api";
+
+import { mapActions } from "vuex";
export default {
components: {
@@ -50,9 +51,8 @@
},
name: "App",
created() {
- this.getUserInfo();
+ this.setUseInfo();
this.$state.theme = "red";
- console.log(this.$state.theme, "asdasdasd");
let title = this.$route.meta.title || this.$t("hj224");
this.title = title;
if (this.$route.meta.is_Show) {
@@ -108,21 +108,8 @@
};
},
methods: {
- async getUserInfo() {
- // 获取用户信息
- // let showcookie = this.getCookie('USER_TOKEN');
- let data = await getUserInfodata();
- if (data.status === 0) {
- // this.getProductSetting()
- this.$store.state.userInfo = data.data;
- } else {
- this.$store.commit("elAlertShow", {
- elAlertShow: true,
- elAlertText: data.msg,
- });
- }
- this.$store.state.user = this.user;
- },
+ ...mapActions(["setUseInfo"]),
+
footColse() {
this.$store.commit("dialogVisible", true);
},
diff --git a/src/page/login/login.vue b/src/page/login/login.vue
index 8d3c048..8925c62 100644
--- a/src/page/login/login.vue
+++ b/src/page/login/login.vue
@@ -62,7 +62,7 @@
import headers from "./components/header.vue";
import * as api from "@/axios/api";
import { Notify } from "vant";
-import { mapMutations } from "vuex";
+import { mapActions, mapMutations } from "vuex";
export default {
name: "newLogin",
@@ -92,6 +92,7 @@
},
methods: {
+ ...mapActions(["setUseInfo"]),
...mapMutations(["undataToken"]),
checkboxChange(e) {
window.localStorage.setItem("login_checked", e);
@@ -116,6 +117,7 @@
let data = await api.login(opts);
if (data.status === 0) {
+ this.setUseInfo();
if (this.checked) {
window.localStorage.setItem(
"login_admin",
diff --git a/src/page/trading/buy.vue b/src/page/trading/buy.vue
index cde6f52..e3edf13 100644
--- a/src/page/trading/buy.vue
+++ b/src/page/trading/buy.vue
@@ -228,6 +228,7 @@
<script>
import * as api from "@/axios/api";
+import { mapActions } from "vuex";
export default {
name: "trBuy",
@@ -313,7 +314,7 @@
} else if (this.bayType == "qh") {
this.priceTabs = [this.$t("hj108")];
}
- this.getUserInfo();
+ this.setUseInfo();
this.getMoneyData();
this.getSettingInfo();
},
@@ -332,6 +333,8 @@
},
},
methods: {
+ ...mapActions(["setUseInfo"]),
+
async getMoneyData() {
let data = await api.getMoney();
let type = this.bayType === "SZHB" ? "US" : this.bayType;
@@ -476,15 +479,7 @@
this.$router.push("/authentications");
return;
}
- // if (!this.agree) {
- // Toast('需同意合作协议才能交易!')
- // } else if (isNull(this.selectNumber) && isNull(this.autoNumber)) {
- // Toast('请选择购买手数')
- // } else if (isNull(this.selectType)) {
- // Toast('请选择买卖方向')
- // } else if(isNull(this.subaccountNumber)) {
- // Toast('请选择子账户')
- // } else {}
+
if (this.buying) {
return;
}
@@ -538,18 +533,17 @@
elAlertType: "success",
});
this.getUserInfo();
- var buyType = ''
+ var buyType = "";
if (this.tabsCurrentIndex == 0) {
buyType = 1;
} else {
buyType = 0;
}
- if(this.bayType=='US'){
-
- this.$router.push("/warehouse?index=1&buyType="+buyType);
- }else if(this.bayType=='MAS'){
- this.$router.push("/warehouse?index=0&buyType="+buyType);
- }else {
+ if (this.bayType == "US") {
+ this.$router.push("/warehouse?index=1&buyType=" + buyType);
+ } else if (this.bayType == "MAS") {
+ this.$router.push("/warehouse?index=0&buyType=" + buyType);
+ } else {
this.$router.push("/warehouse");
}
} else {
diff --git a/src/store/index.js b/src/store/index.js
index eda41e4..cc6c409 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -1,3 +1,4 @@
+import { getUserInfodata } from "@/axios/api";
import Vue from "vue";
import Vuex from "vuex";
// import getters from './getters'
@@ -9,9 +10,9 @@
let state = {
className: "black",
theme: "red",
- userInfo: {
- // 用户信息
- },
+ userInfo: window.localStorage.getItem("useInfo")
+ ? JSON.parse(window.localStorage.getItem("useInfo"))
+ : {},
user: {},
bankInfo: {
bankNo: ""
@@ -34,8 +35,24 @@
export default new Vuex.Store({
state,
- actions: {},
+ actions: {
+ async setUseInfo({ commit }) {
+ let data = await getUserInfodata();
+ if (data.status === 0) {
+ commit("SET_USE_INFO", data.data);
+ } else {
+ commit("elAlertShow", {
+ elAlertShow: true,
+ elAlertText: data.msg
+ });
+ }
+ }
+ },
mutations: {
+ SET_USE_INFO(state, useInfo) {
+ state.userInfo = useInfo;
+ window.localStorage.setItem("useInfo", JSON.stringify(useInfo));
+ },
undataToken(state, token) {
state.token = token || null;
},
--
Gitblit v1.9.3