purchasedPhotoAlbum.vue 13.4 KB
Newer Older
qipeng's avatar
qipeng committed
1 2 3 4 5 6 7 8 9
<template>
	<view class="albumBox">
		<!--头部-->
		<view class="album-address">
			<view class="address-left">
				<view class="left-picker" @click="orderShow=true">
					<i>{{cityName}}</i>
					<image src="../static/album/myPhoto01.png"></image>
				</view>
qipeng's avatar
qipeng committed
10
				<u-picker mode="selector" :show="orderShow" :default-selector="[orderType]" :columns="option"	keyName="areaName" @confirm="industrysTypeConfirm($event)" @cancel="cancel"></u-picker>
qipeng's avatar
qipeng committed
11 12 13 14 15
				
				<view class="left-picker" @click="merchantShow=true">
					<i>{{merchantName}}</i>
					<image src="../static/album/myPhoto01.png"></image>
				</view>
qipeng's avatar
qipeng committed
16
				<u-picker mode="selector" :show="merchantShow" :default-selector="[orderType]" :columns="merchantList"	keyName="merchantName" @confirm="industrysTypeConfirm2($event)" @cancel="cancel2"></u-picker>
qipeng's avatar
qipeng committed
17 18 19 20
			</view>
		</view>
		
		<!--主体循环-->
qipeng's avatar
qipeng committed
21 22
		<view class="album-subjectBox" v-for="(item,index) in previewData" :key="index">
			<view class="suject-lable">
qipeng's avatar
qipeng committed
23 24
				<image src="../static/album/icon01.png"></image>
				<view>{{item.merchantName}}</view>
qipeng's avatar
qipeng committed
25
			</view>
qipeng's avatar
qipeng committed
26
			<view class="album-subject">
qipeng's avatar
qipeng committed
27 28
				<view class="subject-List" v-for="(item2,index2) in item.photoOrderImgResVoList" :key="index2">
					<image class="list-image" :src="item2.imgUrl"  @click="stopPhoto(index,index2)"></image>
qipeng's avatar
qipeng committed
29 30 31 32
					<!-- <u-checkbox v-model="item2.checkType" v-if="checkTypeFun==true" @click.stop.native="()=>{}" @change="stopPhoto(index,index2)" shape="circle" class="list-uCheck"></u-checkbox> -->
					<checkbox-group @click.stop.native="()=>{}" @change="stopPhoto(index,index2)">
						<checkbox value="val" :checked="item2.checkType" style="transform:scale(0.7)" class="list-uCheck" :class="item2.checkType==true?'list-uCheckAct':''" />
					</checkbox-group>
qipeng's avatar
qipeng committed
33 34
				</view>
			</view>
35
		</view>
qipeng's avatar
qipeng committed
36
		
qipeng's avatar
qipeng committed
37 38 39 40
		<!--脚部-->
		<view class="album-bottom">
			<view class="bottom-left" v-if="maskDetail==false">
				<!--全选按钮-->
qipeng's avatar
qipeng committed
41 42 43
				<view class="album-checkAll" @click="checkProjectAllFun()">
					<!-- <u-checkbox v-model="checkProjectAll" @change="checkProjectAllFun()">全选</u-checkbox> -->
					<checkbox value="val" :checked="checkProjectAll" style="transform:scale(0.7)" :class="checkProjectAll==true?'checkAll-allAct':''" />
qipeng's avatar
qipeng committed
44 45 46 47 48 49 50 51 52 53
					<view class="checkAll-tips">未下载影像保留15天</view>
				</view>
			</view>
			<view class="bootom-btn" @click="upLoad()">去下载</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
