15 changed files with 534 additions and 378 deletions
			
			
		| @ -0,0 +1,12 @@ | |||||||
|  | import request from '@/utils/request' | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 获取字典 | ||||||
|  |  */ | ||||||
|  | export function getDictBatchByType(params) { | ||||||
|  | 	return request({ | ||||||
|  | 		url: `/system/dict-data/lists_dict_type`, | ||||||
|  | 		method: 'GET', | ||||||
|  | 		params | ||||||
|  | 	}) | ||||||
|  | } | ||||||
| @ -1,60 +1,82 @@ | |||||||
| <template> | <template> | ||||||
| 	<view class="container"> |   <view class="container"> | ||||||
| 		<u--image src="/static/favicon.png" width="180px" height="80px" mode="aspectFit" :fade="true" duration="450"></u--image> |     <u--image | ||||||
| 		<text class="title">智慧生态</text> |       src="/static/favicon.png" | ||||||
| 	</view> |       width="180px" | ||||||
|  |       height="80px" | ||||||
|  |       mode="aspectFit" | ||||||
|  |       :fade="true" | ||||||
|  |       duration="450" | ||||||
|  |     ></u--image> | ||||||
|  |     <text class="title">智慧生态</text> | ||||||
|  |   </view> | ||||||
| </template> | </template> | ||||||
| 
 | 
 | ||||||
