Browse Source

fix 选择代金券

jmx 8 năm trước cách đây
mục cha
commit
f8aa316da3

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
www/webapp/o2o/dist/js/config.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
www/webapp/o2o/dist/js/main.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
www/webapp/o2o/dist/js/model/user.js


+ 1 - 1
www/webapp/o2o/dist/js/page/home.js

@@ -1 +1 @@
-define(["$","template","IScroll","product","user","native","config","address"],function(e,t,n,r,i,s,o,u){function a(e){e.preventDefault(),s.back()}return{title:"壹管家上门服务",body:"",init:function(t,n){var o=this,u=e(document);e.newTouch(".back-button",function(e){a.call(this,e)},o),o.on("tapBackButton",function(e){a.call(this,e)}),e.newTouch(".service-telephone",function(e){e.preventDefault(),s.call("4000328170")},o),e.newTouch(".btn-product",function(t){t.preventDefault();var n=parseInt(e(this).attr("data-product-type"));u.trigger("spa:navigate",{hash:"placeOrder",pushData:{product:r.allList[n-1],needReset:!0}})},o),e.newTouch(".btn-action-my-order",function(e){e.preventDefault(),u.trigger("spa:navigate",{hash:""})},o),e.newTouch(".btn-action-coupon",function(e){e.preventDefault(),i.checkLogin(function(){u.trigger("spa:navigate",{hash:"mine",pushData:{needReset:!0}})})},o),n.resolve()},beforeopen:function(e,t){localStorage.removeItem("cart_products"),t.resolve(),s.switchPopGesture(!0)},afteropen:function(r,s){var a=this,f=e(document);if(!r.pushData.dontNeedReload){f.trigger("spa:openloader");var l=t("home/index",{showNavBar:!o.isWX&&!o.isChubao});e(".spa-page-body",a).html(l),setTimeout(function(){r.scroll=new n("#homeScroll")},500),u.getList({request_from:"weixin",user_id:i.id}),i.getCouponList(i.id),f.trigger("spa:closeloader")}s.resolve(),r.prevPage=e(".spa-page-empty")},beforeclose:function(e,t){t.resolve(),s.switchPopGesture(!1)}}});
+define(["$","template","IScroll","product","user","native","config","address"],function(e,t,n,r,i,s,o,u){function a(e){e.preventDefault(),s.back()}return{title:"壹管家上门服务",body:"",init:function(t,n){var o=this,u=e(document);e.newTouch(".back-button",function(e){a.call(this,e)},o),o.on("tapBackButton",function(e){a.call(this,e)}),e.newTouch(".service-telephone",function(e){e.preventDefault(),s.call("4000328170")},o),e.newTouch(".btn-product",function(t){t.preventDefault();var n=parseInt(e(this).attr("data-product-type"));u.trigger("spa:navigate",{hash:"placeOrder",pushData:{product:r.allList[n-1],needReset:!0}})},o),e.newTouch(".btn-action-my-order",function(e){e.preventDefault(),u.trigger("spa:navigate",{hash:""})},o),e.newTouch(".btn-action-coupon",function(e){e.preventDefault(),i.checkLogin(function(){u.trigger("spa:navigate",{hash:"mine",pushData:{needReset:!0}})})},o),n.resolve()},beforeopen:function(e,t){localStorage.removeItem("cart_products"),t.resolve(),s.switchPopGesture(!0)},afteropen:function(r,s){var a=this,f=e(document);if(!r.pushData.dontNeedReload){f.trigger("spa:openloader");var l=t("home/index",{showNavBar:!o.isWX&&!o.isChubao});e(".spa-page-body",a).html(l),setTimeout(function(){r.scroll=new n("#homeScroll")},500),u.getList({request_from:"weixin",user_id:i.id}),f.trigger("spa:closeloader")}s.resolve(),r.prevPage=e(".spa-page-empty")},beforeclose:function(e,t){t.resolve(),s.switchPopGesture(!1)}}});

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
www/webapp/o2o/dist/js/page/myCoupon.js