qipeng's avatar
qipeng committed
54 55 56 57
// import uPicker from '@/uview-ui/components/u-picker/u-picker.vue'
// import uCheckboxGroup from '@/uview-ui/components/u-checkbox-group/u-checkbox-group.vue'
// import uCheckbox from '@/uview-ui/components/u-checkbox/u-checkbox'
// import uToast from '@/uview-ui/components/u-toast/u-toast.vue'
qipeng's avatar
qipeng committed
58 59
export default {
  components: {
qipeng's avatar
qipeng committed
60 61 62 63
    // uPicker,
    // uCheckboxGroup,
    // uCheckbox,
    // uToast
qipeng's avatar
qipeng committed
64 65 66 67 68 69 70
  },
  data() {
    return {
      faceIds: [], //查询照片ID
      openid:'',
      orderShow: false, //头部城市选择
      option: [],//城市
qipeng's avatar
qipeng committed
71 72
      cityName: '全部',
      areaId:'',//城市ID
qipeng's avatar
qipeng committed
73 74 75
      merchantId:'',//商户ID
      location: {},//位置信息
      projectCheck: 0, //当前选择的产品
qipeng's avatar
qipeng committed
76 77
      merchantList:[],//商户列表
      merchantName:'全部',//商户名称
qipeng's avatar
qipeng committed
78
      merchantShow:false,//
qipeng's avatar
qipeng committed
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
      projectMoreType: false, //是否显示更多产品
      checkProjectAll: false, //所有产品全选
      maskDetail: false,
      maskPreviewType:false,//遮罩预览
      previewData: [ //图片预览
        // {
        //   type: false,
        //   src: '../static/album/customPic.png'
        // },
      ],
      previewNum: 0, //当前是第几张图片
      checkTypeFun:true,//刷新选项
      //左右滑动监听开始
      startData: {
        clientX: '',
        clientY: '',
      },
      transition: '',
      touch: {},
      touchLeft: 0,
      touchRight: 0,
      touchType: 0, //向左0++  向右1--
      //左右滑动 监听结束
      originalPrice:0,//原价单价
      originalPrices:0,//原价
      sellingPrice:0,//售价单价
      sellingPrices:0,//售价
      favorablePrice:0,//优惠
      priceNum:0,//选购了多少照片
qipeng's avatar
qipeng committed
108
      //options:{},//参数
qipeng's avatar
qipeng committed
109 110
      imgList:[],//下载图片列表
      downImgNumber:0,//下载图片的数量
qipeng's avatar
qipeng committed
111 112 113
    }
  },
  onLoad(option) {
qipeng's avatar
qipeng committed
114 115 116
    this.openid = uni.getStorageSync('openid') //获取openid
    //this.openid = 'oh2UV1lFq2CjxbBw0y7DOohhBFBM' //获取openid uni.getStorageSync('openid') 
    //this.options = option
qipeng's avatar
qipeng committed
117
    //this.merchantId = 'z0015605022691a5945bbe463141668c'//uni.getStorageSync('merchantId')
qipeng's avatar
qipeng committed
118 119 120 121 122 123 124 125 126 127 128
    this.obtainProvince()//获取省市区
    this.inquireMerchant()//查询所有商户
    this.getPhotos()//照片列表
  },
  methods: {
    obtainProvince(){//获取省列表
      this.$request('scenic/search/loadAreaByCity',{
        areaLevel:1,
        inChina:0
      }).then((res)=>{
        if(res.code=='00'){
qipeng's avatar
qipeng committed
129 130 131
          var opTionList = []
          opTionList.push(res.data)
          this.option = opTionList
qipeng's avatar
qipeng committed
132 133 134 135 136 137 138 139 140 141 142 143
        }else{
          this.$refs.uToast.show({
            title: res.message,
            type: 'error',
          })
        }
      })
    },
    inquireMerchant(){//查询所有商户
      var data = {
        areaCode:this.areaId,//省市ID
      }
qipeng's avatar
qipeng committed
144
		  this.$request('scenic/albumConfig/getSurveyConfig',data).then((res)=>{
qipeng's avatar
qipeng committed
145
		    if(res.code=='00'){
qipeng's avatar
qipeng committed
146 147 148
          var merchantListList = []
          merchantListList.push(res.data)
          this.merchantList = merchantListList
qipeng's avatar
qipeng committed
149 150 151 152 153 154 155 156 157 158
		    }else{
		      this.$refs.uToast.show({
		        title: res.message,
		        type: 'error',
		      })
		    }
		  })
    },
    getPhotos(){//照片
		  var data = {
qipeng's avatar
qipeng committed
159 160
		    userId:this.openid,
		    orderType:11,//商户ID
qipeng's avatar
qipeng committed
161
		  }
qipeng's avatar
qipeng committed
162
		  this.$request('orderc/photo/queryPhotoOrderList',data).then((res)=>{
qipeng's avatar
qipeng committed
163 164 165
		    if(res.code=='00'){
		      this.previewData = res.data
          this.previewData.forEach((item,index)=>{
qipeng's avatar
qipeng committed
166
            item.photoOrderImgResVoList.forEach((item2,index2)=>{
qipeng's avatar
qipeng committed
167 168
              item2['checkType'] = false
            })
qipeng's avatar
qipeng committed
169 170 171 172 173 174 175 176 177 178
          })
		    }else{
		      this.$refs.uToast.show({
		        title: res.message,
		        type: 'error',
		      })
		    }
		  })
    },
    industrysTypeConfirm(e) { //单列----分类 点击确定 城市
qipeng's avatar
qipeng committed
179 180
      this.cityName = e.value[0].areaName
      this.areaId = e.value[0].areaId
qipeng's avatar
qipeng committed
181
      this.inquireMerchant()
qipeng's avatar
qipeng committed
182
      this.cancel()
qipeng's avatar
qipeng committed
183
    },
qipeng's avatar
qipeng committed
184
    industrysTypeConfirm2(e) { //单列----分类 点击确定 项目
qipeng's avatar
qipeng committed
185 186
      this.merchantId = e.value[0].merchantId
      this.merchantName = e.value[0].merchantName
qipeng's avatar
qipeng committed
187
		  this.getPhotos()
qipeng's avatar
qipeng committed
188
      this.cancel2()
qipeng's avatar
qipeng committed
189
    },
qipeng's avatar
qipeng committed
190 191 192
    cancel() { //单列 点击取消
      this.orderShow = false
    },
qipeng's avatar
qipeng committed
193 194
    cancel2() { //单列 点击取消
		  this.merchantShow = false
qipeng's avatar
qipeng committed
195
    },
qipeng's avatar
qipeng committed
196
    stopPhoto(index,index2){//刷新显示
qipeng's avatar
qipeng committed
197 198 199
      if(this.checkProjectAll==true){
        this.checkProjectAll=false
      }
qipeng's avatar
qipeng committed
200 201
      if(this.previewData[index].photoOrderImgResVoList[index2].checkType==false){
        this.previewData[index].photoOrderImgResVoList[index2].checkType = true
qipeng's avatar
qipeng committed
202
      }else{
qipeng's avatar
qipeng committed
203
        this.previewData[index].photoOrderImgResVoList[index2].checkType = false
qipeng's avatar
qipeng committed
204 205 206 207 208 209 210 211
      }
      this.checkTypeFun = false
      this.checkTypeFun = true
    },
    checkProjectAllFun(){//是否全选
      if(this.checkProjectAll==true){
        this.checkProjectAll = false
        this.previewData.forEach((item,index)=>{
qipeng's avatar
qipeng committed
212
          item.photoOrderImgResVoList.forEach((item2,index2)=>{
qipeng's avatar
qipeng committed
213 214
					  item2.checkType = false
          })
qipeng's avatar
qipeng committed
215 216 217 218
        })
      }else{
        this.checkProjectAll = true
        this.previewData.forEach((item,index)=>{
qipeng's avatar
qipeng committed
219
          item.photoOrderImgResVoList.forEach((item2,index2)=>{
qipeng's avatar
qipeng committed
220 221
					  item2.checkType = true
          })
qipeng's avatar
qipeng committed
222 223 224
        })
      }
    },
qipeng's avatar
qipeng committed
225
    upLoad(){//下载
226
      this.imgList = []
qipeng's avatar
qipeng committed
227
      this.previewData.forEach((item,index)=>{
qipeng's avatar
qipeng committed
228
			  item.photoOrderImgResVoList.forEach((item2,index2)=>{
qipeng's avatar
qipeng committed
229
          if(item2.checkType==true){
qipeng's avatar
qipeng committed
230
            var imgUrl = item2.imgUrl
qipeng's avatar
qipeng committed
231 232
            this.imgList.push(imgUrl)
          }
qipeng's avatar
qipeng committed
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
			  })
      })
      this.download()
    },
    //---点击下载
    download(){
		  this.downImgNumber=0
		  this.imgList.forEach(item=>{
		    this.downloadFun(item)
		  })
    },
    //---下载方法
    downloadFun(imgUrl) { 
		  uni.showLoading({
		    title: '下载中',
		    mask: true
		  })
		  let fileName = new Date().getTime()
		  uni.downloadFile({ //下载文件资源到本地
		    url:imgUrl,
		    filePath: wx.env.USER_DATA_PATH + '/' + fileName + '.jpg', //filePath指定文件下载后存储的路径,wx.env.USER_DATA_PATH,时间戳为文件名
		    success: res => { //下载到本地成功
		      if(res.statusCode==200){
		        let filePath = res.filePath
		        uni.saveImageToPhotosAlbum({ //保存图片到系统相册。
						  filePath,
						  success: file => { //保存成功
		            this.downImgNumber+=1
		            if(this.downImgNumber==this.imgList.length){
		              uni.showToast({
									  title: '下载成功',
									  icon: 'success',
									  mask: true
		              })
		            }
						  },
						  fail: err => {
						    uni.hideLoading()
						    this.getPermissions(err)
						  }
		        })
		      }
		    },
		    fail: err => { //下载失败
		      uni.hideLoading()
		      uni.showToast({
		        title: '下载失败',
		        icon: 'none',
		        mask: true
		      })
		    }
		  })
    },
    //---获取授权
    getPermissions(err){
		  //拒绝授权时显示
		  if (err.errMsg.includes('fail auth deny')) {
			  uni.showModal({
			    title: '提示',
			    content: '需要您授权保存相册',
			    showCancel: false,
			    success: data => {
			      //打开权限设置
			      uni.openSetting({
			        success: setting => {
			          if (!setting.authSetting['scope.writePhotosAlbum']) {
			            uni.showModal({
			              title: '提示',
			              content: '获取权限失败无法保存到相册',
			              showCancel: false,
			            })
			          }
			        },
			      })
			    }
			  })
		  }
qipeng's avatar
qipeng committed
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
    },
  }
}
</script>

