-
黑马头条
- 主要按钮
- 信息按钮
- 默认按钮
- 警告按钮
- 危险按钮
-
-
+
+
-
+
diff --git a/src/api/index.js b/src/api/index.js
new file mode 100644
index 0000000..044d7a7
--- /dev/null
+++ b/src/api/index.js
@@ -0,0 +1,11 @@
+
+/*
+ *用户登录api
+ */
+import { login, getSmsCode } from './user'
+export const loginAPI = login // 导出用户接口api
+
+/*
+ * 获取验证码
+ */
+export const getSmsCodeAPI = getSmsCode
diff --git a/src/api/user.js b/src/api/user.js
new file mode 100644
index 0000000..46b857f
--- /dev/null
+++ b/src/api/user.js
@@ -0,0 +1,21 @@
+/*
+ *用户相关的请求模块
+ */
+import request from '@/utils/request'
+/*
+ *登录模块
+ */
+export const login = (data) => request({
+ url: '/app/v1_0/authorizations',
+ method: 'post',
+ data
+})
+
+/*
+ *获取验证码--一分钟只能发一次
+ !该接口不可用
+ */
+export const getSmsCode = mobile => request({
+ method: 'get',
+ url: `/app/v1_0/sms/codes/${mobile}`
+})
diff --git a/src/css/index.css b/src/css/index.css
index 2deafa8..7e52b0f 100644
--- a/src/css/index.css
+++ b/src/css/index.css
@@ -75,3 +75,12 @@
.toutiao-fenxiang:before {
content: "\e607";
}
+body {
+ background-color: #f5f7f9;
+}
+body .page-nav-bar {
+ background-color: #3296fa;
+}
+body .page-nav-bar .van-nav-bar__title {
+ color: #fff;
+}
diff --git a/src/main.js b/src/main.js
index ea2ec73..363c589 100644
--- a/src/main.js
+++ b/src/main.js
@@ -2,9 +2,15 @@ import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
+// 加载全局样式
import '@/styles/index.less'
+// 加载vant 核心组件库
import Vant from 'vant'
+// 加载vant 全局样式
import 'vant/lib/index.css'
+
+// 加载动态设置rem基准值
+import 'amfe-flexible'
Vue.use(Vant)
Vue.config.productionTip = false
diff --git a/src/router/index.js b/src/router/index.js
index de40895..265e91e 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -4,6 +4,11 @@ import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [
+ {
+ path: '/login',
+ name: 'login',
+ component: () => import('@/views/login')
+ }
]
diff --git a/src/store/index.js b/src/store/index.js
index ceffa8e..3499d7b 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -1,6 +1,6 @@
import Vue from 'vue'
import Vuex from 'vuex'
-
+import user from '@/store/modules/user'
Vue.use(Vuex)
export default new Vuex.Store({
@@ -13,5 +13,6 @@ export default new Vuex.Store({
actions: {
},
modules: {
+ user
}
})
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
new file mode 100644
index 0000000..8b4b972
--- /dev/null
+++ b/src/store/modules/user.js
@@ -0,0 +1,21 @@
+import { getItem, setItem } from '@/utils/storage'
+export default {
+ namespaced: true,
+ state: {
+ // 获取本地token
+ userToken: getItem('user')
+ },
+ mutations: {
+ changeUserToken (state, userToken) {
+ state.userToken = userToken
+ // 将token存入本地
+ setItem('user', userToken)
+ }
+ },
+ actions: {
+
+ },
+ getters: {
+
+ }
+}
diff --git a/src/styles/index.less b/src/styles/index.less
index 284508d..5055d6d 100644
--- a/src/styles/index.less
+++ b/src/styles/index.less
@@ -1,2 +1,12 @@
// 引入icon.less
-@import './icon.less';
\ No newline at end of file
+@import './icon.less';
+
+body {
+ background-color: #f5f7f9;
+ .page-nav-bar {
+ background-color: #3296fa;
+ .van-nav-bar__title {
+ color: #fff;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/utils/request.js b/src/utils/request.js
new file mode 100644
index 0000000..97acc27
--- /dev/null
+++ b/src/utils/request.js
@@ -0,0 +1,11 @@
+/*
+ * 封装 axios 请求模块
+ */
+import axios from 'axios'
+axios.defaults.baseURL = 'http://api-toutiao-web.itheima.net'
+const request = axios
+
+// const request = axios.create({
+// baseURL: "http://ttapi.research.itcast.cn"
+// })
+export default request
diff --git a/src/utils/storage.js b/src/utils/storage.js
new file mode 100644
index 0000000..a39519d
--- /dev/null
+++ b/src/utils/storage.js
@@ -0,0 +1,26 @@
+/*
+ *本地存储方法封装
+*/
+
+// 获取本地存储数据
+export const getItem = (key) => {
+ const data = localStorage.getItem(key)
+ try {
+ return JSON.parse(data)
+ } catch (err) {
+ return data
+ }
+}
+
+// 向本地存储存入数据
+export const setItem = (key, value) => {
+ if (typeof value === 'object') {
+ value = JSON.stringify(value)
+ }
+ localStorage.setItem(key, value)
+}
+
+// 移除本地存储数据
+export const removeItem = (key) => {
+ localStorage.removeItem(key)
+}
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
new file mode 100644
index 0000000..b55f1b2
--- /dev/null
+++ b/src/views/login/index.vue
@@ -0,0 +1,201 @@
+