Forráskód Böngészése

长图海报发布

xhj 2 éve
szülő
commit
65bde3bbd4

+ 18 - 5
library/longPoster/index.vue

@@ -9,13 +9,17 @@
 		</view>
 		<view style="height: 120rpx;"></view>
 		<view class="ddflex" style="padding: 30rpx;">
-			<view class="poster-item" v-for="item in 36">
-				<image class="poster-item-pic" src="http://img.zhiqiyun.com/test/2023/07/31/8b7ed072b68fe70f0d6f409a71a8b17b.png" mode="aspectFill"></image>
-				<view class="poster-item-title tover">年度理赔账单</view>
-				<view class="zhuanfa" @click="download('http://img.zhiqiyun.com/test/2023/07/31/8b7ed072b68fe70f0d6f409a71a8b17b.png')">转发</view>
+			<view class="poster-item" v-for="item in pageList" @click="jumpDetail(item)">
+				<image class="poster-item-pic" :src="item.pic" mode="aspectFill"></image>
+				<view class="poster-item-title tover">{{item.title?item.title:'未命名'}}</view>
+				<view class="zhuanfa">编辑</view>
 				<!-- <view class="poster-item-use">2056 人正在使用</view> -->
 			</view>
 		</view>
+		<view class="nodata nosp bgfff" v-if="pageList.length==0">
+			<image src="/static/images/empty_sp.png"></image>
+			<text>暂无海报</text>
+		</view>
 		
 		<view class="act-create" @click="showBtn">
 			<image src="../static/images/add.png"></image>
@@ -57,7 +61,8 @@
 				},
 			}
 		},
-		onLoad(options) {
+		async onLoad(options) {
+			await req.silenceLogin()
 			this.getPageList(true);
 		},
 		onShow() {
@@ -128,6 +133,14 @@
 				
 					}
 				});
