浏览代码

默认地址选择问题

洪海涛 8 年之前
父节点
当前提交
ed155fd5da

文件差异内容过多而无法显示
+ 0 - 0
www/webapp/o2o/dist/js/main.js


文件差异内容过多而无法显示
+ 0 - 0
www/webapp/o2o/dist/js/model/user.js


文件差异内容过多而无法显示
+ 0 - 0
www/webapp/o2o/dist/js/page/address/addressDetail.js


+ 1 - 1
www/webapp/o2o/dist/js/page/address/addressList.js

@@ -1 +1 @@
-define(["$","template","native","config","address","user","api","order"],function(e,t,n,r,i,s,o,u){function a(t,n){t.preventDefault(),e(document).trigger("spa:navigate",{hash:n})}return{title:"壹管家上门服务",body:"",init:function(t,n){var r=this,u=e(document);e.newTouch(".back-button",function(e){a.call(this,e,t.pushData.backHash)},r),r.on("tapBackButton",function(e){a.call(this,e,t.pushData.backHash)}),r.on("swipeRight",function(e){a.call(this,e,t.pushData.backHash)}),e.newTouch(".address-item",function(n){var a=e(this).data("id"),f=e(this).data("index");o.checkAddress({address_id:a,user_id:s.id},function(n){n.success?(r.trigger("tapBackButton"),t.callback&&e.isFunction(t.callback.onSelect)&&t.callback.onSelect(i.list[f],n.data.station)):u.trigger("spa:openpanel",["simpleAlert",{message:n.message}])})},r),e.newTouch(".btn-add",function(e){u.trigger("spa:navigate",{hash:"addressAdd",pushData:{needReload:!0}})},r),e.newTouch(".btn-edit",function(t){var n=e(this).data("id"),r=e(this).data("index");u.trigger("spa:navigate",{hash:"addressDetail",pushData:{addressIndex:r,addressID:n,needReload:!0},callback:{onEdit:function(e){}}})},r),n.resolve()},beforeopen:function(n,s){var o=this,u=t("address/list/index",{showNavBar:!r.isWX&&!r.isChubao,addText:"添加地址",addresses:i.list});e(".spa-page-body",o).html(u),s.resolve()},afteropen:function(e,t){t.resolve()}}});
+define(["$","template","native","config","address","user","api","order"],function(e,t,n,r,i,s,o,u){function a(t,n){t.preventDefault(),e(document).trigger("spa:navigate",{hash:n})}return{title:"壹管家上门服务",body:"",init:function(t,n){var r=this,u=e(document);e.newTouch(".back-button",function(e){a.call(this,e,t.pushData.backHash)},r),r.on("tapBackButton",function(e){a.call(this,e,t.pushData.backHash)}),r.on("swipeRight",function(e){a.call(this,e,t.pushData.backHash)}),e.newTouch(".address-item",function(n){var a=e(this).data("id"),f=e(this).data("index");o.checkAddress({address_id:a,user_id:s.id},function(n){n.success?(r.trigger("tapBackButton"),t.callback&&e.isFunction(t.callback.onSelect)&&t.callback.onSelect(i.list[f],n.data.station)):u.trigger("spa:openpanel",["simpleAlert",{message:n.message}])})},r),e.newTouch(".btn-add",function(e){u.trigger("spa:navigate",{hash:"addressAdd",pushData:{needReload:!0}})},r),e.newTouch(".btn-edit",function(t){var n=e(this).data("id"),r=e(this).data("index");u.trigger("spa:navigate",{hash:"addressDetail",pushData:{addressIndex:r,addressID:n,needReload:!0}})},r),n.resolve()},beforeopen:function(n,s){var o=this,u=t("address/list/index",{showNavBar:!r.isWX&&!r.isChubao,addText:"添加地址",addresses:i.list});e(".spa-page-body",o).html(u),s.resolve()},afteropen:function(e,t){t.resolve()}}});

文件差异内容过多而无法显示
+ 0 - 0
www/webapp/o2o/dist/js/page/placeOrder.js


+ 0 - 1
www/webapp/o2o/js/model/address.js

@@ -52,7 +52,6 @@ define(['base', '$', 'native', 'api', 'user', 'config'], function (base, $, nati
                 that.list = res.data;
                 that.list = res.data;
                 that.defaultAddress = that.list[0];
                 that.defaultAddress = that.list[0];
             }
             }
-
             if (typeof(callback) == 'function') {
             if (typeof(callback) == 'function') {
                 callback(res);
                 callback(res);
             }
             }

