Merchant.php 1.1 KB
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/5
 * Time: 15:47
 */

namespace app\home\controller;


use app\common\controller\WechatBase;
use EasyWeChat\Foundation\Application;
use think\Db;

class Merchant extends WechatBase
{
    protected $user_id;
    function _initialize()
    {
        parent::_initialize();
        //判断是否授权
        $user_id = get_current_user_id();
        if(empty($user_id)){
            $this->redirect('user/authorization_view');
        }
        $this->user_id = $user_id;
    }
    public function index(){
        $data = Db::name('page')->where(['id'=>1])->find();
        $this->assign('data',$data);
        return $this->fetch();
    }
    public function enter_view(){
        $options = [
            'app_id' => config('wechat.app_id'),
            'secret' => config('wechat.secret'),
        ];
        $app = new Application($options);
        $js = $app->js;
        $jssdk = $js->config(['chooseImage', 'uploadImage', 'previewImage'], $debug = false, $beta = false, $json = true);
        $this->assign('jssdk',$jssdk);
        return $this->fetch();
    }
}