+			},
+			jumpDetail(item){
+				if(item.cateCode=='nianduzhangdan'){
+					this.jumpUrl('/library/longPosterService/longPosterService?id='+item.id)
+				}
+				if(item.cateCode=='riyuenianbao'){
+					this.jumpUrl('/library/longPosterService/longPosterService2?id='+item.id)
+				}
 			}
 		},
 		mounted() {

+ 10 - 0
library/longPosterContent/longPosterContent.vue

@@ -2,6 +2,12 @@
 	<view>
 		<!-- 账单 -->
 		<view class="form-input">
+			<view class="input-label">标题</view>
+			<view class="input-box ddflex">
+				<input v-model="title" class="fflex" placeholder="请填写"/>
+			</view>
+		</view>
+		<view class="form-input">
 			<view class="input-label">统计时间</view>
 			<picker mode="date" fields="year" :value="time" @change="timeChange">
 				<view class="input-box ddflex">
@@ -55,6 +61,7 @@
 		data() {
 			return {
 				time:'',
+				title:'',
 				
 				text1Index:-1,
 				text1List:[],
@@ -82,6 +89,7 @@
 				this.codeDetail = prevPage.$vm.codeDetail
 				
 				this.time = prevPage.$vm.time
+				this.title = prevPage.$vm.title
 				
 				this.text2Title = prevPage.$vm.dataForm[1].title
 				this.text2Content = prevPage.$vm.dataForm[1].data.value
@@ -114,6 +122,7 @@
 				}
 			},
 			async submit(){
+				if(!this.title) return req.msg("请填写标题")
 				if(!this.time) return req.msg('请选择统计时间')
 				if(this.text1Index<0) return req.msg('请选择文本一')
 				if(!this.text2Title) return req.msg('请填写文本二')
@@ -122,6 +131,7 @@
 				
 				let pages = getCurrentPages(); //获取所有页面栈实例列表
 				let prevPage = pages[pages.length - 2]; //上一页页面实例
+				prevPage.$vm.title = this.title
 				prevPage.$vm.time = this.time
 				prevPage.$vm.dataForm = await this.getSubmitData()
 				uni.navigateBack()

+ 11 - 0
library/longPosterContent/longPosterContent2.vue

@@ -2,6 +2,12 @@
 	<!-- 日报信息 -->
 	<view>
 		<view class="form-input">
+			<view class="input-label">标题</view>
+			<view class="input-box ddflex">
+				<input v-model="title" class="fflex" placeholder="请填写"/>
+			</view>
+		</view>
+		<view class="form-input">
 			<view class="input-label">报表类型</view>
 			<picker :range="formList" range-key="name" :value="formIndex" @change="formTypeChange">
 				<view class="input-box ddflex">
@@ -78,6 +84,8 @@
 				
 				time:'',
 				
+				title:'',
+				
 				text1Index:-1,
 				text1List:[],
 				
@@ -109,6 +117,7 @@
 				this.formType = prevPage.$vm.formType
 				this.formIndex = this.formList.findIndex(item=>item.value==prevPage.$vm.formType)
 				this.time = prevPage.$vm.time
+				this.title = prevPage.$vm.title
 				
 				this.codeDetail.map(item=>{
 					if(item.chineseName == '文本一') {
@@ -160,6 +169,7 @@
 				}
 			},
 			async submit(){
+				if(!this.title) return req.msg('请填写标题')
 				if(!this.time) return req.msg('请选择统计时间')
 				if(this.text1Index<0) return req.msg('请选择文本一')
 				if(this.text2Index<0) return req.msg('请选择文本二')
@@ -171,6 +181,7 @@
 				let prevPage = pages[pages.length - 2]; //上一页页面实例
 				prevPage.$vm.formType = this.formType
 				prevPage.$vm.time = this.time
+				prevPage.$vm.title = this.title
 				prevPage.$vm.dataForm = await this.getSubmitData()
 				uni.navigateBack()
 			},

+ 79 - 27
library/longPosterService/longPosterService.vue

@@ -2,19 +2,23 @@
 	<view>
 		<view class="poster" id="poster">
 			<!-- 年度理赔账单 -->
-			<image class="poster-pic" :src="posterBg" mode="widthFix"></image>
+			<image class="poster-pic" :src="posterBg?posterBg:'/library/static/images/temp1.png'" mode="widthFix"></image>
 			
 			<view style="position: absolute;top: 912rpx;left: 50%;transform: translateX(-50%);min-width:604rpx;">
-				<view style="font-size: 36rpx;font-weight: bold;text-align: center;">{{dataForm[0].title?dataForm[0].title:'文本一'}}</view>
-				<view style="font-size: 90rpx;font-weight: bold;color: #FF5700;margin-top: 5rpx;line-height: 126rpx;text-align: center;">{{dataForm[0].data?dataForm[0].data.value:'300'}}</view>
+				<view style="background-color: #fff;padding: 20rpx 0;">
+					<view style="font-size: 36rpx;font-weight: bold;text-align: center;">{{dataForm[0].title?dataForm[0].title:'文本一'}}</view>
+					<view style="font-size: 90rpx;font-weight: bold;color: #FF5700;margin-top: 5rpx;line-height: 126rpx;text-align: center;">{{dataForm[0].data?dataForm[0].data.value:'300'}}</view>
+				</view>
 				
-				<view style="font-size: 33rpx;font-weight: bold;margin-top: 78rpx;text-align: center;">{{dataForm[1].title?dataForm[1].title:'文本二'}}</view>
-				<view style="width:522rpx;font-size: 26rpx;font-weight: 400;color: #333;line-height: 48rpx;margin: 17rpx auto 0;">
-					{{dataForm[1].data?dataForm[1].data.value:'文本二内容'}}
+				<view style="background-color: #fff;margin-top: 30rpx;padding: 20rpx 0;">
+					<view style="font-size: 33rpx;font-weight: bold;text-align: center;">{{dataForm[1].title?dataForm[1].title:'文本二'}}</view>
+					<view style="width:522rpx;font-size: 26rpx;font-weight: 400;color: #333;line-height: 48rpx;margin: 17rpx auto 0;">
+						{{dataForm[1].data?dataForm[1].data.value:'文本二内容'}}
+					</view>
 				</view>
 				
 				
-				<view class="table-th ddflex">
+				<view class="table-th ddflex" v-if="dataForm[2].data.title&&dataForm[2].data.title.length>0">
 					<view class="table-th-item fflex" v-for="item,index in dataForm[2].data.title">{{item}}</view>
 				</view>
 				
@@ -64,10 +68,9 @@
 		props: {},
 		data() {
 			return {
-				productLink:'',
 				posterBg:'',
 				base64:'',
-				
+				title:'',
 				time:'',
 				dataForm:[{
 					chineseName:'文本一',
@@ -86,12 +89,17 @@
 					data:[]
 				}],
 				
-				codeDetail:''
+				codeDetail:'',
+				
+				id:""
 			}
 		},
 		onLoad(options) {
-			this.posterBg = 'https://img.zhiqiyun.com/test/2023/08/23/e5705790f7614ebede4c06073b7abd50.png'
 			this.getCodeDetail('nianduzhangdan')
+			if(options.id){
+				this.id = options.id
+				this.getPosterDetail()
+			}
 		},
 		onShow() {
 			
@@ -107,7 +115,24 @@
 					this.codeDetail = res&&res.extForm?JSON.parse(res.extForm):[]
 				})
 			},
+			getPosterDetail(){
+				req.getRequest('/api/material/library/detail',{id:this.id},res=>{
+					this.title = res&&res.title?res.title:''
+					this.time = res&&res.extForm?JSON.parse(res.extForm).time:''
+					this.posterBg = res&&res.extForm?JSON.parse(res.extForm).posterBg:''
+					this.dataForm = res&&res.extForm?JSON.parse(res.extForm).dataForm:[]
+				})
+			},
 			toImg() {
+				if(!this.title) return req.msg('请编辑内容')
+				if(!this.time) return req.msg('请编辑内容')
+				if(!this.dataForm[0].title) return req.msg('请编辑文本一')
+				if(!this.dataForm[1].title) return req.msg('请编辑文本二')
+				if(!this.dataForm[2].title) return req.msg('请编辑文本三')
+				
+				uni.showLoading({
+					title:'发布中'
+				})
 				// 使页面滑到顶部,避免顶部出现白边
 				uni.pageScrollTo({
 					scrollTop: 0,
@@ -119,27 +144,54 @@
 					height: dom.clientHeight,
 					scrollY: 0, // html2canvas默认绘制视图内的页面,需要把scrollY,scrollX设置为0
 					scrollX: 0,
-					useCORS: true, //支持跨域,但好像没什么用
+					useCORS: true, //支持跨域
 				}).then((canvas) => {
 					// 将生产的canvas转为base64图片
 					this.base64 = canvas.toDataURL('image/png')
-					console.log(this.base64)
-					uni.downloadFile({
-						url: this.base64, //仅为示例,并非真实的资源
-						success: (res) => {
-							console.log(res)
-							if (res.statusCode === 200) {
-								console.log('下载成功');
-								var oA = document.createElement("a");
-								oA.download = ''; // 设置下载的文件名,默认是'下载'
-								oA.href = res.tempFilePath; //临时路径再保存到本地
-								document.body.appendChild(oA);
-								oA.click();
-								oA.remove(); // 下载之后把创建的元素删除
+					req.postRequest('/api/nocheck/uploadBase64',{fileString:this.base64.replace('data:image/png;base64,','')},data=>{
+						let dataP = {
+							title:this.title,
+							code:'nianduzhangdan',
+							pic:data.src,
+							extForm:{
+								posterBg:this.posterBg,
+								time:this.time,
+								dataForm:this.dataForm
 							}
-					
 						}
-					});
+						dataP.extForm = JSON.stringify(dataP.extForm)
+						let url = '/api/material/saveLongPoster'
+						if(this.id) {
+							dataP.id = this.id
+							url = '/api/material/updateLongPoster'
+						}
+						// return false
+						req.postRequest(url,dataP,res=>{
+							uni.hideLoading()
+							req.msg('发布成功')
+							setTimeout(()=>{
+								uni.navigateBack()
+							},1000)
+						})
+					})
+					
+					
+					// uni.downloadFile({
+					// 	url: this.base64, //仅为示例,并非真实的资源
+					// 	success: (res) => {
+					// 		console.log(res)
+					// 		if (res.statusCode === 200) {
+					// 			console.log('下载成功');
+					// 			var oA = document.createElement("a");
+					// 			oA.download = ''; // 设置下载的文件名,默认是'下载'
+					// 			oA.href = res.tempFilePath; //临时路径再保存到本地
+					// 			document.body.appendChild(oA);
+					// 			oA.click();
+					// 			oA.remove(); // 下载之后把创建的元素删除
+					// 		}
+					
+					// 	}
+					// });
 				});
 			},
 			uploadImage(){

+ 61 - 8
library/longPosterService/longPosterService2.vue

@@ -2,7 +2,14 @@
 	<view>
 		<view class="poster" id="poster">
 			<!-- 日报 -->
-			<image class="poster-pic" :src="posterBg" mode="widthFix"></image>
+			<image class="poster-pic" :src="posterBg?posterBg:'/library/static/images/temp2.png'" mode="widthFix"></image>
+			<view style="position: absolute;top: 48rpx;right: 30rpx;text-align: right;color: #fff;font-size: 36rpx;font-weight: bold;" v-if="time">
+				<view>{{time.slice(0,4)}}年</view>
+				<view>
+					<block v-if="formType!=1">{{time.slice(5,7)}}月</block>
+					<block v-if="formType==3">{{time.slice(8,10)}}日</block>
+				</view>
+			</view>
 			<view style="position: absolute;top: 414rpx;left: 50%;transform: translateX(-50%);min-width:604rpx;">
 				<view style="font-size: 36rpx;font-weight: 400;text-align: left;color: #FFFFFF;">{{dataForm[0].title?dataForm[0].title:'文本一'}}</view>
 				<view style="font-size: 90rpx;font-weight: bold;text-align: left;color: #FFFFFF;">{{dataForm[0].data?dataForm[0].data.value:'300'}}</view>
@@ -72,6 +79,7 @@
 				
 				formType:1,//1 年报 2 月报 3日报
 				time:'',
+				title:'',
 				
 				dataForm:[{
 					chineseName:'文本一',
@@ -95,12 +103,17 @@
 					data:[]
 				}],
 				
+				id:'',
 				codeDetail:''
 			}
 		},
 		onLoad(options) {
 			this.posterBg = 'https://img.zhiqiyun.com/test/2023/08/23/d2ae45f898abdb12559da237f3c92188.png'
 			this.getCodeDetail('riyuenianbao')
+			if(options.id){
+				this.id = options.id
+				this.getPosterDetail()
+			}
 		},
 		onShow() {
 			
@@ -116,10 +129,28 @@
 					this.codeDetail = res&&res.extForm?JSON.parse(res.extForm):[]
 				})
 			},
