切换导航条
此项目
正在载入...
登录
李涵
/
integral
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
李洪娟
6 years ago
提交
320f35e104ccb09f9913b2ee02838e817bc96a05
2 个父辈
06403121
9e8b7cdc
master
...
li
lilijuan
Merge branch 'master' of
http://114.215.101.231:8099/lihan/integral
into lilijuan
隐藏空白字符变更
内嵌
并排对比
正在显示
15 个修改的文件
包含
397 行增加
和
67 行删除
app/friendship/controller/FriendController.php
app/index/controller/IndexController.php
app/integral/controller/IntegralController.php
app/login/controller/LoginController.php
app/sms/controller/SmsController.php
app/user/controller/AdminIndexController.php
app/user/controller/CenterController.php
public/themes/admin_simpleboot3/user/admin_index/index.html
public/themes/simpleboot3/friendship/password_manager.html
public/themes/simpleboot3/index/index/login.html → public/themes/simpleboot3/login/login/login.html
public/themes/simpleboot3/user/center/edit_phone.html
public/themes/simpleboot3/user/center/integral_log.html
simplewind/cmf/controller/HomeBaseController.php
simplewind/cmf/controller/NoneBaseController.php
simplewind/vendor/weiwei/api-doc/src/Doc.php
app/friendship/controller/FriendController.php
查看文件 @
320f35e
...
...
@@ -127,14 +127,23 @@ class FriendController extends HomeBaseController
if
(
$total
>
0
)
{
if
(
Db
::
name
(
'user'
)
->
where
([
'id'
=>
$uid
])
->
setDec
(
'balance'
,
$total
))
{
if
(
Db
::
name
(
'user'
)
->
where
([
'id'
=>
$friend_id
])
->
setInc
(
'balance'
,
$total
))
{
//
插入赠送
记录日志log
//记录日志log
$log
=
[
'uid'
=>
$friend_id
,
'create_time'
=>
time
(),
'balance'
=>
$total
,
'type'
=>
3
0
=>
[
'uid'
=>
$friend_id
,
'create_time'
=>
time
(),
'balance'
=>
$total
,
'type'
=>
3
],
1
=>
[
'uid'
=>
session
(
'user.id'
),
'create_time'
=>
time
(),
'balance'
=>
$total
,
'type'
=>
4
]
];
if
(
Db
::
name
(
'zj_integral_log'
)
->
insert
(
$log
))
{
if
(
Db
::
name
(
'zj_integral_log'
)
->
insertAll
(
$log
))
{
Db
::
commit
();
$tag
=
true
;
}
else
{
...
...
app/index/controller/IndexController.php
查看文件 @
320f35e
...
...
@@ -42,11 +42,6 @@ class IndexController extends HomeBaseController
]);
}
//强制绑定手机页面
public
function
login
()
{
return
$this
->
fetch
();
}
/**
* 易连云打印机demo
*/
...
...
app/integral/controller/IntegralController.php
查看文件 @
320f35e
...
...
@@ -9,23 +9,29 @@
namespace
app\integral\controller
;
use
app\integral\model\IntegralModel
;
use
think\Db
;
use
cmf\controller\
Pay
BaseController
;
use
cmf\controller\
None
BaseController
;
class
IntegralController
extends
Pay
BaseController
class
IntegralController
extends
None
BaseController
{
public
function
autoExecute
()
{
$model
=
new
IntegralModel
;
$give
=
Db
::
name
(
'zj_integral_give'
)
->
where
([
'balance'
=>
[
'neq'
,
0
]])
->
field
(
'id,uid,balance,total,ratio'
)
->
select
();
foreach
(
$give
as
$item
)
{
$give_balance
=
(
int
)(
$item
[
'total'
]
*
$item
[
'ratio'
]
/
100
);
$remain_balance
=
$item
[
'balance'
]
-
$give_balance
;
if
(
$remain_balance
<
0
)
{
$give_balance
=
$remain_balance
;
$remain_balance
=
0
;
public
function
autoExecuteIntegral
()
{
$start
=
date
(
'23:57'
);
$end
=
date
(
'23:59'
);
$now
=
date
(
'H:i'
);
if
(
$now
>=
$start
&&
$now
<=
$end
)
{
$model
=
new
IntegralModel
;
$give
=
Db
::
name
(
'zj_integral_give'
)
->
where
([
'balance'
=>
[
'neq'
,
0
]])
->
field
(
'id,uid,balance,total,ratio'
)
->
select
();
foreach
(
$give
as
$item
)
{
$give_balance
=
(
int
)(
$item
[
'total'
]
*
$item
[
'ratio'
]
/
100
);
$remain_balance
=
$item
[
'balance'
]
-
$give_balance
;
if
(
$remain_balance
<
0
)
{
$give_balance
=
$remain_balance
;
$remain_balance
=
0
;
}
Db
::
name
(
'user'
)
->
where
([
'id'
=>
$item
[
'uid'
]])
->
setInc
(
'balance'
,
$give_balance
);
$model
->
insertIntegralLog
(
$item
[
'id'
],
$item
[
'uid'
],
time
(),
$give_balance
,
1
);
$model
->
updateIntegralGive
(
$item
[
'id'
],
$remain_balance
);
}
Db
::
name
(
'user'
)
->
where
([
'id'
=>
$item
[
'uid'
]])
->
setInc
(
'balance'
,
$give_balance
);
$model
->
insertIntegralLog
(
$item
[
'id'
],
$item
[
'uid'
],
time
(),
$give_balance
,
1
);
$model
->
updateIntegralGive
(
$item
[
'id'
],
$remain_balance
);
}
}
}
\ No newline at end of file
...
...
app/login/controller/LoginController.php
0 → 100644
查看文件 @
320f35e
<?php
/**
* Created by PhpStorm.
* User: yhbr
* Date: 2018/11/10
* Time: 9:50
*/
namespace
app\login\controller
;
use
cmf\controller\NoneBaseController
;
class
LoginController
extends
NoneBaseController
{
//强制绑定手机页面
public
function
login
()
{
return
$this
->
fetch
();
}
}
\ No newline at end of file
...
...
app/sms/controller/SmsController.php
查看文件 @
320f35e
...
...
@@ -7,10 +7,10 @@
*/
namespace
app\sms\controller
;
use
cmf\controller\
Hom
eBaseController
;
use
cmf\controller\
Non
eBaseController
;
use
think\Db
;
class
SmsController
extends
Hom
eBaseController
class
SmsController
extends
Non
eBaseController
{
public
function
sendSms
()
{
...
...
@@ -34,20 +34,52 @@ class SmsController extends HomeBaseController
}
}
//单纯发送验证码
public
function
checkCode
()
{
$mobile
=
request
()
->
param
(
'mobile'
);
$code
=
request
()
->
param
(
'code'
);
$data
=
Db
::
name
(
'zj_code'
)
->
field
(
'mobile,code,expire_time'
)
->
where
([
'mobile'
=>
$mobile
])
->
find
();
if
(
time
()
>
$data
[
'expire_time'
])
{
$this
->
success
(
'验证码已过期,请重新发送'
,
''
,
false
);
if
(
!
empty
(
$data
))
{
if
(
time
()
>
$data
[
'expire_time'
])
{
$this
->
success
(
'验证码已过期,请重新发送'
,
''
,
false
);
}
else
{
if
(
$code
==
$data
[
'code'
]
&&
$code
!=
null
&&
$data
[
'code'
]
!=
null
&&
$mobile
==
$data
[
'mobile'
])
{
Db
::
name
(
'zj_code'
)
->
where
([
'mobile'
=>
$mobile
])
->
update
([
'code'
=>
''
]);
$this
->
success
(
'身份信息核实成功'
,
url
(
''
),
true
);
}
else
{
$this
->
success
(
'验证码有误'
,
''
,
false
);
}
}
}
else
{
if
(
$code
==
$data
[
'code'
]
&&
$code
!=
null
&&
$data
[
'code'
]
!=
null
&&
$mobile
==
$data
[
'mobile'
])
{
Db
::
name
(
'zj_code'
)
->
where
([
'mobile'
=>
$mobile
])
->
update
([
'code'
=>
''
]);
$this
->
success
(
'身份信息核实成功'
,
url
(
''
),
true
);
$this
->
success
(
'验证码有误'
,
''
,
false
);
}
}
//修改密码、个人信息时的校验(必须验证输入手机号和原绑定手机号一致)
public
function
checkCodeS
()
{
$mobile
=
request
()
->
param
(
'mobile'
);
$code
=
request
()
->
param
(
'code'
);
$data
=
Db
::
name
(
'zj_code'
)
->
field
(
'mobile,code,expire_time'
)
->
where
([
'mobile'
=>
$mobile
])
->
find
();
$mobile
=
DB
::
name
(
'user'
)
->
where
([
'id'
=>
session
(
'user.id'
)])
->
value
(
'mobile'
);
if
(
!
empty
(
$data
))
{
if
(
$mobile
==
$data
[
'mobile'
])
{
if
(
time
()
>
$data
[
'expire_time'
])
{
$this
->
success
(
'验证码已过期,请重新发送'
,
''
,
false
);
}
else
{
if
(
$code
==
$data
[
'code'
]
&&
$code
!=
null
&&
$data
[
'code'
]
!=
null
&&
$mobile
==
$data
[
'mobile'
])
{
Db
::
name
(
'zj_code'
)
->
where
([
'mobile'
=>
$mobile
])
->
update
([
'code'
=>
''
]);
$this
->
success
(
'身份信息核实成功'
,
url
(
''
),
true
);
}
else
{
$this
->
success
(
'验证码有误'
,
''
,
false
);
}
}
}
else
{
$this
->
success
(
'
验证码有误
'
,
''
,
false
);
$this
->
success
(
'
请输入原始绑定手机号码
'
,
''
,
false
);
}
}
else
{
$this
->
success
(
'验证码有误'
,
''
,
false
);
}
}
...
...
@@ -56,16 +88,20 @@ class SmsController extends HomeBaseController
$mobile
=
request
()
->
param
(
'mobile'
);
$code
=
request
()
->
param
(
'code'
);
$data
=
Db
::
name
(
'zj_code'
)
->
field
(
'mobile,code,expire_time'
)
->
where
([
'mobile'
=>
$mobile
])
->
find
();
if
(
time
()
>
$data
[
'expire_time'
])
{
$this
->
success
(
'验证码已过期,请重新发送'
,
''
,
false
);
}
else
{
if
(
$code
==
$data
[
'code'
]
&&
$code
!=
null
&&
$data
[
'code'
]
!=
null
&&
$mobile
==
$data
[
'mobile'
])
{
Db
::
name
(
'zj_code'
)
->
where
([
'mobile'
=>
$mobile
])
->
update
([
'code'
=>
''
]);
Db
::
name
(
'user'
)
->
update
([
'id'
=>
session
(
'user.id'
),
'mobile'
=>
$mobile
]);
$this
->
success
(
'绑定成功'
,
url
(
''
),
true
);
if
(
!
empty
(
$data
))
{
if
(
time
()
>
$data
[
'expire_time'
])
{
$this
->
success
(
'验证码已过期,请重新发送'
,
''
,
false
);
}
else
{
$this
->
success
(
'验证码有误'
,
''
,
false
);
if
(
$code
==
$data
[
'code'
]
&&
$code
!=
null
&&
$data
[
'code'
]
!=
null
&&
$mobile
==
$data
[
'mobile'
])
{
Db
::
name
(
'zj_code'
)
->
where
([
'mobile'
=>
$mobile
])
->
update
([
'code'
=>
''
]);
Db
::
name
(
'user'
)
->
update
([
'id'
=>
session
(
'user.id'
),
'mobile'
=>
$mobile
]);
$this
->
success
(
'绑定成功'
,
url
(
''
),
true
);
}
else
{
$this
->
success
(
'验证码有误'
,
''
,
false
);
}
}
}
else
{
$this
->
success
(
'验证码有误'
,
''
,
false
);
}
}
...
...
app/user/controller/AdminIndexController.php
查看文件 @
320f35e
...
...
@@ -56,9 +56,9 @@ class AdminIndexController extends AdminBaseController
*/
public
function
index
()
{
$where
=
[
'user_type'
=>
2
];
$where1
=
[];
$where3
=
[];
$where
=
[
'user_type'
=>
2
];
$where1
=
[];
$where3
=
[];
$param
=
request
()
->
param
();
...
...
@@ -67,28 +67,73 @@ class AdminIndexController extends AdminBaseController
$keyword
=
$param
[
'keyword'
];
$keywordComplex
[
'mobile|id'
]
=
$keyword
;
}
if
(
!
empty
(
$param
[
'start_time'
])){
$where
[
'create_time'
]
=
[
'egt'
,
strtotime
(
$param
[
'start_time'
])];
}
if
(
!
empty
(
$param
[
'end_time'
])){
$where1
[
'create_time'
]
=
[
'elt'
,
strtotime
(
$param
[
'end_time'
])];
if
(
!
empty
(
$param
[
'start_time'
]))
{
$where
[
'create_time'
]
=
[
'egt'
,
strtotime
(
$param
[
'start_time'
])];
}
if
(
!
empty
(
$param
[
'end_time'
]))
{
$where1
[
'create_time'
]
=
[
'elt'
,
strtotime
(
$param
[
'end_time'
])];
}
if
(
!
empty
(
$param
[
'min'
])){
$where
[
'balance'
]
=
[
'egt'
,
$param
[
'min'
]];
if
(
!
empty
(
$param
[
'min'
]))
{
$where
[
'balance'
]
=
[
'egt'
,
$param
[
'min'
]];
}
if
(
!
empty
(
$param
[
'max'
])){
$where1
[
'balance'
]
=
[
'elt'
,
$param
[
'max'
]];
if
(
!
empty
(
$param
[
'max'
]))
{
$where1
[
'balance'
]
=
[
'elt'
,
$param
[
'max'
]];
}
$uid
=
(
isset
(
$param
[
'uid'
]))
?
$param
[
'uid'
]
:
null
;
//下级人员
if
(
$uid
)
{
if
(
$uid
)
{
$where3
[
'parent_id'
]
=
[
'eq'
,
$uid
];
}
$usersQuery
=
Db
::
name
(
'user'
);
$list
=
$usersQuery
->
whereOr
(
$keywordComplex
)
->
where
(
$where
)
->
where
(
$where1
)
->
where
(
$where3
)
->
order
(
"create_time DESC"
)
->
paginate
(
10
);
//获取订单数和会员专区金额统计
foreach
(
$list
as
$k
=>
$item
)
{
$uid
=
$item
[
'id'
];
$role
=
$item
[
'role'
];
//如果此人为普通会员,只统计其金额总和
if
(
$role
==
1
)
{
$map
=
[
'uid'
=>
[
'eq'
,
$item
[
'id'
]],
'pay_type'
=>
[
'eq'
,
3
],
'step'
=>
[
'neq'
,
1
]
];
$data
=
Db
::
name
(
'zj_order'
)
->
where
(
$map
)
->
field
(
'sum(whole) as whole,sum(whole_num) as whole_num'
)
->
select
();
$whole
=
$data
[
0
][
'whole'
];
$whole_num
=
$data
[
0
][
'whole_num'
];
$total
=
$whole
-
$whole_num
;
}
else
{
//先查此人的下级
$son_arr
=
Db
::
name
(
'user'
)
->
where
([
'parent_id'
=>
$item
[
'id'
]])
->
field
(
'id'
)
->
select
()
->
toArray
();
if
(
!
empty
(
$son_arr
))
{
$son_str
=
''
;
foreach
(
$son_arr
as
$key
=>
$v
)
{
if
(
$key
==
count
(
$son_arr
)
-
1
)
{
$son_str
.=
$v
[
'id'
];
}
else
{
$son_str
.=
$v
[
'id'
]
.
','
;
}
}
$map
=
[
'uid'
=>
[
'in'
,
$son_str
],
'pay_type'
=>
[
'eq'
,
3
],
'step'
=>
[
'neq'
,
1
]
];
$data
=
Db
::
name
(
'zj_order'
)
->
where
(
$map
)
->
field
(
'sum(whole) as whole,sum(whole_num) as whole_num'
)
->
select
();
$whole
=
$data
[
0
][
'whole'
];
$whole_num
=
$data
[
0
][
'whole_num'
];
$total
=
$whole
-
$whole_num
;
}
else
{
$total
=
0
;
}
}
$item
[
'total'
]
=
$total
;
$list
[
$k
]
=
$item
;
}
// 获取分页显示
$list
->
appends
(
$param
);
$this
->
assign
(
'start_time'
,
isset
(
$param
[
'start_time'
])
?
$param
[
'start_time'
]
:
''
);
...
...
@@ -158,12 +203,13 @@ class AdminIndexController extends AdminBaseController
/**
* 用户积分详情
*/
public
function
balance
(){
if
(
$this
->
request
->
param
()){
$id
=
input
(
'param.id'
);
$all
=
Db
::
name
(
'zj_integral_log'
)
->
where
(
'uid'
,
$id
)
->
paginate
(
20
);
$this
->
assign
(
'list'
,
$all
);
$this
->
assign
(
'page'
,
$all
->
render
());
public
function
balance
()
{
if
(
$this
->
request
->
param
())
{
$id
=
input
(
'param.id'
);
$all
=
Db
::
name
(
'zj_integral_log'
)
->
where
(
'uid'
,
$id
)
->
paginate
(
20
);
$this
->
assign
(
'list'
,
$all
);
$this
->
assign
(
'page'
,
$all
->
render
());
return
$this
->
fetch
();
}
}
...
...
app/user/controller/CenterController.php
查看文件 @
320f35e
...
...
@@ -380,10 +380,13 @@ class CenterController extends HomeBaseController
$type
=
request
()
->
param
(
'type'
);
if
(
$type
==
1
)
{
$title
=
'积分获取记录'
;
$where
[
'type'
]
=
[
'in'
,
"1,3"
];
}
else
{
$title
=
'积分使用记录'
;
$where
[
'type'
]
=
[
'in'
,
"2,4"
];
}
$log
=
Db
::
name
(
'zj_integral_log'
)
->
where
([
'uid'
=>
session
(
'user.id'
),
'type'
=>
$type
])
->
order
(
'create_time DESC'
)
->
select
();
$where
[
'uid'
]
=
[
'eq'
,
session
(
'user.id'
)];
$log
=
Db
::
name
(
'zj_integral_log'
)
->
where
(
$where
)
->
order
(
'create_time DESC'
)
->
select
();
return
$this
->
fetch
(
'integral_log'
,
[
'log'
=>
$log
,
'title'
=>
$title
...
...
public/themes/admin_simpleboot3/user/admin_index/index.html
查看文件 @
320f35e
...
...
@@ -36,6 +36,7 @@
<th>
下单量
</th>
<th
style=
"width:160px"
>
{:lang('REGISTRATION_TIME')}
</th>
<th>
积分余额
</th>
<th>
会员专区金额统计
</th>
<th>
{:lang('STATUS')}
</th>
<th
style=
"width: 450px;"
>
{:lang('ACTIONS')}
</th>
</tr>
...
...
@@ -52,6 +53,7 @@
<td>
{$vo.order_count}
</td>
<td>
{:date('Y-m-d H:i:s',$vo['create_time'])}
</td>
<td>
{$vo.balance}
</td>
<td>
{$vo.total}
</td>
<td>
{$user_statuses[$vo['user_status']]}
</td>
<td>
<neq
name=
"vo.id"
value=
"1"
>
...
...
@@ -65,7 +67,9 @@
</empty>
<a
href=
"{:url('balance',array('id'=>$vo['id']))}"
>
查看积分详情
</a>
|
<a
href=
"{:url('admin/zj_order/index',array('uid'=>$vo.id))}"
>
查看用户订单
</a>
|
<if
condition=
"$vo.parent_id eq ''"
>
<a
href=
"{:url('admin/User/role', ['uid'=>$vo['id']])}"
>
变更角色
</a>
</if>
<if
condition=
"$vo['role'] eq '2'"
>
|
<a
href=
"{:url('user/adminIndex/index',['uid'=>$vo['id']])}"
>
查看下级人员
</a></if>
<else/>
<a
style=
"color: #ccc;"
>
{:lang('BLOCK_USER')}
</a>
...
...
public/themes/simpleboot3/friendship/password_manager.html
查看文件 @
320f35e
...
...
@@ -151,7 +151,7 @@
alert
(
'请输入验证码'
);
}
else
{
$
.
ajax
({
url
:
"{:url('sms/Sms/checkCode')}"
,
url
:
"{:url('sms/Sms/checkCode
S
')}"
,
data
:{
mobile
:
mobile
,
code
:
code
...
...
public/themes/simpleboot3/
index/index
/login.html → public/themes/simpleboot3/
login/login
/login.html
查看文件 @
320f35e
public/themes/simpleboot3/user/center/edit_phone.html
查看文件 @
320f35e
...
...
@@ -151,7 +151,7 @@
alert
(
'请输入验证码'
);
}
else
{
$
.
ajax
({
url
:
"{:url('sms/Sms/checkCode')}"
,
url
:
"{:url('sms/Sms/checkCode
S
')}"
,
data
:{
mobile
:
mobile
,
code
:
code
...
...
public/themes/simpleboot3/user/center/integral_log.html
查看文件 @
320f35e
...
...
@@ -41,13 +41,16 @@
<div
class=
"good_intergral"
>
<p
class=
"buy_good"
>
<if
condition=
"$vo['type'] eq '1'"
>
购买商品
获得
购买商品
收入
</if>
<if
condition=
"$vo['type'] eq '2'"
>
购买商品
消费
购买商品
支出
</if>
<if
condition=
"$vo['type'] eq '3'"
>
好友购买奖励
好友赠送收入
</if>
<if
condition=
"$vo['type'] eq '4'"
>
好友赠送支出
</if>
</p>
<p
class=
"good_date"
>
{$vo.create_time|date='Y-m-d', ###}
</p>
...
...
simplewind/cmf/controller/HomeBaseController.php
查看文件 @
320f35e
...
...
@@ -59,6 +59,10 @@ class HomeBaseController extends BaseController
}
}
}
}
else
{
if
(
Db
::
name
(
'user'
)
->
where
([
'id'
=>
session
(
'user.id'
)])
->
value
(
'mobile'
)
==
null
)
{
$this
->
redirect
(
url
(
'login/Login/login'
));
}
}
}
else
{
$this
->
error
(
'请从微信浏览器打开'
);
...
...
simplewind/cmf/controller/NoneBaseController.php
0 → 100644
查看文件 @
320f35e
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +---------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace
cmf\controller
;
use
app\user\model\UserModel
;
use
think\Db
;
use
app\admin\model\ThemeModel
;
use
think\View
;
class
NoneBaseController
extends
BaseController
{
public
function
_initialize
()
{
parent
::
_initialize
();
// TODO: Change the autogenerated stub
// 监听home_init
hook
(
'home_init'
);
parent
::
_initialize
();
$siteInfo
=
cmf_get_site_info
();
View
::
share
(
'site_info'
,
$siteInfo
);
}
public
function
_initializeView
()
{
$cmfThemePath
=
config
(
'cmf_theme_path'
);
$cmfDefaultTheme
=
cmf_get_current_theme
();
$themePath
=
"
{
$cmfThemePath
}{
$cmfDefaultTheme
}
"
;
$root
=
cmf_get_root
();
//使cdn设置生效
$cdnSettings
=
cmf_get_option
(
'cdn_settings'
);
if
(
empty
(
$cdnSettings
[
'cdn_static_root'
]))
{
$viewReplaceStr
=
[
'__ROOT__'
=>
$root
,
'__TMPL__'
=>
"
{
$root
}
/
{
$themePath
}
"
,
'__STATIC__'
=>
"
{
$root
}
/static"
,
'__WEB_ROOT__'
=>
$root
];
}
else
{
$cdnStaticRoot
=
rtrim
(
$cdnSettings
[
'cdn_static_root'
],
'/'
);
$viewReplaceStr
=
[
'__ROOT__'
=>
$root
,
'__TMPL__'
=>
"
{
$cdnStaticRoot
}
/
{
$themePath
}
"
,
'__STATIC__'
=>
"
{
$cdnStaticRoot
}
/static"
,
'__WEB_ROOT__'
=>
$cdnStaticRoot
];
}
$viewReplaceStr
=
array_merge
(
config
(
'view_replace_str'
),
$viewReplaceStr
);
config
(
'template.view_base'
,
"
{
$themePath
}
/"
);
config
(
'view_replace_str'
,
$viewReplaceStr
);
$themeErrorTmpl
=
"
{
$themePath
}
/error.html"
;
if
(
file_exists_case
(
$themeErrorTmpl
))
{
config
(
'dispatch_error_tmpl'
,
$themeErrorTmpl
);
}
$themeSuccessTmpl
=
"
{
$themePath
}
/success.html"
;
if
(
file_exists_case
(
$themeSuccessTmpl
))
{
config
(
'dispatch_success_tmpl'
,
$themeSuccessTmpl
);
}
}
/**
* 加载模板输出
* @access protected
* @param string $template 模板文件名
* @param array $vars 模板输出变量
* @param array $replace 模板替换
* @param array $config 模板参数
* @return mixed
*/
protected
function
fetch
(
$template
=
''
,
$vars
=
[],
$replace
=
[],
$config
=
[])
{
$template
=
$this
->
parseTemplate
(
$template
);
$more
=
$this
->
getThemeFileMore
(
$template
);
$this
->
assign
(
'theme_vars'
,
$more
[
'vars'
]);
$this
->
assign
(
'theme_widgets'
,
$more
[
'widgets'
]);
return
parent
::
fetch
(
$template
,
$vars
,
$replace
,
$config
);
}
/**
* 自动定位模板文件
* @access private
* @param string $template 模板文件规则
* @return string
*/
private
function
parseTemplate
(
$template
)
{
// 分析模板文件规则
$request
=
$this
->
request
;
// 获取视图根目录
if
(
strpos
(
$template
,
'@'
))
{
// 跨模块调用
list
(
$module
,
$template
)
=
explode
(
'@'
,
$template
);
}
$viewBase
=
config
(
'template.view_base'
);
if
(
$viewBase
)
{
// 基础视图目录
$module
=
isset
(
$module
)
?
$module
:
$request
->
module
();
$path
=
$viewBase
.
(
$module
?
$module
.
DS
:
''
);
}
else
{
$path
=
isset
(
$module
)
?
APP_PATH
.
$module
.
DS
.
'view'
.
DS
:
config
(
'template.view_path'
);
}
$depr
=
config
(
'template.view_depr'
);
if
(
0
!==
strpos
(
$template
,
'/'
))
{
$template
=
str_replace
([
'/'
,
':'
],
$depr
,
$template
);
$controller
=
cmf_parse_name
(
$request
->
controller
());
if
(
$controller
)
{
if
(
''
==
$template
)
{
// 如果模板文件名为空 按照默认规则定位
$template
=
str_replace
(
'.'
,
DS
,
$controller
)
.
$depr
.
$request
->
action
();
}
elseif
(
false
===
strpos
(
$template
,
$depr
))
{
$template
=
str_replace
(
'.'
,
DS
,
$controller
)
.
$depr
.
$template
;
}
}
}
else
{
$template
=
str_replace
([
'/'
,
':'
],
$depr
,
substr
(
$template
,
1
));
}
return
$path
.
ltrim
(
$template
,
'/'
)
.
'.'
.
ltrim
(
config
(
'template.view_suffix'
),
'.'
);
}
/**
* 获取模板文件变量
* @param string $file
* @param string $theme
* @return array
*/
private
function
getThemeFileMore
(
$file
,
$theme
=
""
)
{
//TODO 增加缓存
$theme
=
empty
(
$theme
)
?
cmf_get_current_theme
()
:
$theme
;
// 调试模式下自动更新模板
if
(
APP_DEBUG
)
{
$themeModel
=
new
ThemeModel
();
$themeModel
->
updateTheme
(
$theme
);
}
$themePath
=
config
(
'cmf_theme_path'
);
$file
=
str_replace
(
'\\'
,
'/'
,
$file
);
$file
=
str_replace
(
'//'
,
'/'
,
$file
);
$file
=
str_replace
([
'.html'
,
'.php'
,
$themePath
.
$theme
.
"/"
],
''
,
$file
);
$files
=
Db
::
name
(
'theme_file'
)
->
field
(
'more'
)
->
where
([
'theme'
=>
$theme
])
->
where
(
function
(
$query
)
use
(
$file
)
{
$query
->
where
([
'is_public'
=>
1
])
->
whereOr
([
'file'
=>
$file
]);
})
->
select
();
$vars
=
[];
$widgets
=
[];
foreach
(
$files
as
$file
)
{
$oldMore
=
json_decode
(
$file
[
'more'
],
true
);
if
(
!
empty
(
$oldMore
[
'vars'
]))
{
foreach
(
$oldMore
[
'vars'
]
as
$varName
=>
$var
)
{
$vars
[
$varName
]
=
$var
[
'value'
];
}
}
if
(
!
empty
(
$oldMore
[
'widgets'
]))
{
foreach
(
$oldMore
[
'widgets'
]
as
$widgetName
=>
$widget
)
{
$widgetVars
=
[];
if
(
!
empty
(
$widget
[
'vars'
]))
{
foreach
(
$widget
[
'vars'
]
as
$varName
=>
$var
)
{
$widgetVars
[
$varName
]
=
$var
[
'value'
];
}
}
$widget
[
'vars'
]
=
$widgetVars
;
$widgets
[
$widgetName
]
=
$widget
;
}
}
}
return
[
'vars'
=>
$vars
,
'widgets'
=>
$widgets
];
}
public
function
checkUserLogin
()
{
$userId
=
cmf_get_current_user_id
();
if
(
empty
(
$userId
))
{
$this
->
error
(
"用户尚未登录"
,
url
(
"user/login/index"
));
}
}
}
\ No newline at end of file
...
...
simplewind/vendor/weiwei/api-doc/src/Doc.php
查看文件 @
320f35e
...
...
@@ -8,7 +8,7 @@ class Doc
'version'
=>
'1.0.0'
,
'copyright'
=>
'银河百荣科技'
,
'controller'
=>
[
'api\\
index
\\controller\\IndexController'
'api\\
home
\\controller\\IndexController'
],
'password'
=>
'bronet'
,
'static_path'
=>
''
,
...
...
请
注册
或
登录
后发表评论