Membercard.php 4.4 KB

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