Commit 0bb0f389 authored by renjie's avatar renjie

修改相册首页进入逻辑

parent 7f8864fd
<template> <template>
<view class="big-box" :style="{'padding-top': statusBarHeight + 'px'}"> <view class="big-box" :style="{'padding-top': statusBarHeight + 'px'}" v-show="show">
<view class="nav-bar" :style="{'top': statusBarHeight + 'px', 'height': navHeight + 'px','line-height': navHeight + 'px'}"> <view class="nav-bar" :style="{'top': statusBarHeight + 'px', 'height': navHeight + 'px','line-height': navHeight + 'px'}">
摄影/旅拍 摄影/旅拍
</view> </view>
...@@ -92,6 +92,7 @@ export default { ...@@ -92,6 +92,7 @@ export default {
statusBarHeight: 0, statusBarHeight: 0,
capsule: 0, capsule: 0,
navHeight: 0, navHeight: 0,
show: false,//是否显示首页
list: [ list: [
{ {
title: '精彩瞬间', title: '精彩瞬间',
...@@ -129,14 +130,15 @@ export default { ...@@ -129,14 +130,15 @@ export default {
image: './static/album/customPic.png', image: './static/album/customPic.png',
color: '#D48D46' color: '#D48D46'
} }
] ],
options: {}//路由参数
} }
}, },
methods: { methods: {
jumpToScanFaceClick() {//---跳转扫脸页面 jumpToScanFaceClick() {//---跳转扫脸页面
const openid = uni.getStorageSync('openid') const openid = uni.getStorageSync('openid')
this.$request('wechatUser/pdFace/checkScanFace',{openid}).then(res => {//创建任务 this.$request('wechatUser/pdFace/checkScanFace',{openid}).then(res => {
if (res.code === '00') { if (res.code === '00') {
if(res.data.isScanFace === 0) {//未扫脸 if(res.data.isScanFace === 0) {//未扫脸
uni.navigateTo({ uni.navigateTo({
...@@ -156,7 +158,6 @@ export default { ...@@ -156,7 +158,6 @@ export default {
}) })
}, },
jumptoVlog() {//---跳转到vlog页面 jumptoVlog() {//---跳转到vlog页面
console.log('fdsa')
uni.redirectTo({ uni.redirectTo({
url: '/pages/vlog/vlogIndex/vlogIndex' url: '/pages/vlog/vlogIndex/vlogIndex'
}) })
...@@ -166,15 +167,88 @@ export default { ...@@ -166,15 +167,88 @@ export default {
this.jumpToScanFaceClick() this.jumpToScanFaceClick()
} }
}, },
judgeWhether(url, data) {//---判断是否成功的封装函数
return new Promise((resolve, reject) => {
this.$request(url, data).then(res => {
if (res.code === '00') {
resolve(res.data)
}else{
reject(false)
}
})
})
},
async handleWhetherToVotePage() {//---判断是否跳转投票页面
// 1.获取调查列表
const surveyQueryData = {
pageCode: 'albumIndex',//默认前端写死
channelId: this.options.channelId//游客扫码携带的channelId或者是胖丁登录时的公司id
}
const surveyList = await this.judgeWhether('scenic/market/findPageMarket', surveyQueryData)
// 2.判断商店是否在做投票活动
let surveyIds
let surveyResult = []
if(surveyList.length) {
surveyIds = surveyList.map(item => item.surveyId)
surveyResult = await this.judgeWhether('scenic/albumConfig/getSurveyConfig', { surveyIds })
}
// 3.判断用户是否已经投过票
let voteObj = {}// 用户投票信息
if(surveyResult.length) {
// 默认保存第一个商店id到缓存
uni.setStorageSync('merchantId', surveyResult[0].merchantId)
const votedQueryData = {
merchantId: surveyResult[0].merchantId,
openid: uni.getStorageSync('openid')
}
voteObj = await this.judgeWhether('wechatUser/pdAlbum/checkVisitorSurvey', votedQueryData)
}
// 4.判断是否跳转投票页面
if(voteObj.alreadySurvey === 0) {// 未投过票
uni.navigateTo({
url: `./chooseFavorite?surveyConfig=${JSON.stringify(surveyResult)}`
})
}else if(voteObj.alreadySurvey === 1) {// 已投票
this.show = true
}
},
recordDeviceInfo() {//---记录设备信息 recordDeviceInfo() {//---记录设备信息
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight // 状态栏高度 this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight // 状态栏高度
this.capsule = uni.getMenuButtonBoundingClientRect() // 胶囊大小、位置数据 this.capsule = uni.getMenuButtonBoundingClientRect() // 胶囊大小、位置数据
this.navHeight = (this.capsule.top - this.statusBarHeight) * 2 + this.capsule.height // 导航栏高度 this.navHeight = (this.capsule.top - this.statusBarHeight) * 2 + this.capsule.height // 导航栏高度
} }
}, },
onLoad(option) { onLoad(options) {
if(option.tip === 'true') this.showtip = true
this.recordDeviceInfo() this.recordDeviceInfo()
this.options = options
if(this.options.tip === 'true') {
this.show = true
this.showtip = true
}else {
this.handleWhetherToVotePage()
}
if(uni.getStorageSync('location')) return
uni.getLocation({//获取定位
type: 'wgs84',
success: res => {
uni.setStorageSync('location', JSON.stringify(res))
},
fail() {
uni.showToast({
title: '获取经纬度失败',
icon: 'none'
})
}
})
} }
} }
</script> </script>
......
<template> <template>
<view class="big-box" :style="{'padding-top': statusBarHeight + 'px'}"> <view class="big-box" :style="{'padding-top': statusBarHeight + 'px'}">
<view class="nav-bar" :style="{'height': navHeight + 'px'}"> <view class="nav-bar" :style="{'height': navHeight + 'px'}">
<picker mode="selector" @change="companyChage" :value="index" :range="companyArr" range-key="name"> <picker mode="selector" @change="companyChage" :value="index" :range="companyArr" range-key="merchantName">
<view class="company">{{companyArr[index] ? companyArr[index].name : '请选择公司'}}</view> <view class="company">{{companyArr[index] ? companyArr[index].merchantName : '请选择公司'}}</view>
</picker> </picker>
<u-icon name="arrow-down"></u-icon> <u-icon name="arrow-down"></u-icon>
</view> </view>
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
<image class="start" src="./static/album/star.png"></image> <image class="start" src="./static/album/star.png"></image>
</view> </view>
<view class="img-box"> <view class="img-box">
<view class="item" @click="imageChange(item)" v-for="(item, index) in imgArr" :key="item.id"> <view class="item" @click="imageChange(item)" v-for="(item, index) in imgArr" :key="item.templateId">
<image class="img" :src="item.url" mode="aspectFill"></image> <image class="img" :src="item.templateUrl" mode="aspectFill"></image>
<u-checkbox class="checkbox" v-model="item.value" shape="circle"></u-checkbox> <u-checkbox class="checkbox" v-model="item.value" shape="circle"></u-checkbox>
</view> </view>
</view> </view>
...@@ -39,20 +39,27 @@ export default { ...@@ -39,20 +39,27 @@ export default {
index: 0,// 选中的公司索引-默认选中第一个 index: 0,// 选中的公司索引-默认选中第一个
companyArr: [],// 公司枚举 companyArr: [],// 公司枚举
imgArr: [],//图片 imgArr: [],//图片
value: true,
location: {},//位置信息
option: {},//路由传参 option: {},//路由传参
} }
}, },
methods: { methods: {
saveClick() {//---提交 saveClick() {//---提交
const selectedPic = this.imgArr.filter(item => item.value) const templateIds = this.imgArr.map(item => {
if(item.value) return item.templateId
}) || []
if(!templateIds.length) return uni.showToast({
title: '您还没有选择模板哟!',
icon: 'none'
})
const data = { const data = {
id: selectedPic[0].id,// 图片id merchantId: this.companyArr[this.index].merchantId,//商店id
merchantId: selectedPic[0].merchantId openid: uni.getStorageSync('openid'), //openid
templateIds//模板Id
} }
uni.setStorageSync('merchantId', data.merchantId) uni.setStorageSync('merchantId', data.merchantId)
this.$request('scenic/V2merchant/submitChoose', data).then(res => {//创建任务 this.$request('wechatUser/pdAlbum/saveVisitorSurvey', data).then(res => {
if (res.code === '00') { if (res.code === '00') {
uni.showToast({ uni.showToast({
title: '提交成功', title: '提交成功',
...@@ -71,99 +78,30 @@ export default { ...@@ -71,99 +78,30 @@ export default {
}, },
companyChage(e) {//---公司变化 companyChage(e) {//---公司变化
this.index = Number(e.detail.value) this.index = Number(e.detail.value)
const merchantId = this.companyArr[this.index].id this.imgArr = this.companyArr[this.index].templateDetailList
this.getPic(merchantId)
}, },
imageChange(item) {//---图片选择 imageChange(item) {//---图片选择
this.imgArr.forEach(item => item.value = false) this.$set(item, 'value', !item.value)
item.value = true this.$forceUpdate()
// item.value = !item.value
}, },
recordDeviceInfo() {//---记录设备信息 recordDeviceInfo() {//---记录设备信息
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight // 状态栏高度 this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight // 状态栏高度
this.capsule = uni.getMenuButtonBoundingClientRect() // 胶囊大小、位置数据 this.capsule = uni.getMenuButtonBoundingClientRect() // 胶囊大小、位置数据
this.navHeight = (this.capsule.top - this.statusBarHeight) * 2 + this.capsule.height // 导航栏高度 this.navHeight = (this.capsule.top - this.statusBarHeight) * 2 + this.capsule.height // 导航栏高度
},
getCompany(nearbyId) {//---获取景区列表
this.$request('scenic/newMerchant/findAllMerchant').then(res => {//创建任务
if (res.code === '00') {
if(!res.data.length) return
const id = this.option.merchantId || nearbyId
let index = res.data.findIndex(item => item.id === id)
this.index = index === -1 ? 0 : index
this.companyArr = res.data
this.getPic(this.companyArr[this.index].id)
}else{
uni.showToast({
title: res.message,
icon: 'none'
})
}
})
},
getPic(merchantId) {//---获取景区图片
this.$request('scenic/V2merchant/getImgList',{ merchantId }).then(res => {//创建任务
if (res.code === '00') {
res.data.forEach(item => item.value = false)
this.imgArr = res.data
}else{
uni.showToast({
title: res.message,
icon: 'none'
})
}
})
},
getNearByCompany() {//---获取最近的景区
const data = {
merchantType: 1,
userlatitude: this.location.latitude,//纬度
userlongitude: this.location.longitude//经度
}
this.$request('scenic/newMerchant/findAllMerchant', data).then(res => {//创建任务
if (res.code === '00') {
if(!res.data.length) {
this.getCompany()
return uni.showToast({
title: '获取最近景点失败',
icon: 'none'
})
}
this.getCompany(res.data[0].id)
}else{
uni.showToast({
title: res.message,
icon: 'none'
})
}
})
} }
}, },
onLoad(option) { onLoad(option) {
this.option = option
this.recordDeviceInfo() this.recordDeviceInfo()
uni.getLocation({//获取定位 this.option = option
type: 'wgs84',
success: res => {
this.location = res
uni.setStorageSync('location', JSON.stringify(res))
if(this.option.merchantId) {//扫码进入则直接加载景区列表,默认显示传入的景区 this.companyArr = JSON.parse(option.surveyConfig)
this.getCompany() const imgArr = []
}else {//否则获取并显示距离最近的景点 this.companyArr.forEach(item => {
this.getNearByCompany() imgArr.push(...item.templateDetailList)
}
},
fail() {
this.getCompany()
uni.showToast({
title: '获取经纬度失败',
icon: 'none'
})
}
}) })
imgArr.forEach(item => this.$set(item, 'value', false))
this.imgArr = this.companyArr[0].templateDetailList
} }
} }
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment