info.js
3.42 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
//商家管理
'use strict';
var $ = require('jquery'),
Handlebars = require('yoho.handlebars');
var dropDown=require('../common/dropDown');
require('../util/jquery.gritter');
var grid=require('../common/grid');
var edit=require('../common/edit');
exports.init=function(){
$('.urlAdd').on('click',function(){
var type = $(this).data('type'),
inputAdd = '';
switch(type)
{
case 0:
inputAdd = '<input type="text" name="homepage" class="form-control" style="margin-top:15px;" placeholder="官方网址">';
break;
case 1:
inputAdd = '<input type="text" name="homeurl" class="form-control" style="margin-top:15px;" placeholder="其他平台网址">';
break;
case 2:
inputAdd = '<input type="text" name="homeaddresslist" class="form-control" style="margin-top:15px;" placeholder="代表实体店">';
break;
}
$('.Add').eq(type).append(inputAdd);
});
new dropDown({el:"#store-type"});
new dropDown({el:"#store-model"});
new dropDown({el:"#brand-name",ajax:"brand"});
$('#addBrand').on('click',function(){
var storeModel = $('#store-model').val();
if(storeModel==1&&$('#updateBrand tbody tr').length<1){
$('#savebrand .checkbox').each(function(){
if($(this).prop('checked')){
var check = $(this).closest('tr').html();
var brand=check.split('<td>')[check.split('<td>').length-2];
var supplier=check.split('<td>')[check.split('<td>').length-1];
var table = '<tr><td>'+brand+'<td>'+supplier+'<td><button type="button" class="btn btn-danger btn-xs">删除</button></td></tr>'
$('#updateBrand tbody').append(table);
}
})
}else{
$('#savebrand .checkbox').each(function(){
if($(this).prop('checked')){
var check = $(this).closest('tr').html();
var brand=check.split('<td>')[check.split('<td>').length-2];
var supplier=check.split('<td>')[check.split('<td>').length-1];
var table = '<tr><td>'+brand+'<td>'+supplier+'<td><button type="button" class="btn btn-danger btn-xs">删除</button></td></tr>'
$('#updateBrand tbody').append(table);
}
})
}
});
var e=new edit("#storeForm");
e.on("validate",function(){
});
var submit=function(callback){
e.submit('/store/add',function(option){
option.success=function(res){
console.log(res.data.code);
if(res.data.code=="200"){
// location.href="/supplier/store/index";
}else{
e.$tip("提交失败");
}
return false;
},
option.error=function(res){
e.$tip("提交失败");
}
callback&&callback(option.data);
});
}
$("#btn1").click(function(){
var homepage=$("input[name='homepage']");
var hplist=[];
homepage.each(function(index){
hplist.push(homepage[index].value);
})
var homeurl=$("input[name='homeurl']");
var homeurlist=[];
homeurl.each(function(index){
homeurlist.push(homepage[index].value);
})
var homeaddress=$("input[name='homeaddresslist']");
var homeaddresslist=[];
homeaddress.each(function(index){
homeaddresslist.push(homeaddress[index].value);
})
submit(function(data){
data.websiteUrl=hplist.toString();
data.otherUrl=homeurlist.toString();
data.shopAddress=homeaddresslist.toString();
data.onCheck=1;
});
return false;
});
}