<script>
	import { MINI, LOGIN_ACTION, ENV_MODEL, TokenPrefix } from './publicConfig/config.js'
	const loginBehavior = require('./mixins/loginBehavior.js')
	
	// #ifdef H5
	import VConsole from 'vconsole'; //引入H5调试工具
	// #endif

	export default {
		mixins: [loginBehavior],
		onLaunch: function() {
			this.judgePlatform(); //判断运行平台，仅初始化时执行
		},
		globalData: {
			cacheUserInfo: {},//用户信息
			projectMini: '', //项目名
			loginAction: '', //登录Action
			userLocation: {},
			cacheUserLocation: {}, //用户地址位置信息缓存,含经、纬度地址描述等
			transferAddress: {}, //中转地址  中转操作时更新
			shipmentInfo: { //运单信息 查看运单详情时进行修改
				shipmentId: "", //运单id
				shipmentBizName: "", //运单对象名 路由跳转详情时赋值
				shipmentNo: '', //运单号
				truckName: '' //车牌号
			},
			stopsInfo: { //站点信息 查看站点详情时修改
				locationId: '',
				loadStop: '', //是否装货站点
				unloadStop: '', //是否卸货站点
				locationName: '', //站点名称
				locationAddress: '', //站点地址
				locationOrders: '', //订单数
				locationQty: '', //件数数
				locationWeight: '', //重量
				locationVolume: '', //体积
			},
			backPagePath: '', //回退页面路径,含完整参数
			
			serviceProvider: 'AMap' ,//地图服务商，默认为高德地图
			MapIns: null , //地图实例, 默认在Index首页初始化, mxins下getUserLocation中赋值
		},
		methods: {
			//判断平台
			judgePlatform() {
				//项目是否为H5 条件编译,代码块仅判断成功才运行
				//#ifdef H5
				if (process.env.NODE_ENV === 'development') { //HBuilderX中，点击运行是--开发环境，点击发行是--生产环境
					this.globalData.projectMini = MINI.h5Dev
					const vConsole = new VConsole(); //H5实例化调试工具,工具git地址：https://github.com/Tencent/vConsole
				} else { //生产环境区分，默认生产PROD
				    switch(ENV_MODEL.model){
						case 'UAT':
						this.globalData.projectMini = MINI.h5Uat						
						break;
						default:
						this.globalData.projectMini = MINI.h5Prod
					}						
				}
				this.globalData.loginAction = LOGIN_ACTION.h5
				this.isRunningWxBrowser()
				//#endif

				//项目是否为小程序 MP代表所有小程序 MP-WEIXIN：微信小程序
				//#ifdef MP
				this.globalData.projectMini = MINI.wxApp
				this.globalData.loginAction = LOGIN_ACTION.wxApp
				this.getWxToken()
				//#endif
			},

			//判断是否运行于微信环境
			isRunningWxBrowser() {							
				if (this.isWxBrowser()) { 
					const { code, time } = this.getH5Code()
					if (code) {
						this.login(code)
					}			
				} else {
					this.globalData.projectMini = MINI.web
					this.login('')
				}
			},
			
			//判断是否为微信浏览器
			isWxBrowser(){
				let ua = window.navigator.userAgent.toLowerCase() //判断浏览器类型, 包含浏览器类型、版本、操作系统类型、浏览器引擎类型等信息
				return ua.match(/MicroMessenger/i) == 'micromessenger'
			}
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	@import "static/iconfont/iconfont-weapp-icon.css";

	/*每个页面公共css */
	// 设置整个项目的背景色
	page,
	view {
		margin: 0;
		padding: 0;
		font-family: PingFangSC-Regular, PingFang SC !important; //苹方简体
	}

	page,
	view,
	::after,
	::before {
		box-sizing: border-box
	}

	/*flex布局容器*/
	.flex {
		display: flex;
	}

	.flex_col {
		display: flex;
		flex-direction: column;
	}

	.flex_center {
		display: flex;
		align-items: center;
	}

	.flex_sb {
		display: flex;
		justify-content: space-between;
	}

	.flex_wrap {
		flex-wrap: wrap;
	}

	.flex_end {
		justify-content: flex-end;
	}

	.flex_cen {
		display: flex;
		justify-content: center;
	}

	/* 写一个CSS用于隐藏页面 */
	.display_none {
		display: none;
	}

	/* 字体加粗 */
	.font_bolder {
		font-weight: bolder;
	}

	/* 单行字体溢出省略 */
	.overflowOmitRow {
		width: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	/* 多行字体溢出省略 */
	.overflowOmitRows {
		width: 100%;
		display: -webkit-box;
		word-break: break-all;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.content_box {
		color: #434343;
		background: #FAFAFA;
		min-height: 100vh;
		font-size: 32rpx;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
	}

	/* 统一样式类 */
	.box_shadow_card {
		padding: 20rpx;
		border-radius: 24rpx;
		background-color: #FFFFFF;
		box-shadow: 1px 3px 12px 0px rgba(0, 0, 0, 0.04);
	}

	.routine_radius_card {
		padding: 24rpx;
		margin: 0 24rpx 24rpx;
		background-color: #FFFFFF;
		border-radius: 0 0 16rpx 16rpx;
	}

	// 通用按钮
	.common_btn {
		width: 327rpx;
		height: 88rpx;
		font-size: 32rpx;
		font-weight: bolder;
		color: #2E75E6;
		border-radius: 44rpx;
		border: 2rpx solid;
		margin-top: 20rpx;

		&::after {
			border: none;
		}
	}

	.shipment_code {
		font-size: 28rpx;
		font-weight: 400;
	}

	.operation-btn {
		width: 100%;
		margin-bottom: 40rpx;
		flex-grow: 1;
		display: flex;
		align-items: flex-end;

		.submitBtn {
			color: #FFFFFF;
			background: linear-gradient(136deg, #2E75E6 0%, #2E2EE6 100%);
		}
	}

	.u-form-item__body__left__content__required {
		font-size: 28rpx !important;
		top: auto !important;
		left: -16rpx !important;
	}

	//常用按钮样式
	.footer-btns{
        width: 100%;
        position:fixed;
        bottom: 0;
        height: 144rpx;
        background: #FFFFFF;
        padding: 28rpx 24rpx;
		z-index: 999;
		border-top:2rpx solid #F0F0F0;
    }
	.size-small{
		width: 327rpx !important;
	}
    .primary-btn{
		width: 100%;
        height: 88rpx;
        background: linear-gradient(90deg, #2E75E6 0%, #5E58EE 100%);
        border-radius: 48rpx;
        color: #FFFFFF;
        border-radius: 44rpx;
        line-height: 86rpx;
        font-size: 32rpx;
        font-weight: 500;
    }
    .info-btn{
		width: 100%;
        height: 88rpx;
        border-radius: 44rpx;
        border: 3rpx solid #2E75E6;
        color: #2E75E6;
        background: #FFFFFF;
        line-height: 86rpx;
        font-size: 32rpx;
        font-weight: 500;
    }
</style>