| <script> | <script> | ||||||
| export default { | export default { | ||||||
| 	name: 'Login', |   name: 'Login', | ||||||
| 	data() { |   data() { | ||||||
| 		return {} |     return {} | ||||||
| 	}, |   }, | ||||||
| 	onLoad() { |   onLoad() { | ||||||
| 		this.init() |     this.init() | ||||||
| 	}, |   }, | ||||||
| 	methods: { |   methods: { | ||||||
| 		init() { |     init() { | ||||||
| 			uni.login({ |       uni.login({ | ||||||
| 				success: (res) => { |         success: res => { | ||||||
| 					// 系统登录 |           // 系统登录 | ||||||
| 					this.$store |           this.$store | ||||||
| 						.dispatch('Login', { |             .dispatch('Login', { | ||||||
| 							type: 34, |               type: 34, | ||||||
| 							code: res.code, |               code: res.code, | ||||||
| 							state: 'default' |               state: 'default' | ||||||
| 						}) |             }) | ||||||
| 						.then((res) => { |             .then(() => { | ||||||
| 							console.log('store.login', res) |               this.loginSuccess() | ||||||
| 						}) |             }) | ||||||
| 				} |         } | ||||||
| 			}) |       }) | ||||||
| 		} |     }, | ||||||
| 	} |     loginSuccess() { | ||||||
|  |       this.$store.dispatch('GetInfo').then(res => { | ||||||
|  |         const { data } = res | ||||||
|  |         const { user } = data | ||||||
|  |         if (user.mobile) { | ||||||
|  |           uni.switchTab({ | ||||||
|  |             url: '/pages/index' | ||||||
|  |           }) | ||||||
|  |         } else { | ||||||
|  |           uni.navigateTo({ | ||||||
|  |             url: '/sub/owner/edit' | ||||||
|  |           }) | ||||||
|  |         } | ||||||
|  |       }) | ||||||
|  |     } | ||||||
|  |   } | ||||||
| } | } | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <style lang="scss" scoped> | <style lang="scss" scoped> | ||||||
| .container { | .container { | ||||||
| 	height: 100vh; |   height: 100vh; | ||||||
| 	width: 100vw; |   width: 100vw; | ||||||
| 	display: flex; |   display: flex; | ||||||
| 	justify-content: center; |   justify-content: center; | ||||||
| 	align-items: center; |   align-items: center; | ||||||
| 	flex-flow: column nowrap; |   flex-flow: column nowrap; | ||||||
| 	gap: 20px; |   gap: 20px; | ||||||
| 	background: linear-gradient(180deg, #02815b 0%, #114636 100%); |   background: linear-gradient(180deg, #02815b 0%, #114636 100%); | ||||||
| 	.icon { |   .icon { | ||||||
| 		width: 40vw; |     width: 40vw; | ||||||
| 		filter: drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.12)); |     filter: drop-shadow(0px 2px 2px rgba(0, 0, 0, 0.12)); | ||||||
| 	} |   } | ||||||
| 	.title { |   .title { | ||||||
| 		color: #fff; |     color: #fff; | ||||||
| 		text-shadow: 0px 2px 2px rgba(0, 0, 0, 0.12); |     text-shadow: 0px 2px 2px rgba(0, 0, 0, 0.12); | ||||||
| 		font-size: 30px; |     font-size: 30px; | ||||||
| 		font-weight: 400; |     font-weight: 400; | ||||||
| 		letter-spacing: 2px; |     letter-spacing: 2px; | ||||||
| 	} |   } | ||||||
| } | } | ||||||
| </style> | </style> | ||||||
|  | |||||||
| @ -1,87 +1,205 @@ | |||||||
| <template> | <template> | ||||||
| 	<cs-page title="编辑个人信息"> |   <cs-page isCustom> | ||||||
| 		<view class="container"> |     <template #header> | ||||||
| 			<!-- 我的头像 --> |       <view class="wd-flex wd-flex-row wd-items-center" style="gap: 8px"> | ||||||
| 			<view class="section wd-flex wd-flex-row wd-justify-between wd-items-center"> |         <u-icon name="arrow-left" v-if="form.mobile"></u-icon> | ||||||
| 				<text class="wd-font-800">我的头像</text> |         <text class="wd-font-800 wd-text-16">编辑个人信息</text> | ||||||
| 				<view class="wd-flex wd-flex-row wd-items-center" style="gap: 8px"> |       </view> | ||||||
| 					<u-avatar src="/static/images/avatar.jpg"></u-avatar> |     </template> | ||||||
| 					<u-icon name="arrow-right"></u-icon> |     <view class="container"> | ||||||
| 				</view> |       <!-- 我的头像 --> | ||||||
| 			</view> |       <view class="section wd-flex wd-flex-row wd-justify-between wd-items-center"> | ||||||
| 			<!-- 真实姓名 --> |         <text class="wd-font-800">我的头像</text> | ||||||
| 			<view class="section wd-flex wd-flex-row wd-justify-between wd-items-center"> |         <button | ||||||
| 				<text class="wd-font-800">真实姓名</text> |           class="wd-flex wd-flex-row wd-items-center avatarBtn" | ||||||
| 				<view class="wd-flex wd-flex-row wd-items-center" style="gap: 8px"> |           style="gap: 8px" | ||||||
| 					<input class="wd-text-right" type="text" placeholder-class="txt" placeholder="请输入" v-model="form.realName" /> |           type="balanced" | ||||||
| 					<u-icon name="arrow-right" color="#99A1B7" size="16"></u-icon> |           open-type="chooseAvatar" | ||||||
| 				</view> |           @chooseavatar="chooseAvatar" | ||||||
| 			</view> |         > | ||||||
| 			<!-- 用户性别 --> |           <u-avatar :src="form.avatar"></u-avatar> | ||||||
| 			<view class="section wd-flex wd-flex-row wd-justify-between wd-items-center"> |           <u-icon name="arrow-right"></u-icon> | ||||||
| 				<text class="wd-font-800">用户性别</text> |         </button> | ||||||
| 				<view class="wd-flex wd-flex-row wd-items-center" style="gap: 8px"> |       </view> | ||||||
| 					<u-icon name="arrow-right" color="#99A1B7" size="16"></u-icon> |       <!-- 真实姓名 --> | ||||||
| 				</view> |       <view class="section wd-flex wd-flex-row wd-justify-between wd-items-center"> | ||||||
| 			</view> |         <text class="wd-font-800">姓名</text> | ||||||
| 			<!-- 手机号码 --> |         <view class="wd-flex wd-flex-row wd-items-center" style="gap: 8px"> | ||||||
| 			<view class="section wd-flex wd-flex-row wd-justify-between wd-items-center"> |           <input | ||||||
| 				<text class="wd-font-800">手机号码</text> |             class="wd-text-right" | ||||||
| 				<view class="wd-flex wd-flex-row wd-items-center" style="gap: 8px"> |             type="text" | ||||||
| 					<input class="wd-text-right" type="number" placeholder-class="txt" placeholder="请输入" v-model="form.mobile" /> |             placeholder-class="txt" | ||||||
| 					<u-icon name="arrow-right" color="#99A1B7" size="16"></u-icon> |             placeholder="请输入姓名" | ||||||
| 				</view> |             v-model="form.realName" | ||||||
| 			</view> |           /> | ||||||
| 			<!-- 所属部门 --> |           <u-icon name="arrow-right" color="#99A1B7" size="16"></u-icon> | ||||||
| 			<view class="section wd-flex wd-flex-row wd-justify-between wd-items-center"> |         </view> | ||||||
| 				<text class="wd-font-800">所属部门</text> |       </view> | ||||||
| 				<view class="wd-flex wd-flex-row wd-items-center" style="gap: 8px"> |       <!-- 用户性别 --> | ||||||
| 					<u-icon name="arrow-right" color="#99A1B7" size="16"></u-icon> |       <view class="section wd-flex wd-flex-row wd-justify-between wd-items-center"> | ||||||
| 				</view> |         <text class="wd-font-800">性别</text> | ||||||
| 			</view> |         <view class="wd-flex wd-flex-row wd-items-center" style="gap: 8px"> | ||||||
| 			<button class="button">提交</button> |           <input | ||||||
| 		</view> |             class="wd-text-right" | ||||||
| 	</cs-page> |             type="number" | ||||||
|  |             placeholder-class="txt" | ||||||
|  |             placeholder="请选择性别" | ||||||
|  |             v-model="form.sex" | ||||||
|  |             disabled | ||||||
|  |             @click="showPicker()" | ||||||
|  |           /> | ||||||
|  |           <u-icon name="arrow-right" color="#99A1B7" size="16"></u-icon> | ||||||
|  |         </view> | ||||||
|  |       </view> | ||||||
|  |       <!-- 手机号码 --> | ||||||
|  |       <view class="section wd-flex wd-flex-row wd-justify-between wd-items-center"> | ||||||
|  |         <text class="wd-font-800">手机号码</text> | ||||||
|  |         <view class="wd-flex wd-flex-row wd-items-center" style="gap: 8px"> | ||||||
|  |           <input | ||||||
|  |             class="wd-text-right" | ||||||
|  |             type="number" | ||||||
|  |             placeholder-class="txt" | ||||||
|  |             placeholder="请输入手机号码" | ||||||
|  |             v-model="form.mobile" | ||||||
|  |           /> | ||||||
|  |           <u-icon name="arrow-right" color="#99A1B7" size="16"></u-icon> | ||||||
|  |         </view> | ||||||
|  |       </view> | ||||||
|  |       <!-- 所属部门 --> | ||||||
|  |       <view class="section wd-flex wd-flex-row wd-justify-between wd-items-center"> | ||||||
|  |         <text class="wd-font-800">部门</text> | ||||||
|  |         <view class="wd-flex wd-flex-row wd-items-center" style="gap: 8px"> | ||||||
|  |           <input | ||||||
|  |             class="wd-text-right" | ||||||
|  |             type="number" | ||||||
|  |             placeholder-class="txt" | ||||||
|  |             placeholder="请选择部门" | ||||||
|  |             v-model="form.dept" | ||||||
|  |             disabled | ||||||
|  |             @click="showPicker()" | ||||||
|  |           /> | ||||||
|  |           <u-icon name="arrow-right" color="#99A1B7" size="16"></u-icon> | ||||||
|  |         </view> | ||||||
|  |       </view> | ||||||
|  |       <!-- 身份 --> | ||||||
|  |       <view class="section wd-flex wd-flex-row wd-justify-between wd-items-center" @click="showPicker()"> | ||||||
|  |         <text class="wd-font-800">角色</text> | ||||||
|  |         <view class="wd-flex wd-flex-row wd-items-center" style="gap: 8px"> | ||||||
|  |           <text v-if="form.userType">{{ $dict.echoDicValue(dictMap.wx_user_type, form.userType) }}</text> | ||||||
|  |           <text class="placeholder" v-else>请选择角色</text> | ||||||
|  |           <u-icon name="arrow-right" color="#99A1B7" size="16"></u-icon> | ||||||
|  |         </view> | ||||||
|  |       </view> | ||||||
|  |       <button class="button">提交</button> | ||||||
|  |     </view> | ||||||
|  |     <u-picker | ||||||
|  |       :show="picker.show" | ||||||
|  |       :columns="picker.columns" | ||||||
|  |       @cancel="closePicker" | ||||||
|  |       closeOnClickOverlay | ||||||
|  |       @close="closePicker" | ||||||
|  |     ></u-picker> | ||||||
|  |   </cs-page> | ||||||
| </template> | </template> | ||||||
| 
 | 
 | ||||||
