MemberAuth.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. *
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 控制器
  14. */
  15. class MemberAuth extends BaseMember
  16. {
  17. public function initialize()
  18. {
  19. parent::initialize(); // TODO: Change the autogenerated stub
  20. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/member_auth.lang.php');
  21. }
  22. /**
  23. * 会员升级
  24. *
  25. * @param
  26. * @return
  27. */
  28. public function index()
  29. {
  30. $member_model = model('member');
  31. if (request()->isPost()) {
  32. $member_array = array();
  33. $member_array['member_auth_state'] = 1;
  34. $member_array['member_idcard'] = input('post.member_idcard');
  35. $member_array['member_truename'] = input('post.member_truename');
  36. $member_validate = ds_validate('member');
  37. if (!$member_validate->scene('auth')->check($member_array)) {
  38. ds_json_encode(10001, $member_validate->getError());
  39. }
  40. if (!$this->member_info['member_idcard_image1']) {
  41. ds_json_encode(10001, lang('member_idcard_image1_require'));
  42. }
  43. if (!$this->member_info['member_idcard_image2']) {
  44. ds_json_encode(10001, lang('member_idcard_image2_require'));
  45. }
  46. if (!$this->member_info['member_idcard_image3']) {
  47. ds_json_encode(10001, lang('member_idcard_image3_require'));
  48. }
  49. $update = $member_model->editMember(array(array('member_id', '=', $this->member_info['member_id']), array('member_auth_state', 'in', array(0, 2))), $member_array, $this->member_info['member_id']);
  50. $message = $update ? lang('ds_common_save_succ') : lang('ds_common_save_fail');
  51. if ($update) {
  52. ds_json_encode(10000, $message);
  53. } else {
  54. ds_json_encode(10001, $message);
  55. }
  56. }
  57. View::assign('member_info', $this->member_info);
  58. /* 设置买家当前菜单 */
  59. $this->setMemberCurMenu('member_auth');
  60. /* 设置买家当前栏目 */
  61. $this->setMemberCurItem('index');
  62. return View::fetch($this->template_dir . 'index');
  63. }
  64. public function image_upload()
  65. {
  66. $file_name = input('param.id');
  67. if (!empty($_FILES[$file_name]['name'])) {
  68. $res = ds_upload_pic(ATTACH_IDCARD_IMAGE, $file_name);
  69. if (!$res['code']) {
  70. ds_json_encode(10001, $res['msg']);
  71. }
  72. if (!in_array(substr($file_name, 0, 20), array('member_idcard_image1', 'member_idcard_image2', 'member_idcard_image3'))) {
  73. ds_json_encode(10001, lang('param_error'));
  74. }
  75. $member_array = array();
  76. $member_array[substr($file_name, 0, 20)] = $res['data']['file_name'];
  77. $member_model = model('member');
  78. if (!$member_model->editMember(array(array('member_id', '=', $this->member_info['member_id']), array('member_auth_state', 'in', array(0, 2))), $member_array, $this->member_info['member_id'])) {
  79. ds_json_encode(10001, lang('ds_common_save_fail'));
  80. }
  81. ds_json_encode(10000, '', array('file_name' => $res['data']['file_name'], 'file_path' => get_member_idcard_image($res['data']['file_name'])));
  82. }
  83. ds_json_encode(10001, lang('param_error'));
  84. }
  85. public function image_drop()
  86. {
  87. $file_name = input('param.file_name');
  88. if (!in_array($file_name, array('member_idcard_image1', 'member_idcard_image2', 'member_idcard_image3'))) {
  89. ds_json_encode(10001, lang('param_error'));
  90. }
  91. @unlink(BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_IDCARD_IMAGE . DIRECTORY_SEPARATOR . $this->member_info[$file_name]);
  92. $member_array = array();
  93. $member_array[$file_name] = '';
  94. $member_model = model('member');
  95. if (!$member_model->editMember(array(array('member_id', '=', $this->member_info['member_id']), array('member_auth_state', 'in', array(0, 2))), $member_array, $this->member_info['member_id'])) {
  96. ds_json_encode(10001, lang('ds_common_save_fail'));
  97. }
  98. ds_json_encode(10000);
  99. }
  100. /**
  101. * 用户中心右边,小导航
  102. *
  103. * @param string $menu_type 导航类型
  104. * @param string $menu_key 当前导航的menu_key
  105. * @return
  106. */
  107. public function getMemberItemList()
  108. {
  109. $menu_array = array(
  110. array(
  111. 'name' => 'index',
  112. 'text' => lang('member_auth'),
  113. 'url' => (string)url('MemberAuth/index')
  114. ),
  115. );
  116. return $menu_array;
  117. }
  118. }