MemberAuth.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  10. * 网站地址: https://www.valimart.net/
  11. * ----------------------------------------------------------------------------
  12. *
  13. * ============================================================================
  14. * 控制器
  15. */
  16. class MemberAuth extends BaseMember
  17. {
  18. public function initialize()
  19. {
  20. parent::initialize(); // TODO: Change the autogenerated stub
  21. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/member_auth.lang.php');
  22. }
  23. /**
  24. * 会员升级
  25. *
  26. * @param
  27. * @return
  28. */
  29. public function index()
  30. {
  31. $member_model = model('member');
  32. if (request()->isPost()) {
  33. $member_array = array();
  34. $member_array['member_auth_state'] = 1;
  35. $member_array['member_idcard'] = input('post.member_idcard');
  36. $member_array['member_truename'] = input('post.member_truename');
  37. $member_validate = ds_validate('member');
  38. if (!$member_validate->scene('auth')->check($member_array)) {
  39. ds_json_encode(10001,$member_validate->getError());
  40. }
  41. if(!$this->member_info['member_idcard_image1']){
  42. ds_json_encode(10001,lang('member_idcard_image1_require'));
  43. }
  44. if(!$this->member_info['member_idcard_image2']){
  45. ds_json_encode(10001,lang('member_idcard_image2_require'));
  46. }
  47. if(!$this->member_info['member_idcard_image3']){
  48. ds_json_encode(10001,lang('member_idcard_image3_require'));
  49. }
  50. $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']);
  51. $message = $update ? lang('ds_common_save_succ') : lang('ds_common_save_fail');
  52. if($update){
  53. ds_json_encode(10000,$message);
  54. }else{
  55. ds_json_encode(10001,$message);
  56. }
  57. }
  58. View::assign('member_info', $this->member_info);
  59. /* 设置买家当前菜单 */
  60. $this->setMemberCurMenu('member_auth');
  61. /* 设置买家当前栏目 */
  62. $this->setMemberCurItem('index');
  63. return View::fetch($this->template_dir.'index');
  64. }
  65. public function image_upload() {
  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. $file_name=input('param.file_name');
  87. if(!in_array($file_name,array('member_idcard_image1','member_idcard_image2','member_idcard_image3'))){
  88. ds_json_encode(10001,lang('param_error'));
  89. }
  90. @unlink(BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_IDCARD_IMAGE . DIRECTORY_SEPARATOR . $this->member_info[$file_name]);
  91. $member_array=array();
  92. $member_array[$file_name] = '';
  93. $member_model = model('member');
  94. 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'])){
  95. ds_json_encode(10001,lang('ds_common_save_fail'));
  96. }
  97. ds_json_encode(10000);
  98. }
  99. /**
  100. * 用户中心右边,小导航
  101. *
  102. * @param string $menu_type 导航类型
  103. * @param string $menu_key 当前导航的menu_key
  104. * @return
  105. */
  106. public function getMemberItemList()
  107. {
  108. $menu_array = array(
  109. array(
  110. 'name' => 'index',
  111. 'text' => lang('member_auth'),
  112. 'url' => (string)url('MemberAuth/index')
  113. ),
  114. );
  115. return $menu_array;
  116. }
  117. }