Selaa lähdekoodia

Merge branch 'hcb' of SH-Arbitrate/miniapp into dev

hejinbo 2 vuotta sitten
vanhempi
commit
9e98f71d38

+ 39
- 34
App.vue Näytä tiedosto

@@ -1,38 +1,43 @@
1 1
 <script>
2
-  import config from './config'
3
-  import store from '@/store'
4
-  import { getToken } from '@/utils/auth'
5
-	import { initEid,startEid  } from './mp_ecard_sdk/main';
6
-  export default {
7
-	  globalData:{
8
-	  	requestUrl:'http://121.40.189.20:9001',
9
-	  },
10
-    onLaunch: function() {
11
-      this.initApp();
12
-	  initEid();
13
-    },
14
-    methods: {
15
-      // 初始化应用
16
-      initApp() {
17
-        // 初始化应用配置
18
-        this.initConfig()
19
-        // 检查用户登录状态
20
-        //#ifdef H5
21
-        this.checkLogin()
22
-        //#endif
23
-      },
24
-      initConfig() {
25
-        this.globalData.config = config
26
-      },
27
-      checkLogin() {
28
-        if (!getToken()) {
29
-          this.$tab.reLaunch('/pages/login') 
30
-        }
31
-      }
32
-    }
33
-  }
2
+	import config from './config'
3
+	import store from '@/store'
4
+	import {
5
+		getToken
6
+	} from '@/utils/auth'
7
+	import {
8
+		initEid
9
+	} from './mp_ecard_sdk/main';
10
+	export default {
11
+		globalData: {
12
+			requestUrl: 'https://www.api.xayunmei.com/API',
13
+		},
14
+		onLaunch: function() {
15
+			this.initApp();
16
+			initEid();
17
+			uni.setStorageSync('certificationStatus', '未认证')
18
+		},
19
+		methods: {
20
+			// 初始化应用
21
+			initApp() {
22
+				// 初始化应用配置
23
+				this.initConfig()
24
+				// 检查用户登录状态
25
+				//#ifdef H5
26
+				this.checkLogin()
27
+				//#endif
28
+			},
29
+			initConfig() {
30
+				this.globalData.config = config
31
+			},
32
+			checkLogin() {
33
+				if (!getToken()) {
34
+					this.$tab.reLaunch('/pages/login')
35
+				}
36
+			}
37
+		}
38
+	}
34 39
 </script>
35 40
 
36 41
 <style lang="scss">
37
-  @import '@/static/scss/index.scss'
38
-</style>
42
+	@import '@/static/scss/index.scss'
43
+</style>

+ 46
- 38
api/login.js Näytä tiedosto

@@ -2,58 +2,66 @@ import request from '@/utils/request'
2 2
 
3 3
 // 登录方法
4 4
 export function login(username, password, code, uuid) {
5
-  const data = {
6
-    username,
7
-    password,
8
-    code,
9
-    uuid
10
-  }
11
-  return request({
12
-    'url': '/login',
13
-    headers: {
14
-      isToken: false
15
-    },
16
-    'method': 'post',
17
-    'data': data
18
-  })
5
+	const data = {
6
+		username,
7
+		password,
8
+		code,
9
+		uuid
10
+	}
11
+	return request({
12
+		'url': '/login',
13
+		headers: {
14
+			isToken: false
15
+		},
16
+		'method': 'post',
17
+		'data': data
18
+	})
19 19
 }
20 20
 
21 21
 // 注册方法
22 22
 export function register(data) {
23
-  return request({
24
-    url: '/register',
25
-    headers: {
26
-      isToken: false
27
-    },
28
-    method: 'post',
29
-    data: data
30
-  })
23
+	return request({
24
+		url: '/register',
25
+		headers: {
26
+			isToken: false
27
+		},
28
+		method: 'post',
29
+		data: data
30
+	})
31 31
 }
32 32
 
33 33
 // 获取用户详细信息
34 34
 export function getInfo() {
35
-  return request({
36
-    'url': '/getInfo',
37
-    'method': 'get'
38
-  })
35
+	return request({
36
+		'url': '/getInfo',
37
+		'method': 'get'
38
+	})
39 39
 }
40 40
 
41 41
 // 退出方法
