|
@@ -5,14 +5,14 @@
|
|
|
<uni-row class="demo-uni-row" :width="nvueWidth">
|
|
|
<uni-col>
|
|
|
<view class="demo-uni-col">
|
|
|
- <uni-easyinput class="uni-input" prefixIcon="search" v-model="searchVal" placeholder="请输入商户名称"></uni-easyinput>
|
|
|
+ <uni-easyinput class="uni-input" prefixIcon="search" v-model="formData.name" placeholder="请输入商户名称"></uni-easyinput>
|
|
|
</view>
|
|
|
</uni-col>
|
|
|
</uni-row>
|
|
|
<uni-row class="demo-uni-row" :width="nvueWidth">
|
|
|
<uni-col :span="11">
|
|
|
<view class="demo-uni-col">
|
|
|
- <uni-data-picker :localdata="addressItems" v-model="selectedAddress" placeholder="商铺位置" popup-title="选择商铺位置"
|
|
|
+ <uni-data-picker :localdata="addressOptions" v-model="selectedAddress" placeholder="商铺位置" popup-title="选择商铺位置"
|
|
|
@change="onchange"
|
|
|
@nodeclick="onnodeclick"
|
|
|
@popupclosed="onpopupclosed"></uni-data-picker>
|
|
@@ -20,7 +20,7 @@
|
|
|
</uni-col>
|
|
|
<uni-col :span="5">
|
|
|
<view class="demo-uni-col">
|
|
|
- <uni-data-select class="search-data-select" placeholder="使用状态" v-model="statusValue" :localdata="statusRange">状态</uni-data-select>
|
|
|
+ <uni-data-select class="search-data-select" placeholder="使用状态" v-model="formData.status" :localdata="statusOptions">状态</uni-data-select>
|
|
|
</view>
|
|
|
</uni-col>
|
|
|
<uni-col :span="4">
|
|
@@ -38,7 +38,7 @@
|
|
|
</view>
|
|
|
<uni-list border class="list">
|
|
|
<uni-list-item
|
|
|
- v-for="(item, index) in dataList"
|
|
|
+ v-for="(item, index) in resultList"
|
|
|
:key="index"
|
|
|
:ellipsis="2"
|
|
|
:title=getTitle(item)
|
|
@@ -59,48 +59,48 @@
|
|
|
import { BASE_URL } from '../../env.js';
|
|
|
export default {
|
|
|
data() {
|
|
|
- return {
|
|
|
- searchVal: '',
|
|
|
- // more = 加载前, loading = 加载中, noMore = 没有更多
|
|
|
- more: 'more',
|
|
|
- dataList: [],
|
|
|
+ return {
|
|
|
+ addressOptions: [],
|
|
|
+ statusOptions: [],
|
|
|
currentAddress: null,
|
|
|
- selectedAddress: null,
|
|
|
- addressItems: [],
|
|
|
- statusValue: null,
|
|
|
- statusRange: [],
|
|
|
- queryForm: {
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 12,
|
|
|
+ selectedAddress: null,
|
|
|
+ formData: {
|
|
|
+ pageNum: 0,
|
|
|
+ pageSize: 20,
|
|
|
district: null,
|
|
|
building: null,
|
|
|
floor: null,
|
|
|
status: null,
|
|
|
name: null,
|
|
|
- }
|
|
|
+ },
|
|
|
+ resultList: [],
|
|
|
+ more: 'more'
|
|
|
}
|
|
|
},
|
|
|
onShow: function() {
|
|
|
// this.init();
|
|
|
},
|
|
|
+ // 页面生命周期中onReachBottom(页面滚动到底部的事件)
|
|
|
+ onReachBottom() {
|
|
|
+ if(this.more != 'noMore') {
|
|
|
+ this.more = 'more';
|
|
|
+ this.getShopList();
|
|
|
+ }
|
|
|
+ },
|
|
|
async mounted() {
|
|
|
await this.getDicts();
|
|
|
await this.getDistrictBuildingFloor();
|
|
|
await this.getShopList();
|
|
|
},
|
|
|
methods: {
|
|
|
- getTitle(shop){
|
|
|
- const title = shop.district
|
|
|
- + " 楼栋:" + shop.building
|
|
|
- + " 楼层:" + shop.floor
|
|
|
- + " 铺位号:" + shop.number;
|
|
|
- + "商户:" + shop.name;
|
|
|
- + "状态:" + shop.status;
|
|
|
- return title;
|
|
|
+ async getDicts() {
|
|
|
+ const resp_vacant = await dictApi.getDict('vacant_status');
|
|
|
+ if (resp_vacant.code == 200)
|
|
|
+ this.statusOptions = resp_vacant.data.map(l => ({ ...l, value: l.dictValue, text: l.dictLabel }));
|
|
|
},
|
|
|
async getDistrictBuildingFloor() {
|
|
|
const resp_address = await shopApi.getDistrictBuildingFloor();
|
|
|
- this.addressItems = resp_address.data.map(node => this.flattenValues(node));
|
|
|
+ this.addressOptions = resp_address.data.map(node => this.flattenValues(node));
|
|
|
},
|
|
|
flattenValues(node, parentValue='') {
|
|
|
if(parentValue!==''){
|
|
@@ -112,54 +112,39 @@
|
|
|
}
|
|
|
return node;
|
|
|
},
|
|
|
- async getDicts() {
|
|
|
- const resp_vacant = await dictApi.getDict('vacant_status');
|
|
|
- if (resp_vacant.code == 200)
|
|
|
- this.statusRange = resp_vacant.data.map(l => ({ ...l, value: l.dictValue, text: l.dictLabel }));
|
|
|
- },
|
|
|
- // 列表点击函数
|
|
|
- listItemBtn(e) {
|
|
|
- uni.navigateTo({ url: `/pages/shop/info?id=${e.shopId}` })
|
|
|
- },
|
|
|
// 搜索函数
|
|
|
async getShopList() {
|
|
|
- this.resetFormAndResult();
|
|
|
this.more = 'loading';
|
|
|
|
|
|
- if(this.currentAddress != null){
|
|
|
- var parts = this.currentAddress.value.split(":");
|
|
|
- if (parts.length >= 1) this.queryForm.district = parts[0];
|
|
|
- if (parts.length >= 2) this.queryForm.building = parts[1];
|
|
|
- if (parts.length >= 3) this.queryForm.floor = parts[2];
|
|
|
- }
|
|
|
-
|
|
|
- console.log("getShopList:", this.queryForm);
|
|
|
const queryParams = {};
|
|
|
- for (const key in this.queryForm) {
|
|
|
- if (this.queryForm[key] !== null && this.queryForm[key] !== undefined) {
|
|
|
- queryParams[key] = this.queryForm[key];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ this.getFormParams(queryParams);
|
|
|
const resp = await shopApi.getShopList({...queryParams});
|
|
|
- this.dataList.push(...resp.data.map(e => {return {...e}}))
|
|
|
- // 根据总数 算页数 如果当前页 = 总页数就是没有数据 否则就是上拉加载
|
|
|
- this.more = this.page >= Math.ceil(resp.total / this.size) ? 'noMore' : 'more';
|
|
|
+ this.resultList.push(...resp.rows);
|
|
|
+
|
|
|
+ this.updateMoreStatus(resp.total);
|
|
|
},
|
|
|
// 搜索函数
|
|
|
async handleSearch() {
|
|
|
+ this.resultList.length = 0;
|
|
|
+ this.formData.pageNum = 0;
|
|
|
+
|
|
|
await this.getShopList();
|
|
|
},
|
|
|
async handleReset() {
|
|
|
- this.resetFormAndResult();
|
|
|
-
|
|
|
- this.searchVal = null;
|
|
|
this.currentAddress = null;
|
|
|
this.selectedAddress = null;
|
|
|
- this.statusValue = null;
|
|
|
-
|
|
|
+
|
|
|
+ this.formData.pageNum = 0;
|
|
|
+ this.formData.name = null;
|
|
|
+ this.formData.district = null;
|
|
|
+ this.formData.building = null;
|
|
|
+ this.formData.floor = null;
|
|
|
+ this.formData.status = null;
|
|
|
+
|
|
|
+ this.resultList.length = 0;
|
|
|
+
|
|
|
await this.getShopList();
|
|
|
- },
|
|
|
+ },
|
|
|
onchange(nodesPath) {
|
|
|
const value = nodesPath.detail.value[0];
|
|
|
if (!value) {
|
|
@@ -168,31 +153,46 @@
|
|
|
},
|
|
|
onnodeclick(node) {
|
|
|
this.currentAddress = node;
|
|
|
- console.log("onnodeclick:", this.currentAddress);
|
|
|
},
|
|
|
onpopupclosed() {
|
|
|
- console.log("onpopupclosed:", this.currentAddress.value);
|
|
|
this.$nextTick(() => {
|
|
|
this.selectedAddress = this.currentAddress.value
|
|
|
});
|
|
|
},
|
|
|
- resetFormAndResult() {
|
|
|
- this.dataList.length = 0;
|
|
|
-
|
|
|
- this.queryForm.pageNum = 1;
|
|
|
- this.queryForm.pageSize= 12;
|
|
|
- this.queryForm.status = this.statusValue;
|
|
|
- this.queryForm.district = null;
|
|
|
- this.queryForm.building = null;
|
|
|
- this.queryForm.floor = null;
|
|
|
- this.queryForm.name = this.searchVal;
|
|
|
- }
|
|
|
- },
|
|
|
- // 页面生命周期中onReachBottom(页面滚动到底部的事件)
|
|
|
- onReachBottom() {
|
|
|
- if(this.more != 'noMore') {
|
|
|
- this.more = 'more';
|
|
|
- this.getShopList();
|
|
|
+ // 列表点击函数
|
|
|
+ listItemBtn(e) {
|
|
|
+ uni.navigateTo({ url: `/pages/shop/info?id=${e.shopId}` })
|
|
|
+ },
|
|
|
+ getTitle(shop){
|
|
|
+ const title = shop.district
|
|
|
+ + " 楼栋:" + shop.building
|
|
|
+ + " 楼层:" + shop.floor
|
|
|
+ + " 铺位号:" + shop.number;
|
|
|
+ + "商户:" + shop.name;
|
|
|
+ + "状态:" + shop.status;
|
|
|
+ return title;
|
|
|
+ },
|
|
|
+ getFormParams(queryParams){
|
|
|
+ this.formData.pageNum += 1;
|
|
|
+
|
|
|
+ if(this.currentAddress != null){
|
|
|
+ var parts = this.currentAddress.value.split(":");
|
|
|
+ if (parts.length >= 1) this.formData.district = parts[0];
|
|
|
+ if (parts.length >= 2) this.formData.building = parts[1];
|
|
|
+ if (parts.length >= 3) this.formData.floor = parts[2];
|
|
|
+ }
|
|
|
+
|
|
|
+ for (const key in this.formData) {
|
|
|
+ if (this.formData[key] !== null
|
|
|
+ && this.formData[key] !== undefined
|
|
|
+ && this.formData[key] !== '') {
|
|
|
+ queryParams[key] = this.formData[key];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ updateMoreStatus(total){
|
|
|
+ // 根据总数 算页数 如果当前页 = 总页数就是没有数据 否则就是上拉加载
|
|
|
+ this.more = this.formData.pageNum >= Math.ceil(total / this.formData.pageSize) ? 'noMore' : 'more';
|
|
|
}
|
|
|
}
|
|
|
}
|