Blame view

src/main/webapp/WEB-INF/pages/monthpay.html 13.5 KB
e80df919   atao   init
1
2
3
  <!DOCTYPE html>
  <html lang="en">
  <head>
1b8be02a   atao   修改购买卡时的费用
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
      <meta charset="UTF-8">
      <title>月卡支付</title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
      <meta name="format-detection" content="telephone=no"/>
      <meta name="format-detection" content="email=no"/>
      <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
      <meta name="apple-mobile-web-app-capable" content="yes"/>
      <meta name="apple-mobile-web-app-title" content="">
      <meta name="google" value="notranslate"><!-- 禁止Chrome 浏览器中自动提示翻译 -->
      <link rel="apple-touch-icon-precomposed" href="favicon.ico">
      <link rel="shortcut icon" href="favicon.ico">
      <link rel="Bookmark" href="favicon.ico">
      <link rel="stylesheet" href="//cdn.bootcss.com/weui/1.1.1/style/weui.min.css">
      <link rel="stylesheet" href="//cdn.bootcss.com/jquery-weui/1.0.1/css/jquery-weui.min.css">
      <link rel="stylesheet" href="${staticHost}/css/reset.css">
      <link rel="stylesheet" href="${staticHost}/css/monthpay.min.css">
e80df919   atao   init
20
21
22
  </head>
  <body ontouchstart>
  <div class="weui-cells weui-cells_form">
1b8be02a   atao   修改购买卡时的费用
23
24
25
26
27
28
      <input type="hidden" id="parkLotCardId" value="${parkLotCardId!''}"/>
      <div class="weui-cell">
          <div class="weui-cell__hd"><label class="weui-label">车牌号</label></div>
          <div class="weui-cell__bd">
              <input class="weui-input" type="text" value="" maxlength="7" placeholder="请输入车牌号,必填" id="license_number">
          </div>
e80df919   atao   init
29
      </div>
1b8be02a   atao   修改购买卡时的费用
30
31
32
33
34
      <div class="weui-cell">
          <div class="weui-cell__hd"><label class="weui-label">卡类别</label></div>
          <div class="weui-cell__bd" id="cardTypeRemark">
              <!--  蓝牌小车包月卡-->
          </div>
e80df919   atao   init
35
      </div>
e80df919   atao   init
36
37
38
  </div>
  
  <div class="weui-cells weui-cells_form">
1b8be02a   atao   修改购买卡时的费用
39
40
41
42
      <div class="weui-cell">
          <div class="weui-cell__hd"><label class="weui-label">停车场</label></div>
          <input type="hidden" id="parkLotCode"/>
          <div class="weui-cell__bd" id="parkLotName"></div>
e80df919   atao   init
43
      </div>
1b8be02a   atao   修改购买卡时的费用
44
45
46
47
48
49
50
      <div class="weui-cell">
          <div class="weui-cell__hd"><label class="weui-label">购买数量</label></div>
          <div class="weui-cell__bd">
              <span id="reduce_btn" class="reduce_btn">-</span><input class="weui-input inpt-num" id="numder" type="text"
                                                                      readonly="" value="1"><span id="add_btn"
                                                                                                  class="add_btn">+</span>
          </div>
e80df919   atao   init
51
      </div>
1b8be02a   atao   修改购买卡时的费用
52
53
54
55
56
57
58
      <div class="weui-cell">
          <div class="weui-cell__hd"><label for="date" class="weui-label">开始时间</label></div>
          <div class="weui-cell__bd">
              <input class="weui-input" id="date" type="text" placeholder="请选择开始时间">
          </div>
          <div class="weui-cell__ft">
          </div>
e80df919   atao   init
59
      </div>
1b8be02a   atao   修改购买卡时的费用
60
61
62
63
64
      <div class="weui-cell">
          <div class="weui-cell__hd"><label for="date1" class="weui-label">有效期至</label></div>
          <div class="weui-cell__bd">
              <input class="weui-input" id="date1" type="text" readonly placeholder="请先选择开始时间">
          </div>
e80df919   atao   init
65
      </div>
1b8be02a   atao   修改购买卡时的费用
66
67
68
69
70
71
      <div class="weui-cell">
          <div class="weui-cell__hd"><label class="weui-label">合计</label></div>
          <input type="hidden" id="cardAmount"/>
          <div class="weui-cell__bd pay-total">
              ¥<span id="totle_money">90</span>
          </div>
e80df919   atao   init
72
      </div>
e80df919   atao   init
73
74
  </div>
  <div class="pay-content-padded">
1b8be02a   atao   修改购买卡时的费用
75
      <a href="javascript:;" class="weui-btn weui-btn_primary" id="pay_btn">提交订单</a>