<style scoped lang="scss">
	page {
		background-color: #F7F7F7;
	}

	.albumBox {
		// 76=16 - 44 - 16   98 =34 - 32 - 32
		display: flex;
		flex-direction: column;
		height: 100%;
		background-color: #F7F7F7;
		padding-bottom: 98rpx;
327
		padding-top: 96rpx;
qipeng's avatar
qipeng committed
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
		overflow: auto;
	}

	.album-address {
		display: flex;
		justify-content: space-between;
		width: 100%;
		height: 76rpx;
		padding: 0 24rpx 0 24rpx;
		background-color: #FFFFFF;
		box-shadow: 0 0 16px 0 rgba(0, 0, 0, 0.1);
		overflow: hidden;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 20;

		.address-left {
			display: flex;
			flex: 1;
			box-shadow: inset -16px 0px 8px 0px rgba(255, 255, 255, 0.2);
			overflow-x: auto;

			.left-picker {
				display: flex;
				font-size: 32rpx;
				color: #333333;
				line-height: 76rpx;
				margin-right: 24rpx;

				image {
					width: 26rpx;
					height: 26rpx;
					margin-top: 25rpx;
					margin-left: 8rpx;
				}
			}
qipeng's avatar
qipeng committed
365 366 367 368 369
			/deep/ .u-popup{
				position: absolute;
				left: 0;
				top: 0;
			}
qipeng's avatar
qipeng committed
370 371 372 373 374 375
		}
	}

	.album-address::-webkit-scrollbar {
		display: none;
	}
