Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zuiketang
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
zuiketang
Commits
7e920324
Commit
7e920324
authored
Oct 09, 2016
by
xiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加公共的全局文件
parent
1f3f14a6
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
118 additions
and
31 deletions
+118
-31
Utils.php
src/common/libs/Utils.php
+26
-0
UserCenterController.php
src/frontend/controllers/UserCenterController.php
+20
-13
info.php
src/frontend/views/user-center/info.php
+20
-7
global.js
src/frontend/web/js/libs/global.js
+12
-0
info.js
src/frontend/web/js/user-center/info.js
+37
-10
webpack.config.js
src/frontend/web/webpack.config.js
+1
-1
课程审核.html
ui/html/课程审核.html
+2
-0
No files found.
src/common/libs/Utils.php
View file @
7e920324
...
@@ -84,4 +84,30 @@ class Utils
...
@@ -84,4 +84,30 @@ class Utils
}
}
}
}
/**
* 获取中英文混合总字数
* @param $str
* @return int
*/
public
static
function
getStringLen
(
$str
)
{
$count
=
0
;
for
(
$i
=
0
;
$i
<
strlen
(
$str
);
$i
++
)
{
$value
=
ord
(
$str
[
$i
]);
if
(
$value
>
127
)
{
$count
++
;
if
(
$value
>=
192
&&
$value
<=
223
)
{
$i
++
;
}
elseif
(
$value
>=
224
&&
$value
<=
239
)
{
$i
=
$i
+
2
;
}
elseif
(
$value
>=
240
&&
$value
<=
247
)
{
$i
=
$i
+
3
;
}
}
$count
++
;
}
return
$count
;
}
}
}
\ No newline at end of file
src/frontend/controllers/UserCenterController.php
View file @
7e920324
...
@@ -24,6 +24,8 @@ use Yii;
...
@@ -24,6 +24,8 @@ use Yii;
class
UserCenterController
extends
Controller
class
UserCenterController
extends
Controller
{
{
public
$layout
=
'user-center'
;
public
$defaultAction
=
'info'
;
public
$defaultAction
=
'info'
;
/**
/**
...
@@ -59,12 +61,10 @@ class UserCenterController extends Controller
...
@@ -59,12 +61,10 @@ class UserCenterController extends Controller
{
{
$qiniu
=
Yii
::
$app
->
qiniu
;
$qiniu
=
Yii
::
$app
->
qiniu
;
$returnBody
=
'{"key":"$(key)"}'
;
//图片上传Token
//图片上传Token
//$imgName = 'preview/'.$qiniu->genRandomDir().'/'.Yii::$app->security->generateRandomString(20);
$imgPath
=
'avatar/'
.
$qiniu
->
generateRandomFilePath
(
'$(ext)'
,
10
);
$imgPath
=
'avatar/'
.
$qiniu
->
generateRandomFilePath
(
'$(ext)'
,
10
);
$publicToken
=
$qiniu
->
getUploadToken
(
'public'
,
$imgPath
,
$returnBody
);
$publicToken
=
$qiniu
->
getUploadToken
(
'public'
,
$imgPath
);
return
$this
->
render
(
'info'
,
compact
(
'publicToken'
));
return
$this
->
render
(
'info'
,
compact
(
'publicToken'
));
}
}
...
@@ -102,24 +102,31 @@ class UserCenterController extends Controller
...
@@ -102,24 +102,31 @@ class UserCenterController extends Controller
return
$this
->
render
(
'browse_record'
);
return
$this
->
render
(
'browse_record'
);
}
}
//fe7e7ff7-ef6d-45da-a6f5-ec93792101b4
/**
/**
* 设置头像信息
* 保存用户信息
* @param $key
* @throws \yii\web\ForbiddenHttpException
* @throws \yii\web\ForbiddenHttpException
*/
*/
public
function
actionS
etVatarInfo
(
$key
)
public
function
actionS
aveUserInfo
(
)
{
{
$requst
=
Yii
::
$app
->
request
;
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
$user
=
Yii
::
$app
->
user
->
identity
;
$username
=
$requst
->
post
(
'username'
);
$user
->
avatar
=
$key
;
$avatar
=
$requst
->
post
(
'avatar'
);
$user
->
save
();
$status
=
TRUE
;
Utils
::
ajaxResponse
();
$msg
=
""
;
if
(
Utils
::
getStringLen
(
$username
)
>
20
)
{
$status
=
FALSE
;
$msg
=
'昵称超过长度限制'
;
}
else
{
}
Utils
::
ajaxResponse
(
$status
,
$msg
);
}
else
{
}
else
{
throw
new
\yii\web\ForbiddenHttpException
(
'非法请求'
);
throw
new
\yii\web\ForbiddenHttpException
(
'非法请求'
);
}
}
}
}
}
}
\ No newline at end of file
src/frontend/views/user-center/info.php
View file @
7e920324
...
@@ -9,13 +9,26 @@
...
@@ -9,13 +9,26 @@
$url
=
Yii
::
$app
->
qiniu
->
storages
[
'public'
][
'url'
];
$url
=
Yii
::
$app
->
qiniu
->
storages
[
'public'
][
'url'
];
?>
?>
<h1>
user-center/info
</h1>
<div
class=
"add-box"
>
<div
class=
"add-box-main"
>
<div
class=
"tit"
>
基本信息
</div>
<div
id=
"avatar-uploader-container"
><img
id=
"avatar-uploader"
token=
"
<?=
$publicToken
?>
"
<div
class=
"upload-avatar"
>
src=
"
<?php
echo
Yii
::
$app
->
user
->
identity
->
avatar
===
''
?
\frontend\assets\AppAsset
::
getStaticUrl
(
'img/avatar.jpg'
)
:
$url
.
Yii
::
$app
->
user
->
identity
->
avatar
?>
"
>
<img
id=
"avatar-uploader"
token=
"
<?=
$publicToken
?>
"
src=
"
<?php
echo
\yii\bootstrap\Html
::
encode
(
Yii
::
$app
->
user
->
identity
->
avatar
===
''
?
\frontend\assets\AppAsset
::
getStaticUrl
(
'img/avatar.jpg'
)
:
$url
.
Yii
::
$app
->
user
->
identity
->
avatar
)
?>
"
>
<input
id=
"avatar"
type=
"hidden"
value=
"
<?=
\yii\bootstrap\Html
::
encode
(
Yii
::
$app
->
user
->
identity
->
avatar
)
?>
"
>
</div>
<div
class=
"type-name"
>
<input
id=
"username"
type=
"text"
value=
"
<?=
\yii\bootstrap\Html
::
encode
(
Yii
::
$app
->
user
->
identity
->
username
)
?>
"
placeholder=
"请输入您的昵称..."
>
</div>
<div
class=
"btn-box m-t-20"
>
<button
id=
"cancel"
class=
"btn btn-nobg"
>
取消
</button>
<button
id=
"save"
class=
"btn btn-save m-l-10"
>
保存
</button>
</div>
</div>
</div>
</div>
<p>
You may change the content of this page by modifying
the file
<code>
<?=
__FILE__
;
?>
</code>
.
</p>
\ No newline at end of file
src/frontend/web/js/libs/global.js
0 → 100644
View file @
7e920324
/**
* Created by xiabin on 2016/10/9.
*/
//yii2框架开启csrf后post请求需要添加
$
.
ajaxSetup
({
beforeSend
:
function
()
{
if
(
this
.
type
==
"POST"
)
{
this
.
data
+=
"&_csrf-frontend="
+
encodeURIComponent
(
$
(
"meta[name='csrf-token']"
).
attr
(
"content"
));
}
}
});
\ No newline at end of file
src/frontend/web/js/user-center/info.js
View file @
7e920324
/**
/**
* Created by xiabin on 2016/9/29.
* Created by xiabin on 2016/9/29.
*/
*/
layer
.
msg
(
'玩命提示中'
);
var
token
=
$
(
'#avatar-uploader'
).
attr
(
'token'
);
require
.
ensure
(
'../libs/plupload/plupload.full.min.js'
,
function
()
{
require
.
ensure
(
'../libs/plupload/plupload.full.min.js'
,
function
()
{
require
(
'script!../libs/plupload/plupload.full.min.js'
);
require
(
'script!../libs/plupload/plupload.full.min.js'
);
var
token
=
$
(
'#avatar-uploader'
).
attr
(
'token'
);
var
uploader
=
new
plupload
.
Uploader
({
var
uploader
=
new
plupload
.
Uploader
({
runtimes
:
'html5,flash,html4'
,
runtimes
:
'html5,flash,html4'
,
browse_button
:
'avatar-uploader'
,
browse_button
:
'avatar-uploader'
,
...
@@ -62,14 +61,8 @@ require.ensure('../libs/plupload/plupload.full.min.js', function () {
...
@@ -62,14 +61,8 @@ require.ensure('../libs/plupload/plupload.full.min.js', function () {
// }
// }
// 查看简单反馈
// 查看简单反馈
var
res
=
JSON
.
parse
(
info
.
response
);
var
res
=
JSON
.
parse
(
info
.
response
);
var
url
=
__QINIU_URL__
+
res
.
key
;
$
(
'#avatar-uploader'
).
attr
(
'src'
,
url
);
$
.
getJSON
(
__BASE_URL__
+
'user-center/set-vatar-info?key='
+
res
.
key
,
function
(
reponse
)
{
$
(
'#avatar'
).
val
(
res
.
key
);
if
(
reponse
.
status
)
{
window
.
location
.
reload
();
}
}).
error
(
function
()
{
layer
.
alert
(
'设置头像信息接口错误'
,
{
'icon'
:
2
,
'title'
:
'提示'
});
});
},
},
'Error'
:
function
(
up
,
err
,
errTip
)
{
'Error'
:
function
(
up
,
err
,
errTip
)
{
//上传出错时,处理相关的事情
//上传出错时,处理相关的事情
...
@@ -82,4 +75,38 @@ require.ensure('../libs/plupload/plupload.full.min.js', function () {
...
@@ -82,4 +75,38 @@ require.ensure('../libs/plupload/plupload.full.min.js', function () {
uploader
.
init
()
uploader
.
init
()
});
});
$
(
"#cancel"
).
click
(
function
()
{
window
.
location
.
reload
();
});
var
oldAvatar
=
$
(
'#avatar'
).
val
();
var
oldUsername
=
$
(
"#username"
).
val
();
$
(
"#save"
).
click
(
function
()
{
var
avatar
=
$
(
'#avatar'
).
val
();
var
username
=
$
(
"#username"
).
val
();
if
(
avatar
===
oldAvatar
&&
username
===
oldUsername
)
{
return
false
;
}
var
url
=
__BASE_URL__
+
'user-center/save-user-info'
;
console
.
log
(
avatar
);
console
.
log
(
username
);
var
dataObj
=
{
avatar
:
avatar
,
username
:
username
};
$
.
ajax
({
type
:
"POST"
,
url
:
url
,
data
:
dataObj
,
dataType
:
'json'
,
success
:
function
(
reponse
)
{
if
(
!
reponse
.
status
===
true
)
{
layer
.
alert
(
reponse
.
message
||
'系统错误'
,
{
icon
:
2
,
title
:
"提示"
})
}
}
}).
error
(
function
()
{
layer
.
alert
(
'保存用户信息接口错误'
,
{
'icon'
:
2
,
'title'
:
'提示'
});
})
});
src/frontend/web/webpack.config.js
View file @
7e920324
...
@@ -9,7 +9,7 @@ var CopyWebpackPlugin = require('copy-webpack-plugin');
...
@@ -9,7 +9,7 @@ var CopyWebpackPlugin = require('copy-webpack-plugin');
var
ExtractTextPlugin
=
require
(
"extract-text-webpack-plugin"
);
var
ExtractTextPlugin
=
require
(
"extract-text-webpack-plugin"
);
var
entry
=
{
var
entry
=
{
vendor
:
[
"jquery"
,
"vue"
,
js_dir
+
"/utils/layer"
],
vendor
:
[
"jquery"
,
"vue"
,
js_dir
+
"/utils/layer"
,
js_dir
+
"/libs/global.js"
],
login_css
:
[
css_dir
+
'/login.css'
],
login_css
:
[
css_dir
+
'/login.css'
],
style
:
[
css_dir
+
'/reset.css'
,
css_dir
+
'/style.css'
],
style
:
[
css_dir
+
'/reset.css'
,
css_dir
+
'/style.css'
],
signup
:
[
js_dir
+
'/site/signup.js'
],
signup
:
[
js_dir
+
'/site/signup.js'
],
...
...
ui/html/课程审核.html
View file @
7e920324
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
<div
class=
"tp-sidebar"
>
<div
class=
"tp-sidebar"
>
<div
class=
"logo"
><a
href=
"#"
><img
src=
"img/logo.png"
></a></div>
<div
class=
"logo"
><a
href=
"#"
><img
src=
"img/logo.png"
></a></div>
<div
class=
"side-menu"
>
<div
class=
"side-menu"
>
<!-- Contenedor -->
<!-- Contenedor -->
<ul
id=
"accordion"
class=
"accordion"
>
<ul
id=
"accordion"
class=
"accordion"
>
...
@@ -47,6 +48,7 @@
...
@@ -47,6 +48,7 @@
</li>
</li>
</ul>
</ul>
</div>
</div>
</div>
</div>
<div
class=
"auto-main"
>
<div
class=
"auto-main"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment