1
0

first commit

This commit is contained in:
2020-08-06 14:58:51 +08:00
commit 17096657dc
780 changed files with 92857 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\ArticleModel as ArticleModelModel;
class Ajax extends _Init
{
public function _initialize()
{
if (!IS_AJAX) {
return $this->error('请不要非法访问');
}
}
public function modelstyle()
{
$list = ArticleModelModel::where(['status' => 1])->select();
$this->assign('list', $list);
return $this->success($this->fetch('ajax/modelstyle'));
}
}

View File

@@ -0,0 +1,146 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\Article as ArticleModel;
use app\common\model\MemberInfo as MemberInfoModel;
use app\common\service\Article as ArticleService;
class Article extends _Init
{
public function _initialize()
{
parent::_initialize();
$this->nav = 1;
}
public function index()
{
$map = [
'uid' => UID,
'status' => 1,
];
$list = ArticleModel::where($map)->order("id desc")->paginate(10);
$this->assign('list', $list);
if (IS_AJAX) {
if (count($list) > 0) {
return $this->success($this->fetch('article/lists'));
} else {
return $this->error('已经到最后一页');
}
}
return $this->fetch();
}
public function show($id)
{
$info = ArticleModel::find($id);
if (!empty($info)) {
$info->setInc('click');
}
$this->assign('info', $info);
return $this->fetch();
}
public function add()
{
if (IS_POST) {
$data = $this->request->post();
$data['uid'] = UID;
$res = ArticleService::userAdd($data);
if ($res === true) {
return $this->success('发布成功', url('mobile/article/index'));
} else {
return $this->error('发布失败,' . $res);
}
} else {
return $this->fetch();
}
}
public function edit($id = '')
{
if (IS_POST) {
$data = $this->request->post();
$info = ArticleModel::find($data['id'] ?: 0);
if ($info) {
unset($data['id']);
if ($info->save($data)) {
return $this->success('发表成功', url('mobile/article/index'));
} else {
return $this->error('发表失败');
}
} else {
return $this->error('您修改的文章已不存在');
}
} else {
$info = ArticleModel::find($id);
if ($info->uid != UID) {
$this->redirect(url('center/index'));
}
$this->assign('info', $info);
return $this->fetch('add');
}
}
public function collect()
{
if (IS_POST) {
$info = MemberInfoModel::get(UID);
if (!$info->is_vip) {
return $this->error('采集失败您还不是VIP。', url('vip/index'));
}
$url = $this->request->post('url') ?: '';
if ($url) {
if (!preg_match('/(http:\/\/)|(https:\/\/)/i', $url)) {
return $this->error('您粘贴的地址不正确!');
}
if (!preg_match('/(mp.weixin.qq.com)/i', $url)) {
return $this->error('您粘贴的地址不是微信文章地址!');
}
$id = ArticleService::collect($url, UID);
if ($id) {
return $this->success('采集成功', url('mobile/article/edit', 'id=' . $id));
} else {
return $this->error('采集失败');
}
} else {
return $this->error('请输入文章地址');
}
} else {
$this->nav = 2;
return $this->fetch();
}
}
public function del($id)
{
if (IS_AJAX) {
$info = ArticleModel::find($id);
if ($info->uid != UID) {
return $this->error('非法操作');
} else {
if ($info->delete()) {
return $this->success('删除成功');
} else {
return $this->error('删除失败');
}
}
} else {
return $this->error('请不要非法访问');
}
}
public function video()
{
$this->meta_title = '发布文章视频教程';
return $this->fetch();
}
}

View File

@@ -0,0 +1,47 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\Content as ContentModel;
use app\common\service\Content as ContentService;
class Cause extends _Init
{
public function _initialize()
{
parent::_initialize();
$this->nav = 2;
}
public function index()
{
$this->list = ContentService::categoryList('cause');
return $this->fetch();
}
public function lists($category)
{
$this->list = ContentModel::where('category_id', $category)->where('status', 1)->order('create_time desc')->paginate(20);
if (IS_AJAX) {
if (count($this->list) > 0) {
return $this->success($this->fetch('cause/list'));
} else {
return $this->error('已经到最后一页');
}
}
return $this->fetch();
}
public function detail($id)
{
parent::shareArticle();
$this->info = ContentModel::where('id', $id)->where('status', 1)->find();
return $this->fetch();
}
}