42 42
 export function logout() {
43
-  return request({
44
-    'url': '/logout',
45
-    'method': 'post'
46
-  })
43
+	return request({
44
+		'url': '/logout',
45
+		'method': 'post'
46
+	})
47 47
 }
48 48
 
49 49
 // 获取验证码
50 50
 export function getCodeImg() {
51
-  return request({
52
-    'url': '/captchaImage',
53
-    headers: {
54
-      isToken: false
55
-    },
56
-    method: 'get',
57
-    timeout: 20000
58
-  })
51
+	return request({
52
+		'url': '/captchaImage',
53
+		headers: {
54
+			isToken: false
55
+		},
56
+		method: 'get',
57
+		timeout: 20000
58
+	})
59 59
 }
60
+
61
+// 获取eidtoken
62
+export function getEidtoken() {
63
+	return request({
64
+		'url': '/identityAuthentication/selectIdentityAuthenticaEIDtoken',
65
+		method: 'post',
66
+	})
67
+}

+ 26
- 25
config.js Näytä tiedosto

@@ -1,27 +1,28 @@
1 1
 // 应用全局配置
2 2
 module.exports = {
3
-  baseUrl: 'http://121.40.189.20:9001',
4
-   // baseUrl: 'http://192.168.3.77:8080',
5
-  // baseUrl: 'http://localhost:8080',
6
-  // 应用信息
7
-  appInfo: {
8
-    // 应用名称
9
-    name: "arbitrate-wx",
10
-    // 应用版本
11
-    version: "1.1.0",
12
-    // 应用logo
13
-    logo: "/static/chuizi.png",
14
-    // 官方网站
15
-    site_url: "http://ruoyi.vip",
16
-    // 政策协议
17
-    agreements: [{
18
-        title: "隐私政策",
19
-        url: "https://ruoyi.vip/protocol.html"
20
-      },
21
-      {
22
-        title: "用户服务协议",
23
-        url: "https://ruoyi.vip/protocol.html"
24
-      }
25
-    ]
26
-  }
27
-}
3
+	baseUrl: 'https://api.xayunmei.com/zhongcaiapi/',
4
+	// baseUrl: 'http://121.40.189.20:9001',
5
+	// baseUrl: 'http://192.168.3.77:8080',
6
+	// baseUrl: 'http://localhost:8080',
7
+	// 应用信息
8
+	appInfo: {
9
+		// 应用名称
10
+		name: "arbitrate-wx",
11
+		// 应用版本
12
+		version: "1.1.0",
13
+		// 应用logo
14
+		logo: "/static/chuizi.png",
15
+		// 官方网站
16
+		site_url: "http://ruoyi.vip",
17
+		// 政策协议
18
+		agreements: [{
19
+				title: "隐私政策",
20
+				url: "https://ruoyi.vip/protocol.html"
21
+			},
22
+			{
23
+				title: "用户服务协议",
24
+				url: "https://ruoyi.vip/protocol.html"
25
+			}
26
+		]
27
+	}
28
+}

+ 3
- 1
mp_ecard_sdk/globalConfig.js Näytä tiedosto

@@ -1 +1,3 @@
1
-export default{normalPath:"/pages"};
1
+export default {
2
+	normalPath: ""
3
+};

+ 3
- 2
pages/im/index.vue Näytä tiedosto

@@ -12,8 +12,9 @@
12 12
 			}
13 13
 		},
14 14
 		onLoad: function() {
15
-			// this.name = this.$store.state.user.name;
16
-			this.sendImg = `https://txroom.xayunmei.com`
15
+			this.name = this.$store.state.user.name;
16
+			this.sendImg = `https://txroom.xayunmei.com/#/?name=${this.name}`
17
+			// this.sendImg = `http://localhost:8080/#/?name=${this.name}`
17 18
 		},
18 19
 
19 20
 	}

+ 193
- 192
pages/login.vue Näytä tiedosto

@@ -1,206 +1,207 @@
1 1
 <template>
