MembersController.php 1.3 KB
<?php
namespace app\admin\controller;

use cmf\controller\AdminBaseController;
use think\Db;
use app\admin\model\AdminMenuModel;

class MembersController extends AdminBaseController{

    //显示会员列表
    public function mem_list(){

        $data = Db::name('members') -> select();
        $this -> assign('data',$data);
        return $this -> fetch();

    }

    //添加会员
    public function mem_add(){

        $data['name'] = input('post.name');
        $data['passwd'] = input('post.passwd');
        $data['jifen'] = input('post.jifen');
        $id = Db::name('members') -> insertGetId($data);
        return $id;

    }

    //当点击编辑时显示会员数据
    public function mem_edit_show(){

        $id = input('post.id');
        $data = Db::name('members') -> where('id',$id) -> find();
        return json_encode($data);

    }

    //更新数据
    public function mem_edit_up(){

        $data['id'] = input('post.id');
        $data['name'] = input('post.name');
        $data['passwd'] = input('post.passed');
        $data['jifen'] = input('post.jifen');
        $res = Db::name('members') -> update($data);
        return true;

    }

    //删除数据
    public function mem_del(){
        $id = input('post.id');
        Db::name('members') -> delete($id);
        return true;
    }











}