<template>
	<view class="p-root-merchantManagement-dynamicNotice g_bg_f_5 g_p_10 g_pb_120" style="min-height: 100vh;padding-top: 24px;">
		<view class="g_pt_10" hover-class="none" hover-stop-propagation="false">
			<view class="g_mb_4 g_pl_10 g_c_6">预览</view>
			<view class="g_flex_row_start flex_center g_bg_f g_radius_8" style="overflow: hidden">
				<view class="g_flex_column_center g_h_48">
					<image class="g_w_48 g_h_48" :src="noticeImg" mode="aspectFit|aspectFill|widthFix" lazy-load="false" binderror="" bindload=""> </image>
				</view>
				<u-notice-bar color="#333" padding="0rpx" :playState="playState" font-size="32" style="width: calc(100% - 54px)" :speed="100" :volume-icon="false" type="none" :list="noticList"></u-notice-bar>
			</view>
		</view>
		<view class="g_mt_32">
			<view class="g_mb_4 g_pl_10 g_c_6">公告内容</view>
			<view class="g_bg_f g_pl_10 g_radius_8">
				<u-input type="textarea" height="240" :customStyle="{ fontSize: '34rpx' }" :clearable="false" autoHeight :value="notice" @input="changeNotice"></u-input>
			</view>
			<view class="g_mt_32" hover-class="none" hover-stop-propagation="false">
				<rh-button  :type="isChange ? 'primary' : 'disabled'" btnText="提交" @clickBtn="subNameInfo"
					:loading="isSubmit"
				/>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	onShareAppMessage() {
		return this.G.shareFun();
	},
	onLoad(options) {
		let appId = getApp().globalData.appId;
		if (appId == "wx581db3f39c49ed2b") {
			this.noticeImg = "https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/notice/yinghua.png";
		} else if (appId == "wxcd0e4a001e1d87bd") {
			this.noticeImg = "https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/notice/huipin.png";
		} else if (appId == "wxd522e45fa0d4be09") {
			this.noticeImg = "https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/notice/xindu.png";
		} else if (appId == "wx15bc9c758f4eb129") {
			this.noticeImg = "https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/notice/yexiaoman.png";
		} else {
			this.noticeImg = "https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/noticIcon.png";
		}
		console.log(this.appInfo);
		var reg = /[\r\n]/g;
		this.noticList[0] = this.appInfo.notice.replace(reg, "");
		this.notice = this.appInfo.notice;
		this.sqlStr = this.appInfo.notice;
		this.playState = "play";
	},
	data() {
		return {
			sqlStr:'',
			noticeImg: "",
			noticList: [""],
			notice: "",
			playState: "paused",
			appInfo: uni.getStorageSync("miniApp-info"),
			
			isSubmit:false,
			isChange:false,
		};
	},
	methods: {
		changeNotice(e) {
			console.log(e);
			let that = this;
			if(that.sqlStr == e){
				this.isChange = false;
			}else{
				this.isChange = true;
			}
			this.playState = "paused";
			var reg = /[\r\n]/g;
			this.notice = e;
			this.noticList[0] = e.replace(reg, "");
			this.playState = "play";
			if (e == "") {
				this.playState = "paused";
			}
		},
		subNameInfo() {
			let that = this;
			if(!that.isChange){
				return false;
			}
			that.isSubmit = true;
			this.G.Put(this.api.merchantManagement_updateField, { fieldName: "notice", fieldValue: this.noticList[0] }, () => {
      
				that.isSubmit = false;
				uni.showToast({
					title: "修改成功",
					icon: "none",
				});
				that.isChange = false;
				that.G.getAgencyInfo();
			},()=>{
				that.isSubmit = false;
			});
			// 在这里，使用世界前沿的人工智能技术，为用户甄选海量的在招职位，用更流畅，更快捷，更精准的搜索体验，带你去发现多彩的世界。
		},
	},
};
</script>

<style lang="less">
.p-root-person-idform {
	.m-submit {
		.bocai_btn_type_infro {
			background: #ccc !important;
			color: #fff !important;
			font-weight: 600 !important;
			font-size: 18px !important;
		}
	}
	.cardText {
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -50%);
		text-align: center;
	}
}
</style>
