s_cook.js
4.01 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
124
125
126
127
128
129
130
131
132
var util = require('../../utils/util.js')
var uri=require('../../utils/uri.js')
Page({
data:{
alllist:[
{
title:'快餐适用菜谱',
isshow:false,
list:[
{
id:1,
name:'我的菜品',
count:40,
isselect:true
},
// {
// id:2,
// name:'外卖',
// count:110,
// isselect:false
// }
]
},
{
title:'菜单样式',
isshow:false,
list:[
{
id:2,
name:'图文菜单',
isselect:false,
imgurl:'../image/menu1.svg'
},
{
id:1,
name:'双图菜单',
isselect:true,
imgurl:'../image/menu2.svg'
}
]
},
]
},
onLoad:function(){
wx.setNavigationBarTitle({
title:'菜谱及样式'
})
this.setData({
sellerid:util.cache('sellerid')
})
},
onShow:function(){
var that=this;
this.dcdetail();
util.postSuccessFun=function(json,uri_code){
switch(uri_code){
case uri.CGI__USER_GETSELLERCONFIG__CODE:
if(json.ret==200 && json.data[0]!=''){
var template=json.data[0][0].is_set_template ? json.data[0][0].is_set_template.status : 1;
console.log(template)
var alllist=that.data.alllist;
alllist.forEach(function(v,i){
if(i==1){
v.list.forEach(function(r,n){
r.isselect=false;
if(r.id==template){
r.isselect=true
}
})
}
})
that.setData({
alllist:alllist
})
}
break;
case uri.CGI__USER_SETSELLERCONFIG__CODE:
if(json.ret==200){
console.log(json)
that.dcdetail();
}
break;
}
}
},
setting:function(e){
var index=e.currentTarget.dataset.id;
var list=this.data.alllist;
list.forEach(function(v,i){
if(index==i){
v.isshow=!v.isshow
}
})
this.setData({
alllist:list
})
},
dcdetail:function(){
util.post(uri.CGI__USER_GETSELLERCONFIG,{sellerid:this.data.sellerid,type:4},uri.CGI__USER_GETSELLERCONFIG__CODE)
},
singleselect:function(e){
var id=e.currentTarget.dataset.id;
var index=e.currentTarget.dataset.index;
var list=this.data.alllist;
list.forEach(function(v,i){
if(i==index){
v.list.forEach(function(r,n){
r.isselect=false;
if(r.id==id){
r.isselect=true
}
})
}
})
this.setData({
alllist:list
})
if(index==1){
var data={
sellerid:this.data.sellerid,
type:4,
is_set_template:id
}
util.post(uri.CGI__USER_SETSELLERCONFIG,data,uri.CGI__USER_SETSELLERCONFIG__CODE)
}
},
netchange:function () {
this.onShow()
}
})