正在显示
7 个修改的文件
包含
40 行增加
和
3 行删除
@@ -64,8 +64,8 @@ class Order extends Backend | @@ -64,8 +64,8 @@ class Order extends Backend | ||
64 | ->select(); | 64 | ->select(); |
65 | 65 | ||
66 | foreach ($list as $row) { | 66 | foreach ($list as $row) { |
67 | - | ||
68 | $row->getRelation('user')->visible(['nickname','avatar']); | 67 | $row->getRelation('user')->visible(['nickname','avatar']); |
68 | + $row->user->nickname = \app\admin\model\User::emoji_decode($row->user->nickname); | ||
69 | } | 69 | } |
70 | $list = collection($list)->toArray(); | 70 | $list = collection($list)->toArray(); |
71 | $result = array("total" => $total, "rows" => $list); | 71 | $result = array("total" => $total, "rows" => $list); |
@@ -52,6 +52,7 @@ class User extends Backend | @@ -52,6 +52,7 @@ class User extends Backend | ||
52 | ->select(); | 52 | ->select(); |
53 | foreach ($list as $k => $v) { | 53 | foreach ($list as $k => $v) { |
54 | $v->hidden(['password', 'salt']); | 54 | $v->hidden(['password', 'salt']); |
55 | + $v->nickname = \app\admin\model\User::emoji_decode($v->nickname); | ||
55 | } | 56 | } |
56 | $result = array("total" => $total, "rows" => $list); | 57 | $result = array("total" => $total, "rows" => $list); |
57 | 58 |
@@ -191,6 +191,9 @@ trait Backend | @@ -191,6 +191,9 @@ trait Backend | ||
191 | } | 191 | } |
192 | $this->error(__('Parameter %s can not be empty', '')); | 192 | $this->error(__('Parameter %s can not be empty', '')); |
193 | } | 193 | } |
194 | + if(isset($row->nickname) && !empty($row->nickname)){ | ||
195 | + $row->nickname = \app\admin\model\User::emoji_decode($row->nickname); | ||
196 | + } | ||
194 | $this->view->assign("row", $row); | 197 | $this->view->assign("row", $row); |
195 | return $this->view->fetch(); | 198 | return $this->view->fetch(); |
196 | } | 199 | } |
@@ -101,4 +101,12 @@ class User extends Model | @@ -101,4 +101,12 @@ class User extends Model | ||
101 | return $this->belongsTo('UserGroup', 'group_id', 'id', [], 'LEFT')->setEagerlyType(0); | 101 | return $this->belongsTo('UserGroup', 'group_id', 'id', [], 'LEFT')->setEagerlyType(0); |
102 | } | 102 | } |
103 | 103 | ||
104 | + //字符转表情 | ||
105 | + public static function emoji_decode($str){ | ||
106 | + $strDecode = preg_replace_callback('|\[\[EMOJI:(.*?)\]\]|', function ($matches) { | ||
107 | + return rawurldecode($matches[1]); | ||
108 | + }, $str); | ||
109 | + return $strDecode; | ||
110 | + } | ||
111 | + | ||
104 | } | 112 | } |
@@ -143,8 +143,8 @@ | @@ -143,8 +143,8 @@ | ||
143 | <div class="form-group layer-footer"> | 143 | <div class="form-group layer-footer"> |
144 | <label class="control-label col-xs-12 col-sm-2"></label> | 144 | <label class="control-label col-xs-12 col-sm-2"></label> |
145 | <div class="col-xs-12 col-sm-8"> | 145 | <div class="col-xs-12 col-sm-8"> |
146 | - <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button> | ||
147 | - <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> | 146 | + <!--<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>--> |
147 | + <!--<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>--> | ||
148 | </div> | 148 | </div> |
149 | </div> | 149 | </div> |
150 | </form> | 150 | </form> |
@@ -76,6 +76,7 @@ class User extends Api | @@ -76,6 +76,7 @@ class User extends Api | ||
76 | $ret = $this->auth->login($result); | 76 | $ret = $this->auth->login($result); |
77 | if ($ret) { | 77 | if ($ret) { |
78 | $data = $this->auth->getUserinfo(); | 78 | $data = $this->auth->getUserinfo(); |
79 | + $data['nickname'] = $this->auth->emoji_decode($data['nickname']); | ||
79 | $this->success('登录成功', $data); | 80 | $this->success('登录成功', $data); |
80 | }else { | 81 | }else { |
81 | $this->error($this->auth->getError()); | 82 | $this->error($this->auth->getError()); |
@@ -215,6 +215,7 @@ class Auth | @@ -215,6 +215,7 @@ class Auth | ||
215 | 215 | ||
216 | $userModel = new \app\admin\model\User(); | 216 | $userModel = new \app\admin\model\User(); |
217 | $where = ['openid'=>$result['openid']]; | 217 | $where = ['openid'=>$result['openid']]; |
218 | + $result['nickname'] = $this->emoji_encode($result['nickname']); | ||
218 | $ret = $userModel->where($where)->find(); | 219 | $ret = $userModel->where($where)->find(); |
219 | if ($ret) { | 220 | if ($ret) { |
220 | $userModel->where($where)->update($result); | 221 | $userModel->where($where)->update($result); |
@@ -650,4 +651,27 @@ class Auth | @@ -650,4 +651,27 @@ class Auth | ||
650 | return $result; | 651 | return $result; |
651 | } | 652 | } |
652 | 653 | ||
654 | + //表情转字符 | ||
655 | + public function emoji_encode($str){ | ||
656 | + $strEncode = ''; | ||
657 | + $length = mb_strlen($str,'utf-8'); | ||
658 | + for ($i=0; $i < $length; $i++) { | ||
659 | + $_tmpStr = mb_substr($str,$i,1,'utf-8'); | ||
660 | + if(strlen($_tmpStr) >= 4){ | ||
661 | + $strEncode .= '[[EMOJI:'.rawurlencode($_tmpStr).']]'; | ||
662 | + }else{ | ||
663 | + $strEncode .= $_tmpStr; | ||
664 | + } | ||
665 | + } | ||
666 | + return $strEncode; | ||
667 | + } | ||
668 | + | ||
669 | + //字符转表情 | ||
670 | + public function emoji_decode($str){ | ||
671 | + $strDecode = preg_replace_callback('|\[\[EMOJI:(.*?)\]\]|', function ($matches) { | ||
672 | + return rawurldecode($matches[1]); | ||
673 | + }, $str); | ||
674 | + return $strDecode; | ||
675 | + } | ||
676 | + | ||
653 | } | 677 | } |
-
请 注册 或 登录 后发表评论