Commit 0f854804 authored by Administrator's avatar Administrator

微信用户

parent 1f10e656
Pipeline #108 canceled with stages
...@@ -30,8 +30,27 @@ class WxuserController extends Controller ...@@ -30,8 +30,27 @@ class WxuserController extends Controller
if($pagenNum === '' || $limit == ''){ if($pagenNum === '' || $limit == ''){
return $this->jsonErrorData(105,'页数或limit不能为空'); return $this->jsonErrorData(105,'页数或limit不能为空');
} }
$cont = WxUser::count(); $where = [];
$keys = $request->all();
if(isset($keys['sex'])) {
$keys['sex'] = $keys['sex'] == 3 ? 0 : $keys['sex'];
$where[] = ['sex', '=', $keys['sex']];
}
if(isset($keys['state'])) {
$where[] = ['state', '=', $keys['state']];
}
if(isset($keys['mobile'])) {
$where[] = ['mobile', 'like', "%$keys[mobile]%"];
}
$city = '';
if(isset($keys['city'])) {
$city = $keys['city'];
}
$cont = WxUser::where($where)
->whereRaw("concat(country, province, city) like '%{$city}%'")->count();
$Wxuser = WxUser::select('nickname','id','openid','sex','province','city','mobile','country','headimgurl','created_at','state') $Wxuser = WxUser::select('nickname','id','openid','sex','province','city','mobile','country','headimgurl','created_at','state')
->where($where)
->whereRaw("concat(country, province, city) like '%{$city}%'")
->offset($pagenNum) ->offset($pagenNum)
->orderBy('id', 'desc') ->orderBy('id', 'desc')
->limit($limit) ->limit($limit)
...@@ -46,32 +65,30 @@ class WxuserController extends Controller ...@@ -46,32 +65,30 @@ class WxuserController extends Controller
//用户搜索 //用户搜索
public function seek (Request $request){ public function seek (Request $request){
$keys = $request->all(); $keys = $request->all();
foreach ($keys as $key => $val) { $where = [];
if ($key == 'page') {
unset($keys[$key]); if(isset($keys['sex'])) {
} elseif ($key == 'limit'){ $keys['sex'] = $keys['sex'] == 3 ? 0 : $keys['sex'];
unset($keys[$key]); $where[] = ['sex', '=', $keys['sex']];
}
} }
foreach ($keys as $k => $v) { if(isset($keys['state'])) {
if($k == 'sex'){ $where[] = ['state', '=', $keys['state']];
if ($v == '男'){
$v = 1;
}else if ($v == '女'){
$v =2;
}
}else if ($k == 'state'){
if ($v == '正常'){
$v = 2;
}else if ($v == '禁用'){
$v = 1;
}
}
$keys[$key] && DB::table('wx_user')->where($k, 'like', '%' . $v . '%');
} }
if(isset($keys['mobile'])) {
$datas = DB::table('wx_user')->get(); $where[] = ['mobile', 'like', "%$keys[mobile]%"];
$cont = DB::table('wx_user')->count(); }
$city = '';
if(isset($keys['city'])) {
$city = $keys['city'];
}
$datas = DB::table('wx_user')
->where($where)
->whereRaw("concat(country, province, city) like '%{$city}%'")
->limit($keys['limit'])
->offset($keys['limit'] * ($keys['page'] - 1))
->orderBy('id', 'DESC')
->get();
$cont = DB::table('wx_user')->where($where)->whereRaw("concat(country, province, city) like '%{$city}%'")->count();
$data = ['Wxuser'=>$datas,'cont'=>$cont]; $data = ['Wxuser'=>$datas,'cont'=>$cont];
return $this->jsonSuccessData($data); return $this->jsonSuccessData($data);
} }
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
<div class="app-container"> <div class="app-container">
<div class="filter-container"> <div class="filter-container">
<el-form ref="query" :model="query" style="display: inline-block;"> <el-form ref="query" :model="query" style="display: inline-block;">
<el-input v-model="query.nickname" placeholder="用户名称" style="width: 200px;" class="filter-item" name="userskk" /> <el-input v-model="query.mobile" placeholder="手机号" style="width: 200px;" class="filter-item" name="userskk" />
<el-input v-model="query.city" placeholder="地区" style="width: 200px;" class="filter-item" name="city" />
<el-select v-model="query.sex" placeholder="性别" clearable style="width: 90px" class="filter-item" @change="selectOneSex"> <el-select v-model="query.sex" placeholder="性别" clearable style="width: 90px" class="filter-item" @change="selectOneSex">
<el-option v-for="item in importanceOptions" :key="item" :label="item" :value="item" /> <el-option v-for="item in importanceOptions" :key="item.key" :label="item.val" :value="item.key" />
</el-select> </el-select>
<el-select v-model="query.state" placeholder="状态" clearable class="filter-item" style="width: 130px" @change="selectOneState"> <el-select v-model="query.state" placeholder="状态" clearable class="filter-item" style="width: 130px" @change="selectOneState">
<el-option v-for="item in calendarTypeOptions" :key="item" :label="item" :value="item" /> <el-option v-for="item in calendarTypeOptions" :key="item.key" :label="item.val" :value="item.key" />
</el-select> </el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleSubmit"> <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleSubmit">
{{ $t('table.search') }} {{ $t('table.search') }}
...@@ -25,19 +26,13 @@ ...@@ -25,19 +26,13 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="用户名称"> <el-table-column align="left" label="用户名称">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.nickname | handeNickname }}</span> <el-image :src="scope.row.headimgurl" :preview-src-list="srcList" style="width:50px"></el-image>
<a class="zl-nickname">{{ scope.row.nickname | handeNickname }}</a>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-if="showReviewer" align="center" label="openid" width="320">
<el-table-column align="center" label="用户头像" width="150">
<template slot-scope="scope">
<el-image :src="scope.row.headimgurl" :preview-src-list="srcList"></el-image>
</template>
</el-table-column>
<el-table-column v-if="showReviewer" align="center" label="openid" width="150">
<template slot-scope="scope"> <template slot-scope="scope">
<span style="color: #909399;" @click="handleCopy(scope.row.openid,$event)">{{ scope.row.openid }}</span> <span style="color: #909399;" @click="handleCopy(scope.row.openid,$event)">{{ scope.row.openid }}</span>
</template> </template>
...@@ -45,7 +40,7 @@ ...@@ -45,7 +40,7 @@
<el-table-column align="center" label="性别" width="150"> <el-table-column align="center" label="性别" width="150">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.sex==1 ? '男' : '女' }}</span> <span>{{ scope.row.sex | handeSex }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="手机号" width="200"> <el-table-column align="center" label="手机号" width="200">
...@@ -53,14 +48,14 @@ ...@@ -53,14 +48,14 @@
<span>{{ scope.row.mobile }}</span> <span>{{ scope.row.mobile }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="地区" width="170"> <el-table-column align="center" label="地区" width="220">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.country }}{{ scope.row.province }}{{ scope.row.city }}</span> <span>{{ scope.row.country }}{{ scope.row.province }}{{ scope.row.city }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="创建时间" width="170"> <el-table-column align="center" label="创建时间" width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.created_at | parseTime('{y}-{m}-{d} {h}:{i}') }}</span> <span>{{ scope.row.created_at | parseTime('{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="状态" width="170"> <el-table-column align="center" label="状态" width="170">
...@@ -89,6 +84,12 @@ export default { ...@@ -89,6 +84,12 @@ export default {
handeNickname: function(value) { handeNickname: function(value) {
return Base64.decode(value); return Base64.decode(value);
}, },
handeSex: function(value) {
const sexes = [
'未知', '男', '女',
];
return sexes[value];
},
}, },
data() { data() {
return { return {
...@@ -100,12 +101,28 @@ export default { ...@@ -100,12 +101,28 @@ export default {
query: { query: {
page: 1, page: 1,
limit: 10, limit: 10,
nickname: undefined, mobile: undefined,
sex: undefined, sex: undefined,
state: undefined, state: undefined,
city: undefined,
}, },
importanceOptions: ['男', '女'], importanceOptions: [{
calendarTypeOptions: ['正常', '禁用'], 'key': 0,
'val': '未知',
}, {
'key': 1,
'val': '男',
}, {
'key': 2,
'val': '女',
}],
calendarTypeOptions: [{
'key': 1,
'val': '禁用',
}, {
'key': 2,
'val': '启用',
}],
srcList: [], srcList: [],
downloadLoading: false, downloadLoading: false,
}; };
...@@ -151,7 +168,10 @@ export default { ...@@ -151,7 +168,10 @@ export default {
if (j === 'created_at') { if (j === 'created_at') {
return parseTime(v[j]); return parseTime(v[j]);
} else if (j === 'sex') { } else if (j === 'sex') {
return v[j] === 1 ? '男' : '女'; const sexes = [
'未知', '男', '女',
];
return sexes[v[j]];
} else { } else {
return v[j]; return v[j];
} }
...@@ -185,3 +205,10 @@ export default { ...@@ -185,3 +205,10 @@ export default {
}, },
}; };
</script> </script>
<style>
.zl-nickname{
position: absolute;
line-height: 50px;
margin-left: 10px;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment