MemberAuth.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. * DSMall多用户商城
  8. * ============================================================================
  9. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  10. * 网站地址: http://www.csdeshang.com
  11. * ----------------------------------------------------------------------------
  12. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  13. * 不允许对程序代码以任何形式任何目的的再发布。
  14. * ============================================================================
  15. * 控制器
  16. */
  17. class MemberAuth extends BaseMember
  18. {
  19. public function initialize()
  20. {
  21. parent::initialize(); // TODO: Change the autogenerated stub
  22. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/member_auth.lang.php');
  23. }
  24. /**
  25. * 会员升级
  26. *
  27. * @param
  28. * @return
  29. */
  30. public function index()
  31. {
  32. $member_model = model('member');
  33. if (request()->isPost()) {
  34. $member_array = array();
  35. $member_array['member_auth_state'] = 1;
  36. $member_array['member_idcard'] = input('post.member_idcard');
  37. $member_array['member_truename'] = input('post.member_truename');
  38. $member_validate = ds_validate('member');
  39. if (!$member_validate->scene('auth')->check($member_array)) {
  40. ds_json_encode(10001,$member_validate->getError());
  41. }
  42. if(!$this->member_info['member_idcard_image1']){
  43. ds_json_encode(10001,lang('member_idcard_image1_require'));
  44. }
  45. if(!$this->member_info['member_idcard_image2']){
  46. ds_json_encode(10001,lang('member_idcard_image2_require'));
  47. }
  48. if(!$this->member_info['member_idcard_image3']){
  49. ds_json_encode(10001,lang('member_idcard_image3_require'));
  50. }
  51. $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']);
  52. $message = $update ? lang('ds_common_save_succ') : lang('ds_common_save_fail');
  53. if($update){
  54. ds_json_encode(10000,$message);
  55. }else{
  56. ds_json_encode(10001,$message);
  57. }
  58. }
  59. View::assign('member_info', $this->member_info);
  60. /* 设置买家当前菜单 */
  61. $this->setMemberCurMenu('member_auth');
  62. /* 设置买家当前栏目 */
  63. $this->setMemberCurItem('index');
  64. return View::fetch($this->template_dir.'index');
  65. }
  66. public function image_upload() {
  67. $file_name = input('param.id');
  68. if (!empty($_FILES[$file_name]['name'])) {
  69. $res=ds_upload_pic(ATTACH_IDCARD_IMAGE,$file_name);
  70. if(!$res['code']){
  71. ds_json_encode(10001,$res['msg']);
  72. }
  73. if(!in_array(substr($file_name,0,20),array('member_idcard_image1','member_idcard_image2','member_idcard_image3'))){
  74. ds_json_encode(10001,lang('param_error'));
  75. }
  76. $member_array=array();
  77. $member_array[substr($file_name,0,20)] = $res['data']['file_name'];
  78. $member_model = model('member');
  79. 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'])){
  80. ds_json_encode(10001,lang('ds_common_save_fail'));
  81. }
  82. ds_json_encode(10000,'',array('file_name'=>$res['data']['file_name'],'file_path'=>get_member_idcard_image($res['data']['file_name'])));
  83. }
  84. ds_json_encode(10001,lang('param_error'));
  85. }
  86. public function image_drop(){
  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. }