Sfoglia il codice sorgente

请求初始封装;

sinea17 2 anni fa
parent
commit
830025c337
4 ha cambiato i file con 483 aggiunte e 406 eliminazioni
  1. 109 107
      App.vue
  2. 59 0
      api/index.js
  3. 4 0
      api/system.js
  4. 311 299
      pages/self/enterprise/info.vue

+ 109 - 107
App.vue

@@ -1,84 +1,84 @@
 <script>
 import md5 from '@/common/md5.js';
 export default {
-  globalData: {
-    shareUrl: "https://xnh.xazhima.com/prod-api/wap/business/weixin/",
-    globalTimestamp: Date.now().toString(),
-    secret: "AirQK_weichat_app_zhima",
-    selectedIndex:0,
-	isSider:false,
-	user_id: '',
-	open_id:'',
-	user_status:'',
-	user_name:'',
-	user_phone:'',
-	user_headUrl:'',
-	globalAuth:false,
-	session_key: '',
-	isAndroid:false,
-	user_department:'',
-	user_real_name:'',
-  },
-  onLaunch: function () {
-    console.log("App Launch");
-	// let equType = uni.getSystemInfoSync().platform;
-	//  switch(equType){
-	//     case 'android':
-	//        console.log('运行Android上')
-	// 		setTimeout(()=>{
-	// 			getApp().globalData.isAndroid = true 
-	// 		},100)
-	//        break;
-	//     case 'ios':
-	//        console.log('运行iOS上');
-	//        break;
-	//     default:
-	//        console.log('运行在开发者工具上')
-	//        break;
-	// }
-	this.loginLoad();
-  },
-  onShow: function () {
-    console.log("App Show");
-   // uni.hideTabBar({})
-  },
-  onHide: function () {
-    console.log("App Hide");
-  },
-  methods:{
-	  loginLoad(){
-	  	let that = this;
-	  	uni.login({
-	  		success(res) {
-	  		   that.loginRequest(res.code)
-	  		}
-	  	})
-	  },
-	  loginRequest(codeRes){
-		let that = this;
-	  	let url = getApp().globalData.shareUrl+"login/" + codeRes;
-		uni.request({
-	  		url:url,
-	  		method: 'GET',
-	  		header: {
-	  			'content-type': 'application/x-www-form-urlencoded'
-	  		},
-	  		
-	  		success: (res) => {
-	  			console.log(res)
-	  			if(res.code === 200){
-	  				getApp().globalData.open_id = res.data.openid;
-					getApp().globalData.session_key = res.data.session_key
-					that.$isResolve();
-				//	uni.hideLoading() 
-	  			}
-	  		},
-	  		fail: () => {
-	  			console.log("连接失败");
-	  		}
-	  	});
-	  },
-  }
+	globalData: {
+		shareUrl: 'https://xnh.xazhima.com/prod-api/wap/business/weixin/',
+		globalTimestamp: Date.now().toString(),
+		secret: 'AirQK_weichat_app_zhima',
+		selectedIndex: 0,
+		isSider: false,
+		user_id: '',
+		open_id: '',
+		user_status: '',
+		user_name: '',
+		user_phone: '',
+		user_headUrl: '',
+		globalAuth: false,
+		session_key: '',
+		isAndroid: false,
+		user_department: '',
+		user_real_name: ''
+	},
+	onLaunch: function () {
+		console.log('App Launch');
+		// let equType = uni.getSystemInfoSync().platform;
+		//  switch(equType){
+		//     case 'android':
+		//        console.log('运行Android上')
+		// 		setTimeout(()=>{
+		// 			getApp().globalData.isAndroid = true
+		// 		},100)
+		//        break;
+		//     case 'ios':
+		//        console.log('运行iOS上');
+		//        break;
+		//     default:
+		//        console.log('运行在开发者工具上')
+		//        break;
+		// }
+		this.loginLoad();
+	},
+	onShow: function () {
+		console.log('App Show');
+		// uni.hideTabBar({})
+	},
+	onHide: function () {
+		console.log('App Hide');
+	},
+	methods: {
+		loginLoad() {
+			let that = this;
+			uni.login({
+				success(res) {
+					that.loginRequest(res.code);
+				}
+			});
+		},
+		loginRequest(codeRes) {
+			let that = this;
+			let url = getApp().globalData.shareUrl + 'login/' + codeRes;
+			uni.request({
+				url: url,
+				method: 'GET',
+				header: {
+					'content-type': 'application/x-www-form-urlencoded'
+				},
+
+				success: (res) => {
+					console.log(res);
+					if (res.code === 200) {
+						getApp().globalData.open_id = res.data.openid;
+						getApp().globalData.session_key = res.data.session_key;
+						that.$isResolve();
+						//	uni.hideLoading()
+					}
+				},
+				fail: () => {
+					console.log('连接失败');
+				}
+			});
+		}
+	}
 };
 </script>
 
