141 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Vue
		
	
	
	
			
		
		
	
	
			141 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Vue
		
	
	
	
<script>
 | 
						||
	export default {
 | 
						||
		globalData:{
 | 
						||
			userInfo: {}
 | 
						||
		},
 | 
						||
		onLaunch: function() {
 | 
						||
			console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!')
 | 
						||
			console.log('App Launch')
 | 
						||
			var that = this;
 | 
						||
			// #ifdef MP-WEIXIN
 | 
						||
			// that.wxmpLogin();
 | 
						||
			// #endif
 | 
						||
		},
 | 
						||
		onShow: function() {
 | 
						||
		},
 | 
						||
		onHide: function() {
 | 
						||
		},
 | 
						||
		methods:{
 | 
						||
			wxmpLogin: function(needLoad=true) {
 | 
						||
				//微信小程序登录流程
 | 
						||
				var that = this;
 | 
						||
				uni.login({
 | 
						||
					provider: 'weixin',
 | 
						||
					success: (loginRes) => {
 | 
						||
						that.$api.wxmpLogin({code: loginRes.code}).then(res=>{
 | 
						||
							uni.hideLoading()
 | 
						||
							uni.setStorageSync('access', res.access)
 | 
						||
							that.$api.getUserInfo().then(res=>{
 | 
						||
								uni.setStorageSync('userInfo', res)
 | 
						||
								if(needLoad){
 | 
						||
									var pages = getCurrentPages();    //获取加载的页面
 | 
						||
								  var currentPage = pages[pages.length - 1];  //获取当前页面的对象
 | 
						||
								  var url = currentPage.route;  //当前页面url
 | 
						||
									uni.redirectTo({
 | 
						||
										url: '/' + url,
 | 
						||
										fail() {
 | 
						||
											uni.reLaunch({
 | 
						||
												url: '/' + url
 | 
						||
											})
 | 
						||
										}
 | 
						||
									})
 | 
						||
								}
 | 
						||
							})
 | 
						||
						}).catch(e=>{
 | 
						||
							uni.reLaunch({
 | 
						||
								url: '/pages/auth/login?autoLoading=no'
 | 
						||
							})
 | 
						||
						})
 | 
						||
					}
 | 
						||
				})
 | 
						||
			},
 | 
						||
		}
 | 
						||
	}
 | 
						||
</script>
 | 
						||
 | 
						||
<style lang="scss">
 | 
						||
	/*每个页面公共css */
 | 
						||
	@import "@/static/iconfont.css";
 | 
						||
	@import '@/uni_modules/uni-scss/index.scss';
 | 
						||
	@import '@/uni_modules/uni-scss/theme.scss';
 | 
						||
	@import '@/uni_modules/uni-scss/variables.scss';
 | 
						||
	/* #ifndef APP-NVUE */
 | 
						||
	@import '@/static/customicons.css';
 | 
						||
	/* #endif */
 | 
						||
	// 设置整个项目的背景色
 | 
						||
	page {
 | 
						||
		background-color: #f7f7f7;
 | 
						||
	}
 | 
						||
	.container {
 | 
						||
		color: #333;
 | 
						||
		padding: 0rpx 12rpx;
 | 
						||
		background-color: #fff;
 | 
						||
	}
 | 
						||
	.uni-forms-item {
 | 
						||
		margin-bottom: 8rpx !important;
 | 
						||
	}
 | 
						||
	.uni-forms-item--border {
 | 
						||
		padding: 4rpx
 | 
						||
	}
 | 
						||
	.uni-forms-item__content {
 | 
						||
		display: flex;
 | 
						||
		align-items: center;
 | 
						||
	}
 | 
						||
	.dialogWrap {
 | 
						||
		position: fixed;
 | 
						||
		width: 100vw;
 | 
						||
		height: 100vh;
 | 
						||
		background-color: rgba(0, 0, 0, .3);
 | 
						||
		top: 0;
 | 
						||
		left: 0;
 | 
						||
		z-index: 110;
 | 
						||
	}
 | 
						||
	
 | 
						||
	.dialogCont {
 | 
						||
		width: 92vw;
 | 
						||
		position: absolute;
 | 
						||
		top: 50%;
 | 
						||
		margin: auto;
 | 
						||
		background-color: #ffffff;
 | 
						||
		left: 2vw;
 | 
						||
		transform: translateY(-50%);
 | 
						||
		padding: 10rpx;
 | 
						||
		border-radius: 20rpx;
 | 
						||
	}
 | 
						||
	
 | 
						||
	.dialogTitle {
 | 
						||
		font-size: 28rpx;
 | 
						||
		padding-bottom: 12rpx;
 | 
						||
		border-bottom: 1upx solid #eeeeee;
 | 
						||
		display: flex;
 | 
						||
		justify-content: space-between;
 | 
						||
	}
 | 
						||
	.header_sticky {
 | 
						||
		position: -webkit-sticky;
 | 
						||
		position: sticky;
 | 
						||
		top: 90rpx;
 | 
						||
		z-index: 10;
 | 
						||
		background-color: white;
 | 
						||
		display: flex;
 | 
						||
		align-items: center;
 | 
						||
		justify-content: space-between;
 | 
						||
	}
 | 
						||
	.header_fixed {
 | 
						||
		position: fixed;
 | 
						||
		width: 100%;
 | 
						||
		top: env(safe-area-inset-top)px;
 | 
						||
		z-index: 1;
 | 
						||
		background-color: white;
 | 
						||
	}
 | 
						||
	.footer_fixed {
 | 
						||
		position: fixed;
 | 
						||
		bottom: 0;
 | 
						||
		left: 0;
 | 
						||
		right: 0;
 | 
						||
		background-color: #fff;
 | 
						||
		padding: 12rpx;
 | 
						||
		box-shadow: 0 -2rpx 8rpx rgba(0, 0, 0, 0.1);
 | 
						||
		z-index: 10;
 | 
						||
	}
 | 
						||
</style>
 |