| <script> | <script> | ||||||
|  | import { getUserProfile, uploadAvatar } from '@/api/system/user.js' | ||||||
|  | import { getDictBatchByType } from '@/api/system/dict.js' | ||||||
| export default { | export default { | ||||||
| 	data() { |   data() { | ||||||
| 		return { |     return { | ||||||
| 			form: { |       dictMap: {}, | ||||||
| 				avatar: undefined, |       form: { | ||||||
| 				realName: undefined, |         avatar: undefined, | ||||||
| 				mobile: undefined, |         realName: undefined, | ||||||
| 				department: undefined |         mobile: undefined, | ||||||
| 			} |         department: undefined, | ||||||
| 		} |         sex: undefined | ||||||
| 	} |       }, | ||||||
|  |       picker: { | ||||||
|  |         show: false, | ||||||
|  |         colums: [] | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   onLoad() { | ||||||
|  |     this.getDict() | ||||||
|  |   }, | ||||||
|  |   onShow() { | ||||||
|  |     // this.init() | ||||||
|  |   }, | ||||||
|  |   methods: { | ||||||
|  |     showPicker() { | ||||||
|  |       this.picker.show = true | ||||||
|  |     }, | ||||||
|  |     closePicker() { | ||||||
|  |       this.picker = { | ||||||
|  |         show: false, | ||||||
|  |         colums: [] | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     init() { | ||||||
|  |       getUserProfile().then(res => { | ||||||
|  |         this.form = res.data | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|  |     getDict() { | ||||||
|  |       getDictBatchByType({ type: ['system_user_sex', 'wx_user_type'].join(',') }).then(res => { | ||||||
|  |         this.dictMap = res.data | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|  |     chooseAvatar(e) { | ||||||
|  |       const data = { | ||||||
|  |         name: 'avatarFile', | ||||||
|  |         filePath: e.detail.avatarUrl | ||||||
|  |       } | ||||||
|  |       uploadAvatar(data).then(res => { | ||||||
|  |         this.init() | ||||||
|  |       }) | ||||||
|  |     } | ||||||
|  |   } | ||||||
| } | } | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <style lang="scss" scoped> | <style lang="scss" scoped> | ||||||
| .container { | .container { | ||||||
| 	height: 100%; |   height: 100%; | ||||||
| 	padding: 10px; |   padding: 10px; | ||||||
| 	position: relative; |   position: relative; | ||||||
| 	.section { |   .section { | ||||||
| 		border-radius: $cs-border-radius; |     border-radius: $cs-border-radius; | ||||||
| 		background: #fff; |     background: #fff; | ||||||
| 		box-shadow: 0 0 4px 2px $cs-shadow-color; |     box-shadow: 0 0 4px 2px $cs-shadow-color; | ||||||
| 		margin-bottom: $cs-gap; |     margin-bottom: $cs-gap; | ||||||
| 		padding: 24px; |     padding: 24px; | ||||||
| 	} |   } | ||||||
| 	.button { |   .button { | ||||||
| 		background-color: $uni-color-primary; |     background-color: $uni-color-primary; | ||||||
| 		color: #fff; |     color: #fff; | ||||||
| 		border-radius: 30px; |     border-radius: 30px; | ||||||
| 		position: fixed; |     position: fixed; | ||||||
| 		bottom: 30px; |     bottom: 30px; | ||||||
| 		right: 10px; |     right: 10px; | ||||||
| 		left: 10px; |     left: 10px; | ||||||
| 		height: 40px; |     height: 40px; | ||||||
| 		line-height: 40px; |     line-height: 40px; | ||||||
| 		box-sizing: border-box; |     box-sizing: border-box; | ||||||
| 	} |   } | ||||||
|  |   .placeholder { | ||||||
|  |     color: $uni-text-color-grey; | ||||||
|  |   } | ||||||
|  |   button { | ||||||
|  |     padding-left: 0; | ||||||
|  |     padding-right: 0; | ||||||
|  |   } | ||||||
|  |   .avatarBtn { | ||||||
|  |     background-color: #fff; | ||||||
|  |     flex: 1; | ||||||
|  |     justify-content: flex-end; | ||||||
|  |     &::after { | ||||||
|  |       content: ''; | ||||||
|  |       display: none; | ||||||
|  |     } | ||||||
|  |   } | ||||||
| } | } | ||||||
| </style> | </style> | ||||||
|  | |||||||
| @ -1,67 +1,68 @@ | |||||||
| <template> | <template> | ||||||
| 	<view class="container"> |   <view class="container"> | ||||||
| 		<view class="fit-content"></view> |     <view class="fit-content"></view> | ||||||
| 		<view class="operation" v-if="isCustom"> |     <view class="operation" v-if="isCustom"> | ||||||
| 			<slot></slot> |       <slot></slot> | ||||||
| 		</view> |     </view> | ||||||
| 		<view class="" v-else> |     <view v-else> | ||||||
| 			<view class="operation" v-if="isTab"> |       <view class="operation" v-if="isTab"> | ||||||
| 				<text class="title">{{ title }}</text> |         <text class="title">{{ title }}</text> | ||||||
| 			</view> |       </view> | ||||||
| 			<view class="operation wd-flex wd-flex-row wd-items-center" style="gap: 10px" v-else @tap="goback()"> |       <view class="operation wd-flex wd-flex-row wd-items-center" style="gap: 10px" v-else @tap="goback()"> | ||||||
| 				<view class="icon-box"> |         <view class="icon-box"> | ||||||
| 					<u-icon name="arrow-left" size="12"></u-icon> |           <u-icon name="arrow-left" size="12"></u-icon> | ||||||
| 				</view> |         </view> | ||||||
| 				<text class="title wd-text-16">{{ title }}</text> |         <text class="title wd-text-16">{{ title }}</text> | ||||||
| 			</view> |       </view> | ||||||
| 		</view> |     </view> | ||||||
| 	</view> |   </view> | ||||||
| </template> | </template> | ||||||
| 
 | 
 | ||||||
| <script> | <script> | ||||||
| export default { | export default { | ||||||
| 	name: 's-header', |   name: 's-header', | ||||||
| 	data() { |   data() { | ||||||
| 		return {} |     return {} | ||||||
| 	}, |   }, | ||||||
| 	props: { |   props: { | ||||||
| 		title: String, |     title: String, | ||||||
| 		isTab: { |     isTab: { | ||||||
| 			type: Boolean, |       type: Boolean, | ||||||
| 			default: false |       default: false | ||||||
| 		}, |     }, | ||||||
| 		isCustom: { |     isCustom: { | ||||||
| 			type: Boolean, |       type: Boolean, | ||||||
| 			default: false |       default: false | ||||||
| 		} |     } | ||||||
| 	}, |   }, | ||||||
| 	methods: { |   methods: { | ||||||
| 		goback() { |     goback() { | ||||||
| 			uni.switchTab({ |       uni.switchTab({ | ||||||
| 				url: '/pages/owner' |         url: '/pages/owner' | ||||||
| 			}) |       }) | ||||||
| 		} |     } | ||||||
| 	} |   } | ||||||
| } | } | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <style lang="scss" scoped> | <style lang="scss" scoped> | ||||||
| .container { | .container { | ||||||
| 	background-color: #fff; |   background-color: #fff; | ||||||
| 	box-shadow: 0 1px 2px 1px $cs-shadow-color; |   box-shadow: 0 1px 2px 1px $cs-shadow-color; | ||||||
| 	.fit-content { |   .fit-content { | ||||||
| 		height: 8vh; |     height: 6vh; | ||||||
| 	} |   } | ||||||
| 	.operation { |   .operation { | ||||||
| 		padding: 5px 10px; |     padding: 5px 10px; | ||||||
| 		.title { |     padding-bottom: 15px; | ||||||
| 			color: #000; |     .title { | ||||||
| 		} |       color: #000; | ||||||
| 		.icon-box { |     } | ||||||
| 			padding: 5px; |     .icon-box { | ||||||
| 			border-radius: 50%; |       padding: 5px; | ||||||
| 			box-shadow: 0 0 4px 2px $cs-shadow-color; |       border-radius: 50%; | ||||||
| 		} |       box-shadow: 0 0 4px 2px $cs-shadow-color; | ||||||
| 	} |     } | ||||||
|  |   } | ||||||
| } | } | ||||||
| </style> | </style> | ||||||
|  | |||||||
| @ -0,0 +1,8 @@ | |||||||
|  | /** | ||||||
|  |  * 回显字典值 | ||||||
|  |  * @param {Object} dict | ||||||
|  |  * @param {Object} value | ||||||
|  |  */ | ||||||
|  | export function echoDicValue(dict, value) { | ||||||
|  | 	return dict.find(d => d.value == value.toString()).label || '' | ||||||
|  | } | ||||||
| @ -1,73 +1,83 @@ | |||||||
| import store from '@/store' | import store from '@/store' | ||||||
| import config from '@/config' | import config from '@/config' | ||||||
| import { getAccessToken } from '@/utils/auth' | import { | ||||||
|  | 	getAccessToken | ||||||
|  | } from '@/utils/auth' | ||||||
| import errorCode from '@/utils/errorCode' | import errorCode from '@/utils/errorCode' | ||||||
| import { toast, showConfirm, tansParams } from '@/utils/common' | import { | ||||||
|  | 	toast, | ||||||
|  | 	showConfirm, | ||||||
|  | 	tansParams | ||||||
|  | } from '@/utils/common' | ||||||
| 
 | 
 | ||||||
| let timeout = 10000 | let timeout = 10000 | ||||||
| const baseUrl = config.baseUrl | const baseUrl = config.baseUrl | ||||||
| 
 | 
 | ||||||
| const upload = config => { | const upload = config => { | ||||||
|   // 是否需要设置 token
 | 	// 是否需要设置 token
 | ||||||
|   const isToken = (config.headers || {}).isToken === false | 	const isToken = (config.headers || {}).isToken === false | ||||||
|   config.header = config.header || {} | 	config.header = config.header || {} | ||||||
|   if (getAccessToken() && !isToken) { | 	if (getAccessToken() && !isToken) { | ||||||
|     config.header['Authorization'] = 'Bearer ' + getAccessToken() | 		config.header['Authorization'] = 'Bearer ' + getAccessToken() | ||||||
|   } | 	} | ||||||
|   // get请求映射params参数
 | 	// get请求映射params参数
 | ||||||
|   if (config.params) { | 	if (config.params) { | ||||||
|     let url = config.url + '?' + tansParams(config.params) | 		let url = config.url + '?' + tansParams(config.params) | ||||||
|     url = url.slice(0, -1) | 		url = url.slice(0, -1) | ||||||
|     config.url = url | 		config.url = url | ||||||
|   } | 	} | ||||||
|   // 设置租户 TODO 芋艿:强制 1 先
 | 	// 设置租户 TODO 芋艿:强制 1 先
 | ||||||
|   config.header['tenant-id'] = '1'; | 	config.header['tenant-id'] = '1'; | ||||||
|   return new Promise((resolve, reject) => { | 	return new Promise((resolve, reject) => { | ||||||
|       uni.uploadFile({ | 		uni.uploadFile({ | ||||||
|         timeout: config.timeout || timeout, | 			timeout: config.timeout || timeout, | ||||||
|         url: baseUrl + config.url, | 			url: baseUrl + config.url, | ||||||
|         filePath: config.filePath, | 			filePath: config.filePath, | ||||||
|         name: config.name || 'file', | 			name: config.name || 'file', | ||||||
|         header: config.header, | 			header: config.header, | ||||||
|         formData: config.formData, | 			formData: config.formData, | ||||||
|         method: config.method || 'post', | 			method: config.method || 'post', | ||||||
|         success: (res) => { | 			success: (res) => { | ||||||
|           let result = JSON.parse(res.data) | 				let result = JSON.parse(res.data) | ||||||
|           const code = result.code || 200 | 				const code = result.code || 200 | ||||||
|           const msg = errorCode[code] || result.msg || errorCode['default'] | 				const msg = errorCode[code] || result.msg || errorCode['default'] | ||||||
|           if (code === 200) { | 				if (code === 200) { | ||||||
|             resolve(result) | 					resolve(result) | ||||||
|           } else if (code == 401) { | 				} else if (code == 401) { | ||||||
|             showConfirm("登录状态已过期,您可以继续留在该页面,或者重新登录?").then(res => { | 					showConfirm("登录状态已过期,您可以继续留在该页面,或者重新登录?").then(res => { | ||||||
|               if (res.confirm) { | 						if (res.confirm) { | ||||||
|                 store.dispatch('LogOut').then(res => { | 							store.dispatch('LogOut').then(res => { | ||||||
|                   uni.reLaunch({ url: '/pages/login/login' }) | 								uni.reLaunch({ | ||||||
|                 }) | 									url: '/pages/login/login' | ||||||
|               } | 								}) | ||||||
|             }) | 							}) | ||||||
|             reject('无效的会话,或者会话已过期,请重新登录。') | 						} | ||||||
|           } else if (code === 500) { | 					}) | ||||||
|             toast(msg) | 					reject('无效的会话,或者会话已过期,请重新登录。') | ||||||
|             reject('500') | 				} else if (code === 500) { | ||||||
|           } else if (code !== 200) { | 					toast(msg) | ||||||
|             toast(msg) | 					reject('500') | ||||||
|             reject(code) | 				} else if (code !== 200) { | ||||||
|           } | 					toast(msg) | ||||||
|         }, | 					reject(code) | ||||||
|         fail: (error) => { | 				} | ||||||
|           let { message } = error | 			}, | ||||||
|           if (message == 'Network Error') { | 			fail: (error) => { | ||||||
|             message = '后端接口连接异常' | 				let { | ||||||
|           } else if (message.includes('timeout')) { | 					message | ||||||
|             message = '系统接口请求超时' | 				} = error | ||||||
|           } else if (message.includes('Request failed with status code')) { | 				if (message == 'Network Error') { | ||||||
|             message = '系统接口' + message.substr(message.length - 3) + '异常' | 					message = '后端接口连接异常' | ||||||
|           } | 				} else if (message.includes('timeout')) { | ||||||
|           toast(message) | 					message = '系统接口请求超时' | ||||||
|           reject(error) | 				} else if (message.includes('Request failed with status code')) { | ||||||
|         } | 					message = '系统接口' + message.substr(message.length - 3) + '异常' | ||||||
|       }) | 				} | ||||||
|   }) | 				toast(message) | ||||||
|  | 				reject(error) | ||||||
|  | 			} | ||||||
|  | 		}) | ||||||
|  | 	}) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export default upload | export default upload | ||||||
					Loading…
					
					
				
		Reference in new issue