Memberconnect.php 6.8 KB

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