微信开发——公众号管理

1.我们可能会添加多个公众号,这是就会出现选择哪个公众号的问题。当我们点击进入公众号是就会出现  正在使用,而其他的都会显示   停止使用。


  1. <extend name="Common:base"/>  
  2. <block name="body">  
  3. <div class="conent-hd">  
  4.       <h2>公众号管理  
  5.       <a href="{:U('add')}" class="layui-btn layui-btn-normal layui-btn-sm rha-nav-title" style="position:absolute;right:30px;">添加公众号</a>  
  6.       </h2>  
  7.     </div>  
  8.       <table class="layui-table">  
  9.         <colgroup>  
  10.           <col width="150">  
  11.           <col width="200">  
  12.           <col>  
  13.         </colgroup>  
  14.           <thead>  
  15.       <tr>  
  16.         <th>公众号信息</th>  
  17.         <th>状态</th>  
  18.         <th>操作</th>  
  19.       </tr>   
  20.     </thead>  
  21.     <tbody>  
  22.     <volist name="data" id="row">  
  23.       <tr>  
  24.         <td>  
  25.           <div class="mp_logo">  
  26.             <div class="logo-left">  
  27.               LGOG:<img src="{$row.logo}" width="40" height="40">  
  28.             </div>  
  29.             <div class="mp_qrcode">  
  30.             <div class="logo-left">  
  31.               二维码:<img src="{$row.qrcode}" width="40" height="40">  
  32.             </div>  
  33.             <div class="logo-right">  
  34.               <p class="p1">公众号名称:{$row.name}</p>  
  35.               <p class="p2">公众号类型:{$row.type}</p>  
  36.             </div>  
  37.           </div>  
  38.         </td>  
  39.         <td><eq name='row.is_use' value="1">正在使用<else/>未使用</eq></td>  
  40.         <td>   
  41.           <a href="{:U('updata')}?id={$row.id}" class="layui-btn layui-btn-xs">进入公众号</a>  
  42.           <a href="{:U('enter')}?id={$row.id}" class="layui-btn layui-btn-xs">接入信息</a>  
  43.           <a href="" class="layui-btn layui-btn-xs">删除</a>  
  44.         </td>  
  45.       </tr>  
  46.     </volist>  
  47.     </tbody>  
  48.       </table>  
  49.     </block>  

点击接入微信服务器信息时出现下面这个页面


  1. <extend name="Common:base"/>  
  2. <block name="body">  
  3. <table class="layui-table" lay-skin="line">  
  4.       <colgroup>  
  5.         <col width="150">  
  6.         <col width="300">  
  7.         <col>  
  8.       </colgroup>  
  9.       <thead>  
  10.         <tr>  
  11.           <th>名称</th>  
  12.           <th>信息</th>  
  13.         </tr>   
  14.       </thead>  
  15.       <tbody>  
  16.         <tr>  
  17.           <td>APPID</td>  
  18.           <td>{$mp.appid}</td>  
  19.         </tr>  
  20.         <tr>  
  21.           <td>appsecret</td>  
  22.           <td>{$mp.appsecret}</td>  
  23.         </tr>  
  24.         <tr>  
  25.           <td>url</td>  
  26.           <td>{$mp.url}</td>  
  27.         </tr>  
  28.         <tr>  
  29.           <td>token</td>  
  30.           <td>{$mp.access_token}</td>  
  31.         </tr>  
  32.       </tbody>  
  33.       </volist>  
  34.   </table>      
  35. </block>  
  1. <?php  
  2. namespace Home\Controller;  
  3. use Think\Controller;  
  4. class MpController extends Controller {//公众号管理  
  5.     //显示公众号列表  
  6.     public function index(){  
  7.         $model=M('mp');  
  8.         $data=$model->order('id desc')->select();  
  9.         $this->assign('data',$data);  
  10.         $this->display();  
  11.     }  
  12.     //进入公众号  
  13.     public function update(){  
  14.         $id=I('get.id');  
  15.         $model=M('mp');  
  16.         $model->where("id!=$id")->setField('is_use','0');  
  17.         $ret=$model->where("id=$id")->setField('is_use','1');  
  18.         if($ret) {  
  19.             $this->success('操作成功!');  
  20.         }else{  
  21.             $this->error('正在使用此公众号');  
  22.         }  
  23.     }  
  24.     //新增公众号  
  25.     public function addmp(){  
  26.         if(IS_GET){  
  27.             $this->display();  
  28.         }else{  
  29.             $Form = D('mp');  
  30.             $result=$Form->create();  
  31.             if($result) {  
  32.                 $result = $Form->add();  
  33.             if($result) {  
  34.                 $this->success('数据添加成功!');  
  35.             }else{  
  36.                 $this->error('数据添加错误!');  
  37.             }  
  38.             }else{  
  39.                 $this->error($Form->getError());  
  40.             }  
  41.         }  
  42.     }  
  43.     //接入公众号,$i主键  
  44.     public function enter($id){  
  45.         $mp=M('mp')->find($id);  
  46.         $mp['url']='http://'.$_SERVER['HTTP_HOST'].U('mp/index/index',array('id'=>$mp['id']));  
  47.         $this->assign('mp',$mp);  
  48.         $this->display();  
  49.     }  
  50.   
  51. }  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值