Authored by 陈轩

Merge branch 'feature/service' of http://git.yoho.cn/fe/yohobuywap-node into feature/service

@@ -62,7 +62,8 @@ exports.fetchImHistory = (uid, pageSize, startTime, endTime) => { @@ -62,7 +62,8 @@ exports.fetchImHistory = (uid, pageSize, startTime, endTime) => {
62 exports.fetchOrderList = (uid, createTimeBegin) => { 62 exports.fetchOrderList = (uid, createTimeBegin) => {
63 let params = { 63 let params = {
64 uid, 64 uid,
65 - encryptedUid: encryptedUid(uid) 65 + encryptedUid: encryptedUid(uid),
  66 + imgSize: '90x120',
66 }; 67 };
67 68
68 _.forEach({createTimeBegin}, (key, val) => { 69 _.forEach({createTimeBegin}, (key, val) => {
@@ -13,8 +13,8 @@ @@ -13,8 +13,8 @@
13 {{!--inline partails--}} 13 {{!--inline partails--}}
14 {{#*inline 'order'}} 14 {{#*inline 'order'}}
15 <div class="chat-order"> 15 <div class="chat-order">
16 - <img src="{{thumb}}">  
17 - <div> 16 + <img src="{{imgSrc}}">
  17 + <div class="order-info">
18 <span class="label">订单号: </span><span>{{orderCode}}</span><br> 18 <span class="label">订单号: </span><span>{{orderCode}}</span><br>
19 <span class="label">金额: </span><span class="red">{{cost}}</span><br> 19 <span class="label">金额: </span><span class="red">{{cost}}</span><br>
20 <span class="label">下单时间: </span><span>{{createTime}}</span><br> 20 <span class="label">下单时间: </span><span>{{createTime}}</span><br>
@@ -7,15 +7,51 @@ @@ -7,15 +7,51 @@
7 </header> 7 </header>
8 <section class="order-goods"> 8 <section class="order-goods">
9 {{# goods}} 9 {{# goods}}
10 - {{> order/good}} 10 + <div class="order-good" data-id="{{id}}">
  11 + <div class="thumb-wrap">
  12 + {{#if link}}
  13 + <a href="{{link}}"><img class="thumb lazy" src="{{image thumb 90 120}}"></a>
  14 + {{else}}
  15 + <img class="thumb lazy" src="{{image thumb 90 120}}">
  16 + {{/if}}
  17 + <p class="tag{{#if gift}} gift-tag{{/if}}{{#if advanceBuy}} advance-buy-tag{{/if}}"></p>
  18 + </div>
  19 + <div class="deps">
  20 + <p class="name row">{{name}}</p>
  21 + <p class="row">
  22 + {{#if color}}
  23 + <span class="color">
  24 + {{#if tickets}}日期{{else}}颜色{{/if}}:{{color}}
  25 + </span>
  26 + {{/if}}
  27 +
  28 + {{#if size}}
  29 + <span class="size">
  30 + {{#if tickets}}区域{{else}}尺码{{/if}}:{{size}}
  31 + </span>
  32 + {{/if}}
  33 + </p>
  34 + <p class="row price-wrap">
  35 + <span class="price">
  36 + ¥{{price}}
  37 + </span>
  38 + <span class="count">
  39 + ×{{count}}
  40 + </span>
  41 + {{#if appearDate}}
  42 + <span class="appear-date">上市期:{{appearDate}}</span>
  43 + {{/if}}
  44 + </p>
  45 + </div>
  46 + </div>
11 {{/ goods}} 47 {{/ goods}}
12 </section> 48 </section>
13 <footer class="footer"> 49 <footer class="footer">
14 -{{count}}件商品 实付<span class="sum-cost">¥{{sumCost}}</span> 50 +{{count}}件商品 实付<span class="sum-cost">¥{{lastOrderAmount}}</span>
15 {{#shippingCost}}(含运费¥{{.}}){{/shippingCost}} 51 {{#shippingCost}}(含运费¥{{.}}){{/shippingCost}}
16 </footer> 52 </footer>
17 <div class="send-order clearfix"> 53 <div class="send-order clearfix">
18 - <button class="send-order-btn">发送订单</button> 54 + <button class="send-order-btn" data-action="select">发送订单</button>
19 </div> 55 </div>
20 </div> 56 </div>
21 <input class="js-create-time" type="hidden" name="human-time" value="{{time}}"> 57 <input class="js-create-time" type="hidden" name="human-time" value="{{time}}">
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 'use strict'; 6 'use strict';
7 7
8 import { 8 import {
9 - time 9 +time
10 } from './time'; 10 } from './time';
11 import { 11 import {
12 tip 12 tip
@@ -17,12 +17,10 @@ import { @@ -17,12 +17,10 @@ import {
17 OrderListView 17 OrderListView
18 } from './view'; 18 } from './view';
19 19
20 -require('../../home/jquery.upload');  
21 -var saveImage = require('../../home/save-image');  
22 -  
23 var socket = require('./socket-chat'), 20 var socket = require('./socket-chat'),
24 socketConf = require('./socket-config'), 21 socketConf = require('./socket-config'),
25 - cmEntity = socketConf.conversationMessage; 22 + cmEntity = socketConf.conversationMessage,
  23 + lastTimeShow = 0;
26 24
27 const chatBox = $('#chat-window'), 25 const chatBox = $('#chat-window'),
28 encryptedUid = $('#encrypteduid').val(); 26 encryptedUid = $('#encrypteduid').val();
@@ -57,6 +55,8 @@ var chat = { @@ -57,6 +55,8 @@ var chat = {
57 state: { 55 state: {
58 lastMSGTime: '' 56 lastMSGTime: ''
59 }, 57 },
  58 + $ratingView: $('#chat-comment'),
  59 +
60 60
61 messageT: require('service/chat/msg.hbs'), 61 messageT: require('service/chat/msg.hbs'),
62 62
@@ -149,12 +149,23 @@ var chat = { @@ -149,12 +149,23 @@ var chat = {
149 .on('selectOrder.OrderListView', function(event, data) { 149 .on('selectOrder.OrderListView', function(event, data) {
150 let msg = { 150 let msg = {
151 type: 'order', 151 type: 'order',
152 - data 152 + data,
  153 + style: 'send-msg',
153 }; 154 };
154 155
155 self.sendMSG(msg); 156 self.sendMSG(msg);
156 }); 157 });
157 158
  159 + this.$ratingView.on('click', '.submit', function() {
  160 + self.ratingView.post({
  161 + encryptedUid,
  162 + conversationId: cmEntity.conversationId,
  163 + });
  164 + }).on('rating-success', function(e, data) {
  165 + append(tip(`您对我们的服务评价为:${data}`).onLine());
  166 + resizeFooter();
  167 + });
  168 +
158 window.addEventListener('online', function() { 169 window.addEventListener('online', function() {
159 self._networkSick(false); 170 self._networkSick(false);
160 }); 171 });
@@ -455,39 +466,11 @@ var chat = { @@ -455,39 +466,11 @@ var chat = {
455 chat.init(); 466 chat.init();
456 467
457 // 触发菜单 468 // 触发菜单
458 -$('.menu-trigger').on('touchend', function() { 469 +$('.menu-trigger').on('click', function() {
459 let $menu = $('.menu'); 470 let $menu = $('.menu');
460 471
461 - if ($menu.css('display') === 'none') {  
462 - $menu.show();  
463 - resizeFooter();  
464 - } else {  
465 - $menu.hide();  
466 - resizeFooter();  
467 - }  
468 -  
469 - $('.upload-img').upload({  
470 - auto: true,  
471 - fileType: 'image/*',  
472 - uploadScript: '/api/upload/image',  
473 - fileObjName: 'filename',  
474 - fileSizeLimit: 5000000,  
475 - height: '100%',  
476 - width: '100%',  
477 - multi: false,  
478 - formData: {  
479 - bucket: 'suggest'  
480 - },  
481 - onUploadComplete: function(file, data) {  
482 - let url;  
483 -  
484 - data = saveImage.saveImage(data);  
485 - url = data.imgList[0].imgRelUrl + '?imageView2/2/w/640/q/90';  
486 - url = 'http://img11.static.yhbimg.com/suggest' + url;  
487 - sendMsg(2, url);  
488 - }  
489 - });  
490 - $('.uploadifive-button').css('position', 'absolute'); 472 + $menu.toggle();
  473 + resizeFooter();
491 }); 474 });
492 475
493 476
@@ -93,17 +93,20 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { @@ -93,17 +93,20 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, {
93 93
94 const curVal = this.rank = $rank.index(); 94 const curVal = this.rank = $rank.index();
95 95
  96 + this.rankText = rankMap[curVal];
96 this.$label.text(rankMap[curVal]); 97 this.$label.text(rankMap[curVal]);
97 98
  99 + this.$ranks.removeClass('rated');
98 this.$ranks.toggleClass(index => { 100 this.$ranks.toggleClass(index => {
99 return index <= curVal ? 'rated' : null; 101 return index <= curVal ? 'rated' : null;
100 }); 102 });
101 }, 103 },
102 104
103 post(data) { 105 post(data) {
104 - const elem = this.elem; 106 + const self = this,
  107 + elem = this.elem;
105 var params = { 108 var params = {
106 - stars: this.rank, 109 + stars: ++this.rank,
107 promoter: 1, 110 promoter: 1,
108 reasonMsg: elem.find('.words-to-say').val(), 111 reasonMsg: elem.find('.words-to-say').val(),
109 }; 112 };
@@ -115,7 +118,8 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, { @@ -115,7 +118,8 @@ RatingView.prototype = $.extend({}, EventEmitter.prototype, {
115 data: params, 118 data: params,
116 success: function(res) { 119 success: function(res) {
117 if (res && res.code === 200) { 120 if (res && res.code === 200) {
118 - 121 + elem.hide();
  122 + elem.trigger('rating-success', [self.rankText]);
119 } 123 }
120 }, 124 },
121 error: function() { 125 error: function() {
@@ -151,7 +155,7 @@ OrderListView.prototype = $.extend({}, EventEmitter.prototype, { @@ -151,7 +155,7 @@ OrderListView.prototype = $.extend({}, EventEmitter.prototype, {
151 self.toggleHide(true); 155 self.toggleHide(true);
152 }) 156 })
153 .on('click.OrderListView.select', '[data-action=select]', function() { 157 .on('click.OrderListView.select', '[data-action=select]', function() {
154 - 158 + self.selectOrder($(event.target));
155 }); 159 });
156 160
157 // 被通知显示,执行显示 161 // 被通知显示,执行显示
@@ -161,13 +165,13 @@ OrderListView.prototype = $.extend({}, EventEmitter.prototype, { @@ -161,13 +165,13 @@ OrderListView.prototype = $.extend({}, EventEmitter.prototype, {
161 /** 165 /**
162 * method: 选择订单,然后关闭 166 * method: 选择订单,然后关闭
163 */ 167 */
164 - selectOrder: function() {  
165 - let $order = $(event.target).closest('.order-page'); 168 + selectOrder: function($btn) {
  169 + let $order = $btn.closest('.order-page');
166 170
167 // 订单数据 171 // 订单数据
168 let data = { 172 let data = {
169 imgSrc: $order.find('.thumb').attr('src'), 173 imgSrc: $order.find('.thumb').attr('src'),
170 - orderCode: $order.find('[data-id]'), 174 + orderCode: $order.find('[data-id]').attr('data-id'),
171 cost: $order.find('.sum-cost').text(), 175 cost: $order.find('.sum-cost').text(),
172 createTime: $order.find('.js-create-time').val(), 176 createTime: $order.find('.js-create-time').val(),
173 orderStatus: $order.find('.order-status').text() 177 orderStatus: $order.find('.order-status').text()
@@ -202,6 +206,7 @@ OrderListView.prototype = $.extend({}, EventEmitter.prototype, { @@ -202,6 +206,7 @@ OrderListView.prototype = $.extend({}, EventEmitter.prototype, {
202 let html = self.orderListT({orders: result.data}); 206 let html = self.orderListT({orders: result.data});
203 207
204 self.$localOrders.append(html); 208 self.$localOrders.append(html);
  209 + lazyLoad($('img.lazy'));
205 }); 210 });
206 } 211 }
207 }); 212 });
@@ -131,6 +131,54 @@ @@ -131,6 +131,54 @@
131 } 131 }
132 } 132 }
133 133
  134 + .chat-order {
  135 + padding: 25px 35px;
  136 + background: #fff;
  137 + margin: 0 12px 0 0;
  138 + overflow: hidden;
  139 +
  140 + &:after {
  141 + content: "";
  142 + position: absolute;
  143 + display: inline-block;
  144 + width: 0;
  145 + height: 0;
  146 + font-size: 0;
  147 + border: 10px solid;
  148 + border-radius: 2px;
  149 + top: 0;
  150 + right: 0;
  151 + border-color: #fff transparent transparent #fff;
  152 + }
  153 +
  154 + img {
  155 + height: 173px;
  156 + width: 128px;
  157 + float: left;
  158 + margin-right: 10px;
  159 + }
  160 +
  161 + .order-info {
  162 + overflow: hidden;
  163 + line-height: 1.7;
  164 + }
  165 +
  166 + span {
  167 + float: left;
  168 + padding: 0;
  169 + font-size: 28px;
  170 + line-height: 1;
  171 + }
  172 +
  173 + .red {
  174 + color: #d0021b;
  175 + }
  176 +
  177 + .label {
  178 + color: #b0b0b0;
  179 + }
  180 + }
  181 +
134 /* 网络连接失败 */ 182 /* 网络连接失败 */
135 .connection-failed { 183 .connection-failed {
136 position: absolute; 184 position: absolute;