审查视图

application/api/controller/Cards.php 5.2 KB
王智 authored
1 2 3 4 5 6 7 8 9 10
<?php
/**
 * Created by PhpStorm.
 * User: 86132
 * Date: 2020/11/19
 * Time: 8:35
 */

namespace app\api\controller;
王智 authored
11
use EasyWeChat\Foundation\Application;
王智 authored
12 13 14 15 16 17 18 19 20 21 22 23 24
use app\common\controller\Api;
use think\Db;

/**
 * 海报分享接口
 */
class Cards extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];


    /**
王智 authored
25
     * 海报分享接口
王智 authored
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
     * @ApiTitle    (转发好友)
     * @ApiSummary  (转发好友)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Cards/MiniAppOtherFriend)
     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
     * @ApiParams   (name="Goods_id", type="integer", required=true, description="商品ID")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data":
    })
     */
    public function MiniAppOtherFriend()
    {
        $UserId = $this->is_token($this->request->header());
        $params = $this->request->param();
        $GoodsArray = Db::name('goods')->where('id', $params['Goods_id'])->find();
        if (empty($GoodsArray)) {
            $this->error('分享错误', 0);
            die;
        }
        $data = [
            'Goods_id' => $GoodsArray['id'],
            'User_id' => $UserId,
            'Title' => $GoodsArray['title'],
            'Image' => cdnurl($GoodsArray['image']),
        ];
        $this->success('成功', $data);
    }


    /**
王智 authored
60
     * 海报分享接口
王智 authored
61 62 63 64 65 66
     * @ApiTitle    (商品详情生成海报)
     * @ApiSummary  (商品详情生成海报)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Cards/GoodsConNewsPaper)
     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
     * @ApiParams   (name="Goods_id", type="integer", required=true, description="商品ID")
王智 authored
67
     * @ApiParams   (name="path", type="integer", required=true, description="路径")
王智 authored
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data":
    })
     */
    public function GoodsConNewsPaper()
    {
        $UserId = $this->is_token($this->request->header());
        $params = $this->request->param();
        $GoodsArray = Db::name('goods')->where('id', $params['Goods_id'])->find();
        if (empty($GoodsArray)) {
            $this->error('分享错误', 0);
            die;
        }
王智 authored
85
        $UserInfo = Db::name('user')->where('id', $UserId)->find();
王智 authored
86
        //小程序码
王智 authored
87 88 89 90 91 92 93 94 95 96 97
        $MiniAppQrcodeUrl = $this->InserMiniAppQrCode($GoodsArray['id'], $UserId, $params['path']);
        $data = [
            'Avatar' => $UserInfo['avatar'],
            'Nickname' => $UserInfo['nickname'],
            'Goods_id' => $GoodsArray['id'],
            'User_id' => $UserId,
            'Title' => $GoodsArray['title'],
            'Price' => $GoodsArray['price'],
            'DeletePrice' => $GoodsArray['delete_price'],
            'Image' => cdnurl($GoodsArray['image']),
            'MiniAppQrcodeUrl' => $MiniAppQrcodeUrl
王智 authored
98
        ];
王智 authored
99
        $this->success('成功', $data);
王智 authored
100
    }
王智 authored
101
王智 authored
102 103

    /**
王智 authored
104
     * 海报分享接口
王智 authored
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
     * @ApiTitle    (邀请好友/测试题/名片海报)
     * @ApiSummary  (邀请好友/测试题/名片海报)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Cards/CardsPaper)
     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
     * @ApiParams   (name="path", type="integer", required=true, description="路径")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data":
    })
     */
    public function CardsPaper()
王智 authored
120
    {
王智 authored
121 122 123 124 125 126 127 128 129 130 131 132
        $UserId = $this->is_token($this->request->header());
        $params = $this->request->param();
        $UserInfo = Db::name('user')->where('id', $UserId)->find();
        //小程序码
        $MiniAppQrcodeUrl = $this->InserMiniAppQrCode(0, $UserId, $params['path']);
        $data = [
            'Avatar' => $UserInfo['avatar'],
            'Nickname' => $UserInfo['nickname'],
            'User_id' => $UserId,
            'MiniAppQrcodeUrl' => $MiniAppQrcodeUrl
        ];
        $this->success('成功', $data);
王智 authored
133
    }
王智 authored
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158


    /**
     * 海报分享接口
     * @ApiTitle    (分享)
     * @ApiSummary  (分享))
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/Cards/MiniAppFriends)
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    'code':'1',
    'msg':'返回成功',
    "data":
    })
     */
    public function MiniAppFriends()
    {
        $Array = Db::name('miniappfriends')->where('id', 1)->find();
        $data = [
            'Title' => $Array['title'],
            'Image' => cdnurl($Array['image']),
        ];
        $this->success('成功', $data);
    }
王智 authored
159
}