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