Commit 883d3be8c29e6e20c063045387fb47b0dcd4e1c7

Authored by vking
1 parent cf331da5

subscribe

  1 +// component/menu/addDelete.js
  2 +import util from '../../utils/util';
  3 +import App from '../../utils/api';
  4 +const subscribe=[
  5 + 'LjNlk6OAhMcfC5i9f6IHM2HFhr3aWcTvAMiXczTkXtk',//测试 预约通知
  6 +]
  7 +Component({
  8 + /**
  9 + * 组件的属性列表
  10 + */
  11 + properties: {
  12 + ids:{
  13 + type:Array,
  14 + value:subscribe.keys()
  15 + }
  16 + },
  17 +
  18 + /**
  19 + * 组件的初始数据
  20 + */
  21 + data: {
  22 +
  23 + },
  24 + attached(){
  25 +
  26 + },
  27 + ready () {
  28 +
  29 + },
  30 + detached(){
  31 +
  32 + },
  33 + observers: {
  34 + ids:function(){
  35 + console.log('this.data.ids',this.data.ids)
  36 + this.subscribeIds=[];
  37 + this.data.ids.forEach(i=>{
  38 + this.subscribeIds.push(subscribe[i])
  39 + })
  40 + },
  41 + },
  42 + /**
  43 + * 组件的方法列表
  44 + */
  45 + methods: {
  46 + subscribe(){
  47 + console.log('subscribe',this.subscribeIds)
  48 + wx.requestSubscribeMessage({
  49 + tmplIds:this.subscribeIds,
  50 + success:res=>{
  51 + console.log('wx.requestSubscribeMessage.success',res)
  52 + let accept=[]
  53 + this.subscribeIds.forEach(id=>{
  54 + if(res[id]=='accept'){
  55 + accept.push(id)
  56 + }
  57 + })
  58 + if(accept.length>0){
  59 + util.toast('订阅成功','none')
  60 + setTimeout(()=>{
  61 + App.Wechat.Subscribe({
  62 + tplid:accept.toString()
  63 + })
  64 + },3000)
  65 + }else{
  66 + util.toast('订阅失败,请在设置中打开','none')
  67 + }
  68 + },
  69 + fail:(efail)=>{
  70 + console.log('wx.requestSubscribeMessage.fail',efail)
  71 + wx.showModal({
  72 + title: '授权提示',
  73 + content: '您拒绝了订阅消息,请点击确定打开授权',
  74 + confirmColor: '#199095',
  75 + cancelColor: '#999',
  76 + success: function (res) {
  77 + if (res.confirm) {
  78 + util.setting();
  79 + }
  80 + }
  81 + })
  82 + },
  83 + })
  84 + },
  85 + }
  86 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
  1 +<view bindtap="subscribe" style="width: 100%;">
  2 + <slot></slot>
  3 +</view>
  1 +@import "../../app.wxss";
@@ -33,14 +33,14 @@ Page({ @@ -33,14 +33,14 @@ Page({
33 * 生命周期函数--监听页面初次渲染完成 33 * 生命周期函数--监听页面初次渲染完成
34 */ 34 */
35 onReady: function () { 35 onReady: function () {
36 - 36 + this.selectComponent('#getpos').getPos();
37 }, 37 },
38 38
39 /** 39 /**
40 * 生命周期函数--监听页面显示 40 * 生命周期函数--监听页面显示
41 */ 41 */
42 onShow: function () { 42 onShow: function () {
43 - this.selectComponent('#getpos').getPos(); 43 + this.getDetail()
44 }, 44 },
45 45
46 /** 46 /**
@@ -64,6 +64,19 @@ Page({ @@ -64,6 +64,19 @@ Page({
64 console.log('onShareAppMessage', arguments) 64 console.log('onShareAppMessage', arguments)
65 return this.shareSetting(e); 65 return this.shareSetting(e);
66 }, 66 },
  67 + getDetail(){
  68 + App.Reserve.Detail({
  69 + openid: getApp().openid,
  70 + rid: this.id
  71 + }).then(res => {
  72 + this.detail=this.formatDatail(res.data)
  73 + this.detail.ddate_solt=Number(this.detail.ddate_solt);
  74 + this.setData({
  75 + detail: this.detail,
  76 + hasOnlineReserve:res.data.type==1,
  77 + })
  78 + })
  79 + },
67 formatDatail(detail) { 80 formatDatail(detail) {
68 detail.rdateStr = util.unixtoTime(detail.ddate, 'MM月DD日 WW HH:II'); 81 detail.rdateStr = util.unixtoTime(detail.ddate, 'MM月DD日 WW HH:II');
69 detail=RS.reserve(detail); 82 detail=RS.reserve(detail);
@@ -212,20 +225,14 @@ Page({ @@ -212,20 +225,14 @@ Page({
212 onpos(e){ 225 onpos(e){
213 console.log('onpos',e); 226 console.log('onpos',e);
214 this.location=e.detail 227 this.location=e.detail
215 - App.Reserve.Detail({  
216 - openid: getApp().openid,  
217 - rid: this.id  
218 - }).then(res => {  
219 - let detail=this.formatDatail(res.data)  
220 - detail.ddate_solt=Number(detail.ddate_solt);  
221 - this.setData({  
222 - detail: detail,  
223 - hasOnlineReserve:res.data.type==1,  
224 - })  
225 - if(detail.type==1 && detail.status==6){  
226 - this.GetRecommendSellerList(detail.seller.id)  
227 - }  
228 - }) 228 + if(!this.detail){
  229 + return setTimeout(()=>{
  230 + this.onpos(e)
  231 + },500)
  232 + }
  233 + if(this.detail.type==1 && this.detail.status==6){
  234 + this.GetRecommendSellerList(this.detail.seller.id)
  235 + }
229 }, 236 },
230 gotoSellerDetail(e){ 237 gotoSellerDetail(e){
231 console.log(e) 238 console.log(e)
@@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
11 "formids":"/components/formids/formids", 11 "formids":"/components/formids/formids",
12 "sb-tr":"/components/reserve/seller-box-transverse/seller-box", 12 "sb-tr":"/components/reserve/seller-box-transverse/seller-box",
13 "getpos":"/components/userinfo/getpos", 13 "getpos":"/components/userinfo/getpos",
14 - "as":"/components/actionSheet/index" 14 + "as":"/components/actionSheet/index",
  15 + "subscribe": "/components/userinfo/subscribe"
15 } 16 }
16 } 17 }
@@ -26,8 +26,13 @@ @@ -26,8 +26,13 @@
26 <view class="icon"> 26 <view class="icon">
27 <icon type="waiting" size="47" color="#C8B16D"/> 27 <icon type="waiting" size="47" color="#C8B16D"/>
28 </view> 28 </view>
29 - <view class="title Medium">餐厅处理中</view>  
30 - <view class="info" wx:if="{{firstShowMsg}}">{{firstShowMsg}}</view> 29 + <view class="title Medium">{{firstShowMsg.length>10?'餐厅处理中':'餐厅休息中'}}</view>
  30 + <view class="info" wx:if="{{firstShowMsg}}">
  31 + {{firstShowMsg.length>10?firstShowMsg:'营业后将优先处理您的订单,预计早上'+firstShowMsg+'左右短信告知预订结果'}}
  32 + </view>
  33 + <subscribe class="flex-lr share-view subscribe" ids="{{[0]}}">
  34 + <view class="share-but">提醒我包间预订结果</view>
  35 + </subscribe>
31 </block> 36 </block>
32 <block wx:elif="{{detail.status==6}}"> 37 <block wx:elif="{{detail.status==6}}">
33 <view class="icon"> 38 <view class="icon">
@@ -78,7 +83,6 @@ @@ -78,7 +83,6 @@
78 </userinfo> 83 </userinfo>
79 </view> 84 </view>
80 </block> 85 </block>
81 -  
82 <view style="height: 40rpx;"></view> 86 <view style="height: 40rpx;"></view>
83 <card seller="{{detail.seller}}" detail="{{detail}}" bindevent="cardEvent"></card> 87 <card seller="{{detail.seller}}" detail="{{detail}}" bindevent="cardEvent"></card>
84 <view class="detail-info Medium" style="margin-top: 56rpx;"> 88 <view class="detail-info Medium" style="margin-top: 56rpx;">
@@ -19,6 +19,8 @@ @@ -19,6 +19,8 @@
19 margin-bottom: 26rpx; 19 margin-bottom: 26rpx;
20 } 20 }
21 .success .info{ 21 .success .info{
  22 + box-sizing: border-box;
  23 + padding: 0 5%;
22 font-size: 26rpx; 24 font-size: 26rpx;
23 color:#999999 25 color:#999999
24 } 26 }
@@ -155,4 +157,7 @@ @@ -155,4 +157,7 @@
155 .transverse-list .seller{ 157 .transverse-list .seller{
156 width: 98%; 158 width: 98%;
157 margin: 0 auto; 159 margin: 0 auto;
  160 +}
  161 +.share-view.subscribe{
  162 + margin-top: 24rpx;
158 } 163 }
@@ -6,7 +6,7 @@ import DA from './data'; @@ -6,7 +6,7 @@ import DA from './data';
6 import reddot from '../../utils/reddot'; 6 import reddot from '../../utils/reddot';
7 import PubSub from '../../utils/PubSub' 7 import PubSub from '../../utils/PubSub'
8 const {regeneratorRuntime} = global 8 const {regeneratorRuntime} = global
9 -const mapScale=14.9//18; 9 +const mapScale=15//18;
10 const transverseViewHeight=235; 10 const transverseViewHeight=235;
11 const renNum=function(){ 11 const renNum=function(){
12 let arr=[] 12 let arr=[]
@@ -164,9 +164,9 @@ Page({ @@ -164,9 +164,9 @@ Page({
164 if(this.data.user.remark!=''){ 164 if(this.data.user.remark!=''){
165 this.setremark(); 165 this.setremark();
166 } 166 }
167 - let firstShowMsg='餐厅一般会在10分钟内为您反馈结果,请留意短信或微信通知' 167 + let firstShowMsg='预计10分钟左右餐厅将告知您结果(请留意短息或微信通知)'
168 if(!this.hasInWorkTime()){//非营业时间预订 168 if(!this.hasInWorkTime()){//非营业时间预订
169 - firstShowMsg='商家未上班,上班后将第一时间告知您预订结果,请留意短信/微信通知(上班时间:'+this.data.seller.rec_stime+'—'+this.data.seller.rec_etime+')' 169 + firstShowMsg=this.data.seller.rec_stime
170 } 170 }
171 wx.removeStorageSync('remark') 171 wx.removeStorageSync('remark')
172 wx.redirectTo({ 172 wx.redirectTo({
@@ -483,7 +483,7 @@ @@ -483,7 +483,7 @@
483 "id": 57, 483 "id": 57,
484 "name": "pages/customer/detail_owner", 484 "name": "pages/customer/detail_owner",
485 "pathName": "pages/customer/detail_owner", 485 "pathName": "pages/customer/detail_owner",
486 - "query": "id=33347&hasFirstShow=1", 486 + "query": "id=33347&firstShowMsg=1111",
487 "scene": null 487 "scene": null
488 }, 488 },
489 { 489 {
@@ -414,5 +414,11 @@ export default { @@ -414,5 +414,11 @@ export default {
414 //写入快速备注 414 //写入快速备注
415 'App.Customer.SetUserRemarkes':{ 415 'App.Customer.SetUserRemarkes':{
416 openid:'openid', 416 openid:'openid',
417 - } 417 + },
  418 +
  419 + //订阅消息
  420 + 'App.Wechat.Subscribe':{
  421 + openid:'openid',
  422 + },
  423 +
418 } 424 }