Authored by Rock Zhang

Merge branch 'feature/message' into feature/wap4.3

Conflicts:
	library/Api/Yohobuy.php
	template/m.yohobuy.com/partials/layout/use.phtml
@@ -16,24 +16,18 @@ use Plugin\Cache; @@ -16,24 +16,18 @@ use Plugin\Cache;
16 class Yohobuy 16 class Yohobuy
17 { 17 {
18 /* 正式环境 */ 18 /* 正式环境 */
19 - // php API 19 + // php API
20 // const API_URL = 'http://api2.open.yohobuy.com/'; 20 // const API_URL = 'http://api2.open.yohobuy.com/';
21 // const API_URL2 = 'http://api.open.yohobuy.com/'; 21 // const API_URL2 = 'http://api.open.yohobuy.com/';
22 // const SERVICE_URL = 'http://service.api.yohobuy.com/'; 22 // const SERVICE_URL = 'http://service.api.yohobuy.com/';
23 // const YOHOBUY_URL = 'http://www.yohobuy.com/'; 23 // const YOHOBUY_URL = 'http://www.yohobuy.com/';
24 -  
25 - //java API  
26 -// const API_URL = 'http://apih5.yoho.cn/';  
27 -// const API_URL2 = 'http://apih5.yoho.cn/';  
28 -// const SERVICE_URL = 'http://serviceh5.yoho.cn/';  
29 -// const YOHOBUY_URL = 'http://www.yohobuy.com/';  
30 -// const API_OLD = 'http://api2.open.yohobuy.com/';  
31 -  
32 -// const API_URL = 'http://api.yoho.cn/';  
33 -// const API_URL2 = 'http://api.yoho.cn/';  
34 -// const SERVICE_URL = 'http://service.yoho.cn/';  
35 -// const YOHOBUY_URL = 'http://www.yohobuy.com/';  
36 -// const API_OLD = 'http://api2.open.yohobuy.com/'; 24 +
  25 + //java API
  26 +// const API_URL = 'http://api.yoho.yohoops.org/';
  27 +// const API_URL2 = 'http://api.yoho.yohoops.org/';
  28 +// const SERVICE_URL = 'http://service.yoho.yohoops.org/';
  29 +// const YOHOBUY_URL = 'http://www.yohobuy.com/';
  30 +// const API_OLD = 'http://api2.open.yohobuy.com/';
37 31
38 /* 预览环境 java API */ 32 /* 预览环境 java API */
39 // const API_URL = 'http://preapi.yoho.cn/'; 33 // const API_URL = 'http://preapi.yoho.cn/';
@@ -41,29 +35,26 @@ class Yohobuy @@ -41,29 +35,26 @@ class Yohobuy
41 // const SERVICE_URL = 'http://serviceh5.yoho.cn/'; 35 // const SERVICE_URL = 'http://serviceh5.yoho.cn/';
42 // const YOHOBUY_URL = 'http://www.yohobuy.com/'; 36 // const YOHOBUY_URL = 'http://www.yohobuy.com/';
43 // const API_OLD = 'http://api2.open.yohobuy.com/'; 37 // const API_OLD = 'http://api2.open.yohobuy.com/';
44 - 38 +
45 /* 测试环境 java API*/ 39 /* 测试环境 java API*/
46 - const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://devapi.yoho.cn:58078/';  
47 -// const API_URL = 'http://devapi.yoho.cn:58078/';  
48 - const DEV_API_URL = 'http://devapi.yoho.cn:58078/';  
49 - const SERVICE_URL = 'http://testservice.yoho.cn:28077/'; // 'http://devservice.yoho.cn:58077/';  
50 - const DEV_SERVICE_URL = 'http://devservice.yoho.cn:58077/';  
51 - const PRD_SERVICE_URL = 'http://serviceh5.yoho.cn/'; 40 + const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://192.168.102.205:8080/gateway/'
  41 + const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
52 const YOHOBUY_URL = 'http://www.yohobuy.com/'; 42 const YOHOBUY_URL = 'http://www.yohobuy.com/';
53 const API_OLD = 'http://test2.open.yohobuy.com/'; 43 const API_OLD = 'http://test2.open.yohobuy.com/';
54 44
55 - /* 测试环境 php API*/  
56 -// const API_URL = 'http://test2.open.yohobuy.com/';  
57 -// const SERVICE_URL = 'http://test.service.api.yohobuy.com/';  
58 -// const YOHOBUY_URL = 'http://www.yohobuy.com/';  
59 -// const API_OLD = 'http://api2.open.yohobuy.com/';  
60 - 45 + /* 预览环境 */
  46 +// const API_URL = 'http://preapi.yoho.cn/';
  47 +// const API_URL2 = 'http://preapi.yoho.cn/';
  48 +// const SERVICE_URL = 'http://preservice.yoho.cn/';
  49 +// const YOHOBUY_URL = 'http://www.yohobuy.com/';
  50 +// const API_OLD = 'http://api2.open.yohobuy.com/';
  51 +
61 /** 52 /**
62 * 登录老接口Api配置 53 * 登录老接口Api配置
63 */ 54 */
64 const API_LOGIN_URL = 'http://api.open.yohobuy.com'; 55 const API_LOGIN_URL = 'http://api.open.yohobuy.com';
65 const API_LOGIN_URL_TEST = 'http://test.open.yohobuy.com'; 56 const API_LOGIN_URL_TEST = 'http://test.open.yohobuy.com';
66 - 57 +
67 /** 58 /**
68 * 私钥列表 59 * 私钥列表
69 * 60 *
@@ -76,7 +67,6 @@ class Yohobuy @@ -76,7 +67,6 @@ class Yohobuy
76 'web' => '0ed29744ed318fd28d2c07985d3ba633', 67 'web' => '0ed29744ed318fd28d2c07985d3ba633',
77 'h5' => 'fd4ad5fcfa0de589ef238c0e7331b585', 68 'h5' => 'fd4ad5fcfa0de589ef238c0e7331b585',
78 ); 69 );
79 -  
80 70
81 71
82 /** 72 /**
@@ -87,15 +77,12 @@ class Yohobuy @@ -87,15 +77,12 @@ class Yohobuy
87 // 苹果设备 77 // 苹果设备
88 if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) { 78 if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone')) {
89 return 'iphone'; 79 return 'iphone';
90 - }  
91 - // 苹果IPAD 80 + } // 苹果IPAD
92 elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) { 81 elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
93 return 'ipad'; 82 return 'ipad';
94 - }  
95 - elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'android')) { 83 + } elseif (stristr($_SERVER['HTTP_USER_AGENT'], 'android')) {
96 return 'android'; 84 return 'android';
97 - }  
98 - // 其它 85 + } // 其它
99 else { 86 else {
100 return 'android'; 87 return 'android';
101 } 88 }
@@ -213,8 +200,7 @@ class Yohobuy @@ -213,8 +200,7 @@ class Yohobuy
213 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. 200 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
214 if (empty($result)) { 201 if (empty($result)) {
215 $result = Cache::get($url, 'slave'); 202 $result = Cache::get($url, 'slave');
216 - }  
217 - // 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据. 203 + } // 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据.
218 else { 204 else {
219 Cache::set($url, $result, $cache); 205 Cache::set($url, $result, $cache);
220 } 206 }
@@ -237,7 +223,7 @@ class Yohobuy @@ -237,7 +223,7 @@ class Yohobuy
237 public static function post($url, $data = array(), $returnJson = false, $timeout = 10, $header = array(), $cookie = array()) 223 public static function post($url, $data = array(), $returnJson = false, $timeout = 10, $header = array(), $cookie = array())
238 { 224 {
239 $ch = curl_init($url); 225 $ch = curl_init($url);
240 - 226 +
241 curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 227 curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
242 if (!empty($header)) { 228 if (!empty($header)) {
243 curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 229 curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
@@ -354,13 +340,12 @@ class Yohobuy @@ -354,13 +340,12 @@ class Yohobuy
354 } 340 }
355 341
356 $response = json_decode($data, true); 342 $response = json_decode($data, true);
357 - if(!$isOriginalData) {//只返回data数据 343 + if (!$isOriginalData) {//只返回data数据
358 if (!isset($response['data'])) { 344 if (!isset($response['data'])) {
359 continue; 345 continue;
360 } 346 }
361 $result[$name] = $response['data']; 347 $result[$name] = $response['data'];
362 - }  
363 - else { 348 + } else {
364 $result[$name] = $response; 349 $result[$name] = $response;
365 } 350 }
366 curl_multi_remove_handle($mh, $ch[$name]); 351 curl_multi_remove_handle($mh, $ch[$name]);
@@ -373,8 +358,7 @@ class Yohobuy @@ -373,8 +358,7 @@ class Yohobuy
373 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. 358 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
374 if (empty($result[$name])) { 359 if (empty($result[$name])) {
375 $result = Cache::get($key, 'slave'); 360 $result = Cache::get($key, 'slave');
376 - }  
377 - // 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据. 361 + } // 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据.
378 else { 362 else {
379 Cache::set($key, $result, $cache); 363 Cache::set($key, $result, $cache);
380 } 364 }
@@ -422,8 +406,7 @@ class Yohobuy @@ -422,8 +406,7 @@ class Yohobuy
422 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. 406 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
423 if (empty($result)) { 407 if (empty($result)) {
424 $result = Cache::get($key, 'slave'); 408 $result = Cache::get($key, 'slave');
425 - }  
426 - // 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据. 409 + } // 接口调用成功时,这里会设置一级(master)和二级(slave)的缓存数据.
427 else { 410 else {
428 Cache::set($key, $result, $cache); 411 Cache::set($key, $result, $cache);
429 } 412 }
@@ -459,6 +459,57 @@ class UserData @@ -459,6 +459,57 @@ class UserData
459 } 459 }
460 460
461 /** 461 /**
  462 + * 删除我的消息
  463 + *
  464 + * @param int $uid 用户id
  465 + * @param int $id 消息id
  466 + * @return mixed
  467 + */
  468 + public static function delMessageData($uid, $id)
  469 + {
  470 + $param = Yohobuy::param();
  471 + $param['method'] = 'app.inbox.delmessage';
  472 + $param['uid'] = $uid;
  473 + $param['id'] = $id;
  474 + $param['client_secret'] = Sign::getSign($param);
  475 +
  476 + return Yohobuy::get(Yohobuy::API_URL, $param);
  477 + }
  478 +
  479 + /**
  480 + * 根据用户uid获取生日券id
  481 + * @param int $uid 用户id
  482 + * @return mixed
  483 + */
  484 + public static function getBirthCouponById($uid)
  485 + {
  486 + $param = Yohobuy::param();
  487 + $param['method'] = 'app.promotion.queryBirthCoupon';
  488 + $param['uid'] = $uid;
  489 + $param['couponType'] = 4;
  490 + $param['client_secret'] = Sign::getSign($param);
  491 +
  492 + return Yohobuy::get(Yohobuy::API_URL, $param);
  493 + }
  494 +
  495 + /**
  496 + * vip会员领取生日券
  497 + * @param type $uid 用户id
  498 + * @param type $couponId 生日券号
  499 + * @return type
  500 + */
  501 + public static function getBirthCoupon($uid, $couponId)
  502 + {
  503 + $param = Yohobuy::param();
  504 + $param['method'] = 'app.promotion.getCoupon';
  505 + $param['uid'] = $uid;
  506 + $param['couponId'] = $couponId;
  507 + $param['client_secret'] = Sign::getSign($param);
  508 +
  509 + return Yohobuy::get(Yohobuy::API_URL, $param);
  510 + }
  511 +
  512 + /**
462 * 在线客服接口 513 * 在线客服接口
463 * 514 *
464 * @return array 消息接口返回的数据 515 * @return array 消息接口返回的数据
@@ -40,6 +40,7 @@ $('.employ span').each(function(index) { @@ -40,6 +40,7 @@ $('.employ span').each(function(index) {
40 }); 40 });
41 }); 41 });
42 42
  43 +
43 function scrollHandler() { 44 function scrollHandler() {
44 if ($(window).scrollTop() + $(window).height() > $('body').height() - 100) { 45 if ($(window).scrollTop() + $(window).height() > $('body').height() - 100) {
45 page++; 46 page++;
@@ -20,3 +20,4 @@ require('./pay'); @@ -20,3 +20,4 @@ require('./pay');
20 require('./personal-details'); 20 require('./personal-details');
21 require('./currency'); 21 require('./currency');
22 require('./currency-new'); 22 require('./currency-new');
  23 +require('./message');
  1 +var $ = require('jquery'),
  2 + dialog = require('./dialog');
  3 +
  4 +var $page = $('.massage-page');
  5 +
  6 +var pickBusy = false;
  7 +
  8 +
  9 +// 领取生日券
  10 +$page.on('touchstart', '.pick-coupon-btn', function() {
  11 + if (pickBusy) {
  12 + return;
  13 + }
  14 + pickBusy = true;
  15 +
  16 + var $id = $(this).data('id');
  17 +
  18 + $.ajax({
  19 + type: 'POST',
  20 + url: '/home/pickCoupon',
  21 + data: {
  22 + id: $id
  23 + },
  24 + success: function(data) {
  25 + if (data.code === 200) {
  26 + dialog.showDialog({
  27 + dialogText: '领取成功',
  28 + autoHide: 2000,
  29 + fast: true
  30 + });
  31 + $(this).removeClass('pick-coupon-btn');
  32 + }
  33 +
  34 + pickBusy = false;
  35 +
  36 + dialog.showDialog({
  37 + dialogText: data.message,
  38 + autoHide: 2000,
  39 + fast: true
  40 + });
  41 + }
  42 + });
  43 +});
  1 +var $ = require('jquery'),
  2 + loading = require('../plugin/loading'),
  3 + dialog = require('./dialog');
  4 +
  5 +var $page = $('.massage-page'),
  6 + page = 1,
  7 + stopLoading = false;
  8 +
  9 +function massageAJAX(page) {
  10 + loading.showLoadingMask();
  11 + $.ajax({
  12 + type: 'POST',
  13 + url: '/home/ajaxMessage',
  14 + dataType: 'html',
  15 + data: {
  16 + page: page
  17 + },
  18 + success: function(data) {
  19 + if (data === ' ') {
  20 + stopLoading = true;
  21 + if (page === 1) {
  22 + data = '<p style="text-align:center">您没有消息</p>';
  23 + }
  24 + }
  25 +
  26 + $('.massage-page').append(data);
  27 + window.rePosFooter();
  28 + loading.hideLoadingMask();
  29 + }
  30 + });
  31 +}
  32 +
  33 +function scrollHandler() {
  34 + if (!stopLoading && ($(window).scrollTop() + $(window).height() > $('body').height() - 100)) {
  35 + page++;
  36 + massageAJAX(page);
  37 + }
  38 +}
  39 +
  40 +$(window).scroll(function() {
  41 + window.requestAnimationFrame(scrollHandler);
  42 +});
  43 +
  44 +// 删除消息
  45 +$page.on('touchstart', '.del', function() {
  46 + var $good = $(this).closest('.massage-list'),
  47 + $id = $good.data('id');
  48 +
  49 + dialog.showDialog({
  50 + dialogText: '确定删除这条消息吗?',
  51 + hasFooter: {
  52 + leftBtnText: '取消',
  53 + rightBtnText: '确定'
  54 + }
  55 + }, function() {
  56 +
  57 + $.ajax({
  58 + type: 'POST',
  59 + url: '/home/ajaxDelMes',
  60 + data: {
  61 + id: $id
  62 + },
  63 + success: function(data) {
  64 + if (data.code === 200) {
  65 + dialog.showDialog({
  66 + dialogText: '删除消息成功',
  67 + autoHide: 2000,
  68 + fast: true
  69 + });
  70 + setTimeout(function() {
  71 + window.history.go(0);
  72 + }, 1200);
  73 + }
  74 + }
  75 + });
  76 + });
  77 +});
  78 +
  79 +massageAJAX(page);
1 $vip: sprite-map("me/vip/*.png", $spacing: 10px); 1 $vip: sprite-map("me/vip/*.png", $spacing: 10px);
2 $fav: sprite-map("me/fav/*.png", $spacing: 5px); 2 $fav: sprite-map("me/fav/*.png", $spacing: 5px);
3 3
4 -@import "home", "vip-grade", "order", "order-detail", "coupons", "personal-details", "yoho-coin", "fav", "suggest", "address", "online-service", "my-guang", "ihelp", "browse-record", "logistic", "pay","yoho-coin-new", "yoho-coin-detail"; 4 +@import "home", "message", "vip-grade", "order", "order-detail", "coupons", "personal-details", "yoho-coin", "fav", "suggest", "address", "online-service", "my-guang", "ihelp", "browse-record", "logistic", "pay","yoho-coin-new", "yoho-coin-detail";
  1 +.massage-page{
  2 + margin-top: .4rem;
  3 + padding-bottom:.6rem;
  4 + .massage-list{
  5 + padding: 1em 2em 1em 1.4em;
  6 + border-bottom: 1px solid #F8F8F8;
  7 + position: relative;
  8 + overflow: hidden;
  9 + p{
  10 + font-size: 1.2em;
  11 + color: #222;
  12 + }
  13 + span{
  14 + font-size: 0.9em;
  15 + color: #999999;
  16 + }
  17 + i{
  18 + position: absolute;
  19 + right: .6rem;
  20 + top: .6rem;
  21 + color: #cccccc;
  22 + }
  23 + strong{
  24 + width: 8px;
  25 + height: 8px;
  26 + position: absolute;
  27 + left: .4rem;
  28 + top: 1rem;
  29 + background: #f00;
  30 + border-radius:50%;
  31 + }
  32 + }
  33 + .massage-main{
  34 + border-bottom: 1px solid #F8F8F8;
  35 + padding: 12px;
  36 + margin-left: 10px;
  37 + margin-bottom: 10px;
  38 + h6{
  39 + margin-bottom: .2rem;
  40 + }
  41 + span{
  42 + color: #656565;
  43 + }
  44 +
  45 + }
  46 + .sale-btn{
  47 + background-color: #ea2622;
  48 + color: #fff;
  49 + padding: 5px 10px 5px 10px;
  50 + }
  51 + .coupon-item{
  52 + margin-left: 10px;
  53 + padding-bottom: 10px;
  54 + border-bottom: 1px solid #F8F8F8;
  55 + margin-top: 10px;
  56 + .coupon-img{
  57 + width: 3.2rem;
  58 + height: auto;
  59 + overflow: hidden;
  60 + float: left;
  61 + margin-right: .4rem;
  62 + img{
  63 + width: 100%;
  64 + height: auto;
  65 + }
  66 + }
  67 + .coupon-info{
  68 + font-size: .55rem;
  69 + span{
  70 + color: #f00;
  71 + }
  72 + }
  73 + .coupon-action{
  74 + width: 110px;
  75 + font-size: 12px;
  76 + letter-spacing: 2px;
  77 + margin: 3px 0 0 0;
  78 + height: 35px;
  79 + line-height: 35px;
  80 + background: #ed0010;
  81 + text-align: center;
  82 + margin-left: 3.6rem;
  83 + a{
  84 + display: block;
  85 + color: #fff;
  86 + width: 100%;
  87 + height:100%;
  88 + }
  89 + }
  90 + }
  91 +}
  1 +{{#list}}
  2 +<div class="massage-list" data-id="{{id}}">
  3 + {{#if isNotReaded}}
  4 + <strong></strong>
  5 + {{/if}}
  6 + <p><a href="{{url}}">{{title}}</a></p>
  7 + <span>{{time}}</span>
  8 + <i class="iconfont del">&#xe621;</i>
  9 +</div>
  10 +{{/list}}
  1 +{{> layout/header}}
  2 +<div class="massage-page yoho-page">
  3 + <div class="massage-main">
  4 + <h6>{{title}}</h6>
  5 + <span>{{sender}} 发送于{{time}}</span>
  6 + </div>
  7 + {{#if text}}
  8 + <div class="massage-main">
  9 + {{# text}}
  10 + <!-- 文本消息 -->
  11 + <p>{{{content}}}</p>
  12 + {{/ text}}
  13 + </div>
  14 + {{/if}}
  15 +
  16 + {{#if coupons}}
  17 + {{# coupons}}
  18 + <!-- 优惠券消息 -->
  19 + <div class="coupon-item">
  20 + <div class="coupon-img">
  21 + <img src="http://static.yohobuy.com/images/v2/activity/default_coupon.jpg">
  22 + </div>
  23 + <div class="coupon-info">
  24 + <p>{{remark}}</p>
  25 + {{#if url}}
  26 + <p>面值:<span>{{price}}</span></p>
  27 + <p>有效期:{{useTime}}</p>
  28 + {{^}}
  29 + <p>使用时间:{{useTime}}</p>
  30 + <p>领取时间:{{pickTime}}</p>
  31 + {{/if}}
  32 + </div>
  33 + <div class="coupon-action">
  34 + {{#if url}}
  35 + <a href="{{url}}" class="view-coupon-btn">立即查看</a>
  36 + {{^}}
  37 + <a{{#if canPick}} class="pick-coupon-btn" data-id="{{id}}"{{/if}}>立即领取</a>
  38 + {{/if}}
  39 + </div>
  40 + </div>
  41 + {{/ coupons}}
  42 + {{/if}}
  43 + {{#if sale}}
  44 + {{# sale}}
  45 + <!-- 促销消息 -->
  46 + <div class="sale-img">
  47 + <img src="{{image}}">
  48 + </div>
  49 + <br />
  50 + <br />
  51 + <p>{{{content}}}</p>
  52 + <br />
  53 + <br />
  54 + <a href="{{btnLink}}" class="sale-btn">{{btnName}}</a>
  55 + {{/ sale}}
  56 + {{/if}}
  57 +</div>
  58 +{{> layout/footer}}
  1 +{{> layout/header}}
  2 +<div class="massage-page yoho-page">
  3 +
  4 +</div>
  5 +{{> layout/footer}}
@@ -368,3 +368,13 @@ @@ -368,3 +368,13 @@
368 </script> 368 </script>
369 {{/if}} 369 {{/if}}
370 370
  371 +{{#if messagePage}}
  372 +<script>
  373 + seajs.use('js/me/message');
  374 +</script>
  375 +{{/if}}
  376 +{{#if messageDetailPage}}
  377 +<script>
  378 + seajs.use('js/me/message-detail');
  379 +</script>
  380 +{{/if}}
@@ -271,6 +271,97 @@ class HomeController extends AbstractAction @@ -271,6 +271,97 @@ class HomeController extends AbstractAction
271 } 271 }
272 272
273 /** 273 /**
  274 + * 消息
  275 + */
  276 + public function messageAction()
  277 + {
  278 + // 审判跳转登录页
  279 + $this->auditJumpLogin();
  280 +
  281 + $this->setTitle('我的消息');
  282 + $this->setNavHeader('我的消息', true, false);
  283 +
  284 + $messages['pageFooter'] = true;
  285 + $messages['messagePage'] = true;
  286 + $this->_view->display('message', $messages);
  287 + }
  288 +
  289 + /*
  290 + * 异步获取我的消息
  291 + */
  292 + public function ajaxMessageAction()
  293 + {
  294 + $result = array();
  295 +
  296 + if ($this->isAjax()) {
  297 + $page = $this->post('page', 1);
  298 + $uid = $this->getUid(true);
  299 + $result = UserModel::getMessageData($uid, $page, 20);
  300 + }
  301 +
  302 + if (empty($result)) {
  303 + echo ' ';
  304 + } else {
  305 + $this->_view->display('message-list', $result);
  306 + }
  307 + }
  308 +
  309 + /*
  310 + * 异步删除我的消息
  311 + */
  312 + public function ajaxDelMesAction()
  313 + {
  314 + $result = array();
  315 +
  316 + if ($this->isAjax()) {
  317 + $id = $this->post('id', 0);
  318 + $uid = $this->getUid(true);
  319 + $result = UserModel::delMessage($uid, $id);
  320 + }
  321 +
  322 + $this->echoJson($result);
  323 + }
  324 +
  325 + /**
  326 + * 消息详情
  327 + */
  328 + public function messageDetailAction()
  329 + {
  330 + $this->setTitle('我的消息');
  331 + $this->setNavHeader('我的消息', true, false);
  332 +
  333 + $id = $this->get('id', 0);
  334 + $uid = $this->getUid(true);
  335 + $data = UserModel::getMessageDetail($uid, $id);
  336 + $data['pageFooter'] = true;
  337 + $data['messageDetailPage'] = true;
  338 +
  339 + $this->_view->display('message-main', $data);
  340 + }
  341 +
  342 + /**
  343 + * 我的消息详情中领取生日券
  344 + */
  345 + public function pickCouponAction()
  346 + {
  347 + $result = array('code' => 400, 'message' => '', 'data' => '');
  348 +
  349 + do {
  350 + /* 判断是不是AJAX请求 */
  351 + if (!$this->isAjax()) {
  352 + break;
  353 + }
  354 +
  355 + $uid = $this->getUid(true);
  356 + $id = $this->post('id', 0);
  357 + $result = UserModel::pickBirthCoupon($uid, $id);
  358 + }
  359 + while (false);
  360 +
  361 + $this->echoJson($result);
  362 + }
  363 +
  364 + /**
274 * 优惠券 365 * 优惠券
275 */ 366 */
276 public function couponsAction() 367 public function couponsAction()
@@ -467,7 +558,7 @@ class HomeController extends AbstractAction @@ -467,7 +558,7 @@ class HomeController extends AbstractAction
467 $serviceUrl = 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info='; 558 $serviceUrl = 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=';
468 if ($uid) { 559 if ($uid) {
469 $time = time() . '000'; 560 $time = time() . '000';
470 - $info = 'userId=' . $uid . '&name=' . $this->_uname . '&memo=&hashCode=' . md5( strtoupper( rawurlencode($uid . $this->_uname . $time . '1231') ) ) . '&timestamp=' . $time; 561 + $info = 'userId=' . $uid . '&name=' . $this->_uname . '&memo=&hashCode=' . md5(strtoupper(rawurlencode($uid . $this->_uname . $time . '1231'))) . '&timestamp=' . $time;
471 $serviceUrl .= rawurlencode($info); 562 $serviceUrl .= rawurlencode($info);
472 } 563 }
473 564
@@ -812,7 +903,7 @@ class HomeController extends AbstractAction @@ -812,7 +903,7 @@ class HomeController extends AbstractAction
812 903
813 /* 判断订单是否已付款, 已付款跳到订单详情页 */ 904 /* 判断订单是否已付款, 已付款跳到订单详情页 */
814 if (!empty($orderDetail['isPay'])) { 905 if (!empty($orderDetail['isPay'])) {
815 - $this->go(Helpers::url('/home/orderdetail', array('order_code' => $orderCode)) ); 906 + $this->go(Helpers::url('/home/orderdetail', array('order_code' => $orderCode)));
816 } 907 }
817 908
818 $hasWxShare = strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false; 909 $hasWxShare = strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false;
@@ -892,8 +983,8 @@ class HomeController extends AbstractAction @@ -892,8 +983,8 @@ class HomeController extends AbstractAction
892 $input->SetBody('有货订单号:' . $orderCode); 983 $input->SetBody('有货订单号:' . $orderCode);
893 $input->SetOut_trade_no('YOHOBuy_' . $orderCode); // 商户订单号 984 $input->SetOut_trade_no('YOHOBuy_' . $orderCode); // 商户订单号
894 $input->SetTotal_fee($totalFee); 985 $input->SetTotal_fee($totalFee);
895 - $input->SetTime_start(date("YmdHis", (int) $orderDetail['data']['create_time']));  
896 - $input->SetTime_expire(date("YmdHis", (int) $orderDetail['data']['create_time'] + 7200)); 986 + $input->SetTime_start(date("YmdHis", (int)$orderDetail['data']['create_time']));
  987 + $input->SetTime_expire(date("YmdHis", (int)$orderDetail['data']['create_time'] + 7200));
897 $input->SetNotify_url(WxPayConfig::NOTIFY_URL); 988 $input->SetNotify_url(WxPayConfig::NOTIFY_URL);
898 $input->SetTrade_type("JSAPI"); 989 $input->SetTrade_type("JSAPI");
899 $input->SetOpenid($openId); 990 $input->SetOpenid($openId);
@@ -1026,5 +1117,4 @@ class HomeController extends AbstractAction @@ -1026,5 +1117,4 @@ class HomeController extends AbstractAction
1026 echo ' '; 1117 echo ' ';
1027 } 1118 }
1028 } 1119 }
1029 -  
1030 } 1120 }
@@ -875,13 +875,167 @@ class UserModel @@ -875,13 +875,167 @@ class UserModel
875 $messageData = UserData::messageData($uid, $page, $size); 875 $messageData = UserData::messageData($uid, $page, $size);
876 876
877 // 处理我的消息数据 877 // 处理我的消息数据
878 - if (isset($messageData['data']) && !empty($messageData['data'])) {  
879 - $result = $messageData['data']; 878 + if (isset($messageData['data']['list']) && !empty($messageData['data']['list'])) {
  879 + $messages = $messageData['data']['list'];
  880 + $one = array();
  881 + foreach ($messages as $message) {
  882 + $one = array();
  883 + $one['id'] = $message['id'];
  884 + $one['title'] = $message['title'];
  885 + $one['time'] = date('Y-m-d H:i:s', $message['create_time']);
  886 + $one['isNotReaded'] = ($message['is_read'] === 'N');
  887 + $one['url'] = Helpers::url('/home/messageDetail', array('id' => $message['id']));
  888 +
  889 + $result['list'][] = $one;
  890 + }
880 } 891 }
881 892
882 return $result; 893 return $result;
883 } 894 }
884 895
  896 + /*
  897 + * 删除消息
  898 + *
  899 + * @param int $uid 用户ID
  900 + * @param int $id 消息ID
  901 + * @return array
  902 + */
  903 + public static function delMessage($uid, $id)
  904 + {
  905 + $result = array('code' => 400, 'message' => '出错啦~');
  906 +
  907 + do {
  908 + if (empty($uid) || empty($id)) {
  909 + break;
  910 + }
  911 +
  912 + $message = UserData::delMessageData($uid, $id);
  913 + if (isset($message['code']) && $message['code'] == 200) {
  914 + $result['code'] = 200;
  915 + }
  916 +
  917 + } while (false);
  918 +
  919 + return $result;
  920 + }
  921 +
  922 + /*
  923 + * 我的消息中领取生日券
  924 + *
  925 + * @param int $uid 用户ID
  926 + * @param int $id 消息ID
  927 + * @return array
  928 + */
  929 + public static function pickBirthCoupon($uid, $id)
  930 + {
  931 + $result = array('code' => 400, 'message' => '出错啦~');
  932 +
  933 + do {
  934 + if (empty($uid) || empty($id)) {
  935 + break;
  936 + }
  937 +
  938 + $coupon = UserData::getBirthCoupon($uid, $id);
  939 + if (!isset($coupon['code'])) {
  940 + break;
  941 + }
  942 + $result = $coupon;
  943 +
  944 + } while (false);
  945 +
  946 + return $result;
  947 + }
  948 +
  949 + /**
  950 + * 处理我的消息详情信息
  951 + *
  952 + * @param int $uid 用户ID
  953 + * @param int $id 消息ID
  954 + * @return array
  955 + */
  956 + public static function getMessageDetail($uid, $id)
  957 + {
  958 + $result = array();
  959 +
  960 + do {
  961 + // UID或者id为空
  962 + if (empty($uid) || empty($id)) {
  963 + break;
  964 + }
  965 +
  966 + $messageData = UserData::messageData($uid, 1, 1000);
  967 +
  968 + // 接口未正确返回
  969 + if (!isset($messageData['data']['list'])) {
  970 + break;
  971 + }
  972 +
  973 + // 处理我的消息数据
  974 + $messages = $messageData['data']['list'];
  975 + foreach ($messages as $contentval) {
  976 + if ($contentval['id'] != $id) {
  977 + continue;
  978 + }
  979 + //信息过滤
  980 + if ($contentval['type'] === 'showGetCoin' || $contentval['type'] === 'notice') {
  981 + continue;
  982 + }
  983 +
  984 + $result['sender'] = $contentval['from']; //消息发言人
  985 + $result['title'] = $contentval['title']; //消息标题
  986 + $result['time'] = date('Y-m-d H:i:s', $contentval['create_time']); //消息创建时间
  987 + //判断消息类型
  988 + switch ($contentval['type']) {
  989 + case 'pullCoupon':
  990 + //领取生日券消息
  991 + $result['coupons'] = array();
  992 + $coupondata = UserData::getBirthCouponById($uid); //获取优惠券信息
  993 + if (empty($coupondata['data']) || !isset($coupondata['data'])) {
  994 + continue;
  995 + }
  996 + foreach ($coupondata['data'] as $couponval) {
  997 + $result['coupons'][] = array(
  998 + 'id' => isset($couponval['id']) ? $couponval['id'] : '',
  999 + 'remark' => isset($couponval['couponName']) ? $couponval['couponName'] : '',
  1000 + 'useTime' => isset($contentval['body']['use_time']) ? $contentval['body']['use_time'] : '',
  1001 + 'pickTime' => isset($contentval['body']['collar_time']) ? $contentval['body']['collar_time'] : '',
  1002 + 'canPick' => true
  1003 + );
  1004 + }
  1005 + break;
  1006 + case 'button':
  1007 + //促销活动
  1008 + $result['sale'] = array(
  1009 + 'image' => isset($contentval['body']['image']) ? $contentval['body']['image'] : '',
  1010 + 'content' => isset($contentval['body']['text']) ? $contentval['body']['text'] : '',
  1011 + 'btnLink' => isset($contentval['body']['pc_link']) ? $contentval['body']['pc_link'] : '',
  1012 + 'btnName' => isset($contentval['body']['button_text']) ? $contentval['body']['button_text'] : '',
  1013 + );
  1014 + break;
  1015 + case 'pushCoupon':
  1016 + //查看优惠券
  1017 + $result['coupons'] = array();
  1018 + $result['coupons'][] = array(
  1019 + 'remark' => isset($contentval['body']['coupon_name']) ? $contentval['body']['coupon_name'] : '',
  1020 + 'useTime' => isset($contentval['body']['time']) ? $contentval['body']['time'] : '',
  1021 + 'id' => isset($contentval['body']['inboxId']) ? $contentval['body']['inboxId'] : '',
  1022 + 'price' => isset($contentval['body']['price']) ? $contentval['body']['price'] : '',
  1023 + 'url' => Helpers::url('/home/coupons', array('t' => microtime(true)))
  1024 + );
  1025 + break;
  1026 + default:
  1027 + //普通文本
  1028 + $result['text'] = array(
  1029 + 'content' => isset($contentval['body']['content']) ? $contentval['body']['content'] : ''
  1030 + );
  1031 + break;
  1032 + }
  1033 + }
  1034 + } while (false);
  1035 +
  1036 + return $result;
  1037 + }
  1038 +
885 /** 1039 /**
886 * 处理在线客服数据 1040 * 处理在线客服数据
887 * 1041 *