123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <?php
- namespace app\home\controller;
- use think\facade\View;
- use think\facade\Lang;
- /**
-
- *
-
- *
- * ----------------------------------------------------------------------------
- *
-
- * 控制器
- */
- class MemberAuth extends BaseMember
- {
- public function initialize()
- {
- parent::initialize(); // TODO: Change the autogenerated stub
- Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/member_auth.lang.php');
- }
- /**
- * 会员升级
- *
- * @param
- * @return
- */
- public function index()
- {
- $member_model = model('member');
- if (request()->isPost()) {
- $member_array = array();
- $member_array['member_auth_state'] = 1;
- $member_array['member_idcard'] = input('post.member_idcard');
- $member_array['member_truename'] = input('post.member_truename');
- $member_validate = ds_validate('member');
- if (!$member_validate->scene('auth')->check($member_array)) {
- ds_json_encode(10001, $member_validate->getError());
- }
- if (!$this->member_info['member_idcard_image1']) {
- ds_json_encode(10001, lang('member_idcard_image1_require'));
- }
- if (!$this->member_info['member_idcard_image2']) {
- ds_json_encode(10001, lang('member_idcard_image2_require'));
- }
- if (!$this->member_info['member_idcard_image3']) {
- ds_json_encode(10001, lang('member_idcard_image3_require'));
- }
- $res = $this->getIdCardInfo($this->member_info);
- if ($res['code'] == 200) {
- $info = $res['data'];
- if ($member_array['member_idcard'] != $info['idcard'] || $member_array['member_truename'] !== $info['name']) {
- ds_json_encode(10001,'您提交的身份信息或身份证照片未通过校验,请仔细核对后提交');
- }
- } else {
- ds_json_encode(10001,$res['msg']);
- }
- $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']);
- $message = $update ? lang('ds_common_save_succ') : lang('ds_common_save_fail');
- if ($update) {
- ds_json_encode(10000, $message);
- } else {
- ds_json_encode(10001, $message);
- }
- }
- View::assign('member_info', $this->member_info);
- /* 设置买家当前菜单 */
- $this->setMemberCurMenu('member_auth');
- /* 设置买家当前栏目 */
- $this->setMemberCurItem('index');
- return View::fetch($this->template_dir . 'index');
- }
- public function index2()
- {
- ds_json_encode(10001, lang('member_idcard_image2_require'));
- $member_model = model('member');
- if (request()->isPost()) {
- $member_array = array();
- $member_array['member_auth_state'] = 1;
- $member_array['member_idcard'] = input('post.member_idcard');
- $member_array['member_truename'] = input('post.member_truename');
- // $member_validate = ds_validate('member');
- // if (!$member_validate->scene('auth')->check($member_array)) {
- // ds_json_encode(10001, $member_validate->getError());
- // }
- if (!$this->member_info['member_idcard_image2']) {
- ds_json_encode(10001, lang('member_idcard_image2_require'));
- }
- $res = $this->getIdCardInfo($this->member_info);
- if ($res['code'] == 200) {
- $info = $res['data'];
- if ($member_array['member_idcard'] != $info['idcard'] || $member_array['member_truename'] !== $info['name']) {
- ds_json_encode(10001,'您提交的身份信息或身份证照片未通过校验,请仔细核对后提交');
- }
- } else {
- ds_json_encode(10001,$res['msg']);
- }
- $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']);
- $message = $update ? lang('ds_common_save_succ') : lang('ds_common_save_fail');
- if ($update) {
- ds_json_encode(10000, $message);
- } else {
- ds_json_encode(10001, $message);
- }
- }
- View::assign('member_info', $this->member_info);
- /* 设置买家当前菜单 */
- $this->setMemberCurMenu('member_auth');
- /* 设置买家当前栏目 */
- $this->setMemberCurItem('index');
- return View::fetch($this->template_dir . 'index');
- }
- public function image_upload()
- {
- $file_name = input('param.id');
- if (!empty($_FILES[$file_name]['name'])) {
- // $file = request()->file($file_name);
- // $size = $file->getSize();
- // if ($size > 10485760) {
- // ds_json_encode(10001, '上传图片大学不能超过10M');
- // }
- $res = ds_upload_pic(ATTACH_IDCARD_IMAGE, $file_name);
- if (!$res['code']) {
- ds_json_encode(10001, $res['msg']);
- }
- if (!in_array(substr($file_name, 0, 20), array('member_idcard_image1', 'member_idcard_image2', 'member_idcard_image3'))) {
- ds_json_encode(10001, lang('param_error'));
- }
- $member_array = array();
- $member_array[substr($file_name, 0, 20)] = $res['data']['file_name'];
- $member_model = model('member');
- 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'])) {
- ds_json_encode(10001, lang('ds_common_save_fail'));
- }
- ds_json_encode(10000, '', array('file_name' => $res['data']['file_name'], 'file_path' => get_member_idcard_image($res['data']['file_name'])));
- }
- ds_json_encode(10001, lang('param_error'));
- }
- public function image_upload2()
- {
- $memberId = session('member_id');
- session('member_image_'.$memberId,'');
- $file_name = input('param.id');
- if (!empty($_FILES[$file_name]['name'])) {
- // $file = request()->file($file_name);
- // $size = $file->getSize();
- // if ($size > 10485760) {
- // ds_json_encode(10001, '上传图片大学不能超过10M');
- // }
- $res = ds_upload_pic(ATTACH_STORE_JOININ, $file_name);
- if (!$res['code']) {
- ds_json_encode(10001, $res['msg']);
- }
- if (!in_array(substr($file_name, 0, 20), array('member_idcard_image1', 'member_idcard_image2', 'member_idcard_image3'))) {
- ds_json_encode(10001, lang('param_error'));
- }
- $member_array = array();
- $member_array[substr($file_name, 0, 20)] = $res['data']['file_name'];
- $member_model = model('member');
- // 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'])) {
- // ds_json_encode(10001, lang('ds_common_save_fail'));
- // }
- ds_json_encode(10000, '', array('file_name' => $res['data']['file_name'], 'file_path' => get_store_joinin_imageurl($res['data']['file_name'])));
- }
- ds_json_encode(10001, lang('param_error'));
- }
- public function image_drop()
- {
- $file_name = input('param.file_name');
- if (!in_array($file_name, array('member_idcard_image1', 'member_idcard_image2', 'member_idcard_image3'))) {
- ds_json_encode(10001, lang('param_error'));
- }
- @unlink(BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_IDCARD_IMAGE . DIRECTORY_SEPARATOR . $this->member_info[$file_name]);
- $member_array = array();
- $member_array[$file_name] = '';
- $member_model = model('member');
- 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'])) {
- ds_json_encode(10001, lang('ds_common_save_fail'));
- }
- ds_json_encode(10000);
- }
- public function image_drop2()
- {
- $memberId = session('member_id');
- $data2 = session('member_image2_'.$memberId);
- $data3 = session('member_image3_'.$memberId);
- ds_json_encode(10000, '',
- array('image2' =>get_store_joinin_imageurl($data2['business_licence_number_electronic']),
- 'image3'=>get_store_joinin_imageurl($data3['business_author_letter']))
- );
- }
- public function image_drop3()
- {
- ds_json_encode(10000);
- }
- /**
- * 用户中心右边,小导航
- *
- * @param string $menu_type 导航类型
- * @param string $menu_key 当前导航的menu_key
- * @return
- */
- public function getMemberItemList()
- {
- $menu_array = array(
- array(
- 'name' => 'index',
- 'text' => lang('member_auth'),
- 'url' => (string)url('MemberAuth/index')
- ),
- );
- return $menu_array;
- }
- }
|