albumIndex.vue 16.3 KB
Newer Older
1
<template>
2
	<view class="big-box" :style="{'padding-top': statusBarHeight + 'px'}" v-if="show">
3 4

		<view class="nav-bar"
5 6
			:style="{'display': 'flex','top': statusBarHeight + 'px', 'height': navHeight + 'px','line-height': navHeight + 'px'}">
			<u-icon name="arrow-left" color="#333" v-if="options.index" @click="returnClick"></u-icon>
renjie's avatar
renjie committed
7 8
			摄影/旅拍
		</view>
9

renjie's avatar
renjie committed
10
		<view class="body">
11
			<view class="scroll-view">
renjie's avatar
renjie committed
12
				<view class="item" @click="jumpToScanFaceClick">
renjie's avatar
renjie committed
13
					<image class="img" src="./static/album/myAlbum.png"></image>
renjie's avatar
renjie committed
14 15 16
					<text class="title">我的相片</text>
				</view>
				<view class="item">
renjie's avatar
renjie committed
17
					<image class="img" src="./static/album/DIY.png"></image>
renjie's avatar
renjie committed
18 19
					<text class="title">影像DIY</text>
				</view>
renjie's avatar
renjie committed
20
				<view class="item" @click="jumpToScanFaceClick">
renjie's avatar
renjie committed
21
					<image class="img" src="./static/album/custom.png"></image>
renjie's avatar
renjie committed
22 23
					<text class="title">旅拍定制</text>
				</view>
renjie's avatar
renjie committed
24
				<view class="item" @click="jumptoVlog">
renjie's avatar
renjie committed
25
					<image class="img" src="./static/album/myVlog.png"></image>
renjie's avatar
renjie committed
26 27 28
					<text class="title">我的Vlog</text>
				</view>
			</view>
29

renjie's avatar
renjie committed
30 31 32 33
			<view class="private-custom">
				<view class="title">私人定制</view>
				<u-waterfall v-model="list" ref="uWaterfall">
					<template v-slot:left="{leftList}">
34 35
						<view class="left demo-water" v-for="(item, index) in leftList" :key="index"
							@click="jumpToClick(item.title)">
renjie's avatar
renjie committed
36
							<image :src="item.image" mode="aspectFill"></image>
renjie's avatar
renjie committed
37 38
							<view class="info-box" :style="{'background-color': item.color}">
								<view class="item-title">{{item.title}}</view>
renjie's avatar
renjie committed
39
								<view class="slogan">快来定制吧</view>
renjie's avatar
renjie committed
40 41 42 43 44 45 46 47
								<view class="bottom">
									<view class="img-btn">
										点击定制
										<u-icon name="arrow-right"></u-icon>
									</view>
									<text class="count">{{item.count}}</text>
								</view>
							</view>
48
						</view>
renjie's avatar
renjie committed
49 50
					</template>
					<template v-slot:right="{rightList}">
51 52
						<view class="demo-water" v-for="(item, index) in rightList" :key="index"
							@click="jumpToClick(item.title)">
renjie's avatar
renjie committed
53
							<image :src="item.image" mode="aspectFill"></image>
renjie's avatar
renjie committed
54 55
							<view class="info-box" :style="{'background-color': item.color}">
								<view class="item-title">{{item.title}}</view>
renjie's avatar
renjie committed
56
								<view class="slogan">快来定制吧</view>
renjie's avatar
renjie committed
57 58 59 60 61 62 63 64 65 66 67 68 69
								<view class="bottom">
									<view class="img-btn">
										点击定制
										<u-icon name="arrow-right"></u-icon>
									</view>
									<text class="count">{{item.count}}</text>
								</view>
							</view>
						</view>
					</template>
				</u-waterfall>
			</view>
		</view>
70

71 72
		<view class="coupon" @click="showUseRule = true" v-if="isHaveCoupon">
			<image class="coupon-img" src="@/static/img/my/coupon.png" mode="aspectFit"></image>
renjie's avatar
renjie committed
73 74 75 76 77
			<text class="coupon-price">
				<text class="r-symbol"></text>
				{{couponPrice}}
			</text>
		</view>
78

79 80
		<u-overlay :show="couponTip || showUseRule">
			<view class="mask" @tap.stop>
