查询接口,vue前端

查询和获取数据库所有数据写在一起

//审核后台得到视频列表
    public function getVideoList()
    {
        $input = $this->getinput->json();
        if (isset($input['page'])) {
            $offset = ($input['page'] - 1) * 10;
            $limit = 10;
        } else {
            $offset = 0;
            $limit = 100;
        }
//        总条件
        $query = $this->db;

//如果需要查询某一项 加上查询语句
        if (isset($input['film_name'])) {
            $query = $query->where('film_name', $input['film_name']);
        }
//        查询后得到总结果
        $count_query = clone $query;
        $result_query = clone $query;
//        得到总结果的条数
        $count = $count_query->get('video')->num_rows();
//        根据查询结果得到这个条数
        $result = $result_query->order_by('created_at', 'desc')->offset($offset)->limit($limit)->get('video')->result_array();
        $data = array(
            'data' => $result,
            'total' => $count,
        );
        echo json_encode($data);
    }

vue内容

get_VideoList: async function () {
                let self = this;
                //搜索条件,电影名称
                if(this.film_name===''){
                    this.film_name=undefined
                }
                this.params={
                    page: this.currentPage,
                    film_name:this.film_name
                }
                let {data} = await this.$http.post('/getVideoList',this.params)
                console.log(data)
                self.video_list = data.data
                self.total = data.total
                for (var i = 0; i < self.video_list.length; i++) {
                    if (self.video_list[i].states == 0) {
                        self.video_list[i].states = false
                    } else {
                        self.video_list[i].states = true
                    }
                }
            },
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值