2
-  <view class="normal-login-container">
3
-    <view class="logo-content align-center justify-center flex">
4
-      <image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix">
5
-      </image>
6
-      <text class="title">法务平台</text>
7
-    </view>
8
-    <view class="login-form-content">
9
-      <view class="input-item flex align-center">
10
-        <view class="iconfont icon-user icon"></view>
11
-        <input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
12
-      </view>
13
-      <view class="input-item flex align-center">
14
-        <view class="iconfont icon-password icon"></view>
15
-        <input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
16
-      </view>
17
-      <view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
18
-        <view class="iconfont icon-code icon"></view>
19
-        <input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
20
-        <view class="login-code"> 
21
-          <image :src="codeUrl" @click="getCode" class="login-code-img"></image>
22
-        </view>
23
-      </view>
24
-      <view class="action-btn">
25
-        <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
26
-      </view>
27
-      <view class="reg text-center" v-if="register">
28
-        <text class="text-grey1">没有账号?</text>
29
-        <text @click="handleUserRegister" class="text-blue">立即注册</text>
30
-      </view>
31
-	 <!-- <view class="reg text-center" v-if="register">
2
+	<view class="normal-login-container">
3
+		<view class="logo-content align-center justify-center flex">
4
+			<image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix">
5
+			</image>
6
+			<text class="title">法务平台</text>
7
+		</view>
8
+		<view class="login-form-content">
9
+			<view class="input-item flex align-center">
10
+				<view class="iconfont icon-user icon"></view>
11
+				<input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
12
+			</view>
13
+			<view class="input-item flex align-center">
14
+				<view class="iconfont icon-password icon"></view>
15
+				<input v-model="loginForm.password" type="password" class="input" placeholder="请输入密码" maxlength="20" />
16
+			</view>
17
+			<view class="input-item flex align-center" style="width: 60%;margin: 0px;" v-if="captchaEnabled">
18
+				<view class="iconfont icon-code icon"></view>
19
+				<input v-model="loginForm.code" type="number" class="input" placeholder="请输入验证码" maxlength="4" />
20
+				<view class="login-code">
21
+					<image :src="codeUrl" @click="getCode" class="login-code-img"></image>
22
+				</view>
23
+			</view>
24
+			<view class="action-btn">
25
+				<button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button>
26
+			</view>
27
+			<view class="reg text-center" v-if="register">
28
+				<text class="text-grey1">没有账号?</text>
29
+				<text @click="handleUserRegister" class="text-blue">立即注册</text>
30
+			</view>
31
+			<!-- <view class="reg text-center" v-if="register">
32 32
 	    <text class="text-grey1">使用其他方式登录:</text>
33 33
 	    <text @click="handleUserRegister" class="text-blue"></text>
34 34
 	  </view> -->
35
-     <!-- <view class="xieyi text-center">
35
+			<!-- <view class="xieyi text-center">
36 36
         <text class="text-grey1">登录即代表同意</text>
37 37
         <text @click="handleUserAgrement" class="text-blue">《用户协议》</text>
38 38
         <text @click="handlePrivacy" class="text-blue">《隐私协议》</text>
39 39
       </view> -->
40
-    </view>
41
-     
42
-  </view>
40
+		</view>
41
+
42
+	</view>
43 43
 </template>
44 44
 
45 45
 <script>