renjie's avatar
renjie committed
81
				<view class="img-box">
82
					<image class="bg" src="@/static/img/my/backgroundIcon01.png" mode="aspectFit"></image>
83 84 85
					<view class="coupon-box" v-if="couponTip">
						<view class="congra">恭喜您!</view>
						<view class="get-coupon">
86
							免费获得 2 寸照片
87 88 89 90
						</view>
						<image class="my-card" src="./static/album/myCard.png" mode="aspectFit"></image>
						<view class="address">(使用地址:长江索道南站观景台旁)</view>
					</view>
renjie's avatar
renjie committed
91
					<view class="rules" v-if="showUseRule">
renjie's avatar
renjie committed
92
						<view class="title">使用规则</view>
renjie's avatar
renjie committed
93
						<view class="block" v-for="item in rules" :key="item.ruleName">
94
							<text class="name">{{item.ruleName}}</text>
renjie's avatar
renjie committed
95
							<view class="content">
96 97 98 99
								<view class="small-font" v-for="rule in item.contents" :key="rule.value">
									<text class="dot">·</text>
									{{rule.value}}
								</view>
renjie's avatar
renjie committed
100 101 102
							</view>
						</view>
					</view>
103
					<u-icon class="close" name="close-circle" color="#fff" @click="closeMask"></u-icon>
renjie's avatar
renjie committed
104
				</view>
renjie's avatar
renjie committed
105
				<u-button type="primary" shape="circle" @click="closeMask">知道了</u-button>
renjie's avatar
renjie committed
106
			</view>
107
		</u-overlay>
108

109 110 111 112
	</view>
</template>

