JM-MiniApp/pages/index/index.vue

441 lines
11 KiB
Vue
Raw Normal View History

2023-10-08 21:21:21 +08:00
<script setup>
// 引入依赖
2023-10-18 21:00:42 +08:00
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'
2023-11-07 23:40:53 +08:00
import unCombox from '@/uni_modules/uni-combox/components/uni-combox/uni-combox.vue'
2023-11-05 18:19:14 +08:00
import { onLoad,onShow } from "@dcloudio/uni-app"
2023-10-08 21:21:21 +08:00
import mySwiper from "@/components/mySwiper.vue"
2023-11-14 23:48:34 +08:00
import aikefu from "@/components/aikefu.vue"
2023-10-25 00:18:08 +08:00
import {ref,onMounted,nextTick,watch} from "vue"
import api from '@/api/index.js'
2023-10-08 21:21:21 +08:00
import {useStore} from '@/store/index.js'
2023-10-11 22:20:34 +08:00
// import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
2023-10-08 21:21:21 +08:00
const store = useStore()
2023-11-05 18:19:14 +08:00
onShow((e) => {
2023-10-25 00:18:08 +08:00
getLbtList()
if(store.userInfo && !store.operation_info) { //登录过 且 未填写手术信息
// getHospitalList()
2023-10-18 21:00:42 +08:00
setTimeout(()=>{
inputDialog.value.open()
},0)
2023-10-08 21:21:21 +08:00
}
})
2023-10-25 00:18:08 +08:00
2023-10-08 21:21:21 +08:00
// 变量
2023-10-25 00:18:08 +08:00
const hospitals = ref(null)
// const hospitals_show = ref(false)
2023-10-08 21:21:21 +08:00
const inputDialog = ref()
const inputClose = ref()
2023-10-25 00:18:08 +08:00
const choosed_h = ref(null)
const blur_h = ref(0)
const surgery_time = ref(null) // 手术时间
const isSurgery = ref(-1) //是否已经手术 0为手术1已经手术
2023-11-01 00:33:57 +08:00
const lbt_list = ref([])
2023-10-25 00:18:08 +08:00
// 失去焦点的监听
// watch(blur_h,(val1,val2) => {
// // hospitals.value = null
// if(!choosed_h) { // 未选择值
// }
// })
2023-11-01 00:33:57 +08:00
const h_queryParams = ref({
page:1,
pageSize:1000,
key:''
})
2023-10-25 00:18:08 +08:00
// 函数
async function getHospitalList() {
2023-11-01 00:33:57 +08:00
const res = await api.getHospitalList(h_queryParams.value)
2023-10-25 00:18:08 +08:00
if(res.code == 0) {
hospitals.value = res.data.list
}
}
async function getLbtList() { // 获取轮播图
const res = await api.getLbtList()
if(res.code == 0) {
2023-11-01 00:33:57 +08:00
if(res.data.list) {
lbt_list.value = res.data.list
}
2023-10-25 00:18:08 +08:00
}
}
2023-10-18 21:00:42 +08:00
function toClose() {
inputDialog.value.close()
}
function radioChange(e) {
2023-10-25 00:18:08 +08:00
isSurgery.value = e.detail.value
2023-10-18 21:00:42 +08:00
}
const single = ref('')
function maskClick(e){
}
const hValue = ref('') // 医院
const hValueId = ref('') // 医院id
2023-11-05 18:19:14 +08:00
function onClickH() {
2023-11-01 00:33:57 +08:00
h_queryParams.value.key = hValue.value
2023-10-25 00:18:08 +08:00
getHospitalList()
2023-10-23 00:52:34 +08:00
}
function toExam() { // 视力测试
uni.navigateTo({
url:"/pages/index/visionTest"
})
2023-10-18 21:00:42 +08:00
}
2023-10-25 00:18:08 +08:00
function toChooseH(item) {
2023-11-05 18:19:14 +08:00
// console.log(item)
2023-10-25 00:18:08 +08:00
choosed_h.value = item
hValue.value = item.name
2023-11-05 18:19:14 +08:00
// hospitals.value = null
2023-10-25 00:18:08 +08:00
}
// function blurFunc() {
// blur_h.value = 1
// hospitals.value = null
// }
function focusFunc() {
// blur_h.value = 0
}
function toBlur(){
hospitals.value = null
}
async function toSave() {
2023-11-01 00:33:57 +08:00
if(isSurgery.value == -1) {
return
}
if(!surgery_time.value) {
return
}
if(!choosed_h.value || !choosed_h.value.ID) {
return
}
2023-10-25 00:18:08 +08:00
let user_info = JSON.parse(uni.getStorageSync('userInfo'))
2023-11-01 00:33:57 +08:00
let h_query = {
2023-11-05 18:19:14 +08:00
isSurgery:parseInt(isSurgery.value),
2023-10-25 00:18:08 +08:00
surgery_time:surgery_time.value,
userId:user_info.userId,
2023-10-25 23:45:00 +08:00
hospitalId:choosed_h.value?.ID
2023-11-01 00:33:57 +08:00
}
2023-11-07 00:12:02 +08:00
// console.log(h_query);return
2023-11-01 00:33:57 +08:00
const res = await api.hospital(h_query)
2023-10-25 00:18:08 +08:00
if(res.code == 0) {
2023-11-01 00:33:57 +08:00
uni.showToast({
title:"保存成功",
icon:"success",
duration:2000
})
uni.setStorageSync('operation_info',JSON.stringify(h_query))
store.operation_info = JSON.stringify(h_query)
2023-10-25 23:45:00 +08:00
toClose()
2023-10-25 00:18:08 +08:00
}
2023-11-01 00:33:57 +08:00
else{
uni.showToast({
2023-11-05 18:19:14 +08:00
title:res.msg,
2023-11-01 00:33:57 +08:00
icon:"error",
2023-11-05 18:19:14 +08:00
duration:2000,
success() {
if(res.code === 7) // 登录失败
{
// // 清空缓存
// uni.removeStorageSync('userInfo');
// uni.removeStorageSync('access_token');
// uni.removeStorageSync('avatarUrl');
// uni.switchTab({
// url:'/pages/user/index'
// })
store.afterFailLogin()
}
}
2023-11-01 00:33:57 +08:00
})
}
}
2023-11-05 18:19:14 +08:00
function todoFunc(state_index) {
2023-11-01 00:33:57 +08:00
let url = '/pages/index/todo'
2023-11-05 18:19:14 +08:00
url = '/pages/index/done?state_index='+state_index
// if(state_index === 0) {
// url = '/pages/index/done?state_index='+state_index
// }
2023-11-01 00:33:57 +08:00
uni.navigateTo({
url
})
}
function toVisionList() {
uni.navigateTo({
url:"/pages/index/visionList"
})
2023-10-25 00:18:08 +08:00
}
2023-11-07 00:12:02 +08:00
function toNote(index) {
uni.navigateTo({
url:"/pages/index/note_list?index="+index
})
}
2023-10-08 21:21:21 +08:00
</script>
<template>
<view class="content page-box">
<!-- 轮播图 -->
<mySwiper :indicatorDots="true" :isRadius="true" height="160" class="index-siwper margin-b-card" :lbt_list="lbt_list" style="width: 100%;" />
2023-10-23 00:52:34 +08:00
<view class="main-cards" @tap="toExam">
<view class="mc-row">
<view>视力测试</view>
<uni-icons type="forward" color="#9bc027" size="20"></uni-icons>
</view>
</view>
2023-11-01 00:33:57 +08:00
<view class="attention-card">
<view class="part-title">
测试记录
</view>
<view class="ac-parts">
<view @tap="toVisionList" class="ac-part" style="color: gray;" >
视力测试记录
<uni-icons type="forward" color="gray" size="20"></uni-icons>
</view>
</view>
</view>
<view class="attention-card">
<view class="part-title">
事务处理
</view>
</view>
2023-10-11 22:20:34 +08:00
<view class="main-cards">
2023-11-05 18:19:14 +08:00
<view @tap="todoFunc(0)" class="mc-part" style="margin-left: 0;">
2023-10-11 22:20:34 +08:00
<view class="mc-part-text">已完成事项</view>
<image src="../../static/done.png" mode="widthFix"></image>
</view>
2023-11-01 00:33:57 +08:00
<view @tap="todoFunc(1)" class="mc-part mc-part2" style="margin-right: 0;">
2023-10-11 22:20:34 +08:00
<view class="mc-part-text">待完成事项</view>
<image style="transform: rotate(0deg);" src="../../static/undone.png" mode="widthFix"></image>
</view>
</view>
<view class="attention-card">
<view class="part-title">
注意事项
</view>
<view class="ac-parts">
2023-11-07 00:12:02 +08:00
<view @tap="toNote(0)" class="ac-part" style="background: linear-gradient(45deg, #ffa2a2,#ffd3d3, #ffffff00);">
2023-10-11 22:20:34 +08:00
术前注意事项
<uni-icons type="forward" color="#ffa2a2" size="20"></uni-icons>
</view>
2023-11-07 00:12:02 +08:00
<view @tap="toNote(1)" class="ac-part" style="background: linear-gradient(45deg, #f9b275,#fff3e9, #ffffff00);">
2023-10-11 22:20:34 +08:00
术中注意事项
<uni-icons type="forward" color="#f9b275" size="20"></uni-icons>
2023-10-08 21:21:21 +08:00
</view>
2023-11-07 00:12:02 +08:00
<view @tap="toNote(2)" class="ac-part" style="background: linear-gradient(45deg, #8fdc8a,#fdfdfd, #ffffff00);">
2023-10-11 22:20:34 +08:00
术后注意事项
<uni-icons type="forward" color="#8fdc8a" size="20"></uni-icons>
</view>
</view>
</view>
2023-10-25 00:18:08 +08:00
<uni-popup ref="inputDialog" @tap="toBlur" :is-mask-click='false'>
2023-10-08 21:21:21 +08:00
<view class="pop-box">
2023-10-18 21:00:42 +08:00
<view class="pb-title">完善手术信息</view>
<view class="pb-content">
<view class="pb-item">
<view class="pb-item-left">已经手术</view>
<view class="pb-item-right">
<radio-group @change="radioChange">
<label class="radio"><radio value="1" /></label>
<label class="radio"><radio value="0" /></label>
</radio-group>
</view>
</view>
<view class="pb-item">
<view class="pb-item-left">手术时间</view>
<view class="pb-item-right">
<!-- <uni-datetime-picker type="date" :clear-icon="false" v-model="single" @maskClick="maskClick" /> -->
2023-10-25 00:18:08 +08:00
<uniDatetimePicker type="date" :clear-icon="false" v-model="surgery_time" @maskClick="maskClick" ></uniDatetimePicker>
2023-10-18 21:00:42 +08:00
</view>
</view>
<view class="pb-item">
<view class="pb-item-left">医院名称</view>
<view class="pb-item-right">
2023-11-05 18:19:14 +08:00
<!-- <uniEasyinput @tap.stop="focusFunc" suffixIcon="search" v-model="hValue" focus placeholder="请输入内容" @iconClick="onClickH"></uniEasyinput>
2023-10-25 00:18:08 +08:00
<view class="h_res_show_aprt" v-if="hospitals">
<view v-for="(item,i) in hospitals" @tap.stop="toChooseH(item)" class="h_res_show_aprt_row text-ellipsis-1">
{{item.name}}
</view>
2023-11-05 18:19:14 +08:00
</view> -->
<uni-combox @input="onClickH" :candidates="hospitals" placeholder="请选择医院" @choosed="toChooseH" v-model="hValue"></uni-combox>
2023-10-18 21:00:42 +08:00
</view>
</view>
2023-10-25 00:18:08 +08:00
<view class="pb-item pb-item-btn" @tap="toSave">提交</view>
2023-10-18 21:00:42 +08:00
</view>
2023-10-08 21:21:21 +08:00
</view>
2023-10-18 21:00:42 +08:00
<view class="pop-close" @tap="toClose">
2023-10-08 21:21:21 +08:00
关闭
</view>
<!-- <uni-popup-dialog ref="inputClose" mode="input" title="输入内容" value="对话框预置提示内容!"
placeholder="请输入内容" @confirm="dialogInputConfirm"></uni-popup-dialog> -->
</uni-popup>
2023-11-14 23:48:34 +08:00
<aikefu />
2023-10-08 21:21:21 +08:00
</view>
</template>
2023-10-11 22:20:34 +08:00
<style scoped lang="scss">
2023-10-25 00:18:08 +08:00
.pb-item-btn{
padding: 20rpx 0;
text-align: center;
color: white;
background: #26758d;
justify-content: center;
width: 66%;
margin: 0 auto;
border-radius: 10rpx;
}
.h_res_show_aprt{
position: absolute;
bottom: 100%;
width: 100%;
background: white;
z-index: 10;
box-shadow: 1px 2px 10px #02020236;
border: 1px solid #e3e3e3;
max-height: 400rpx;
overflow-y: auto;
left: 0;
.h_res_show_aprt_row{
padding: 20rpx 10rpx;
border-bottom: 2rpx #e3e3e3 solid;
color: gray;
}
.h_res_show_aprt_row:last-child{
border-bottom:unset
}
}
2023-10-23 00:52:34 +08:00
.mc-row{
display:flex;
// width: 100%;
// justify-content: space-between;
width: 100%;
justify-content: space-between;
border: 1px solid #9bc027;
padding: 20px 10px;
border-radius: 10px;
color: #9bc027;
font-size: 16px;
font-weight: 900;
}
2023-10-18 21:00:42 +08:00
.radio{
margin-right:20rpx;
}
.pb-item{
display: flex;
align-items: center;
margin-bottom: 40rpx;
// justify-content: space-between;
.pb-item-left{
width: 30%;
2023-11-05 18:19:14 +08:00
color: gray;
2023-10-18 21:00:42 +08:00
}
.pb-item-right{
2023-10-25 00:18:08 +08:00
position: relative;
2023-10-18 21:00:42 +08:00
margin-left: 10rpx;
width: 75%;
}
}
:deep(){
.uni-popup__wrapper{
width: 100%;
}
}
2023-10-11 22:20:34 +08:00
.part-title{
border-left: 10rpx solid #fe915d;
padding-left: 20rpx;
font-weight: 900;
}
.attention-card{
margin-top: 20rpx;
width: 100%;
.ac-parts{
margin-top: 20rpx;
.ac-part{
display: flex;
align-items: center;
justify-content: space-between;
padding:30rpx 20rpx;
color: white;
margin: 20rpx 0;
}
}
}
.main-cards{
.mc-part{
.mc-part-text{
position: relative;
z-index: 10;
font-size: 36rpx;
font-weight: 900;
}
width: 50%;
/* text-align: center; */
background: linear-gradient(200deg, #82d8f2, #ddecf0);
color: white;
padding: 40rpx 20rpx;
margin: 0 20rpx;
border-radius: 20rpx;
height: 100rpx;
position: relative;
overflow: hidden;
image{
position: absolute;
width: 66%;
right: 0;
bottom: -20%;
z-index: 1;
// transform: rotate(315deg);
transform: rotate(45deg);
}
}
.mc-part2{
background: linear-gradient(200deg,#bbf4d5, #50c053);
// text-align: right;
}
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
margin-top: 20rpx;
}
2023-10-08 21:21:21 +08:00
.pop-box{
2023-10-18 21:00:42 +08:00
.pb-title{
text-align: center;
margin-bottom: 40rpx;
}
2023-10-08 21:21:21 +08:00
background-color: white;
padding: 20rpx;
2023-10-18 21:00:42 +08:00
width: 80%;
margin: 0 auto;
border-radius: 20rpx;
}
.pop-close{
text-align: center;
color: white;
margin-top: 20rpx;
2023-10-08 21:21:21 +08:00
}
.page-box{
padding: 20rpx;
2023-10-19 23:23:22 +08:00
min-height: unset;
2023-10-08 21:21:21 +08:00
}
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>