e80df919   atao   init
76
77
78
79
80
81
  </div>
  <script src="//cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
  <script src="//cdn.bootcss.com/jquery-weui/1.0.1/js/jquery-weui.min.js"></script>
  <script src="${staticHost}/js/jsutil.js"></script>
  <script src="${staticHost}/js/url.js"></script>
  <script type="text/javascript">
1b8be02a   atao   修改购买卡时的费用
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
      var func = {
          //1.初始化页面信息.<br/>
          initMonthCardInfo: function () {
              var parkLotCardId = $('#parkLotCardId').val();
              if (parkLotCardId == null || parkLotCardId == "") {
                  $.alert("系统繁忙,请重新操作!");
                  return false;
              }
              var jsonInfo = {};
              jsonInfo.parkLotCardId = parkLotCardId;
              jsutil.defaultReq(
                  mUrl.queryParkLotCardForChoose,
                  jsonInfo,
                  function (data) {
                      if ("8888" == data.code) {
                          var parkLot = data.data;
                          $('#parkLotName').empty();
                          $('#cardTypeRemark').empty();
                          $('#totle_money').empty();
                          $('#parkLotName').text(parkLot.parkName);
                          $('#parkLotCode').val(parkLot.parkNo);
                          $('#cardTypeRemark').text(parkLot.parkCardCouponsList[0].goods_type_remark);
                          $('#totle_money').text(parkLot.parkCardCouponsList[0].goods_amount);
                          $('#parkLotCardId').val(parkLot.parkCardCouponsList[0].id);
                          $('#cardAmount').val(parkLot.parkCardCouponsList[0].goods_amount);
                      } else {
                          $.alert("系统繁忙,请重新操作!");
                      }
                  });
          }
e80df919   atao   init
112
      };