View File

@@ -0,0 +1,73 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\Member as MemberModel;
class Center extends _Init
{
public function _initialize()
{
parent::_initialize();
$this->user = MemberModel::find(UID);
$this->nav = 5;
}
public function index()
{
return $this->fetch();
}
/**
* 操作成功跳转的快捷方法
* @access protected
* @param mixed $msg 提示信息
* @param string $url 跳转的URL地址
* @param mixed $data 返回的数据
* @param integer $wait 跳转等待时间
* @param array $header 发送的Header信息
* @return void
*/
protected function success($msg = '', $url = null, $data = '', $wait = 3, array $header = [])
{
$msg = $msg ?: '操作成功';
return parent::success($msg, $url, $data, $wait, $header);
}
/**
* 操作错误跳转的快捷方法
* @access protected
* @param mixed $msg 提示信息
* @param string $url 跳转的URL地址
* @param mixed $data 返回的数据
* @param integer $wait 跳转等待时间
* @param array $header 发送的Header信息
* @return void
*/
protected function error($msg = '', $url = null, $data = '', $wait = 3, array $header = [])
{
$msg = $msg ?: '未知错误';
return parent::error($msg, $url, $data, $wait, $header);
}
protected function back($result)
{
if ($result === true) {
return $this->success();
} else {
return $this->error($result);
}
}
public function tishi()
{
return $this->fetch('');
}
}

View File

@@ -0,0 +1,135 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\Experience as ExperienceModel;
use app\common\model\MemberInfo as MemberInfoModel;
use app\common\service\Experience as ExperienceService;
class Experience extends _Init
{
public function _initialize()
{
parent::_initialize();
$this->nav = 5;
}
public function checkVip($title)
{
$info = MemberInfoModel::get(UID);
if (!$info->is_vip) {
return $this->error('您还不是vip不能' . $title, url('vip/index'));
}
}
public function index()
{
$map = [
'pid' => 0,
'status' => 1,
];
$this->list = ExperienceModel::where($map)->order('id desc')->paginate(10);
if (IS_AJAX) {
if (count($this->list) > 0) {
return $this->success($this->fetch('experience/lists'));
} else {
return $this->error('已经到最后一页');
}
}
return $this->fetch();
}
/**
* 提交评论
* @param [type] $id [description]
* @return [type] [description]
*/
public function detail($id)
{
parent::shareArticle();
if (IS_POST) {
self::checkVip('评论');
$content = $this->request->post('content');
$res = ExperienceService::comment($id, UID, $content);
return $this->back($res);
} else {
$this->info = ExperienceModel::get($id);
$this->info->setInc('click');
return $this->fetch();
}
}
/**
* 点赞
* @param [type] $id [description]
* @return [type] [description]
*/
public function tags($id)
{
self::checkVip('点赞');
$res = ExperienceService::tags(UID, $id);
if ($res === true) {
return $this->success();
} else {
return $this->error($res);
}
}
/**
* 我的分享
* @return [type] [description]
*/
public function mine()
{
$map = [
'pid' => 0,
'uid' => UID,
'status' => 1,
];
$this->list = ExperienceModel::where($map)->order('id desc')->paginate(10);
if (IS_AJAX) {
if (count($this->list) > 0) {
return $this->success($this->fetch('experience/minelists'));
} else {
return $this->error('已经到最后一页');
}
}
return $this->fetch();
}
public function add()
{
if (IS_POST) {
self::checkVip('添加信息');
$data = $this->request->post();
$res = ExperienceService::add($data, UID);
if ($res === true) {
return $this->success('添加成功!', url('Experience/index'));
} else {
return $this->error('添加失败!');
}
} else {
return $this->fetch();
}
}
/**
* 删除
* @param [type] $id [description]
* @return [type] [description]
*/
public function del($id)
{
$res = ExperienceService::del($id, UID);
return $this->back($res);
}
}

View File

