wesmiler %!s(int64=6) %!d(string=hai) anos
pai
achega
fb38da5f72

+ 82 - 0
app/api/controller/BaseController.php

@@ -0,0 +1,82 @@
+<?php
+/**
+ * 入口
+ * @author wesmiler
+ */
+
+namespace app\api\controller;
+
+use app\weixin\model\Fans;
+use app\weixin\model\Member;
+use app\weixin\model\Wechat;
+use app\weixin\service\PRedis;
+use cmf\controller\HomeBaseController;
+use think\Request;
+
+class BaseController extends HomeBaseController
+{
+    public $userId = 0;
+    public $needRegProfile = false;
+    public $userInfo = [];
+    public function __construct(Request $request = null)
+    {
+        parent::__construct($request);
+        $this->userInfo = session('userInfo');
+        $debug = config('weixin.debug');
+        $field = 'id,openid,user_login,mobile,real_name,is_reg_profile,user_nickname,avatar,user_status';
+        if (empty($this->userInfo) || $debug) {
+            // 调试模式
+            $curOpenId = session('openid');
+            $openid = $curOpenId ? $curOpenId : config('weixin.openid');
+            if($openid){
+                $this->userInfo = Member::getInfo(['openid' => $openid, 'user_type'=> 2], $field);
+            }
+            $wxInfo = Fans::getInfo(['openid' => $openid]);
+            session('openid', $openid);
+            session('wxInfo', $wxInfo);
+            session('userInfo', $this->userInfo);
+        }
+        
+        $this->userId = isset($this->userInfo['id']) ? intval($this->userInfo['id']) : 0;
+        if(empty($this->userId)){
+            showJson(1007,2103,['url'=> Wechat::makeRedirectUrl(url('/weixin/match/index','','',true))]);
+        }
+
+        // $realname = isset($this->userInfo['real_name'])? $this->userInfo['real_name'] : '';
+        $mobile = isset($this->userInfo['mobile'])? $this->userInfo['mobile'] : '';
+        $isReg = isset($this->userInfo['is_reg_profile'])? $this->userInfo['is_reg_profile'] : 0;
+        if(empty($mobile) || $isReg != 1){
+            $this->needRegProfile = true;
+            session('needRegProfile', true);
+        }else{
+            session('needRegProfile', false);
+        }
+//        $this->userId = 100002;
+    }
+
+    /**
+     * 验证用户
+     */
+    public function checkUser(){
+        $debug = config('weixin.debug');
+        $memberInfo = Member::where(['id'=> $this->userId, 'user_type'=> 2])
+            ->field('user_status,is_reg_profile')
+            ->find();
+        $needRegProfile = isset($memberInfo['is_reg_profile'])? intval($memberInfo['is_reg_profile']) : 0;
+        $userStatus = isset($memberInfo['user_status'])? intval($memberInfo['user_status']) : 0;
+        // 用户冻结
+        if($userStatus != 1){
+            showJson(1006, 2102, ['url' => url('/weixin/page/custom', '', '', true)]);
+        }
+        // 未完善资料
+        if($needRegProfile != 1 && !$debug){
+            $referer = request()->server('HTTP_REFERER');
+            $rebackurl = $referer? $referer : url('/weixin/match/index','','',true);
+            showJson(1006, 2132, ['url'=> Wechat::makeRedirectUrl(url('/weixin/index/entry?rebackurl='.$rebackurl,'','',true))]);
+        }
+    }
+
+}
+
+
+?>

+ 122 - 0
app/api/controller/IndexController.php

