<script>
	export default {
		onLaunch: function() {
			
		},
		onShow: function() {
			
		},
		onHide: function() {
			
		},
		post: function(url, data) {
			var promise = new Promise((resolve, reject) => {
				//init
				let that = this,
					token = uni.getStorageSync('token'),
					header = {
						'token': token || ''
					},
					postData;
				//网络请求
				uni.request({
					url: this.globalData.baseUrl + url,
					data: data,
					method: 'POST',
					header: header,
					success: function(res) {
						
						//返回取得的数据
						if (res.data.code == '1') {
							resolve(res.data.data);
						}else {
								
							
							
							// uni.showToast({
							// 	title: res.data.msg,
							// 	icon: 'none'
							// });
							reject(res.data);
						}
					},
					fail: function(e) {
						reject('网络出错');
						uni.hideNavigationBarLoading();
					}
				});
			});
			return promise;
		},
		
		
		
		globalData: {
			userInfo: null,
			baseUrl: 'http://fnsxcx.w.brotop.cn'
		},
		
		upload(filetype, file) {
		
		    var promise = new Promise((resolve, reject) => {
		      wx.showNavigationBarLoading()
		      wx.showLoading({
		        title: '上传中',
		      })
		      let url = 'http://fnsxcx.w.brotop.cn/api/common/upload';
			 
			
		      let head = {
		        'token':uni.getStorageSync('token'),
		        'XX-Device-Type': ''
		      }
			  console.log(head)
		      let typename = {
		        filetype: filetype
		      }
		      wx.uploadFile({
		        url: url, //仅为示例,非真实的接口地址
		        filePath: file,
		        name: 'file',
		        header: head,
		        formData: typename,
		        success: function (res) {
		          console.log('上传文件后', res)
		          let temdata = JSON.parse(res.data);
		          console.log(temdata)
		          let urlobj = {
		            url: temdata.data.http_url,
		            kurl: temdata.data.url
		          }
		          resolve(urlobj);
		
		        },
		        fail: function (res) {
		          reject('网络出错');
		          wx.hideNavigationBarLoading()
		          wx.hideLoading()
		        },
		        complete: () => {
		          wx.hideNavigationBarLoading()
		          wx.hideLoading()
		        },
		      })
		    });
		    return promise;
		  },
		  
		
	}
</script>

