service-add.js
2.9 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
define(function( require, exports, module ) {
/*
引入包
*/
var _Mcity = require( 'mcity' ); //城市信息
require( 'datepicker' ); // 日历
$(function(){
/*日期选择*/
$( '.m-input-date' ).datepicker({
todayHighlight: true,
autoclose: true,
todayHighlight:true
});
/*
商品产地数据读取
*/
$( '.m-city' ).on( 'click' ,function(){
new _Mcity( this , {});
});
//添加代购商品
var g_num = 1;
$( '#add-more' ).on( 'click' ,function(){
_html = $('<ul class="m-table-view">\
<li class="cell">\
<span class="title group-title">代购商品'+ (++g_num) +'</span><span class="remove-icon"></span>\
</li>\
<li class="cell">\
<span class="title">商品名称<input type="text" class="m-input" placeholder="请输入商品名称"></span>\
</li>\
<li class="cell">\
<span class="title">代购总量<input type="number" class="m-input" value="1000"></span>\
<span class="m-select">\
<span class="select-text">公斤</span>\
<select>\
<option value="0" selected="selected">公斤</option>\
<option value="1">斤</option>\
<option value="2">顿</option>\
<option value="3">盒</option>\
<option value="4">袋</option>\
</select>\
</span>\
</li>\
<li class="cell">\
<span class="title">代购单价<input type="number" class="m-input"></span>\
<span class="text">(元/公斤)</span>\
</li>\
<li class="cell acc-icon">\
<span class="title">商品产地</span><span class="text transition-btn m-city" elem="#filter-area">请选择</span>\
</li>\
<li class="cell acc-icon">\
<span class="title">截止时间</span>\
<span class="text"><input type="text" class="m-input m-input-date" readonly placeholder="选择时间" data-date-format="yyyy-mm-dd" data-date-start-date="Date.default"></span>\
</li>\
</ul>');
_html.insertBefore( $( this ).parent() );
// 删除
$( '.remove-icon' ).on( 'click' ,function(){
$( this ).parents( '.m-table-view' ).remove();
});
// 日期选择
$( '.m-input-date' ).datepicker({
todayHighlight: true,
autoclose: true,
todayHighlight:true
});
// select 交互
$( '.m-select select' ).on('change',function(){
$( this ).parent().find( '.select-text' ).text( $( this ).find( 'option:selected' ).text() );
});
//商品产地数据读取
$( '.m-city' ).on( 'click' ,function(){
new _Mcity( this, {});
});
//页面切换效果
$( '.transition-btn' ).on( 'click' , function(){
$( $( this ).attr( 'elem' ) ).addClass( 'show' );
// $( '.transition-content' ).css( 'display' , 'block' );
});
$( '.transition-close' ).on( 'click' , function(){
$( $( this ).attr( 'elem' ) ).removeClass( 'show' );
});
});
});
});