<style>
.postPublishing {
  width: 100%;
  height: 100%;
  background: #FFF;
 
}
.postPublishing .box{
	padding: 0 15px;
}
.postPublishing .box-item{
	width: 100%;
	height: 50px;
	border-bottom: 1px solid #E2E2E2;
	display: flex;
	align-items: center;
}
.postPublishing .pubox{
	width: 100%;
	height:calc(100vh * 0.8) ;
	padding:0 15px;
}
.postPublishing .pubox-top{
	width: 100%;
	height: 45px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 14px;
	color: #111;
}
::-webkit-scrollbar{
 
   display:none;
 
}
.postPublishing .foritem{
	width: 100%;
	height: 45px;
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: space-between;
}
.postPublishing .flex-row{
	display: flex;align-items: center;
}
.postPublishing .slot-btn{
	width: 200rpx;
	height: 200rpx;
	display: flex;
	justify-content: center;
	align-items: center;
	flex-direction: column;
	background: rgb(244, 245, 246);
	border-radius: 10rpx;
	margin-left: 5px;
}
.postPublishing .slot-btn .mian-title {
	font-size: 28rpx;
	color: #888;
	font-weight: 600;
	margin: 10rpx 0;
}
.postPublishing .release{
	width: 100%;
	height: 45px;
	border-radius: 22px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	color: #FFFFFF;
	margin: 30px 0;
}
</style>

<template>
  <view class="postPublishing" :style="{ height: contentHeight }">
    <view class="box">
		
		<view>
			
			<textarea
			  style="height: 100px;width: 100%;padding: 15px 0;"
			  placeholder="来吧，尽情发挥吧..."
			  v-model="addMsg.Content"
			  maxlength='2000'
			/>
		</view>
		<view style="width: 100%;margin-top: 15px;">
			<u-upload :action="action" :file-list="fileList" @on-remove="onRemove1"  :custom-btn="true"
			 @on-success="uploadSuccessHandler">
				<view slot="addBtn" class="slot-btn">
					<u-icon name="photograph" size="40" color="#888"></u-icon>
					<view class="mian-title">上传图片</view>
				</view>
			</u-upload>
		</view>
		<view class="release" @click="releasebtn" :style="{background:mainColor}">
			发表
		</view>
	</view>

	
	
  </view>
</template>

<script>

export default {

  data() {
    return {
      pageTitle: "发表图文",
	  action: this.host2 + "/api/File/UploadTencent",
	  mainColor:'',
	  fileList:[],
	  addMsg:{}
    };
  },
  created() {
    this.mainColor = this.$uiConfig.mainColor;
	
  },
  mounted() {
   
    uni.setNavigationBarTitle({
      title: this.pageTitle,
    });
	let MallBaseId = uni.getStorageSync("mall_UserInfo").MallBaseId ? uni.getStorageSync("mall_UserInfo").MallBaseId : 1;
	this.action = this.host2 + '/api/File/UploadTencent?MallBaseId=' + MallBaseId
  },
  onLoad: function (option) {  
    this.addMsg = JSON.parse(decodeURIComponent(option.sendMsg))
  },
  methods: {
   
	onRemove1(index) {
		this.addMsg.ImageList.splice(index, 1);
	},
	uploadSuccessHandler(data, index, lists) {
		let r = JSON.parse(data);
		this.addMsg.ImageList.push(r.data);
	},

	releasebtn(){
		let pages = getCurrentPages(); // 当前页面
		let beforePage = pages[pages.length - 2]; // 前一个页面
		uni.showLoading({
			title:'发表中~'
		})
		this.request2(
			{
				url: '/api/AppletMiai/SgetActivityDiscussInfo',
				data: this.addMsg
			},
			res => {
				uni.hideLoading()
				uni.showToast({
					title: '发表成功',
					icon: 'none',
				})
				let that = this
				setTimeout(()=>{
					 uni.navigateBack({
						 success: function() {
							 beforePage.$vm.Children(); // 执行前一个页面的方法
						 }
					 });
				},1000)
			}
		);
		
		
	},


  },
};
</script>