@@ -0,0 +1,63 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\Direct as DirectModel;
use app\common\model\Help as HelpModel;
class Help extends _Init
{
public function _initialize()
{
parent::_initialize();
$this->nav = 4;
}
public function index()
{
return $this->fetch();
}
public function desc()
{
return $this->fetch();
}
public function lists($category)
{
$this->list = HelpModel::where(['status' => 1, 'category' => $category])->select();
return $this->fetch();
}
public function detail($id)
{
parent::shareArticle();
$this->info = HelpModel::get($id);
return $this->fetch();
}
/**
* 直销技巧
*/
public function direct()
{
$this->list = DirectModel::where('status', 1)->order('sort desc,id desc')->select();
$this->nav = 5;
return $this->fetch();
}
public function directDetail($id)
{
$this->info = DirectModel::get($id);
$this->info->setInc('click');
$this->nav = 4;
return $this->fetch();
}
}

View File

@@ -0,0 +1,47 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\MemberInfo;
class Index extends _Init
{
public function _initialize()
{
parent::_initialize();
$this->nav = 1;
}
public function index()
{
if (UID || $this->shareUser) {
if ($this->shareUser) {
$this->info = $this->shareUser;
} else {
$this->info = MemberInfo::get(UID);
}
return $this->fetch('user_' . $this->info['index_tpl']);
} else {
return $this->fetch();
}
}
public function info()
{
if (UID == $this->shareUser['uid']) {
$this->info = MemberInfo::get(UID);
} else {
$this->info = $this->shareUser;
}
return $this->fetch();
}
}

View File

@@ -0,0 +1,42 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\MemberInfo as MemberInfoModel;
use Endroid\QrCode\QrCode;
class Invite extends _Init
{
public function _initialize()
{
parent::_initialize();
$this->nav = 5;
}
public function index($uid = '')
{
if (empty($uid)) {
$uid == UID;
}
$qr = new QrCode();
$url = url('login/reg', 'invite=' . $uid);
$this->img = $qr->setText($url)->setSize(350)->writeDataUri();
$info = MemberInfoModel::get($uid);
if (empty($info)) {
$this->redirect('login/info', 'title=邀请人已经被删除或者禁用');
}
$info['description'] = '';
$info['title'] = $info['nickname'];
$info['thumb'] = $info['avatar'];
$this->assign('info', $info);
return $this->fetch();
}
}

View File

@@ -0,0 +1,157 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\Member as MemberModel;
use app\common\service\Member as MemberService;
use app\common\service\Sms as SmsService;
use app\common\validate\Member as MemberValidate;
use cjango\Wechat\Oauth;
class Login extends _Init
{
public function _initialize()
{
// parent::fenxiang();
$this->showWx = 1;
}
public function index()
{
if (IS_POST) {
$user = $this->request->post('username');
$pass = $this->request->post('password');
$res = MemberService::login($user, $pass);
if ($res === true) {
return $this->success('登录成功', 'center/index');
} else {
return $this->error($res);
}
} else {
if (parent::isLogin()) {
$this->redirect('center/index');
}
return $this->fetch();
}
}
/**
* 注册
* @return [type] [description]
*/
public function reg($invite = 0)
{
if (IS_POST) {
$user = $this->request->post('username');
$pass = $this->request->post('password');
$repass = $this->request->post('repassword');
$code = $this->request->post('mobile_code');
//校验注册数据
$data = [
'username' => $user,
'password' => $pass,
'repass' => $repass,
];
$validate = new MemberValidate();
if (!$validate->scene('mobileRegister')->check($data)) {
return $this->error($validate->getError());
}
//验证码校验
$checkCode = SmsService::check($user, $code);
if ($checkCode !== true) {
return $this->error($checkCode);
}
$res = MemberService::register($user, $pass, 1, $invite);
if ($res === true) {
return $this->success('注册成功', 'login/index');
} else {
return $this->error($res);
}
} else {
return $this->fetch();
}
}
/**
* 忘记密码
* @return [type] [description]
*/
public function forget()
{
if (IS_POST) {
$mobile = $this->request->post('mobile');
$pass = $this->request->post('password');
$repass = $this->request->post('repassword');
$code = $this->request->post('mobile_code');
//验证码校验
$checkCode = SmsService::check($mobile, $code);
if ($checkCode !== true) {
return $this->error($checkCode);
}
$userInfo = MemberModel::where('username', $mobile)->find();
$data = [
'newpass' => $pass,
'repass' => $repass,
];
$validate = new MemberValidate();
if (!$validate->scene('forget')->check(['newpass' => $pass, 'repass' => $repass])) {
return $this->error($validate->getError());
}
if (!$userInfo) {
return '没有这个用户';
} elseif ($userInfo->save(['password' => $pass])) {
return $this->success('', url('login/index'));
} else {
return $this->error('更新失败');
}
}
return $this->fetch();
}
// 自动登录
public function autoLogin()
{
parent::initWechat();
$token = Oauth::token();
if (!$token) {
$url = Oauth::url(url('login/autoLogin'));
$this->redirect($url);
} else {
$openid = $token['openid'];
$res = MemberService::openid_login($openid);
if ($res === true) {
$this->redirect(url('center/index'));
} else {
$this->redirect(url('login/info', ['title' => $res]));
}
}
}
/**
* 信息提示 错误提示
* @param [type] $title [description]
* @return [type] [description]
*/
public function info($title)
{
$this->info = $title;
return $this->fetch();
}
public function logout()
{
MemberService::logout();
return $this->success('退出成功', 'login/index');
}
}

