作者 何书鹏
1 个管道 的构建 通过 耗费 1 秒

11

... ... @@ -37,4 +37,45 @@ class User extends Backend
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = false;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax())
{
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField'))
{
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->where($where)
->order($sort, $order)
->count();
$list = $this->model
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->select();
foreach ($list as $row) {
$row->visible(['id','openid','nickname','mobile','avatar','gender','score','logintime','createtime']);
}
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
return json($result);
}
return $this->view->fetch();
}
}
... ...
<?php
return [
'Id' => 'ID',
'Openid' => '微信openid',
'Nickname' => '昵称',
'Mobile' => '手机号',
'Avatar' => '头像',
'Gender' => '性别',
'Gender 0' => '未知',
'Gender 1' => '男',
'Gender 2' => '女',
'Province' => '所在省份',
'City' => '所在城市',
'District' => '所在区',
'Score' => '积分',
'Createtime' => '创建时间',
'Updatetime' => '更新时间'
'Id' => 'ID',
'Openid' => '微信openid',
'Nickname' => '昵称',
'Mobile' => '手机号',
'Avatar' => '头像',
'Gender' => '性别',
'Gender 0' => '未知',
'Gender 1' => '男',
'Gender 2' => '女',
'Province_id' => '所在省份',
'City_id' => '所在城市',
'District_id' => '所在区',
'Score' => '积分',
'Token' => 'Token',
'Status' => '状态',
'Successions' => '连续登录天数',
'Maxsuccessions' => '最大连续登录天数',
'Prevtime' => '上次登录时间',
'Logintime' => '登录时间',
'Loginip' => '登录IP',
'Loginfailure' => '失败次数',
'Joinip' => '加入IP',
'Jointime' => '加入时间',
'Createtime' => '创建时间',
'Updatetime' => '更新时间'
];
... ...
... ... @@ -25,7 +25,10 @@ class User extends Model
// 追加属性
protected $append = [
'gender_text'
'gender_text',
'prevtime_text',
'logintime_text',
'jointime_text'
];
... ... @@ -44,6 +47,40 @@ class User extends Model
}
public function getPrevtimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['prevtime']) ? $data['prevtime'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public function getLogintimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['logintime']) ? $data['logintime'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public function getJointimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['jointime']) ? $data['jointime'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
protected function setPrevtimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
protected function setLogintimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
protected function setJointimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
}
... ...
... ... @@ -45,21 +45,21 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Province')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Province_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-province" class="form-control" name="row[province]" type="text" value="">
<input id="c-province_id" data-rule="required" data-source="province/index" class="form-control selectpage" name="row[province_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('City')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('City_id')}:</label>
<div class="col-xs-12 col-sm-8">
<div class='control-relative'><input id="c-city" class="form-control" data-toggle="city-picker" name="row[city]" type="text" value=""></div>
<input id="c-city_id" data-rule="required" data-source="city/index" class="form-control selectpage" name="row[city_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('District')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('District_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-district" class="form-control" name="row[district]" type="text" value="">
<input id="c-district_id" data-rule="required" data-source="district/index" class="form-control selectpage" name="row[district_id]" type="text" value="">
</div>
</div>
<div class="form-group">
... ... @@ -68,6 +68,66 @@
<input id="c-score" data-rule="required" class="form-control" name="row[score]" type="number" value="0">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Token')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-token" data-rule="required" class="form-control" name="row[token]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-status" data-rule="required" class="form-control" name="row[status]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Successions')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-successions" data-rule="required" class="form-control" name="row[successions]" type="number" value="1">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Maxsuccessions')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-maxsuccessions" data-rule="required" class="form-control" name="row[maxsuccessions]" type="number" value="1">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Prevtime')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-prevtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[prevtime]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Logintime')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-logintime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[logintime]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Loginip')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-loginip" data-rule="required" class="form-control" name="row[loginip]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Loginfailure')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-loginfailure" data-rule="required" class="form-control" name="row[loginfailure]" type="number" value="0">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Joinip')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-joinip" data-rule="required" class="form-control" name="row[joinip]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Jointime')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-jointime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[jointime]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -45,21 +45,21 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Province')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('Province_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-province" class="form-control" name="row[province]" type="text" value="{$row.province|htmlentities}">
<input id="c-province_id" data-rule="required" data-source="province/index" class="form-control selectpage" name="row[province_id]" type="text" value="{$row.province_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('City')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('City_id')}:</label>
<div class="col-xs-12 col-sm-8">
<div class='control-relative'><input id="c-city" class="form-control" data-toggle="city-picker" name="row[city]" type="text" value="{$row.city|htmlentities}"></div>
<input id="c-city_id" data-rule="required" data-source="city/index" class="form-control selectpage" name="row[city_id]" type="text" value="{$row.city_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('District')}:</label>
<label class="control-label col-xs-12 col-sm-2">{:__('District_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-district" class="form-control" name="row[district]" type="text" value="{$row.district|htmlentities}">
<input id="c-district_id" data-rule="required" data-source="district/index" class="form-control selectpage" name="row[district_id]" type="text" value="{$row.district_id|htmlentities}">
</div>
</div>
<div class="form-group">
... ... @@ -68,6 +68,66 @@
<input id="c-score" data-rule="required" class="form-control" name="row[score]" type="number" value="{$row.score|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Token')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-token" data-rule="required" class="form-control" name="row[token]" type="text" value="{$row.token|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-status" data-rule="required" class="form-control" name="row[status]" type="text" value="{$row.status|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Successions')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-successions" data-rule="required" class="form-control" name="row[successions]" type="number" value="{$row.successions|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Maxsuccessions')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-maxsuccessions" data-rule="required" class="form-control" name="row[maxsuccessions]" type="number" value="{$row.maxsuccessions|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Prevtime')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-prevtime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[prevtime]" type="text" value="{:$row.prevtime?datetime($row.prevtime):''}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Logintime')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-logintime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[logintime]" type="text" value="{:$row.logintime?datetime($row.logintime):''}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Loginip')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-loginip" data-rule="required" class="form-control" name="row[loginip]" type="text" value="{$row.loginip|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Loginfailure')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-loginfailure" data-rule="required" class="form-control" name="row[loginfailure]" type="number" value="{$row.loginfailure|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Joinip')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-joinip" data-rule="required" class="form-control" name="row[joinip]" type="text" value="{$row.joinip|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Jointime')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-jointime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[jointime]" type="text" value="{:$row.jointime?datetime($row.jointime):''}">
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -7,6 +7,7 @@ use app\common\library\Sms;
use app\common\model\User as UserModel;
use app\common\model\UserAddress;
use app\common\model\UserSize;
use app\common\model\Area;
use app\common\controller\Wechat;
use think\Validate;
... ... @@ -97,11 +98,29 @@ class User extends Api
}
/**
* 我的-成为会员(会员介绍)
* @ApiMethod (GET)
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
})
*/
public function memberIntro()
{
$member_intro = str_replace('src="/uploads/', 'src="'.config('upload.cdnurl').'/uploads/', config('site.member_intro'));
$this->success(__('成功'),compact('member_intro'));
}
/**
* 我的-成为会员(绑定手机号)
* @ApiMethod (POST)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="mobile", type="string", required=true, description="手机号")
* @ApiParams (name="captcha", type="string", required=true, description="验证码")
* @ApiParams (name="area", type="string", required=true, description="所在地区", sample="广东省,广州市,海珠区")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
... ... @@ -114,21 +133,28 @@ class User extends Api
{
$mobile = $this->request->request('mobile');
$captcha = $this->request->request('captcha');
if (!$mobile || !$captcha) {
$area = $this->request->request('area');
if (!empty($this->user['mobile'])) {
$this->error(__('您已经成为会员,请勿重复操作'));
}
if (!$mobile || !$captcha || !$area) {
$this->error(__('Invalid parameters'));
}
if (!Validate::regex($mobile, "^1\d{10}$")) {
$this->error(__('Mobile is incorrect'));
}
if (\app\common\model\User::where('mobile', $mobile)->where('id', '<>', $this->user['id'])->find()) {
if (UserModel::where('mobile', $mobile)->where('id', '<>', $this->user['id'])->find()) {
$this->error(__('Mobile already exists'));
}
$result = Sms::check($mobile, $captcha, 'changemobile');
if (!$result) {
$this->error(__('Captcha is incorrect'));
}
$this->user->mobile = $mobile;
$this->user->save();
$area = explode(',', $area);
$province_id = Area::getIdByName($area[0], 1);
$city_id = Area::getIdByName($area[1], 2, $province_id);
$district_id = Area::getIdByName($area[2], 3, $city_id);
$this->user->allowField(true)->save(compact('mobile','province_id', 'city_id', 'district_id'));
Sms::flush($mobile, 'changemobile');
$this->success();
... ...
... ... @@ -56,4 +56,5 @@ return array (
收到商品损坏了
未按预定时间发货
其它原因',
'member_intro' => '<p><img src="http://www.silk.top/uploads/20200724/124840a14af5e41c8508aac71242fad5.gif" style="width: 499px;"><br></p><p>量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程</p>',
);
\ No newline at end of file
... ...
此 diff 太大无法显示。
... ... @@ -31,12 +31,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'mobile', title: __('Mobile')},
{field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'gender', title: __('Gender'), searchList: {"0":__('Gender 0'),"1":__('Gender 1'),"2":__('Gender 2')}, formatter: Table.api.formatter.normal},
{field: 'province', title: __('Province')},
{field: 'city', title: __('City')},
{field: 'district', title: __('District')},
{field: 'score', title: __('Score')},
{field: 'logintime', title: __('Logintime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
... ...