Authored by Rock Zhang

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop

@@ -109,18 +109,13 @@ $page.on('touchstart', '.del-icon', function() { @@ -109,18 +109,13 @@ $page.on('touchstart', '.del-icon', function() {
109 if (data.code === 200) { 109 if (data.code === 200) {
110 dialog.showDialog({ 110 dialog.showDialog({
111 dialogText: '删除浏览记录成功', 111 dialogText: '删除浏览记录成功',
112 - autoHide: true, 112 + autoHide: 2000,
113 fast: true 113 fast: true
114 }); 114 });
115 setTimeout(function() { 115 setTimeout(function() {
116 window.history.go(0); 116 window.history.go(0);
117 }, 1200); 117 }, 1200);
118 } 118 }
119 - },  
120 - complete: function() {  
121 - setTimeout(function() {  
122 - dialog.hideDialog();  
123 - }, 1500);  
124 } 119 }
125 }); 120 });
126 }); 121 });
@@ -37,6 +37,7 @@ exports.showDialog = function(data, callback) { @@ -37,6 +37,7 @@ exports.showDialog = function(data, callback) {
37 37
38 var dialogStr = dialogTemplate(data), 38 var dialogStr = dialogTemplate(data),
39 $dialogBox, 39 $dialogBox,
  40 + defaultHideDuraton,
40 dialogWrapperHammer; 41 dialogWrapperHammer;
41 42
42 $('.dialog-wrapper').remove(); 43 $('.dialog-wrapper').remove();
@@ -63,9 +64,13 @@ exports.showDialog = function(data, callback) { @@ -63,9 +64,13 @@ exports.showDialog = function(data, callback) {
63 64
64 //隐藏 65 //隐藏
65 if (data.autoHide) { 66 if (data.autoHide) {
  67 + defaultHideDuraton = 1000;
  68 + if (data.autoHide > 1) {
  69 + defaultHideDuraton = data.autoHide;
  70 + }
66 setTimeout(function() { 71 setTimeout(function() {
67 $dialogWrapper.fadeOut(); 72 $dialogWrapper.fadeOut();
68 - }, 1000); 73 + }, defaultHideDuraton);
69 } 74 }
70 75
71 dialogWrapperHammer.on('tap', function(event) { 76 dialogWrapperHammer.on('tap', function(event) {
@@ -76,9 +81,5 @@ exports.showDialog = function(data, callback) { @@ -76,9 +81,5 @@ exports.showDialog = function(data, callback) {
76 callback(); 81 callback();
77 } 82 }
78 }); 83 });
79 -  
80 }; 84 };
81 85
82 -exports.hideDialog = function() {  
83 - $dialogWrapper.fadeOut();  
84 -};  
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 var $ = require('jquery'); 6 var $ = require('jquery');
7 7
8 var loading = require('../plugin/loading'), 8 var loading = require('../plugin/loading'),
  9 + tip = require('../plugin/tip'),
9 Hammer = require('yoho.hammer'); 10 Hammer = require('yoho.hammer');
10 11
11 var theOrderCode = document.getElementById('ordercode').value; 12 var theOrderCode = document.getElementById('ordercode').value;
@@ -17,7 +18,7 @@ var appIconPosition = { @@ -17,7 +18,7 @@ var appIconPosition = {
17 baidu: '-2.7rem', 18 baidu: '-2.7rem',
18 weixin: '-1.2rem', 19 weixin: '-1.2rem',
19 QQ: '-5.4rem', 20 QQ: '-5.4rem',
20 - bank: '-4' 21 + bank: '-4rem'
21 }; 22 };
22 23
23 //隐藏微信分享选项 24 //隐藏微信分享选项
@@ -77,11 +78,11 @@ function callpay(orderCode) { @@ -77,11 +78,11 @@ function callpay(orderCode) {
77 jsApiParameters = res.data.jsApiParameters; 78 jsApiParameters = res.data.jsApiParameters;
78 jsApiCall(orderCode, jsApiParameters); 79 jsApiCall(orderCode, jsApiParameters);
79 } else { 80 } else {
80 - alert('微信支付调取失败'); 81 + tip.show('微信支付调取失败');
81 } 82 }
82 }, 83 },
83 error: function() { 84 error: function() {
84 - alert('请刷新本页面,完成微信支付'); 85 + tip.show('请刷新本页面,完成微信支付');
85 } 86 }
86 }); 87 });
87 } 88 }
@@ -99,11 +100,11 @@ function isWXOpen() { @@ -99,11 +100,11 @@ function isWXOpen() {
99 } 100 }
100 101
101 function hideWeChatPay() { 102 function hideWeChatPay() {
102 - var payApps = document.getElementsByClassName('app'); 103 + var $payApps = $('.app');
103 104
104 - [].forEach.call(payApps, function(app, index) {  
105 - if (app.innerHTML.indexOf('微信') !== -1) {  
106 - app.parentNode.style.display = 'none'; 105 + $payApps.each(function(idx, app) {
  106 + if ($(app).attr('id') === 'weixin') {
  107 + $(app).parent().css('display', 'none');
107 return false; 108 return false;
108 } 109 }
109 }); 110 });
@@ -117,29 +118,29 @@ function handleForWX() { @@ -117,29 +118,29 @@ function handleForWX() {
117 118
118 119
119 function setAppIcon(el, position) { 120 function setAppIcon(el, position) {
120 - el.style.backgroundPositionY = position; 121 + $(el).css('background-position-y', position);
121 } 122 }
122 123
123 function loadIcon() { 124 function loadIcon() {
124 - var boxs = document.getElementsByClassName('box');  
125 - var div = null; 125 + var $boxs = $('.box');
  126 + var $div = null;
126 var appid = null; 127 var appid = null;
127 128
128 - [].forEach.call(boxs, function(box, index) {  
129 - div = box.getElementsByClassName('icon')[0].getElementsByTagName('div')[0];  
130 - if (div) {  
131 - appid = box.getAttribute('id'); 129 + $boxs.each(function(idx, box) {
  130 + $div = $(box).find('.icon').find('div');
  131 + if ($div.length > 0) {
  132 + appid = $(box).attr('id');
132 if (appid !== 'alipay') { 133 if (appid !== 'alipay') {
133 - setAppIcon(div, appIconPosition[appid]); 134 + setAppIcon($div, appIconPosition[appid]);
134 } 135 }
135 } 136 }
136 }); 137 });
137 } 138 }
138 139
139 function showPage() { 140 function showPage() {
140 - var pageList = document.getElementsByClassName('payapp-list')[0]; 141 + var $pageList = $('.payapp-list');
141 142
142 - pageList.style.visibility = 'visible'; 143 + $pageList.css('visibility', 'visible');
143 } 144 }
144 145
145 if (wxHammer) { 146 if (wxHammer) {
@@ -64,11 +64,21 @@ lazyLoad(); @@ -64,11 +64,21 @@ lazyLoad();
64 headerNavHammer = new Hammer(document.getElementById('yoho-header')); 64 headerNavHammer = new Hammer(document.getElementById('yoho-header'));
65 65
66 headerNavHammer.on('tap', function(e) { 66 headerNavHammer.on('tap', function(e) {
67 - var suggestText = $('#suggest-textarea').val(); 67 + var suggestText = $('#suggest-textarea').val(),
  68 + textReg = /\S+/;
68 69
69 70
70 if ($(e.target).hasClass('nav-btn')) { 71 if ($(e.target).hasClass('nav-btn')) {
71 72
  73 + if (!textReg.test(suggestText)) {
  74 + diaLog.showDialog({
  75 + autoHide: true,
  76 + dialogText: '意见不能为空'
  77 + });
  78 +
  79 + return;
  80 + }
  81 +
72 $.ajax({ 82 $.ajax({
73 method: 'post', 83 method: 'post',
74 url: '/home/savesuggest', 84 url: '/home/savesuggest',
@@ -85,10 +95,18 @@ headerNavHammer.on('tap', function(e) { @@ -85,10 +95,18 @@ headerNavHammer.on('tap', function(e) {
85 setTimeout(function() { 95 setTimeout(function() {
86 location.pathname = 'home/suggest'; 96 location.pathname = 'home/suggest';
87 }, 2000); 97 }, 2000);
  98 + } else {
  99 + diaLog.showDialog({
  100 + autoHide: true,
  101 + dialogText: '提交失败~'
  102 + });
88 } 103 }
89 }).fail(function() { 104 }).fail(function() {
90 105
91 - //TODO 106 + diaLog.showDialog({
  107 + autoHide: true,
  108 + dialogText: '网络错误~'
  109 + });
92 }); 110 });
93 } 111 }
94 }); 112 });
@@ -807,7 +807,7 @@ class HomeController extends AbstractAction @@ -807,7 +807,7 @@ class HomeController extends AbstractAction
807 ), 807 ),
808 ), 808 ),
809 'orderCode' => $orderCode, 809 'orderCode' => $orderCode,
810 - 'hasWxShare' => strpos($this->_request->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false 810 + 'hasWxShare' => strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false
811 )); 811 ));
812 } 812 }
813 813