View File

@@ -0,0 +1,77 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\MemberList as MemberListModel;
use app\common\service\MemberList as MemberListService;
class Member extends _Init
{
public function _initialize()
{
parent::_initialize();
$this->nav = 5;
}
public function index()
{
$this->list = MemberListModel::where('uid', UID)->where('status', 'egt', 0)->select();
return $this->fetch('');
}
public function add()
{
if (IS_POST) {
$data = $this->request->post();
$res = MemberListService::create($data, UID);
if ($res === true) {
$this->success('添加成功', url('member/index'));
} else {
$this->error($res);
}
} else {
$this->showfoot = '1';
return $this->fetch('');
}
}
public function edit($id)
{
if (IS_POST) {
$data = $this->request->post();
$res = MemberListService::edit($data);
if ($res === true) {
$this->success('编辑成功', url('member/index'));
} else {
$this->error($res);
}
} else {
$this->info = MemberListModel::get($id);
return $this->fetch('add');
}
}
public function del($id)
{
$res = MemberListService::del($id);
$this->back($res);
// if ($res === true) {
// $this->success('删除成功', url('member/index'));
// } else {
// $this->error($res);
// }
}
public function info($id)
{
$this->info = MemberListModel::get($id);
return $this->fetch();
}
}

View File

@@ -0,0 +1,67 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\service\Score as ScoreService;
use app\common\service\Vip as VipService;
use cjango\Wechat;
class Pay extends _Init
{
public function vip($openid = '')
{
parent::initWechat();
if (!$openid) {
$url = Wechat\Oauth::url(url('Pay/getOpenId', 'callback=' . __SELF__));
$this->redirect($url);
}
$fee = 298;
$res = VipService::createPayOrder(UID, $fee, $openid);
if ($res['code'] != 1) {
return $res['msg'];
exit();
}
$this->orderid = $res['data'];
parent::initWechat();
$this->payParams = Wechat\Pay::unified($this->orderid, '超级助手VIP有效期一年', $fee, 'JSAPI', url('openapi/pay/vip'), $openid);
if ($this->payParams == false) {
echo Wechat::error();
exit();
}
return $this->fetch();
}
public function getOpenId($callback)
{
parent::initWechat();
$token = Wechat\Oauth::token();
if ($token) {
$openid = $token['openid'];
$this->redirect($callback . '?openid=' . $openid);
} else {
echo Wechat::error();
}
}
/**
* 兑换会员
* @param [type] $orderid [description]
* @return [type] [description]
*/
public function exchange($orderid)
{
$res = ScoreService::buyVip(UID, $orderid);
if ($res == 1) {
$res = true;
}
return $this->back($res);
}
}

View File

@@ -0,0 +1,76 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\MemberInfo as MemberInfoModel;
use app\common\service\Member as MemberService;
use app\common\service\Message as MessageService;
class Qrcode extends Center
{
public function index()
{
if (UID == $this->shareUser['uid']) {
$this->info = $this->user->info;
} else {
$this->info = $this->shareUser;
$user = MemberInfoModel::where('uid', $this->shareUser['uid'])->find();
$user->setInc('click');
}
return $this->fetch();
}
/**
* 留言
* @param string $uid [description]
* @return [type] [description]
*/
public function comment($uid = '')
{
if (IS_POST) {
$data = $this->request->post();
$res = MessageService::send($data, UID);
return $this->back($res);
} else {
$this->list = MessageService::getList($uid);
return $this->fetch();
}
}
// 点赞
public function tags($uid)
{
$res = MessageService::tags($uid);
if ($res === true) {
return $this->success();
} else {
return $this->error($res);
}
}
// 写签名
public function signature()
{
$signature = $this->request->post('signature');
$res = MemberService::editInfo(UID, ['signature' => $signature], 'signature');
if ($res === true) {
return $this->success('添加成功');
} else {
return $this->error($res);
}
}
//删除
public function del($id)
{
$res = MessageService::del($id);
return $this->back($res);
}
}