46
-  import { getCodeImg } from '@/api/login'
47
-
48
-  export default {
49
-    data() {
50
-      return {
51
-        codeUrl: "",
52
-        captchaEnabled: true,
53
-        // 用户注册开关
54
-        register: true,
55
-        globalConfig: getApp().globalData.config,
56
-        loginForm: {
57
-          username: "admin",
58
-          password: "admin123",
59
-          code: "",
60
-          uuid: ''
61
-        }
62
-      }
63
-    },
64
-    created() {
65
-      this.getCode()
66
-    },
67
-    methods: {
68
-      // 用户注册
69
-      handleUserRegister() {
70
-        this.$tab.redirectTo(`/pages/register`)
71
-      },
72
-      // 隐私协议
73
-      handlePrivacy() {
74
-        let site = this.globalConfig.appInfo.agreements[0]
75
-        this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
76
-      },
77
-      // 用户协议
78
-      handleUserAgrement() {
79
-        let site = this.globalConfig.appInfo.agreements[1]
80
-        this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
81
-      },
82
-      // 获取图形验证码
83
-      getCode() {
84
-        getCodeImg().then(res => {
85
-          this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
86
-          if (this.captchaEnabled) {
87
-            this.codeUrl = 'data:image/gif;base64,' + res.img
88
-            this.loginForm.uuid = res.uuid
89
-          }
90
-        })
91
-      },
92
-      // 登录方法
93
-      async handleLogin() {
94
-        if (this.loginForm.username === "") {
95
-          this.$modal.msgError("请输入您的账号")
96
-        } else if (this.loginForm.password === "") {
97
-          this.$modal.msgError("请输入您的密码")
98
-        } else if (this.loginForm.code === "" && this.captchaEnabled) {
99
-          this.$modal.msgError("请输入验证码")
100
-        } else {
101
-          this.$modal.loading("登录中,请耐心等待...")
102
-          this.pwdLogin()
103
-        }
104
-      },
105
-      // 密码登录
106
-      async pwdLogin() {
107
-        this.$store.dispatch('Login', this.loginForm).then(() => {
108
-          this.$modal.closeLoading()
109
-          this.loginSuccess()
110
-        }).catch(() => {
111
-          if (this.captchaEnabled) {
112
-            this.getCode()
113
-          }
114
-        })
115
-      },
116
-      // 登录成功后,处理函数
117
-      loginSuccess(result) {
118
-        // 设置用户信息
119
-        this.$store.dispatch('GetInfo').then(res => {
120
-          this.$tab.reLaunch('/pages/index')
121
-        })
122
-      }
123
-    }
124
-  }
46
+	import {
47
+		getCodeImg
48
+	} from '@/api/login'
49
+
50
+	export default {
51
+		data() {
52
+			return {
53
+				codeUrl: "",
54
+				captchaEnabled: true,
55
+				// 用户注册开关
56
+				register: true,
57
+				globalConfig: getApp().globalData.config,
58
+				loginForm: {
59
+					username: "admin",
60
+					password: "admin123",
61
+					code: "",
62
+					uuid: ''
63
+				}
64
+			}
65
+		},
66
+		created() {
67
+			this.getCode()
68
+		},
69
+		methods: {
70
+			// 用户注册
71
+			handleUserRegister() {
72
+				this.$tab.redirectTo(`/pages/register`)
73
+			},
74
+			// 隐私协议
75
+			handlePrivacy() {
76
+				let site = this.globalConfig.appInfo.agreements[0]
77
+				this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
78
+			},
79
+			// 用户协议
80
+			handleUserAgrement() {
81
+				let site = this.globalConfig.appInfo.agreements[1]
82
+				this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
83
+			},
84
+			// 获取图形验证码
85
+			getCode() {
86
+				getCodeImg().then(res => {
87
+					this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
88
+					if (this.captchaEnabled) {
89
+						this.codeUrl = 'data:image/gif;base64,' + res.img
90
+						this.loginForm.uuid = res.uuid
91
+					}
92
+				})
93
+			},
94
+			// 登录方法
95
+			async handleLogin() {
96
+				if (this.loginForm.username === "") {
97
+					this.$modal.msgError("请输入您的账号")
98
+				} else if (this.loginForm.password === "") {
99
+					this.$modal.msgError("请输入您的密码")
100
+				} else if (this.loginForm.code === "" && this.captchaEnabled) {
101
+					this.$modal.msgError("请输入验证码")
102
+				} else {
103
+					this.$modal.loading("登录中,请耐心等待...")
104
+					this.pwdLogin()
105
+				}
106
+			},
107
+			// 密码登录
108
+			async pwdLogin() {
109
+				this.$store.dispatch('Login', this.loginForm).then(() => {
110
+					this.$modal.closeLoading()
111
+					this.loginSuccess()
112
+				}).catch(() => {
113
+					if (this.captchaEnabled) {
114
+						this.getCode()
115
+					}
116
+				})
117
+			},
118
+			// 登录成功后,处理函数
119
+			loginSuccess(result) {
120
+				// 设置用户信息
121
+				this.$store.dispatch('GetInfo').then(res => {
122
+					this.$tab.reLaunch('/pages/index')
123
+				})
124
+			}
125
+		}
126
+	}
125 127
 </script>
126 128
 
127 129
 <style lang="scss">