+			getPosterDetail(){
+				req.getRequest('/api/material/library/detail',{id:this.id},res=>{
+					this.title = res&&res.title?res.title:''
+					this.time = res&&res.extForm?JSON.parse(res.extForm).time:''
+					this.posterBg = res&&res.extForm?JSON.parse(res.extForm).posterBg:''
+					this.formType = res&&res.extForm?JSON.parse(res.extForm).formType:''
+					this.dataForm = res&&res.extForm?JSON.parse(res.extForm).dataForm:[]
+				})
+			},
 			creatCode(){
 				
 			},
 			toImg() {
+				if(!this.title) return req.msg('请编辑内容')
+				if(!this.time) return req.msg('请编辑内容')
+				if(!this.dataForm[0].title) return req.msg('请编辑内容')
+				if(!this.dataForm[1].title) return req.msg('请编辑内容')
+				if(!this.dataForm[2].title) return req.msg('请编辑内容')
+				if(!this.dataForm[3].title) return req.msg('请编辑内容')
+				uni.showLoading({
+					title:'发布中'
+				})
 				// 使页面滑到顶部,避免顶部出现白边
 				uni.pageScrollTo({
 					scrollTop: 0,
@@ -135,13 +166,35 @@
 				}).then((canvas) => {
 					// 将生产的canvas转为base64图片
 					this.base64 = canvas.toDataURL('image/png')
-					// console.log(this.base64)
-					// let path = this.base64ToFile(this.base64,new Date().getTime())
-					let path = uni.base64ToArrayBuffer(this.base64);
-					console.log(path)
-					req.uploadFile('/api/nocheck/upload', path, res => {
-						console.log(res)
-					});
+					
+					req.postRequest('/api/nocheck/uploadBase64',{fileString:this.base64.replace('data:image/png;base64,','')},data=>{
+						let dataP = {
+							title:this.title,
+							code:'riyuenianbao',
+							pic:data.src,
+							extForm:{
+								posterBg:this.posterBg,
+								formType:this.formType,
+								time:this.time,
+								dataForm:this.dataForm
+							}
+						}
+						dataP.extForm = JSON.stringify(dataP.extForm)
+						let url = '/api/material/saveLongPoster'
+						if(this.id) {
+							dataP.id = this.id
+							url = '/api/material/updateLongPoster'
+						}
+						// return false
+						req.postRequest(url,dataP,res=>{
+							uni.hideLoading()
+							req.msg('发布成功')
+							setTimeout(()=>{
+								uni.navigateBack()
+							},1000)
+						})
+					})
+					
 					// uni.downloadFile({
 					// 	url: this.base64, //仅为示例,并非真实的资源
 					// 	success: (res) => {

BIN
library/static/images/temp1.png


BIN
library/static/images/temp2.png