wxgzhAction.php 2.8 KB

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