作者 潘浩文
1 个管道 的构建 通过 耗费 1 秒

订单渲染

<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Powerless < wzxaini9@gmail.com>
// +----------------------------------------------------------------------
namespace app\user\controller;
use cmf\controller\WeChatBaseController;
use think\Validate;
use cmf\controller\HomeBaseController;
use app\user\model\UserModel;
use think\Db;
class UserController extends WeChatBaseController
{
public function _initialize()
{
parent::_initialize();
$this->checkWeChatUserLogin();
}
/**
* 登录
*/
public function myLight()
{
$re=$this->checkLogin();
$data=Db::name('light_order')
->alias('lo')
->join('light l','lo.light_id=l.id')
->join('temple t','l.temple_id=t.id')
->where(['lo.users_id'=>$re['id'],'lo.status'=>1,'lo.end_time'=>['>',time()]])
->field('t.name as tname,lo.*')
->select();
$this->assign('list',$data);
return $this->fetch(":myLight");
}
/**
* 登录验证提交
*/
public function doLogin()
{
if ($this->request->isPost()) {
$validate = new Validate([
'captcha' => 'require',
'username' => 'require',
'password' => 'require|min:6|max:32',
]);
$validate->message([
'username.require' => '用户名不能为空',
'password.require' => '密码不能为空',
'password.max' => '密码不能超过32个字符',
'password.min' => '密码不能小于6个字符',
'captcha.require' => '验证码不能为空',
]);
$data = $this->request->post();
if (!$validate->check($data)) {
$this->error($validate->getError());
}
if (!cmf_captcha_check($data['captcha'])) {
$this->error('验证码错误');
}
$userModel = new UserModel();
$user['user_pass'] = $data['password'];
if (Validate::is($data['username'], 'email')) {
$user['user_email'] = $data['username'];
$log = $userModel->doEmail($user);
} else if (preg_match('/(^(13\d|15[^4\D]|17[013678]|18\d)\d{8})$/', $data['username'])) {
$user['mobile'] = $data['username'];
$log = $userModel->doMobile($user);
} else {
$user['user_login'] = $data['username'];
$log = $userModel->doName($user);
}
$session_login_http_referer = session('login_http_referer');
$redirect = empty($session_login_http_referer) ? $this->request->root() : $session_login_http_referer;
switch ($log) {
case 0:
cmf_user_action('login');
$this->success('登录成功', $redirect);
break;
case 1:
$this->error('登录密码错误');
break;
case 2:
$this->error('账户不存在');
break;
case 3:
$this->error('账号被禁止访问系统');
break;
default :
$this->error('未受理的请求');
}
} else {
$this->error("请求错误");
}
}
/**
* 找回密码
*/
public function findPassword()
{
return $this->fetch('/find_password');
}
/**
* 用户密码重置
*/
public function passwordReset()
{
if ($this->request->isPost()) {
$validate = new Validate([
'captcha' => 'require',
'verification_code' => 'require',
'password' => 'require|min:6|max:32',
]);
$validate->message([
'verification_code.require' => '验证码不能为空',
'password.require' => '密码不能为空',
'password.max' => '密码不能超过32个字符',
'password.min' => '密码不能小于6个字符',
'captcha.require' => '验证码不能为空',
]);
$data = $this->request->post();
if (!$validate->check($data)) {
$this->error($validate->getError());
}
if (!cmf_captcha_check($data['captcha'])) {
$this->error('验证码错误');
}
$errMsg = cmf_check_verification_code($data['username'], $data['verification_code']);
if (!empty($errMsg)) {
$this->error($errMsg);
}
$userModel = new UserModel();
if ($validate::is($data['username'], 'email')) {
$log = $userModel->emailPasswordReset($data['username'], $data['password']);
} else if (preg_match('/(^(13\d|15[^4\D]|17[013678]|18\d)\d{8})$/', $data['username'])) {
$user['mobile'] = $data['username'];
$log = $userModel->mobilePasswordReset($data['username'], $data['password']);
} else {
$log = 2;
}
switch ($log) {
case 0:
$this->success('密码重置成功', $this->request->root());
break;
case 1:
$this->error("您的账户尚未注册");
break;
case 2:
$this->error("您输入的账号格式错误");
break;
default :
$this->error('未受理的请求');
}
} else {
$this->error("请求错误");
}
}
}
\ No newline at end of file
... ...
... ... @@ -17,8 +17,8 @@
// alert(res.err_code+res.err_desc+res.err_msg);
if (res.err_msg=='get_brand_wcpay_request:cancel'){
//支付取消逻辑
window.history.go(-1);
}else if (res.err_msg=='get_brand_wcpay_request:ok'){
window.location.href="{:url('user/user/myLight')}"
//支付成功逻辑
}else{
//支付失败逻辑
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>我的福牌</title>
<script src="__TMPL__/public/assets/js/jquery-2.1.0.js"></script>
<script src="__TMPL__/public/assets/js/fontsize.js"></script>
<link href="__TMPL__/public/assets/css/blessing.css" rel="stylesheet">
</head>
<body>
<div class="content">
<div class="cards-list">
<foreach name="list" item="vo">
<div class="item" onclick="enter()">
<image src="{:cmf_get_image_preview_url($vo.thumbnail);}" class="img"></image>
<div class="right">
<div class="name">{$vo.tname}</div>
<div class="author">{$vo.name}</div>
<div class="time">{:date('Y年m月d日',$vo['create_time']);}-{:date('Y年m月d日',$vo['end_time']);}</div>
</div>
</div>
</foreach>
</div>
</div>
</body>
<script>
function enter() {
window.location.href='./cards-detail.html';
}
</script>
</html>
\ No newline at end of file
... ...