+ 1 - 1
www/webapp/o2o/js/model/user.js

@@ -8,7 +8,7 @@ define(['base', '$', 'native', 'api', 'order', 'config', 'address'], function (b
 		}
 		}
 		User.instance = this;
 		User.instance = this;
 		this.storagePrefix = 'user_';
 		this.storagePrefix = 'user_';
-		this.id = ''; //57e22bb59f5160c2048b456c//57e38f1b9f5160ac048b457d
+		this.id = '57e38f1b9f5160ac048b457d'; //57e22bb59f5160c2048b456c//57e38f1b9f5160ac048b457d
 		this.lastID = this.getCache('lastID', null, '');
 		this.lastID = this.getCache('lastID', null, '');
 		this.name = '';
 		this.name = '';
 		this.avatar='';
 		this.avatar='';

+ 37 - 20
www/webapp/o2o/js/page/address/addressDetail.js

@@ -1,7 +1,6 @@
 define(['template', 'native', 'config', 'address', 'api', 'user'], function (template, native, config, address, api, user) {
 define(['template', 'native', 'config', 'address', 'api', 'user'], function (template, native, config, address, api, user) {
 	function back(event) {
 	function back(event) {
 		event.preventDefault();
 		event.preventDefault();
-
 		$(document).trigger('spa:navigate', {
 		$(document).trigger('spa:navigate', {
 			hash: 'addressList'
 			hash: 'addressList'
 		});
 		});
@@ -29,14 +28,15 @@ define(['template', 'native', 'config', 'address', 'api', 'user'], function (tem
 				back.call(this, event);
 				back.call(this, event);
 			});
 			});
 
 
-			$.newTouch('.btn-delete', function() {
+			/*删除地址*/
+			$.newTouch('.btn-delete', function () {
 				var addressID = $(this).data('id');
 				var addressID = $(this).data('id');
-				address.deleteAddress(user.id, addressID, function(res){
+				address.deleteAddress(user.id, addressID, function (res) {
 					if (res.success) {
 					if (res.success) {
 						address.getList({
 						address.getList({
 							request_from: 'weixin',
 							request_from: 'weixin',
 							user_id: user.id
 							user_id: user.id
-						}, function(res) {
+						}, function (res) {
 							if (res.success) {
 							if (res.success) {
 								$doc.trigger('spa:navigate', {
 								$doc.trigger('spa:navigate', {
 									hash: 'addressList',
 									hash: 'addressList',
@@ -44,7 +44,8 @@ define(['template', 'native', 'config', 'address', 'api', 'user'], function (tem
 										needReload: true
 										needReload: true
 									}
 									}
 								});
 								});
-							};
+							}
+							;
 						})
 						})
 					} else {
 					} else {
 						$doc.trigger('spa:openpanel', ['simpleAlert', {
 						$doc.trigger('spa:openpanel', ['simpleAlert', {
@@ -64,7 +65,7 @@ define(['template', 'native', 'config', 'address', 'api', 'user'], function (tem
 						needReload: true,
 						needReload: true,
 						searchText: searchText,
 						searchText: searchText,
 						searchProvince: searchProvince,
 						searchProvince: searchProvince,
-            backHash: 'addressDetail'
+						backHash: 'addressDetail'
 					},
 					},
 					callback: {
 					callback: {
 						onSelect: function (name, place, address_position, address_detail) {
 						onSelect: function (name, place, address_position, address_detail) {
@@ -80,12 +81,13 @@ define(['template', 'native', 'config', 'address', 'api', 'user'], function (tem
 			//确认地址
 			//确认地址
 			$.newTouch('.btn-save', function (event) {
 			$.newTouch('.btn-save', function (event) {
 				event.preventDefault();
 				event.preventDefault();
+
+
 				// 设置默认地址
 				// 设置默认地址
 				var addressInfo = address['list'][cachePageData.addressIndex];
 				var addressInfo = address['list'][cachePageData.addressIndex];
 				var name = $('.address-name', $view).val(),
 				var name = $('.address-name', $view).val(),
 					mobile = $('.address-mobile', $view).val(),
 					mobile = $('.address-mobile', $view).val(),
 					detail = $('.address-detail', $view).val();
 					detail = $('.address-detail', $view).val();
-
 				if (name == '') {
 				if (name == '') {
 					$doc.trigger('spa:openpanel', ['simpleAlert', {
 					$doc.trigger('spa:openpanel', ['simpleAlert', {
 						message: '请输入您的名字'
 						message: '请输入您的名字'
@@ -111,7 +113,7 @@ define(['template', 'native', 'config', 'address', 'api', 'user'], function (tem
 					address_position = JSON.stringify(cachePageData.address_position);
 					address_position = JSON.stringify(cachePageData.address_position);
 				} else {
 				} else {
 					var addressDetailTmp = addressInfo.address;
 					var addressDetailTmp = addressInfo.address;
-          addressDetailTmp.detail = detail;
+					addressDetailTmp.detail = detail;
 					var addressStr = JSON.stringify(addressDetailTmp);
 					var addressStr = JSON.stringify(addressDetailTmp);
 					var address_position = addressInfo.position;
 					var address_position = addressInfo.position;
 					address_position = JSON.stringify(address_position);
 					address_position = JSON.stringify(address_position);
@@ -126,15 +128,18 @@ define(['template', 'native', 'config', 'address', 'api', 'user'], function (tem
 					address: addressStr,
 					address: addressStr,
 					address_id: cachePageData.addressID
 					address_id: cachePageData.addressID
 				};
 				};
-				address.editAddress( param, function(res) {
+				address.editAddress(param, function (res) {
 					$doc.trigger('spa:closeloader');
 					$doc.trigger('spa:closeloader');
 					if (res.success) {
 					if (res.success) {
-						$doc.trigger('spa:navigate', {
-							hash: 'addressList',
-							pushData: {
-								needReload: true
-							}
-						});
+						console.log(res);
+						console.log(cachePageData.address_detail);
+						/*$doc.trigger('spa:navigate', {
+						 hash: 'addressList',
+						 pushData: {
+						 needReload: true
+						 },
+						 callback: cachePageData.callback
+						 });*/
 					} else {
 					} else {
 						$doc.trigger('spa:openpanel', ['simpleAlert', {
 						$doc.trigger('spa:openpanel', ['simpleAlert', {
 							message: res.message
 							message: res.message
@@ -143,17 +148,29 @@ define(['template', 'native', 'config', 'address', 'api', 'user'], function (tem
 				})
 				})
 
 
 				/*if (cachePageData.callback && $.isFunction(cachePageData.callback.onSelect)) {
 				/*if (cachePageData.callback && $.isFunction(cachePageData.callback.onSelect)) {
-					cachePageData.callback.onSelect(cachePageData.addressID);
-				}*/
+				 cachePageData.callback.onSelect(cachePageData.addressID);
+				 }*/
 
 
 			}, $view);
 			}, $view);
 
 
+
+			/*$.newTouch('.btn-save', function (event) {
+			 event.preventDefault();
+			 $doc.trigger('spa:navigate', {
+			 hash: 'addressList',
+			 pushData: {
+			 needReload: true
+			 }
+			 });
+			 }, $view);*/
+
 			dtd.resolve();
 			dtd.resolve();
 		},
 		},
-		beforeopen: function(pageData, dtd) {
+		beforeopen: function (pageData, dtd) {
 			var $view = this;
 			var $view = this;
 			var $doc = $(document);
 			var $doc = $(document);
 			var pushData = pageData.pushData;
 			var pushData = pageData.pushData;
+			console.log(address);
 			cachePageData.needReload = pushData.needReload;
 			cachePageData.needReload = pushData.needReload;
 			if (cachePageData.needReload) {
 			if (cachePageData.needReload) {
 				pushData.needReload = false;
 				pushData.needReload = false;
@@ -177,9 +194,9 @@ define(['template', 'native', 'config', 'address', 'api', 'user'], function (tem
 					cachePageData.scroll = null;
 					cachePageData.scroll = null;
 				}
 				}
 
 
-				setTimeout(function() {
+				setTimeout(function () {
 					cachePageData.scroll = new IScroll('#addressListScroll');
 					cachePageData.scroll = new IScroll('#addressListScroll');
-				}, 10);
+				}, 500);
 			}
 			}
 
 
 			dtd.resolve();
 			dtd.resolve();

+ 0 - 6
www/webapp/o2o/js/page/address/addressList.js

@@ -64,18 +64,12 @@ define(['$', 'template', 'native', 'config', 'address', 'user', 'api', 'order'],
             $.newTouch('.btn-edit', function (event) {
             $.newTouch('.btn-edit', function (event) {
                 var addressID = $(this).data('id'),
                 var addressID = $(this).data('id'),
                     addressIndex = $(this).data('index');
                     addressIndex = $(this).data('index');
-
                 $doc.trigger('spa:navigate', {
                 $doc.trigger('spa:navigate', {
                     hash: 'addressDetail',
                     hash: 'addressDetail',
                     pushData: {
                     pushData: {
                         addressIndex: addressIndex,
                         addressIndex: addressIndex,
                         addressID: addressID,
                         addressID: addressID,
                         needReload: true
                         needReload: true
-                    },
-                    callback: {
-                        onEdit: function (addressID) {
-
-                        }
                     }
                     }
                 });
                 });
             }, $view);
             }, $view);

+ 1 - 0
www/webapp/o2o/js/page/mine.js

@@ -56,6 +56,7 @@ define(['$', 'template', 'IScroll', 'user', 'native', 'config', 'address', 'prod
 				});
 				});
 			}, $view);
 			}, $view);
 
 
+
 			// 常用地址
 			// 常用地址
 			$.newTouch('.btn-address-list', function (event) {
 			$.newTouch('.btn-address-list', function (event) {
 				event.preventDefault();
 				event.preventDefault();

+ 7 - 3
www/webapp/o2o/js/page/placeOrder.js

@@ -669,6 +669,7 @@ define(['$', 'template', 'order', 'native', 'helper', 'user', 'api', 'config', '
 							order.bookingTimeStr = texts[0] + ' ' + texts[1];
 							order.bookingTimeStr = texts[0] + ' ' + texts[1];
 							order.precedence = precedence;
 							order.precedence = precedence;
 							// 更新预定时间组件
 							// 更新预定时间组件
+
 							$('.booking-time', $view).html(order.bookingTimeStr);
 							$('.booking-time', $view).html(order.bookingTimeStr);
 							if (product.extra && !order.appendID) {
 							if (product.extra && !order.appendID) {
 							} else {
 							} else {
@@ -680,7 +681,6 @@ define(['$', 'template', 'order', 'native', 'helper', 'user', 'api', 'config', '
 			}, $view);
 			}, $view);
 			/*用户选择完时间之后,默认使用优惠券*/
 			/*用户选择完时间之后,默认使用优惠券*/
 			var dPicker = function () {
 			var dPicker = function () {
-
 				extraJson = JSON.stringify([{type: order.appendID, price: order.price}]);
 				extraJson = JSON.stringify([{type: order.appendID, price: order.price}]);
 				var productss = JSON.stringify([{product_id: order.productID, count: order.productCount}]);
 				var productss = JSON.stringify([{product_id: order.productID, count: order.productCount}]);
 				api.getCouponList({
 				api.getCouponList({
@@ -889,13 +889,17 @@ define(['$', 'template', 'order', 'native', 'helper', 'user', 'api', 'config', '
 		beforeopen: function (pageData, dtd) {
 		beforeopen: function (pageData, dtd) {
 			/*地址- setInterval-setTimeout*/
 			/*地址- setInterval-setTimeout*/
 			setTimeout(function () {
 			setTimeout(function () {
+				if ($('.booking-time').html() == "选择服务时间" && order.bookingTimeStr.length > 0) {
+					$('.booking-time', $view).html(order.bookingTimeStr);
+				}
 				/*隐藏广告位*/
 				/*隐藏广告位*/
 				$('.product-pic-o2o').css('display', 'none');
 				$('.product-pic-o2o').css('display', 'none');
 				/*当用户没有地址时*/
 				/*当用户没有地址时*/
 				var defaultAddress = address.defaultAddress;
 				var defaultAddress = address.defaultAddress;
-				if (typeof(defaultAddress.address) == "undefined") {
+				if (typeof(defaultAddress) == "undefined" || typeof(address.defaultAddress.length) == "undefined") {//登陆与未登录  默认地址判断
 					$('.order-mobile').html('添加服务地址');
 					$('.order-mobile').html('添加服务地址');
-				} else if (typeof(defaultAddress.address) !== "undefined" && $('.order-username').html() == "") {
+					return;
+				} else if (typeof(address.defaultAddress) !== "undefined" && typeof(defaultAddress.address) !== "undefined") {
 					order.address = address.defaultAddress;
 					order.address = address.defaultAddress;
 					$('.order-username').html(defaultAddress.name);
 					$('.order-username').html(defaultAddress.name);
 					$('.order-mobile').html(defaultAddress.mobile);
 					$('.order-mobile').html(defaultAddress.mobile);

部分文件因为文件数量过多而无法显示