diff --git a/rc-busness/assets/css/openaddress.less b/rc-busness/assets/css/openaddress.less index cfd8a9ea..b3c14f13 100644 --- a/rc-busness/assets/css/openaddress.less +++ b/rc-busness/assets/css/openaddress.less @@ -130,10 +130,10 @@ margin:0 auto; justify-content: space-between } .usercontshow{ - min-height: 20vh; + // min-height: 20vh; margin-bottom: 2rem; - padding-left:.5rem; - padding-right:.5rem; + // padding-left:.5rem; + // padding-right:.5rem; } .rc-button{ @@ -268,7 +268,7 @@ display: none; border: 1px solid #D7D7D7; border-radius: 3px; position: relative; - margin-left: 20px; + // margin-left: 20px; } .alledit{ diff --git a/rc-busness/components/address.vue b/rc-busness/components/address.vue index debd1f9a..e5f6a2a2 100644 --- a/rc-busness/components/address.vue +++ b/rc-busness/components/address.vue @@ -42,6 +42,7 @@ - \ No newline at end of file + diff --git a/rc-busness/components/header.vue b/rc-busness/components/header.vue index 50120a90..5c4d5677 100644 --- a/rc-busness/components/header.vue +++ b/rc-busness/components/header.vue @@ -1,157 +1,145 @@ - \ No newline at end of file + diff --git a/rc-busness/components/unlogin.vue b/rc-busness/components/unlogin.vue index db5f8889..1f88547b 100644 --- a/rc-busness/components/unlogin.vue +++ b/rc-busness/components/unlogin.vue @@ -1,86 +1,99 @@ - \ No newline at end of file + diff --git a/rc-busness/config/async/fetch.js b/rc-busness/config/async/fetch.js index d9ce1b29..d0def938 100644 --- a/rc-busness/config/async/fetch.js +++ b/rc-busness/config/async/fetch.js @@ -1,6 +1,7 @@ import { baseUrl -} from './env' +} from './env'; + export default async(url = '', data = {}, type = 'GET', method = 'fetch') => { type = type.toUpperCase() @@ -18,16 +19,18 @@ export default async(url = '', data = {}, type = 'GET', method = 'fetch') => { url = url + '?' + dataStr } } - + + if (fetch && method === 'fetch') { let token=''; if(process.client) { - let tokenStr = localStorage.getItem("userInfo"); - if(tokenStr){ - tokenStr = JSON.parse(tokenStr); - if(tokenStr && tokenStr.xaccessToken) - token=tokenStr.xaccessToken; - } + token = localStorage.getItem("token"); + // let tokenStr = localStorage.getItem("userInfo"); + // if(tokenStr){ + // tokenStr = JSON.parse(tokenStr); + // if(tokenStr && tokenStr.xaccessToken) + // token=tokenStr.xaccessToken; + // } } let requestConfig = { method: type, diff --git a/rc-busness/nuxt.config.js b/rc-busness/nuxt.config.js index cf6a46a5..c96f3288 100644 --- a/rc-busness/nuxt.config.js +++ b/rc-busness/nuxt.config.js @@ -57,7 +57,7 @@ export default { '@/plugins/swiper', '@/plugins/ElementUI', { src: '@/plugins/localStorage', ssr: false }, - + '@/plugins/until/common', ], @@ -73,7 +73,7 @@ export default { modules: [ '@nuxtjs/axios', ['nuxt-tailvue', {toast: true}], - + 'cookie-universal-nuxt', ], styleResources: { diff --git a/rc-busness/package.json b/rc-busness/package.json index 0ba14800..1d65da35 100644 --- a/rc-busness/package.json +++ b/rc-busness/package.json @@ -17,6 +17,7 @@ "dependencies": { "@nuxtjs/axios": "^5.13.6", "amfe-flexible": "^2.2.1", + "cookie-universal-nuxt": "^2.1.5", "core-js": "^3.15.1", "element-ui": "^2.15.6", "ip": "^1.1.5", diff --git a/rc-busness/pages/index.vue b/rc-busness/pages/index.vue index 80600ff7..2f2673b9 100644 --- a/rc-busness/pages/index.vue +++ b/rc-busness/pages/index.vue @@ -1043,7 +1043,7 @@ import Myheader from "~/components/header.vue"; import FixRight from "~/components/fixed-right.vue"; import Myfooter from "~/components/rc-footer.vue"; import unlogin from "~/components/unlogin.vue"; -import { mapMutations } from "vuex"; +import { mapMutations,mapState } from "vuex"; import envData from "~/config/env-data.js"; import { userquery, @@ -1354,11 +1354,22 @@ export default { FixRight, // userswiper }, - created() { + computed: { + ...mapState({ + loginState : state => state.login.loginState, + userInfo : state => state.user.userInfo, + }) + }, + async created() { vm = this; let curEnv = process.env.NODE_ENV; this.catlistvideo = envData[curEnv].catlistvideo; this.doglistvideo = envData[curEnv].doglistvideo; + /* 判断是否登录 */ + await this.$store.dispatch('checkLoginState',this); + if(this.loginState && !this.userInfo){ + this.$store.dispatch('getUserInfo',this); + } }, watch: {}, mounted() { diff --git a/rc-busness/pages/myorder/userrecord.vue b/rc-busness/pages/myorder/userrecord.vue index 79732038..d1124221 100644 --- a/rc-busness/pages/myorder/userrecord.vue +++ b/rc-busness/pages/myorder/userrecord.vue @@ -1,101 +1,86 @@ \ No newline at end of file + diff --git a/rc-busness/pages/myorder/usertion.vue b/rc-busness/pages/myorder/usertion.vue index 56332b2b..38470413 100644 --- a/rc-busness/pages/myorder/usertion.vue +++ b/rc-busness/pages/myorder/usertion.vue @@ -1,444 +1,429 @@ \ No newline at end of file +@import url('../../assets/css/usertion.less'); + diff --git a/rc-busness/pages/personal/discount.vue b/rc-busness/pages/personal/discount.vue index 56e1dd01..222f3da1 100644 --- a/rc-busness/pages/personal/discount.vue +++ b/rc-busness/pages/personal/discount.vue @@ -1,275 +1,264 @@ - \ No newline at end of file +@import url('../../assets/css/discount.less'); + diff --git a/rc-busness/pages/personal/integral.vue b/rc-busness/pages/personal/integral.vue index b71d1644..3b6a3ee6 100644 --- a/rc-busness/pages/personal/integral.vue +++ b/rc-busness/pages/personal/integral.vue @@ -1,127 +1,111 @@ \ No newline at end of file +@import url('../../assets/css/integral.less'); + diff --git a/rc-busness/pages/personal/mypersonal.vue b/rc-busness/pages/personal/mypersonal.vue index eb39c0c7..4d5c8ec3 100644 --- a/rc-busness/pages/personal/mypersonal.vue +++ b/rc-busness/pages/personal/mypersonal.vue @@ -1,429 +1,416 @@ \ No newline at end of file +@import url('@/assets/css/global.less'); +@import url('@/assets/css/mypersonal.less'); + + diff --git a/rc-busness/pages/personal/settlement.vue b/rc-busness/pages/personal/settlement.vue index 79a6afbc..d87964be 100644 --- a/rc-busness/pages/personal/settlement.vue +++ b/rc-busness/pages/personal/settlement.vue @@ -1,357 +1,303 @@ \ No newline at end of file + diff --git a/rc-busness/pages/personal/useraddress.vue b/rc-busness/pages/personal/useraddress.vue index 1415c2ea..efc1020d 100644 --- a/rc-busness/pages/personal/useraddress.vue +++ b/rc-busness/pages/personal/useraddress.vue @@ -1,479 +1,466 @@ \ No newline at end of file +@import url('../../assets/css/orderquantity.less'); + diff --git a/rc-busness/pages/personal/usermember.vue b/rc-busness/pages/personal/usermember.vue index 77611bc1..fa4ccd5c 100644 --- a/rc-busness/pages/personal/usermember.vue +++ b/rc-busness/pages/personal/usermember.vue @@ -1,23 +1,21 @@ \ No newline at end of file +@import url('../../assets/css/usermember.less'); + diff --git a/rc-busness/pages/personal/userpay.vue b/rc-busness/pages/personal/userpay.vue index ee5c9aec..0357f775 100644 --- a/rc-busness/pages/personal/userpay.vue +++ b/rc-busness/pages/personal/userpay.vue @@ -1,450 +1,435 @@ - \ No newline at end of file + diff --git a/rc-busness/pages/productdetails/producted.vue b/rc-busness/pages/productdetails/producted.vue index 345747fc..fb92f05d 100644 --- a/rc-busness/pages/productdetails/producted.vue +++ b/rc-busness/pages/productdetails/producted.vue @@ -1,61 +1,58 @@ \ No newline at end of file +@import url("../../assets/css/global.less"); +@import url('../../assets/css/producted.less'); + diff --git a/rc-busness/pages/useraddress/addaddress.vue b/rc-busness/pages/useraddress/addaddress.vue index bb6b69f7..3f763a82 100644 --- a/rc-busness/pages/useraddress/addaddress.vue +++ b/rc-busness/pages/useraddress/addaddress.vue @@ -1,236 +1,222 @@ - diff --git a/rc-busness/pages/useraddress/editaddress.vue b/rc-busness/pages/useraddress/editaddress.vue index a91488ac..c73c92a6 100644 --- a/rc-busness/pages/useraddress/editaddress.vue +++ b/rc-busness/pages/useraddress/editaddress.vue @@ -1,258 +1,247 @@ - diff --git a/rc-busness/pages/useraddress/openaddress.vue b/rc-busness/pages/useraddress/openaddress.vue index 9d6f4b9b..6b51d5db 100644 --- a/rc-busness/pages/useraddress/openaddress.vue +++ b/rc-busness/pages/useraddress/openaddress.vue @@ -1,206 +1,203 @@ - \ No newline at end of file + diff --git a/rc-busness/pages/userlogin/login.vue b/rc-busness/pages/userlogin/login.vue index 623ac748..8e7a2c47 100644 --- a/rc-busness/pages/userlogin/login.vue +++ b/rc-busness/pages/userlogin/login.vue @@ -152,7 +152,8 @@ export default { envData, phone: "", layerMSg: "手机格式不对", - tel: "", + tel: "", // 15766132405 18825059708 + sms: "", //去除记得把验证码打开 1234 password: "", userdata:{}, allcheck:false, @@ -165,7 +166,6 @@ export default { ], hash:'', text: "", - sms: "", buttonmsg: "获取验证码", flag: false, adminCode: "", @@ -220,13 +220,14 @@ export default { }, ...mapState({ userInfo : state => state.user.userInfo, + loginState : state => state.login.loginState, }) }, mounted() { //console.log(this.$route.params); - this.checkIsLogin(); - let user = this.$store.state.userInfo; - if(user) { + // this.checkIsLogin(); + // let user = this.$store.state.userInfo; + if(this.loginState && this.userInfo) { this.$router.push({ path: "/personal/mypersonal", }); @@ -401,13 +402,21 @@ export default { } } else{ - let data=await this.vadmsg(); + /* 暂时关闭短信验证 */ + let data = await this.vadmsg(); + // let data = { + // code : 1, + // } if(data.code=="1") { data = await userregOrLogin(this.tel); let token=JSON.stringify(data); - this.changeClod({ cloud: token }); - this.checkIsLogin(); + this.$store.dispatch('setUserInfo',{ + data : data, + app : this, + }); + // this.changeClod({ cloud: token }); + // this.checkIsLogin(); let returnMessage=''; if(data.type==1) { if(data.data.memberName===undefined){ diff --git a/rc-busness/pages/usersearch/search.vue b/rc-busness/pages/usersearch/search.vue index 14da32d1..98aa5f37 100644 --- a/rc-busness/pages/usersearch/search.vue +++ b/rc-busness/pages/usersearch/search.vue @@ -571,12 +571,19 @@ export default { tabs }, mounted() { + const { query } = this.$route; + this.activeIndex1 = query.type || 0; + this.activeIndex = query.type || 0; + this.value = query.content || ''; this.usetmessage(); this.userst(); //Handling RxGoods filter let curEnv = process.env.NODE_ENV; this.rxFilters = envData[curEnv].rxGoodsFilter; //Handling RxGoods filter end + + console.log(); + }, methods: { //换一批 @@ -723,6 +730,7 @@ export default { this.$nextTick(() => { this.$refs.userstandard[0].style.margin = 0 + "px"; }); + console.log(this.activeIndex1, this.value,'this.activeIndex1, this.value'); let data = await biaome(this.activeIndex1, this.value, 1, 10); if (data) { this.rccontair = data; diff --git a/rc-busness/plugins/until/common.js b/rc-busness/plugins/until/common.js new file mode 100644 index 00000000..88ca169f --- /dev/null +++ b/rc-busness/plugins/until/common.js @@ -0,0 +1,24 @@ +/** + * 这个是一些全局函数方法 + */ +import { Message } from 'element-ui'; + + +export default ({ app }, inject) => { + /** + * 消息提示框 + * msg 提示语 + * type 提示框状态 success/warning/info/error + * duration 默认3秒 + */ + inject('messageToast',(msg,type='success',duration=3000)=>{ + Message({ + type : type || 'success', + message : msg, + duration + }) + }) + + + inject('myInjectedFunction', string => Message('That was easy!', string)); +} \ No newline at end of file diff --git a/rc-busness/plugins/until/until.js b/rc-busness/plugins/until/until.js index a7d8a72f..67250c13 100644 --- a/rc-busness/plugins/until/until.js +++ b/rc-busness/plugins/until/until.js @@ -3,7 +3,7 @@ */ /** - * 设置cookie的值 + * 设置cookie的值(获取的是前端的 nuxt框架不可用 用cookie-universal-nuxt获取存放的token) * @param {String} key cookie的键 * @param {String} val cookie的值 * @param {String} exdays 过期时间默认的话是7天 @@ -16,7 +16,7 @@ const setCookie = (key,val,exdays = 7)=>{ } /** - * 获取cookie的值 + * 获取cookie的值(获取的是前端的 nuxt框架不可用 用cookie-universal-nuxt获取存放的token) * @param {String} key cookie的键 */ const getCookie = (key)=>{ @@ -30,8 +30,6 @@ const getCookie = (key)=>{ } - - export { setCookie, getCookie, diff --git a/rc-busness/store/index.js b/rc-busness/store/index.js index cfdaa024..cef673b0 100644 --- a/rc-busness/store/index.js +++ b/rc-busness/store/index.js @@ -1,74 +1,88 @@ - import user from './modules/user.js'; - - +import user from './modules/user.js'; + import login from './modules/login.js'; + const state = () => ({ - // 这里是全局数据保存的地方 - tabsList: [ - { - path: '/', - name: 'index', - meta:{ - title: '首页', - - } - }, - ] + // 这里是全局数据保存的地方 + tabsList: [{ + path: '/', + name: 'index', + meta: { + title: '首页', -}) + } + }, ], + userInfo : null, //以前遗留的问题 用户数据后台统一用modal里面的userInfo + userKey : 'user_mobile', //存储用户的KEY值 + tokenKey : 'token', //存储用户token的key + -const mutations = { -// changeLogin(state, val) { -// console.log(state,val); -// let list=[]; -// list.push(val); + }) -// JSON.parse(list); -// console.log(list); -// localStorage.setItem("cardata", list); -// }, - changeClod(state, val) { - localStorage.setItem('userInfo', val.cloud); - }, - logoutSystem(state) { - localStorage.removeItem('userInfo') - }, - checkIsLogin(state) { - let rawUserInfoStr = localStorage.getItem('userInfo'); - let rawUserInfo = JSON.parse(rawUserInfoStr); - if(rawUserInfo && rawUserInfo.hasOwnProperty('xaccessToken') && rawUserInfo['xaccessToken'].length>36) - state.userInfo = rawUserInfo; - else - state.userInfo = undefined; - }, - changemessage(state, val) { - localStorage.setItem('message', val.data); - }, - selectMenu(state, val) { - let result = state.tabsList.findIndex(item => item.name === val.data.name) - result === -1 ? state.tabsList.push(val.data) : '' - }, + const mutations = { + // changeLogin(state, val) { + // console.log(state,val); + // let list=[]; + // list.push(val); -// changeMenu(state, user){ -// // console.log("vuex存储的变化",JSON.parse(user)) -// // console.log("vuex存储的变化",user) -// state.menuList = user; -// localStorage.setItem('menuList', user); -// } -} + // JSON.parse(list); + // console.log(list); + // localStorage.setItem("cardata", list); + // }, + changeClod(state, val) { + localStorage.setItem('userInfo', val.cloud); + }, + logoutSystem(state) { + localStorage.removeItem('userInfo') + }, + checkIsLogin(state) { + let rawUserInfoStr = localStorage.getItem('userInfo'); + let rawUserInfo = JSON.parse(rawUserInfoStr); + if (rawUserInfo && rawUserInfo.hasOwnProperty('xaccessToken') && rawUserInfo['xaccessToken'].length > 36) + state.userInfo = rawUserInfo; + else + state.userInfo = undefined; + }, + changemessage(state, val) { + localStorage.setItem('message', val.data); + }, + selectMenu(state, val) { + let result = state.tabsList.findIndex(item => item.name === val.data.name) + result === -1 ? state.tabsList.push(val.data) : '' + }, + + + SET_INDEX_USER_INFO(state,data){ + state.userInfo = data; + } -const actions = { - setPosition: ({ - commit - }, position) => { - commit('setPosition', position) - } -} + // changeMenu(state, user){ + // // console.log("vuex存储的变化",JSON.parse(user)) + // // console.log("vuex存储的变化",user) + // state.menuList = user; + // localStorage.setItem('menuList', user); + // } + } -/* 功能模块 */ -const modules = { - user, -} + const actions = { + setPosition: ({ + commit + }, position) => { + commit('setPosition', position) + } + } + + /* 功能模块 */ + const modules = { + user, + login + } -export default {namespaced: true, state, mutations, actions,modules} + export default { + namespaced: true, + state, + mutations, + actions, + modules + } diff --git a/rc-busness/store/modules/login.js b/rc-busness/store/modules/login.js index 2d2409f6..4288a3b1 100644 --- a/rc-busness/store/modules/login.js +++ b/rc-busness/store/modules/login.js @@ -1,17 +1,57 @@ +// import { getCookie } from "../../plugins/until/until.js"; export default { - state : { - des : '这个存储用户登录逻辑操作', - loginState : false, //登录状态 + state: { + des: '这个存储用户登录逻辑操作', + loginState: false, //登录状态 }, /* 存储修改状态的静态方法 */ - mutations : { + mutations: { /* 设置登录状态 */ - SET_LOGIN_STATE(state){ - console.log(state); - } + SET_LOGIN_STATE(state, value) { + state.loginState = value + }, }, /* 存储修改数据的动态方法 */ - actions : { - + actions: { + /** + * 判断是否登录 + * context + * app vue 实例 + */ + checkLoginState(context, app) { + let key = context.rootState.userKey; + let mobile = app.$cookies.get(key); + let isHasToken = false; + if (mobile == undefined || !mobile || mobile == 'mobile') { + isHasToken = false; + } else { + isHasToken = true; + /* 更新用户数据 */ + if (!context.rootState.user.userInfo) { + context.dispatch('getUserInfo', app, { + root: true + }); + } + } + context.commit('SET_LOGIN_STATE', isHasToken); + }, + /** + * 退出登录 + * @param {Object} context 上下文 + * @param {Object} app vue 实例 + */ + logout(context, app){ + let userKey = context.rootState.userKey; + let tokenKey = context.rootState.tokenKey; + app.$cookies.remove(userKey); + app.$cookies.remove(tokenKey); + context.commit('SET_USER_INFO', null, { + root: true + }); + context.commit('SET_INDEX_USER_INFO', null, { + root: true + }); + localStorage.removeItem(tokenKey) + } } -} \ No newline at end of file +} diff --git a/rc-busness/store/modules/user.js b/rc-busness/store/modules/user.js index 1c90c321..22aafd68 100644 --- a/rc-busness/store/modules/user.js +++ b/rc-busness/store/modules/user.js @@ -1,18 +1,61 @@ +import Vue from "vue"; +import { userregOrLogin } from '../../ajax/getData.js'; + + export default { - state : { - des : '这个存储用户数据的模块列表', - userInfo : {}, //用户信息 - loginState : false, //登录状态 + state: { + des: '这个存储用户数据的模块列表', + userInfo: null, //用户信息 + loginState: false, //登录状态 }, /* 存储修改状态的静态方法 */ - mutations : { + mutations: { /* 设置用户信息 */ - SET_USER_INFO(state){ - console.log(state); + SET_USER_INFO(state, userInfo) { + state.userInfo = userInfo; } }, /* 存储修改数据的动态方法 */ - actions : { - + actions: { + /** + * 设置会员信息 + * @param {Object} context 上下文 + * @param {Object} { + data : 后台返回的用户数据 + app : vue实例this + } + */ + setUserInfo(context, { + data, + app + }) { + const userKey = context.rootState.userKey; + const tokenKey = context.rootState.tokenKey; + const userInfo = data.data; + const { + mobile + } = userInfo; + /* 存储数据 变更登录状态 */ + app.$cookies.set(userKey, mobile); + app.$cookies.set(tokenKey, data.xaccessToken); + localStorage.setItem(tokenKey,data.xaccessToken); + context.commit('SET_USER_INFO', userInfo); + context.commit('SET_LOGIN_STATE', true, { + root: true + }); + context.commit('SET_INDEX_USER_INFO', data, { + root: true + }); + }, + /* 获取用户数据 */ + async getUserInfo(context,app){ + let key = context.rootState.userKey; + let mobile = app.$cookies.get(key); + const data = await userregOrLogin(app.$cookies.get(key)); + context.dispatch('setUserInfo',{ + data, + app, + }) + } } -} \ No newline at end of file +}