فهرست منبع

Merge branch 'feature_业主工会' of http://192.168.4.246:3000/elab-damai-h5/h5-elab-open-ownerUnion into feature_业主工会

王晓晨 3 سال پیش
والد
کامیت
9fc61713c2
3فایلهای تغییر یافته به همراه51 افزوده شده و 59 حذف شده
  1. 2 1
      pages.json
  2. 46 0
      pages/homePage/homePage.vue
  3. 3 58
      util/api.js

+ 2 - 1
pages.json

@@ -7,6 +7,7 @@
 				"enablePullDownRefresh": true,
 				"onReachBottomDistance": 50,
 				"scrollIndicator": "none",
+				"navigationStyle":"custom",
 				"app-plus": {
 					"pullToRefresh": {
 						"support": true,
@@ -38,7 +39,7 @@
 		"navigationBarTitleText": "uni-app",
 		"navigationBarBackgroundColor": "#F8F8F8",
 		"backgroundColor": "#F8F8F8",
-		"navigationStyle": "custom",
+		"navigationStyle":"default",
 		"app-plus": {
 			"titleView": false
 		}

+ 46 - 0
pages/homePage/homePage.vue

@@ -147,11 +147,14 @@
            return{
 			   color4:'#F5F5F7',
 			   houseList:[],
+			   userId:"",
+			   token:"",
 		   }
 		},
 		mounted() {
           this.color4 = app.globalData.color4;
 		  this.getHomePage();
+		  this.regist();
 		},
 		methods: {
             async getHomePage(){
@@ -167,6 +170,49 @@
 				if(ret.data.success){
 					let pageModel = ret.data.pageModel;
 					this.houseList = pageModel.resultSet||[];
+				}
+			},
+			async regist(){
+				let ret =await this.$myRequest({
+					url:"/regist",
+					data:{
+						"code": "o08gpwOfRgwnhh1WCBYGLbaszur8",
+						"shareToken": ""
+					}
+				});
+				if(ret.data.success){
+					this.userId = ret.data.single.userId;
+					if(ret.data.single.authed==1){
+						this.token = ret.data.single.token;
+						this.getUserInfo()
+					}else{
+						this.getToken()
+					}
+				}
+			},
+			async getToken(){
+				let ret =await this.$myRequest({
+					url:"/authorizedPhone",
+					data:{
+						"code": (new Date()).getTime(),
+						"phone": "18721775127",
+						"userId": this.userId
+					}
+				});
+				if(ret.data.success){
+					this.token = ret.data.single;
+					this.getUserInfo()
+				}
+			},
+			async getUserInfo(){
+				let ret = await this.$myRequest({
+					url:"/user/userInfo",
+					data:{
+						
+					},
+					method:"GET"
+				});
+				if(ret.data.success){
 					
 				}
 			},

+ 3 - 58
util/api.js

@@ -22,35 +22,7 @@ export const myRequest = (options) => {
 		options.token = null
 	}
 	let BASE_URL = getApp().globalData.BASE_URL;
-	var plat = getApp().globalData.platform
-	if (plat == 'android') {
-		elabprojectname = 'com.elab.damai'
-		elabsystem = '1'
-		elabEnvironment = '2'
-	} else if (plat == 'ios') {
-		elabprojectname = 'com.elab.damai'
-		elabsystem = '1'
-		elabEnvironment = '1'
-	} else {
-		elabprojectname = '大麦数字营销'
-		elabsystem = '3'
-		elabEnvironment = '4'
-	}
-
-	// console.log("param", JSON.stringify(options.data) + "token:" + options.token + ":url = " + BASE_URL + options.url)
-	return new Promise((resolve, reject) => {
-		let userInfo = uni.getStorageSync('userInfo');
-		if (!userInfo) {
-			var pages = getCurrentPages()
-			var currentPage = pages[pages.length - 1]
-			var url = currentPage.route
-			if (url.indexOf('loginPage/index') == -1) {
-				uni.redirectTo({
-					url: '/pages/loginPage/index'
-				})
-				reject()
-			}
-		}
+	return new Promise((resolve, reject) => {
 		requestTask = uni.request({
 			url: BASE_URL + options.url,
 			method: options.method || "POST",
@@ -62,36 +34,9 @@ export const myRequest = (options) => {
 			// 	'elabEnvironment': elabEnvironment
 			// },
 			success: res => {
-
-				// console.log("token", options.token)
-				// console.log("返回参数:", res);
-				if (res.statusCode == 401) { //登出
-					uni.removeStorage({
-						key: 'userInfo',
-					})
-					getApp().globalData.token = "";
-					uni.removeStorageSync('selectedData');
-					uni.removeStorageSync('selecedProject');
-					if (!isToLoginSend) {
-						isToLoginSend = true;
-						uni.reLaunch({
-							url: "../loginPage/index",
-							success() {
-								setTimeout(() => {
-									isToLoginSend = false;
-								}, 1000)
-							}
-						})
-						uni.showToast({
-							title: "您的账号在别处登录,请重新登录",
-							icon: "none",
-							duration: 3000
-						})
-					}
-					ekanfang.logout();
-					return
-				}
 				uni.hideLoading()
+				uni.hideNavigationBarLoading();
+				uni.stopPullDownRefresh();
 				resolve(res)
 			},
 			fail: (err) => {