View File

@@ -0,0 +1,37 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\Score as ScoreModel;
use app\common\model\ScoreRules as ScoreRulesModel;
use tools\Time;
class Score extends _Init
{
public function _initialize()
{
parent::_initialize();
$this->nav = 5;
}
public function index()
{
$this->list = ScoreModel::where('uid', UID)->select();
$this->dayCount = ScoreModel::where('uid', UID)->where('create_time', 'between', Time::day())->sum('score');
$this->monthCount = ScoreModel::where('uid', UID)->where('create_time', 'between', Time::month())->sum('score');
$this->allCount = ScoreModel::where('uid', UID)->sum('score');
return $this->fetch();
}
public function info()
{
$this->list = ScoreRulesModel::where('')->select();
return $this->fetch();
}
}

View File

@@ -0,0 +1,337 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\Member as MemberModel;
use app\common\model\Province as ProvinceModel;
use app\common\model\Storage as StorageModel;
use app\common\service\City as CitySercice;
use app\common\service\Member as MemberService;
use cjango\Wechat;
use cjango\Wechat\Oauth;
class Setting extends Center
{
public function index()
{
return $this->fetch();
}
//修改密码
public function password()
{
if (IS_POST) {
$newpass = $this->request->post('newpass');
$repass = $this->request->post('repass');
$oldpass = $this->request->post('oldpass');
$res = MemberService::changePassword(UID, $oldpass, $newpass, $repass);
if ($res === true) {
return $this->success('修改成功', 'setting/index');
} else {
return $this->error($res);
}
} else {
return $this->fetch();
}
}
//设置模版
public function template()
{
if (IS_POST) {
$tpl = $this->request->post('tpl');
if (MemberService::changeTpl(UID, $tpl)) {
return $this->success('', 'center/index');
} else {
return $this->error();
}
} else {
return $this->fetch();
}
}
//修改姓名
public function nickname()
{
if (IS_POST) {
$nickname = $this->request->post('nickname');
$res = MemberService::editInfo(UID, ['nickname' => $nickname], 'nickname');
if ($res === true) {
return $this->success('修改成功', 'setting/index');
} else {
return $this->error($res);
}
} else {
return $this->fetch();
}
}
// 修改手机
public function mobile()
{
if (IS_POST) {
$mobile = $this->request->post('mobile');
$res = MemberService::editInfo(UID, ['mobile' => $mobile], 'mobile');
if ($res === true) {
return $this->success('修改成功', 'setting/index');
} else {
return $this->error($res);
}
} else {
return $this->fetch();
}
}
// 添加微信
public function wechat()
{
if (IS_POST) {
$wechat = $this->request->post('wechat');
$res = MemberService::editInfo(UID, ['wechat' => $wechat], 'wechat');
if ($res === true) {
return $this->success('修改成功', 'setting/index');
} else {
return $this->error($res);
}
} else {
return $this->fetch();
}
}
// 修改qq
public function qq()
{
if (IS_POST) {
$qq = $this->request->post('qq');
$res = MemberService::editInfo(UID, ['qq' => $qq], 'qq');
if ($res === true) {
return $this->success('修改成功', 'setting/index');
} else {
return $this->error($res);
}
} else {
return $this->fetch();
}
}
// 修改Email
public function email()
{
if (IS_POST) {
$email = $this->request->post('email');
$res = MemberService::editInfo(UID, ['email' => $email], 'email');
if ($res === true) {
return $this->success('修改成功', 'setting/index');
} else {
return $this->error($res);
}
} else {
return $this->fetch();
}
}
// 修改二维码
public function qrcode()
{
if (IS_POST) {
$qrcode = $this->request->post('qrcode');
$res = MemberService::editInfo(UID, ['qrcode' => $qrcode], 'qrcode');
if ($res === true) {
return $this->success('修改成功', 'setting/index');
} else {
return $this->error($res);
}
} else {
return $this->fetch();
}
}
// 修改职位
public function position()
{
if (IS_POST) {
$position = $this->request->post('position');
$res = MemberService::editInfo(UID, ['position' => $position], 'position');
if ($res === true) {
return $this->success('修改成功', 'setting/index');
} else {
return $this->error($res);
}
} else {
return $this->fetch();
}
}
// 修改地区
public function city()
{
if (IS_POST) {
$province = $this->request->post('province');
$city = $this->request->post('city');
$res = MemberService::editInfo(UID, ['province' => $province, 'city' => $city], 'city');
if ($res === true) {
return $this->success('修改成功', 'setting/index');
} else {
return $this->error($res);
}
} else {
$this->info = MemberService::info(UID);
$this->province = ProvinceModel::where('status', 0)->select();
$this->city = CitySercice::getCity($this->info->province);
return $this->fetch();
}
}
// 绑定/解绑微信
public function bindWechat()
{
if (IS_POST) {
$openid = $this->request->post('openid');
$unbind = $this->request->post('unbind');
if (!empty($unbind)) {
$res = MemberService::unBindWechat(UID, $openid); //解绑
$str = '解除绑定成功';
} else {
$res = MemberService::bindWechat(UID, ['openid' => $openid]); //绑定
$str = '绑定成功';
}
if ($res === true) {
return $this->success($str, 'setting/index');
} else {
return $this->error($res);
}
} else {
$this->wechat = self::getWechat();
$userInfo = MemberModel::where('openid', $this->wechat['openid'])->find();
if ($userInfo) {
$this->assign('userInfo', $userInfo);
}
return $this->fetch();
}
}
/**
* [uploadPicture h5图片上传(后端)]
* @return [type] [description]
*/
public function uploadPicture()
{
$input = $this->request->post();
$data = $input['files']['base64'];
$name = $input['files']['name'];
$hash = hash('md5', base64_decode($data));
$info = StorageModel::where('hash', $hash)->find();
if ($info) {
$return = array('code' => 1, 'msg' => '上传成功', 'id' => $info->id, 'url' => $info->path);
if ($input['type'] == 'headimgurl') {
$res = MemberService::editInfo(UID, ['headimgurl' => $info->path], 'headimgurl');
if ($res === true) {
return $this->success($return);
} else {
return $this->error($res);
}
} else {
return $this->success($return);
}
} else {
// 获取图片
$temp = $data;
list($type, $data) = explode(',', $temp);
// 判断类型
if (strstr($type, 'image/jpeg') !== '') {
$ext = '.jpg';
} elseif (strstr($type, 'image/gif') !== '') {
$ext = '.gif';
} elseif (strstr($type, 'image/png') !== '') {
$ext = '.png';
}
// 生成的文件名
$path = "/uploads/" . $input['type'] . "/" . date('Y-m/d') . '/';
if (!$this->mkdir('.' . $path)) {
exit();
}
$url = $path . $name;
$photo = '.' . $url;
// 生成文件
file_put_contents($photo, base64_decode($data));
$data = [
'hash' => $hash,
'type' => 'image',
'name' => $name,
'ext' => $ext,
'path' => $url,
'size' => $input['files']['size'],
];
if ($insert = StorageModel::create($data)) {
$return = array('code' => 1, 'msg' => '上传成功', 'url' => $url, 'id' => $insert->id);
if ($input['type'] == 'headimgurl') {
$res = MemberService::editInfo(UID, ['headimgurl' => $url], 'headimgurl');
if ($res === true) {
return $this->success($return);
} else {
return $this->error($res);
}
} else {
return $this->success($return);
}
} else {
return $this->error('上传失败');
}
}
}
/**
* [mkdir 检测路径]
* @param [type] $savepath [description]
* @return [type] [description]
*/
public function mkdir($dir)
{
if (is_dir($dir)) {
return true;
}
if (mkdir($dir, 0777, true)) {
return true;
} else {
return false;
}
}
//获取城市数据
public function getCity($id)
{
$list = CitySercice::getData($id);
echo json_encode($list);
}
// 获取微信数据
public function getWechat()
{
parent::initWechat();
$token = Oauth::token();
if (!$token) {
$url = Oauth::url(url('setting/bindWechat'), 'STATE', 'snsapi_userinfo');
$this->redirect($url);
}
$wechat = Oauth::info($token['access_token'], $token['openid']);
if ($wechat) {
return $wechat;
} else {
$this->redirect(url('setting/bindWechat'));
}
}
}

