2023-11-23 23:39:38 +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 } from "@dcloudio/uni-app"
|
|
|
|
// import mySwiper from "@/components/mySwiper.vue"
|
|
|
|
import {ref,onMounted,nextTick} from "vue"
|
|
|
|
import {useStore} from '@/store/index.js'
|
|
|
|
import api from "@/api/index.js"
|
|
|
|
const store = useStore()
|
|
|
|
onLoad((e) => {
|
2023-11-28 22:30:40 +08:00
|
|
|
res_.value = JSON.parse(decodeURIComponent(e.res))
|
2024-02-28 00:47:54 +08:00
|
|
|
// console.log(res_.value)
|
|
|
|
// console.log(store.bgList)
|
|
|
|
// if(store.bgList.length>0) {
|
|
|
|
// bg_imgs.value = store.bgList
|
|
|
|
// }
|
2023-11-23 23:39:38 +08:00
|
|
|
randomFunc()
|
|
|
|
})
|
|
|
|
// 变量
|
2023-11-28 22:30:40 +08:00
|
|
|
const res_ = ref(null)
|
2023-11-23 23:39:38 +08:00
|
|
|
const userInfo = ref(null)
|
|
|
|
const bg_imgs = ref([
|
2024-01-14 13:47:56 +08:00
|
|
|
// {url:'/static/result1.jpg'},
|
|
|
|
// {url:'/static/result2.jpg'},
|
|
|
|
// {url:'/static/result3.jpg'},
|
2023-11-23 23:39:38 +08:00
|
|
|
])
|
|
|
|
const bg_index = ref(0)
|
2023-11-28 22:30:40 +08:00
|
|
|
const avatarUrl = ref(null)
|
|
|
|
const info = ref({left:'',right:''})
|
|
|
|
const show_ = ref(false)
|
2024-02-28 00:47:54 +08:00
|
|
|
const bg_list = ref([
|
|
|
|
"https://jmyl-app.oss-cn-chengdu.aliyuncs.com/miniapp/result/result1.jpg",
|
|
|
|
"https://jmyl-app.oss-cn-chengdu.aliyuncs.com/miniapp/result/result2.jpg",
|
|
|
|
"https://jmyl-app.oss-cn-chengdu.aliyuncs.com/miniapp/result/result3.jpg"
|
|
|
|
])
|
|
|
|
const bg_list_index = ref(0)
|
2023-11-23 23:39:38 +08:00
|
|
|
// 函数
|
|
|
|
function randomFunc() {
|
2024-02-28 00:47:54 +08:00
|
|
|
info.value.left = parseFloat(res_.value.leftEyeVision)
|
|
|
|
info.value.right = parseFloat(res_.value.rightEyeVision)
|
|
|
|
// 根据测试成绩显示不同的背景图
|
|
|
|
if ((info.value.left + info.value.right) / 2 > 5) {
|
|
|
|
bg_list_index.value = 0
|
|
|
|
} else if ((info.value.left + info.value.right) / 2 < 4.9 && (info.value.left + info.value.right) / 2 > 4.5) {
|
|
|
|
bg_list_index.value = 1
|
|
|
|
} else if ((info.value.left + info.value.right) / 2 < 4.5) {
|
|
|
|
bg_list_index.value = 2
|
|
|
|
}
|
|
|
|
// bg_index.value = parseInt((Math.random()*store.bgList.length))
|
2023-11-28 22:30:40 +08:00
|
|
|
uni.getImageInfo({
|
2023-12-29 00:12:16 +08:00
|
|
|
// src:bg_imgs.value[bg_index.value],
|
2024-02-28 00:47:54 +08:00
|
|
|
src: bg_list.value[bg_list_index.value],
|
2023-11-28 22:30:40 +08:00
|
|
|
success:function(res) {
|
|
|
|
avatarUrl.value = uni.getStorageSync('avatarUrl')
|
2024-06-19 22:25:50 +08:00
|
|
|
// info.value.left = parseFloat(res_.value.leftEyeVision)
|
|
|
|
// info.value.right = parseFloat(res_.value.rightEyeVision)
|
2023-11-28 22:30:40 +08:00
|
|
|
show_.value = true
|
2024-06-19 22:25:50 +08:00
|
|
|
// 判断度数长度是否只有一位
|
|
|
|
info.value.left = getRightNum(info.value.left)
|
|
|
|
info.value.right = getRightNum(info.value.right)
|
2023-11-28 22:30:40 +08:00
|
|
|
},
|
|
|
|
fail(err) {
|
|
|
|
console.log(err)
|
|
|
|
}
|
|
|
|
})
|
2024-02-28 00:47:54 +08:00
|
|
|
}
|
2024-06-19 22:25:50 +08:00
|
|
|
function getRightNum(num) {
|
|
|
|
if((num+'').length === 1) {
|
|
|
|
num = num+'.0'
|
|
|
|
}
|
|
|
|
return num
|
|
|
|
}
|
2024-02-28 00:47:54 +08:00
|
|
|
</script>
|
2023-11-23 23:39:38 +08:00
|
|
|
<template>
|
|
|
|
<view class="visionTestBox page-box">
|
|
|
|
<!-- <view class="actionBox" :style="{background:`url(${bg_imgs[bg_index]})`}">
|
|
|
|
测试
|
|
|
|
</view> -->
|
|
|
|
<view class="actionBox">
|
|
|
|
<view class="img-box">
|
2024-02-28 00:47:54 +08:00
|
|
|
<image style="width: 100%;" :src="bg_list[bg_list_index]" mode="widthFix"></image>
|
2023-11-28 22:30:40 +08:00
|
|
|
<view v-if="show_" class="avatar-box">
|
|
|
|
<image :src="avatarUrl" mode="widthFix"></image>
|
|
|
|
</view>
|
|
|
|
<view v-if="show_" class="res-text-row">
|
|
|
|
<view class="rtr-left">{{info.left}}</view>
|
|
|
|
<view class="rtr-right">{{info.right}}</view>
|
2023-11-23 23:39:38 +08:00
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
2024-02-28 00:47:54 +08:00
|
|
|
</view>
|
|
|
|
</template>
|
2023-11-23 23:39:38 +08:00
|
|
|
<style scoped lang="scss">
|
2023-11-28 22:30:40 +08:00
|
|
|
.avatar-box{
|
|
|
|
width: 100%;
|
|
|
|
position: absolute;
|
|
|
|
top:280rpx;
|
|
|
|
image{
|
|
|
|
width: 260rpx;
|
|
|
|
margin: 0px auto;
|
|
|
|
display: block;
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
}
|
2023-11-23 23:39:38 +08:00
|
|
|
.img-box{
|
|
|
|
position: relative;
|
|
|
|
.res-text-row{
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-around;
|
|
|
|
align-items: center;
|
|
|
|
position: absolute;
|
|
|
|
top: 47%;
|
|
|
|
font-weight: 900;
|
2023-11-28 22:30:40 +08:00
|
|
|
color:gray;
|
2023-11-23 23:39:38 +08:00
|
|
|
.rtr-left{
|
|
|
|
margin-left: 20%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.visionTestBox,.actionBox{
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
.actionBox{
|
|
|
|
.ab-show-box{
|
|
|
|
// width: 100%;
|
|
|
|
height: 50%;
|
|
|
|
border: 2rpx solid #d0d0d0;
|
|
|
|
margin: 10rpx;
|
|
|
|
margin-top: 0px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
image{
|
|
|
|
height: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.ab-action-box{
|
|
|
|
.ac-row{
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
.ac-row-card-text{
|
|
|
|
padding: 10rpx !important;
|
|
|
|
width: 80rpx !important;
|
|
|
|
height: 80rpx !important;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
.ac-row-card{
|
|
|
|
// white-space: nowrap;
|
|
|
|
margin: 20rpx;
|
|
|
|
font-size: 24rpx;
|
|
|
|
border-radius: 50%;
|
|
|
|
width: 40rpx;
|
|
|
|
height: 40rpx;
|
|
|
|
padding: 30rpx;
|
|
|
|
box-shadow: 2rpx 20rpx 40rpx #dfdfdf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.content-text{
|
|
|
|
margin-bottom: 20rpx;
|
|
|
|
.ct-title{
|
|
|
|
text-align: center;
|
|
|
|
font-size: 34px;
|
|
|
|
color: #26758d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.okBtn{
|
|
|
|
width: 100%;
|
|
|
|
color: white;
|
|
|
|
background-color: #26758d;
|
|
|
|
padding: 20rpx;
|
|
|
|
text-align: center;
|
|
|
|
box-sizing: border-box;
|
|
|
|
border-radius: 20rpx;
|
|
|
|
}
|
|
|
|
.pop-box{
|
|
|
|
.pb-title{
|
|
|
|
text-align: center;
|
|
|
|
margin-bottom: 40rpx;
|
|
|
|
}
|
|
|
|
background-color: white;
|
|
|
|
padding: 20rpx;
|
|
|
|
width: 80%;
|
|
|
|
margin: 0 auto;
|
|
|
|
border-radius: 20rpx;
|
2024-02-28 00:47:54 +08:00
|
|
|
}
|
2023-11-23 23:39:38 +08:00
|
|
|
</style>
|