JM-MiniApp/pages/index/visionList.vue

119 lines
3.0 KiB
Vue
Raw Permalink Normal View History

2023-11-01 00:33:57 +08:00
<script setup>
// 引入依赖
import uniDatetimePicker from '@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue'
import uniEasyinput from '@/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue'
import { onLoad,onPullDownRefresh,onReachBottom } from "@dcloudio/uni-app"
import emptyCard from "@/components/emptyCard.vue"
import {ref,onMounted,nextTick,watch} from "vue"
import api from '@/api/index.js'
import util from "@/utils/index.js"
import {useStore} from '@/store/index.js'
// import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
const store = useStore()
// 生命周期
onLoad((e) => {
if(store.userInfo){
let user_info = JSON.parse(store.userInfo)
queryParams.value.userId = user_info.userId
}
getList()
})
onPullDownRefresh(()=> { // 下拉刷新
init()
getList()
})
onReachBottom(() => { // 上滑触底
queryParams.value.page++
getList()
})
// 变量
const list = ref([])
const queryParams = ref({
page:1,
pageSize:10,
userId:0
})
// 函数
function init(){
list.value = []
queryParams.value.page = 1
queryParams.value.pageSize = 10
}
async function getList() {
const res = await api.getVisionList(queryParams.value)
if(res.code === 0) {
if(res.data.list && res.data.list.length > 0) {
list.value.push(...res.data.list)
}
else{
queryParams.value.page--
}
}
else{
uni.showToast({
title:"获取失败",
icon:"error",
duration:2000
})
}
2023-12-29 00:12:16 +08:00
}
function toResult(params) {
console.log(params)
uni.redirectTo({
url:"/pages/index/result?res="+encodeURIComponent(JSON.stringify(params))
})
}
// encodeURIComponent(JSON.stringify(params))
2023-11-01 00:33:57 +08:00
</script>
<template>
<view class="visinoListBox page-box">
<view class="vl-item-box" v-if="list.length > 0">
2023-12-29 00:12:16 +08:00
<view class="vl-item" v-for="(item,i) in list" @tap="toResult(item)">
2023-11-01 00:33:57 +08:00
<view class="vl-title">{{util.timestampToDate(item.CreatedAt)}}</view>
<view class="vl-row-box">
<view class="vl-row">
<view class="vlr-left">右眼</view>
2023-12-29 00:12:16 +08:00
<view class="vlr-right">{{item.rightEyeVision}}</view>
2023-11-01 00:33:57 +08:00
</view>
<view class="vl-row">
<view class="vlr-left">左眼</view>
2023-12-29 00:12:16 +08:00
<view class="vlr-right">{{item.leftEyeVision}}</view>
2023-11-01 00:33:57 +08:00
</view>
</view>
</view>
</view>
<emptyCard v-else></emptyCard>
</view>
</template>
<style scoped lang="scss">
.visinoListBox{
.vl-item-box{
padding: 20rpx;
.vl-item{
2023-12-29 00:12:16 +08:00
margin-bottom: 20rpx;
padding: 20rpx;
/* border: 1px solid #eaeaea; */
border-radius: 20rpx;
box-shadow: 5px 5px 5px #f3f3f3;
2023-11-01 00:33:57 +08:00
.vl-title{
2023-12-29 00:12:16 +08:00
border-left: 10rpx solid #26758d;
padding-left: 5px;
margin-bottom: 10px;
2023-11-01 00:33:57 +08:00
}
.vl-row-box{
.vl-row{
display: flex;
align-items: center;
.vlr-left{
2023-12-29 00:12:16 +08:00
margin-right:20rpx
;color: gray;
2023-11-01 00:33:57 +08:00
}
.vlr-right{
margin-left: 20rpx;
}
}
}
}
}
}
</style>