<script>
renjie's avatar
renjie committed
113 114 115
export default {
  data() {
    return {
116 117
      couponTip: false, //券领取提示
      showUseRule: false, //使用规则提示
renjie's avatar
renjie committed
118 119 120
      statusBarHeight: 0,
      capsule: 0,
      navHeight: 0,
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
      show: false, //是否显示首页
      isHaveCoupon: false, //是否有劵
      list: [{
        title: '精彩瞬间',
        count: '10W+',
        image: './static/album/wonderfulMoment.png',
        color: '#037EFF'
      },
      {
        title: '网红旅拍',
        count: '8W+',
        image: './static/album/travalphoto.png',
        color: '#826847'
      },
      {
        title: '抱枕DIY',
        count: '4W+',
        image: './static/album/pillow.png',
        color: '#1175B4'
      },
      {
        title: '明信片',
        count: '4W+',
        image: './static/album/postcard.png',
        color: '#3478DC'
      },
      {
        title: '旅游台历定制',
        count: '4W+',
        image: './static/album/deskCalender.png',
        color: '#1A9B45'
      },
      {
        title: '定制相册',
        count: '4W+',
        image: './static/album/customPic.png',
        color: '#D48D46'
      }
159
      ],
160 161 162
      rules: [], //使用规则
      options: {}, //路由参数
      couponPrice: '', //优惠券金额
163
      openid: '',
renjie's avatar
renjie committed
164
      userId: '',
renjie's avatar
renjie committed
165 166 167
    }
  },
  methods: {
renjie's avatar
renjie committed
168
    returnClick() {
169 170 171
      uni.navigateBack({
        delta: 1
      })
renjie's avatar
renjie committed
172
    },
173
    closeMask() { //---关闭遮罩
174
      this.couponTip = false
175 176
      this.showUseRule = false
    },
177 178 179 180 181 182 183
    jumpToScanFaceClick() { //---跳转扫脸页面
      this.$request('wechatUser/pdFace/checkScanFace', {
        openid: this.openid
      }).then(res => {
        if (res.code === '00') {
          const merchantId = this.options.merchantId || 'z0015605022691a5945bbe463141668c' // 默认长江索道
          if (res.data.isScanFace === 0) { //未扫脸
renjie's avatar
renjie committed
184
            uni.navigateTo({
renjie's avatar
renjie committed
185
              url: `./getPortrait?merchantId=${merchantId}`
renjie's avatar
renjie committed
186
            })
187
          } else if (res.data.isScanFace === 1) { //已扫脸
renjie's avatar
renjie committed
188 189
            const faceIds = JSON.stringify(res.data.faceIds)
            const companyId = this.options.companyId
renjie's avatar
renjie committed
190
            uni.navigateTo({
renjie's avatar
renjie committed
191
              url: `./myPhotoAlbum/myPhotoAlbum?faceIds=${faceIds}&companyId=${companyId}&merchantId=${merchantId}`
renjie's avatar
renjie committed
192
            })
renjie's avatar
renjie committed
193
          }
194 195 196 197 198 199
        } else {
          uni.showToast({
            title: res.message,
            icon: 'none'
          })
        }
200 201
      }).catch(err => {
        uni.showToast({
202 203
          title: err,
          icon: 'none'
204
        })
renjie's avatar
renjie committed
205 206
      })
    },
207
    jumptoVlog() { //---跳转到vlog页面
renjie's avatar
renjie committed
208
      uni.redirectTo({
209
        url: '/pages/vlog/vlogIndex/vlogIndex'
renjie's avatar
renjie committed
210
      })
renjie's avatar
renjie committed
211 212
    },
    jumpToClick(title) {
213
      if (title === '精彩瞬间' || title === '网红旅拍') {
renjie's avatar
renjie committed
214
        this.jumpToScanFaceClick()
renjie's avatar
renjie committed
215 216
      }
    },
217 218 219 220 221 222 223 224 225
    judgeWhether(url, data) { //---判断是否成功的封装函数
      return new Promise((resolve, reject) => {
        this.$request(url, data).then(res => {
          if (res.code === '00') {
            resolve(res.data)
          } else {
            reject(false)
          }
        }).catch(() => {
226 227
          reject(false)
        })
228
      })
229
    },
230
    async handleWhetherToVotePage() { //---判断是否跳转投票页面
renjie's avatar
renjie committed
231 232 233 234 235 236 237 238 239 240 241
      try{
        // 1.获取调查列表id
        const surveyQueryData = {
          pageCode: 'albumIndex', //默认前端写死
          channelId: this.options.channelId //游客扫码携带的channelId
        }
        const surveyList = await this.judgeWhether('scenic/market/findPageMarket', surveyQueryData)
				
        // 2.判断商店是否在做投票活动,获取模板
        let surveyIds
        let surveyResult = []
242

renjie's avatar
renjie committed
243 244 245 246 247 248 249 250 251 252
        if (surveyList.length) {
          surveyIds = surveyList.map(item => item.surveyId)
          surveyResult = await this.judgeWhether('scenic/albumConfig/getSurveyConfig', {
            surveyIds
          })
        }else {// 调查模板为空则直接展示首页
          this.show = true
          this.couponIsUse()
          return
        }
253

renjie's avatar
renjie committed
254 255
        // 3.判断用户是否已经投过票
        let voteObj = {} // 用户投票信息
256

renjie's avatar
renjie committed
257 258 259 260 261 262 263 264 265 266
        if (surveyResult.length) {
          const votedQueryData = {
            merchantId: surveyResult[0].merchantId,
            openid: uni.getStorageSync('openid')
          }
          voteObj = await this.judgeWhether('wechatUser/pdAlbum/checkVisitorSurvey', votedQueryData)
        }else {
          this.show = true
          this.couponIsUse()
          return
267
        }
268

renjie's avatar
renjie committed
269 270 271 272 273 274 275 276 277 278 279
        // 4.判断是否跳转投票页面
        if (voteObj.alreadySurvey === 0) { // 未投过票	
          uni.navigateTo({
            url: `./chooseFavorite?surveyConfig=${JSON.stringify(surveyResult)}`
          })
        } else if (voteObj.alreadySurvey === 1) { // 已投票
          this.show = true
          this.couponIsUse()
        }
			
      }catch(e){
280
        this.show = true
renjie's avatar
renjie committed
281 282
        this.couponIsUse()
        console.log(e)
283 284
      }
    },
285
    getCoupon() { //---获取优惠券
286 287 288 289 290 291 292 293
      var data = {
        pageCode: 'albumIndex',
        marketingStatus: 1,
        openid: this.openid,
        userId: this.userId
      }
      this.$request('scenic/market/findPageMarket', data).then((res) => {
        if (res.code === '00') {
renjie's avatar
renjie committed
294 295 296
          if(res.data.length) {
            this.couponTip = true
          }
297 298 299
        } else if(res.code === '04') {
          this.isHaveCoupon = false
        }else {
renjie's avatar
renjie committed
300
          uni.showToast({
301 302
					  title: res.message,
					  icon: 'none'
renjie's avatar
renjie committed
303 304
          })
        }
305
      })
306
    },
307 308 309 310 311
    couponIsUse() { //---判断是否有劵
      this.$request('wechatUser/myPage/getUserCouponList', {
        openid: this.openid
      }).then(res => {
        if (res.code === '00') {
renjie's avatar
renjie committed
312
          const albumCoupon = res.data.filter(item => item.useRange === 11 && item.couponStatus === 1) // 过滤 相册的劵
313

renjie's avatar
renjie committed
314
          if(!albumCoupon.length) return
315
					
renjie's avatar
renjie committed
316
          const firstItem = albumCoupon[0]
317
					
renjie's avatar
renjie committed
318 319
          this.isHaveCoupon = true
          this.couponPrice = firstItem.deductPrice
320
					
renjie's avatar
renjie committed
321 322 323
          // 处理使用规则数据结构
          this.handleDataStructure(firstItem.couponRule, '规则说明')
          this.handleDataStructure(firstItem.couponRuleRemind, '补充说明')
324 325 326 327 328 329
        } else {
          uni.showToast({
            title: res.message,
            icon: 'none'
          })
        }
renjie's avatar
renjie committed
330
      }).catch(err => {
331 332 333 334
        uni.showToast({
          title: err,
          icon: 'none'
        })
renjie's avatar
renjie committed
335 336
      })
    },
renjie's avatar
renjie committed
337 338 339
    handleDataStructure(str, title) { //---处理使用规则数据结构
      let ruleContents = str ? str.split(';') : []
      ruleContents = ruleContents.map(value => {
340 341 342
			  return {
			    value
			  }
renjie's avatar
renjie committed
343 344
      })
      this.rules.push({
345 346
			  ruleName: title,
			  contents: ruleContents
renjie's avatar
renjie committed
347 348
      })
    },
349
    recordDeviceInfo() { //---记录设备信息
renjie's avatar
renjie committed
350 351 352
      this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight // 状态栏高度
      this.capsule = uni.getMenuButtonBoundingClientRect() // 胶囊大小、位置数据
      this.navHeight = (this.capsule.top - this.statusBarHeight) * 2 + this.capsule.height // 导航栏高度
353
    }
renjie's avatar
renjie committed
354
  },
355
  onLoad(options) {
356
    this.$commonjs.getCompanyId(options)
357 358
    this.openid = uni.getStorageSync('openid')
    this.userId = uni.getStorageSync('userId')
renjie's avatar
renjie committed
359
    this.recordDeviceInfo()
360
    this.options = options
361
    if (this.options.template === 'true') { // 从模板选择页进入
362
      this.show = true
363
			this.couponTip = true
364 365
    }else if (this.options.channelId) { // 扫码进入本页
      this.handleWhetherToVotePage()
366
    } else if (this.options.index == 1) { // 从vlog首页进入
367
      this.show = true
renjie's avatar
renjie committed
368
      this.couponIsUse()
369
    }
370
		
371 372 373
    if (uni.getStorageSync('location')) return

    uni.getLocation({ //获取定位
374 375
      type: 'wgs84',
      success: res => {
376
        uni.setStorageSync('location', JSON.stringify(res))
377
      },
378
      fail() {
renjie's avatar
renjie committed
379
        console.log('获取经纬度失败')
380
      }
381 382
    })
  }
renjie's avatar
renjie committed
383
}
384 385
</script>