@@ -0,0 +1,122 @@
+<?php
+/**
+ * 首页
+ * @author wesmiler
+ */
+namespace app\api\controller;
+use app\portal\model\PortalPostModel;
+use app\weixin\service\Article;
+use app\weixin\model\Wechat;
+use app\weixin\service\PRedis;
+
+class IndexController extends BaseController
+{
+
+    /**
+     * 获取JSSDK参数
+     */
+    public function getJssdkParams(){
+        $url = input('url', '');
+        $jssdkParams = Wechat::getJssdkParams($url);
+        PRedis::set('shares:'.date('YmdHis'), ['url'=> $url,'params'=> $jssdkParams], 600);
+        showJson(1005,1001, $jssdkParams);
+    }
+
+    /**
+     * 获取微信信息
+     */
+    public function getWxInfo(){       
+        $wxInfo = session('wxInfo');
+        showJson(1005,1001, $wxInfo);
+    }
+
+    /**
+     * 获取条件参数
+     */
+    public function params(){
+        $params['ages'] = config('weixin.ages');
+        $params['heights'] = config('weixin.heights');
+        $params['weights'] = config('weixin.weights');
+        $params['incomes'] = config('weixin.incomes');
+        $params['educations'] = config('weixin.educations');
+        $params['positions'] = config('weixin.positions');
+        $params['marrieds'] = config('weixin.marrieds');
+        $params['propertys'] = config('weixin.propertys');
+        showJson(1005,1001, $params);
+    }
+
+    /**
+     * 获取网站信息
+     */
+    public function getSiteInfo(){
+        $siteInfo =  $siteInfo = cmf_get_site_info();
+        $chooseNum = isset($siteInfo['choose_num'])? intval($siteInfo['choose_num']) : 0;
+        $data = [
+            'site_name'=> isset($siteInfo['site_name'])? $siteInfo['site_name'] : '',
+            'site_seo_title'=> isset($siteInfo['site_seo_title'])? $siteInfo['site_seo_title'] : '',
+            'site_seo_keywords'=> isset($siteInfo['site_seo_keywords'])? $siteInfo['site_seo_keywords'] : '',
+            'site_seo_description'=> isset($siteInfo['site_seo_description'])? $siteInfo['site_seo_description'] : '',
+            'contact_type'=> isset($siteInfo['contact_type'])? $siteInfo['contact_type'] : 1,
+            'choose_num'=> $chooseNum? $chooseNum : 3,
+            'custom_intro'=> isset($siteInfo['custom_intro'])? htmlspecialchars_decode($siteInfo['custom_intro']) : '',
+        ];
+        showJson(1005,1001, $data);
+    }
+
+    /**
+     * 获取广告列表
+     */
+    public function getAdvertList(){
+        $id = input('type', 1);
+        $pages = config('config.pages');
+        $slideNum = isset($pages['slideNum'])? intval($pages['slideNum']) : 0;
+        $dataList = db('slide')->alias('s')
+            ->join('slide_item si','si.slide_id=s.id','left')
+            ->where(['s.id'=> $id,'s.status'=> 1])
+            ->field('si.id,si.title,si.image,si.url,si.description')
+            ->order('si.list_order')
+            ->limit($slideNum? $slideNum :6)
+            ->select()
+            ->toArray();
+
+        foreach($dataList as &$item){
+            $item['image'] = $item['image']? cmf_get_image_preview_url($item['image']) : '';
+        }
+
+        showJson(1005,1001, $dataList);
+    }
+
+    /**
+     * 获取单页文章内容
+     */
+    public function getPage(){
+        $info = [];
+        $type = input('type', 'about');
+        $articles = config('weixin.articles');
+        $articleId = isset($articles[$type])? intval($articles[$type]) : 0;
+        if($articleId){
+            $field = 'id,thumbnail,post_title,post_excerpt,post_content,published_time,post_source,user_id';
+            $info = PortalPostModel::where(['id'=> $articleId,'post_type'=> 2,'post_status'=>1])
+                ->field($field)
+                ->find();
+            if($info){
+                $info['post_content'] = htmlspecialchars_decode($info['post_content']);
+            }
+        }
+        showJson(1005,1001, $info);
+    }
+
+    /**
+     * 获取客服列表
+     */
+    public function getCustomList(){
+        $params = input();
+        $pageSize = input('pageSize', 20);
+        $dataList = Article::getList($params, $pageSize);
+        showJson(1005, 1001, $dataList);
+    }
+
+}
+
+
+?>

+ 57 - 0
app/api/lang/en-us.php

@@ -0,0 +1,57 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +---------------------------------------------------------------------
+// | Author: Dean <zxxjjforever@163.com>
+// +----------------------------------------------------------------------
+return [
+    "SAVE"                    => 'Save',
+    "CLOSE"                   => 'Close',
+    "OPEN"                    => 'Open',
+    "ENABLED"                 => 'Enabled',
+    "DISABLED"                => 'Disabled',
+    "DELETE"                  => "Delete",
+    "RESTORE"                 => 'Restore',
+    "DOWNLOAD"                => 'Download',
+    "YES"                     => 'Yes',
+    "NO"                      => 'No',
+    "EDIT"                    => 'Edit',
+    "ADD"                     => 'Add',
+    "BACK"                    => 'Back',
+    'LOGIN'                   => 'Login',
+    'PASSWORD'                => "Password",
+    'USERNAME_OR_EMAIL'       => 'Username or Email',
+    'LOGIN_SUCCESS'           => "Login success!",
+    'PASSWORD_NOT_RIGHT'      => "Password Error!",
+    'PASSWORD_REQUIRED'       => "Password cannot be empty!",
+    'CAPTCHA_REQUIRED'        => "Verification code cannot be empty!",
+    'CAPTCHA_NOT_RIGHT'       => "Verification code error!",
+    'USERNAME_NOT_EXIST'      => "Username does not exist!",
+    'USERNAME_OR_EMAIL_EMPTY' => "Username or email address can't for empty!",
+    'USE_DISABLED'            => "This user has been disabled!",
+    'ENTER_VERIFY_CODE'       => 'Please enter the verification code!',
+    'HOME'                    => 'Home',
+    'LOADING'                 => 'Loading...',
+    'LOGOUT'                  => 'Logout',
+    "OK"                      => "Ok",
+    "STATUS"                  => 'Status',
+    "ACTIONS"                 => 'Actions',
+    "SORT"                    => 'Sort',
+    "DISPLAY"                 => 'Display',
+    "HIDDEN"                  => 'Hidden',
+    "HIDE"                    => 'Hide',
+    'DELETE_CONFIRM_MESSAGE'  => 'Are you sure to delete?',
+    'SETTING'                 => 'Setting',
+    "ADD_SUCCESS"             => 'Add success!',
+    "ADD_FAILED"              => 'Add failed!',
+    "EDIT_SUCCESS"            => 'Save success!',
+    "EDIT_FAILED"             => 'Save failed!',
+    "NO_DATA"                 => 'No data!',
+    "MOBILE"                  => 'Mobile'
+
+
+];