@@ -88,7 +88,7 @@ export default {
 page {
 	height: 100%;
 	background: #f3f3f3;
-	&:before{
+	&:before {
 		content: '';
 		position: fixed;
 		left: 0;
@@ -99,55 +99,57 @@ page {
 		background: #e0e0e0;
 	}
 }
-button::after{
+button::after {
 	display: none;
 }
- *{touch-action: none;}
+* {
+	touch-action: none;
+}
 .display-flex-start {
-  display: flex;
-  align-items: center;
+	display: flex;
+	align-items: center;
 }
 .display-flex-center {
-  display: flex;
-  justify-content: center;
-  align-items: center;
+	display: flex;
+	justify-content: center;
+	align-items: center;
 }
 .display-flex-end {
-  display: flex;
-  justify-content: flex-end;
-  align-items: center;
+	display: flex;
+	justify-content: flex-end;
+	align-items: center;
 }
 .display-between {
-  display: flex;
-  justify-content: space-between;
+	display: flex;
+	justify-content: space-between;
 }
 .display-around {
-  display: flex;
-  justify-content: space-around;
+	display: flex;
+	justify-content: space-around;
 }
 .display-between-column {
-  display: flex;
-  flex-direction: column;
-  justify-content: space-between;
+	display: flex;
+	flex-direction: column;
+	justify-content: space-between;
 }
 .display-around-column {
-  display: flex;
-  flex-direction: column;
-  justify-content: space-around;
+	display: flex;
+	flex-direction: column;
+	justify-content: space-around;
 }
 .display-evenly-column {
-  display: flex;
-  flex-direction: column;
-  justify-content: space-evenly;
+	display: flex;
+	flex-direction: column;
+	justify-content: space-evenly;
 }
 .display-wrap {
-  flex-wrap: wrap;
+	flex-wrap: wrap;
 }
 .items-center {
-  align-items: center;
+	align-items: center;
 }
-.margin-top-10{
-  margin-top: 10%;
+.margin-top-10 {
+	margin-top: 10%;
 }
 .shareParent {
 	width: 100%;
@@ -161,7 +163,7 @@ button::after{
 	margin-top: 1%;
 }
 .margin-right-0 {
-	margin-right: 0!important;
+	margin-right: 0 !important;
 }
 .color-666 {
 	color: #666666;

+ 59 - 0
api/index.js

@@ -0,0 +1,59 @@
+const baseRequest = async (url, method, data = {}, loading = true) => {
+	let header = {}
+	return new Promise((reslove, reject) => {
+		loading && uni.showLoading({
+			title: '加载中'
+		})
+		uni.request({
+			url: 'https://xnh.xazhima.com/prod-api/wap/business/weixin' + url,
+			method: method || 'GET',
+			header: header,
+			timeout: 10000,
+			data: data || {},
+			success: (successData) => {
+				const res = successData.data
+				if (successData.statusCode == 200) {
+					if (res.code === 200) {
+						reslove(res)
+					} else {
+						uni.showToast({
+							title: '登录信息失效'
+						})
+					}
+				} else {
+					uni.showToast({
+						title: '网络连接失败,请稍后重试'
+					})
+					reject(res)
+				}
+			},
+			fail: (msg) => {
+				uni.showToast({
+					title: '网络连接失败,请稍后重试'
+				})
+				reject(msg)
+			},
+			complete: () => {
+				uni.hideLoading()
+			},
+		})
+	})
+}
+const request = {
+	getPath: (api, data, keys, loading) => {
+		let newRequestPath = api;
+		Object.keys(keys).forEach(function (key) {
+			newRequestPath = newRequestPath.replace(
+				"{" + key + "}",
+				keys[key]
+			);
+		});
+		return baseRequest(newRequestPath, 'GET', data, loading)
+	}
+}
+
+// ['options', 'get', 'post', 'put', 'head', 'delete', 'trace', 'connect'].forEach((method) => {
+// 	request[method] = (api, data, loading) => baseRequest(api, method, data, loading)
+// })
+
+export default request

+ 4 - 0
api/system.js

@@ -0,0 +1,4 @@
+import request from '@/api'
+
+// 字典接口, 用字典类型关键字获取字典数据接口
+export const getDict = code => request.getPath('/dict/{code}', {}, {code})

+ 311 - 299
pages/self/enterprise/info.vue

@@ -1,8 +1,7 @@
 <template>
 	<view class="page-wrap">
 		<view class="tabs-panel">
-			<view :class="{ item: true, active: tabActive === item.value }" v-for="(item, index) in tabList" :key="index"
-				@click="tabActive = item.value">
+			<view :class="{ item: true, active: tabActive === item.value }" v-for="(item, index) in tabList" :key="index" @click="tabActive = item.value">
 				{{ item.label }}
 			</view>
 		</view>
@@ -234,360 +233,373 @@
 </template>
 
 <script>
-	export default {
-		data() {
-			return {
-				tabActive: 1,
-				tabList: [{
-						label: '基础资料',
-						value: 1
-					},
-					{
-						label: '资金账户',
-						value: 2
-					},
-					{
-						label: '认证信息',
-						value: 3
-					},
-					{
-						label: '团队成员',
-						value: 4
-					}
-				],
-				authType: 1,
-				array: ['总经办', '财务部', '行政部'],
-				test: '',
-				testValue1: '',
-				testValue2: ''
-			};
+import { getDict } from '@/api/system.js';
+export default {
+	data() {
+		return {
+			tabActive: 1,
+			tabList: [
+				{
+					label: '基础资料',
+					value: 1
+				},
+				{
+					label: '资金账户',
+					value: 2
+				},
+				{
+					label: '认证信息',
+					value: 3
+				},
+				{
+					label: '团队成员',
+					value: 4
+				}
+			],
+			authType: 1,
+			array: ['总经办', '财务部', '行政部'],
+			test: '',
+			testValue1: '',
+			testValue2: ''
+		};
+	},
+	onLoad() {
+		this.getOptionsConfig();
+	},
+	methods: {
+		// 获取选项配置
+		async getOptionsConfig() {
+			const { rows: companyTypeList } = await getDict('biz_company_type');
+			const { rows: companyTaxList } = await getDict('biz_company_tax ');
+			const { rows: companyIndustryList } = await getDict('biz_company_industry');
+			const { rows: companySizeList } = await getDict('biz_company_size');
+			console.log(companyTypeList, companyTaxList, companyIndustryList, companySizeList);
 		},
-		methods: {
-			handleOpenAddMember() {
-				this.$refs.memberDialog.open();
-			},
-			bindPickerChange(e) {
-				this.test = this.array[e.detail.value];
-			},
-			dialogInputConfirm() {},
-			//打开权限设置
-			handleOpenAuthSetting() {
-				uni.navigateTo({
-					url: 'authSetting'
-				});
-			}
+		handleOpenAddMember() {
+			this.$refs.memberDialog.open();
+		},
+		bindPickerChange(e) {
+			this.test = this.array[e.detail.value];
+		},
+		dialogInputConfirm() {},
+		//打开权限设置
+		handleOpenAuthSetting() {
+			uni.navigateTo({
+				url: 'authSetting'
+			});
 		}
-	};
+	}
+};
 </script>
 
 <style lang="scss" scoped>
-	.page-wrap {
-		padding-top: 82.42rpx;
+.page-wrap {
+	padding-top: 82.42rpx;
+}
+
+.tabs-panel {
+	position: fixed;
+	left: 0;
+	top: 0;
+	right: 0;
+	height: 82.42rpx;
+	background: #fff;
+	display: flex;
+	z-index: 1;
+
+	&::before,
+	&::after {
+		content: '';
+		position: absolute;
+		left: 0;
+		right: 0;
+		height: 1rpx;
+		background: #e0e0e0;
 	}
 
-	.tabs-panel {
-		position: fixed;
-		left: 0;
+	&::before {
 		top: 0;
-		right: 0;
-		height: 82.42rpx;
-		background: #fff;
-		display: flex;
-		z-index: 1;
+	}
 
-		&::before,
-		&::after {
+	&::after {
+		bottom: 0;
+	}
+
+	.item {
+		flex: 1;
+		text-align: center;
+		font-size: 27.47rpx;
+		color: #999;
+		line-height: 82.42rpx;
+		position: relative;
+
+		& + .item::before {
 			content: '';
 			position: absolute;
 			left: 0;
-			right: 0;
-			height: 1rpx;
-			background: #e0e0e0;
-		}
-
-		&::before {
 			top: 0;
-		}
-
-		&::after {
 			bottom: 0;
+			width: 1rpx;
+			background: #e0e0e0;
 		}
+	}
 
-		.item {
-			flex: 1;
-			text-align: center;
-			font-size: 27.47rpx;
-			color: #999;
-			line-height: 82.42rpx;
-			position: relative;
-
-			&+.item::before {
-				content: '';
-				position: absolute;
-				left: 0;
-				top: 0;
-				bottom: 0;
-				width: 1rpx;
-				background: #e0e0e0;
-			}
-		}
-
-		.active {
-			color: #00bcd2;
+	.active {
+		color: #00bcd2;
 
-			&::after {
-				content: '';
-				position: absolute;
-				left: 0%;
-				right: 0%;
-				bottom: 0%;
-				height: 5.49rpx;
-				background: #00bcd2;
-				z-index: 1;
-			}
+		&::after {
+			content: '';
+			position: absolute;
+			left: 0%;
+			right: 0%;
+			bottom: 0%;
+			height: 5.49rpx;
+			background: #00bcd2;
+			z-index: 1;
 		}
 	}
+}
 
-	.info-panel {
-		font-size: 27.47rpx;
-
-		.row {
-			min-height: 96.15rpx;
-			display: flex;
-			align-items: center;
-			justify-content: space-between;
-			padding: 20.6rpx 41.21rpx;
-			box-sizing: border-box;
-			background: #fff;
-			position: relative;
-			color: #515151;
+.info-panel {
+	font-size: 27.47rpx;
 
-			&:first-child::before,
-			&+.row::before {
-				content: '';
-				position: absolute;
-				left: 0;
-				right: 0;
-				top: 0;
-				height: 1px;
-				background: #e0e0e0;
-				transform: scaleY(0.5);
-			}
-
-			.label {
-				white-space: nowrap;
-				margin-right: 54.95rpx;
-			}
-
-			.text {
-				flex: 1;
-				text-align: right;
-			}
-
-			.arrow {
-				width: 27.47rpx;
-				height: 27.47rpx;
-				margin-left: 6.87rpx;
-			}
+	.row {
+		min-height: 96.15rpx;
+		display: flex;
+		align-items: center;
+		justify-content: space-between;
+		padding: 20.6rpx 41.21rpx;
+		box-sizing: border-box;
+		background: #fff;
+		position: relative;
+		color: #515151;
 
-			.avatar {
-				width: 82.42rpx;
-				height: 82.42rpx;
-				border-radius: 50%;
-			}
+		&:first-child::before,
+		& + .row::before {
+			content: '';
+			position: absolute;
+			left: 0;
+			right: 0;
+			top: 0;
+			height: 1px;
+			background: #e0e0e0;
+			transform: scaleY(0.5);
 		}
 
-		.title {
-			color: #666666;
-			padding: 0 41.21rpx;
-			line-height: 82.42rpx;
+		.label {
+			white-space: nowrap;
+			margin-right: 54.95rpx;
 		}
 
-		.space {
-			background: #f3f3f3;
-			height: 13.74rpx;
+		.text {
+			flex: 1;
+			text-align: right;
 		}
 
-		.radio-group {
-			display: flex;
-
-			.item {
-				position: relative;
-				padding-left: 43.96rpx;
-				line-height: 32.97rpx;
-				margin-left: 41.21rpx;
-
-				&:before {
-					content: '';
-					position: absolute;
-					left: 0%;
-					top: 50%;
-					transform: translateY(-50%);
-					width: 30.22rpx;
-					height: 30.22rpx;
-					border: 1rpx solid #ddd;
-					border-radius: 50%;
-					box-sizing: border-box;
-				}
-
-				.radio {
-					width: 32.97rpx;
-					height: 32.97rpx;
-					position: absolute;
-					left: 0;
-					top: 50%;
-					transform: translateY(-50%);
-					display: none;
-					z-index: 1;
-				}
+		.arrow {
+			width: 27.47rpx;
+			height: 27.47rpx;
+			margin-left: 6.87rpx;
+		}
 
-				&.active .radio {
-					display: block;
-				}
-			}
+		.avatar {
+			width: 82.42rpx;
+			height: 82.42rpx;
+			border-radius: 50%;
 		}
 	}
 
-	.submit-btn {
-		width: 549.45rpx;
-		height: 75.55rpx;
-		background: #079eff;
-		font-size: 27.47rpx;
-		color: #fff;
-		border-radius: 8.24rpx;
-		margin: 54.95rpx auto;
+	.title {
+		color: #666666;
+		padding: 0 41.21rpx;
+		line-height: 82.42rpx;
 	}
 
-	.list-panel {
-		margin-top: 13.74rpx;
+	.space {
+		background: #f3f3f3;
+		height: 13.74rpx;
+	}
+
+	.radio-group {
+		display: flex;
 
 		.item {
-			display: flex;
-			align-items: center;
-			padding: 16.48rpx 27.47rpx;
-			min-height: 96.15rpx;
-			box-sizing: border-box;
 			position: relative;
-			background: #fff;
+			padding-left: 43.96rpx;
+			line-height: 32.97rpx;
+			margin-left: 41.21rpx;
 
-			&+.item::before {
+			&:before {
 				content: '';
 				position: absolute;
 				left: 0%;
-				right: 0%;
-				top: 0%;
-				height: 1rpx;
-				transform: scaleY(0.5);
-				background: #e0e0e0;
+				top: 50%;
+				transform: translateY(-50%);
+				width: 30.22rpx;
+				height: 30.22rpx;
+				border: 1rpx solid #ddd;
+				border-radius: 50%;
+				box-sizing: border-box;
 			}
-		}
 
-		.avatar {
-			width: 76.92rpx;
-			height: 76.92rpx;
-		}
+			.radio {
+				width: 32.97rpx;
+				height: 32.97rpx;
+				position: absolute;
+				left: 0;
+				top: 50%;
+				transform: translateY(-50%);
+				display: none;
+				z-index: 1;
+			}
 
-		.text {
-			flex: 1;
-			font-size: 27.47rpx;
-			color: #545e8f;
-			margin-left: 13.74rpx;
+			&.active .radio {
+				display: block;
+			}
 		}
+	}
+}
+
+.submit-btn {
+	width: 549.45rpx;
+	height: 75.55rpx;
+	background: #079eff;
+	font-size: 27.47rpx;
+	color: #fff;
+	border-radius: 8.24rpx;
+	margin: 54.95rpx auto;
+}
+
+.list-panel {
+	margin-top: 13.74rpx;
+
+	.item {
+		display: flex;
+		align-items: center;
+		padding: 16.48rpx 27.47rpx;
+		min-height: 96.15rpx;
+		box-sizing: border-box;
+		position: relative;
+		background: #fff;
 
-		.sub {
-			display: block;
-			font-size: 24.73rpx;
-			color: #999999;
+		& + .item::before {
+			content: '';
+			position: absolute;
+			left: 0%;
+			right: 0%;
+			top: 0%;
+			height: 1rpx;
+			transform: scaleY(0.5);
+			background: #e0e0e0;
 		}
+	}
 
-		.btn {
-			background: none;
-			border: none;
-			font-size: 27.47rpx;
-			color: #f97631;
-			white-space: nowrap;
-			padding: 0;
-			margin-left: 13.74rpx;
-		}
+	.avatar {
+		width: 76.92rpx;
+		height: 76.92rpx;
+	}
 
-		.add-btn {
-			margin-top: 27.47rpx;
-			font-size: 27.47rpx;
-			color: #00bcd2;
-			height: 82.42rpx;
-			line-height: 82.42rpx;
-			display: block;
-			text-align: left;
-			padding: 0 0 0 54.95rpx;
-			background: #fff;
-			border: none;
-			border-radius: 13.74rpx;
-		}
+	.text {
+		flex: 1;
+		font-size: 27.47rpx;
+		color: #545e8f;
+		margin-left: 13.74rpx;
+	}
+
+	.sub {
+		display: block;
+		font-size: 24.73rpx;
+		color: #999999;
 	}
 
-	.popup-form {
-		width: 100%;
+	.btn {
+		background: none;
+		border: none;
 		font-size: 27.47rpx;
+		color: #f97631;
+		white-space: nowrap;
+		padding: 0;
+		margin-left: 13.74rpx;
+	}
 
-		&-item {
-			display: flex;
-			align-items: center;
-			height: 82.42rpx;
-			position: relative;
+	.add-btn {
+		margin-top: 27.47rpx;
+		font-size: 27.47rpx;
+		color: #00bcd2;
+		height: 82.42rpx;
+		line-height: 82.42rpx;
+		display: block;
+		text-align: left;
+		padding: 0 0 0 54.95rpx;
+		background: #fff;
+		border: none;
+		border-radius: 13.74rpx;
+	}
+}
 
-			&::before {
-				content: '';
-				position: absolute;
-				left: 0;
-				right: 0;
-				bottom: 0;
-				height: 1rpx;
-				background: #e0e0e0;
-			}
-		}
+.popup-form {
+	width: 100%;
+	font-size: 27.47rpx;
 
-		.label {
-			white-space: nowrap;
-			margin-right: 13.74rpx;
-		}
+	&-item {
+		display: flex;
+		align-items: center;
+		height: 82.42rpx;
+		position: relative;
 
-		.input {
-			flex: 1;
-			text-align: right;
+		&::before {
+			content: '';
+			position: absolute;
+			left: 0;
+			right: 0;
+			bottom: 0;
+			height: 1rpx;
+			background: #e0e0e0;
 		}
+	}
 
-		.picker {
-			flex: 1;
-		}
+	.label {
+		white-space: nowrap;
+		margin-right: 13.74rpx;
+	}
+
+	.input {
+		flex: 1;
+		text-align: right;
 	}
 
-	// .file-panel {
-	// 	padding: 27.47rpx;
-
-	// 	.file-item {
-	// 		width: 192.31rpx;
-
-	// 		.upload {
-	// 			width: 192.31rpx;
-	// 			height: 192.31rpx;
-	// 			box-sizing: border-box;
-	// 			border: 1px solid #ddd;
-	// 			background: #fff;
-	// 			display: flex;
-	// 			align-items: center;
-	// 			justify-content: center;
-
-	// 			&-icon {
-	// 				width: 137.36rpx;
-	// 				height: 137.36rpx;
-	// 			}
-	// 		}
-
-	// 		.name {
-	// 			font-size: 27.47rpx;
-	// 			text-align: center;
-	// 			line-height: 86.54rpx;
-	// 		}
-	// 	}
-	// }
-</style>
+	.picker {
+		flex: 1;
+	}
+}
+
+// .file-panel {
+// 	padding: 27.47rpx;
+
+// 	.file-item {
+// 		width: 192.31rpx;
+
+// 		.upload {
+// 			width: 192.31rpx;
+// 			height: 192.31rpx;
+// 			box-sizing: border-box;
+// 			border: 1px solid #ddd;
+// 			background: #fff;
+// 			display: flex;
+// 			align-items: center;
+// 			justify-content: center;
+
+// 			&-icon {
+// 				width: 137.36rpx;
+// 				height: 137.36rpx;
+// 			}
+// 		}
+
+// 		.name {
+// 			font-size: 27.47rpx;
+// 			text-align: center;
+// 			line-height: 86.54rpx;
+// 		}
+// 	}
+// }
+</style>