10.23修改

This commit is contained in:
阿怪 2023-10-23 23:57:15 +08:00
parent 23f37bc1a5
commit f55439859b
6 changed files with 163 additions and 93 deletions

36
App.vue
View File

@ -1,18 +1,30 @@
<script> <!-- // <script>
//
// export default {
// onLaunch: function() {
// console.log('App Launch')
// },
// onShow: function() {
// console.log('App Show')
// },
// onHide: function() {
// console.log('App Hide')
// }
// }
// </script> -->
<script setup>
import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue' import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
export default { import { onLoad,onLaunch } from "@dcloudio/uni-app"
onLaunch: function() { import {useStore} from '@/store/index.js'
console.log('App Launch') const store = useStore()
}, onLaunch((e) => {
onShow: function() { console.log('App onLaunch')
console.log('App Show') let userInfo = uni.getStorageSync('userInfo')
}, if(userInfo) {
onHide: function() { store.userInfo = userInfo
console.log('App Hide')
}
} }
})
</script> </script>
<style lang="scss"> <style lang="scss">
/*每个页面公共css */ /*每个页面公共css */
.page-bg-gray{ .page-bg-gray{

View File

@ -9,6 +9,7 @@ const API = {
userinfoUpdae:data => net.PUT('/user/info',data), // 更新用户信息 userinfoUpdae:data => net.PUT('/user/info',data), // 更新用户信息
// 首页 // 首页
getHospitalList:data => net.GET('/hospital/list',data), // 获取医院信息 getHospitalList:data => net.GET('/hospital/list',data), // 获取医院信息
saveVision:data => net.POST("/vision",data),// 保存视力测试结果
// 百科 // 百科
getArticleList:data => net.GET("/article/list",data),// 百科列表 getArticleList:data => net.GET("/article/list",data),// 百科列表
getArticleDetail:data => net.GET("/article/"+data.id),// 百科列表 getArticleDetail:data => net.GET("/article/"+data.id),// 百科列表

View File

@ -1,6 +1,6 @@
// isdev 为 true 表示开发环境 false 表示发布环境 // isdev 为 true 表示开发环境 false 表示发布环境
const isdev = true; const isdev = true;
const baseUrl = isdev ? 'https://62bafc5f.r16.cpolar.top' : 'http://niunai.zhitou1688.com';// 办公室接口 & 测试环境 const baseUrl = isdev ? 'http://18b10cba.r6.cpolar.top' : 'http://18b10cba.r6.cpolar.top';// 办公室接口 & 测试环境
// const baseUrl = isdev ? 'http://192.168.1.133:8899' : 'https://api.gwkjxb.com';// 办公室接口 & 正式环境 // const baseUrl = isdev ? 'http://192.168.1.133:8899' : 'https://api.gwkjxb.com';// 办公室接口 & 正式环境
// const baseUrl = 'https://api.gwkjxb.com';// 正式环境(由于本地测试后台没有启动,暂时通用正式服) // const baseUrl = 'https://api.gwkjxb.com';// 正式环境(由于本地测试后台没有启动,暂时通用正式服)

View File

@ -12,7 +12,7 @@
if(!store.userInfo?.has_operation) { // if(!store.userInfo?.has_operation) { //
operation_flag.value = true operation_flag.value = true
setTimeout(()=>{ setTimeout(()=>{
console.log(inputDialog.value) // console.log(inputDialog.value)
inputDialog.value.open() inputDialog.value.open()
},0) },0)
} }

View File

@ -6,22 +6,32 @@
// import mySwiper from "@/components/mySwiper.vue" // import mySwiper from "@/components/mySwiper.vue"
import {ref,onMounted,nextTick} from "vue" import {ref,onMounted,nextTick} from "vue"
import {useStore} from '@/store/index.js' import {useStore} from '@/store/index.js'
import api from "@/api/index.js"
const store = useStore() const store = useStore()
onLoad((e) => { onLoad((e) => {
if(!store.userInfo?.has_operation) { // userInfo.value = JSON.parse(store.userInfo)
console.log(userInfo.value)
countDown.value = countDown_init
// if(!store.userInfo?.has_operation) { //
// setTimeout(()=>{
// // console.log(inputDialog.value)
// inputDialog.value.open()
// },0)
// }
setTimeout(()=>{ setTimeout(()=>{
// console.log(inputDialog.value) // console.log(inputDialog.value)
inputDialog.value.open() inputDialog.value.open()
},0) },0)
}
}) })
// //
const userInfo = ref(null)
const inputDialog = ref() const inputDialog = ref()
const inputDialog2 = ref() const inputDialog2 = ref()
const inputDialog3 = ref() const inputDialog3 = ref()
const step1 = ref('先测右眼,请遮住左眼') const step1 = ref('先测右眼,请遮住左眼')
const step2 = ref('请遮住右眼') const step2 = ref('请遮住右眼')
const countDown = ref(5) const countDown = ref(null) //
const countDown_init = 3
const scale_ = ref(1) const scale_ = ref(1)
const current_img = ref("") // const current_img = ref("") //
const current_img_index = ref(null) const current_img_index = ref(null)
@ -59,10 +69,10 @@
width:'29px' width:'29px'
}) })
const num = ref(0) const num = ref(0)
const now = ref(1) const now = ref(1); // 1-2-
const vision_info = ref({ const vision_info = ref({
left:4, left:4,
right:4.1 right:4
}) })
// //
function toStart() { // function toStart() { //
@ -93,22 +103,31 @@
} }
function chooseFunc(index) { function chooseFunc(index) {
// //
if(!index){ // if(!index || index!=current_img_index.value){ //
}
else{ //
if(now.value == 1) { //
vision_info.value.right+=0.1
vision_info.value.right = Number(vision_info.value.right.toFixed(1))
}
else{ //
vision_info.value.left+=0.1
vision_info.value.left = Number(vision_info.value.left.toFixed(1))
}
} }
// //
randomFunc() randomFunc()
// //
if(num.value>8) { // if(num.value>8) { //
if(now.value == 2) { // if(now.value == 2) { //
inputDialog3.value.open()
return return
} }
show_size.value.width = '29px' show_size.value.width = '29px'
countDown.value = 5 countDown.value = countDown_init
step1.value = '测左眼,请遮住右眼' step1.value = '测左眼,请遮住右眼'
num.value = 8 num.value = 0
now.value = 2 now.value = 2
toStart() toStart()
} }
@ -117,8 +136,17 @@
num.value++ num.value++
} }
} }
function okFunc() { // async function okFunc() { //
inputDialog3.value.open() // inputDialog3.value.open()
const res = await api.saveVision({
leftEyeVision:vision_info.value.left,
rightEyeVision:vision_info.value.right,
userId:userInfo.value.userId
})
if(res.code == 0) {
uni.navigateBack()
}
} }
</script> </script>
<template> <template>
@ -147,8 +175,10 @@
<view class="pop-box"> <view class="pop-box">
<view class="pb-title">测试须知</view> <view class="pb-title">测试须知</view>
<view class="pb-content"> <view class="pb-content">
<view class="content-text"> <view class="content-text" style="color: gray;">
使用uni-app自带的editor组件该组件支持AppH5微信小程序其他家小程序自身未提供这类解决方案 1.适应室内光纤两分钟左右
2.取坐位或站立正对手机检查者眼部跟手机平行保持手机距离40厘米
3.先测右眼后测左眼测试时请遮挡另一只眼睛
</view> </view>
<view class="okBtn" @tap="toStart">确定</view> <view class="okBtn" @tap="toStart">确定</view>
</view> </view>
@ -166,12 +196,16 @@
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<uni-popup ref="inputDialog3" :is-mask-click='true'> <uni-popup ref="inputDialog3" :is-mask-click='false'>
<view class="pop-box"> <view class="pop-box">
<view class="pb-title">测试结束</view> <view class="pb-title">测试结束</view>
<view class="pb-content"> <view class="pb-content">
<view class="content-text"> <view class="content-text">
测试结束当前视力为{{vision_info.left}}(){{vision_info.right}}() 测试结束当前视力为{{vision_info.left}}(){{vision_info.right}}()
<view style="opacity: 0;">
使用uni-app自带的editor组件该组件支持AppH5微信小程序其他家小程序自身未提供这类解决方案
</view>
</view> </view>
<view class="okBtn" @tap="okFunc">确定</view> <view class="okBtn" @tap="okFunc">确定</view>
</view> </view>
@ -194,7 +228,7 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
image{ image{
// width: 29px; height: auto;
} }
} }
.ab-action-box{ .ab-action-box{

View File

@ -8,68 +8,22 @@
import api from "@/api/index" import api from "@/api/index"
import custom from "@/utils/index.js" import custom from "@/utils/index.js"
onShow(() => { onShow(() => {
is_login.value = custom.checkLogin() getInfo()
// console.log(is_login.value)
if(is_login.value) {
userinfo.value = uni.getStorageSync('userInfo')
avatar.value = uni.getStorageSync('avatarUrl')
userinfo.value = JSON.parse(userinfo.value)
// console.log(userinfo.value)
}
}) })
// //
const avatar = ref('') const avatar = ref('')
const res_form = ref(null) const res_form = ref(null)
const is_login = ref(null) const is_login = ref(null)
const userinfo = ref(null) const userinfo = ref(null)
// const avatarUrl = ref(null)
const nickname = ref('')
// //
function getPhoneNumber (e) { function getInfo(){
// tel_code.value = e.detail.code is_login.value = custom.checkLogin()
// console.log(e) // console.log(is_login.value)
getAccess_token({code:e.detail.code}) if(is_login.value) {
// console.log(e.detail.code) // avatar.value = uni.getStorageSync('avatarUrl')
// console.log(e.detail.errMsg) // userinfo.value = JSON.parse(uni.getStorageSync('userInfo'))
// console.log(e.detail.errno) //
}
async function getAccess_token(params={}){//token
//token
// wx.clearStorageSync();
//访
const data={
username:params.code,//code
type:'wechat_mini_app',
identity:'user',
password:'111'
}
// console.log(':',data)
const res = await api.getToken(data)
if(res.code === 200) {
res_form.value = res.data
res_form.value.access_token = 'Bearer '+res.data.access_token
let userId = res.data.userId
uni.setStorageSync('access_token',res_form.value.access_token);// token
wx_login(userId)
}
}
async function wx_login(userId){
let res=await new Promise(resolve=>{
uni.login({
provider: 'weixin', //使
success: function (loginRes) {
resolve(loginRes);
console.log(loginRes,'微信登录返回信息');
}
});
});
let res2=await api.wx_login({code:res.code},userId);
if(res2.code === 0) {
// for(let prop in res_form.value) {
// uni.setStorageSync(prop,res_form.value[prop])
// }
uni.setStorageSync(userInfo,JSON.stringify(res_form.value))
}
else{
uni.clearStorage();
} }
} }
function toLogin() { function toLogin() {
@ -105,6 +59,60 @@
url:"/pages/user/userInfo" url:"/pages/user/userInfo"
}) })
} }
function getPhoneNumber (e) {
// tel_code.value = e.detail.code
// console.log(e)
getAccess_token({code:e.detail.code})
// console.log(e.detail.code) //
// console.log(e.detail.errMsg) //
// console.log(e.detail.errno) //
}
async function getAccess_token(params={}){//token
//token
// wx.clearStorageSync();
//访
const data={
username:params.code,//code
type:'wechat_mini_app',
identity:'user',
password:'111'
}
// console.log(':',data);return;
const res = await api.getToken(data)
if(res.code === 200) {
if(res.data.newUser) { //
toUserInfo()
}
else{
uni.setStorageSync('avatarUrl', res.data.avatar);//avatarUrl
res_form.value = res.data
res_form.value.access_token = 'Bearer '+res.data.access_token
let userId = res.data.userId
uni.setStorageSync('access_token',res_form.value.access_token);// token
wx_login(userId)
}
}
}
async function wx_login(userId){
let res=await new Promise(resolve=>{
uni.login({
provider: 'weixin', //使
success: function (loginRes) {
resolve(loginRes);
console.log(loginRes,'微信登录返回信息');
}
});
});
let res2=await api.wx_login({code:res.code},userId);
if(res2.code === 0) {
uni.setStorageSync('userInfo',JSON.stringify(res_form.value))
// is_login.value = custom.checkLogin()
getInfo()
}
else{
uni.clearStorage();
}
}
</script> </script>
<template> <template>
<view class="user-box page-box"> <view class="user-box page-box">
@ -115,8 +123,12 @@
</view> </view>
<uni-icons style="position: absolute;right:20rpx;top: 40%;" v-if="is_login" type="forward" color="white" size="20"></uni-icons> <uni-icons style="position: absolute;right:20rpx;top: 40%;" v-if="is_login" type="forward" color="white" size="20"></uni-icons>
</view> </view>
<view class="btn-box" @tap="toLogin" v-if="!is_login"> <!-- <view class="btn-box" @tap="toLogin" v-if="!is_login"> -->
<view class="btn">登录</view> <view class="btn-box" v-if="!is_login">
<!-- <view class="btn">登录</view> -->
<view class="btn-part">
<button class="buy-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">立即登录</button>
</view>
</view> </view>
<view class="row-box" v-else> <view class="row-box" v-else>
<view class="rb-card" @tap="toDetail(1)" style="margin-bottom: 10px;"> <view class="rb-card" @tap="toDetail(1)" style="margin-bottom: 10px;">
@ -166,6 +178,17 @@
</view> </view>
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
.buy-btn{
display: inline-block;
margin-top:1rem;
background-color: #26758d;
color: white;
border-radius: 50rpx;
font-weight: 200;
font-size: 24rpx;
width: 50%;
padding: 10rpx 0;
}
.rbc-content-left-box{ .rbc-content-left-box{
uni-icons{ uni-icons{
margin-right: 20rpx; margin-right: 20rpx;