<script>
	import configData from './config.js'
	export default {
		onLaunch: function() {
			console.log('App Launch');
			console.log(configData, '--------------')
		},
		onShow: function() {
			console.log('App Show');
		},
		onHide: function() {
			console.log('App Hide');
		},
		methods: {
			request(api, params, method) {
				var that = this;
				let method1 = method
				let header1 = {
					'content-type': 'application/json;charset=utf-8',
					'Authorization': 'bearer' + ' ' + uni.getStorageSync('token'),
					'type': 'weapp'
				}
				// if (method.toUpperCase() == 'PUT') {
				// 	method1 = 'POST'
				// 	header1['X-HTTP-Method-Override'] = 'PUT'
				// }
				// if (method.toUpperCase() == 'DELETE') {
				// 	method1 = 'POST'
				// 	header1['X-HTTP-Method-Override'] = 'DELETE'
				// }
				return new Promise((resolve, reject) => {
					uni.request({
						url: configData.data.baseUrl + api,
						data: params,
						header: header1,
						method: method1,
						success: (res) => {
							resolve(res)
							// console.log(res)
							if (res.statusCode == 450) {
								return;
							}
							if (res.data.statusCode != 200) {
								if (res.data.message == '订单不存在或订单已结算') {
									uni.redirectTo({
										url: '/pages/index/index',
									})
									return false;
								} else if (res.data.message == '运动中不能关锁') {

									return false;
								}
								if (res.message != undefined) {

								} else if (res.data.message != undefined) {

								}
							} else if (res.statusCode != 200) {
								if (res.message != undefined) {
									uni.showToast({
										title: res.message,
										icon: 'none',
										duration: 3000,
										mask: true
									})
								} else if (res.data.message != undefined) {
									uni.showToast({
										title: res.data.message,
										icon: 'none',
										duration: 3000,
										mask: true
									})
								}
							}
							if (res.statusCode == 429) {
								uni.showToast({
									title: "操作频繁请稍后再试",
									icon: 'none',
									duration: 3000,
									mask: true
								})
								uni.navigateBack({

								})
							}
							if (res.statusCode == 401) {
								uni.removeStorageSync('token')
								uni.reLaunch({
									url: '/pages/login/index'
								})
								// this.tokens()

							}
						},
						fail: (err) => {

							reject("请求失败")
						}
					})
				})
			},
		}
	};
</script>

<style>
	/* 解决头条小程序组件内引入字体不生效的问题 */
	/* #ifdef MP-TOUTIAO */
	@font-face {
		font-family: uniicons;
		src: url('/static/uni.ttf');
	}

	/* #endif */




	@font-face {
		font-family: "iconfont";
		src: url('~@/static/font/iconfont.eot?t=1617154761591');
		/* IE9 */
		src: url('~@/static/font/iconfont.eot?t=1617154761591#iefix') format('embedded-opentype'),
			/* IE6-IE8 */
			url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAdQAAsAAAAADUAAAAcCAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCECgqMPIpEATYCJAMkCxQABCAFhG0HeRtpC8iemjwRAhawACCBBPJgRYCtkbNw/AwlUk09sCSSxEKiZ1UlAY2uJlRVvZ/HTXs/QROgBhSm1GSu1A42RyqGBAh+JBMPVQZzMcqZSAIERCfs7v59+7V62i0UbPB2vcx8sd1FfBG1dO9HPF/CQiIkUW+EQigQIjkSCwrDKYHJ7zXT6wloLSmG9pSNM4BIxjkBo67RTguIbMVySDio80qfY/NraBnw1XEh9gh4oP58+AZbE4GoSMDd6OCFUjuM/pjy00eJ+/+22sQBl5/E6yQStgCZ8My36ingur1FZa3fRJ5LwJhk9jvjx5TPun428jP6684/Rf5e+vtR3+N24xIFY/xRoFaqBIUolf/HK4GyAQRvOXXPaqJq8q4oVIKPRKEKnEYugW+dcyn4GykUwS+hUAL/CPpMZI18zBiwDMJXEN8BJ/aoXUEljZST+X2mCGE+ScgEks6jkVTCxovT0hRJSdLUVL1AJhPfzYO2nJLbL11WWM4fVaLEm6rVa9HbH5lJnDj1rAtsfs5gdxNZOzqMwoFlKHzkwpnsRuLWKw1sjg8I+JgB5NmX3RFp2U3G8vYeRehuYibaenUQiSmJPVequFVyYs0a5SfqyGVSWnHb2tX3hqqw+zp3zbkmYY7H5Ws7TK9eUWt2yYfj4QPRfXJs5O+h+ziFcTVJxtLNazfUEKgjWBqAkDaIx41k7GD4AEF4yETCbKncgBKZDDBy6/aTpEoxGojoPo6R3/EdHQzBXX8ce3ozfONJ9NG1mvTqL5/5pUZn1S5mClnHfPo59yz6IvySgqfisvJV69bvTt+YMK7eu3ED41izCu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FtTi/spdyqXlCtyM38Nzm7+ZkRUUqhlKEhtXCTsiGj5BZzAdWPey1dMxmbuGGLShKiyCEltjTcHt0Chsw1Kte3Q2qz85M64EFzIYmCTVgLBiKMQDXkDyYjHCETwXShM+RZKI+HQOh7SztlZF01oQ5SFpewa6ywNbQv4HUIZS2ijp1DOaV5LyGqoSSYqxNCtmj49ezt7yyk/FcrjAGa6sy/LOjSOUMCnKSM3o7zegCYYCrgpG9vTxbLBob16OfwO7GkL+ICwWwjFgpWz2mlYzYql2QT4ORKzCNf3T0FxmsbLIhTi+hNrQglh0GvX6KOn3jG85cwfy7UuExnTOfXFUumgETtCAny6KGOS4uW7AjSC/lu5UWxYPblSdAQN1YtO5YjLepYvfNN6FbS4L9AEDOGIh/hIgIRIhMSIgPKCxe+aRgvZgN8520ULZtKW2RaaPyNgp/ryQ7TTxRKzLH437Xf2sNISY4SHYly08F0EAAAA') format('woff2'),
			url('~@/static/font/iconfont.woff?t=1617154761591') format('woff'),
			url('~@/static/font/iconfont.ttf?t=1617154761591') format('truetype'),
			/* chrome, firefox, opera, Safari, Android, iOS 4.2+ */
			url('~@/static/font/iconfont.svg?t=1617154761591#iconfont') format('svg');
		/* iOS 4.1- */
	}

	.iconfont {
		font-family: "iconfont" !important;
		font-size: 16px;
		font-style: normal;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
	}

	.icon-yanjing-bi:before {
		content: "\e61d";
	}

	.icon-fanhui:before {
		content: "\e669";
	}

	.icon-yanjingkeshi:before {
		content: "\e63e";
	}

	.icon-yanjing:before {
		content: "\e611";
	}

	.icon-right:before {
		content: "\eb1b";
	}

	.icon-tongzhi:before {
		content: "\f288";
	}

	.icon-xiazai:before {
		content: "\f2bc";
	}

	.icon-wode2:before {
		content: "\f2e2";
	}
</style>
