Memberconnect.php 7.3 KB

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