+ 1 - 1
www/webapp/o2o/dist/js/page/picker.js

@@ -1 +1 @@
-define(["$","template","order","config","user","api"],function(e,t,n,r,i,s){function o(t){e(document).trigger("spa:navigate",{hash:t})}var u={};return{title:"壹管家上门服务",body:"",init:function(n,r){var u=this,a=e(document);e.newTouch(".back-button",function(e){e.preventDefault();var t=n.pushData;o.call(this,t.backHash)},u),u.on("tapBackButton",function(e){e.preventDefault();var t=n.pushData;o.call(this,t.backHash)}),e.newTouch(".picker-option",function(){event.preventDefault();if(e(this).hasClass("unable"))return;u.trigger("tapBackButton"),n.callback&&e.isFunction(n.callback.onSelect)&&n.callback.onSelect(e(this).data("value"))},u),e.newTouch(".btn-coupon",function(r){r.preventDefault();var o=n.pushData,f=e("#coupon-code",u).val();if(f.length<8){a.trigger("spa:openpanel",["simpleAlert",{message:"请输入有效的兑换码"}]);return}e(this).val(""),i.exchangeCoupon(f,function(e){a.trigger("spa:openloader"),e.success?s.getCouponList({products:o.products,type:o.type,user_id:i.id},function(e){a.trigger("spa:closeloader"),a.trigger("spa:openpanel",["simpleAlert",{message:e.message}]);if(e.success){i.orderCoupons=e.data;var n=t("picker/cell",{options:e.data});u.find(".card-list").html(n)}}):(a.trigger("spa:closeloader"),a.trigger("spa:openpanel",["simpleAlert",{message:e.message}]))})},u),r.resolve()},beforeopen:function(e,n){var i=this,s=e.pushData;if(s.needReload){s.needReload=!1;var o=s.temp?s.temp:"picker/index",u=t(o,{options:s.options,unuseables:s.unuseables,title:s.title,showNavBar:!r.isWX&&!r.isChubao});i.find(".spa-page-body").html(u),e.scroll&&(e.scroll.destroy(),e.scroll=null),setTimeout(function(){e.scroll=new IScroll("#pickerScroll")},10)}n.resolve()}}});
+define(["$","template","order","config","user","api"],function(e,t,n,r,i,s){function o(t){e(document).trigger("spa:navigate",{hash:t})}return{title:"壹管家上门服务",body:"",init:function(n,r){var u=this,a=e(document);e.newTouch(".back-button",function(e){e.preventDefault();var t=n.pushData;o.call(this,t.backHash)},u),u.on("tapBackButton",function(e){e.preventDefault();var t=n.pushData;o.call(this,t.backHash)}),e.newTouch(".picker-option",function(){event.preventDefault();if(e(this).hasClass("unable"))return;u.trigger("tapBackButton"),n.callback&&e.isFunction(n.callback.onSelect)&&n.callback.onSelect(e(this).data("value"))},u),e.newTouch(".btn-coupon",function(r){r.preventDefault();var o=n.pushData,f=e("#coupon-code",u).val();f.length<8?a.trigger("spa:openpanel",["simpleAlert",{message:"请输入有效的兑换码"}]):(e(this).val(""),i.exchangeCoupon(f,function(e){a.trigger("spa:openloader"),e.success?s.getCouponList({products:o.products,type:o.type,user_id:i.id},function(e){a.trigger("spa:closeloader"),a.trigger("spa:openpanel",["simpleAlert",{message:e.message}]);if(e.success){i.orderCoupons=e.data;var n=t("picker/cell",{options:e.data});u.find(".card-list").html(n)}}):(a.trigger("spa:closeloader"),a.trigger("spa:openpanel",["simpleAlert",{message:e.message}]))}))},u),r.resolve()},beforeopen:function(n,o){var u=e(document),a=this,f=n.pushData;u.trigger("spa:openloader"),s.getCouponList({products:f.products,booking_time:f.time,user_id:i.id,type:f.type},function(e){var i=t("picker/coupon",{options:e.data,unuseables:e.unuseable_coupons,title:"选择代金券",showNavBar:!r.isWX&&!r.isChubao});a.find(".spa-page-body").html(i),n.scroll&&(n.scroll.destroy(),n.scroll=null),setTimeout(function(){n.scroll=new IScroll("#pickerScroll")},500),o.resolve(),u.trigger("spa:closeloader")})}}});

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
www/webapp/o2o/dist/js/page/placeOrder.js