128
-  page {
129
-    background-color: #ffffff;
130
-  }
131
-
132
-  .normal-login-container {
133
-    width: 100%;
134
-
135
-    .logo-content {
136
-      width: 100%;
137
-      font-size: 21px;
138
-      text-align: center;
139
-      padding-top: 15%;
140
-
141
-      image {
142
-        border-radius: 4px;
143
-      }
144
-
145
-      .title {
146
-        margin-left: 10px;
147
-      }
148
-    }
149
-
150
-    .login-form-content {
151
-      text-align: center;
152
-      margin: 20px auto;
153
-      margin-top: 15%;
154
-      width: 80%;
155
-
156
-      .input-item {
157
-        margin: 20px auto;
158
-        background-color: #f5f6f7;
159
-        height: 45px;
160
-        border-radius: 20px;
161
-
162
-        .icon {
163
-          font-size: 38rpx;
164
-          margin-left: 10px;
165
-          color: #999;
166
-        }
167
-
168
-        .input {
169
-          width: 100%;
170
-          font-size: 14px;
171
-          line-height: 20px;
172
-          text-align: left;
173
-          padding-left: 15px;
174
-        }
175
-
176
-      }
177
-
178
-      .login-btn {
179
-        margin-top: 40px;
180
-        height: 45px;
181
-      }
182
-      
183
-      .reg {
184
-        margin-top: 15px;
185
-      }
186
-      
187
-      .xieyi {
188
-        color: #333;
189
-        margin-top: 20px;
190
-      }
191
-      
192
-      .login-code {
193
-        height: 38px;
194
-        float: right;
195
-      
196
-        .login-code-img {
197
-          height: 38px;
198
-          position: absolute;
199
-          margin-left: 10px;
200
-          width: 200rpx;
201
-        }
202
-      }
203
-    }
204
-  }
205
-
206
-</style>
130
+	page {
131
+		background-color: #ffffff;
132
+	}
133
+
134
+	.normal-login-container {
135
+		width: 100%;
136
+
137
+		.logo-content {
138
+			width: 100%;
139
+			font-size: 21px;
140
+			text-align: center;
141
+			padding-top: 15%;
142
+
143
+			image {
144
+				border-radius: 4px;
145
+			}
146
+
147
+			.title {
148
+				margin-left: 10px;
149
+			}
150
+		}
151
+
152
+		.login-form-content {
153
+			text-align: center;
154
+			margin: 20px auto;
155
+			margin-top: 15%;
156
+			width: 80%;
157
+
158
+			.input-item {
159
+				margin: 20px auto;
160
+				background-color: #f5f6f7;
161
+				height: 45px;
162
+				border-radius: 20px;
163
+
164
+				.icon {
165
+					font-size: 38rpx;
166
+					margin-left: 10px;
167
+					color: #999;
168
+				}
169
+
170
+				.input {
171
+					width: 100%;
172
+					font-size: 14px;
173
+					line-height: 20px;
174
+					text-align: left;
175
+					padding-left: 15px;
176
+				}
177
+
178
+			}
179
+
180
+			.login-btn {
181
+				margin-top: 40px;
182
+				height: 45px;
183
+			}
184
+
185
+			.reg {
186
+				margin-top: 15px;
187
+			}
188
+
189
+			.xieyi {
190
+				color: #333;
191
+				margin-top: 20px;
192
+			}
193
+
194
+			.login-code {
195
+				height: 38px;
196
+				float: right;
197
+
198
+				.login-code-img {
199
+					height: 38px;
200
+					position: absolute;
201
+					margin-left: 10px;
202
+					width: 200rpx;
203
+				}
204
+			}
205
+		}
206
+	}
207
+</style>

+ 39
- 7
pages/work/index.vue Näytä tiedosto

@@ -12,7 +12,12 @@
12 12
 		</uni-swiper-dot>
13 13
 
14 14
 		<!-- 宫格组件 -->
15
-		<uni-section class="uni-section" title="系统管理" type="line" @click="certification">
15
+		<uni-section v-if="certificationStatus == '已认证'" class="uni-section" title="系统管理" type="line">
16
+			<template v-slot:right>
17
+				{{certificationStatus}}
18
+			</template>
19
+		</uni-section>
20
+		<uni-section v-else class="uni-section" title="系统管理" type="line" @click="certification">
16 21
 			<template v-slot:right>
