MemberAuth.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. $res = $this->getIdCardInfo($this->member_info);
  47. if ($res['code'] == 200) {
  48. $info = $res['data'];
  49. if ($member_array['member_idcard'] != $info['idcard'] || $member_array['member_truename'] !== $info['name']) {
  50. ds_json_encode(10001,'您提交的身份信息或身份证照片未通过校验,请仔细核对后提交');
  51. }
  52. } else {
  53. ds_json_encode(10001,$res['msg']);
  54. }
  55. $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']);
  56. $message = $update ? lang('ds_common_save_succ') : lang('ds_common_save_fail');
  57. if ($update) {
  58. ds_json_encode(10000, $message);
  59. } else {
  60. ds_json_encode(10001, $message);
  61. }
  62. }
  63. View::assign('member_info', $this->member_info);
  64. /* 设置买家当前菜单 */
  65. $this->setMemberCurMenu('member_auth');
  66. /* 设置买家当前栏目 */
  67. $this->setMemberCurItem('index');
  68. return View::fetch($this->template_dir . 'index');
  69. }
  70. public function index2()
  71. {
  72. ds_json_encode(10001, lang('member_idcard_image2_require'));
  73. $member_model = model('member');
  74. if (request()->isPost()) {
  75. $member_array = array();
  76. $member_array['member_auth_state'] = 1;
  77. $member_array['member_idcard'] = input('post.member_idcard');
  78. $member_array['member_truename'] = input('post.member_truename');
  79. // $member_validate = ds_validate('member');
  80. // if (!$member_validate->scene('auth')->check($member_array)) {
  81. // ds_json_encode(10001, $member_validate->getError());
  82. // }
  83. if (!$this->member_info['member_idcard_image2']) {
  84. ds_json_encode(10001, lang('member_idcard_image2_require'));
  85. }
  86. $res = $this->getIdCardInfo($this->member_info);
  87. if ($res['code'] == 200) {
  88. $info = $res['data'];
  89. if ($member_array['member_idcard'] != $info['idcard'] || $member_array['member_truename'] !== $info['name']) {
  90. ds_json_encode(10001,'您提交的身份信息或身份证照片未通过校验,请仔细核对后提交');
  91. }
  92. } else {
  93. ds_json_encode(10001,$res['msg']);
  94. }
  95. $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']);
  96. $message = $update ? lang('ds_common_save_succ') : lang('ds_common_save_fail');
  97. if ($update) {
  98. ds_json_encode(10000, $message);
  99. } else {
  100. ds_json_encode(10001, $message);
  101. }
  102. }
  103. View::assign('member_info', $this->member_info);
  104. /* 设置买家当前菜单 */
  105. $this->setMemberCurMenu('member_auth');
  106. /* 设置买家当前栏目 */
  107. $this->setMemberCurItem('index');
  108. return View::fetch($this->template_dir . 'index');
  109. }
  110. public function image_upload()
  111. {
  112. $file_name = input('param.id');
  113. if (!empty($_FILES[$file_name]['name'])) {
  114. // $file = request()->file($file_name);
  115. // $size = $file->getSize();
  116. // if ($size > 10485760) {
  117. // ds_json_encode(10001, '上传图片大学不能超过10M');
  118. // }
  119. $res = ds_upload_pic(ATTACH_IDCARD_IMAGE, $file_name);
  120. if (!$res['code']) {
  121. ds_json_encode(10001, $res['msg']);
  122. }
  123. if (!in_array(substr($file_name, 0, 20), array('member_idcard_image1', 'member_idcard_image2', 'member_idcard_image3'))) {
  124. ds_json_encode(10001, lang('param_error'));
  125. }
  126. $member_array = array();
  127. $member_array[substr($file_name, 0, 20)] = $res['data']['file_name'];
  128. $member_model = model('member');
  129. 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'])) {
  130. ds_json_encode(10001, lang('ds_common_save_fail'));
  131. }
  132. ds_json_encode(10000, '', array('file_name' => $res['data']['file_name'], 'file_path' => get_member_idcard_image($res['data']['file_name'])));
  133. }
  134. ds_json_encode(10001, lang('param_error'));
  135. }
  136. public function image_upload2()
  137. {
  138. $memberId = session('member_id');
  139. session('member_image_'.$memberId,'');
  140. $file_name = input('param.id');
  141. if (!empty($_FILES[$file_name]['name'])) {
  142. // $file = request()->file($file_name);
  143. // $size = $file->getSize();
  144. // if ($size > 10485760) {
  145. // ds_json_encode(10001, '上传图片大学不能超过10M');
  146. // }
  147. $res = ds_upload_pic(ATTACH_STORE_JOININ, $file_name);
  148. if (!$res['code']) {
  149. ds_json_encode(10001, $res['msg']);
  150. }
  151. if (!in_array(substr($file_name, 0, 20), array('member_idcard_image1', 'member_idcard_image2', 'member_idcard_image3'))) {
  152. ds_json_encode(10001, lang('param_error'));
  153. }
  154. $member_array = array();
  155. $member_array[substr($file_name, 0, 20)] = $res['data']['file_name'];
  156. $member_model = model('member');
  157. // 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'])) {
  158. // ds_json_encode(10001, lang('ds_common_save_fail'));
  159. // }
  160. ds_json_encode(10000, '', array('file_name' => $res['data']['file_name'], 'file_path' => get_store_joinin_imageurl($res['data']['file_name'])));
  161. }
  162. ds_json_encode(10001, lang('param_error'));
  163. }
  164. public function image_drop()
  165. {
  166. $file_name = input('param.file_name');
  167. if (!in_array($file_name, array('member_idcard_image1', 'member_idcard_image2', 'member_idcard_image3'))) {
  168. ds_json_encode(10001, lang('param_error'));
  169. }
  170. @unlink(BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_IDCARD_IMAGE . DIRECTORY_SEPARATOR . $this->member_info[$file_name]);
  171. $member_array = array();
  172. $member_array[$file_name] = '';
  173. $member_model = model('member');
  174. 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'])) {
  175. ds_json_encode(10001, lang('ds_common_save_fail'));
  176. }
  177. ds_json_encode(10000);
  178. }
  179. public function image_drop2()
  180. {
  181. $memberId = session('member_id');
  182. $data2 = session('member_image2_'.$memberId);
  183. $data3 = session('member_image3_'.$memberId);
  184. ds_json_encode(10000, '',
  185. array('image2' =>get_store_joinin_imageurl($data2['business_licence_number_electronic']),
  186. 'image3'=>get_store_joinin_imageurl($data3['business_author_letter']))
  187. );
  188. }
  189. public function image_drop3()
  190. {
  191. ds_json_encode(10000);
  192. }
  193. /**
  194. * 用户中心右边,小导航
  195. *
  196. * @param string $menu_type 导航类型
  197. * @param string $menu_key 当前导航的menu_key
  198. * @return
  199. */
  200. public function getMemberItemList()
  201. {
  202. $menu_array = array(
  203. array(
  204. 'name' => 'index',
  205. 'text' => lang('member_auth'),
  206. 'url' => (string)url('MemberAuth/index')
  207. ),
  208. );
  209. return $menu_array;
  210. }
  211. }