wxgzhAction.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. class wxgzhClassAction extends Action
  3. {
  4. public function setsaveAjax()
  5. {
  6. m('wxgzh:index')->clearalltoken();
  7. $pid = m('wxgzh:index')->optionpid;
  8. $this->option->setval('wxgzh_appid@'.$pid.'', $this->post('appid'));
  9. $this->option->setval('wxgzh_secret@'.$pid.'', $this->post('secret'));
  10. $this->option->setval('wxgzh_tplmess@'.$pid.'', $this->post('tplmess'));
  11. $this->option->setval('wxgzh_centerurl@'.$pid.'', $this->post('centerurl'));
  12. $this->backmsg();
  13. }
  14. public function getsetAjax()
  15. {
  16. $arr= array();
  17. $arr['appid'] = $this->option->getval('wxgzh_appid');
  18. $arr['secret'] = $this->option->getval('wxgzh_secret');
  19. $arr['tplmess'] = $this->option->getval('wxgzh_tplmess');
  20. $arr['centerurl'] = $this->option->getval('wxgzh_centerurl');
  21. echo json_encode($arr);
  22. }
  23. public function testsendAjax()
  24. {
  25. $lx = (int)$this->get('lx');
  26. if($lx==0){
  27. $val = m('wxgzh:wxgzh')->getticket();
  28. }else{
  29. $val = 'ok';
  30. }
  31. if($val==''){
  32. showreturn('','测试失败');
  33. }else{
  34. showreturn('','测试成功');
  35. }
  36. }
  37. //获取模版消息列表
  38. public function getlisttplAjax()
  39. {
  40. return m('wxgzh:index')->gettpllist();
  41. }
  42. public function wotpl_before($table)
  43. {
  44. return array(
  45. 'order' => 'status desc'
  46. );
  47. }
  48. public function wouser_before($table)
  49. {
  50. $where = '';
  51. $key = $this->post('key');
  52. if(!isempt($key)){
  53. $where=" and (`nickname` like '%$key%' or `province`='$key' or `city`='$key')";
  54. }
  55. return $where;
  56. }
  57. public function wotpl_after($table, $rows)
  58. {
  59. return array(
  60. 'rows' => $rows
  61. );
  62. }
  63. public function wxxcyus_after($table, $rows)
  64. {
  65. $dm = getconfig('systype');
  66. foreach($rows as $k=>$rs){
  67. if(!isempt($rs['mobile'])){
  68. $rows[$k]['mobile'] = substr($rs['mobile'],0,3).'****'.substr($rs['mobile'],-4);
  69. if($dm=='demo')$rows[$k]['mobile']='已绑定';
  70. }
  71. }
  72. return array(
  73. 'rows' => $rows
  74. );
  75. }
  76. public function gettpleditAjax()
  77. {
  78. $id = (int)$this->get('id','0');
  79. $rs = m('wotpl')->getone($id);
  80. $cont = $rs['content'];
  81. $farr = $this->rock->matcharr($cont);
  82. return array(
  83. 'data' => $rs,
  84. 'farr' => $farr,
  85. 'marr' => m('wxgzh:index')->getxinhutpl()
  86. );
  87. }
  88. public function savetpleditAjax()
  89. {
  90. $id = (int)$this->post('id','0');
  91. m('wotpl')->update(array(
  92. 'modename' => $this->post('modename'),
  93. 'modeparams' => $this->post('modeparams')
  94. ),$id);
  95. }
  96. public function testsendtplAjax()
  97. {
  98. $id = (int)$this->post('id','0');
  99. $openid = $this->post('openid');
  100. if(isempt($openid))return returnerror('没有输入openid');
  101. $urs = m('wouser')->getone("`openid`='$openid'");
  102. if(!$urs)return returnerror('没有找到此授权的微信人');
  103. $barr = m('wxgzh:index')->sendtpl($openid, $id, array(), true);
  104. if($barr['errcode']!=0)return returnerror($barr['errcode'].'.'.$barr['msg']);
  105. return returnsuccess($barr['msg']);
  106. }
  107. }
粤ICP备19079148号