1.我们可能会添加多个公众号,这是就会出现选择哪个公众号的问题。当我们点击进入公众号是就会出现 正在使用,而其他的都会显示 停止使用。
- <extend name="Common:base"/>
- <block name="body">
- <div class="conent-hd">
- <h2>公众号管理
- <a href="{:U('add')}" class="layui-btn layui-btn-normal layui-btn-sm rha-nav-title" style="position:absolute;right:30px;">添加公众号</a>
- </h2>
- </div>
- <table class="layui-table">
- <colgroup>
- <col width="150">
- <col width="200">
- <col>
- </colgroup>
- <thead>
- <tr>
- <th>公众号信息</th>
- <th>状态</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody>
- <volist name="data" id="row">
- <tr>
- <td>
- <div class="mp_logo">
- <div class="logo-left">
- LGOG:<img src="{$row.logo}" width="40" height="40">
- </div>
- <div class="mp_qrcode">
- <div class="logo-left">
- 二维码:<img src="{$row.qrcode}" width="40" height="40">
- </div>
- <div class="logo-right">
- <p class="p1">公众号名称:{$row.name}</p>
- <p class="p2">公众号类型:{$row.type}</p>
- </div>
- </div>
- </td>
- <td><eq name='row.is_use' value="1">正在使用<else/>未使用</eq></td>
- <td>
- <a href="{:U('updata')}?id={$row.id}" class="layui-btn layui-btn-xs">进入公众号</a>
- <a href="{:U('enter')}?id={$row.id}" class="layui-btn layui-btn-xs">接入信息</a>
- <a href="" class="layui-btn layui-btn-xs">删除</a>
- </td>
- </tr>
- </volist>
- </tbody>
- </table>
- </block>
点击接入微信服务器信息时出现下面这个页面
- <extend name="Common:base"/>
- <block name="body">
- <table class="layui-table" lay-skin="line">
- <colgroup>
- <col width="150">
- <col width="300">
- <col>
- </colgroup>
- <thead>
- <tr>
- <th>名称</th>
- <th>信息</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>APPID</td>
- <td>{$mp.appid}</td>
- </tr>
- <tr>
- <td>appsecret</td>
- <td>{$mp.appsecret}</td>
- </tr>
- <tr>
- <td>url</td>
- <td>{$mp.url}</td>
- </tr>
- <tr>
- <td>token</td>
- <td>{$mp.access_token}</td>
- </tr>
- </tbody>
- </volist>
- </table>
- </block>
- <?php
- namespace Home\Controller;
- use Think\Controller;
- class MpController extends Controller {//公众号管理
- //显示公众号列表
- public function index(){
- $model=M('mp');
- $data=$model->order('id desc')->select();
- $this->assign('data',$data);
- $this->display();
- }
- //进入公众号
- public function update(){
- $id=I('get.id');
- $model=M('mp');
- $model->where("id!=$id")->setField('is_use','0');
- $ret=$model->where("id=$id")->setField('is_use','1');
- if($ret) {
- $this->success('操作成功!');
- }else{
- $this->error('正在使用此公众号');
- }
- }
- //新增公众号
- public function addmp(){
- if(IS_GET){
- $this->display();
- }else{
- $Form = D('mp');
- $result=$Form->create();
- if($result) {
- $result = $Form->add();
- if($result) {
- $this->success('数据添加成功!');
- }else{
- $this->error('数据添加错误!');
- }
- }else{
- $this->error($Form->getError());
- }
- }
- }
- //接入公众号,$i主键
- public function enter($id){
- $mp=M('mp')->find($id);
- $mp['url']='http://'.$_SERVER['HTTP_HOST'].U('mp/index/index',array('id'=>$mp['id']));
- $this->assign('mp',$mp);
- $this->display();
- }
- }