17 22
 				{{certificationStatus}}
18 23
 			</template>
@@ -89,6 +94,9 @@
89 94
 	import {
90 95
 		startEid
91 96
 	} from '../../mp_ecard_sdk/main.js'
97
+	import {
98
+		getEidtoken
99
+	} from "../../api/login.js"
92 100
 	export default {
93 101
 		data() {
94 102
 			return {
@@ -104,7 +112,8 @@
104 112
 						image: 'https://img.tukuppt.com/bg_grid/00/81/07/DGEl4suqeV.jpg!/fh/350'
105 113
 					}
106 114
 				],
107
-				certificationStatus: "未认证"
115
+				certificationStatus: "未认证",
116
+				eidToken: ""
108 117
 			}
109 118
 		},
110 119
 		methods: {
@@ -116,6 +125,14 @@
116 125
 			},
117 126
 			changeGrid(e) {
118 127
 				// this.$modal.showToast('模块建设中~')
128
+				if (this.certificationStatus == "未认证") {
129
+					uni.showToast({
130
+						title: '请先完成实名认证',
131
+						icon: 'none',
132
+						duration: 1000
133
+					})
134
+					return
135
+				}
119 136
 				switch (e) {
120 137
 					case 0:
121 138
 						uni.navigateTo({
@@ -131,14 +148,22 @@
131 148
 						break;
132 149
 				}
133 150
 			},
151
+			// 获取eidtoken
152
+			getEidtokenFn() {
153
+				getEidtoken({}).then(res => {
154
+					console.log(res.data.eidToken, "kkkkkkkkk");
155
+					this.eidToken = res.data.eidToken
156
+				})
157
+			},
134 158
 			// 点击实名认证
135 159
 			certification() {
136
-				uni.navigateTo({
137
-					url: ('/mp_ecard_sdk/index/index')
138
-				})
160
+				let that = this
161
+				// uni.navigateTo({
162
+				// 	url: ('/mp_ecard_sdk/index/index')
163
+				// })
139 164
 				startEid({
140 165
 					data: {
141
-						token,
166
+						token: this.eidToken,
142 167
 					},
143 168
 					verifyDoneCallback(res) {
144 169
 						const {
@@ -148,10 +173,17 @@
148 173
 						console.log('收到核身完成的res:', res);
149 174
 						console.log('核身的token是:', token);
150 175
 						console.log('是否完成核身:', verifyDone);
176
+						// flagShow = '已认证'
177
+						// console.log(flagShow, "JKJJKJKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKk");
178
+						// console.log(this, "PPPPPPPPPPPPPPP");
179
+						that.certificationStatus = '已认证'
151 180
 					},
152 181
 				});
153 182
 			}
154
-		}
183
+		},
184
+		onLoad() {
185
+			this.getEidtokenFn()
186
+		},
155 187
 	}
156 188
 </script>
157 189
 

+ 6
- 6
store/getters.js Näytä tiedosto

@@ -1,8 +1,8 @@
1 1
 const getters = {
2
-  token: state => state.user.token,
3
-  avatar: state => state.user.avatar,
4
-  name: state => state.user.name,
5
-  roles: state => state.user.roles,
6
-  permissions: state => state.user.permissions
2
+	token: state => state.user.token,
3
+	avatar: state => state.user.avatar,
4
+	name: state => state.user.name,
5
+	roles: state => state.user.roles,
6
+	permissions: state => state.user.permissions
7 7
 }
8
-export default getters
8
+export default getters

+ 103
- 85
store/modules/user.js Näytä tiedosto

@@ -1,98 +1,116 @@
1 1
 import config from '@/config'
2 2
 import storage from '@/utils/storage'
3 3
 import constant from '@/utils/constant'
4
-import { login, logout, getInfo } from '@/api/login'
5
-import { getToken, setToken, removeToken } from '@/utils/auth'
4
+import {
5
+	login,
6
+	logout,
7
+	getInfo
8
+} from '@/api/login'
9
+import {
10
+	getToken,
11
+	setToken,
12
+	removeToken
13
+} from '@/utils/auth'
6 14
 
7 15
 const baseUrl = config.baseUrl
