Membercard.php 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\Lang;
  4. use think\facade\Db;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. *
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 控制器
  14. */
  15. class Membercard extends BaseMall
  16. {
  17. /**
  18. * AJAX for membership information
  19. */
  20. public function index()
  21. {
  22. $ownid = session('member_id');
  23. $uid = intval(input('get.uid'));
  24. $member_info = Db::name('member')->field('member_id, member_name, member_truename, member_sex, member_email, member_qq, member_ww, member_areainfo, member_birthday, member_privacy, member_exppoints')->find($uid);
  25. if (empty($member_info)) {
  26. echo 'false';
  27. exit;
  28. }
  29. if ($member_info['member_privacy'] != '') {
  30. $member_info['member_privacy'] = unserialize($member_info['member_privacy']);
  31. }
  32. //会员详情及会员级别处理
  33. if ($member_info) {
  34. $member_gradeinfo = model('member')->getOneMemberGrade(intval($member_info['member_exppoints']));
  35. $member_info = array_merge($member_info, $member_gradeinfo);
  36. }
  37. if ($ownid == $uid) {
  38. $followed = 2;
  39. } else {
  40. // Whether to pay attention to yourself(own)
  41. $followed = 0; // 0 stranger, 1 friend, 2 own
  42. $friend_info = Db::name('snsfriend')->where('friend_frommid', $uid)->where('friend_tomid', $ownid)->find();
  43. if (!empty($friend_info)) {
  44. $followed = 1;
  45. }
  46. }
  47. $data = array();
  48. $data['id'] = $member_info['member_id'];
  49. $data['name'] = $member_info['member_name'];
  50. $data['avatar'] = get_member_avatar_for_id($member_info['member_id']);
  51. $data['nickname'] = ($followed >= intval($member_info['member_privacy']['nickname']) && !empty($member_info['member_nickname'])) ? $member_info['member_nickname'] : '';
  52. $data['sex'] = ($followed >= intval($member_info['member_privacy']['sex']) && !empty($member_info['member_sex'])) ? $member_info['member_sex'] : 3;
  53. $data['email'] = ($followed >= intval($member_info['member_privacy']['email']) && !empty($member_info['member_email'])) ? $member_info['member_email'] : lang('home_member_privary');
  54. $data['qq'] = ($followed >= intval($member_info['member_privacy']['qq']) && !empty($member_info['member_qq'])) ? $member_info['member_qq'] : '';
  55. $data['ww'] = ($followed >= intval($member_info['member_privacy']['ww']) && !empty($member_info['member_ww'])) ? $member_info['member_ww'] : '';
  56. $data['areainfo'] = ($followed >= intval($member_info['member_privacy']['area']) && !empty($member_info['member_areainfo'])) ? $member_info['member_areainfo'] : lang('home_member_privary');
  57. $data['birthday'] = ($followed >= intval($member_info['member_privacy']['birthday']) && !empty($member_info['member_birthday'])) ? $member_info['member_birthday'] : lang('home_member_privary');
  58. $data['level_name'] = $member_info['level_name'];
  59. switch (input('get.from')) {
  60. case 'shop':
  61. $data['url'] = HOME_SITE_URL;
  62. break;
  63. default:
  64. $data['url'] = '';
  65. break;
  66. }
  67. if ($ownid == $uid) {
  68. $data['follow'] = 2; // 0 stranger, 1 friend, 2 own
  69. } else {
  70. // Whether to pay attention to me
  71. $friend_info = Db::name('snsfriend')->where('friend_frommid', $ownid)->where('friend_tomid', $uid)->find();
  72. $data['follow'] = (!empty($friend_info)) ? 1 : 0;
  73. }
  74. // Pay attention to the number of
  75. $data['attention_count'] = Db::name('snsfriend')->where(array('friend_frommid' => $uid))->count();
  76. // Number of fans
  77. $data['fans_count'] = Db::name('snsfriend')->where(array('friend_tomid' => $uid))->count();
  78. echo $_GET['callback'] . '(' . json_encode($data) . ')';
  79. }
  80. public function mcard_info()
  81. {
  82. echo 'false';
  83. exit;
  84. }
  85. }