作者 王晓刚
1 个管道 的构建 通过 耗费 9 秒

问题文档修复

... ... @@ -130,24 +130,24 @@ class Index extends Backend
}
if ($this->request->isPost()) {
$url = $this->request->get('url', 'index/forget');
$email = $this->request->post('email');
$mobile = $this->request->post('mobile');
$rule = [
'email' => 'require|email',
'mobile' => 'require',
// '__token__' => 'require|token',
];
$data = [
'email' => $email,
'mobile' => $mobile,
// '__token__' => $token,
];
$validate = new Validate($rule, [], ['email' => __('email')]);
$validate = new Validate($rule, [], ['mobile' => __('mobile')]);
$result = $validate->check($data);
if (!$result) {
$this->error($validate->getError(), $url, ['token' => $this->request->token()]);
}
//根据email获取商户信息
$admin = Db::name('admin')->where(['email'=>$email])->find();
//根据mobile获取商户信息
$admin = Db::name('admin')->where(['mobile'=>$mobile])->find();
if(empty($admin)){
$this->error('当前email尚未绑定');
$this->error('当前手机号尚未绑定');
}
if(empty($admin['user_id'])){
$this->error('平台管理员忘记密码请联系总管理员');
... ... @@ -158,12 +158,12 @@ class Index extends Backend
//生成验证码
$code = generateCode(6);
//储存验证码
$admin_code = Db::name('admin_code')->where(['email'=>$email])->find();
$admin_code = Db::name('admin_code')->where(['mobile'=>$mobile])->find();
$arr['code'] = $code;
$arr['pasttime'] = time()+600;
$arr['is_use'] = 0;
if(empty($admin_code)){
$arr['email'] = $email;
$arr['mobile'] = $mobile;
$arr['createtime'] = time();
$result1 = Db::name('admin_code')->insert($arr);
}else{
... ... @@ -173,13 +173,17 @@ class Index extends Backend
if(empty($result1)){
$this->error('sql执行失败');
}
//发送验证码
$this->send_ems($admin['email'],$code);
if ($result) {
$this->success('发送成功');
} else {
$content = array(
'content' => "【工品达】您的验证码是:" . $code . ",请于10分钟内使用,如非本人操作,可忽略此消息。",//短信内容
'mobile' => $mobile,//手机号码
'tKey' => time(),
);
$result2 = json_decode(send_sms2($content),true);
if ($result2['code'] != 200) {
Db::rollback();
$this->error('发送失败');
}
$this->success('发送成功');
/*AdminLog::setTitle(__('Login'));
$result = $this->auth->login($username, $password, $keeplogin ? 86400 : 0);
if ($result === true) {
... ... @@ -199,7 +203,7 @@ class Index extends Backend
return $this->view->fetch();
}
public function send_ems($receiver,$code){
/*public function send_ems($receiver,$code){
\think\Config::set('site', \think\Config::get('site'));
$email = new Email();
$str = "验证码:$code,10分钟内有效。";
... ... @@ -209,7 +213,7 @@ class Index extends Backend
->message($str)
->send();
return $result;
}
}*/
/**
* 验证验证码是否正确
... ... @@ -217,24 +221,24 @@ class Index extends Backend
public function verify_code(){
if ($this->request->isPost()) {
$url = $this->request->get('url', 'index/forget');
$email = $this->request->post('email');
$mobile = $this->request->post('mobile');
$code = $this->request->post('code');
$rule = [
'email' => 'require|email',
'mobile' => 'require',
'code' => 'require',
// '__token__' => 'require|token',
];
$data = [
'email' => $email,
'mobile' => $mobile,
'code' => $code,
// '__token__' => $token,
];
$validate = new Validate($rule, [], ['email' => __('email'), 'code' => '请输入验证码']);
$validate = new Validate($rule, [], ['mobile' => __('mobile'), 'code' => '请输入验证码']);
$result = $validate->check($data);
if (!$result) {
$this->error($validate->getError(), $url, ['token' => $this->request->token()]);
}
$admin_code = Db::name('admin_code')->where(['email'=>$email])->find();
$admin_code = Db::name('admin_code')->where(['mobile'=>$mobile])->find();
if(empty($admin_code)){
$this->error('404');
}
... ... @@ -254,8 +258,8 @@ class Index extends Backend
//生成令牌(为了安全)
$str = "Bronet";
$auth_code = config('auth_code');
$token = rawurlencode(sha1(md5($str.$auth_code).md5($email)));
$this->success('验证通过',url('reset_password',['token'=>$token,'email'=>$email],false,true));
$token = rawurlencode(sha1(md5($str.$auth_code).md5($mobile)));
$this->success('验证通过',url('reset_password',['token'=>$token,'email'=>$mobile],false,true));
}
}
... ... @@ -270,21 +274,21 @@ class Index extends Backend
if($this->request->isPost()){
$password = $this->request->param('password');
$affirm_password = $this->request->param('affirm_password');
$email = $this->request->param('email');
$mobile = $this->request->param('mobile');
$token = $this->request->param('token');
$rule = [
'password' => 'require|length:3,30',
'affirm_password' => 'require|length:3,30',
'email' => 'require|email',
'mobile' => 'require',
'token' => 'require',
];
$data = [
'password' => $password,
'affirm_password' => $affirm_password,
'email' => $email,
'mobile' => $mobile,
'token' => $token,
];
$validate = new Validate($rule, [], ['password' => __('password'), 'affirm_password' => __('Password'), 'email' => __('email')]);
$validate = new Validate($rule, [], ['password' => __('password'), 'affirm_password' => __('Password'), 'mobile' => __('mobile')]);
$result = $validate->check($data);
if (!$result) {
$this->error($validate->getError(), $url, ['token' => $this->request->token()]);
... ... @@ -294,11 +298,11 @@ class Index extends Backend
}
$str = "Bronet";
$auth_code = config('auth_code');
$token2 = rawurlencode(sha1(md5($str.$auth_code).md5($email)));
$token2 = rawurlencode(sha1(md5($str.$auth_code).md5($mobile)));
if($token != $token2){
$this->error('令牌错误','','','');
}
$admin = Db::name('admin')->where(['email'=>$email])->find();
$admin = Db::name('admin')->where(['email'=>$mobile])->find();
$password = md5(md5($password) . $admin['salt']);
$result = Db::name('admin')->where(['id'=>$admin['id']])->update(['password'=>$password]);
if(empty($result)){
... ... @@ -308,10 +312,10 @@ class Index extends Backend
$this->success('重置成功',$url);
}else{
$token = $this->request->param('token');
$email = $this->request->param('email');
$mobile = $this->request->param('mobile');
$str = "Bronet";
$auth_code = config('auth_code');
$token2 = rawurlencode(sha1(md5($str.$auth_code).md5($email)));
$token2 = rawurlencode(sha1(md5($str.$auth_code).md5($mobile)));
if($token != $token2){
$this->error('令牌错误','','','');
}
... ...
<!DOCTYPE html>
<html lang="en">
<head>
{include file="common/meta" /}
<style type="text/css">
body {
color:#999;
background:url('{$background}');
background-size:cover;
}
a {
color:#fff;
}
.login-panel{margin-top:150px;}
.login-screen {
max-width:400px;
padding:0;
margin:100px auto 0 auto;
}
.login-screen .well {
border-radius: 3px;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
background: rgba(255,255,255, 0.2);
}
.login-screen .copyright {
text-align: center;
}
@media(max-width:767px) {
.login-screen {
padding:0 20px;
}
}
.profile-img-card {
width: 100px;
height: 100px;
margin: 10px auto;
display: block;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
}
.profile-name-card {
text-align: center;
}
#login-form {
margin-top:20px;
}
#login-form .input-group {
margin-bottom:15px;
}
</style>
</head>
<body>
<div class="container">
<div class="login-wrapper">
<div class="login-screen">
<div class="well">
<div class="login-form">
<p class="profile-name-card"></p>
<form action="" method="post" id="login-form">
<div id="errtips" class="hide"></div>
{:token()}
<div class="input-group">
<div class="input-group-addon"><span class="fa fa-envelope" aria-hidden="true"></span></div>
<input type="text" class="form-control" id="pd-form-email" placeholder="{:__('Mobile')}" name="mobile" value="" data-rule="{:__('Mobile')}:required;mobile" />
</div>
{if $config.fastadmin.login_captcha}
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-option-horizontal" aria-hidden="true"></span></div>
<input type="text" name="code" class="form-control" id="code" placeholder="{:__('Captcha')}"/>
<span class="input-group-addon" style="padding:0;border:none;cursor:pointer;">
<!--<img src="{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha" width="100" height="30" onclick="this.src = '{:rtrim('__PUBLIC__', '/')}/index.php?s=/captcha&r=' + Math.random();"/>-->
<button type="button" class="btn btn-default btn-small btn-block get_code" style="border:0;">发送验证码</button>
</span>
</div>
{/if}
<div class="form-group button">
<button type="button" class="btn btn-success btn-lg btn-block affirm">确认</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{include file="common/script" /}
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -90,9 +90,9 @@
<input type="checkbox" name="keeplogin" id="keeplogin" value="1" />
{:__('Keep login')}
</label>
<!--<label class="inline pull-right" style="cursor:pointer" onclick="window.location.href='{:url('forget')}'">
<label class="inline pull-right" style="cursor:pointer" onclick="window.location.href='{:url('forget')}'">
忘记密码?
</label>-->
</label>
</div>
<div class="form-group">
<button type="submit" class="btn btn-success btn-lg btn-block">{:__('Sign in')}</button>
... ...
<!DOCTYPE html>
<html lang="en">
<head>
{include file="common/meta" /}
<style type="text/css">
body {
color:#999;
background:url('{$background}');
background-size:cover;
}
a {
color:#fff;
}
.login-panel{margin-top:150px;}
.login-screen {
max-width:400px;
padding:0;
margin:100px auto 0 auto;
}
.login-screen .well {
border-radius: 3px;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
background: rgba(255,255,255, 0.2);
}
.login-screen .copyright {
text-align: center;
}
@media(max-width:767px) {
.login-screen {
padding:0 20px;
}
}
.profile-img-card {
width: 100px;
height: 100px;
margin: 10px auto;
display: block;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
}
.profile-name-card {
text-align: center;
}
#login-form {
margin-top:20px;
}
#login-form .input-group {
margin-bottom:15px;
}
</style>
</head>
<body>
<div class="container">
<div class="login-wrapper">
<div class="login-screen">
<div class="well">
<div class="login-form">
<p class="profile-name-card"></p>
<form action="" method="post" id="login-form">
<div id="errtips" class="hide"></div>
{:token()}
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></div>
<input type="password" class="form-control" id="pd-form-password" placeholder="{:__('Password')}" name="password" autocomplete="off" value="" data-rule="{:__('Password')}:required;password" />
</div>
<div class="input-group">
<div class="input-group-addon"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></div>
<input type="password" class="form-control" id="pd-form-affirm_password" placeholder="{:__('确认密码')}" name="affirm_password" autocomplete="off" value="" data-rule="{:__('Password')}:required;password" />
</div>
<div class="form-group button">
<button type="submit" class="btn btn-success btn-lg btn-block affirm">确认修改</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{include file="common/script" /}
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -82,7 +82,7 @@ class Goods extends Frontend
if(!empty($collect)){
$is_collect = "1";
}
$userModel = new \app\index\model\User();
/*$userModel = new \app\index\model\User();
$encrypt = '2';
$user = $userModel->findData(['id'=>$user_id]);
if(!empty($user)){
... ... @@ -94,7 +94,7 @@ class Goods extends Frontend
if($encrypt == '2'){
$data['store_phone'] = "***********";
$data['store_address'] = "***********";
}
}*/
}
$data['is_collect'] = $is_collect;
//获取评论
... ... @@ -300,7 +300,7 @@ class Goods extends Frontend
$ids[] = $vo['id'];
}
}
$data[$key]['distance'] = $distance;
$data[$key]['distance'] = $encrypt == '1' ? $distance : '';
}
if(!empty($param['sort'])){
if($param['sort'] == 2){
... ...
... ... @@ -27,6 +27,7 @@ class Shop extends Frontend
}
public function detail(){
$province_id = $this->request->param('province_id',0,'intval');
$user_id = $this->auth->id;
$store_id = $this->request->param('store_id',0,'intval');
if(empty($store_id)){
... ... @@ -45,7 +46,7 @@ class Shop extends Frontend
$userModel = new \app\index\model\User();
$user = $userModel->findData(['id'=>$user_id]);
if(!empty($user)){
if($user['is_svip'] == '1' || ($user['is_vip'] == '1' && in_array($user['province_id'],$user['province_ids']))){
if($user['is_svip'] == '1' || ($user['is_vip'] == '1' && in_array($province_id,$user['province_ids']))){
$encrypt = '1';
}
}
... ... @@ -57,7 +58,10 @@ class Shop extends Frontend
$data['address'] = "***********";
}
$this->assign('data',$data);
dump(collection($data)->toArray());
// dump(collection($data)->toArray());
if($this->request->isAjax()){
$this->success('SUCCESS','',$data);
}
return $this->fetch();
}
... ...
... ... @@ -743,6 +743,10 @@
$(vo.property).each(function (key2, p) {
property += "<span class=\"myLable\">"+p+"</span>";
});
var distance = '';
if(vo.distance != ''){
distance = "("+vo.distance+"km)";
}
var str = "<tr onclick=\"window.location.href='{:url('index/goods/detail',array('goods_id'=>'GOODS_ID'))}'\">\n" +
" <td>"+vo.id+"</td>\n" +
" <td><img src=\""+vo.thumbnail+"\" alt=\"\" style='width: 100px;height:100px'></td>\n" +
... ... @@ -751,7 +755,7 @@
" <td onclick=\"window.event.stopPropagation();window.location.href='{:url('index/shop/detail',array('store_id'=>'STORE_ID'))}'\">"+vo.store_name+property+"\n" +
" <td>"+vo.brand+"</td>\n" +
" <td>单价:¥"+vo.price+"</td>\n" +
" <td>"+vo.store_address+"("+vo.distance+"km)</td>\n" +
" <td>"+vo.store_address+""+distance+"</td>\n" +
" </tr>";
goods_html += str.replace("GOODS_ID",vo.id).replace("STORE_ID",vo.store_id);
console.log(goods_html);
... ...
... ... @@ -317,8 +317,8 @@
</div>
<div class="infoBox">
<p class="shopTitle">{$data.name}</p>
<p class="contactNumber">联系电话:{$data.phone}</p>
<p class="shopAddress">店铺地址:{$data.address}</p>
<p class="contactNumber">联系电话:</p>
<p class="shopAddress">店铺地址:</p>
<div class="shopIntroduceBox">
<p class="title">店铺简介:</p>
<p class="contentText"> {$data.content}</p>
... ... @@ -390,6 +390,8 @@
lat = r.point.lat;
//初始化产品热卖
initGoodsList();
//店铺详情
getStore();
}else{
toast(res.msg);
}
... ... @@ -404,6 +406,24 @@
},{enableHighAccuracy: true})
}
//店铺详细信息
function getStore(){
$.ajax({
url:"{:url('index/shop/detail')}",
type:"POST",
data:{'store_id':store_id,'province_id':province_id},
success:function(res){
if(res.code == 1){
$('.contactNumber').text("联系电话:"+res.data.phone);
$('.shopAddress').text("店铺地址:"+res.data.address);
}
},
error:function(res){
toast('与服务器断开连接');
}
})
}
//初始化商品列表
function initGoodsList(page = 1, pageNum = 25){
$.ajax({
... ...
... ... @@ -379,6 +379,148 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'form'], functi
}, function (data) {
$("input[name=captcha]").next(".input-group-addon").find("img").trigger("click");
});
},
forget: function () {
var lastlogin = localStorage.getItem("lastlogin");
if (lastlogin) {
lastlogin = JSON.parse(lastlogin);
$("#profile-img").attr("src", Backend.api.cdnurl(lastlogin.avatar));
$("#profile-name").val(lastlogin.username);
}
//让错误提示框居中
Fast.config.toastr.positionClass = "toast-top-center";
//本地验证未通过时提示
$("#login-form").data("validator-options", {
invalid: function (form, errors) {
$.each(errors, function (i, j) {
Toastr.error(j);
});
},
target: '#errtips'
});
//为表单绑定事件
/*Form.api.bindevent($("#login-form"), function (data,res) {
/!*localStorage.setItem("lastlogin", JSON.stringify({
id: data.id,
username: data.username,
avatar: data.avatar
}));
location.href = Backend.api.fixurl(data.url);*!/
//显示验证码
Toastr.success('发送成功');
}, function (data,res) {
Toastr.error('发送失败');
$("input[name=captcha]").next(".input-group-addon").find("img").trigger("click");
});*/
//发送验证码
$('.get_code').click(function(){
var mobile = $('#pd-form-email').val();
var mobile_regular = /^1[3456789]\d{9}$/;
if(mobile == ''){
Toastr.error('请输入手机号');
return false;
}else if(!mobile_regular.test(mobile)){
Toastr.error('请输入正确手机号');
return false;
}
var that = $(this);
that.text('发送中...');
that.addClass('disabled');
that.attr('disabled',true);
$.ajax({
url:"index/forget",
type:"POST",
data:{'email':email},
success:function(res){
console.log(res);
if(res.code == 1){
that.text('重新发送');
that.removeClass('disabled');
that.attr('disabled',false);
Toastr.success('发送成功');
}else{
Toastr.error(res.msg);
}
},
error:function(res){
Toastr.error('发送失败');
}
})
})
//验证验证码是否正确
$('.affirm').click(function(){
var mobile = $('#pd-form-email').val();
var mobile_regular = /^1[3456789]\d{9}$/;
var code = $('#code').val()
if(mobile == ''){
Toastr.error('请输入手机号');
return false;
}else if(!mobile_regular.test(mobile)){
Toastr.error('请输入正确手机号');
return false;
}else if(code == ''){
Toastr.error('请输入验证码');
return false;
}
$.ajax({
url:"index/verify_code",
type:"POST",
data:{'mobile':mobile,'code':code},
success:function(res){
console.log(res);
if(res.code == 1){
Toastr.success('验证通过,请稍等...');
setTimeout(function(){
window.location.href = res.url;
},2000)
}else{
Toastr.error(res.msg);
}
},
error:function(res){
Toastr.error('发送失败');
}
})
})
},
reset_password: function () {
var lastlogin = localStorage.getItem("lastlogin");
if (lastlogin) {
lastlogin = JSON.parse(lastlogin);
$("#profile-img").attr("src", Backend.api.cdnurl(lastlogin.avatar));
$("#profile-name").val(lastlogin.username);
}
//让错误提示框居中
Fast.config.toastr.positionClass = "toast-top-center";
//本地验证未通过时提示
$("#login-form").data("validator-options", {
invalid: function (form, errors) {
$.each(errors, function (i, j) {
Toastr.error(j);
});
},
target: '#errtips'
});
//为表单绑定事件
Form.api.bindevent($("#login-form"), function (data,res) {
/*localStorage.setItem("lastlogin", JSON.stringify({
id: data.id,
username: data.username,
avatar: data.avatar
}));
location.href = Backend.api.fixurl(data.url);*/
setTimeout(function(){
window.location.href = res.url;
},2000)
}, function (data,res) {
$("input[name=captcha]").next(".input-group-addon").find("img").trigger("click");
});
}
};
... ...