|
@@ -1,242 +1,258 @@
|
|
|
define(['$', 'template', 'IScroll', 'product', 'user', 'native', 'config'], function ($, template, IScroll, product, user, native, config) {
|
|
|
- function back(event) {
|
|
|
- event.preventDefault();
|
|
|
- native.back();
|
|
|
- }
|
|
|
-
|
|
|
- return {
|
|
|
- title: '壹管家上门服务',
|
|
|
- body: '',
|
|
|
- init: function (pageData, dtd) {
|
|
|
- var $view = this;
|
|
|
- var $doc = $(document);
|
|
|
-
|
|
|
- var tpl = template('home/index', {
|
|
|
- showNavBar: !config.isWX && !config.isChubao
|
|
|
- });
|
|
|
-
|
|
|
- $('.spa-page-body', $view).html(tpl);
|
|
|
-
|
|
|
- setTimeout(function() {
|
|
|
- pageData.scroll = new IScroll('#homeScroll', {
|
|
|
- preventDefaultException: { className: /(^|\s)home-content(\s|$)/ }
|
|
|
- });
|
|
|
- }, 50);
|
|
|
- //返回
|
|
|
- $.newTouch('.back-button', function (event) {
|
|
|
- back.call(this, event);
|
|
|
- }, $view);
|
|
|
-
|
|
|
- $view.on('tapBackButton', function(event) {
|
|
|
- back.call(this, event);
|
|
|
- });
|
|
|
-
|
|
|
- //客服电话
|
|
|
- $.newTouch('.service-telephone', function (event) {
|
|
|
+ function back(event) {
|
|
|
event.preventDefault();
|
|
|
+ native.back();
|
|
|
+ }
|
|
|
|
|
|
- native.call('4000328170');
|
|
|
- }, $view);
|
|
|
+ return {
|
|
|
+ title: '壹管家上门服务',
|
|
|
+ body: '',
|
|
|
+ init: function (pageData, dtd) {
|
|
|
+ var $view = this;
|
|
|
+ var $doc = $(document);
|
|
|
|
|
|
- // SPA
|
|
|
- $.newTouch('.btn-action-spa', function (event) {
|
|
|
- event.preventDefault();
|
|
|
- goProductPage(5);
|
|
|
- }, $view);
|
|
|
+ var tpl = template('home/index', {
|
|
|
+ showNavBar: !config.isWX && !config.isChubao
|
|
|
+ });
|
|
|
|
|
|
- // 美容
|
|
|
- $.newTouch('.btn-action-groom', function (event) {
|
|
|
- event.preventDefault();
|
|
|
+ $('.spa-page-body', $view).html(tpl);
|
|
|
|
|
|
- goProductPage(3);
|
|
|
- }, $view);
|
|
|
+ setTimeout(function () {
|
|
|
+ pageData.scroll = new IScroll('#homeScroll', {
|
|
|
+ preventDefaultException: {className: /(^|\s)home-content(\s|$)/}
|
|
|
+ });
|
|
|
+ }, 50);
|
|
|
+ //返回
|
|
|
+ $.newTouch('.back-button', function (event) {
|
|
|
+ back.call(this, event);
|
|
|
+ }, $view);
|
|
|
|
|
|
- // 剃毛
|
|
|
- $.newTouch('.btn-action-shave', function (event) {
|
|
|
- event.preventDefault();
|
|
|
- goProductPage(2);
|
|
|
- }, $view);
|
|
|
+ $view.on('tapBackButton', function (event) {
|
|
|
+ back.call(this, event);
|
|
|
+ });
|
|
|
|
|
|
- // 洗澡
|
|
|
- $.newTouch('.btn-action-bath', function (event) {
|
|
|
- event.preventDefault();
|
|
|
- goProductPage(1);
|
|
|
- }, $view);
|
|
|
+ //客服电话
|
|
|
+ $.newTouch('.service-telephone', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
|
|
|
- // 洁牙
|
|
|
- $.newTouch('.btn-action-jieya', function (event) {
|
|
|
- event.preventDefault();
|
|
|
- goProductPage(4);
|
|
|
- }, $view);
|
|
|
+ native.call('4000328170');
|
|
|
+ }, $view);
|
|
|
|
|
|
- // 训犬
|
|
|
- $.newTouch('.btn-action-xunquan', function (event) {
|
|
|
- event.preventDefault();
|
|
|
- goProductPage(6);
|
|
|
- }, $view);
|
|
|
+ // SPA
|
|
|
+ $.newTouch('.btn-action-spa', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goProductPage(5);
|
|
|
+ }, $view);
|
|
|
|
|
|
- // 断尾
|
|
|
- $.newTouch('.btn-action-duanwei', function (event) {
|
|
|
- event.preventDefault();
|
|
|
- goProductPage(7);
|
|
|
- }, $view);
|
|
|
+ // 美容
|
|
|
+ $.newTouch('.btn-action-groom', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
|
|
|
- // 碳酸浴
|
|
|
- $.newTouch('.btn-action-tansuanyun', function (event) {
|
|
|
- event.preventDefault();
|
|
|
- goProductPage(8);
|
|
|
- }, $view);
|
|
|
+ goProductPage(3);
|
|
|
+ }, $view);
|
|
|
|
|
|
- // 驱虫
|
|
|
- $.newTouch('.btn-action-quchong', function (event) {
|
|
|
- event.preventDefault();
|
|
|
- goProductPage(11);
|
|
|
- }, $view);
|
|
|
+ // 剃毛
|
|
|
+ $.newTouch('.btn-action-shave', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goProductPage(2);
|
|
|
+ }, $view);
|
|
|
|
|
|
- // 药浴
|
|
|
- $.newTouch('.btn-action-yaoyu', function (event) {
|
|
|
- event.preventDefault();
|
|
|
- goProductPage(12);
|
|
|
- }, $view);
|
|
|
+ // 洗澡
|
|
|
+ $.newTouch('.btn-action-bath', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goProductPage(1);
|
|
|
+ }, $view);
|
|
|
|
|
|
- // 染色
|
|
|
- $.newTouch('.btn-action-ranse', function (event) {
|
|
|
- event.preventDefault();
|
|
|
- goProductPage(13);
|
|
|
- }, $view);
|
|
|
+ //日常清洁=洁牙
|
|
|
+ $.newTouch('.btn-action-richang', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goProductPage(4);
|
|
|
+ }, $view);
|
|
|
+ /* //洁牙
|
|
|
+ $.newTouch('.btn-action-jieya', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goProductPage(4);
|
|
|
+ }, $view);*/
|
|
|
|
|
|
- // 助产
|
|
|
- $.newTouch('.btn-action-zhuchan', function (event) {
|
|
|
- event.preventDefault();
|
|
|
- goComing(9);
|
|
|
- }, $view);
|
|
|
+ // 训犬
|
|
|
+ $.newTouch('.btn-action-xunquan', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goProductPage(6);
|
|
|
+ }, $view);
|
|
|
|
|
|
- // 我的预约
|
|
|
- $.newTouch('.btn-action-my-order', function (event) {
|
|
|
- event.preventDefault();
|
|
|
- user.checkLogin(function () {
|
|
|
- $doc.trigger('spa:navigate', {
|
|
|
- hash: 'myOrder/1',
|
|
|
- pushData: {
|
|
|
- needReload: true
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- }, $view);
|
|
|
+ // 断尾
|
|
|
+ $.newTouch('.btn-action-duanwei', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goProductPage(7);
|
|
|
+ }, $view);
|
|
|
+ //除螨杀菌-碳酸浴
|
|
|
+ $.newTouch('.btn-action-tansuanyun', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goProductPage(8);
|
|
|
+ }, $view);
|
|
|
+ // 碳酸浴
|
|
|
+ /*$.newTouch('.btn-action-tansuanyun', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goProductPage(8);
|
|
|
+ }, $view);*/
|
|
|
+ //深度清洁=屈虫
|
|
|
+ $.newTouch('.btn-action-shendu', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goProductPage(11);
|
|
|
+ }, $view);
|
|
|
+ // 驱虫
|
|
|
+ /* $.newTouch('.btn-action-quchong', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goProductPage(11);
|
|
|
+ }, $view);*/
|
|
|
+ //其它-药浴
|
|
|
+ $.newTouch('.btn-action-qita', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goProductPage(12);
|
|
|
+ }, $view);
|
|
|
+ // 药浴
|
|
|
+ /* $.newTouch('.btn-action-yaoyu', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goProductPage(12);
|
|
|
+ }, $view);*/
|
|
|
|
|
|
- // 优惠券
|
|
|
- $.newTouch('.btn-action-coupon', function (event) {
|
|
|
- event.preventDefault();
|
|
|
- user.checkLogin(function () {
|
|
|
- $doc.trigger('spa:navigate', {
|
|
|
- hash: 'myCoupon'
|
|
|
- });
|
|
|
- });
|
|
|
- }, $view);
|
|
|
-
|
|
|
- // 招聘
|
|
|
- $.newTouch('.btn-action-hire', function() {
|
|
|
- event.preventDefault();
|
|
|
- $doc.trigger('spa:navigate', {
|
|
|
- hash: 'hire'
|
|
|
- });
|
|
|
- }, $view);
|
|
|
+ // 染色
|
|
|
+ $.newTouch('.btn-action-ranse', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goProductPage(13);
|
|
|
+ }, $view);
|
|
|
|
|
|
- dtd.resolve();
|
|
|
+ // 助产
|
|
|
+ $.newTouch('.btn-action-zhuchan', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ goComing(9);
|
|
|
+ }, $view);
|
|
|
|
|
|
+ // 我的预约
|
|
|
+ $.newTouch('.btn-action-my-order', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ user.checkLogin(function () {
|
|
|
+ $doc.trigger('spa:navigate', {
|
|
|
+ hash: 'myOrder/1',
|
|
|
+ pushData: {
|
|
|
+ needReload: true
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }, $view);
|
|
|
|
|
|
- function goProductPage(type) {
|
|
|
- user.checkLogin(function () {
|
|
|
- if (!user['productVisit'][13]) { // 预期字段不足 先清除本地数据
|
|
|
- localStorage.removeItem('user_productVisit');
|
|
|
- localStorage.removeItem('user_productVisit-time');
|
|
|
- user['productVisit'][13] = {
|
|
|
- visited: false
|
|
|
+ // 优惠券
|
|
|
+ $.newTouch('.btn-action-coupon', function (event) {
|
|
|
+ event.preventDefault();
|
|
|
+ user.checkLogin(function () {
|
|
|
+ $doc.trigger('spa:navigate', {
|
|
|
+ hash: 'myCoupon'
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }, $view);
|
|
|
+
|
|
|
+ // 招聘
|
|
|
+ $.newTouch('.btn-action-hire', function () {
|
|
|
+ event.preventDefault();
|
|
|
+ $doc.trigger('spa:navigate', {
|
|
|
+ hash: 'hire'
|
|
|
+ });
|
|
|
+ }, $view);
|
|
|
+ dtd.resolve();
|
|
|
+
|
|
|
+
|
|
|
+ function goProductPage(type) {
|
|
|
+ user.checkLogin(function () {
|
|
|
+ if (!user['productVisit'][13]) { // 预期字段不足 先清除本地数据
|
|
|
+ localStorage.removeItem('user_productVisit');
|
|
|
+ localStorage.removeItem('user_productVisit-time');
|
|
|
+ user['productVisit'][13] = {
|
|
|
+ visited: false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (user['productVisit'][type]['visited']) {
|
|
|
+ $doc.trigger('spa:navigate', {
|
|
|
+ hash: 'placeOrder',
|
|
|
+ pushData: {
|
|
|
+ productType: type,
|
|
|
+ serviceType: type,
|
|
|
+ needReset: true
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ $doc.trigger('spa:navigate', {
|
|
|
+ hash: 'product',
|
|
|
+ pushData: {
|
|
|
+ type: type,
|
|
|
+ needReload: true,
|
|
|
+ fromHome: true
|
|
|
+ }
|
|
|
+ });
|
|
|
+ user.productVisit[type].visited = true;
|
|
|
+ user.setCache('productVisit');
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
- }
|
|
|
- if (user['productVisit'][type]['visited']) {
|
|
|
- $doc.trigger('spa:navigate', {
|
|
|
- hash: 'placeOrder',
|
|
|
- pushData: {
|
|
|
- productType: type,
|
|
|
- serviceType: type,
|
|
|
- needReset: true
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- $doc.trigger('spa:navigate', {
|
|
|
- hash: 'product',
|
|
|
- pushData: {
|
|
|
- type: type,
|
|
|
- needReload: true,
|
|
|
- fromHome: true
|
|
|
- }
|
|
|
- });
|
|
|
- user.productVisit[type].visited = true;
|
|
|
- user.setCache('productVisit');
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- function goComing(type) {
|
|
|
- user.checkLogin(function () {
|
|
|
- $doc.trigger('spa:navigate', {
|
|
|
- hash: 'coming',
|
|
|
- pushData: {
|
|
|
- productType: type
|
|
|
+
|
|
|
+ function goComing(type) {
|
|
|
+ user.checkLogin(function () {
|
|
|
+ $doc.trigger('spa:navigate', {
|
|
|
+ hash: 'coming',
|
|
|
+ pushData: {
|
|
|
+ productType: type
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!user.activities['visited_offservice0126']) {
|
|
|
+ // showActivity();
|
|
|
+ }
|
|
|
+ function showActivity() {
|
|
|
+ var imgUrl = 'http://wozhua-others.qiniudn.com/20160126-offservice.png';
|
|
|
+ var d = new Image();
|
|
|
+ d.src = imgUrl;
|
|
|
+ d.onload = function () {
|
|
|
+ $doc.trigger('spa:openpanel', ['activity', {
|
|
|
+ content: imgUrl
|
|
|
+ }]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforeopen: function (pageData, dtd) {
|
|
|
+ localStorage.removeItem('cart_products');
|
|
|
+ dtd.resolve();
|
|
|
+ native.switchPopGesture(true);
|
|
|
+ },
|
|
|
+ afteropen: function (pageData, dtd) {
|
|
|
+ var $view = this;
|
|
|
+ var $doc = $(document);
|
|
|
+ if (!pageData.pushData.dontNeedReload) {
|
|
|
+ $doc.trigger('spa:openloader');
|
|
|
+ product.getListAll(user.id, function (res) {
|
|
|
+ $doc.trigger('spa:closeloader');
|
|
|
+ if (res.holiday) {
|
|
|
+ var offDay = res.holiday;
|
|
|
+ product.offDay = offDay;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 检测新用户
|
|
|
+ if (!user.isCheck.couponCheck) {
|
|
|
+ user.getCouponList(user.id, function (res) {
|
|
|
+ if (res.success) {
|
|
|
+ user.isCheck['couponCheck'] = true;
|
|
|
+ user.setCache('isCheck');
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- if (!user.activities['visited_offservice0126']) {
|
|
|
- // showActivity();
|
|
|
- }
|
|
|
- function showActivity () {
|
|
|
- var imgUrl = 'http://wozhua-others.qiniudn.com/20160126-offservice.png';
|
|
|
- var d = new Image();
|
|
|
- d.src = imgUrl;
|
|
|
- d.onload = function() {
|
|
|
- $doc.trigger('spa:openpanel', ['activity', {
|
|
|
- content: imgUrl
|
|
|
- }]);
|
|
|
+ dtd.resolve();
|
|
|
+ //强制设置首页的上一页是空的,后面再调整框架
|
|
|
+ pageData.prevPage = $('.spa-page-empty');
|
|
|
+ },
|
|
|
+ beforeclose: function (pageData, dtd) {
|
|
|
+ dtd.resolve();
|
|
|
+ native.switchPopGesture(false);
|
|
|
}
|
|
|
- }
|
|
|
- },
|
|
|
- beforeopen: function(pageData, dtd) {
|
|
|
- localStorage.removeItem('cart_products');
|
|
|
- dtd.resolve();
|
|
|
- native.switchPopGesture(true);
|
|
|
- },
|
|
|
- afteropen: function(pageData, dtd) {
|
|
|
- var $view = this;
|
|
|
- var $doc = $(document);
|
|
|
- if (!pageData.pushData.dontNeedReload) {
|
|
|
- $doc.trigger('spa:openloader');
|
|
|
- product.getListAll(user.id, function(res) {
|
|
|
- $doc.trigger('spa:closeloader');
|
|
|
- if (res.holiday) {
|
|
|
- var offDay = res.holiday;
|
|
|
- product.offDay = offDay;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // 检测新用户
|
|
|
- if (!user.isCheck.couponCheck) {
|
|
|
- user.getCouponList(user.id, function(res) {
|
|
|
- if (res.success) {
|
|
|
- user.isCheck['couponCheck'] = true;
|
|
|
- user.setCache('isCheck');
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- dtd.resolve();
|
|
|
- //强制设置首页的上一页是空的,后面再调整框架
|
|
|
- pageData.prevPage = $('.spa-page-empty');
|
|
|
- },
|
|
|
- beforeclose: function(pageData, dtd) {
|
|
|
- dtd.resolve();
|
|
|
- native.switchPopGesture(false);
|
|
|
}
|
|
|
- }
|
|
|
})
|