|
@@ -281,6 +281,9 @@ define(['$', 'template', 'order', 'native', 'helper', 'user', 'api', 'config', '
|
|
|
$('.coupon-selected-name', $view).html('选择优惠券');
|
|
|
order.couponValue = 0;
|
|
|
order.couponID = '';
|
|
|
+ if ($('.booking-time').text() !== "选择服务时间") {
|
|
|
+ dPicker();
|
|
|
+ }
|
|
|
payCharge($('.order-cost', $view));
|
|
|
}, $view);
|
|
|
|
|
@@ -662,28 +665,48 @@ define(['$', 'template', 'order', 'native', 'helper', 'user', 'api', 'config', '
|
|
|
order.precedence = precedence;
|
|
|
// 更新预定时间组件
|
|
|
$('.booking-time', $view).html(order.bookingTimeStr);
|
|
|
- /*用户选择完时间之后,默认使用优惠券*/
|
|
|
- extraJson = JSON.stringify([{type: order.appendID, price: order.price}]);
|
|
|
- var productss = JSON.stringify([{product_id: order.productID, count: order.productCount}]);
|
|
|
- api.getCouponList({
|
|
|
- products: productss, //产品
|
|
|
- booking_time: order.bookingTimeStr, //预订时间
|
|
|
- user_id: user.id, //用户id
|
|
|
- type: product.type, //资源
|
|
|
- extra: extraJson//appendID==extra(一室一卫) price =价格
|
|
|
- }, function (res) {
|
|
|
- if (res.success) {
|
|
|
- if (typeof(res.data[0]) !== "undefined") {
|
|
|
- $('.coupon-selected-name', $view).text(res.data[0].coupon.name);
|
|
|
- order.couponValue = res.data[0].coupon.value;
|
|
|
- payCharge($('.order-cost', $view));
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ dPicker();
|
|
|
}
|
|
|
}
|
|
|
}]);
|
|
|
}, $view);
|
|
|
+ /*用户选择完时间之后,默认使用优惠券*/
|
|
|
+ var dPicker = function () {
|
|
|
+ extraJson = JSON.stringify([{type: order.appendID, price: order.price}]);
|
|
|
+ var productss = JSON.stringify([{product_id: order.productID, count: order.productCount}]);
|
|
|
+ api.getCouponList({
|
|
|
+ products: productss, //产品
|
|
|
+ booking_time: order.bookingTimeStr, //预订时间
|
|
|
+ user_id: user.id, //用户id
|
|
|
+ type: product.type, //资源
|
|
|
+ extra: extraJson//appendID==extra(一室一卫) price =价格
|
|
|
+ }, function (res) {
|
|
|
+ if (res.success) {
|
|
|
+ if (typeof(res.data[0]) !== "undefined") {
|
|
|
+ var index = 0;
|
|
|
+ var arrValue = [];
|
|
|
+ var arrCoupon = [];
|
|
|
+ var CouponName;
|
|
|
+ for (var i = 0; i < res.data.length; i++) {
|
|
|
+ arrValue[i] = res.data[i].coupon.value;
|
|
|
+ arrCoupon[i] = res.data[i].coupon;
|
|
|
+ }
|
|
|
+ var max = Math.max.apply(null, arrValue);//最大值
|
|
|
+ for (var j = 0; j < arrCoupon.length; j++) {
|
|
|
+ if (arrCoupon[j].value == max) {
|
|
|
+ CouponName = arrCoupon[j].name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(arrCoupon);
|
|
|
+ console.log(arrValue);
|
|
|
+ console.log(index);
|
|
|
+ $('.coupon-selected-name', $view).text(CouponName);
|
|
|
+ order.couponValue = max;
|
|
|
+ payCharge($('.order-cost', $view));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
|
|
|
/* 点击选择优惠券 */
|
|
|
$.newTouch('.show-coupon-picker', function (event) {
|