Browse Source

商户绑定流程逻辑更改

xiaoxin 2 years ago
parent
commit
a088bd7232

+ 14 - 2
pages/addPlace/addPlace.vue

@@ -49,10 +49,14 @@
 				// 民宿列表
 				hotelList: [],
 				// 当前高亮索引
-				activeIndex: 0
+				activeIndex: 0,
+				// 已经选中的数组
+				oldList:[]
 			}
 		},
-		onLoad() {
+		onLoad(options) {
+			this.oldList = JSON.parse(options.list)
+			console.log(this.oldList);
 			this.getTownList()
 			this.getHotelList()
 		},
@@ -78,9 +82,17 @@
 						userId: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').id : ''
 					}
 				})
+				
 				// console.log(res)
 				if (res.code === 200) {
 					this.hotelList = res.data.pageList
+					this.hotelList.forEach((ele)=>{
+				         this.oldList.forEach((item)=>{
+				         	if(item.id ===ele.id){
+								ele.is_collect_hotel = true
+							}
+				         })
+					})
 				}
 			},
 			// 切换乡镇回调

+ 5 - 153
pages/binding/binding.vue

@@ -9,13 +9,13 @@
 			<view class="form_name">
 				账户
 				<view class="name_input">
-					<input type="text" placeholder="请输入商户超级管理员账号" v-model="formName" />
+					<input type="text" placeholder="请输入账号" v-model="formName" />
 				</view>
 			</view>
 			<view class="form_password">
 				密码
 				<view class="password_input">
-					<input type="text" password placeholder="请输入商户超级管理员密码" v-model="formPassword" />
+					<input type="text" password placeholder="请输入密码" v-model="formPassword" />
 				</view>
 			</view>
 			<view class="form_msg">{{ info }}</view>
@@ -37,8 +37,7 @@ export default {
 			// 账户
 			formName: '',
 			// 密码
-			formPassword: '',
-			code: ''
+			formPassword: ''
 		}
 	},
 	onLoad(options) {
@@ -68,156 +67,9 @@ export default {
 				})
 				return
 			}
-			console.log(this.formName)
-			console.log(this.formPassword)
-			uni.login({
-				provider: 'weixin',
-				success: (res) => {
-					this.code = res.code
-					if (this.type === '2') {
-						// 解绑
-						if (this.status === '1') {
-							// 商户解绑
-							this.handleUnbind()
-						} else {
-							// 业主解绑
-							this.handleUnbind2()
-						}
-					} else {
-						// 绑定
-						if (this.status === '1') {
-							// 商户绑定
-							this.handleBinding()
-						} else {
-							// 业主绑定
-							this.handleBinding2()
-						}
-					}
-				}
-			})
-		},
-		// 商户绑定请求
-		async handleBinding() {
-			const res = await this.$myRequest({
-				url: '/mhotel/appmanage_code.action',
-				data: {
-					code: this.code,
-					admin_name: this.formName,
-					password: this.formPassword
-				}
-			})
-			// console.log(res)
-			if (res.code === 200) {
-				uni.showToast({
-					title: res.message,
-					icon: 'success',
-					mask: true
-				})
-				let data = JSON.stringify(res.data)
-
-				setTimeout(() => {
-					uni.redirectTo({
-						url: `/pages/shopInfo/shopInfo?type=1&data=${data}`
-					})
-				}, 1500)
-			} else {
-				uni.showToast({
-					title: res.message,
-					icon: 'none',
-					mask: true
-				})
-			}
-		},
-		// 业主绑定请求
-		async handleBinding2() {
-			const res = await this.$myRequest({
-				url: '/mhotel/appcode.action',
-				data: {
-					code: this.code,
-					admin_name: this.formName,
-					password: this.formPassword
-				}
-			})
-			// console.log(res)
-			if (res.code === 200) {
-				uni.showToast({
-					title: res.message,
-					icon: 'success',
-					mask: true
-				})
-				let data = JSON.stringify(res.data)
-				setTimeout(() => {
-					uni.redirectTo({
-						url: `/pages/shopInfo/shopInfo?type=2&data=${data}`
-					})
-				}, 1500)
-			} else {
-				uni.showToast({
-					title: res.message,
-					icon: 'none',
-					mask: true
-				})
-			}
-		},
-		// 商户解绑请求
-		async handleUnbind() {
-			const res = await this.$myRequest({
-				url: '/mhotel/appuncode_ma.action',
-				data: {
-					code: this.code,
-					admin_name: this.formName,
-					password: this.formPassword
-				}
+			uni.navigateTo({
+				url: `/pages/web/web?url=https://chtech.ncjti.edu.cn/hotelReservation/getLoginCode/&formName=${this.formName}&formPassword=${this.formPassword}&type=${this.type}&status=${this.status}`
 			})
-			// console.log(res)
-			if (res.code === 200) {
-				uni.showToast({
-					title: res.message,
-					icon: 'success',
-					mask: true
-				})
-				setTimeout(() => {
-					uni.switchTab({
-						url: '/pages/my/my'
-					})
-				}, 1500)
-			} else {
-				uni.showToast({
-					title: res.message,
-					icon: 'none',
-					mask: true
-				})
-			}
-		},
-		// 业主解绑请求
-		async handleUnbind2() {
-			const res = await this.$myRequest({
-				url: '/mhotel/appuncode.action',
-				data: {
-					code: this.code,
-					admin_name: this.formName,
-					password: this.formPassword
-				}
-			})
-			// console.log(res)
-			if (res.code === 200) {
-				uni.showToast({
-					title: res.message,
-					icon: 'success',
-					mask: true
-				})
-				setTimeout(() => {
-					uni.switchTab({
-						url: '/pages/my/my'
-					})
-				}, 1500)
-			} else {
-				uni.showToast({
-					title: res.message,
-					icon: 'none',
-					mask: true
-				})
-			}
 		}
 	}
 }

