Commit 1cbb0502ee42f445b0f8cb5358f25785aa114982

Authored by vking
1 parent f4a4be08

电话弹框

// components/actionSheet/phone.js
import util from '../../utils/util';
Component({
/**
* 组件的属性列表
*/
properties: {
//items: Array,//电话列表
//seller:Object,//商家信息
hasTip:{
type:Boolean,
value:true,
},
},
/**
* 组件的初始数据
*/
data: {
actionSheetHidden: true,
hasOnlineReserve:false,
},
/**
* 组件的方法列表
*/
methods: {
show(seller){
this.seller=seller
let seller_tel = this.seller.seller_tel;
if(this.seller.is_online_reserve==1 && this.seller.is_tele==0){
//开通在线预订,但无商家接单设备,拨打运营电话
seller_tel = ['400-000-9690']
}else{
if (seller_tel.length < 1) {
seller_tel = [this.seller.phone]
}
}
this.setData({
actionSheetHidden: false,
items:seller_tel,
hasOnlineReserve:this.seller.is_online_reserve==1 && this.seller.is_tele==1
})
},
hide(){
this.setData({
actionSheetHidden: true,
})
},
bindItemTap(e){
this.hide();
let index=util.attr(e,'index')
if(index=='reserve'){//跳转到预订页
let pages=getCurrentPages();
let p=pages[pages.length-1];
if(p.route=='pages/reserve/detail'){
p.setData({
activeTab:'reserve'
})
}else{
let url=util.http_build_query({id:this.seller.id,activeTab:'reserve'},'/pages/reserve/detail')
wx.navigateTo({
url:url,
})
}
return;
}else{
let value=util.attr(e,'value')
wx.makePhoneCall({
phoneNumber: value.replace(/[^\d]/g, '')
})
}
},
actionSheetChange(){
this.hide();
}
}
})
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--components/actionSheet/phone.wxml-->
<view class="mask" wx:if="{{!actionSheetHidden}}"catchtap="catchtap">
<view class="action-sheet flex-vc">
<view class="title">拨打电话</view>
<view class="action-sheet-item-block">
<view class="action-sheet-item flex-cc"
wx:if="{{hasOnlineReserve}}"
bindtap="bindItemTap" data-value="reserve" data-index="reserve">
立即在线预订
<view class="tuijian">推荐</view>
</view>
<block wx:for="{{items}}" wx:key="itemskey">
<view class="action-sheet-item flex-cc" bindtap="bindItemTap" data-value="{{item}}" data-index="{{index}}">
{{item}}
</view>
</block>
</view>
<view class="action-sheet-cancel" bindtap="hide">取消</view>
</view>
</view>
\ No newline at end of file
... ...
/* components/actionSheet/phone.wxss */
@import "../../app.wxss";
.mask{
z-index: 99999;
}
.action-sheet{
background:rgba(255,255,255,1);
border-radius:24rpx 24rpx 0rpx 0rpx;
position: fixed;
bottom: 0;
width: 100%;
box-sizing: border-box;
padding: 30rpx 0;
}
.title{
height:50rpx;
font-size:36rpx;
font-family:PingFangSC-Semibold,PingFang SC;
font-weight:600;
color:rgba(0,0,0,1);
line-height:50rpx;
}
.action-sheet-item-block{
width: 100%;
}
.action-sheet-item{
width: 100%;
height: 128rpx;
line-height: 128rpx;
font-size:34rpx;
font-family:PingFangSC-Regular,PingFang SC;
font-weight:400;
color:rgba(0,0,0,1);
border-bottom: 2rpx solid #E5E5E5;
}
.action-sheet-item:last-child{
border-bottom-width: 0;
padding-top: 20rpx;
}
.action-sheet-cancel{
height:84rpx;
background:rgba(245,245,245,1);
border-radius:42rpx;
width: calc(100% - 80rpx);
text-align: center;
font-size:36rpx;
font-family:PingFangSC-Regular,PingFang SC;
font-weight:400;
color:rgba(102,102,102,1);
line-height:84rpx;
}
.tuijian{
background-image: url("http://nosqn.colorcun.com/phone/tuijian.png");
background-size: 100% 100%;
width: 54rpx;
height: 34rpx;
margin-left: 16rpx;
font-size:20rpx;
font-family:PingFangSC-Semibold,PingFang SC;
font-weight:600;
color:rgba(255,255,255,1);
line-height:28rpx;
text-align: center;
margin-top: 10rpx;
}
... ...
... ... @@ -57,6 +57,7 @@ Component({
value: false,
},
hasNewActivityList:Boolean,//新的活动商家列表
hasInSwiper:Boolean,//是否在Swiper控件内,不能使用组件电话框,只能通知页面
},
/**
... ... @@ -107,9 +108,10 @@ Component({
})
},
tapButton(e) {
//console.log('tapButton',e)
let type = util.attr(e, 'type');
if (type == 'oncall') {
if(this.data.seller.is_online_reserve==1){
if(this.data.seller.is_online_reserve==1 && this.data.seller.is_tele==1){
let url=util.http_build_query({id:this.data.seller.id,activeTab:'reserve'},'/pages/reserve/detail')
if(this.data.seller.findSellerParamObj){
let findSellerParamObj=this.data.seller.findSellerParamObj
... ... @@ -126,30 +128,11 @@ Component({
url:url,
})
}
let seller_tel = this.data.seller.seller_tel;
if (seller_tel.length < 1) {
seller_tel = [this.data.seller.phone]
if(this.data.hasInSwiper){
this.triggerEvent('event',{act:type,seller:this.data.seller})
}else{
this.selectComponent('#as').show(this.data.seller);
}
if (seller_tel.length == 1) {
wx.makePhoneCall({
phoneNumber: seller_tel[0].replace(/[^\d]/g, '')
})
} else {
//wx.hideTabBar();
wx.showActionSheet({
itemList: seller_tel,
complete: () => {
//wx.showTabBar();
},
success: (res) => {
let phone = seller_tel[res.tapIndex]
wx.makePhoneCall({
phoneNumber: phone.replace(/[^\d]/g, '')
})
}
});
}
} else {
util.toast('请打电话预订', 'none');
}
... ...
... ... @@ -2,6 +2,7 @@
"component": true,
"usingComponents": {
"formids":"/components/formids/formids",
"as-phone":"/components/actionSheet/phone",
"stat":"/components/stat/stat"
}
}
\ No newline at end of file
... ...
... ... @@ -94,4 +94,5 @@
</view>
</view>
</view>
</view>
\ No newline at end of file
</view>
<as-phone id="as"></as-phone>
\ No newline at end of file
... ...
... ... @@ -189,4 +189,10 @@ Page({
this.location=e.detail
this.getListData();
},
sbtrEvent(e){
console.log(e);
if(e.detail.act=='oncall'){
this.selectComponent('#as').show(e.detail.seller);
}
},
})
\ No newline at end of file
... ...
... ... @@ -8,6 +8,7 @@
"nav":"/components/nav/nav",
"sb-tr":"/components/reserve/seller-box-transverse/seller-box",
"getpos":"/components/userinfo/getpos",
"as-phone":"/components/actionSheet/phone",
"card":"/components/seller-card/seller-card"
}
}
\ No newline at end of file
... ...
... ... @@ -36,6 +36,7 @@
<swiper-item bindtap="gotoSellerDetail" id="{{item.id}}">
<view class="seller" id="seller-{{item.id}}">
<sb-tr seller="{{item}}"
hasInSwiper bindevent="sbtrEvent"
hasActivityTags="{{false}}"
hasActivityShort="{{true}}"
hasBrand="true" hasActivityTese="true"
... ... @@ -47,4 +48,5 @@
</view>
</view>
</block>
<getpos bindpos="onpos" id="getpos" hasAllowFail hasAllowLoading="{{false}}"></getpos>
\ No newline at end of file
<getpos bindpos="onpos" id="getpos" hasAllowFail hasAllowLoading="{{false}}"></getpos>
<as-phone id="as"></as-phone>
\ No newline at end of file
... ...
... ... @@ -208,22 +208,7 @@ Page({
activeTab:'reserve'
})
}
if(this.data.hasOnlineReserve && this.data.seller.is_tele==0){
wx.makePhoneCall({
phoneNumber:'400-000-9690'
})
}else{
let seller_tel=this.data.seller.seller_tel||[]
if(seller_tel.length<1) return util.toast('商家电话错误','none')
if(seller_tel.length==1){//只有一个电话
let phone=seller_tel[0].replace(/[^\d]/,'')
wx.makePhoneCall({
phoneNumber:phone
})
}else{
this.selectComponent('#as').show();
}
}
this.selectComponent('#as').show(this.data.seller);
},
reservePhone(e){
if(e.detail.value){
... ...
... ... @@ -7,7 +7,7 @@
"userinfo":"/components/userinfo/userinfo",
"userinfo-share":"/components/userinfo/share",
"stat":"/components/stat/stat",
"as":"/components/actionSheet/index",
"as-phone":"/components/actionSheet/phone",
"nav":"/components/nav/nav",
"getpos":"/components/userinfo/getpos",
"discount":"/components/reserve/seller/discount",
... ...
... ... @@ -180,7 +180,7 @@
</view>
</view>
<as id="as" items="{{seller.seller_tel}}" bindclick="reservePhone" hasTip="{{false}}"></as>
<as-phone id="as"></as-phone>
<getpos bindpos="onpos" id="getpos" hasAllowLoading="{{false}}"></getpos>
<!--
<activity-tips str="¥price" cla="reserve-detail" pos="pages/reserve/detail"></activity-tips>
... ...
... ... @@ -597,4 +597,7 @@
background-image: url("http://nosqn.colorcun.com/sellerbaobao/right-1.png");
right:0;
left:auto;
}
.as-phone{
}
\ No newline at end of file
... ...
... ... @@ -941,5 +941,11 @@ Page({
},
elog(e){
util.elog({attr:util.attr(e),detail:e.detail},util.attr(e,'ename')||'点击')
}
},
sbtrEvent(e){
console.log(e);
if(e.detail.act=='oncall'){
this.selectComponent('#as').show(e.detail.seller);
}
},
})
\ No newline at end of file
... ...
... ... @@ -12,6 +12,7 @@
"caixi":"/components/reserve/caixi",
"list":"/components/reserve/seller-box-transverse-cview/list",
"activity-enter":"/components/activity/enter",
"as-phone":"/components/actionSheet/phone",
"activity-tips":"/components/tips/discount"
}
}
\ No newline at end of file
... ...
... ... @@ -71,9 +71,11 @@
previous-margin="{{15}}px" next-margin="{{15}}px" style="height: 350rpx;"
current="{{current}}" bindchange="bindtransition" hidden="{{!hasSellers}}">
<block wx:for="{{markers}}" wx:key="markerskey" wx:if="{{item.id!='location' && item.id!='locationMe'}}">
<swiper-item bindtap="gotoDetail" data-sid="{{item.id}}" wx:if="{{item.display!='none'}}">
<swiper-item bindtap="gotoDetail"
data-sid="{{item.id}}" wx:if="{{item.display!='none'}}">
<view class="seller" id="seller-{{item.id}}">
<sb-tr seller="{{item.seller}}"
hasInSwiper bindevent="sbtrEvent"
hasActivityTags="{{false}}"
hasActivityShort="{{true}}"
hasBrand="true" hasActivityRed="true"
... ... @@ -144,4 +146,5 @@
></caixi>
<activity-enter hasInHome wx:if="{{hasGetPos}}"></activity-enter>
<boost bindevent="boostEvent" wx:if="{{hasBoost}}"></boost>
<activity-tips wx:if="{{hasSetActivity}}" map="{{map}}"></activity-tips>
\ No newline at end of file
<activity-tips wx:if="{{hasSetActivity}}" map="{{map}}"></activity-tips>
<as-phone id="as"></as-phone>
\ No newline at end of file
... ...
... ... @@ -291,4 +291,10 @@ Page({
url:url,
})
},
sbtrEvent(e){
console.log(e);
if(e.detail.act=='oncall'){
this.selectComponent('#as').show(e.detail.seller);
}
},
})
\ No newline at end of file
... ...
... ... @@ -7,6 +7,7 @@
"getpos":"/components/userinfo/getpos",
"nav":"/components/nav/nav",
"search-item":"/components/reserve/search/item",
"as-phone":"/components/actionSheet/phone",
"sb-tr":"/components/reserve/seller-box-transverse/seller-box"
}
}
\ No newline at end of file
... ...
... ... @@ -45,6 +45,7 @@
<swiper-item bindtap="gotoSellerDetail" id="{{item.id}}">
<view class="seller" id="seller-{{item.id}}">
<sb-tr seller="{{item}}"
hasInSwiper bindevent="sbtrEvent"
hasActivityTags="{{false}}"
hasActivityShort="{{true}}"
hasBrand="true" hasActivityTese="true"
... ... @@ -68,4 +69,5 @@
</view>
</view>
</view>
<getpos bindpos="onpos" id="getpos" hasAllowFail></getpos>
\ No newline at end of file
<getpos bindpos="onpos" id="getpos" hasAllowFail></getpos>
<as-phone id="as"></as-phone>
\ No newline at end of file
... ...
... ... @@ -587,7 +587,7 @@
"id": 71,
"name": "pages/reserve/detail",
"pathName": "pages/reserve/detail",
"query": "id=1001&activeTab=reserve&date=2020-02-16&pnum=6",
"query": "id=4645&_activeTab=reserve&date=2020-02-16&pnum=6",
"scene": null
},
{
... ...