Commit 1cbb0502ee42f445b0f8cb5358f25785aa114982

Authored by vking
1 parent f4a4be08

电话弹框

  1 +// components/actionSheet/phone.js
  2 +import util from '../../utils/util';
  3 +Component({
  4 + /**
  5 + * 组件的属性列表
  6 + */
  7 + properties: {
  8 + //items: Array,//电话列表
  9 + //seller:Object,//商家信息
  10 + hasTip:{
  11 + type:Boolean,
  12 + value:true,
  13 + },
  14 + },
  15 +
  16 + /**
  17 + * 组件的初始数据
  18 + */
  19 + data: {
  20 + actionSheetHidden: true,
  21 + hasOnlineReserve:false,
  22 + },
  23 +
  24 + /**
  25 + * 组件的方法列表
  26 + */
  27 + methods: {
  28 + show(seller){
  29 + this.seller=seller
  30 + let seller_tel = this.seller.seller_tel;
  31 + if(this.seller.is_online_reserve==1 && this.seller.is_tele==0){
  32 + //开通在线预订,但无商家接单设备,拨打运营电话
  33 + seller_tel = ['400-000-9690']
  34 + }else{
  35 + if (seller_tel.length < 1) {
  36 + seller_tel = [this.seller.phone]
  37 + }
  38 + }
  39 + this.setData({
  40 + actionSheetHidden: false,
  41 + items:seller_tel,
  42 + hasOnlineReserve:this.seller.is_online_reserve==1 && this.seller.is_tele==1
  43 + })
  44 + },
  45 + hide(){
  46 + this.setData({
  47 + actionSheetHidden: true,
  48 + })
  49 + },
  50 + bindItemTap(e){
  51 + this.hide();
  52 + let index=util.attr(e,'index')
  53 + if(index=='reserve'){//跳转到预订页
  54 + let pages=getCurrentPages();
  55 + let p=pages[pages.length-1];
  56 + if(p.route=='pages/reserve/detail'){
  57 + p.setData({
  58 + activeTab:'reserve'
  59 + })
  60 + }else{
  61 + let url=util.http_build_query({id:this.seller.id,activeTab:'reserve'},'/pages/reserve/detail')
  62 + wx.navigateTo({
  63 + url:url,
  64 + })
  65 + }
  66 + return;
  67 + }else{
  68 + let value=util.attr(e,'value')
  69 + wx.makePhoneCall({
  70 + phoneNumber: value.replace(/[^\d]/g, '')
  71 + })
  72 + }
  73 + },
  74 + actionSheetChange(){
  75 + this.hide();
  76 + }
  77 + }
  78 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
  1 +<!--components/actionSheet/phone.wxml-->
  2 +<view class="mask" wx:if="{{!actionSheetHidden}}"catchtap="catchtap">
  3 + <view class="action-sheet flex-vc">
  4 + <view class="title">拨打电话</view>
  5 + <view class="action-sheet-item-block">
  6 + <view class="action-sheet-item flex-cc"
  7 + wx:if="{{hasOnlineReserve}}"
  8 + bindtap="bindItemTap" data-value="reserve" data-index="reserve">
  9 + 立即在线预订
  10 + <view class="tuijian">推荐</view>
  11 + </view>
  12 + <block wx:for="{{items}}" wx:key="itemskey">
  13 + <view class="action-sheet-item flex-cc" bindtap="bindItemTap" data-value="{{item}}" data-index="{{index}}">
  14 + {{item}}
  15 + </view>
  16 + </block>
  17 + </view>
  18 + <view class="action-sheet-cancel" bindtap="hide">取消</view>
  19 + </view>
  20 +</view>
  1 +/* components/actionSheet/phone.wxss */
  2 +@import "../../app.wxss";
  3 +.mask{
  4 + z-index: 99999;
  5 +}
  6 +.action-sheet{
  7 + background:rgba(255,255,255,1);
  8 + border-radius:24rpx 24rpx 0rpx 0rpx;
  9 + position: fixed;
  10 + bottom: 0;
  11 + width: 100%;
  12 + box-sizing: border-box;
  13 + padding: 30rpx 0;
  14 +}
  15 +.title{
  16 + height:50rpx;
  17 + font-size:36rpx;
  18 + font-family:PingFangSC-Semibold,PingFang SC;
  19 + font-weight:600;
  20 + color:rgba(0,0,0,1);
  21 + line-height:50rpx;
  22 +}
  23 +.action-sheet-item-block{
  24 + width: 100%;
  25 +}
  26 +.action-sheet-item{
  27 + width: 100%;
  28 + height: 128rpx;
  29 + line-height: 128rpx;
  30 +
  31 + font-size:34rpx;
  32 + font-family:PingFangSC-Regular,PingFang SC;
  33 + font-weight:400;
  34 + color:rgba(0,0,0,1);
  35 + border-bottom: 2rpx solid #E5E5E5;
  36 +}
  37 +.action-sheet-item:last-child{
  38 + border-bottom-width: 0;
  39 + padding-top: 20rpx;
  40 +}
  41 +.action-sheet-cancel{
  42 + height:84rpx;
  43 + background:rgba(245,245,245,1);
  44 + border-radius:42rpx;
  45 + width: calc(100% - 80rpx);
  46 + text-align: center;
  47 +
  48 + font-size:36rpx;
  49 + font-family:PingFangSC-Regular,PingFang SC;
  50 + font-weight:400;
  51 + color:rgba(102,102,102,1);
  52 + line-height:84rpx;
  53 +}
  54 +.tuijian{
  55 + background-image: url("http://nosqn.colorcun.com/phone/tuijian.png");
  56 + background-size: 100% 100%;
  57 + width: 54rpx;
  58 + height: 34rpx;
  59 + margin-left: 16rpx;
  60 +
  61 + font-size:20rpx;
  62 + font-family:PingFangSC-Semibold,PingFang SC;
  63 + font-weight:600;
  64 + color:rgba(255,255,255,1);
  65 + line-height:28rpx;
  66 +
  67 + text-align: center;
  68 + margin-top: 10rpx;
  69 +}
@@ -57,6 +57,7 @@ Component({ @@ -57,6 +57,7 @@ Component({
57 value: false, 57 value: false,
58 }, 58 },
59 hasNewActivityList:Boolean,//新的活动商家列表 59 hasNewActivityList:Boolean,//新的活动商家列表
  60 + hasInSwiper:Boolean,//是否在Swiper控件内,不能使用组件电话框,只能通知页面
60 }, 61 },
61 62
62 /** 63 /**
@@ -107,9 +108,10 @@ Component({ @@ -107,9 +108,10 @@ Component({
107 }) 108 })
108 }, 109 },
109 tapButton(e) { 110 tapButton(e) {
  111 + //console.log('tapButton',e)
110 let type = util.attr(e, 'type'); 112 let type = util.attr(e, 'type');
111 if (type == 'oncall') { 113 if (type == 'oncall') {
112 - if(this.data.seller.is_online_reserve==1){ 114 + if(this.data.seller.is_online_reserve==1 && this.data.seller.is_tele==1){
113 let url=util.http_build_query({id:this.data.seller.id,activeTab:'reserve'},'/pages/reserve/detail') 115 let url=util.http_build_query({id:this.data.seller.id,activeTab:'reserve'},'/pages/reserve/detail')
114 if(this.data.seller.findSellerParamObj){ 116 if(this.data.seller.findSellerParamObj){
115 let findSellerParamObj=this.data.seller.findSellerParamObj 117 let findSellerParamObj=this.data.seller.findSellerParamObj
@@ -126,30 +128,11 @@ Component({ @@ -126,30 +128,11 @@ Component({
126 url:url, 128 url:url,
127 }) 129 })
128 } 130 }
129 - let seller_tel = this.data.seller.seller_tel;  
130 - if (seller_tel.length < 1) {  
131 - seller_tel = [this.data.seller.phone] 131 + if(this.data.hasInSwiper){
  132 + this.triggerEvent('event',{act:type,seller:this.data.seller})
  133 + }else{
  134 + this.selectComponent('#as').show(this.data.seller);
132 } 135 }
133 - if (seller_tel.length == 1) {  
134 - wx.makePhoneCall({  
135 - phoneNumber: seller_tel[0].replace(/[^\d]/g, '')  
136 - })  
137 - } else {  
138 - //wx.hideTabBar();  
139 - wx.showActionSheet({  
140 - itemList: seller_tel,  
141 - complete: () => {  
142 - //wx.showTabBar();  
143 - },  
144 - success: (res) => {  
145 - let phone = seller_tel[res.tapIndex]  
146 - wx.makePhoneCall({  
147 - phoneNumber: phone.replace(/[^\d]/g, '')  
148 - })  
149 - }  
150 - });  
151 - }  
152 -  
153 } else { 136 } else {
154 util.toast('请打电话预订', 'none'); 137 util.toast('请打电话预订', 'none');
155 } 138 }
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 "component": true, 2 "component": true,
3 "usingComponents": { 3 "usingComponents": {
4 "formids":"/components/formids/formids", 4 "formids":"/components/formids/formids",
  5 + "as-phone":"/components/actionSheet/phone",
5 "stat":"/components/stat/stat" 6 "stat":"/components/stat/stat"
6 } 7 }
7 } 8 }
@@ -94,4 +94,5 @@ @@ -94,4 +94,5 @@
94 </view> 94 </view>
95 </view> 95 </view>
96 </view> 96 </view>
97 -</view>  
  97 +</view>
  98 +<as-phone id="as"></as-phone>
@@ -189,4 +189,10 @@ Page({ @@ -189,4 +189,10 @@ Page({
189 this.location=e.detail 189 this.location=e.detail
190 this.getListData(); 190 this.getListData();
191 }, 191 },
  192 + sbtrEvent(e){
  193 + console.log(e);
  194 + if(e.detail.act=='oncall'){
  195 + this.selectComponent('#as').show(e.detail.seller);
  196 + }
  197 + },
192 }) 198 })
@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 "nav":"/components/nav/nav", 8 "nav":"/components/nav/nav",
9 "sb-tr":"/components/reserve/seller-box-transverse/seller-box", 9 "sb-tr":"/components/reserve/seller-box-transverse/seller-box",
10 "getpos":"/components/userinfo/getpos", 10 "getpos":"/components/userinfo/getpos",
  11 + "as-phone":"/components/actionSheet/phone",
11 "card":"/components/seller-card/seller-card" 12 "card":"/components/seller-card/seller-card"
12 } 13 }
13 } 14 }
@@ -36,6 +36,7 @@ @@ -36,6 +36,7 @@
36 <swiper-item bindtap="gotoSellerDetail" id="{{item.id}}"> 36 <swiper-item bindtap="gotoSellerDetail" id="{{item.id}}">
37 <view class="seller" id="seller-{{item.id}}"> 37 <view class="seller" id="seller-{{item.id}}">
38 <sb-tr seller="{{item}}" 38 <sb-tr seller="{{item}}"
  39 + hasInSwiper bindevent="sbtrEvent"
39 hasActivityTags="{{false}}" 40 hasActivityTags="{{false}}"
40 hasActivityShort="{{true}}" 41 hasActivityShort="{{true}}"
41 hasBrand="true" hasActivityTese="true" 42 hasBrand="true" hasActivityTese="true"
@@ -47,4 +48,5 @@ @@ -47,4 +48,5 @@
47 </view> 48 </view>
48 </view> 49 </view>
49 </block> 50 </block>
50 -<getpos bindpos="onpos" id="getpos" hasAllowFail hasAllowLoading="{{false}}"></getpos>  
  51 +<getpos bindpos="onpos" id="getpos" hasAllowFail hasAllowLoading="{{false}}"></getpos>
  52 +<as-phone id="as"></as-phone>
@@ -208,22 +208,7 @@ Page({ @@ -208,22 +208,7 @@ Page({
208 activeTab:'reserve' 208 activeTab:'reserve'
209 }) 209 })
210 } 210 }
211 - if(this.data.hasOnlineReserve && this.data.seller.is_tele==0){  
212 - wx.makePhoneCall({  
213 - phoneNumber:'400-000-9690'  
214 - })  
215 - }else{  
216 - let seller_tel=this.data.seller.seller_tel||[]  
217 - if(seller_tel.length<1) return util.toast('商家电话错误','none')  
218 - if(seller_tel.length==1){//只有一个电话  
219 - let phone=seller_tel[0].replace(/[^\d]/,'')  
220 - wx.makePhoneCall({  
221 - phoneNumber:phone  
222 - })  
223 - }else{  
224 - this.selectComponent('#as').show();  
225 - }  
226 - } 211 + this.selectComponent('#as').show(this.data.seller);
227 }, 212 },
228 reservePhone(e){ 213 reservePhone(e){
229 if(e.detail.value){ 214 if(e.detail.value){
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 "userinfo":"/components/userinfo/userinfo", 7 "userinfo":"/components/userinfo/userinfo",
8 "userinfo-share":"/components/userinfo/share", 8 "userinfo-share":"/components/userinfo/share",
9 "stat":"/components/stat/stat", 9 "stat":"/components/stat/stat",
10 - "as":"/components/actionSheet/index", 10 + "as-phone":"/components/actionSheet/phone",
11 "nav":"/components/nav/nav", 11 "nav":"/components/nav/nav",
12 "getpos":"/components/userinfo/getpos", 12 "getpos":"/components/userinfo/getpos",
13 "discount":"/components/reserve/seller/discount", 13 "discount":"/components/reserve/seller/discount",
@@ -180,7 +180,7 @@ @@ -180,7 +180,7 @@
180 </view> 180 </view>
181 181
182 </view> 182 </view>
183 - <as id="as" items="{{seller.seller_tel}}" bindclick="reservePhone" hasTip="{{false}}"></as> 183 + <as-phone id="as"></as-phone>
184 <getpos bindpos="onpos" id="getpos" hasAllowLoading="{{false}}"></getpos> 184 <getpos bindpos="onpos" id="getpos" hasAllowLoading="{{false}}"></getpos>
185 <!-- 185 <!--
186 <activity-tips str="¥price" cla="reserve-detail" pos="pages/reserve/detail"></activity-tips> 186 <activity-tips str="¥price" cla="reserve-detail" pos="pages/reserve/detail"></activity-tips>
@@ -597,4 +597,7 @@ @@ -597,4 +597,7 @@
597 background-image: url("http://nosqn.colorcun.com/sellerbaobao/right-1.png"); 597 background-image: url("http://nosqn.colorcun.com/sellerbaobao/right-1.png");
598 right:0; 598 right:0;
599 left:auto; 599 left:auto;
  600 +}
  601 +.as-phone{
  602 +
600 } 603 }
@@ -941,5 +941,11 @@ Page({ @@ -941,5 +941,11 @@ Page({
941 }, 941 },
942 elog(e){ 942 elog(e){
943 util.elog({attr:util.attr(e),detail:e.detail},util.attr(e,'ename')||'点击') 943 util.elog({attr:util.attr(e),detail:e.detail},util.attr(e,'ename')||'点击')
944 - } 944 + },
  945 + sbtrEvent(e){
  946 + console.log(e);
  947 + if(e.detail.act=='oncall'){
  948 + this.selectComponent('#as').show(e.detail.seller);
  949 + }
  950 + },
945 }) 951 })
@@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
12 "caixi":"/components/reserve/caixi", 12 "caixi":"/components/reserve/caixi",
13 "list":"/components/reserve/seller-box-transverse-cview/list", 13 "list":"/components/reserve/seller-box-transverse-cview/list",
14 "activity-enter":"/components/activity/enter", 14 "activity-enter":"/components/activity/enter",
  15 + "as-phone":"/components/actionSheet/phone",
15 "activity-tips":"/components/tips/discount" 16 "activity-tips":"/components/tips/discount"
16 } 17 }
17 } 18 }
@@ -71,9 +71,11 @@ @@ -71,9 +71,11 @@
71 previous-margin="{{15}}px" next-margin="{{15}}px" style="height: 350rpx;" 71 previous-margin="{{15}}px" next-margin="{{15}}px" style="height: 350rpx;"
72 current="{{current}}" bindchange="bindtransition" hidden="{{!hasSellers}}"> 72 current="{{current}}" bindchange="bindtransition" hidden="{{!hasSellers}}">
73 <block wx:for="{{markers}}" wx:key="markerskey" wx:if="{{item.id!='location' && item.id!='locationMe'}}"> 73 <block wx:for="{{markers}}" wx:key="markerskey" wx:if="{{item.id!='location' && item.id!='locationMe'}}">
74 - <swiper-item bindtap="gotoDetail" data-sid="{{item.id}}" wx:if="{{item.display!='none'}}"> 74 + <swiper-item bindtap="gotoDetail"
  75 + data-sid="{{item.id}}" wx:if="{{item.display!='none'}}">
75 <view class="seller" id="seller-{{item.id}}"> 76 <view class="seller" id="seller-{{item.id}}">
76 <sb-tr seller="{{item.seller}}" 77 <sb-tr seller="{{item.seller}}"
  78 + hasInSwiper bindevent="sbtrEvent"
77 hasActivityTags="{{false}}" 79 hasActivityTags="{{false}}"
78 hasActivityShort="{{true}}" 80 hasActivityShort="{{true}}"
79 hasBrand="true" hasActivityRed="true" 81 hasBrand="true" hasActivityRed="true"
@@ -144,4 +146,5 @@ @@ -144,4 +146,5 @@
144 ></caixi> 146 ></caixi>
145 <activity-enter hasInHome wx:if="{{hasGetPos}}"></activity-enter> 147 <activity-enter hasInHome wx:if="{{hasGetPos}}"></activity-enter>
146 <boost bindevent="boostEvent" wx:if="{{hasBoost}}"></boost> 148 <boost bindevent="boostEvent" wx:if="{{hasBoost}}"></boost>
147 -<activity-tips wx:if="{{hasSetActivity}}" map="{{map}}"></activity-tips>  
  149 +<activity-tips wx:if="{{hasSetActivity}}" map="{{map}}"></activity-tips>
  150 +<as-phone id="as"></as-phone>
@@ -291,4 +291,10 @@ Page({ @@ -291,4 +291,10 @@ Page({
291 url:url, 291 url:url,
292 }) 292 })
293 }, 293 },
  294 + sbtrEvent(e){
  295 + console.log(e);
  296 + if(e.detail.act=='oncall'){
  297 + this.selectComponent('#as').show(e.detail.seller);
  298 + }
  299 + },
294 }) 300 })
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 "getpos":"/components/userinfo/getpos", 7 "getpos":"/components/userinfo/getpos",
8 "nav":"/components/nav/nav", 8 "nav":"/components/nav/nav",
9 "search-item":"/components/reserve/search/item", 9 "search-item":"/components/reserve/search/item",
  10 + "as-phone":"/components/actionSheet/phone",
10 "sb-tr":"/components/reserve/seller-box-transverse/seller-box" 11 "sb-tr":"/components/reserve/seller-box-transverse/seller-box"
11 } 12 }
12 } 13 }
@@ -45,6 +45,7 @@ @@ -45,6 +45,7 @@
45 <swiper-item bindtap="gotoSellerDetail" id="{{item.id}}"> 45 <swiper-item bindtap="gotoSellerDetail" id="{{item.id}}">
46 <view class="seller" id="seller-{{item.id}}"> 46 <view class="seller" id="seller-{{item.id}}">
47 <sb-tr seller="{{item}}" 47 <sb-tr seller="{{item}}"
  48 + hasInSwiper bindevent="sbtrEvent"
48 hasActivityTags="{{false}}" 49 hasActivityTags="{{false}}"
49 hasActivityShort="{{true}}" 50 hasActivityShort="{{true}}"
50 hasBrand="true" hasActivityTese="true" 51 hasBrand="true" hasActivityTese="true"
@@ -68,4 +69,5 @@ @@ -68,4 +69,5 @@
68 </view> 69 </view>
69 </view> 70 </view>
70 </view> 71 </view>
71 -<getpos bindpos="onpos" id="getpos" hasAllowFail></getpos>  
  72 +<getpos bindpos="onpos" id="getpos" hasAllowFail></getpos>
  73 +<as-phone id="as"></as-phone>
@@ -587,7 +587,7 @@ @@ -587,7 +587,7 @@
587 "id": 71, 587 "id": 71,
588 "name": "pages/reserve/detail", 588 "name": "pages/reserve/detail",
589 "pathName": "pages/reserve/detail", 589 "pathName": "pages/reserve/detail",
590 - "query": "id=1001&activeTab=reserve&date=2020-02-16&pnum=6", 590 + "query": "id=4645&_activeTab=reserve&date=2020-02-16&pnum=6",
591 "scene": null 591 "scene": null
592 }, 592 },
593 { 593 {