123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- 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) {
- event.preventDefault();
- native.call('4000328170');
- }, $view);
- // SPA
- $.newTouch('.btn-action-spa', function (event) {
- event.preventDefault();
- goProductPage(5);
- }, $view);
- // 美容
- $.newTouch('.btn-action-groom', function (event) {
- event.preventDefault();
- goProductPage(3);
- }, $view);
- // 剃毛
- $.newTouch('.btn-action-shave', function (event) {
- event.preventDefault();
- goProductPage(2);
- }, $view);
- // 洗澡
- $.newTouch('.btn-action-bath', function (event) {
- event.preventDefault();
- goProductPage(1);
- }, $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-xunquan', function (event) {
- event.preventDefault();
- goProductPage(6);
- }, $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-ranse', function (event) {
- event.preventDefault();
- goProductPage(13);
- }, $view);
- // 助产
- $.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);
- // 优惠券
- $.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');
- }
- });
- }
- 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');
- }
- });
- }
- dtd.resolve();
- //强制设置首页的上一页是空的,后面再调整框架
- pageData.prevPage = $('.spa-page-empty');
- },
- beforeclose: function (pageData, dtd) {
- dtd.resolve();
- native.switchPopGesture(false);
- }
- }
- })
|