+ 68 - 0
app/api/lang/zh-cn.php

@@ -0,0 +1,68 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
+// +---------------------------------------------------------------------
+// | Author: Dean <zxxjjforever@163.com>
+// +----------------------------------------------------------------------
+return [
+    "SAVE"                     => '保存',
+    "CLOSE"                    => '关闭',
+    "OPEN"                     => '开启',
+    "ENABLED"                  => '开启',
+    "DISABLED"                 => '禁用',
+    "DELETE"                   => "删除",
+    "RESTORE"                  => '恢复',
+    "DOWNLOAD"                 => '下载',
+    "YES"                      => '是',
+    "NO"                       => '否',
+    "EDIT"                     => '编辑',
+    "ADD"                      => '添加',
+    "BACK"                     => '返回',
+    'LOGIN'                    => '登录',
+    'PASSWORD'                 => "密码",
+    'USERNAME_OR_EMAIL'        => '用户名或邮箱',
+    'LOGIN_SUCCESS'            => "登录成功!",
+    'PASSWORD_NOT_RIGHT'       => "密码错误!",
+    'PASSWORD_REQUIRED'        => "密码不能为空!",
+    'CAPTCHA_REQUIRED'         => "验证码不能为空!",
+    'CAPTCHA_NOT_RIGHT'        => "验证码错误!",
+    'USERNAME_NOT_EXIST'       => "用户名不存在!",
+    'USERNAME_OR_EMAIL_EMPTY'  => "用户名或邮箱不能为空!",
+    'ENTER_VERIFY_CODE'        => '请输入验证码',
+    'HOME'                     => '首页',
+    'LOADING'                  => '正在加载...',
+    'LOGOUT'                   => '退出',
+    "OK"                       => "确定",
+    "STATUS"                   => '状态',
+    "ACTIONS"                  => '操作',
+    "SORT"                     => '排序',
+    "DISPLAY"                  => '显示',
+    "HIDDEN"                   => '隐藏',
+    "HIDE"                     => '隐藏',
+    'DELETE_CONFIRM_MESSAGE'   => '你确定删除吗?',
+    'SETTING'                  => '设置',
+    "ADD_SUCCESS"              => '添加成功!',
+    "ADD_FAILED"               => '添加失败!',
+    "EDIT_SUCCESS"             => '保存成功!',
+    "EDIT_FAILED"              => '保存失败!',
+    "NO_DATA"                  => '没有数据',
+    "MOBILE"                   => '手机',
+    "SENDER_NAME"              => '发件人',
+    "SENDER_EMAIL_ADDRESS"     => '邮箱地址',
+    "SENDER_SMTP_SERVER"       => 'SMTP服务器',
+    "SMTP_MAIL_ADDRESS"        => '发件箱帐号',
+    "SMTP_MAIL_PASSWORD"       => '发件箱密码',
+    "EMAIL_ACTIVATION"         => '邮箱激活',
+    "EMAIL_SUBJECT"            => '邮件标题',
+    "EMAIL_TEMPLATE"           => '邮件模版',
+    "EMAIL_TEMPLATE_HELP_TEXT" => '请用{$link}代替激活链接,{$username}代替用户名',
+
+
+
+
+
+];

+ 8 - 0
app/demo/README.md

@@ -0,0 +1,8 @@
+ThinkCMF 演示应用
+===============
+
+### 加载第三方库
+支持使用`composer`加载第三方库
+```
+composer require phpoffice/phpspreadsheet
+```

+ 13 - 0
app/demo/composer.json

@@ -0,0 +1,13 @@
+{
+    "name": "thinkcmf/apps-demo",
+    "description": "ThinkCMF demo app",
+    "type": "cmf-app",
+    "license": "MIT",
+    "authors": [
+        {
+            "name": "catman",
+            "email": "catman@thinkcmf.com"
+        }
+    ],
+    "require": {}
+}

+ 27 - 0
app/demo/controller/IndexController.php

@@ -0,0 +1,27 @@
+<?php
+// +----------------------------------------------------------------------
+// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Released under the MIT License.
+// +----------------------------------------------------------------------
+// | Author: 老猫 <thinkcmf@126.com>
+// +----------------------------------------------------------------------
+
+namespace app\demo\controller;
+
+use cmf\controller\HomeBaseController;
+
+class IndexController extends HomeBaseController
+{
+    public function index()
+    {
+        return $this->fetch(':index');
+    }
+
+    public function ws()
+    {
+        return $this->fetch(':ws');
+    }
+}

+ 11 - 0
app/demo/vendor/.gitignore

@@ -0,0 +1,11 @@
+.buildpath
+.DS_Store
+.project
+.settings
+.idea
+.git
+/build
+/public/assets/dist
+/node_modules
+Vagrantfile
+.vagrant