376 377 378 379 380 381
	.album-subjectBox{
		display: flex;
		flex-direction: column;
		flex: 1;
		overflow: auto;
	}
qipeng's avatar
qipeng committed
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
	.suject-lable{
		display: flex;
		height: 44rpx;
		margin-bottom: 24rpx;
		padding: 0 24rpx 0 24rpx;
		image{
			display: block;
			width: 32rpx;
			height: 32rpx;
			margin: 6rpx 6rpx 0 0;
		}
		view{
			font-size: 32rpx;
			color: #333333;
			line-height: 44rpx;
		}
	}
qipeng's avatar
qipeng committed
399 400 401 402 403 404 405
	.album-subject {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		padding: 0 24rpx 0 24rpx;
		.subject-List {
			width: 344rpx;
qipeng's avatar
qipeng committed
406
			height: 344rpx;
qipeng's avatar
qipeng committed
407 408 409 410 411 412 413 414
			margin-bottom: 24rpx;
			border-radius: 16rpx;
			overflow: hidden;
			position: relative;

			.list-image {
				display: block;
				width: 344rpx;
qipeng's avatar
qipeng committed
415
				height: 344rpx;
qipeng's avatar
qipeng committed
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
			}

			.list-mask {
				width: 344rpx;
				height: 64rpx;
				background-color: rgba(0, 0, 0, 0.2);
				font-size: 28rpx;
				color: #fff;
				line-height: 64rpx;
				text-align: center;
				position: absolute;
				left: 0;
				bottom: 0;
			}

			.list-uCheck {
				position: absolute;
				right: 0;
				top: 24rpx;
qipeng's avatar
qipeng committed
435 436 437 438 439 440 441 442 443 444 445 446
				/deep/ .wx-checkbox-input,
				/deep/ .uni-checkbox-input{
					border-radius: 100rpx;
				}
			}
			.list-uCheckAct{
				/deep/ .wx-checkbox-input,
				/deep/ .uni-checkbox-input{
					background-color: #3688FF !important;
					border-color: #3688FF !important;
					color: #ffffff !important;
				}
qipeng's avatar
qipeng committed
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
			}
		}
	}

	.album-bottom {
		display: flex;
		justify-content: space-between;
		width: 100%;
		height: 98rpx;
		padding: 0 0 0 24rpx;
		box-shadow: 0rpx -2rpx 8rpx 2rpx rgba(0, 0, 0, 0.08);
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 25;

		.bottom-left {
			flex: 1;
			display: flex;
			line-height: 98rpx;
			.album-checkAll {
qipeng's avatar
qipeng committed
468
				display: flex;
qipeng's avatar
qipeng committed
469 470
				width: 100%;
				height: 98rpx;
qipeng's avatar
qipeng committed
471
				padding: 0rpx 24rpx 0 0rpx;
qipeng's avatar
qipeng committed
472 473 474 475 476 477 478 479
				overflow: hidden;
				/deep/ .u-checkbox {
					line-height: 34rpx !important;
				}
			
				/deep/ .u-checkbox__label {
					font-size: 24rpx !important;
				}
qipeng's avatar
qipeng committed
480 481 482 483 484 485 486 487
				.checkAll-allAct{
					/deep/ .wx-checkbox-input,
					/deep/ .uni-checkbox-input{
						background-color: #3688FF !important;
						border-color: #3688FF !important;
						color: #ffffff !important;
					}
				}
qipeng's avatar
qipeng committed
488 489 490 491
			
				.checkAll-tips {
					font-size: 24rpx;
					color: #999999;
qipeng's avatar
qipeng committed
492
					line-height: 98rpx;
qipeng's avatar
qipeng committed
493 494 495 496 497 498 499 500 501
					margin-left: 24rpx;
				}
			}
		}

		.bootom-btn {
			width: 240rpx;
			height: 98rpx;
			background-color: #3688FF;
qipeng's avatar
qipeng committed
502
			background: linear-gradient(90deg, #ED400C 0%, #FB862C 100%);
qipeng's avatar
qipeng committed
503 504 505 506 507 508 509 510 511
			font-size: 32rpx;
			color: #fff;
			font-weight: bold;
			text-align: center;
			line-height: 98rpx;
		}
	}

</style>