menu.js
2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import App from '../../utils/api';
import util from '../../utils/util'
Component({
data:{
menuhidden:true,
customer_activity:'',
url:'pages/reserve/index_new',
},
attached: function() {
this.setStatus();
this.getuser();
this.getautomenu();
this.getorder();
this.getCheckUserHavePhone()
},
methods:{
// 检测用户是否绑定手机号
getCheckUserHavePhone() {
App.Wechat.CheckUserHavePhone({
openid: getApp().openid,
}).then((json) => {
if (json.ret == 200) {
let data = json.data;
let phone = (data && data.phone) ? data.phone : '';
this.getlist(phone)
}
})
},
//获取用户未使用优惠券列表数量
getlist(phone) {
let params = {
openid: getApp().openid,
}
if(phone) params.phone = phone
App.Activity.GetNewRechargeListByOpenid({...params}).then((res) => {
if (res.ret == 200) {
let list = res.data;
list = list.filter(item => {
return (item.recharge_name || item.aname)
})
this.setData({
'customer_activity': list.length,
})
}
})
},
getuser(){
App.User.GetBalance().then(res=>{
this.setData({
user:res.data
})
})
},
getorder(){
App.Reserve.GetReserveIsConsume().then((json)=>{
if(json.ret==200){
console.log('787878',json.data)
this.setData({
haveorder:json.data.is_customer==1 || json.data.is_manager==1
})
}
})
},
getautomenu(){
App.Foodset.GetUserFoodOrders({
status:2,//tabType,
openid: getApp().openid,
offset:1,
limit:1,
size:1,
}).then(res=>{
console.log(res)
if(res.data.length>0){
this.setData({
shownotice:true
})
}
})
},
showmenu(){
this.setData({
menuhidden:false
})
},
hidemenu(){
this.setData({
menuhidden:true
})
},
topage(e){
let url=e.currentTarget.dataset.path;
wx.navigateTo({
url:url
})
},
topagerelunch(e){
let url=e.currentTarget.dataset.path;
wx.reLaunch({
url:url
})
},
tosearch(e){
let url=e.currentTarget.dataset.path;
wx.navigateTo({
url:url
})
},
gotoList(e){
getApp().meListType=e.currentTarget.dataset.type;
wx.redirectTo({
url:'/pages/me/list?type='+e.currentTarget.dataset.type
})
},
setStatus(){
let pages = getCurrentPages();
let p = pages[pages.length - 1];
console.log('custom-tab-bar.setStatus',p.route)
this.setData({
url:p.route,
})
},
}
})