Browse Source

首页 添加 请求产品列表(仅供后端判断新用户)

jiaomengxiao 8 năm trước cách đây
mục cha
commit
66e3b414dc

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


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
www/webapp/o2o/dist/js/build/template.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/product.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}),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(s,a){var f=this,l=e(document);if(!s.pushData.dontNeedReload){l.trigger("spa:openloader");var c=t("home/index",{showNavBar:!o.isWX&&!o.isChubao});e(".spa-page-body",f).html(c),setTimeout(function(){s.scroll=new n("#homeScroll")},500),r.getListAll(i.id),u.getList({request_from:"weixin",user_id:i.id}),l.trigger("spa:closeloader")}a.resolve(),s.prevPage=e(".spa-page-empty")},beforeclose:function(e,t){t.resolve(),s.switchPopGesture(!1)}}});

+ 17 - 0
www/webapp/o2o/js/api.js

@@ -64,6 +64,23 @@ define(['config', 'base'], function (config, base) {
         });
     };
 
+    //获取商品列表
+    API.prototype.getProductList = function(data) {
+        var that = this;
+        this.isLoading = true;
+        $.signAjax({
+            url: config.apiPath + '/index.php?r=o2o/product/list',
+            data: data,
+            dataType: 'JSON',
+            success: function(res) {
+                that.isLoading = false;
+            },
+            error: function(res) {
+                that.isLoading = false;
+            }
+        });
+    };
+
     API.prototype.getAgreement = function (data, callback) {
         var that = this;
         this.isLoading = true;

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


+ 57 - 0
www/webapp/o2o/js/model/product.js

@@ -424,6 +424,63 @@ define(['base', '$', 'api'], function (base, $, api) {
                 ]
             }
         ];
+
+        //列出所有的产品
+        Product.prototype.getListAll = function (userID, callback) {
+            var that = this;
+            api.getProductList({
+                user_id: userID,
+                // type: type
+            }, function (res) {
+                if (res.success) {
+                    that.productList = {};
+
+                    var petDic = {};
+                    var productDatas = res['data']['products'];
+                    var extraroducts = res['data']['extra_products'];
+                    // that.extraService = extraroducts;
+
+                    for(var i in that.productGroup) {
+                        that.productGroup[i] = [];
+                    }
+
+                    for(var i in that.extraProductGroup) {
+                        that.extraProductGroup[i] = [];
+                    }
+
+                    for (var i = 0, len = productDatas.length; i < len; i++) {
+                        var eachProduct = productDatas[i];
+                        that.productGroup[eachProduct['type']].push(eachProduct);
+                        var petIDs = [];
+
+
+                        that.productDic[eachProduct.id] = {//产品中心
+                            petIDs: petIDs,//宠物ID
+                            maxWeight: eachProduct.max_weight,//产品最大
+                            minWeight: eachProduct.min_weight,//产品最小
+                            // price: parseFloat(eachProduct.price).toFixed(2)
+                            price: parseFloat(eachProduct.price)//解析产品价格
+                            // 价格不要加小数点后两位
+                        };
+                    }
+
+
+                    // for (var petID in petDic) {
+                    //   that.productGroup[eachProduct['type']].push(petDic[petID]);
+                    // }
+                }
+                if (typeof (callback) == 'function') {
+                    callback(res);
+                }
+            });
+        }
+    };
+
+    //列出所有的产品
+    Product.prototype.getListAll = function (userID) {
+        api.getProductList({
+            user_id: userID
+        });
     };
 
     Product.prototype = new base();

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

@@ -214,8 +214,9 @@ define(['$', 'template', 'IScroll', 'product', 'user', 'native', 'config', 'addr
                 setTimeout(function () {
                     pageData.scroll = new IScroll('#homeScroll');
                 }, 500);
-                // product.getListAll(user.id, function (res) {
-                // });
+
+                // 目前的作用只是供后端判断,该用户是否为新用户,所以没有回调。
+                product.getListAll(user.id);
 
                 address.getList({
                     request_from: 'weixin',

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