View File

@@ -0,0 +1,47 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\Content as ContentModel;
use app\common\service\Content as ContentService;
class Share extends _Init
{
public function _initialize()
{
parent::_initialize();
$this->nav = 3;
}
public function index()
{
$this->list = ContentService::categoryList('share');
return $this->fetch();
}
public function lists($category)
{
$this->list = ContentModel::where(['status' => 1, 'category_id' => $category])->order('id desc')->paginate(20);
if (IS_AJAX) {
if (count($this->list) > 0) {
return $this->success($this->fetch('share/list'));
} else {
return $this->error('已经到最后一页');
}
}
return $this->fetch();
}
public function detail($id)
{
parent::shareArticle();
$this->info = ContentModel::get($id);
return $this->fetch();
}
}

View File

@@ -0,0 +1,58 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\Member as MemberModel;
use app\common\service\Sms as SmsService;
class Sms extends _Init
{
public function _initialize()
{
}
/**
* [短信验证码]
* @return [type] [description]
*/
public function getsms()
{
$mobile = $this->request->post('mobile');
$forget = $this->request->post('forget');
$MemberInfo = MemberModel::where('username', $mobile)->find();
if (!empty($MemberInfo) && empty($forget)) {
return $this->error('这个手机号已经注册过了');
}
$res = SmsService::send($mobile);
if ($res === true) {
return $this->success('发送成功');
} else {
return $this->error($res);
}
}
/**
* [短信验证码]
* @return [type] [description]
*/
public function getresms()
{
$mobile = $this->request->post('mobile');
$MemberInfo = MemberModel::where('username', $mobile)->find();
$res = SmsService::send($mobile);
if ($res === true) {
return $this->success('发送成功');
} else {
return $this->error($res);
}
}
}

