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