8 16
 
9 17
 const user = {
10
-  state: {
11
-    token: getToken(),
12
-    name: storage.get(constant.name),
13
-    avatar: storage.get(constant.avatar),
14
-    roles: storage.get(constant.roles),
15
-    permissions: storage.get(constant.permissions)
16
-  },
18
+	state: {
19
+		token: getToken(),
20
+		name: storage.get(constant.name),
21
+		avatar: storage.get(constant.avatar),
22
+		roles: storage.get(constant.roles),
23
+		permissions: storage.get(constant.permissions)
24
+	},
17 25
 
18
-  mutations: {
19
-    SET_TOKEN: (state, token) => {
20
-      state.token = token
21
-    },
22
-    SET_NAME: (state, name) => {
23
-      state.name = name
24
-      storage.set(constant.name, name)
25
-    },
26
-    SET_AVATAR: (state, avatar) => {
27
-      state.avatar = avatar
28
-      storage.set(constant.avatar, avatar)
29
-    },
30
-    SET_ROLES: (state, roles) => {
31
-      state.roles = roles
32
-      storage.set(constant.roles, roles)
33
-    },
34
-    SET_PERMISSIONS: (state, permissions) => {
35
-      state.permissions = permissions
36
-      storage.set(constant.permissions, permissions)
37
-    }
38
-  },
26
+	mutations: {
27
+		SET_TOKEN: (state, token) => {
28
+			state.token = token
29
+		},
30
+		SET_NAME: (state, name) => {
31
+			state.name = name
32
+			storage.set(constant.name, name)
33
+		},
34
+		SET_AVATAR: (state, avatar) => {
35
+			state.avatar = avatar
36
+			storage.set(constant.avatar, avatar)
37
+		},
38
+		SET_ROLES: (state, roles) => {
39
+			state.roles = roles
40
+			storage.set(constant.roles, roles)
41
+		},
42
+		SET_PERMISSIONS: (state, permissions) => {
43
+			state.permissions = permissions
44
+			storage.set(constant.permissions, permissions)
45
+		}
46
+	},
39 47
 
40
-  actions: {
41
-    // 登录
42
-    Login({ commit }, userInfo) {
43
-      const username = userInfo.username.trim()
44
-      const password = userInfo.password
45
-      const code = userInfo.code
46
-      const uuid = userInfo.uuid
47
-      return new Promise((resolve, reject) => {
48
-        login(username, password, code, uuid).then(res => {
49
-          setToken(res.token)
50
-          commit('SET_TOKEN', res.token)
51
-          resolve()
52
-        }).catch(error => {
53
-          reject(error)
54
-        })
55
-      })
56
-    },
48
+	actions: {
49
+		// 登录
50
+		Login({
51
+			commit
52
+		}, userInfo) {
53
+			const username = userInfo.username.trim()
54
+			const password = userInfo.password
55
+			const code = userInfo.code
56
+			const uuid = userInfo.uuid
57
+			return new Promise((resolve, reject) => {
58
+				login(username, password, code, uuid).then(res => {
59
+					setToken(res.token)
60
+					commit('SET_TOKEN', res.token)
61
+					resolve()
62
+				}).catch(error => {
63
+					reject(error)
64
+				})
65
+			})
66
+		},
57 67
 
58
-    // 获取用户信息
59
-    GetInfo({ commit, state }) {
60
-      return new Promise((resolve, reject) => {
61
-        getInfo().then(res => {
62
-          const user = res.user
63
-          const avatar = (user == null || user.avatar == "" || user.avatar == null) ? require("@/static/images/profile.jpg") : baseUrl + user.avatar
64
-          const username = (user == null || user.userName == "" || user.userName == null) ? "" : user.userName
65
-          if (res.roles && res.roles.length > 0) {
66
-            commit('SET_ROLES', res.roles)
67
-            commit('SET_PERMISSIONS', res.permissions)
68
-          } else {
69
-            commit('SET_ROLES', ['ROLE_DEFAULT'])
70
-          }
71
-          commit('SET_NAME', username)
72
-          commit('SET_AVATAR', avatar)
73
-          resolve(res)
74
-        }).catch(error => {
75
-          reject(error)
76
-        })
77
-      })
78
-    },
68
+		// 获取用户信息
69
+		GetInfo({
70
+			commit,
71
+			state
72
+		}) {
73
+			return new Promise((resolve, reject) => {
74
+				getInfo().then(res => {
75
+					const user = res.user
76
+					const avatar = (user == null || user.avatar == "" || user.avatar == null) ?
77
+						require("@/static/images/profile.jpg") : baseUrl + user.avatar
78
+					const username = (user == null || user.userName == "" || user.userName ==
79
+						null) ? "" : user.userName
80
+					if (res.roles && res.roles.length > 0) {
81
+						commit('SET_ROLES', res.roles)
82
+						commit('SET_PERMISSIONS', res.permissions)
83
+					} else {
84
+						commit('SET_ROLES', ['ROLE_DEFAULT'])
85
+					}
86
+					commit('SET_NAME', username)
87
+					commit('SET_AVATAR', avatar)
88
+					resolve(res)
89
+				}).catch(error => {
90
+					reject(error)
91
+				})
92
+			})
93
+		},
79 94
 
80
-    // 退出系统
81
-    LogOut({ commit, state }) {
82
-      return new Promise((resolve, reject) => {
83
-        logout(state.token).then(() => {
84
-          commit('SET_TOKEN', '')
85
-          commit('SET_ROLES', [])
86
-          commit('SET_PERMISSIONS', [])
87
-          removeToken()
88
-          storage.clean()
89
-          resolve()
90
-        }).catch(error => {
91
-          reject(error)
92
-        })
93
-      })
94
-    }
95
-  }
95
+		// 退出系统
96
+		LogOut({
97
+			commit,
98
+			state
99
+		}) {
100
+			return new Promise((resolve, reject) => {
101
+				logout(state.token).then(() => {
102
+					commit('SET_TOKEN', '')
103
+					commit('SET_ROLES', [])
104
+					commit('SET_PERMISSIONS', [])
105
+					removeToken()
106
+					storage.clean()
107
+					resolve()
108
+				}).catch(error => {
109
+					reject(error)
110
+				})
111
+			})
112
+		}
113
+	}
96 114
 }
