Commit 0f854804 authored by Administrator's avatar Administrator

微信用户

parent 1f10e656
Pipeline #108 canceled with stages
......@@ -30,8 +30,27 @@ class WxuserController extends Controller
if($pagenNum === '' || $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')
->where($where)
->whereRaw("concat(country, province, city) like '%{$city}%'")
->offset($pagenNum)
->orderBy('id', 'desc')
->limit($limit)
......@@ -46,32 +65,30 @@ class WxuserController extends Controller
//用户搜索
public function seek (Request $request){
$keys = $request->all();
foreach ($keys as $key => $val) {
if ($key == 'page') {
unset($keys[$key]);
} elseif ($key == 'limit'){
unset($keys[$key]);
}
}
foreach ($keys as $k => $v) {
if($k == 'sex'){
if ($v == '男'){
$v = 1;
}else if ($v == '女'){
$v =2;
$where = [];
if(isset($keys['sex'])) {
$keys['sex'] = $keys['sex'] == 3 ? 0 : $keys['sex'];
$where[] = ['sex', '=', $keys['sex']];
}
}else if ($k == 'state'){
if ($v == '正常'){
$v = 2;
}else if ($v == '禁用'){
$v = 1;
if(isset($keys['state'])) {
$where[] = ['state', '=', $keys['state']];
}
if(isset($keys['mobile'])) {
$where[] = ['mobile', 'like', "%$keys[mobile]%"];
}
$keys[$key] && DB::table('wx_user')->where($k, 'like', '%' . $v . '%');
$city = '';
if(isset($keys['city'])) {
$city = $keys['city'];
}
$datas = DB::table('wx_user')->get();
$cont = DB::table('wx_user')->count();
$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];
return $this->jsonSuccessData($data);
}
......
......@@ -2,12 +2,13 @@
<div class="app-container">
<div class="filter-container">
<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-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 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-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleSubmit">
{{ $t('table.search') }}
......@@ -25,19 +26,13 @@
</template>
</el-table-column>
<el-table-column align="center" label="用户名称">
<el-table-column align="left" label="用户名称">
<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>
</el-table-column>
<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">
<el-table-column v-if="showReviewer" align="center" label="openid" width="320">
<template slot-scope="scope">
<span style="color: #909399;" @click="handleCopy(scope.row.openid,$event)">{{ scope.row.openid }}</span>
</template>
......@@ -45,7 +40,7 @@
<el-table-column align="center" label="性别" width="150">
<template slot-scope="scope">
<span>{{ scope.row.sex==1 ? '男' : '女' }}</span>
<span>{{ scope.row.sex | handeSex }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="手机号" width="200">
......@@ -53,14 +48,14 @@
<span>{{ scope.row.mobile }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="地区" width="170">
<el-table-column align="center" label="地区" width="220">
<template slot-scope="scope">
<span>{{ scope.row.country }}{{ scope.row.province }}{{ scope.row.city }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="创建时间" width="170">
<el-table-column align="center" label="创建时间" width="200">
<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>
</el-table-column>
<el-table-column align="center" label="状态" width="170">
......@@ -89,6 +84,12 @@ export default {
handeNickname: function(value) {
return Base64.decode(value);
},
handeSex: function(value) {
const sexes = [
'未知', '男', '女',
];
return sexes[value];
},
},
data() {
return {
......@@ -100,12 +101,28 @@ export default {
query: {
page: 1,
limit: 10,
nickname: undefined,
mobile: undefined,
sex: undefined,
state: undefined,
city: undefined,
},
importanceOptions: ['男', '女'],
calendarTypeOptions: ['正常', '禁用'],
importanceOptions: [{
'key': 0,
'val': '未知',
}, {
'key': 1,
'val': '男',
}, {
'key': 2,
'val': '女',
}],
calendarTypeOptions: [{
'key': 1,
'val': '禁用',
}, {
'key': 2,
'val': '启用',
}],
srcList: [],
downloadLoading: false,
};
......@@ -151,7 +168,10 @@ export default {
if (j === 'created_at') {
return parseTime(v[j]);
} else if (j === 'sex') {
return v[j] === 1 ? '男' : '女';
const sexes = [
'未知', '男', '女',
];
return sexes[v[j]];
} else {
return v[j];
}
......@@ -185,3 +205,10 @@ export default {
},
};
</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