<style>
	/*每个页面公共css */
	
	image {
		width: 100%;
		height: 100%;
		display: block;
	}
	
	.viewimg{
		width:560rpx;
		height:890rpx;
		font-size: 0;
		position:absolute;
		top:50%;
		left:50%;
		transform: translate(-50%,-50%);
	}
	.huifu{
		color:#333!important;
		margin-left:10rpx;
	}
	.nodata{
		color:#999;
		font-size: 32rpx;
		text-align: center;
		margin-top:40rpx;
	}
	/* 布局 */
	.layout_row{
		display: flex;
		display: -webkit-flex;
		flex-direction: row;
		align-items: center;
		justify-content: flex-start;
	}
	.justify_between{
		display: flex;
		display: -webkit-flex;
		flex-direction: row;
		justify-content: space-between;
	}
	.justify_column_bet{
		display: flex;
		display: -webkit-flex;
		flex-direction: column;
		align-items: flex-start;
		justify-content: space-between;
	}
	.column_center{
		display: flex;
		display: -webkit-flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
	.layer_star {
	    display: flex;
	    display: -webkit-flex;
		flex-direction: row;
	    justify-content: flex-start;
	    align-items: center
	}
	
	.layer_nostar {
	    display: flex;
	    display: -webkit-flex;
	    justify-content: flex-start;
	}
	
	.layer_center {
	    display: flex;
	    display: -webkit-flex;
	    justify-content: center;
	    align-items: center
	}
	
	.layer_nocenter {
	    display: flex;
	    display: -webkit-flex;
	    justify-content: center;
	}
	
	.layer_end {
	    display: flex;
	    display: -webkit-flex;
	    justify-content: flex-end;
	    align-items: center
	}
	
	.layer_noend {
	    display: flex;
	    display: -webkit-flex;
	    justify-content: flex-end;
	}
	
	.layer_between {
	    display: flex;
	    display: -webkit-flex;
	    justify-content: space-between;
	    align-items: center
	}
	
	.layer_nobetween {
	    display: flex;
	    display: -webkit-flex;
	    justify-content: space-between;
	}
	.layer_around{
		display: flex;
		display: -webkit-flex;
		justify-content: space-around;
		align-items: center;
	}
	.flex_star {
	    display: flex;
	    display: -webkit-flex;
	    flex-direction: column;
	    align-items: flex-start
	}
	.flex_column_center{
		display: flex;
		display: -webkit-flex;
		flex-direction: column;
		justify-content: flex-start;
		align-items: center
	}
	.flex_column_nojustify{
		display: flex;
		display: -webkit-flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
	.flex_star_between {
	    display: flex;
	    display: -webkit-flex;
	    flex-direction: column;
		justify-content: space-between;
	    align-items: flex-start
	}
	
	.flex_center {
	    display: flex;
	    display: -webkit-flex;
	    flex-direction: column;
	    align-items: center;
		justify-content: center;
	}
	.flex_warp {
	    display: flex;
	    display: -webkit-flex;
	    flex-wrap: wrap;
		align-items: center;
		justify-content: center;
	}
	.flex_wrap_between{
		display: flex;
		display: -webkit-flex;
		flex-wrap: wrap;
		justify-content: space-between;
	}
	.flex_wrap_no{
		display: flex;
		display: -webkit-flex;
		flex-wrap: wrap;
	}
	/* 模态框 */
	
	.tx_mask {
	    z-index: 99;
	    width: 100%;
	    height: 100vh;
	    position: fixed;
	    top: 0;
		left: 0;
	    background-color: rgba(0, 0, 0, 0.6);
	}
	/* 弹窗内容 */
	.mask_content{
		background-color: rgba(255,255,255,1);
		width:686upx;
		border-radius:16upx;
		position: fixed;
		top: 50%;
		left: 50%;
		transform: translate(-50%,-50%);
		z-index: 100;
	}
	.register {
	  width: 100%;
	  height: 100%;
	  background-color: rgba(0, 0, 0, 0.5);
	  position: fixed;
	  top: 0;
	  left: 0;
	  right: 0;
	  z-index: 999;
	}
	/* 海报 */
	.canvas_dialog{
		width: 590upx;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%,-50%);
		z-index: 100;
	}
	.over_hide{
		height: 100vh;
		overflow: hidden;
	}
	
	.commonpadding {
	  padding: 24rpx 32rpx;
	  box-sizing: border-box;
	  background: #fff;
	}
	
	.flex {
	  display: flex;
	}
	
	.flexone {
	  display: flex;
	  align-items: center;
	}
	
	.flextwo {
	  display: flex;
	  align-items: center;
	  justify-content: space-between;
	}
	
	.flexthree {
	  display: flex;
	  align-items: center;
	  justify-content: center;
	}
	
	.commonone {
	  color: #3d444c;
	  font-size: 28rpx;
	}
	
	.commontwo {
	  color: #232323;
	  font-size: 28rpx;
	}
	.yourow{
		width:28upx;
		height:30upx;
		font-size: 0;
	}
	.botbtn{
		width:686upx;
		height:96upx;
		background:rgba(238,139,39,1);
		border:2upx solid rgba(0,0,0,0);
		box-shadow:0upx 6upx 6upx rgba(238,139,39,0.16);
		opacity:1;
		color:#fff;
		font-size:28rpx;
		text-align: center;
		line-height: 96upx;
		position: fixed;
		bottom:44upx;
		left:32upx;
		border-radius:44upx;
		
	}
</style>