View File

@@ -0,0 +1,33 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\Suggest as SuggestModel;
class Suggest extends Center
{
public function index()
{
if (IS_POST) {
$content = $this->request->post('content');
$data = [
'uid' => UID,
'content' => $content,
];
if (SuggestModel::create($data)) {
return $this->success('提交成功', 'center/index');
} else {
return $this->error();
}
} else {
return $this->fetch();
}
}
}

View File

@@ -0,0 +1,40 @@
<?php
// +-----------------------------------------------------------------------------------+
// | Software: 卍 |
// | Version: 0.1 |
// | Site: http://www.xdeepu.cn |
// | Author: 玄尘 <122383162@qq.com> |
// | Copyright (c) 2017, http://www.xdeepu.cn. All Rights Reserved. |
// +-----------------------------------------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\MemberList as MemberListModel;
/**
* fdsaf
*/
class Tools extends _Init
{
public function index()
{
$this->list = MemberListModel::where('')->select();
return $this->fetch('');
}
public function add()
{
if (IS_POST) {
# code...
} else {
$this->showfoot = '1';
$this->list = MemberListModel::where('')->select();
return $this->fetch('');
}
}
public function info()
{
return $this->fetch('');
}
}

View File

@@ -0,0 +1,75 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use think\Config;
use think\Db;
class Upload extends _Init
{
public function uploadPicture()
{
$data = $this->request->post('files.base64');
$size = $this->request->post('files.size');
list($type, $data) = explode(',', $data);
if (strstr($type, 'image/jpeg') !== '') {
$ext = '.jpg';
} elseif (strstr($type, 'image/gif') !== '') {
$ext = '.gif';
} elseif (strstr($type, 'image/png') !== '') {
$ext = '.png';
}
$fileN = 'img' . time() . $ext;
$path = Config::get('upload.rootPath') . 'image/';
if (!$this->mkdir($path)) {
return $this->error('头像保存目录不存在');
}
$fileName = $path . $fileN;
file_put_contents($fileName, base64_decode($data));
$path = substr($fileName, 1);
$data = [
'type' => 'image',
'name' => $fileN,
'ext' => $ext,
'hash' => md5($fileN),
'path' => $path,
'size' => $size,
'create_time' => time(),
];
$last = Db::name('Storage')->insertGetId($data);
if ($last) {
$re = [
'filename' => $path,
'fileid' => $last,
];
return $this->success('上传成功', '', $re);
} else {
return $this->error('上传失败');
}
}
/**
* [mkdir 检测路径]
* @param [type] $savepath [description]
*/
private function mkdir($dir)
{
if (is_dir($dir)) {
return true;
}
if (mkdir($dir, 0755, true)) {
return true;
} else {
return false;
}
}
}