+ 4 - 2
pages/detail/detail.vue

@@ -242,7 +242,9 @@
 					</view>
 
 					<!-- 入住时间区域 -->
-					<view class="box_time" v-if="item.liveTime">{{ item.liveTime.slice(0, 10) }}入住,{{ item.commentTime.slice(0, 10) }}发表 | {{ item.houseName }}</view>
+					<view class="box_time" v-if="item.liveTime && item.commentTime">
+						{{ item.liveTime.slice(0, 10) }}入住,{{ item.commentTime.slice(0, 10) }}发表 | {{ item.houseName }}
+					</view>
 
 					<!-- 评价内容区域 -->
 					<uv-read-more show-height="85rpx" closeText="全文" color="#096663" fontSize="24rpx" textIndent="0" :toggle="true" :shadowStyle="shadowStyle">
@@ -1750,4 +1752,4 @@ export default {
 		}
 	}
 }
-</style>
+</style>

+ 2 - 2
pages/evaluate/evaluate.vue

@@ -95,7 +95,7 @@
 				left: '-10000rpx',
 				top: '-10000rpx'
 			}"
-			canvas-id="zipCanvas"
+			canvas-id="zipCanvas2"
 		></canvas>
 		<!--画布结束-->
 	</view>
@@ -280,7 +280,7 @@ export default {
 					res.tempFiles.forEach((ele) => {
 						if (ele.fileType === 'image' && ele.size > 1024 * 1024 * 3) {
 							//这里的id和页面中写的html代码的canvas的id要一致
-							let canvasId = 'zipCanvas'
+							let canvasId = 'zipCanvas2'
 							//原图的路径
 							let imagePath = ele.tempFilePath
 							//大小限制1024kb

+ 7 - 2
pages/home3/home3.vue

@@ -101,7 +101,7 @@
 					<view class="circle color"></view>
 					<view class="top_title">精选攻略 .</view>
 					<view class="top_msg">宝藏分享社区</view>
-					<view class="top_more" @click="handleTest">
+					<view class="top_more" @click="handleGoPage">
 						更多
 						<img src="https://chtech.ncjti.edu.cn/hotelReservation/image/13.png" />
 					</view>
@@ -527,6 +527,11 @@ export default {
 			let res = (distance / 1000).toFixed(2) * 1
 
 			return res
+		},
+		handleGoPage() {
+			uni.switchTab({
+				url: '/pages/community/community'
+			})
 		}
 	}
 }
@@ -1131,4 +1136,4 @@ export default {
 		}
 	}
 }
-</style>
+</style>

+ 3 - 45
pages/identity/identity.vue