+ 5 - 3
www/webapp/o2o/js/model/order.js

@@ -20,9 +20,11 @@ define(['base', '$', 'native', 'product', 'api'], function (base, $, native, pro
         this.bookingTime = '';
         this.bookingTimeStr = '';
         this.address = this.getCache('address', null);
-        this.productType = '';
-        this.productID = '';
-        this.productCount = 1;
+
+        this.productType = ''; // 产品类型
+        this.productID = ''; // 产品ID
+        this.productCount = 1; // 产品数量
+
         this.couponID = '';
         this.stationID = this.getCache('stationID', null, '');
         this.cacheReview = this.getCache('cacheReview', null, '');

+ 3 - 23
www/webapp/o2o/js/model/user.js

@@ -150,33 +150,13 @@ define(['base', '$', 'native', 'api', 'order', 'config', 'address'], function(ba
     return couponValue;
   };
 
-  //获取各类产品的优惠券
-  User.prototype.getProductCoupon = function(products, time, type, callback){
-    var that = this;
-    api.getCouponList({
-      products: products,//产品
-      booking_time: time,//预订时间
-      user_id: this.id,//用户id
-      type: type//资源
-    }, function(res) {
-      if (res.success) {
-        that.orderCoupons = res.data;//订购优惠券
-        that.unuseable_coupons = res.unuseable_coupons;//不可用的优惠券
-      }
-
-      if (typeof(callback) == 'function') {//true  回调函数  中将传值res
-        callback(res);
-      }
-    });
-  };
-
-  //优惠券列表
-  User.prototype.getCouponList = function(userId, callback){
+  // 获取用户的所有代金券
+  User.prototype.getCouponList = function(callback){
     var that = this;
 
     api.getCouponList({
       get_all: 1,
-      user_id: userId // 这...
+      user_id: that.id
     }, function(res) {
       if (res.success) {
         // 现有可用优惠券,按照面额降序排序;已经过期的优惠券,按照过期时间由近到远排序

+ 0 - 2
www/webapp/o2o/js/page/home.js

@@ -222,8 +222,6 @@ define(['$', 'template', 'IScroll', 'product', 'user', 'native', 'config', 'addr
                     user_id: user.id
                 });
 
-                user.getCouponList(user.id);
-
                 $doc.trigger('spa:closeloader');
             }
 

+ 1 - 1
www/webapp/o2o/js/page/myCoupon.js

@@ -84,7 +84,7 @@ define(['$', 'template', 'user', 'config', 'IScroll'], function ($, template, us
             var $doc = $(document);
             $doc.trigger('spa:openloader');
             user.checkLogin(function () {
-                user.getCouponList(user.id, function (res) {
+                user.getCouponList(function (res) {
                     $doc.trigger('spa:closeloader');
                     if (res.success) {
                         var tpl = template('myCoupon/index', {

+ 101 - 97
www/webapp/o2o/js/page/picker.js

@@ -1,115 +1,119 @@
 define(['$', 'template', 'order', 'config', 'user', 'api'], function ($, template, order, config, user, api) {
-  function back(backHash) {
-    $(document).trigger('spa:navigate', {
-      hash: backHash
-    });
-  }
+    function back(backHash) {
+        $(document).trigger('spa:navigate', {
+            hash: backHash
+        });
+    }
 
-  var cachePageData = {};
+    return {
+        title: '壹管家上门服务',
+        body: '',
+        init: function (pageData, dtd) {
+            var $view = this;
+            var $doc = $(document);
 
-  return {
-    title: '壹管家上门服务',
-    body: '',
-    init: function (pageData, dtd) {
-      var $view = this;
-      var $doc = $(document);
+            //返回
+            $.newTouch('.back-button', function (event) {
+                event.preventDefault();
 
-      //返回
-      $.newTouch('.back-button', function (event) {
-        event.preventDefault();
+                var pushData = pageData.pushData;
+                back.call(this, pushData['backHash']);
+            }, $view);
 
-        var pushData = pageData.pushData;
-        back.call(this, pushData['backHash']);
-      }, $view);
+            $view.on('tapBackButton', function (event) {
+                event.preventDefault();
 
-      $view.on('tapBackButton', function(event) {
-        event.preventDefault();
+                var pushData = pageData.pushData;
+                back.call(this, pushData['backHash']);
+            });
 
-        var pushData = pageData.pushData;
-        back.call(this, pushData['backHash']);
-      });
+            $.newTouch('.picker-option', function () {
+                event.preventDefault();
+                if ($(this).hasClass('unable')) return;
+                $view.trigger('tapBackButton');
 
-      $.newTouch('.picker-option', function () {
-        event.preventDefault();
-        if ($(this).hasClass('unable')) return;
-        $view.trigger('tapBackButton');
+                if (pageData.callback && $.isFunction(pageData.callback.onSelect)) {
+                    pageData.callback.onSelect($(this).data('value'));
+                }
+            }, $view);
 
-        if (pageData.callback && $.isFunction(pageData.callback.onSelect)) {
-          pageData.callback.onSelect($(this).data('value'));
-        }
-      }, $view);
+            // 兑换
+            $.newTouch('.btn-coupon', function (event) {
+                event.preventDefault();
 
-      // 兑换
-      $.newTouch('.btn-coupon', function(event) {
-        event.preventDefault();
+                var pushData = pageData.pushData;
+                var val = $('#coupon-code', $view).val();
+                if (val.length < 8) {
+                    $doc.trigger('spa:openpanel', ['simpleAlert', {
+                        message: '请输入有效的兑换码'
+                    }]);
+                } else {
+                    $(this).val('');
+                    user.exchangeCoupon(val, function (res) {
+                        $doc.trigger('spa:openloader');
+                        if (res.success) {
+                            api.getCouponList({
+                                products: pushData.products,
+                                type: pushData.type,
+                                user_id: user.id
+                            }, function (res) {
+                                $doc.trigger('spa:closeloader');
+                                $doc.trigger('spa:openpanel', ['simpleAlert', {
+                                    message: res.message
+                                }]);
+                                if (res.success) {
+                                    user.orderCoupons = res.data;
+                                    var tpl = template('picker/cell', {
+                                        options: res.data
+                                    });
+                                    $view.find('.card-list').html(tpl);
+                                }
+                            })
+                        } else {
+                            $doc.trigger('spa:closeloader');
+                            $doc.trigger('spa:openpanel', ['simpleAlert', {
+                                message: res.message
+                            }]);
+                        }
+                    })
+                }
+            }, $view);
+
+            dtd.resolve();
+        },
+        beforeopen: function (pageData, dtd) {
+            var $doc = $(document);
+            var $view = this;
+            var pushData = pageData.pushData;
 
-        var pushData = pageData.pushData;
-        var val = $('#coupon-code', $view).val();
-        if (val.length < 8) {
-          $doc.trigger('spa:openpanel', ['simpleAlert', {
-            message: '请输入有效的兑换码'
-          }]);
-          return;
-        } else {
-          $(this).val('');
-          user.exchangeCoupon(val, function (res) {
             $doc.trigger('spa:openloader');
-            if (res.success) {
-              api.getCouponList({
-                products: pushData.products,
-                type: pushData.type,
-                user_id: user.id
-              }, function (res) {
-                $doc.trigger('spa:closeloader');
-                $doc.trigger('spa:openpanel', ['simpleAlert', {
-                  message: res.message
-                }]);
-                if (res.success) {
-                  user.orderCoupons = res.data;
-                  var tpl = template('picker/cell', {
-                    options: res.data
-                  });
-                  $view.find('.card-list').html(tpl);
-                }
-              })
-            } else {
-              $doc.trigger('spa:closeloader');
-              $doc.trigger('spa:openpanel', ['simpleAlert', {
-                message: res.message
-              }]);
-            }
-          })
-        }
-      }, $view);
+            api.getCouponList({
+                products: pushData.products, //产品
+                booking_time: pushData.time, //预订时间
+                user_id: user.id, //用户id
+                type: pushData.type //资源
+            }, function (res) {
+                var tpl = template('picker/coupon', {
+                    options: res.data,
+                    unuseables: res.unuseable_coupons,
+                    title: '选择代金券',
+                    showNavBar: !config.isWX && !config.isChubao
+                });
 
-      dtd.resolve();
-    },
-    beforeopen: function (pageData, dtd) {
-      var $view = this;
-      var pushData = pageData.pushData;
-      if (pushData.needReload) {
-        pushData.needReload = false;
-        var pickerTemp = pushData.temp ? pushData.temp : 'picker/index';
+                $view.find('.spa-page-body').html(tpl);
 
-        var tpl = template(pickerTemp, {
-          options: pushData['options'],
-          unuseables: pushData['unuseables'],
-          title: pushData['title'],
-          showNavBar: !config.isWX && !config.isChubao
-        });
+                if (pageData.scroll) {
+                    pageData.scroll.destroy();
+                    pageData.scroll = null;
+                }
 
-        $view.find('.spa-page-body').html(tpl);
+                setTimeout(function () {
+                    pageData.scroll = new IScroll('#pickerScroll');
+                }, 500);
 
-        if (pageData.scroll) {
-          pageData.scroll.destroy();
-          pageData.scroll = null;
+                dtd.resolve();
+                $doc.trigger('spa:closeloader');
+            });
         }
-
-        setTimeout(function() {
-          pageData.scroll = new IScroll('#pickerScroll');
-        }, 10);
-      };
-      dtd.resolve();
     }
-  }
-})
+});

+ 8 - 6
www/webapp/o2o/js/page/placeOrder.js

@@ -600,6 +600,11 @@ define(['$', 'template', 'order', 'native', 'helper', 'user', 'api', 'config', '
                     callback: {
                         // 选完之后的回调。values:[日期,时间];texts:时间字符串;precedence:是否加急;
                         onSelect: function (values, texts, precedence) {
+                            // 重置代金券
+                            $('.coupon-selected-name', $view).html('选择优惠券');
+                            order.couponValue = 0;
+                            order.couponID = '';
+                            payCharge($('.order-cost', $view));
                             // 填写order
                             order.bookingDate = values[0];
                             order.bookingTime = values[1];
@@ -623,21 +628,18 @@ define(['$', 'template', 'order', 'native', 'helper', 'user', 'api', 'config', '
                     }]);
                     return;
                 }
+
                 // 跳转到picker页面,展示优惠券
                 $doc.trigger('spa:navigate', {
                     hash: 'picker',
                     pushData: {
-                        options: user.usable_coupons,
-                        unuseables: [],
-                        temp: 'picker/coupon',
                         title: '选择优惠券',
                         backHash: 'placeOrder',
                         products: JSON.stringify([{
                             product_id: order.productID,
-                            count: 1
+                            count: order.productCount
                         }]),
-                        type: order.productType,
-                        needReload: true
+                        type: order.productType
                     },
                     callback: {
                         // 在picker页面挑选之后,回到这个页面时执行的回调。pickValue:选中的优惠券的ID;

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác