Commit 69b1011d74514731534e2fbaba97ed20a60c9612

Authored by vking
1 parent 7ef25b93

online

1 // pages/customer/detail_owner.js 1 // pages/customer/detail_owner.js
2 import util from '../../utils/util'; 2 import util from '../../utils/util';
3 import App from '../../utils/api'; 3 import App from '../../utils/api';
  4 +
4 const {regeneratorRuntime} = global 5 const {regeneratorRuntime} = global
5 import TP from '../../utils/tpls'; 6 import TP from '../../utils/tpls';
  7 +
6 Page({ 8 Page({
7 9
8 /** 10 /**
9 * 页面的初始数据 11 * 页面的初始数据
10 */ 12 */
11 data: { 13 data: {
12 - detail:null, 14 + detail: null,
  15 + hasOnlineReserve: false,
13 }, 16 },
14 - id:null,  
15 - tpls:TP.tpls(), 17 + id: null,
  18 + tpls: TP.tpls(),
16 /** 19 /**
17 * 生命周期函数--监听页面加载 20 * 生命周期函数--监听页面加载
18 */ 21 */
19 onLoad: function (options) { 22 onLoad: function (options) {
20 - this.id=options.id; 23 + this.id = options.id;
21 }, 24 },
22 25
23 /** 26 /**
@@ -31,81 +34,83 @@ Page({ @@ -31,81 +34,83 @@ Page({
31 * 生命周期函数--监听页面显示 34 * 生命周期函数--监听页面显示
32 */ 35 */
33 onShow: function () { 36 onShow: function () {
34 - App.Reserve.Detail({  
35 - openid: getApp().openid,  
36 - rid: this.id  
37 - }).then(res => {  
38 - this.setData({  
39 - detail:this.formatDatail(res.data)  
40 - }) 37 + App.Reserve.Detail({
  38 + openid: getApp().openid,
  39 + rid: this.id
  40 + }).then(res => {
  41 + this.setData({
  42 + detail: this.formatDatail(res.data),
  43 + hasOnlineReserve:res.data.type==0,
41 }) 44 })
  45 + })
42 }, 46 },
43 47
44 /** 48 /**
45 * 生命周期函数--监听页面隐藏 49 * 生命周期函数--监听页面隐藏
46 */ 50 */
47 onHide: function () { 51 onHide: function () {
48 - 52 +
49 }, 53 },
50 54
51 /** 55 /**
52 * 生命周期函数--监听页面卸载 56 * 生命周期函数--监听页面卸载
53 */ 57 */
54 onUnload: function () { 58 onUnload: function () {
55 - 59 +
56 }, 60 },
57 61
58 /** 62 /**
59 * 用户点击右上角分享 63 * 用户点击右上角分享
60 */ 64 */
61 onShareAppMessage: function (e) { 65 onShareAppMessage: function (e) {
62 - console.log('onShareAppMessage',arguments) 66 + console.log('onShareAppMessage', arguments)
63 return this.shareSetting(e); 67 return this.shareSetting(e);
64 }, 68 },
65 - formatDatail(detail){  
66 - detail.rdateStr=util.unixtoTime(detail.ddate,'MM月DD日 WW HH:II');  
67 - detail.tableFirst=detail.tables[0].name;  
68 - if(detail.tables.length>1){  
69 - detail.tableSubInfo='等'+(detail.tables.length)+'个'  
70 - +(detail.tables[0].tid==2?'包间':'');  
71 - }  
72 - // if(!detail.cusman){  
73 - // detail.cusman='vking';  
74 - // detail.cusman_phone='15877556369';  
75 - // detail.cusman_account='wx:vking';  
76 - // }  
77 - let ns=new Date()/1000  
78 - detail.hasCancel=detail.status==4  
79 - detail.hasOvered=false  
80 - if(!detail.hasCancel){  
81 - detail.hasOvered=ns>detail.ddate || detail.status>=2 69 + formatDatail(detail) {
  70 + detail.rdateStr = util.unixtoTime(detail.ddate, 'MM月DD日 WW HH:II');
  71 + detail.tableFirst = detail.tables[0].name;
  72 + if (detail.tables.length > 1) {
  73 + detail.tableSubInfo = '等' + (detail.tables.length) + '个'
  74 + + (detail.tables[0].tid == 2 ? '包间' : '');
82 } 75 }
83 - return detail;  
84 - },  
85 - showManager(){  
86 - this.selectComponent('#manager').show();  
87 - },  
88 - lookLocation:function(){  
89 - wx.openLocation({  
90 - latitude:Number(this.data.detail.seller.lat),  
91 - longitude:Number(this.data.detail.seller.long),  
92 - scale:17,  
93 - address:this.data.detail.seller.map_address,  
94 - success:function (res) {  
95 - console.log(res)  
96 - }  
97 - })  
98 - },  
99 - userinfo(e){  
100 - console.log('userinfo',e)  
101 - util.toast('授权成功,可以继续转发','none');  
102 - // wx.navigateTo({  
103 - // url:'invite?id='+this.id,  
104 - // });  
105 - },  
106 - shareSetting(e){  
107 - console.log('shareSetting',e.target.dataset);  
108 - let hasInvitation=e.target.dataset.act=='invitation'; 76 + // if(!detail.cusman){
  77 + // detail.cusman='vking';
  78 + // detail.cusman_phone='15877556369';
  79 + // detail.cusman_account='wx:vking';
  80 + // }
  81 + let ns = new Date() / 1000
  82 + detail.hasCancel = detail.status == 4
  83 + detail.hasOvered = false
  84 + if (!detail.hasCancel) {
  85 + detail.hasOvered = ns > detail.ddate || detail.status >= 2
  86 + }
  87 + detail.seller.seller_tel=detail.seller.seller_tel.split(',');
  88 + return detail;
  89 + },
  90 + showManager() {
  91 + this.selectComponent('#manager').show();
  92 + },
  93 + lookLocation: function () {
  94 + wx.openLocation({
  95 + latitude: Number(this.data.detail.seller.lat),
  96 + longitude: Number(this.data.detail.seller.long),
  97 + scale: 17,
  98 + address: this.data.detail.seller.map_address,
  99 + success: function (res) {
  100 + console.log(res)
  101 + }
  102 + })
  103 + },
  104 + userinfo(e) {
  105 + console.log('userinfo', e)
  106 + util.toast('授权成功,可以继续转发', 'none');
  107 + // wx.navigateTo({
  108 + // url:'invite?id='+this.id,
  109 + // });
  110 + },
  111 + shareSetting(e) {
  112 + console.log('shareSetting', e.target.dataset);
  113 + let hasInvitation = e.target.dataset.act == 'invitation';
109 if (this.topicVal && this.data.detail.openid == getApp().openid) { 114 if (this.topicVal && this.data.detail.openid == getApp().openid) {
110 App.Reserve.SetTopicFromShare({ 115 App.Reserve.SetTopicFromShare({
111 rid: this.id, 116 rid: this.id,
@@ -117,39 +122,68 @@ Page({ @@ -117,39 +122,68 @@ Page({
117 nickname = util.cache('userInfo').nickName; 122 nickname = util.cache('userInfo').nickName;
118 } catch (e) { 123 } catch (e) {
119 } 124 }
120 - let obj={ 125 + let obj = {
121 //title: (nickname || '') + '给你发了一个邀请,点击查看', 126 //title: (nickname || '') + '给你发了一个邀请,点击查看',
122 title: this.tpls[0].shareTitle, 127 title: this.tpls[0].shareTitle,
123 - path: '/pages/customer/index?id=' + this.id + '&fromid=' + getApp().openid + '&invite_name=' + nickname+'&hasInvitation=1&tplid=1', 128 + path: '/pages/customer/index?id=' + this.id + '&fromid=' + getApp().openid + '&invite_name=' + nickname + '&hasInvitation=1&tplid=1',
124 imageUrl: this.tpls[0].shareImage, 129 imageUrl: this.tpls[0].shareImage,
125 } 130 }
126 - if(hasInvitation){ 131 + if (hasInvitation) {
127 //obj.title=(nickname || '') + '给你发了一个邀请函,点击查看'; 132 //obj.title=(nickname || '') + '给你发了一个邀请函,点击查看';
128 - obj.path=obj.path+'&hasInvitation=1'; 133 + obj.path = obj.path + '&hasInvitation=1';
129 } 134 }
130 return obj; 135 return obj;
131 }, 136 },
132 - cookbook(){  
133 - if(this.data.detail.order && this.data.detail.order.cookbooklist.length>0){ 137 + cookbook() {
  138 + if (this.data.detail.order && this.data.detail.order.cookbooklist.length > 0) {
134 wx.navigateTo({ 139 wx.navigateTo({
135 - url:util.http_build_query({rid:this.id,oid:this.data.detail.order.id,identity:1},'/pack-cookbook/pages/success') 140 + url: util.http_build_query({
  141 + rid: this.id,
  142 + oid: this.data.detail.order.id,
  143 + identity: 1
  144 + }, '/pack-cookbook/pages/success')
136 }); 145 });
137 - }else{ 146 + } else {
138 App.Advance.CreateOrder({ 147 App.Advance.CreateOrder({
139 - rid:this.id,  
140 - openid:getApp().openid,  
141 - }).then(res=>{  
142 - if(res.ret!=200){  
143 - return util.toast(res.msg,'none') 148 + rid: this.id,
  149 + openid: getApp().openid,
  150 + }).then(res => {
  151 + if (res.ret != 200) {
  152 + return util.toast(res.msg, 'none')
144 } 153 }
145 wx.navigateTo({ 154 wx.navigateTo({
146 - url:util.http_build_query({rid:this.id,oid:res.data.id,identity:1,sid:res.data.sellerid},'/pack-cookbook/pages/index') 155 + url: util.http_build_query({
  156 + rid: this.id,
  157 + oid: res.data.id,
  158 + identity: 1,
  159 + sid: res.data.sellerid
  160 + }, '/pack-cookbook/pages/index')
147 }); 161 });
148 }) 162 })
149 } 163 }
150 164
151 }, 165 },
152 - wineGo(){  
153 - util.toast('本区域暂无配送人员','none'); 166 + wineGo() {
  167 + util.toast('本区域暂无配送人员', 'none');
  168 + },
  169 + callSeller(){
  170 + let seller_tel=this.data.detail.seller.seller_tel
  171 + if(seller_tel.length<1) return util.toast('商家电话错误','none')
  172 + if(seller_tel.length==1){//只有一个电话
  173 + let phone=seller_tel[0].replace(/[^\d]/,'')
  174 + wx.makePhoneCall({
  175 + phoneNumber:phone
  176 + })
  177 + }else{
  178 + this.selectComponent('#as').show();
  179 + }
  180 + },
  181 + callSellerPhone(e){
  182 + if(e.detail.value){
  183 + let phone=e.detail.value.replace(/[^\d]/,'')
  184 + wx.makePhoneCall({
  185 + phoneNumber:phone
  186 + })
  187 + }
154 }, 188 },
155 }) 189 })
@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 "manager": "/components/manager/manager", 8 "manager": "/components/manager/manager",
9 "nav":"/components/nav/nav", 9 "nav":"/components/nav/nav",
10 "card":"/components/seller-card/seller-card", 10 "card":"/components/seller-card/seller-card",
11 - "formids":"/components/formids/formids" 11 + "formids":"/components/formids/formids",
  12 + "as":"/components/actionSheet/index"
12 } 13 }
13 } 14 }
@@ -59,7 +59,7 @@ @@ -59,7 +59,7 @@
59 </block> 59 </block>
60 60
61 <view style="height: 40rpx;"></view> 61 <view style="height: 40rpx;"></view>
62 - <card seller="{{detail.seller}}" detail="{{detail}}"></card> 62 + <card seller="{{detail.seller}}" detail="{{detail}}" hasOnlineReserve="{{hasOnlineReserve}}"></card>
63 <view class="detail-info Medium" style="margin-top: 56rpx;"> 63 <view class="detail-info Medium" style="margin-top: 56rpx;">
64 <view class="flex-lr"> 64 <view class="flex-lr">
65 <view>预订人</view> 65 <view>预订人</view>
@@ -94,14 +94,13 @@ @@ -94,14 +94,13 @@
94 <image src="http://qn.colorcun.com/custom/lite-yd/image/click.png" class="more"></image> 94 <image src="http://qn.colorcun.com/custom/lite-yd/image/click.png" class="more"></image>
95 </view> 95 </view>
96 </formids> 96 </formids>
97 - <view class="detail-info Medium">  
98 - <view class="flex-lr">  
99 - <view>退订政策</view>  
100 - </view>  
101 - <view class="flex-lr" style="margin-top: 43rpx;">  
102 - <view>免费退订,已提前点菜,交押金,无法退订</view> 97 + <view class="detail-info Medium tuiding">
  98 + <view class="flex-rr">
  99 + <view class="item" bindtap="callSeller">联系商家</view>
  100 + <view class="item" bindtap="callSeller">取消预订</view>
103 </view> 101 </view>
104 </view> 102 </view>
105 <view style="height: 50rpx;"></view> 103 <view style="height: 50rpx;"></view>
106 </view> 104 </view>
107 -<manager manager="{{detail}}" id="manager"></manager>  
  105 +<manager manager="{{detail}}" id="manager"></manager>
  106 +<as id="as" items="{{detail.seller.seller_tel}}" bindclick="callSellerPhone">拨打电话</as>
@@ -125,4 +125,11 @@ @@ -125,4 +125,11 @@
125 width: 44rpx; 125 width: 44rpx;
126 height: 30rpx; 126 height: 30rpx;
127 margin-left: 10rpx; 127 margin-left: 10rpx;
  128 +}
  129 +.tuiding{
  130 + font-size: 30rpx;
  131 +}
  132 +.tuiding .item{
  133 + margin-left: 40rpx;
  134 + text-decoration: underline;
128 } 135 }