View File

@@ -0,0 +1,31 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\model\Member as MemberModel;
class User extends _Init
{
public function _initialize()
{
parent::_initialize();
}
public function index()
{
$this->info = MemberModel::get($uid);
return $this->fetch('user_' . $this->info->index_tpl);
}
public function intro()
{
return $this->fetch();
}
}

View File

@@ -0,0 +1,18 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
class Vip extends Center
{
public function index()
{
return $this->fetch();
}
}

View File

@@ -0,0 +1,151 @@
<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\mobile\controller;
use app\common\service\MemberInfo;
use app\common\service\Score as ScoreService;
use cjango\Wechat\Token;
use think\Cache;
use think\Config;
use tools\Initialize;
use tools\Str;
class _Init extends Initialize
{
public function _initialize()
{
define('UID', self::isLogin());
if (!UID) {
//判断跳转。文章、每日分享、事业介绍详情页,个人资料页面不跳转
self::T();
// $this->redirect('login/wxLogin', 'callback=' . base64_encode(__SELF__));
}
$uid = $this->request->get('uid');
if ($uid) {
$this->shareUser = MemberInfo::show($uid);
}
//分享初始化
self::fenxiang();
}
/**
* 跳转
*/
public function T()
{
$data = [
'Login/index',
'Login/reg',
'Login/autoLogin',
'Login/info',
'Cause/detail',
'Share/detail',
'Article/show',
'Index/info',
'Index/index',
'Help/directdetail',
'Help/detail',
'Invite/index',
'Qrcode/index',
];
$url = CONTROLLER_NAME . '/' . ACTION_NAME;
if (!in_array($url, $data) || (!UID && !$this->request->get('uid'))) {
if (IS_AJAX) {
return $this->error('操作失败', url('login/index'));
} else {
$this->redirect('login/index');
}
}
}
/**
* 分享文章获取积分
*/
public function ShareArticle()
{
if (!empty($this->shareUser->uid) && $this->shareUser->uid != UID) {
ScoreService::share($this->shareUser->uid);
}
}
/**
* 操作成功跳转的快捷方法
* @access protected
* @param mixed $msg 提示信息
* @param string $url 跳转的URL地址
* @param mixed $data 返回的数据
* @param integer $wait 跳转等待时间
* @param array $header 发送的Header信息
* @return void
*/
protected function success($msg = '', $url = null, $data = '', $wait = 3, array $header = [])
{
$msg = $msg ?: '操作成功';
return parent::success($msg, $url, $data, $wait, $header);
}
/**
* 操作错误跳转的快捷方法
* @access protected
* @param mixed $msg 提示信息
* @param string $url 跳转的URL地址
* @param mixed $data 返回的数据
* @param integer $wait 跳转等待时间
* @param array $header 发送的Header信息
* @return void
*/
protected function error($msg = '', $url = null, $data = '', $wait = 3, array $header = [])
{
$msg = $msg ?: '未知错误';
return parent::error($msg, $url, $data, $wait, $header);
}
protected function back($result)
{
if ($result === true) {
return $this->success();
} else {
return $this->error($result);
}
}
/**
* 微信分享
* @return [type] [description]
*/
public function fenxiang()
{
parent::initWechat();
// 微信分享
$ticket = Cache::get('Wechat_ticket');
$config = Config::get('wechat');
if (!$ticket) {
$ticket = Token::ticket();
Cache::set('Wechat_ticket', $ticket, 7000);
}
$wx['appid'] = $config['appid'];
$wx['timestamp'] = time();
$wx['noncestr'] = $noncestr = Str::random(32);
$sign = array(
'noncestr' => $noncestr,
'jsapi_ticket' => $ticket,
'timestamp' => time(),
'url' => __SELF__,
);
ksort($sign);
$signStr = sha1(urldecode(http_build_query($sign)));
$wx['signature'] = $signStr;
$this->assign('wx', $wx);
}
}