97 115
 
98
-export default user
116
+export default user

+ 1
- 1
unpackage/dist/dev/.sourcemap/mp-weixin/common/main.js.map
File diff suppressed because it is too large
Näytä tiedosto


+ 1
- 1
unpackage/dist/dev/.sourcemap/mp-weixin/common/vendor.js.map
File diff suppressed because it is too large
Näytä tiedosto


+ 1
- 1
unpackage/dist/dev/.sourcemap/mp-weixin/uni_modules/uni-icons/components/uni-icons/uni-icons.js.map
File diff suppressed because it is too large
Näytä tiedosto


+ 1
- 1
unpackage/dist/dev/.sourcemap/mp-weixin/uni_modules/uni-list/components/uni-list-item/uni-list-item.js.map
File diff suppressed because it is too large
Näytä tiedosto


+ 1
- 1
unpackage/dist/dev/.sourcemap/mp-weixin/uni_modules/uni-list/components/uni-list/uni-list.js.map
File diff suppressed because it is too large
Näytä tiedosto


+ 1
- 1
unpackage/dist/dev/mp-weixin/project.private.config.json Näytä tiedosto

@@ -3,6 +3,6 @@
3 3
   "projectname": "若依移动端",
4 4
   "setting": {
5 5
     "compileHotReLoad": true,
6
-    "urlCheck": false
6
+    "urlCheck": true
7 7
   }
8 8
 }

+ 4
- 4
utils/auth.js Näytä tiedosto

@@ -1,13 +1,13 @@
1 1
 const TokenKey = 'App-Token'
2 2
 
3 3
 export function getToken() {
4
-  return uni.getStorageSync(TokenKey)
4
+	return uni.getStorageSync(TokenKey)
5 5
 }
6 6
 
7 7
 export function setToken(token) {
8
-  return uni.setStorageSync(TokenKey, token)
8
+	return uni.setStorageSync(TokenKey, token)
9 9
 }
10 10
 
11 11
 export function removeToken() {
12
-  return uni.removeStorageSync(TokenKey)
13
-}
12
+	return uni.removeStorageSync(TokenKey)
13
+}