BindController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * BindController.php UTF-8
  4. * h5 手机版定
  5. *
  6. * @date : 2018/4/27 21:50
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : liuhongliang <lhl@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace h5wap\wap\controller;
  13. use h5wap\common\controller\V2BaseController;
  14. use huo\controller\member\Bind;
  15. use huo\controller\member\MemCache;
  16. use huolib\sms\SmsType;
  17. use huolib\tool\StrUtils;
  18. use think\Session;
  19. class BindController extends V2BaseController {
  20. public function _initialize() {
  21. parent::_initialize();
  22. $this->checkLogin();
  23. }
  24. /**
  25. * h5wap 绑定手机
  26. * http://doc.1tsdk.com/138?page_id=3137
  27. *
  28. * 【域名】/wap/user/bind/mobile
  29. *
  30. * @return mixed
  31. */
  32. public function bindMobile() {
  33. $_bind_class = new Bind();
  34. $_mobile = $_bind_class->getHasBindMobile($this->mem_id);
  35. $this->assign('CheckOk', $_bind_class->getCheckOk());
  36. if (!empty($_mobile)) {
  37. /* 已绑定手机 */
  38. $_mobile = StrUtils::encryptPhone($_mobile);
  39. /* 显示已绑定手机页面 */
  40. $this->assign('mobile', $_mobile);
  41. if ($_bind_class->getCheckOk()) {
  42. /* 去绑定手机页面 */
  43. return $this->fetch('bind/bind');
  44. } else {
  45. return $this->fetch('bind/check');
  46. }
  47. } else {
  48. /* 显示未绑定手机页面 */
  49. return $this->fetch('bind/bind');
  50. }
  51. }
  52. /**
  53. * H5WAP-发送短信
  54. * http://doc.1tsdk.com/138?page_id=3230
  55. * 【域名】/wap/sms/send
  56. */
  57. public function smsSend() {
  58. $_sms_data = get_val($this->rq_data, 'sms', []);
  59. $_mobile = get_val($_sms_data, 'mobile', '');
  60. $_type = get_val($_sms_data, 'type', SmsType::SMS_ID_VERIFY);
  61. $_bind_class = new Bind();
  62. $_rdata = $_bind_class->smsSend($_mobile, $_type);
  63. return $this->returnData($_rdata);
  64. }
  65. /**
  66. * 校验原有手机
  67. * http://doc.1tsdk.com/138?page_id=3231
  68. * 【域名】/wap/sms/checkold
  69. *
  70. */
  71. public function verifyOldMobile() {
  72. $_sms_data = get_val($this->rq_data, 'sms', []);
  73. $_mobile = get_val($_sms_data, 'mobile', '');
  74. $_type = get_val($_sms_data, 'type', SmsType::SMS_ID_VERIFY);
  75. $_code = get_val($_sms_data, 'code', '');
  76. $_bind_class = new Bind();
  77. $_rdata = $_bind_class->checkOldMobile($_mobile, $_code, $_type);
  78. return $this->returnData($_rdata);
  79. }
  80. /**
  81. * 绑定手机
  82. * http://doc.1tsdk.com/138?page_id=3232
  83. * 【域名】/wap/mobile/bind
  84. */
  85. public function bindPost() {
  86. $_sms_data = get_val($this->rq_data, 'sms', []);
  87. $_mobile = get_val($_sms_data, 'mobile', '');
  88. $_type = get_val($_sms_data, 'type', SmsType::SMS_ID_VERIFY);
  89. $_code = get_val($_sms_data, 'code', '');
  90. $_mem_rq = $this->setMemData();
  91. $_bind_class = new Bind();
  92. $_rdata = $_bind_class->bindPost($this->mem_id, $_mobile, $_code, $_type, $_mem_rq->getPassword());
  93. return $this->returnData($_rdata);
  94. }
  95. }