1b8be02a   atao   修改购买卡时的费用
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
205
206
207
208
209
      $(function () {
          func.initMonthCardInfo();
  
          //当pick的值发生变化的时候
          function pickerOnClose() {
              var inputDateStr = formatDateStr($('#date').val());
              var inputDate = new Date(inputDateStr);
              var inputYear = inputDate.getFullYear();
              var inputMonth = inputDate.getMonth();
              var date = new Date();
              var thisYear = date.getFullYear();
              var thisMonth = date.getMonth();
  
              //当前时间大于选择的时间
              if (thisYear >= inputYear && thisMonth >= inputMonth) {
                  $.toptip('开始时间不能小于下月 1号 ', 'warning');
                  setPickerDefaultValue();
              }
  
              var num = $("#numder").val();
              var startDateStr = $("#date").val();
              var dateStr= formatDateStr(startDateStr);
              handelEndDateAndPrice(num, new Date(dateStr));
  
          }
  
          //设置当前时间默认值
          function setPickerDefaultValue() {
              var date = new Date();
              var year = date.getFullYear() + '年';
              var month = date.getMonth() + 2 + '月';
              if (month.length < 3) {
                  month = '0' + month;
              }
  
              var defaultDate = [year, month, '01日'];
              $("#date").picker("setValue", defaultDate);
  
          }
  
          //初始化时间picker选择器的参数
          function initPickerParam() {
              var onClose = pickerOnClose;
              var years = [];
              var months = ['01月', '02月', '03月', '04月', '05月', '06月', '07月', '08月', '09月', '10月', '11月', '12月'];
  
              var date = new Date();
              var thisYear = date.getFullYear();
              for (var i = 0; i < 10; i++) {
                  years[i] = thisYear + i + '年';
              }
              var param = {};
              param.onClose = onClose;
              param.title = '请选择开始时间';
              var cols = [{"textAlign": 'center', values: years}, {
                  "textAlign": 'center',
                  values: months
              }, {"textAlign": 'center', values: ['01日']}]
              param.cols = cols;
  
              return param;
          }
  
          //选择日期
          $("#date").picker(
              initPickerParam()
          );
  
  
          //根据数量,开始时间计算 结束时间,总价
          function handelEndDateAndPrice(num, startDate) {
              if(typeof num== 'string'){
                  num = parseInt(num);
              }
              //设置数量
              $("#numder").val(num);
              startDate.setMonth(startDate.getMonth() + num);
              startDate.setDate(0)//设置为0,意思为取当前月最后一天
              var year = startDate.getFullYear();
              var month = startDate.getMonth() + 1 + '';
              var day = startDate.getDate() + '';
              if (month.length == 1) {
                  //只有一位,需要补0
                  month = '0' + month;
              }
  
              if (day.length == 1) {
                  //只有一位,需要补0
                  day = '0' + day;
              }
              var endDateStr = year + '年 ' + month + '月 ' + day + '日';
              //设置失效日期
              $('#date1').val(endDateStr);
              //设置总价
              var price = $("#cardAmount").val();
              $("#totle_money").html(num * price);
          }
e80df919   atao   init
210
  
1b8be02a   atao   修改购买卡时的费用
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
  
          //将年月日的日期 格式化成 用 - 间隔的
          function formatDateStr(dateStr) {
              return dateStr.replace('年', '-').replace('月', '-').replace('日', '').replace(' ', '').replace(' ', '');
          }
  
  
          //添加数量
          $("#add_btn").click(function () {
  
              var startDateStr = $("#date").val();
              if (null == startDateStr || startDateStr.length < 1) {
                  $.toptip('请先选择开始时间', 2000, 'warning');
                  return;
              }
              var num = $("#numder").val();
              num++;
              if (num > 1 && num < 6) {
                  var startDate = new Date(formatDateStr(startDateStr));
                  handelEndDateAndPrice(num, startDate);
              } else {
                  $.toptip('最多购买5个月', 2000, 'warning');
              }
  
          });
          //减去数量
          $("#reduce_btn").click(function () {
  
              var startDateStr = $("#date").val();
              if (null == startDateStr || startDateStr.length < 1) {
                  $.toptip('请先选择开始时间', 2000, 'warning');
                  return;
              }
  
              var num = $("#numder").val();
              num--;
              if (num > 0) {
                  var startDate = new Date(formatDateStr($("#date").val()));
                  handelEndDateAndPrice(num, startDate);
e80df919   atao   init
250
              } else {
1b8be02a   atao   修改购买卡时的费用
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
                  $.toptip('最少购买一个月', 2000, 'warning');
              }
  
          });
  
  
          //立即支付
          $('#pay_btn').on('click', function () {
              var carNum = $('#license_number').val();
              var parkLotCardId = $('#parkLotCardId').val();
              var buyNum = $('#numder').val();
              var startDate = formatDateStr($('#date').val());
              var endDate = formatDateStr($('#date1').val());
              var totleMoney = $('#totle_money').text();
              if (carNum == '' || carNum == null || carNum == undefined) {
                  $.toptip('亲!请输入车牌号', 3000, 'warning');  //设置显示时间
e80df919   atao   init
267
                  return false
1b8be02a   atao   修改购买卡时的费用
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
              }
              //车牌校验
              var checkResult = jsutil.isVehicleNumber(jsutil.trim(carNum));
              if (!checkResult) {
                  $.alert("亲!输入车牌号不正确,<br/> 正确格式如:陕K88888");
                  return false;
              }
              /**
               *校验车牌号是否已经在对应的停车场已经订购? 是:跳转续费页面,否:继续订购
               *    parkLotCardId
               */
  
              jsutil.defaultReq(
                  mUrl.checkIsbuyCard,
                  {"carNum": carNum, "parkCardId": parkLotCardId},
                  function (data) {
e80df919   atao   init
284
                      if ("8888" != data.code) {
1b8be02a   atao   修改购买卡时的费用
285
286
                          //$.alert("");
                          return false;
e80df919   atao   init
287
                      } else {
1b8be02a   atao   修改购买卡时的费用
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
                          if (data.data != null && data.data != '') {
                              $.confirm("亲!您已经办理该停车场卡,是否继续续费?", function () {
                                  //点击确认后的回调函数
                                  window.location.href = mUrl.renewView + "&custCardId=" + data.data;
                              }, function () {
                                  window.location.href = mUrl.toParkInfoListView;
                              });
  
                          } else {
                              if (startDate == '' || startDate == null || startDate == undefined) {
                                  $.toptip('亲!请选择开始时间', 3000, 'warning');  //设置显示时间
                                  return false
                              } else {
                                  var jsonInfo = {};
                                  jsonInfo.carNum = carNum;
                                  jsonInfo.parkLotCardId = parkLotCardId;
                                  jsonInfo.buyNum = buyNum;
                                  jsonInfo.startDate = startDate;
                                  jsonInfo.endDate = endDate;
                                  jsonInfo.totleMoney = totleMoney;
                                  jsonInfo.orderType = 3;//
                                  jsutil.defaultReq(
                                      mUrl.createOrderInfo,
                                      jsonInfo,
                                      function (data) {
                                          if ("8888" != data.code) {
                                              $.alert("亲!创建订单失败,请重新尝试!");
                                              return false;
                                          } else {
                                              window.location.href = mUrl.orderPayView + "&parkOrderId=" + data.data;
                                          }
                                      });
                              }
                          }//else
e80df919   atao   init
322
                      }
1b8be02a   atao   修改购买卡时的费用
323
                  });
e80df919   atao   init
324
325
  
  
1b8be02a   atao   修改购买卡时的费用
326
          });
e80df919   atao   init
327
328
  
  
1b8be02a   atao   修改购买卡时的费用
329
      })
e80df919   atao   init
330
331
332
  </script>
  </body>
  </html>