account.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. $config = [
  3. 'list' => [
  4. 'desc' => '当同一个功能有两个账户时,将按照排序和状态使用最新的一个账户',
  5. 'field' => [
  6. 'name',
  7. 'method',
  8. 'sort',
  9. 'test' => [
  10. 'tip' => '开启后,将不会实际发送请求',
  11. 'type' => 'switch',
  12. 'show' => '{test}',
  13. 'active_value' => 1,
  14. 'inactive_value' => 2,
  15. ],
  16. 'status',
  17. ],
  18. 'button' => [
  19. '新增' => ['fastadd', 'name,method,api_account_id,msg/account_email'],
  20. ],
  21. 'data_button' => [
  22. '设置' => ['fastedit', 'name,method,api_account_id,msg/account_email'],
  23. '短信模板' => ['fastedit', 'msg/account_sms,tip', '', 'method=sms'],
  24. '微信模板' => ['fastedit', 'msg/account_wechat,tip', '', 'method=wechat_service,wechat_applet'],
  25. ],
  26. 'search' => [
  27. 'name',
  28. 'method',
  29. 'status',
  30. ]
  31. ],
  32. 'update' => [
  33. 'field' => [
  34. 'name',
  35. 'method' => 'radio',
  36. 'api_account_id' => 'select',
  37. 'msg/account_email' => [
  38. 'name' => '邮件设置',
  39. 'where' => ['account_id' => 'id'],
  40. 'default' => [[]],
  41. # 默认使用表格形式展示,可以改成每行展示
  42. 'type' => 'line',
  43. ],
  44. ],
  45. 'control' => [
  46. 'msg/account_email' => [
  47. 'method' => ['email'],
  48. ],
  49. 'api_account_id' => [
  50. 'method' => ['sms', 'wechat_service', 'wechat_applet', 'app'],
  51. ],
  52. ],
  53. ],
  54. ];
  55. $id = Dever::input('id');
  56. if ($id > 0) {
  57. $default = [];
  58. $info = Dever::db('account', 'msg')->find($id);
  59. $template = Dever::db('template', 'msg')->select(['method' => ['like', $info['method']]]);
  60. if ($template) {
  61. foreach ($template as $v) {
  62. $default[] = [
  63. 'template_id' => $v['id'],
  64. 'template_name' => $v['name'],
  65. ];
  66. }
  67. if ($info['method'] == 'sms') {
  68. $config['update']['field']['msg/account_sms'] = [
  69. 'name' => '短信模板',
  70. 'where' => ['account_id' => 'id'],
  71. 'default' => $default,
  72. ];
  73. } elseif (strstr($info['method'], 'wechat')) {
  74. $config['update']['field']['msg/account_wechat'] = [
  75. 'name' => '微信模板',
  76. 'where' => ['account_id' => 'id'],
  77. 'default' => $default,
  78. ];
  79. }
  80. } else {
  81. if ($info['method'] == 'sms') {
  82. $config['update']['field']['tip'] = [
  83. 'name' => '短信模板',
  84. 'type' => 'show',
  85. 'default' => '暂无短信模板,请在消息模板中选择',
  86. ];
  87. } elseif (strstr($info['method'], 'wechat')) {
  88. $config['update']['field']['tip'] = [
  89. 'name' => '微信模板',
  90. 'type' => 'show',
  91. 'default' => '暂无微信模板,请在消息模板中选择',
  92. ];
  93. }
  94. }
  95. }
  96. return $config;