Browse Source

bug 修复

lilei 2 years ago
parent
commit
7aa6849d40
4 changed files with 31 additions and 31 deletions
  1. 2 2
      App.vue
  2. 2 2
      main.js
  3. 27 1
      pages/personData/personData.vue
  4. 0 26
      service.js

+ 2 - 2
App.vue

@@ -1,8 +1,8 @@
 <script>
 	export default {
 		globalData: {
-			baseUrl: 'http://192.168.0.103:9110/saas/clz/', // 本地
-			// baseUrl: 'https://md.test.zyucgj.com/saas/clz/', // 预发布
+			// baseUrl: 'http://192.168.0.103:9110/saas/clz/', // 本地
+			baseUrl: 'https://md.test.zyucgj.com/saas/clz/', // 预发布
 			// baseUrl: 'https://car.zyucgj.com/saas/clz/' // 生产
 		},
 		onLaunch: function() {

+ 2 - 2
main.js

@@ -17,10 +17,10 @@ App.mpType = 'mini'
 Vue.prototype.$hasPermissions = function (value) {
  let isExist = false;
  if(!store.state.hasLogin){
-	 return true
+ 	 return true
  }
  let permissionsStr = uni.getStorageSync('permCodes');
- // console.log(permissionsStr)
+ console.log(permissionsStr)
  if (permissionsStr == undefined || permissionsStr == null || !permissionsStr) {
   return false;
  }

+ 27 - 1
pages/personData/personData.vue

@@ -57,7 +57,8 @@
 <script>
 	import uniPopup from '@/components/uni-popup/uni-popup.vue'
 	import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
-    import service from '../../service.js';
+	import {saveEmployee } from '@/api/employee'
+	const baseUrl = getApp().globalData.baseUrl
     import {
         mapState,
         mapMutations
@@ -87,8 +88,33 @@
 		},
         methods: {
 		  onChooseAvatar(e) {
+			const _this = this
 			const { avatarUrl } = e.detail 
 			this.avatarUrl = avatarUrl
+			uni.uploadFile({
+				url: baseUrl + '/upload',
+				filePath: avatarUrl,
+				name: 'file',
+				success: (uploadFileRes) => {
+					const ret = JSON.parse(uploadFileRes.data)
+					console.log(ret,'uploadFileRes')
+					if(ret.status == 200){
+						saveEmployee({id:_this.userInfo.userid,photo: ret.data}).then(res => {
+							if(res.status == 200){
+								uni.showToast({
+									icon: "none",
+									title: "修改头像成功"
+								})
+							}
+						})
+					}else{
+						uni.showToast({
+							icon: "none",
+							title: "修改头像失败,请重试"
+						})
+					}
+				}
+			});
 		  },
           loginOut(){
 			  this.$refs.openModal.open()

+ 0 - 26
service.js

@@ -1,26 +0,0 @@
-// 管理账号信息
-const USERS_KEY = 'USERS_KEY';
-const STATE_KEY = 'STATE_KEY';
-
-const getUsers = function () {
-    let ret = '';
-    ret = uni.getStorageSync(USERS_KEY);
-    if (!ret) {
-        ret = '[]';
-    }
-    return JSON.parse(ret);
-}
-
-const addUser = function (userInfo) {
-    let users = getUsers();
-    users.push({
-        account: userInfo.account,
-        password: userInfo.password
-    });
-    uni.setStorageSync(USERS_KEY, JSON.stringify(users));
-}
-
-export default {
-    getUsers,
-    addUser
-}