Commit 11bf8463 authored by 潘永坪's avatar 潘永坪

产品选择页面开发

parent 995c4ad1
export default{
getCurrentPageUrl(){//---获取当前页面url
let pages = getCurrentPages() //获取加载的页面
let currentPage = pages[pages.length-1] //获取当前页面的对象
let url = currentPage.route //当前页面url
let options = currentPage.options //如果要获取url中所带的参数可
let queryTotal=""
for (let key in options){
queryTotal+="&"+key+"="+options[key]
}
queryTotal=queryTotal.substr(1)
let pageUrl=url+"?"+queryTotal//请求的全路径
return pageUrl
},
today:function(){//默认当天
var now = new Date();
var day = ("0" + now.getDate()).slice(-2);
var month = ("0" + (now.getMonth() + 1)).slice(-2);
var today = now.getFullYear()+"-"+(month)+"-"+(day) ;
return today
},
todayTime:function(){
var now = new Date();
var hour = now.getHours()<10?'0'+now.getHours():now.getHours()
var minutes = now.getMinutes()<10?'0'+now.getMinutes():now.getMinutes()
var seconds = now.getSeconds()<10?'0'+now.getSeconds():now.getSeconds()
var time = hour+":"+minutes+":"+seconds
return time
},
dateDifference:function(start,end){//结束日期与开始日期相差几天
var strSeparator = "-";
var oDate1= start.split(strSeparator);
var oDate2= end.split(strSeparator);
var strDateS = new Date(oDate1[0], oDate1[1]-1, oDate1[2]);
var strDateE = new Date(oDate2[0], oDate2[1]-1, oDate2[2]);
getCurrentPageUrl(){//---获取当前页面url
let pages = getCurrentPages() //获取加载的页面
let currentPage = pages[pages.length-1] //获取当前页面的对象
let url = currentPage.route //当前页面url
let options = currentPage.options //如果要获取url中所带的参数可
let queryTotal=''
for (let key in options){
queryTotal+='&'+key+'='+options[key]
}
queryTotal=queryTotal.substr(1)
let pageUrl=url+'?'+queryTotal//请求的全路径
return pageUrl
},
today:function(){//默认当天
var now = new Date()
var day = ('0' + now.getDate()).slice(-2)
var month = ('0' + (now.getMonth() + 1)).slice(-2)
var today = now.getFullYear()+'-'+(month)+'-'+(day)
return today
},
todayTime:function(){
var now = new Date()
var hour = now.getHours()<10?'0'+now.getHours():now.getHours()
var minutes = now.getMinutes()<10?'0'+now.getMinutes():now.getMinutes()
var seconds = now.getSeconds()<10?'0'+now.getSeconds():now.getSeconds()
var time = hour+':'+minutes+':'+seconds
return time
},
dateDifference:function(start,end){//结束日期与开始日期相差几天
var strSeparator = '-'
var oDate1= start.split(strSeparator)
var oDate2= end.split(strSeparator)
var strDateS = new Date(oDate1[0], oDate1[1]-1, oDate1[2])
var strDateE = new Date(oDate2[0], oDate2[1]-1, oDate2[2])
var iDays = parseInt((strDateE- strDateS) / 1000 / 60 / 60 /24)
return iDays
}
},
changeTime:function(option) {//把时间格式转化成数字
// currentTime当前时间,假设是 2019-7-2 19:03
var currentTime = option
var reg = new RegExp('-','g')//去掉时间里面的-
var a = currentTime.replace(reg,'')
var regs = new RegExp(' ','g')//去掉时间里面的空格
var b = a.replace(regs,'')
var regss = new RegExp(':','g')//去掉时间里面的:冒号
var c = b.replace(regss,'')
return c
}
}
//调用方法时--this.$commonjs.today()
\ No newline at end of file
<template>
<u-popup v-model="showPop" mode="bottom" border-radius="14" closeable height="85%">
<view class="son-wrap">
<view class="head">
<view class="head1">
购买须知
</view>
<view class="head2">
{{buyKnowData.name}}
</view>
<view class="head3">
挂牌价:¥{{buyKnowData.originalPrice}}
</view>
</view>
<view class="middle">
<view class="middle-list" v-for="(item,a) of buyKnowData.productTitleResVos" :key="a">
<view class="middle-title">
{{item.title}}
</view>
<view class="middle-content" v-for="(items,b) of item.productChildTitleData" :key="b">
<text>
{{items.title}}
</text>
<view>
<!--<text>随买随用</text>-->
<text v-for="(itemss,c) of items.contentList" :key="c" class="content-child">
{{itemss.content}}
</text>
</view>
</view>
</view>
</view>
<view class="bottom">
<text class="bottom-left">
¥ <text>{{buyKnowData.sellingPrice}}</text>
</text>
<view class="bottom-right">
<text class="btn" @click="showPop=false">
去预订
</text>
</view>
</view>
</view>
</u-popup>
</template>
<script>
export default {
props: ['buyKnowData'],
data() {
return {
showPop: false, //控制弹窗显示隐藏
}
},
methods: {
}
}
</script>
<style scoped="scoped">
.son-wrap{
font-size: 24rpx;
position: relative;
}
.head {
padding: 100rpx 24rpx 0 24rpx;
}
.head1{
text-align: center;
font-size: 32rpx;
font-weight: bold;
text-align: center;
padding: 30rpx 0;
position:fixed;
top: 0;
width: 100%;
background: #fff;
z-index: 1;
}
.head2{
font-weight: bolder;
font-size: 32rpx;
line-height: 40rpx;
}
.head3{
font-size: 28rpx;
margin-top: 20rpx;
color: #666666;
border-bottom: 1px solid #e6e6e6;
padding-bottom: 30rpx;
}
.middle {
padding-bottom: 100rpx;
font-size: 28rpx;
}
.middle-list {
margin: 30rpx 24rpx;
padding-bottom: 24rpx;
border-bottom: 1px solid #E6E6E6;
}
.middle-title{
font-size: 32rpx;
font-weight: bold;
}
.middle-content {
display: flex;
margin-top: 30rpx;
position: relative;
}
.middle-content>text {
color: #666666;
margin-right: 30rpx;
width: 120rpx;
display: inline-block;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
flex-shrink: 0;
font-size: 26rpx;
position: relative;
}
.middle-content view {
display: flex;
flex-direction: column;
justify-content: center;
}
.bottom {
display: flex;
justify-content: space-between;
padding: 0 24rpx;
height: 100rpx;
align-items: center;
position: fixed;
bottom: 0;
width: 100%;
z-index: 9;
background: #FFFFFF;
box-sizing: border-box;
}
.bottom-left{
color: #f9690e;
}
.bottom-left text {
font-size: 36rpx;
font-weight: bolder;
}
.bottom view {
display: flex;
align-items: center;
}
.btn{
padding: 16rpx 48rpx;
border-radius: 20rpx;
font-size: 32rpx;
}
</style>
<template>
<!-- 客服 -->
<u-popup v-model="showPop" mode="bottom" border-radius="14" closeable >
<view class="wrap">
<u-popup v-model="showPop" mode="bottom" border-radius="14" closeable height="85%">
<view class="son-wrap">
<view class="title">
客服电话
</view>
......@@ -40,6 +40,9 @@ export default{
</script>
<style scoped lang="scss">
.son-wrap{
position: relative;
}
.title{
text-align: center;
font-size: 32rpx;
......@@ -62,26 +65,5 @@ export default{
align-items: center;
justify-content: space-between;
}
.wrap{
overflow-y: auto;
position: relative;
}
@media only screen and (max-height: 900px) {
.wrap{
max-height: 750px;
}
}
@media only screen and (max-height: 750px) {
.wrap{
max-height: 600px;
}
}
@media only screen and (max-height: 600px) {
.wrap{
max-height: 500px;
}
}
</style>
\ No newline at end of file
<template>
<!-- 商家详情弹窗 -->
<u-popup v-model="showPop" mode="bottom" border-radius="14" closeable >
<view class="buy-wrap">
<u-popup v-model="showPop" mode="bottom" border-radius="14" closeable height="85%">
<view class="son-wrap">
<view class="head">
{{detailData.name}}
</view>
......@@ -155,7 +155,10 @@ export default {
}
</script>
<style scoped="scoped">
<style scoped="scoped" lang="scss">
.son-wrap{
position: relative;
}
.head{
text-align: center;
font-size: 32rpx;
......@@ -228,26 +231,4 @@ export default {
white-space: nowrap;
margin-right: 10rpx;
}
.buy-wrap{
overflow-y: auto;
position: relative;
}
@media only screen and (max-height: 900px) {
.buy-wrap{
max-height: 750px;
}
}
@media only screen and (max-height: 750px) {
.buy-wrap{
max-height: 600px;
}
}
@media only screen and (max-height: 600px) {
.buy-wrap{
max-height: 500px;
}
}
</style>
\ No newline at end of file
......@@ -41,4 +41,27 @@ Number.prototype.toFixed=function (d) {
return (pm+s).replace(/\.$/,'')
}return this+''
}
// 时间格式化
Date.prototype.Format = function(fmt) {
var o = {
'M+': this.getMonth() + 1, // 月份
'd+': this.getDate(), // 日
'h+': this.getHours(), // 小时
'm+': this.getMinutes(), // 分
's+': this.getSeconds(), // 秒
'q+': Math.floor((this.getMonth() + 3) / 3), // 季度
S: this.getMilliseconds() // 毫秒
}
if (/(y+)/.test(fmt))
fmt = fmt.replace(
RegExp.$1,
(this.getFullYear() + '').substr(4 - RegExp.$1.length)
)
for (var k in o)
if (new RegExp('(' + k + ')').test(fmt))
fmt = fmt.replace(
RegExp.$1,
RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)
)
return fmt
} //调用new Date().Format("yyyy-MM-dd hh:mm");
<template>
<view class="wrap">
<view class="banner">
<u-swiper :list="imgList" name='url' mode="number" height="350"></u-swiper>
<u-swiper :list="imgList" name='url' mode="number" height="420" indicator-pos="topRight"></u-swiper>
</view>
<view class="middle">
<view class="tabbar">
......@@ -26,44 +26,57 @@
距您{{item.distance?parseFloat((item.distance/1000).toFixed(2)):0}}km
</view>
</view>
<label v-for="(items,a) in item.productList" :key='a'>
<view class="product">
<view class="product-left">
<checkbox class="blue" />
</view>
<view class="product-right">
<view class="product-name">
<text>{{items.name}}</text>
<!-- <text class="product-status">已售罄</text> -->
<checkbox-group @change="checkboxChange">
<label v-for="(items,a) in item.productListCopy" :key='a'>
<view class="product" :class="{'on':items.ifChoose}">
<view class="product-left">
<checkbox class="blue" :disabled="items.status==2" :value="JSON.stringify(items)" />
</view>
<view class="product-price">
<view style="font-size: 24rpx;">
<text class="product-rule" v-if="items.productRefundRuleVo">
<text v-if="items.productRefundRuleVo.refundType==0">不可退</text>
<text v-if="items.productRefundRuleVo.refundType==1">规定时间退</text>
<text v-if="items.productRefundRuleVo.refundType==2">随时可退</text>
</text>
<text class="product-rule">
无需取票
</text>
<text>购买须知</text>
<u-icon name="arrow-right"></u-icon>
<view class="product-right">
<view class="product-name">
<text>{{items.name}}</text>
<text class="product-status" v-if='items.status==2'>{{items.statusName}}</text>
</view>
<view>
<text class="product-orange">
¥{{items.originalPrice}}
</text>
<text class="product-sell">
<text style="font-size: 28rpx;">¥</text>{{items.sellingPrice}}
</text>
<view class="product-price">
<view style="font-size: 24rpx;">
<text class="product-rule" v-if="items.productRefundRuleVo">
<text v-if="items.productRefundRuleVo.refundType==0">不可退</text>
<text v-if="items.productRefundRuleVo.refundType==1">规定时间退</text>
<text v-if="items.productRefundRuleVo.refundType==2">随时可退</text>
</text>
<text class="product-rule">
无需取票
</text>
<text @click="showBuyKnow(items)">购买须知</text>
<u-icon name="arrow-right"></u-icon>
</view>
<view>
<text class="product-orange">
¥{{items.originalPrice}}
</text>
<text class="product-sell">
<text style="font-size: 28rpx;">¥</text>{{items.sellingPrice}}
</text>
</view>
</view>
</view>
</view>
</label>
</checkbox-group>
<view class="product-more" v-if="index>0&&item.productList.length>2" >
<view v-if="item.productListCopy.length!=item.productList.length" @click="showMoreProduct(item)">
更多
<u-icon name='arrow-down'></u-icon>
</view>
<view v-else @click="retractProduct(item)">
收起
<u-icon name='arrow-up'></u-icon>
</view>
</label>
</view>
</view>
<u-empty text="空空如也..." mode="list" v-if="scenicList.length==0"></u-empty>
</scroll-view>
......@@ -87,18 +100,18 @@
客服
</view>
<view class="bottom-middle">
<view class="bottom-more">
<view class="bottom-more" v-show="chooseProduct.length>0">
组合购更优惠
<text class="bottom-three"></text>
</view>
<view class="bottom-detail">
<view class="bottom-detail" :style="{'top':chooseProduct.length>0?'-28rpx':'0'}">
<text>
明细
</text>
<u-icon name='arrow-up' size='32' style="margin: 0 8rpx;"></u-icon>
<text class="bottom-number">
1
{{chooseProduct.length}}
</text>
</view>
</view>
......@@ -108,14 +121,27 @@
</view>
<!-- 客服组件 -->
<customer :scenicList='scenicList' ref='customer'></customer>
<!-- 购买须知 -->
<buyKnow :buyKnowData='buyKnowData' ref='buyKnow'></buyKnow>
<!-- 模态框 -->
<u-modal
v-model="showModal"
@confirm="chooseConfirm"
@cancel='chooseCancel'
title='提示'
content='该产品不支持多选'
show-cancel-button=true >
</u-modal>
</view>
</template>
<script>
import customer from '@/components/customer.vue'//客服
import buyKnow from '@/components/buyKnow.vue'//购买须知
export default {
components:{
customer
customer,
buyKnow
},
data() {
return {
......@@ -125,8 +151,38 @@ export default {
imgList:[],//图片列表
scenicList:[],//景区数据
showDistance:false,//定位成功显示距离
buyKnowData:'',//购买须知数据
chooseProduct:[],//选中的产品
showModal:false,//是否显示模态框
}
},
watch: {
//选中产品的数量变化
chooseProduct: {
handler(newValue, oldValue){
// this.originalTotal=0
// this.sellTotal=0
// this.chooseProduct.forEach((item)=>{//通过选中的产品计算价格
// this.originalTotal+=item.originalPrice
// this.sellTotal+=item.sellingPrice
// })
//当选中产品时
if(newValue.length>oldValue.length){
let item=newValue[newValue.length-1]
if(item.isMoreBuy!==0){
//不支持多产品购买时,删除该景区的其他产品
this.showModal=true
}else{
//支持多产品购买时,删除该景区其他产品不支持多产品购买的产品
}
}
},
deep:true,
immediate: false
},
},
onLoad(option){
let token = uni.getStorageSync('token')
if(token){
......@@ -160,6 +216,83 @@ export default {
showCustomer(){
this.$refs.customer.showPop=true
},
//---展示购买须知
showBuyKnow(data){
this.buyKnowData=data
this.$refs.buyKnow.showPop=true
},
//---展示更多产品
showMoreProduct(item){
item.productListCopy=item.productList
this.$forceUpdate()
},
//---收起产品
retractProduct(item){
item.productListCopy=item.productList.slice(0,2)
this.$forceUpdate()
},
//---多选框变化
checkboxChange(e){
let value=e.detail.value
let arr=[]
value.forEach(item=>{
arr.push(JSON.parse(item))
})
this.chooseProduct=arr
//判断是否选中产品,选中产品的背景颜色需要变化
this.scenicList.forEach(item=>{
item.productList.forEach(item2=>{
item2.ifChoose=false
this.chooseProduct.forEach(item3=>{
if(item2.id==item3.id){
item2.ifChoose=true
}
})
})
})
},
//---不支持多选产品弹窗,选择确定事件
chooseConfirm(){
this.chooseProduct.forEach((item2,index)=>{
//删除选中产品以外的其他所有产品
if(this.chooseMerchantId==item2.merchantId&&JSON.stringify(item2)!=JSON.stringify(this.chooseMerchantProduct)){
delete this.chooseProduct[index]
//找到删除下标,然后找到对应的多选框不让选中
this.scenicList.forEach((item3,x)=>{
item3.productList.forEach((item4,y)=>{
if(JSON.stringify(item2)==JSON.stringify(item4)){
document.querySelectorAll('.list')[x].children[1].children[y].children[0].children[0].children[0].checked=false
}
})
})
}
})
this.chooseProduct=this.chooseProduct.filter(function (val) {
return val
})
this.showConfig=false
},
//---不支持多选产品弹窗,选择取消事件
chooseCancel(){
//删除选中产品
this.chooseProduct.forEach((item2,index)=>{
if(JSON.stringify(item2)===JSON.stringify(this.chooseMerchantProduct)){
delete this.chooseProduct[index]
//找到删除下标,然后找到对应的多选框不让选中
this.scenicList.forEach((item3,x)=>{
item3.productList.forEach((item4,y)=>{
if(JSON.stringify(item2)==JSON.stringify(item4)){
document.querySelectorAll('.list')[x].children[1].children[y].children[0].children[0].children[0].checked=false
}
})
})
}
})
this.chooseProduct=this.chooseProduct.filter(function (val) {
return val
})
this.showConfig=false
},
//---商品列表
initList(latitude,longitude) {
let data = {
......@@ -171,10 +304,36 @@ export default {
if (res.code == '00') {
this.scenicList = res.data.merchantList
this.scenicList.forEach((item,index)=>{
//获取当前景区图片,把当前景区放在第一位
if(item.id==this.merchantId){
this.imgList=item.imgList
console.log(this.imgList)
this.scenicList.splice(index,1)
this.scenicList.unshift(item)
item.productListCopy=item.productList
}else{
item.productListCopy=item.productList.slice(0,2)
}
//预订时间为当天时,当前时间大于最早预订时间显示未开售,当前时间大于最晚预订时间显示已售罄
let times = new Date().Format('hh:mm:ss')
let timeNumber = parseInt(this.$commonjs.changeTime(times)) //将当前时间转化为数字
item.productList.forEach(item2=>{
item2.timeNumber1 = parseInt(this.$commonjs.changeTime(item2.earlyBookTime))
item2.timeNumber2 = parseInt(this.$commonjs.changeTime(item2.bookTime))
if(item2.aheadBookDays==0){
if(item2.status==2){
item2.statusName='已售罄'
}else{
if(timeNumber<item2.timeNumber1){
item2.status=2
item2.statusName='未开售'
}
if(timeNumber>item2.timeNumber2){
item2.status=2
item2.statusName='已售罄'
}
}
}
})
})
} else {
uni.showToast({
......@@ -198,7 +357,7 @@ export default {
.middle{
position: relative;
top: -40rpx;
padding: 0 24rpx;
padding: 0 24rpx 60rpx 24rpx;
display: flex;
flex-direction: column;
flex: 1;
......@@ -318,7 +477,10 @@ export default {
font-weight: bold;
margin-left: 10rpx;
}
.product-more{
padding: 10rpx;
text-align: center;
}
.bottom{
position: fixed;
......@@ -359,7 +521,6 @@ export default {
}
.bottom-detail{
position: relative;
top: -28rpx;
text-align: center;
}
.bottom-number{
......
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