@@ -6,6 +6,7 @@
 export default {
 	data() {
 		return {
+			// 1为商户,2为业主
 			type: ''
 		}
 	},
@@ -15,52 +16,9 @@ export default {
 	},
 	methods: {
 		handleCheck(type) {
-			uni.login({
-				provider: 'weixin',
-				success: (res) => {
-					this.handleQuery(type, res.code)
-				}
+			uni.navigateTo({
+				url: `/pages/web/web?url=https://chtech.ncjti.edu.cn/hotelReservation/getLoginCode/&type=${type}&check=1`
 			})
-		},
-		// 查询请求
-		async handleQuery(type, code) {
-			if (type === '1') {
-				// 查询商家是否绑定
-				const res = await this.$myRequest({
-					url: '/mhotel/appget_user_ma.action',
-					data: {
-						code
-					}
-				})
-				if (res.code === 200) {
-					let data = JSON.stringify(res.data)
-					uni.redirectTo({
-						url: `/pages/shopInfo/shopInfo?type=1&data=${data}`
-					})
-				} else {
-					uni.redirectTo({
-						url: '/pages/shop/shop'
-					})
-				}
-			} else if (type === '2') {
-				// 查询业主是否已绑定
-				const res = await this.$myRequest({
-					url: '/mhotel/appgetUser.action',
-					data: {
-						code
-					}
-				})
-				if (res.code === 200) {
-					let data = JSON.stringify(res.data)
-					uni.redirectTo({
-						url: `/pages/shopInfo/shopInfo?type=2&data=${data}`
-					})
-				} else {
-					uni.redirectTo({
-						url: '/pages/shop2/shop2'
-					})
-				}
-			}
 		}
 	}
 }

+ 51 - 85
pages/myEvaluate/myEvaluate.vue

@@ -21,7 +21,7 @@
 					<img mode="aspectFill" :src="item.url" />
 					<view class="center_info">
 						<view>{{ item.houseOrderNumber }}间,{{ item.houseName }}</view>
-						<view v-if="item.checkOutTime">{{ item.checkOutTime.slice(0, 10) }} - {{ item.checkOutTime.slice(0, 10) }}</view>
+						<view v-if="item.checkOutTime">{{ item.liveTime.slice(0, 10) }} - {{ item.checkOutTime.slice(0, 10) }}</view>
 						<view>总价:¥{{ item.payAccount }}</view>
 					</view>
 				</view>
@@ -33,7 +33,7 @@
 
 				<!-- 审核中 已驳回 已评价 样式区域 -->
 				<view class="box_top2" v-if="activeCurrent !== 0">
-					<view class="top_name">{{ item.subTime }}发表</view>
+					<view class="top_name">{{ item.commentTime.slice(0, 20) }}发表</view>
 					<view class="box_type color" v-if="activeCurrent === 1">审核中</view>
 					<view class="box_type color2" v-if="activeCurrent === 2">已驳回</view>
 				</view>
@@ -42,46 +42,39 @@
 					<uni-rate readonly activeColor="#FFC300" :size="16" :value="item.score" />
 				</view>
 				<view class="box_content" v-if="activeCurrent !== 0">
-					审核中审核中审核中审核中审核中审核中审核中审核中审核中审核中审核中审核中审核中审核中审核中审核中审核中审核中审核中审核中审核中
+					{{ item.content }}
 				</view>
 
 				<!-- 图片列表区域 -->
 				<view class="box_img" v-if="activeCurrent !== 0">
-					<img
-						v-for="(ele, index) in item.urls"
-						:key="index"
-						mode="aspectFill"
-						v-if="ele.indexOf('jpg') !== -1 || ele.indexOf('png') !== -1"
-						:src="ele"
-						@click.stop="handleLookImg(ele, index)"
-					/>
-					<video
-						:id="item.id + index2"
-						class="video"
-						:show-fullscreen-btn="false"
-						:show-play-btn="false"
-						v-for="(video, index2) in item.urls"
-						:key="index2"
-						v-if="video.indexOf('mp4') !== -1"
-						:src="video"
-						@fullscreenchange="fullscreenchange"
-						@click.stop="handleClickVideo(item.id + index2)"
-					></video>
+					<view class="box_item" v-for="(ele, index) in item.url" :key="index">
+						<img mode="aspectFill" v-if="ele.indexOf('jpg') !== -1 || ele.indexOf('png') !== -1" :src="ele" @click.stop="() => handleLookImg(ele, index)" />
+						<video
+							:id="item.id + index"
+							class="video"
+							:show-fullscreen-btn="false"
+							:show-play-btn="false"
+							v-if="ele.indexOf('mp4') !== -1"
+							:src="ele"
+							@fullscreenchange="fullscreenchange"
+							@click.stop="handleClickVideo(item.id + index)"
+						></video>
+					</view>
 				</view>
 
 				<!-- 民宿信息区域 -->
 				<view class="box_hotel" v-if="activeCurrent !== 0" @click.stop="">
-					<img mode="aspectFill" :src="item.urls[0]" />
+					<img mode="aspectFill" :src="item.coverImg" />
 					<view class="hotel_info">
 						<view class="info_name">{{ item.hotelName }}</view>
-						<view class="info_tags">{{ item.houseOrderNumber }}间,{{ item.houseName }}</view>
-						<view class="info_tags">{{ item.liveTime.slice(0, 10) }} - {{ item.checkOutTime.slice(0, 10) }}</view>
-						<view class="info_tags">总价:¥{{ item.payAccount }}</view>
+						<view class="info_tags">{{ item.vo.houseOrderNumber }}间,{{ item.houseName }}</view>
+						<view class="info_tags">{{ item.vo.liveTime.slice(0, 10) }} - {{ item.vo.checkOutTime.slice(0, 10) }}</view>
+						<view class="info_tags">总价:¥{{ item.vo.payAccount }}</view>
 					</view>
 				</view>
 				<view class="box_desc" v-if="activeCurrent === 2">
 					<view class="desc_key">备注:</view>
-					<view class="desc_value">{{ item.desc }}</view>
+					<view class="desc_value">{{ item.vo.remark }}</view>
 				</view>
 			</view>
 
@@ -102,44 +95,7 @@ export default {
 			// 分段器数组
 			headerList: ['待评价', '审核中', '已驳回', '已评价'],
 			// 列表数据
-			list: [
-				{
-					id: 1,
-					hotelName: '民宿名称',
-					url: 'https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg',
-					houseOrderNumber: 1,
-					houseName: '单间',
-					payAccount: 229,
-					subTime: '2023-09-22 16:54:20',
-					liveTime: '2023-09-22 16:54:20',
-					checkOutTime: '2023-09-22 16:54:20',
-					score: 5,
-					urls: [
-						'https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg',
-						'https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg',
-						'https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg',
-						'https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg'
-					],
-					desc: '内容不实,驳回评价'
-				},
-				{
-					id: 2,
-					hotelName: '民宿名称',
-					url: 'https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg',
-					houseOrderNumber: 1,
-					houseName: '单间',
-					payAccount: 229,
-					subTime: '2023-09-22 16:54:20',
-					liveTime: '2023-09-22 16:54:20',
-					checkOutTime: '2023-09-22 16:54:20',
-					score: 5,
-					urls: [
-						'https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg',
-						'https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg'
-					],
-					desc: '内容不实,驳回评价'
-				}
-			],
+			list: [],
 			noDataMsg: '暂无待评价数据',
 			// 当前页
 			page: 1,
@@ -147,14 +103,14 @@ export default {
 			rows: 6,
 			// 总条数
 			total: null,
-			status: null,
+			status: 0,
 			// 是否是全屏状态
 			videoContext: null,
 			isFullScreen: false
 		}
 	},
 	onLoad() {
-		// this.getData()
+		this.getData()
 	},
 	methods: {
 		async getData() {
@@ -168,9 +124,11 @@ export default {
 				}
 			})
 			// console.log(res)
-			if (res.code === 200 && res.page.pageList) {
-				this.list = [...this.list, ...res.page.pageList]
-				this.total = res.total
+			if (res.code === 200) {
+				if (res.page.pageList) {
+					this.list = [...this.list, ...res.page.pageList]
+				}
+				this.total = res.page.total
 				this.headerList = [`待评价(${res.data.waitingCount})`, `审核中(${res.data.auditCount})`, `已驳回(${res.data.refuseAuditCount})`, `已评价(${res.data.ratedCount})`]
 			}
 		},
@@ -190,9 +148,9 @@ export default {
 				this.noDataMsg = '暂无已评价数据'
 				this.status = 1
 			}
-			// this.list = []
-			// this.page = 1
-			// this.getData()
+			this.list = []
+			this.page = 1
+			this.getData()
 		},
 		// 列表下拉到底部回调
 		handlePull() {
@@ -214,9 +172,9 @@ export default {
 		},
 		// 点击每一个评价订单的回调
 		handleGoDetail(item) {
-			if (this.activeCurrent === 1) {
+			if (this.activeCurrent !== 0) {
 				uni.navigateTo({
-					url: `/pages/appraiseDetail/appraiseDetail?id=${item.bookingCommentId}`
+					url: `/pages/appraiseDetail/appraiseDetail?id=${item.id}`
 				})
 			} else {
 				uni.navigateTo({
@@ -225,11 +183,13 @@ export default {
 			}
 		},
 		// 点击图片回调
-		handleLookImg(url, current) {
-			this.videoContext.stop()
+		handleLookImg(url, index) {
+			if (this.videoContext) {
+				this.videoContext.stop()
+			}
 			uni.previewImage({
 				urls: [url],
-				current
+				current: index
 			})
 		},
 		// 点击视频控件时触发的回调
@@ -386,16 +346,22 @@ export default {
 				padding: 20rpx 0 40rpx;
 				gap: 10rpx;
 
-				img {
+				.box_item {
 					width: 216rpx;
 					height: 216rpx;
 					border-radius: 20rpx;
-				}
 
-				.video {
-					width: 216rpx;
-					height: 216rpx;
-					border-radius: 20rpx;
+					img {
+						width: 216rpx;
+						height: 216rpx;
+						border-radius: 20rpx;
+					}
+
+					.video {
+						width: 216rpx;
+						height: 216rpx;
+						border-radius: 20rpx;
+					}
 				}
 			}
 

+ 29 - 2
pages/myHome/myHome.vue

@@ -62,7 +62,15 @@
 				<view class="item_box" v-for="item in list" :key="item.id">
 					<!-- 视频推文 -->
 					<view class="box_video" v-if="item.type === 'video'">
-						<video :src="item.url"></video>
+						<!-- :show-play-btn="false" -->
+						<video
+							:id="'id' + item.id"
+							:show-fullscreen-btn="false"
+							:direction="0"
+							:src="item.url"
+							@fullscreenchange="fullscreenchange"
+							@click="handleClickVideo('id' + item.id)"
+						></video>
 					</view>
 
 					<!-- 图片推文 -->
@@ -157,7 +165,11 @@ export default {
 					type: 'image',
 					url: ['https://chtech.ncjti.edu.cn/hotelReservation/fileload/download/1933617026前台.jpg']
 				}
-			]
+			],
+			// video 上下文 videoContext 对象
+			videoContext: null,
+			// 是否是全屏状态
+			isFullScreen: false
 		}
 	},
 	created() {
@@ -183,6 +195,21 @@ export default {
 		this.userInfo = uni.getStorageSync('userInfo')
 	},
 	methods: {
+		// 进入全屏和退出全屏时触发的回调
+		fullscreenchange(e) {
+			this.isFullScreen = e.detail.fullScreen
+		},
+		// 点击视频控件时触发的回调
+		handleClickVideo(id) {
+			this.videoContext = uni.createVideoContext(id)
+			if (this.isFullScreen) {
+				this.videoContext.pause()
+				this.videoContext.exitFullScreen()
+			} else {
+				this.videoContext.requestFullScreen()
+				this.videoContext.play()
+			}
+		},
 		handleBack() {
 			uni.navigateBack(1)
 		},

+ 265 - 14
pages/send/send.vue

@@ -13,14 +13,37 @@
 
 		<!-- 图片视频上传展示区域 -->
 		<view class="upload" :style="{ paddingTop: statusBarH * 2 + customBarH * 2 + 'rpx' }">
-			<view class="upload_img" @click="handleImage">
+			<view v-if="subImgList.length < maxImgCount && !subVideo" class="upload_img" @click="handleImage">
 				<img src="../../static/index/upload-img.png" />
 				添加图片
 			</view>
-			<view class="upload_video" @click="handleVideo">
+			<view v-if="!subImgList.length && !subVideo" class="upload_video" @click="handleVideo">
 				<img src="../../static/index/upload-video.png" />
 				添加视频
 			</view>
+
+			<!-- 图片展示区域 -->
+			<view class="upload_imgBox" v-for="(item, index) in subImgList" :key="index">
+				<img mode="aspectFill" :src="item" @click="handleLookImg(subImgList, index)" />
+				<view class="icon" @click="handleDelete(index)">
+					<img src="../../static/index/close2.png" />
+				</view>
+			</view>
+
+			<!-- 视频展示区域 -->
+			<view v-if="subVideo" class="upload_VideoBox">
+				<video
+					id="myVideo"
+					:show-fullscreen-btn="false"
+					:show-play-btn="false"
+					:src="subVideo"
+					@fullscreenchange="fullscreenchange"
+					@click="handleClickVideo('myVideo')"
+				></video>
+				<view class="icon" @click="handleDeleteVideo">
+					<img src="../../static/index/close2.png" />
+				</view>
+			</view>
 		</view>
 
 		<!-- 标题输入区域 -->
@@ -36,14 +59,14 @@
 		</view>
 
 		<!-- 添加地点区域 -->
-		<view class="add_place" @click="handleGoPage('/pages/addPlace/addPlace')">
+		<view class="add_place" @click="handleGoPage">
 			<img class="img" src="../../static/index/send-address.png" />
 			添加地点
 			<img class="img2" src="../../static/index/send-right.png" />
 		</view>
 
 		<!-- 关联民宿区域 -->
-		<view class="and">
+		<view class="and" v-if="andList.length">
 			<img class="img" src="../../static/index/send-binding.png" />
 			关联民宿
 		</view>
@@ -64,10 +87,26 @@
 				<view class="btn" @click="handleClickLook">查看推文</view>
 			</view>
 		</uni-popup>
+
+		<!-- 用于图片压缩的canvas画布 -->
+		<canvas
+			:style="{
+				width: cw + 'px',
+				height: cw + 'px',
+				position: 'absolute',
+				zIndex: -1,
+				left: '-10000rpx',
+				top: '-10000rpx'
+			}"
+			canvas-id="zipCanvas3"
+		></canvas>
+		<!--画布结束-->
 	</view>
 </template>
 
 <script>
+// 图片压缩方法
+import getLessLimitSizeImage from '@/util/imageCompress.js'
 export default {
 	data() {
 		return {
@@ -83,7 +122,17 @@ export default {
 			contentValue: '',
 			// activeIndex: null,
 			// 关联民宿列表
-			andList: []
+			andList: [],
+			// 上传的图片数据
+			subImgList: [],
+			// 最大上传图片张图
+			maxImgCount: 9,
+			// 上传的视频数据
+			subVideo: '',
+			// video 上下文 videoContext 对象
+			videoContext: null,
+			// 是否是全屏状态
+			isFullScreen: false
 		}
 	},
 	created() {
@@ -112,32 +161,136 @@ export default {
 		// 切换关联民宿回调
 		handleChange(item) {
 			item.is_collect_hotel = !item.is_collect_hotel
-			// this.activeIndex = index
 		},
 		// 点击添加图片回调
 		handleImage() {
 			uni.chooseMedia({
-				count: 9,
+				count: this.maxImgCount - this.subImgList.length,
 				mediaType: ['image'],
+				sizeType: ['compressed'],
 				success: (res) => {
-					console.log(res.tempFiles)
+					res.tempFiles.forEach((ele) => {
+						//这里的id和页面中写的html代码的canvas的id要一致
+						let canvasId = 'zipCanvas3'
+						//原图的路径
+						let imagePath = ele.tempFilePath
+						//大小限制1024kb
+						let limitSize = 1024 * 3
+						//初始绘画区域是画布自身的宽度也就是屏幕宽度
+						let drawWidth = uni.getSystemInfoSync().windowWidth
+						// 图片过大压缩
+						getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, (resPath) => {
+							this.handleUploadMini(resPath, 1)
+						})
+					})
 				}
 			})
 		},
 		// 点击添加视频回调
 		handleVideo() {
 			uni.chooseMedia({
-				count: 9,
+				count: 1,
 				mediaType: ['video'],
 				success: (res) => {
-					console.log(res.tempFiles)
+					res.tempFiles.forEach((ele) => {
+						if (ele.size > 1024 * 1024 * 5) {
+							// 视频过大压缩
+							uni.compressVideo({
+								src: ele.tempFilePath,
+								quality: 'low',
+								success: (res) => {
+									// console.log('压缩后', res)
+									this.handleUploadMini(res.tempFilePath, 2)
+								},
+								fail: (err) => {
+									// console.log(err)
+									uni.showToast(
+										{
+											title: '视频压缩失败',
+											icon: 'none'
+										},
+										2000
+									)
+								}
+							})
+						} else {
+							this.handleUploadMini(ele.tempFilePath, 2)
+						}
+					})
 				}
 			})
 		},
+		// 上传请求
+		handleUploadMini(ele, type) {
+			// 开始上传
+			uni.showLoading({
+				title: '上传中'
+			})
+			uni.uploadFile({
+				url: `https://chtech.ncjti.edu.cn/homestay/file/cos/upload`,
+				filePath: ele,
+				name: 'files',
+				success: (uploadFileRes) => {
+					// console.log(JSON.parse(uploadFileRes.data))
+					let temRes = JSON.parse(uploadFileRes.data)
+					if (temRes.code === 200 || temRes.code === 1) {
+						if (type === 1) {
+							this.subImgList.push(temRes.data)
+						} else if (type === 2) {
+							this.subVideo = temRes.data
+						}
+
+						// console.log(this.subImgList)
+						// console.log(this.subVideo)
+					} else {
+						uni.showToast({
+							title: temRes.message || '上传失败',
+							icon: 'none'
+						})
+					}
+				},
+				fail: () => {
+					uni.showToast({
+						title: '上传失败',
+						icon: 'error'
+					})
+				},
+				complete: (res) => {
+					uni.hideLoading({
+						complete: (hide) => {}
+					})
+				}
+			})
+		},
+		// 删除图片回调
+		handleDelete(index) {
+			this.subImgList.splice(index, 1)
+		},
+		// 删除视频回调
+		handleDeleteVideo() {
+			this.subVideo = ''
+		},
+		// 进入全屏和退出全屏时触发的回调
+		fullscreenchange(e) {
+			this.isFullScreen = e.detail.fullScreen
+		},
+		// 点击视频控件时触发的回调
+		handleClickVideo(id) {
+			this.videoContext = uni.createVideoContext(id)
+			if (this.isFullScreen) {
+				this.videoContext.stop()
+				this.videoContext.exitFullScreen()
+			} else {
+				this.videoContext.requestFullScreen()
+				this.videoContext.play()
+			}
+		},
 		// 点击添加地点回调
-		handleGoPage(url) {
+		handleGoPage() {
+			this.andList = this.andList.filter((ele) => ele.is_collect_hotel)
+			const list = JSON.stringify(this.andList)
 			uni.navigateTo({
-				url
+				url: `/pages/addPlace/addPlace?list=${list}`
 			})
 		},
 		// 全局自定义事件
@@ -146,15 +299,50 @@ export default {
 		},
 		// 点击发布按钮回调
 		handleClickSub() {
-			console.log(this.andList)
+			if (!this.subImgList.length && !this.subVideo) {
+				uni.showToast({
+					title: '请上传图片或者视频',
+					icon: 'none',
+					mask: true
+				})
+				return
+			}
+
+			if (!this.titleValue) {
+				uni.showToast({
+					title: '请输入标题',
+					icon: 'none',
+					mask: true
+				})
+				return
+			}
+			if (!this.contentValue) {
+				uni.showToast({
+					title: '请分享你的故事吧~',
+					icon: 'none',
+					mask: true
+				})
+				return
+			}
 			let temList = this.andList.filter((ele) => ele.is_collect_hotel)
 			console.log(temList)
+			console.log(this.subImgList)
+			console.log(this.subVideo)
+			console.log(this.titleValue)
+			console.log(this.contentValue)
 			this.$refs.popup.open()
 		},
 		// 点击弹窗查看推文按钮回调
 		handleClickLook() {
 			this.$refs.popup.close()
 		},
+		// 点击图片回调
+		handleLookImg(urls, current) {
+			uni.previewImage({
+				urls,
+				current
+			})
+		},
 		handleBack() {
 			uni.navigateBack(1)
 		}
@@ -169,6 +357,7 @@ export default {
 	background-color: #fff;
 
 	.header {
+		z-index: 1;
 		position: fixed;
 		top: 0;
 		left: 0;
@@ -192,6 +381,7 @@ export default {
 	}
 
 	.header2 {
+		z-index: 1;
 		position: fixed;
 		top: 0;
 		left: 0;
@@ -217,6 +407,7 @@ export default {
 		margin-top: 30rpx;
 		padding-bottom: 10rpx;
 		display: flex;
+		flex-wrap: wrap;
 
 		.upload_img {
 			display: flex;
@@ -257,6 +448,67 @@ export default {
 				height: 68rpx;
 			}
 		}
+
+		.upload_imgBox {
+			position: relative;
+			margin-left: 20rpx;
+			margin-bottom: 20rpx;
+			width: 186rpx;
+			height: 283rpx;
+
+			img {
+				width: 100%;
+				height: 100%;
+			}
+
+			.icon {
+				position: absolute;
+				top: 0;
+				right: 0;
+				display: flex;
+				justify-content: center;
+				align-items: center;
+				width: 30rpx;
+				height: 30rpx;
+				border-radius: 7rpx;
+				background-color: rgba(000, 000, 000, 0.5);
+
+				img {
+					width: 30rpx;
+					height: 30rpx;
+				}
+			}
+		}
+
+		.upload_VideoBox {
+			position: relative;
+			margin-left: 20rpx;
+			width: 186rpx;
+			height: 283rpx;
+
+			video {
+				width: 100%;
+				height: 100%;
+			}
+
+			.icon {
+				position: absolute;
+				top: 0;
+				right: 0;
+				display: flex;
+				justify-content: center;
+				align-items: center;
+				width: 30rpx;
+				height: 30rpx;
+				border-radius: 7rpx;
+				background-color: rgba(000, 000, 000, 0.5);
+
+				img {
+					width: 30rpx;
+					height: 30rpx;
+				}
+			}
+		}
 	}
 
 	.title {
@@ -279,7 +531,6 @@ export default {
 		width: 710rpx;
 		height: 290rpx;
 		font-size: 28rpx;
-		color: #b3b3b3;
 		border-bottom: 1rpx solid #e5e5e5;
 
 		.textarea {

+ 8 - 1
pages/web/web.vue

@@ -12,7 +12,14 @@ export default {
 		}
 	},
 	onLoad(options) {
-		this.webUrl = options.url
+		if (options.formName) {
+			this.webUrl = options.url + '?formName=' + options.formName + '&formPassword=' + options.formPassword + '&status=' + options.status + '&type=' + options.type
+		} else if (options.check) {
+			this.webUrl = options.url + '?type=' + options.type + '&check=' + options.check
+		} else {
+			this.webUrl = options.url
+		}
+		// console.log(this.webUrl)
 	}
 }
 </script>

+ 28 - 9
util/imageCompress.js

@@ -21,26 +21,38 @@ function imageSizeIsLessLimitSize(imagePath, limitSize, lessCallback, moreCallba
 
 //将图片画在画布上并获取画好之后的图片的路径
 function getCanvasImage(canvasId, imagePath, imageW, imageH, getImgSuccess) {
+
+	// 像素比
+	let pixelRatio
+	uni.getSystemInfo({
+		success: (res) => {
+			// console.log(res)
+			pixelRatio = res.devicePixelRatio
+		}
+	});
+
 	//创建画布内容
 	const ctx = wx.createCanvasContext(canvasId);
+
 	//图片画上去,imageW和imageH是画上去的尺寸,图像和画布间隔都是0
-	ctx.drawImage(imagePath, 0, 0, imageW, imageH);
+	ctx.drawImage(imagePath, 0, 0, imageW / pixelRatio, imageH / pixelRatio);
 	//这里一定要加定时器,给足够的时间去画(所以每次递归最少要耗时200ms,多次递归很耗时!)
-	ctx.draw(false, setTimeout(function() {
+	ctx.draw(false, setTimeout(() => {
 		//把当前画布指定区域的内容导出生成指定大小的图片,并返回文件路径
 		wx.canvasToTempFilePath({
 			canvasId: canvasId,
 			x: 0,
 			y: 0,
-			width: imageW,
-			height: imageH,
+			width: imageW / pixelRatio,
+			height: imageH / pixelRatio,
 			quality: 1, //最高质量
 			success: (res) => {
+				// console.log(res.tempFilePath);
 				//将取出的图片路径通过回调函数返回
 				getImgSuccess(res.tempFilePath);
 			}
 		})
-	}, 200));
+	}, 500));
 }
 
 //主函数,默认限制大小1024kb即1mb,drawWidth是绘画区域的大小
@@ -57,8 +69,10 @@ function getLessLimitSizeImage(canvasId, imagePath, limitSize = 1024, drawWidth,
 			wx.getImageInfo({
 				src: imagePath,
 				success: (imageInfo) => {
+
 					let maxSide = Math.max(imageInfo.width, imageInfo.height);
 					let windowW = drawWidth;
+
 					let scale = 1;
 					/*
 					这里的目的是当绘画区域缩小的比图片自身尺寸还要小的时候
@@ -70,16 +84,21 @@ function getLessLimitSizeImage(canvasId, imagePath, limitSize = 1024, drawWidth,
 					if (maxSide > windowW) {
 						scale = windowW / maxSide;
 					}
+
+					let imgW
+					let imgH
+
 					// 判断图片是否翻转了
 					if (imageInfo.orientation.indexOf('right') !== -1 || imageInfo.orientation.indexOf(
 							'left') !== -1) {
 						//trunc是去掉小数
-						var imgW = Math.trunc(imageInfo.height * scale);
-						var imgH = Math.trunc(imageInfo.width * scale);
+						imgW = Math.trunc(imageInfo.height * scale);
+						imgH = Math.trunc(imageInfo.width * scale);
 					} else {
-						var imgW = Math.trunc(imageInfo.width * scale);
-						var imgH = Math.trunc(imageInfo.height * scale);
+						imgW = Math.trunc(imageInfo.width * scale);
+						imgH = Math.trunc(imageInfo.height * scale);
 					}
+
 					// console.log('调用压缩', imgW, imgH);
 
 					//图片在规定绘画区域上画并获取新的图片的path