cb_fadd.js
2.58 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
//logs.js
var util = require('../../utils/util.js')
var uri=require('../../utils/uri.js')
Page({
data: {
},
onLoad:function(opt){
var that=this;
console.log('opt:',opt);
util.setBarTitle('添加菜品')
this.setData({
classid:opt.cid ? opt.cid : '',
sellerid: util.cache("sellerid"),
url:opt.url ? opt.url : null
})
wx.removeStorage({key:'cook_name'})
},
onShow:function(){
console.log(util.cache("cook_name"))
this.setData({
cook_name:util.cache("cook_name") ? util.cache("cook_name") : '',
reminderInfo:null,
})
var that=this;
util.postSuccessFun=function(json,uri_code) {
switch (uri_code) {
case uri.CGI__USER_GETCOOKBOOKISEXITS__CODE:
if(json.ret==200){
if(json.data[0]==true){
that.setData({
reminderInfo:'该菜品已存在'
})
}else{
if(that.data.url){
wx.navigateTo({
url: 'cb_sadd?url='+that.data.url,
})
}else{
wx.navigateTo({
url: 'cb_sadd?cid='+that.data.classid,
})
}
}
}
break
}
}
},
//设置缓存数据
setCatchdate:function(e) {
var cook_name;
cook_name = e;
util.cache("cook_name",cook_name);
},
//记录输入信息
cooknameInput:function(e){
var cook_name=''
if(e.detail.keyCode==32){
cook_name=e.detail.value.slice(0,-1);
}else{
cook_name = e.detail.value
}
this.setData({
cook_name:cook_name,
reminderInfo:cook_name!='' ? null : '请输入菜品名'
})
},
nextStep:function(){
console.log(this.data.cook_name)
if(this.data.cook_name!=''){
this.setCatchdate(this.data.cook_name);
util.post(uri.CGI__USER_GETCOOKBOOKISEXITS,{sellerid:this.data.sellerid,name:this.data.cook_name},uri.CGI__USER_GETCOOKBOOKISEXITS__CODE);
}else{
this.setData({
reminderInfo:'请输入菜品名'
})
}
},
netchange:function(){
this.onShow();
}
});