renjie's avatar
renjie committed
386 387 388 389 390 391
<style lang="scss" scoped>
	.big-box {
		position: relative;
		padding: 0 24rpx;
		background: linear-gradient(to right bottom, #c778f350, #66ddad50, #68d6de50);
		z-index: 0;
392

renjie's avatar
renjie committed
393 394 395 396
		&::after {
			content: '';
			width: 100%;
			height: 100%;
397
			position: absolute;
renjie's avatar
renjie committed
398 399 400 401 402
			bottom: 0;
			left: 0;
			z-index: -1;
			background: linear-gradient(to top, #f7f7f7, #f7f7f7 80%, transparent 100%);
		}
403

404
		/deep/.u-transition {
renjie's avatar
renjie committed
405 406 407
			display: flex;
			justify-content: center;
			align-items: center;
408
			transform: scale(1);
renjie's avatar
renjie committed
409
		}
410

411 412 413 414
		.coupon {
			position: fixed;
			right: -30rpx;
			bottom: 200rpx;
renjie's avatar
renjie committed
415 416
			width: 180rpx;
			height: 180rpx;
417

renjie's avatar
renjie committed
418 419 420 421
			.coupon-img {
				width: 100%;
				height: 100%;
			}
422

renjie's avatar
renjie committed
423 424 425 426 427 428 429
			.coupon-price {
				position: absolute;
				bottom: 64rpx;
				left: 50%;
				transform: translateX(-50%);
				font-size: 40rpx;
				font-weight: 700;
430
				color: #fff;
renjie's avatar
renjie committed
431
			}
432

renjie's avatar
renjie committed
433 434 435
			.r-symbol {
				font-size: 10rpx;
			}
436
		}
renjie's avatar
renjie committed
437
	}
438

renjie's avatar
renjie committed
439 440 441 442
	.nav-bar {
		font-size: 36rpx;
		font-weight: 700;
		z-index: 9;
443 444
	}

renjie's avatar
renjie committed
445 446
	.scroll-view {
		display: flex;
renjie's avatar
renjie committed
447 448 449 450
		width: calc(100% + 48rpx);
		position: relative;
		top: 0;
		left: -24rpx;
renjie's avatar
renjie committed
451
		overflow-x: auto;
renjie's avatar
renjie committed
452
		padding: 46rpx 0 0 24rpx;
renjie's avatar
renjie committed
453
		margin-bottom: 48rpx;
454

renjie's avatar
renjie committed
455 456 457
		&::-webkit-scrollbar {
			display: none;
		}
458

renjie's avatar
renjie committed
459 460 461 462 463 464
		.item {
			display: flex;
			flex-direction: column;
			align-items: center;
			margin-right: 24rpx;
		}
465

renjie's avatar
renjie committed
466 467 468 469 470
		.img {
			width: 200rpx;
			height: 136rpx;
			border-radius: 16rpx;
			margin-bottom: 16rpx;
471
			box-shadow: 0px 0px 8px 2px rgba(0, 0, 0, 0.12);
renjie's avatar
renjie committed
472 473
			overflow: hidden;
		}
474

renjie's avatar
renjie committed
475 476 477 478 479
		.title {
			font-size: 28rpx;
			font-weight: 700;
		}
	}
480

renjie's avatar
renjie committed
481 482 483 484 485 486
	.private-custom {
		.title {
			position: relative;
			margin-bottom: 24rpx;
			font-size: 32rpx;
			font-weight: 700;
487

renjie's avatar
renjie committed
488 489 490 491 492 493 494
			&::after {
				content: '';
				width: 128rpx;
				height: 44rpx;
				position: absolute;
				left: -8rpx;
				bottom: -24rpx;
renjie's avatar
renjie committed
495
				background: url('@/pages/album/static/album/private-custom.png') no-repeat;
renjie's avatar
renjie committed
496 497
			}
		}
498

renjie's avatar
renjie committed
499
		.demo-water {
renjie's avatar
renjie committed
500 501
			image {
				border-radius: 16rpx 16rpx 0 0;
renjie's avatar
renjie committed
502
				height: 458rpx;
renjie's avatar
renjie committed
503 504
				width: 100%;
			}
505

renjie's avatar
renjie committed
506 507 508 509 510
			/deep/.u-wrap,
			/deep/.u-lazy-item {
				broder-radius: 16rpx 16rpx 0 0 !important;
			}
		}
511

renjie's avatar
renjie committed
512 513
		.left.demo-water {
			margin-right: 14rpx;
514

renjie's avatar
renjie committed
515 516 517
			image {
				height: 400rpx;
			}
renjie's avatar
renjie committed
518
		}
519

renjie's avatar
renjie committed
520 521 522 523 524 525 526 527 528 529 530
		.info-box {
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			height: 170rpx;
			position: relative;
			top: -16rpx;
			padding: 16rpx;
			box-sizing: border-box;
			border-radius: 0 0 16rpx 16rpx;
			color: #fff;
531

renjie's avatar
renjie committed
532 533 534 535
			.item-title {
				font-size: 28rpx;
				font-weight: 700;
			}
536

renjie's avatar
renjie committed
537 538 539
			.slogan {
				font-size: 24rpx;
			}
540

renjie's avatar
renjie committed
541 542 543 544 545 546 547 548 549 550 551
			.img-btn {
				display: flex;
				justify-content: center;
				align-items: center;
				width: 160rpx;
				height: 40rpx;
				border-radius: 20rpx;
				background-color: #E1E1D9;
				color: #333;
				font-size: 22rpx;
			}
552

renjie's avatar
renjie committed
553 554 555
			.bottom {
				display: flex;
				justify-content: space-between;
556

renjie's avatar
renjie committed
557 558 559 560 561 562 563
				.count {
					font-size: 28rpx;
					color: #ececec;
				}
			}
		}
	}
564

renjie's avatar
renjie committed
565
	.mask {
566 567
		width: 504rpx;
		height: 720rpx;
568

renjie's avatar
renjie committed
569 570 571
		.img-box {
			position: relative;
			margin-bottom: 32rpx;
572 573
			width: 100%;
			height: 100%;
574

575
			/deep/.u-icon {
renjie's avatar
renjie committed
576
				position: absolute;
577
				top: -64rpx;
renjie's avatar
renjie committed
578
				right: 24rpx;
579
				font-size: 40rpx;
580

renjie's avatar
renjie committed
581 582 583
				&::after {
					position: absolute;
					content: '';
584
					top: 34rpx;
renjie's avatar
renjie committed
585 586 587 588
					left: 50%;
					transform: translateX(-50%);
					width: 0;
					height: 32rpx;
589
					border-left: 1px dotted #fff;
renjie's avatar
renjie committed
590 591
				}
			}
592

593
			.bg {
594
				position: absolute;
595 596 597 598 599 600
				left: 0;
				top: 0;
				width: 100%;
				height: 100%;
				z-index: -1;
			}
601

602 603 604
			.my-card {
				width: 85%;
				height: 340rpx;
605
			}
renjie's avatar
renjie committed
606
		}
607

608
		.coupon-box,
609 610 611 612 613 614
		.rules {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 66rpx 0 24rpx 0;
			height: 100%;
615
			overflow-y: auto;
616
		}
617

618 619 620
		.coupon-box {
			justify-content: space-between;
			font-size: 36rpx;
621

622 623 624
			.congra {
				font-weight: 700;
			}
625

626 627 628
			.address {
				font-size: 24rpx;
			}
629

630 631 632 633
			.address {
				font-weight: 700;
			}
		}
634

635 636
		.rules {
			padding: 50rpx 32rpx 24rpx;
637

638 639 640 641 642
			.title {
				font-size: 36rpx;
				font-weight: 700;
				margin-bottom: 48rpx;
			}
643

644 645 646
			.block {
				font-size: 32rpx;
				align-self: flex-start;
647

648 649 650 651 652 653 654 655 656
				.name {
					display: inline-block;
					padding: 4rpx 16rpx;
					margin-bottom: 28rpx;
					border-radius: 4rpx;
					font-size: 24rpx;
					background-color: #000;
					color: #fff;
				}
657

658 659 660 661
				.small-font {
					display: flex;
					font-size: 20rpx;
				}
662

663 664 665
				.small-font:not(:last-child) {
					margin-bottom: 16rpx;
				}
666

667 668 669 670
				.dot {
					margin-right: 10rpx;
				}
			}
671

672 673 674
			.block:not(:last-child) {
				margin-bottom: 32rpx;
			}
renjie's avatar
renjie committed
675
		}
676

renjie's avatar
renjie committed
677
		/deep/.u-btn {
renjie's avatar
renjie committed
678
			width: 304rpx;
renjie's avatar
renjie committed
679
		}
renjie's avatar
renjie committed
680
	}
681
</style>