Alisms.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace addons\alisms;
  3. use think\Addons;
  4. /**
  5. * Alisms
  6. */
  7. class Alisms extends Addons
  8. {
  9. /**
  10. * 插件安装方法
  11. * @return bool
  12. */
  13. public function install()
  14. {
  15. return true;
  16. }
  17. /**
  18. * 插件卸载方法
  19. * @return bool
  20. */
  21. public function uninstall()
  22. {
  23. return true;
  24. }
  25. /**
  26. * 短信发送行为
  27. * @param $params
  28. * @return boolean
  29. */
  30. public function smsSend(&$params)
  31. {
  32. $config = get_addon_config('alisms');
  33. $alisms = new library\Alisms();
  34. $result = $alisms->mobile($params->mobile)
  35. ->template($config['template'][$params->event])
  36. ->param(['code' => $params->code])
  37. ->send();
  38. return $result;
  39. }
  40. /**
  41. * 短信发送通知
  42. * @param $params
  43. * @return boolean
  44. */
  45. public function smsNotice(&$params)
  46. {
  47. $alisms = library\Alisms::instance();
  48. if (is_array($params['msg'])) {
  49. $param = $params['msg'];
  50. } else {
  51. parse_str($params['msg'], $param);
  52. }
  53. $param = $param ? $param : [];
  54. $result = $alisms->mobile($params['mobile'])
  55. ->template($params['template'])
  56. ->param($param)
  57. ->send();
  58. return $result;
  59. }
  60. /**
  61. * 检测验证是否正确
  62. * @param $params
  63. * @return boolean
  64. */
  65. public function smsCheck(&$params)
  66. {
  67. return true;
  68. }
  69. }