Index.php 2.9 KB
<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\api\model\Order;
use app\api\model\Banner;
use EasyWeChat\Factory;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['index','info','jssdk'];
    protected $noNeedRight = ['*'];

    /**
     * @ApiWeigh    (99)
     * @ApiTitle    (首页-发单列表)
     * @ApiSummary  (首页-发单列表)
     * @ApiMethod   (POST)
     *
     * @ApiParams   (name="page", type="inter", required=false, description="当前页(默认1)")
     * @ApiParams   (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
     *
     * @ApiReturn({
        "code": 1,
        "msg": "成功",
        "time": "1604729641",
        "data": {
            "total": 1, //数据总数
            "per_page": 15,
            "current_page": 1,
            "last_page": 1,
            "data": [{
                "id": 1, //发单ID
                "market_name": "你好商城", //商城名称
                "parking_fee": "50.00", //实际停车费
                "deposit": "35.00", //定金
                "grab_countdown": 65 //抢单倒计时
            }]
        }
    })
     */
    public function index(){
        (new OrderGrab)->index();
    }

    /**
     * @ApiWeigh    (97)
     * @ApiTitle    (首页-发单详情)
     * @ApiSummary  (首页-发单详情)
     * @ApiMethod   (POST)
     *
     * @ApiParams   (name="order_id", type="inter", required=true, description="订单ID")
     *
     * @ApiReturn({
        "code": 1,
        "msg": "成功",
        "time": "1603017818",
        "data": {
            "id": 1, //发单ID
            "market_name": "你好商城", //商城名称
            "parking_fee": "50.00", //实际停车费
            "deposit": "35.00", //定金
            "grab_countdown": 65 //抢单倒计时
        }
    })
     */
    public function info(){
        (new OrderGrab)->info();
    }

    /**
     * @ApiWeigh (95)
     * @ApiTitle    (轮播图列表)
     * @ApiSummary  (轮播图列表)
     * @ApiMethod   (POST)
     *
     * @ApiReturn({
        "code": 1,
        "msg": "成功",
        "time": "1602556163",
        "data": [{
            "id": 1, //ID
            "image": "http://www.parking.top/uploads/20201106/856ab1bfffbb5fa30fa826bcab631bbc.jpg" //图片
        }]
    })
     */
    public function bannerList()
    {
        $banner_list = Banner::order(['weigh'=>'desc','createtime'=>'desc'])->field('id,image')->select();
        $this->success('成功',$banner_list);
    }

    public function jssdk()
    {
        $apis = [
            'checkJsApi',
            'getLocation', //获取位置
            'openLocation', //打开位置
        ];
        $res = Factory::officialAccount(config('wechat'))->jssdk->buildConfig($apis, $debug = true, $beta = false, $json = false);
        $this->success('sdk', $res);
    }
}