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