Memberconnect.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 Memberconnect extends BaseMember {
  17. public function initialize() {
  18. parent::initialize(); // TODO: Change the autogenerated stub
  19. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/memberconnect.lang.php');
  20. }
  21. /**
  22. * QQ绑定
  23. */
  24. public function qqbind() {
  25. //获得用户信息
  26. if (trim($this->member_info['member_qqinfo'])) {
  27. $this->member_info['member_qqinfoarr'] = unserialize($this->member_info['member_qqinfo']);
  28. }
  29. View::assign('member_info', $this->member_info);
  30. //信息输出
  31. $this->setMemberCurItem('qq_bind');
  32. $this->setMemberCurMenu('member_connect');
  33. return View::fetch($this->template_dir . 'member_qqbind');
  34. }
  35. /**
  36. * QQ解绑
  37. */
  38. public function qqunbind() {
  39. //修改密码
  40. $member_model = model('member');
  41. $update_arr = array();
  42. if (input('post.is_editpw') == 'yes') {
  43. /**
  44. * 填写密码信息验证
  45. */
  46. $data = array(
  47. 'new_password' => input('post.new_password'),
  48. 'confirm_password' => input('post.confirm_password')
  49. );
  50. $memberconnect_validate = ds_validate('memberconnect');
  51. if (!$memberconnect_validate->scene('qqunbind')->check($data)) {
  52. $this->error($memberconnect_validate->getError());
  53. }
  54. $update_arr['member_password'] = md5(trim(input('post.new_password')));
  55. }
  56. $update_arr['member_qqopenid'] = '';
  57. $update_arr['member_qqinfo'] = '';
  58. $edit_state = $member_model->editMember(array('member_id' => session('member_id')), $update_arr,session('member_id'));
  59. if (!$edit_state) {
  60. $this->error(lang('member_qqconnect_password_modify_fail'),(string)url('Memberconnect/qqbind'));
  61. }
  62. session(null);
  63. session('ref_url',(string)url('Memberconnect/qqbind'));
  64. $this->success(lang('member_qqconnect_unbind_success'), HOME_SITE_URL.'/login/login.html');
  65. }
  66. /**
  67. * 新浪绑定
  68. */
  69. public function sinabind() {
  70. //获得用户信息
  71. if (trim($this->member_info['member_sinainfo'])) {
  72. $this->member_info['member_sinainfoarr'] = unserialize($this->member_info['member_sinainfo']);
  73. }
  74. View::assign('member_info', $this->member_info);
  75. //信息输出
  76. $this->setMemberCurItem('sina_bind');
  77. $this->setMemberCurMenu('member_connect');
  78. return View::fetch($this->template_dir . 'member_sinabind');
  79. }
  80. /**
  81. * 新浪解绑
  82. */
  83. public function sinaunbind() {
  84. //修改密码
  85. $member_model = model('member');
  86. $update_arr = array();
  87. if (input('post.is_editpw') == 'yes') {
  88. /**
  89. * 填写密码信息验证
  90. */
  91. $data = array(
  92. 'new_password' => input('post.new_password'),
  93. 'confirm_password' => input('post.confirm_password')
  94. );
  95. $memberconnect_validate = ds_validate('memberconnect');
  96. if (!$memberconnect_validate->scene('sinaunbind')->check($data)) {
  97. $this->error($memberconnect_validate->getError());
  98. }
  99. $update_arr['member_password'] = md5(trim(input('post.new_password')));
  100. }
  101. $update_arr['member_sinaopenid'] = '';
  102. $update_arr['member_sinainfo'] = '';
  103. $edit_state = $member_model->editMember(array('member_id' => session('member_id')), $update_arr,session('member_id'));
  104. if (!$edit_state) {
  105. $this->error(lang('member_sconnect_password_modify_fail'));
  106. }
  107. session(null);
  108. session('ref_url',(string)url('Memberconnect/sinabind'));
  109. $this->success(lang('member_sconnect_unbind_success'), HOME_SITE_URL.'/Login/login.html');
  110. }
  111. /**
  112. * 微信绑定
  113. */
  114. public function weixinbind() {
  115. //获得用户信息
  116. if (trim($this->member_info['member_wxinfo'])) {
  117. $this->member_info['weixin_infoarr'] = unserialize($this->member_info['member_wxinfo']);
  118. }
  119. View::assign('member_info', $this->member_info);
  120. //信息输出
  121. $this->setMemberCurMenu('member_connect');
  122. $this->setMemberCurItem('weixin_bind');
  123. return View::fetch($this->template_dir . 'member_weixinbind');
  124. }
  125. /**
  126. * 微信解绑
  127. */
  128. public function weixinunbind() {
  129. //修改密码
  130. $member_model = model('member');
  131. $update_arr = array();
  132. if (input('post.is_editpw') == 'yes') {
  133. /**
  134. * 填写密码信息验证
  135. */
  136. $data=[
  137. 'new_password'=>input('post.new_password'),
  138. 'confirm_password'=>input('post.confirm_password')
  139. ];
  140. $memberconnect_validate = ds_validate('memberconnect');
  141. if (!$memberconnect_validate->scene('weixinunbind')->check($data)) {
  142. $this->error($memberconnect_validate->getError());
  143. }
  144. $update_arr['member_password'] = md5(trim(input('post.new_password')));
  145. }
  146. $update_arr['member_wxunionid'] = '';
  147. $update_arr['member_wxopenid'] = '';
  148. $update_arr['member_wxinfo'] = '';
  149. $edit_state = $member_model->editMember(array('member_id' => session('member_id')), $update_arr,session('member_id'));
  150. if (!$edit_state) {
  151. $this->error(lang('ds_common_save_fail'));
  152. }
  153. session(null);
  154. session('ref_url',(string)url('Memberconnect/weixinbind'));
  155. $this->success(lang('wechat_was_unbound_successfully'), HOME_SITE_URL.'/Login/login.html');
  156. }
  157. /**
  158. * 用户中心右边,小导航
  159. *
  160. * @param string $menu_type 导航类型
  161. * @param string $name 当前导航的name
  162. * @param array $array 附加菜单
  163. * @return
  164. */
  165. protected function getMemberItemList() {
  166. $menu_array = array(
  167. array('name' => 'qq_bind', 'text' => lang('ds_member_path_qq_bind'), 'url' => (string)url('Memberconnect/qqbind')),
  168. array('name' => 'sina_bind', 'text' => lang('ds_member_path_sina_bind'), 'url' => (string)url('Memberconnect/sinabind')),
  169. array('name' => 'weixin_bind', 'text' => lang('micro_letter_binding'), 'url' => (string)url('Memberconnect/weixinbind')),
  170. );
  171. return $menu_array;
  172. }
  173. }