user-release-of-goods.js
7.03 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
define(function( require, exports, module ) {
require( 'region' );
require( 'dragsort' );
require( 'jqueryUI' );
require( 'fancybox' );
require( 'validate' );
require( 'validate.extend' );
var _SalesData = require( 'SalesData' ),
_Jselect = require( 'jselect' );
_Pophint = require( 'pophint' );
$(function(){
var methods = {
updateunm : function(view){
var mun = 0;
$("#"+view+" .available").each(function(){
var value = $(this).val();
console.log(value);
if(value && !isNaN(value)){
mun += parseInt($(this).val());
};
});
return mun;
},
updateunit : function(){
var unit = $("#unit").find("option:selected").length > 0 ? $("#unit").find("option:selected").text() : $("#unit").text();
this.unit = unit;
$(".t-unit").html(unit);
},
unit : "斤"
};
region.start();
$(".certification .certification-img").fancybox({
padding : 0
});
$("#add-certification .add-mbox").click(function(){
$.fancybox.close();
});
$(".my-list p").click(function(){
$(this).next().slideToggle();
});
$(".release-stairs").draggable();
//初始化
methods.updateunit();
//业务逻辑区
//添加报价区间
var priceTable = $("#purchases tbody");
$(".addbtn").click(function(){
var pkey = '<tr><td>购买:<input type="text"><span class="jian">'+methods.unit+'</span>以上</td><td><input type="text">元/<span class="jian">'+methods.unit+'</span>'
+'<span class="delete a-link">删除</span></td></tr>';
if($("#purchases tbody tr").length < 3){
priceTable.append(pkey);
};
});
$("#purchases .delete").live("click", function(){
if($("#purchases tbody tr").length > 1){
$(this).parent().parent().remove();
};
});
//设置商品属性选择
var sales1 = new _SalesData({
'rootView':'#transaction-set',
'showView':'#describe',
'radioNmae':'#unit'
})
sales1.event("change", function(){
methods.updateunit();
});
sales1.eachData();
var sales2 = new _SalesData({
'rootView':'#transaction-set',
'showView':'#interval',
'radioNmae':'#unit',
res : [
{"class" : "price", "dilipattern" : "/^[0-9]+$/,可售量有误!", "value" : 0}
]
});
sales2.event("change", function(){
methods.updateunit();
});
sales2.eachData();
//报价方式
$("input[name='pricetype']").change(function(){
if($(this).val() == "false"){
$(".interval-view").show();
$(".specifications-view").hide();
sales2.changeData();
}else{
$(".interval-view").hide();
$(".specifications-view").show();
sales1.changeData();
};
});
//图片切换
$(".s-ntab li").click(function(){
$(".s-ntab li a").removeClass("current");
$(this).find("a").addClass("current");
$(".s-ntab-content").hide();
$(".s-ntab-content").eq($(this).index()).show();
return false;
});
//楼梯
$(".icon-stairs-colse").click(function(){
$(".release-stairs").hide();
});
//认证
$(".img-remove").click(function(){
$(this).parents('li').remove();
});
//拖动
$("#user-list").dragsort({ dragSelector: "span", dragBetween: true, dragEnd: function(){
}});
//楼层跳转
$(".release-stairs li").click(function(){
var view = $(".form-box").eq($(this).index());
var $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
var distance = view.offset().top;
$body.stop().animate({scrollTop: distance}, 800);
});
$(".release-stairs .top").click(function(){
var $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
$body.stop().animate({scrollTop: 0}, 800);
});
$(".certification-img").hover(function(){
if($(this).find("img").attr("src") == ""){
$(this).next().hide();
}else{
$(this).next().show();
};
});
$(".available").live("change", function(){
var getnum = 0;
if($('input[name="pricetype"]:checked').val() == "true"){
getnum = methods.updateunm("describe");
}else{
getnum = methods.updateunm("interval");
};
$(".sell-num").html(getnum+""+methods.unit);
});
require.async(['validate.extend'], function() {
$( '.s-form' ).validate({
});
});
//自动生成标题弹框
$( "#auto-title" ).click(function(){
new _Pophint( this,{
operation: function( target ){
//确定要执行的操作
},
content: "你确定取消吗?",
showButton: false
});
});
/* 模拟下拉列表 */
$( '.sea-select' ).each( function(){
new _Jselect( this , {
searchBar:true
});
});
//新增子分类
$( '#c-nav-add' ).click(function(){
var _html = $('<div class="c-nav-box">\
<select class="sea-select categoryItem" data-pid="0">\
<option value="">请选择分类</option>\
</select>\
<span class="submitBtn grayBtn c-nav-rmove">删除</span>\
</div>');
$( _html ).insertBefore( $( this ) );
new _Jselect( $( _html ).find( '.sea-select' )[0] , {
searchBar:true
});
});
//自定义
$( '.c-info' ).change(function(){
if( $( this ).is( ':checked' ) ){
$( '#'+$( this ).attr('cdata') ).show();
}else{
$( '#'+$( this ).attr('cdata') ).hide();
}
});
});
});