前提:在数据很多有分页的情况下:
在子页面点击按钮,跳转到上一层页面或者首页,然后让其页面自动刷新,并显示第一页的数据。
问题解决
列表详情页面组件:
<view class="bottomBtn">
<button type="submit" @click="checkout">确认创建</button>
</view>
点击按钮跳转到列表页面:
checkout(){
this.$Net.postAction(this.$api.saveServiceOrder, param, 1).then(res => {
this.$Toast.message("创建成功");
uni.navigateBack();
}).catch(er => {
console.log(er)
});
}
列表list页面:
<template>
<view class="">
<view class="orderList">
<empty :list="listData" tips='暂无订单' :type='1' mode="order">
<view class="uni-form-item uni-column" v-for="(item,index) in listData" :key="index"
@click="onOrderdetail(item.serviceOrderId)">
<view class="text Order">
<view class="textOrder">系统编号:{{item.orderNo || '无'}}</view>
<view class="viewBtn">查看详情</view>
</view>
<view class="text">服务名称:{{item.serviceName || '无'}}</view>
<view class="text">类型:{{item.serviceRecipientType || '无'}}</view>
</view>
</empty>
<uni-load-more :status="refreshStatus" :content-text="contentText" color="#999" />
</view>
<view class="bottomBtn">
<button class="addOrder" type="submit" @click="OnOrder()">创建订单</button>
</view>
</view>
</template>
<script>
import {
mapState
} from 'vuex'
import Refresh from '@/mixins/refresh'
import uniLoadMore from '@/components/uni-load-more'
export default {
data() {
return {
listData: []
}
},
components: {
uniLoadMore
},
mixins: [Refresh],
computed: {
...mapState([
'username'
])
},
onLoad(option) {
},
onShow() {
this.refreshData(); //页面自动刷新
},
methods: {
getList(status) {
Object.assign(this.searchReq, {
uplusLoginId: this.username
})
this.$Net.postAction(this.$api.orderList, this.searchReq, 1).then(res => {
if (res.code == 200) {
const {
totalPages,
content
} = res.data;
this.setStatus(totalPages, content, status)
}
})
}
}
}
</script>