10.23修改
This commit is contained in:
parent
23f37bc1a5
commit
f55439859b
36
App.vue
36
App.vue
@ -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'
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.log('App Launch')
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
}
|
||||
import { onLoad,onLaunch } from "@dcloudio/uni-app"
|
||||
import {useStore} from '@/store/index.js'
|
||||
const store = useStore()
|
||||
onLaunch((e) => {
|
||||
console.log('App onLaunch')
|
||||
let userInfo = uni.getStorageSync('userInfo')
|
||||
if(userInfo) {
|
||||
store.userInfo = userInfo
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
/*每个页面公共css */
|
||||
.page-bg-gray{
|
||||
|
@ -9,6 +9,7 @@ const API = {
|
||||
userinfoUpdae:data => net.PUT('/user/info',data), // 更新用户信息
|
||||
// 首页
|
||||
getHospitalList:data => net.GET('/hospital/list',data), // 获取医院信息
|
||||
saveVision:data => net.POST("/vision",data),// 保存视力测试结果
|
||||
// 百科
|
||||
getArticleList:data => net.GET("/article/list",data),// 百科列表
|
||||
getArticleDetail:data => net.GET("/article/"+data.id),// 百科列表
|
||||
|
@ -1,6 +1,6 @@
|
||||
// isdev 为 true 表示开发环境 false 表示发布环境
|
||||
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 = 'https://api.gwkjxb.com';// 正式环境(由于本地测试后台没有启动,暂时通用正式服)
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
if(!store.userInfo?.has_operation) { // 未填写手术信息
|
||||
operation_flag.value = true
|
||||
setTimeout(()=>{
|
||||
console.log(inputDialog.value)
|
||||
// console.log(inputDialog.value)
|
||||
inputDialog.value.open()
|
||||
},0)
|
||||
}
|
||||
|
@ -6,22 +6,32 @@
|
||||
// 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) => {
|
||||
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(()=>{
|
||||
// console.log(inputDialog.value)
|
||||
inputDialog.value.open()
|
||||
},0)
|
||||
}
|
||||
})
|
||||
// 变量
|
||||
const userInfo = ref(null)
|
||||
const inputDialog = ref()
|
||||
const inputDialog2 = ref()
|
||||
const inputDialog3 = ref()
|
||||
const step1 = ref('先测右眼,请遮住左眼')
|
||||
const step2 = ref('请遮住右眼')
|
||||
const countDown = ref(5)
|
||||
const countDown = ref(null) // 倒计时
|
||||
const countDown_init = 3
|
||||
const scale_ = ref(1)
|
||||
const current_img = ref("") // 当前图片
|
||||
const current_img_index = ref(null)
|
||||
@ -59,10 +69,10 @@
|
||||
width:'29px'
|
||||
})
|
||||
const num = ref(0)
|
||||
const now = ref(1)
|
||||
const now = ref(1); // 1-右眼;2-左眼
|
||||
const vision_info = ref({
|
||||
left:4,
|
||||
right:4.1
|
||||
right:4
|
||||
})
|
||||
// 函数
|
||||
function toStart() { // 开始测试
|
||||
@ -93,22 +103,31 @@
|
||||
}
|
||||
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()
|
||||
|
||||
// 判断是否结束,换眼
|
||||
if(num.value>8) { // 结束换眼
|
||||
if(now.value == 2) { // 结束测试
|
||||
|
||||
inputDialog3.value.open()
|
||||
return
|
||||
}
|
||||
show_size.value.width = '29px'
|
||||
countDown.value = 5
|
||||
countDown.value = countDown_init
|
||||
step1.value = '测左眼,请遮住右眼'
|
||||
num.value = 8
|
||||
num.value = 0
|
||||
now.value = 2
|
||||
toStart()
|
||||
}
|
||||
@ -117,8 +136,17 @@
|
||||
num.value++
|
||||
}
|
||||
}
|
||||
function okFunc() { // 结束测试
|
||||
inputDialog3.value.open()
|
||||
async function okFunc() { // 结束测试
|
||||
// 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>
|
||||
<template>
|
||||
@ -147,8 +175,10 @@
|
||||
<view class="pop-box">
|
||||
<view class="pb-title">测试须知</view>
|
||||
<view class="pb-content">
|
||||
<view class="content-text">
|
||||
使用uni-app自带的editor组件,该组件支持App、H5、微信小程序,其他家小程序自身未提供这类解决方案。
|
||||
<view class="content-text" style="color: gray;">
|
||||
1.适应室内光纤两分钟左右。
|
||||
2.取坐位或站立、正对手机,检查者眼部跟手机平行,保持手机距离40厘米。
|
||||
3.先测右眼后测左眼,测试时请遮挡另一只眼睛。
|
||||
</view>
|
||||
<view class="okBtn" @tap="toStart">确定</view>
|
||||
</view>
|
||||
@ -166,12 +196,16 @@
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
<uni-popup ref="inputDialog3" :is-mask-click='true'>
|
||||
<uni-popup ref="inputDialog3" :is-mask-click='false'>
|
||||
<view class="pop-box">
|
||||
<view class="pb-title">测试结束</view>
|
||||
<view class="pb-content">
|
||||
<view class="content-text">
|
||||
测试结束,当前视力为{{vision_info.left}}(左),{{vision_info.right}}(右)。
|
||||
<view style="opacity: 0;">
|
||||
使用uni-app自带的editor组件,该组件支持App、H5、微信小程序,其他家小程序自身未提供这类解决方案。
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="okBtn" @tap="okFunc">确定</view>
|
||||
</view>
|
||||
@ -194,7 +228,7 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
image{
|
||||
// width: 29px;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
.ab-action-box{
|
||||
|
@ -8,68 +8,22 @@
|
||||
import api from "@/api/index"
|
||||
import custom from "@/utils/index.js"
|
||||
onShow(() => {
|
||||
is_login.value = custom.checkLogin()
|
||||
// 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)
|
||||
}
|
||||
getInfo()
|
||||
})
|
||||
// 变量
|
||||
const avatar = ref('')
|
||||
const res_form = ref(null)
|
||||
const is_login = ref(null)
|
||||
const userinfo = ref(null)
|
||||
// const avatarUrl = ref(null)
|
||||
const nickname = ref('')
|
||||
// 函数
|
||||
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)
|
||||
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 getInfo(){
|
||||
is_login.value = custom.checkLogin()
|
||||
// console.log(is_login.value)
|
||||
if(is_login.value) {
|
||||
avatar.value = uni.getStorageSync('avatarUrl')
|
||||
userinfo.value = JSON.parse(uni.getStorageSync('userInfo'))
|
||||
}
|
||||
}
|
||||
function toLogin() {
|
||||
@ -105,6 +59,60 @@
|
||||
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>
|
||||
<template>
|
||||
<view class="user-box page-box">
|
||||
@ -115,8 +123,12 @@
|
||||
</view>
|
||||
<uni-icons style="position: absolute;right:20rpx;top: 40%;" v-if="is_login" type="forward" color="white" size="20"></uni-icons>
|
||||
</view>
|
||||
<view class="btn-box" @tap="toLogin" v-if="!is_login">
|
||||
<view class="btn">登录</view>
|
||||
<!-- <view class="btn-box" @tap="toLogin" v-if="!is_login"> -->
|
||||
<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 class="row-box" v-else>
|
||||
<view class="rb-card" @tap="toDetail(1)" style="margin-bottom: 10px;">
|
||||
@ -166,6 +178,17 @@
|
||||
</view>
|
||||
</template>
|
||||
<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{
|
||||
uni-icons{
|
||||
margin-right: 20rpx;
|
||||
|
Loading…
Reference in New Issue
Block a user