Compare commits

...

25 Commits

Author SHA1 Message Date
c11064f87b fix:修改订阅id 2024-07-03 22:51:41 +08:00
db46299b8c fix:首页调用鉴权接口;用药提醒框:字体太小,需调整展示位置;视力测试:视力结果保留一位小数(例:4.0 5.0) 2024-06-19 22:25:50 +08:00
c30fba1ec2 feat: 首页添加弹幕提醒 2024-04-26 14:57:47 +08:00
d35fab34e3 fix: 订阅提示 2024-03-21 18:17:06 +08:00
cad3bd0c69 fix:事务处理 2024-03-21 16:07:51 +08:00
90b72393be fix:修改订阅 2024-03-20 22:38:04 +08:00
5d6abb0219 fix bug 2024-03-20 14:44:01 +08:00
81758accdc fix: 修复文章详情无法展示图片的bug 2024-02-28 01:26:27 +08:00
e520f33d7c 2024.2.8修改 2024-02-28 00:47:54 +08:00
b40bc7deba fix:注意事项图片;个人资料保存传参 2024-01-31 22:58:43 +08:00
e763f707cc Merge branch 'main' of http://git.echol.cn/loser/JM-MiniApp 2024-01-30 23:38:18 +08:00
0b62426169 注意事项图片2 2024-01-30 23:37:28 +08:00
0a8512f9e2 注意事项图片 2024-01-30 23:36:29 +08:00
26f57ccf5e 样式优化;修改视力测试结果bug 2024-01-17 00:09:29 +08:00
2e387bc71f 添加首页图片 2024-01-14 20:13:09 +08:00
c36401baf6 测试结果背景图优化 2024-01-14 13:47:56 +08:00
2fa219cfe0 1229 10:50修改 2023-12-29 10:51:00 +08:00
6dcbf07b54 1229修改 2023-12-29 02:23:35 +08:00
8733d995ec 优化选项 2023-12-29 00:59:58 +08:00
5c7d95a2be 背景图设置 2023-12-29 00:12:16 +08:00
40bf8f8433 1211 2023-12-11 01:12:26 +08:00
e31e6d8fc5 11.28 2023-11-28 22:30:40 +08:00
eef9377e02 2023.11.23 2023-11-23 23:39:38 +08:00
3579868cc7 2023.11.16 2023-11-16 00:11:40 +08:00
dc946ec669 2023.11.14 2023-11-14 23:48:34 +08:00
39 changed files with 1920 additions and 314 deletions

View File

@@ -34,6 +34,8 @@
// sHeight.value = res.screenHeight
}
})
// 获取测试结果背景图
store.getBgList()
})
</script>
<style lang="scss">

View File

@@ -7,18 +7,25 @@ const API = {
wx_login: (data,userId) => net.POST('/user/binding/wechat',data,true,{"userId":userId}), // 微信登录
// upload: (data) => net.POST('/user/upload',data), // 文件上传
userinfoUpdae:data => net.PUT('/user/info',data,true,{"Content-Type":"application/x-www-form-urlencoded"}), // 更新用户信息
// ai 客服
getAikefuList:data => net.GET('/akefu/list',data), // 获取获取客服列表
getReply:data => net.POST('/ai',data), // 获取客服回复
// 首页
getHospitalList:data => net.GET('/hospital/list',data), // 获取医院信息
saveVision:data => net.POST("/vision",data),// 保存视力测试结果
getLbtList:data => net.GET("/banner/list",data),// 获取轮播图
hospital:data => net.PUT("/user/hospital",data),// 修改医院信息
getHospitalInfo:id => net.GET("/hospital/"+id),// 根据ID获取医院信息
getTodoist:data => net.GET("/user/todo",data),// 获取待办事项
getHospitalInfo2:data => net.GET("/hospital/notes",data),// 根据ID获取医院信息222
getTodoist:(data,userId) => net.GET("/user/todo",data,true,{"userId":userId}),// 获取待办事项
getVisionList:data => net.GET("/vision/list",data),// 获取测试记录
todoFinished:data => net.PUT("/user/todo",data),// 修改待办列表状态
todayTodoList:data => net.GET("/user/todo/today",data),// 今天待办列表
// 百科
getArticleList:data => net.GET("/article/list",data),// 百科列表
getArticleDetail:data => net.GET("/article/"+data.id),// 文章详情
getArticleDetail:(data,userId) => net.GET("/article/"+data.id,null,true,{"userId":userId}),// 文章详情
getArticleFavorite:(data,userId) => net.POST("/favorite",data,true,{"userId":userId}),// 收藏文章
delArticleFavorite:(data,userId) => net.DELETE("/favorite",data,true,{"userId":userId}),// 取消收藏文章
// 我的
getStarList:data => net.GET("/favorite/list",data),// 收藏列表
/*
@@ -37,6 +44,7 @@ const API = {
getCategoryList:data => net.GET('/api/goods_category/lists'), // 获取商品分类
getCategory:data => net.GET('/api/goods/category',data), // 根据分类Id获取分类商品
getCartList:data => net.GET('/api/cart/lists',data), // 获取购物车列表
getBgList:data => net.GET('/poster/list',data), // 获取测试结果背景图列表
addCart:data => net.POST('/api/cart/add',data), // 加入购物车
delCart:data => net.POST('/api/cart/delete',data), // 删除购物车
updateCart:data => net.POST('/api/cart/edit',data), // 更新购物车

View File

@@ -1,6 +1,5 @@
import config from '../config'
// import store from '../store'
import { useStore} from '@/store/index.js'
const loginUrl = 'pages/user/login';
// function JSON_to_URLEncoded(element,key,list){
@@ -75,6 +74,20 @@ export default {
});
}
}
if(res.data.code === 7) { // 登录失败
const store = useStore()
store.afterFailLogin(2000)
uni.showToast({
title:res.msg,
icon:"error",
duration:2000,
mask:true,
// success() {
// console.log(1212121)
// store.afterFailLogin(2000)
// }
})
}
return res.data;
} else {
const reg = /abort/;

47
components/aikefu.vue Normal file
View File

@@ -0,0 +1,47 @@
<template>
<view class="aikefuBox">
<!-- 这是ai客服!!!! -->
<unFab ref="fab" :pattern="pattern" horizontal="left" vertical="bottom"
direction="horizontal" @fabClick="fabClick" />
</view>
</template>
<script setup>
import unFab from '@/uni_modules/uni-fab/components/uni-fab/uni-fab.vue'
import { onLoad } from "@dcloudio/uni-app"
// import mySwiper from "@/components/mySwiper.vue"
import {ref,onMounted,nextTick,computed} from "vue"
// import unCombox from '@/uni_modules/uni-combox/components/uni-combox/uni-combox.vue'
import {useStore} from '@/store/index.js'
const store = useStore()
import api from "@/api/index.js"
const pattern = ref({
color: '#7A7E83',
backgroundColor: '#fff',
selectedColor: '#26758d',
buttonColor: '#26758d',
iconColor: '#fff',
icon:'headphones'
})
// const content = ref([{
// iconPath: '/static/image.png',
// selectedIconPath: '/static/image-active.png',
// text: '相册',
// active: false
// }])
function fabClick() {
// uni.showToast({
// title: '点击了悬浮按钮',
// icon: 'none'
// })
uni.navigateTo({
url:"/pages/index/aikefu"
})
}
</script>
<style scoped lang="scss">
.aikefuBox{
// margin-top: 200rpx;
}
</style>

View File

@@ -1,6 +1,8 @@
// isdev 为 true 表示开发环境 false 表示发布环境
const isdev = true;
const baseUrl = isdev ? 'http://4ca5004.r15.cpolar.top' : 'http://eb467b6.r19.cpolar.top';// 办公室接口 & 测试环境
const isdev = false;
const baseUrl = isdev ? 'https://367a21fd.r12.cpolar.top' : 'https://api.jimingyiliao.com';// 办公室接口 & 测试环境
// const baseUrl = isdev ? 'https://api.jimingyiliao.com' : 'http://eb467b6.r19.cpolar.top';// 办公室接口 & 测试环境
// const baseUrl = isdev ? 'http://707788f2.r1.cpolar.top' : 'http://eb467b6.r19.cpolar.top';// 办公室接口 & 测试环境
// const baseUrl = isdev ? 'http://192.168.1.133:8899' : 'https://api.gwkjxb.com';// 办公室接口 & 正式环境
// const baseUrl = 'https://api.gwkjxb.com';// 正式环境(由于本地测试后台没有启动,暂时通用正式服)

View File

@@ -52,10 +52,11 @@
"mp-weixin" : {
"appid" : "wxaaf66dbb5c3983b3",
"setting" : {
"urlCheck" : false
// "ignoreDevUnusedFiles": false ,
// "ignoreUploadUnusedFiles": false”
"urlCheck" : false,
"minified" : true
},
// "ignoreDevUnusedFiles": false ,
// "ignoreUploadUnusedFiles": false”
"usingComponents" : true
},
"mp-alipay" : {

View File

@@ -3,7 +3,9 @@
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "首页"
"navigationBar":"custom",
"navigationBarTitleText":"",
"navigationStyle":"custom"
}
},
{
@@ -110,7 +112,17 @@
"style": {
"navigationBarTitleText": "关于我们"
}
},
},{
"path": "pages/index/aikefu",
"style": {
"navigationBarTitleText": "客服中心"
}
},{
"path": "pages/index/result",
"style": {
"navigationBarTitleText": "测试结果"
}
}
],
"globalStyle": {
"navigationBarTextStyle": "white",

204
pages/index/aikefu.vue Normal file
View File

@@ -0,0 +1,204 @@
<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 unCombox from '@/uni_modules/uni-combox/components/uni-combox/uni-combox.vue'
import { onLoad,onShow } from "@dcloudio/uni-app"
import mySwiper from "@/components/mySwiper.vue"
import aikefu from "@/components/aikefu.vue"
import {ref,onMounted,nextTick,watch,getCurrentInstance} from "vue"
import api from '@/api/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) => {
uni.createSelectorQuery().in(instance).select('.show-part').boundingClientRect((res)=>{
w_h.value = res.height
// console.log(res)
}).exec()
})
// 变量
const w_h = ref(0)
const records = ref([
{
content:'您好,很高兴为您服务!',
type:1,//1-客服2-我
}
])
const scrollContainer = ref()
const in_content = ref('')
const scrollTop = ref(0.01) //注意不要设置成0不然无效
const instance = getCurrentInstance(); // 获取组件实例
const is_loading = ref(false)
// 函数
async function sendFunc() {
if(is_loading.value) {
return
}
is_loading.value = true
if(!in_content.value) {
uni.showToast({
title:"请填写内容",
icon:'error',
duration:2000,
mask:true
})
is_loading.value = false
return
}
records.value.push({
content:in_content.value,
type:2
})
const res = await api.getReply({msg:in_content.value})
is_loading.value = false
if(res.code === 0) {
in_content.value = ''
// 判断用户输入的关键字是否有效
if(res.data.content) {
records.value.push({
content:res.data.content,
type:1
})
}
else{
records.value.push({
content:'请输入正确的关键词',
type:-1
})
}
}
else{
uni.showToast({
title:res.msg,
icon:"error",
duration:2000
})
}
// 滚动条设置
uni.createSelectorQuery().in(instance).select('#scroll-view-content').boundingClientRect((res)=>{
let top = res.height-w_h.value+100;
if(top>0){
scrollTop.value = top;
}
// console.log(res.height,w_h.value)
}).exec()
}
</script>
<template>
<view class="aikefuBox page-box page-bg-gray" style="height: 100%;">
<!-- 信息展示区域 -->
<!-- <view class="ac-part show-part" id="show-part" ref="scrollContainer" :style="{scrollTop:scrollTop}"> -->
<scroll-view :scroll-with-animation="true" :scroll-y="true" class="ac-part show-part" scroll-y="true" :scroll-top="scrollTop">
<view class="ac-listt-box" id="scroll-view-content">
<view class="r_list-card" v-for="(item,i) in records">
<view v-if="item.type!=-1" class="r-row" :class="item.type === 1?'row-left':'row-right'">
<view class="r-avatar" v-if="item.type === 1">
<image src="../../static/kefu.png" mode="widthFix"></image>
</view>
<view class="r-content" :class="{'r-content-right':item.type==2}">{{item.content}}</view>
</view>
<!-- 错误提示 -->
<view class="r-row wrong-text" v-if="item.type==-1" style="color: #bfbfbf;text-align: center">
{{item.content}}
</view>
</view>
</view>
</scroll-view>
<!-- </view> -->
<!-- 输入区域 -->
<view class="as-part input-part">
<view class="input-box">
<view class="ib-left">
<input v-model="in_content" type="text" placeholder="输入您想咨询的内容">
</view>
<view class="ib-right">
<view class="send_btn" @tap="sendFunc">发送</view>
</view>
</view>
</view>
</view>
</template>
<style scoped lang="scss">
.aikefuBox{
height: 100%;
.show-part{
height: 88%;
// overflow-y: auto;
.ac-listt-box{
padding: 20rpx;
.r_list-card{
margin: 40rpx 0;
.r-row{
overflow: hidden;
.r-avatar{
float: left;
width: 80rpx;
height: 80rpx;
image{
width: 100%;
}
margin-right: 10rpx;
}
.r-content{
background-color: white;
display: inline-block;
padding: 20rpx;
border-radius:0 20rpx 20rpx 20rpx;
box-shadow: 10rpx 10rpx 10rpx #efefef;
}
.r-content-right{
float: right;
border-radius: 20rpx 0 20rpx 20rpx;
background-color: #26758d;
color: white;
}
}
}
}
}
.input-part{
height: 12%;
background: white;
position: fixed;
bottom: 0px;
width: 100%;
box-shadow: 0px -10px 20px 1px #eaeaea;
.input-box{
padding: 20rpx;
display: flex;
align-content: center;
.ib-left{
width: 88%;
margin-right: 20rpx;
input{
width: 100%;
border: 2rpx solid #c3c3c3;
padding: 10rpx 8rpx;
border-radius: 20rpx;
box-sizing: border-box;
display: block;
height: 100%;
}
}
.ib-right{
width: 12%;
display: flex;
align-items: center;
.send_btn{
padding: 10rpx;
background: #26758d;
color: white;
border-radius: 10rpx;
width: 100%;
text-align: center;
}
}
}
}
.ac-part{
}
}
</style>

View File

@@ -11,8 +11,12 @@
import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
import ccNewsTabs from '@/uni_modules/cc-newsTabs/components/cc-newsTabs/cc-newsTabs.vue'
const store = useStore()
import emptyCard from "@/components/emptyCard.vue"
// 生命周期
onLoad((e) => {
if(uni.getStorageSync('userInfo')) {
user_info.value = JSON.parse(uni.getStorageSync('userInfo'))
}
c_index.value = parseInt(e.state_index)
list_box.value[c_index.value].queryParams.isFinish = c_index.value?0:1
if(store.systemInfo) {
@@ -29,6 +33,7 @@
getList()
})
// 变量
const user_info = ref(null)
const inputDialog = ref()
const state_index = ref(0)
const swiper_h = ref(0)
@@ -72,6 +77,17 @@
}
])
// 函数
function subscribeFunc() {
uni.requestSubscribeMessage({
         tmplIds: ['BKyIwkt7HHEQoQ9ByrHqnHaGO5jq8d-MCp9YYGK23TE'],
         success: (res) => {
             console.log(res);
        },
fail(res) {
 console.log(res);
}
    })
}
function init(){
// list.value = []
list_box.value[c_index.value].list = []
@@ -85,12 +101,13 @@
uni.showLoading({
mask:true
})
const res = await api.getTodoist(list_box.value[c_index.value].queryParams)
list_box.value[c_index.value].queryParams.userId = user_info.value?.userId || 0
const res = await api.getTodoist(list_box.value[c_index.value].queryParams,user_info.value?.userId || 0)
uni.hideLoading();
if(res.code === 0) {
if(res.data && res.data.length > 0) {
// list.value.push(...res.data)
list_box.value[c_index.value].list.push(...res.data)
// list_box.value[c_index.value].list.push(...res.data)
list_box.value[c_index.value].list = res.data
}
else{
list_box.value[c_index.value].queryParams.page--
@@ -132,6 +149,7 @@
handle_info.value = item
handle_info_index.value = i
inputDialog.value.open()
subscribeFunc()
}
function finishFunc() {
// api.todoFinished
@@ -146,7 +164,7 @@
})
uni.showToast({
title:res_.msg,
icon:"error",
icon:"success",
duration:2000,
mask:true,
success() {
@@ -168,14 +186,16 @@
<swiper :current="c_index" @change="scroll_func" :style="{'--size':swiper_h+'px'}" class="swiper" circular :indicator-dots="false" :autoplay="false" >
<swiper-item v-for="(item1,i1) in list_box">
<view class="todoBox">
<view v-for="(item,i) in item1.list" @tap="handle_func(item,i)" class="td-item swiper-item uni-bg-green">
<view v-for="(item,i) in item1.list" v-if="item1.list.length>0" @tap="handle_func(item,i)" class="td-item swiper-item uni-bg-green">
<view class="td-content text-ellipsis-2">
{{item.content}}
</view>
<view class="td-info small-text">
{{util.timestampToDate(item.CreatedAt)}}
<!-- {{util.timestampToDate(item.CreatedAt)}} -->
{{item.remindDay + " " +item.remindTime}}
</view>
</view>
<emptyCard v-else></emptyCard>
</view>
</swiper-item>
</swiper>
@@ -189,6 +209,24 @@
{{handle_info?.content}}
</view>
</view>
<view class="pb-item">
<view class="pb-item-left">待办状态</view>
<view class="pb-item-right">
{{handle_info?.remindPeriod?'手术前':'手术后'}}
</view>
</view>
<view class="pb-item">
<view class="pb-item-left">用药频率</view>
<view class="pb-item-right">
{{handle_info?.frequency}}
</view>
</view>
<view class="pb-item">
<view class="pb-item-left">提醒时间</view>
<view class="pb-item-right">
{{handle_info?.remindTime}}
</view>
</view>
<view class="pb-item">
<view class="pb-item-left">创建时间</view>
<view class="pb-item-right">

View File

@@ -5,23 +5,31 @@
import unCombox from '@/uni_modules/uni-combox/components/uni-combox/uni-combox.vue'
import { onLoad,onShow } from "@dcloudio/uni-app"
import mySwiper from "@/components/mySwiper.vue"
import aikefu from "@/components/aikefu.vue"
import {ref,onMounted,nextTick,watch} from "vue"
import api from '@/api/index.js'
import {useStore} from '@/store/index.js'
// import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
const store = useStore()
const h_index = ref(0)
onShow((e) => {
getLbtList()
if(store.userInfo && !store.operation_info) { //登录过 且 未填写手术信息
// if(!store.userInfo && !store.operation_info) { //登录过 且 未填写手术信息
if(!store.userInfo) { //没登录过
// getHospitalList()
setTimeout(()=>{
inputDialog.value.open()
},0)
// setTimeout(()=>{
// inputDialog.value.open()
// },0)
} else {
// setTimeout(()=>{
// inputDialog.value.close()
// },0)
getTodayTodoList()
}
})
// 变量
const hospitals = ref(null)
const hospitals = ref([])
// const hospitals_show = ref(false)
const inputDialog = ref()
const inputClose = ref()
@@ -42,11 +50,64 @@
pageSize:1000,
key:''
})
const todayTodoList = ref([])
const todayTodoListShow = ref({})
// 函数
async function getTodayTodoList() {
const userInfo = uni.getStorageSync('userInfo')
if(userInfo) {
let user_info = JSON.parse(userInfo)
if(user_info.userId) {
const res = await api.todayTodoList({userId:user_info.userId})
if(res.code == 0) {
todayTodoList.value = res.data
// 测试开始
// let o = [
// {
// remindTime: '2024.1.1',
// content: '测试'
// },
// {
// remindTime: '2024.1.1',
// content: '快去测试343232423快去测试快去测试快去测试快去测试快去测试'
// },
// ]
// console.log(o)
// todayTodoList.value.push(...o)
// 测试结束
if(todayTodoList.value.length > 0) {
showTodo()
}
}
}
}
}
function showTodo() {
let start_num = 0
setInterval(() => {
if(!(start_num < todayTodoList.value.length)) {
start_num = 0
}
todayTodoListShow.value = todayTodoList.value[start_num]
start_num++
}, 2000)
}
function subscribeFunc() {
uni.requestSubscribeMessage({
         tmplIds: ['PgxoZOOSDgBcmIGd_EVLDnYUmL3eu6NQTAZCsHQeuWY'],
         success: (res) => {
             console.log(res);
        },
fail(res) {
 console.log(res);
}
    })
}
async function getHospitalList() {
const res = await api.getHospitalList(h_queryParams.value)
if(res.code == 0) {
hospitals.value = res.data.list
console.log(hospitals.value )
}
}
async function getLbtList() { // 获取轮播图
@@ -64,7 +125,7 @@
isSurgery.value = e.detail.value
}
const single = ref('')
function maskClick(e){
function maskClick(e){
}
const hValue = ref('') // 医院
const hValueId = ref('') // 医院id
@@ -92,7 +153,7 @@
// blur_h.value = 0
}
function toBlur(){
hospitals.value = null
// hospitals.value = null
}
async function toSave() {
if(isSurgery.value == -1) {
@@ -101,15 +162,17 @@
if(!surgery_time.value) {
return
}
if(!choosed_h.value || !choosed_h.value.ID) {
return
}
// if(!choosed_h.value || !choosed_h.value.ID) {
// return
// }
let user_info = JSON.parse(uni.getStorageSync('userInfo'))
let h_query = {
isSurgery:parseInt(isSurgery.value),
surgery_time:surgery_time.value,
userId:user_info.userId,
hospitalId:choosed_h.value?.ID
// hospitalId:choosed_h.value?.ID
hospitalId:hospitals.value[h_index.value]?.ID
}
// console.log(h_query);return
const res = await api.hospital(h_query)
@@ -150,6 +213,7 @@
// if(state_index === 0) {
// url = '/pages/index/done?state_index='+state_index
// }
subscribeFunc()
uni.navigateTo({
url
})
@@ -164,67 +228,109 @@
url:"/pages/index/note_list?index="+index
})
}
function bindPickerChange(e) {
h_index.value = e.detail.value
}
// 手机号登录
async function getPhoneNumber (e) {
await store.getAccess_token({code:e.detail.code})
toClose()
}
</script>
<template>
<view class="content page-box">
<!-- 背景图 -->
<view class="bg-imgs-card">
<image src="https://jmyl-app.oss-cn-chengdu.aliyuncs.com/miniapp/bg.png" mode="aspectFill"></image>
</view>
<!-- 轮播图 -->
<mySwiper :indicatorDots="true" :isRadius="true" height="160" class="index-siwper margin-b-card" :lbt_list="lbt_list" style="width: 100%;" />
<view class="main-cards" @tap="toExam">
<!-- <view class="main-cards" @tap="toExam">
<view class="mc-row">
<view>视力测试</view>
<uni-icons type="forward" color="#9bc027" size="20"></uni-icons>
</view>
</view>
<view class="attention-card">
<view class="part-title">
测试记录
</view> -->
<!-- 提示弹幕 -->
<!-- <view class="todayTodoListBox" v-if="todayTodoList.length>0">
<uni-icons type="sound-filled" color="#fc9467" size="30"></uni-icons>
<view class="tlb-item-box">
<view class="tlb-item" @tap="todoFunc(1)">
<view class="tlb-content ">{{todayTodoListShow.remindTime}}: &nbsp;{{todayTodoListShow.content}}</view>
</view>
</view>
<view class="ac-parts">
</view> -->
<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>
<view class="attention-card">
<!-- <view class="attention-card">
<view class="part-title">
事务处理
</view>
</view>
</view> -->
<view class="main-cards">
<view @tap="todoFunc(0)" class="mc-part" style="margin-left: 0;">
<image class="mc-bg-card" src="../../static/style/done.png" mode=""></image>
<view class="mc-part-text">已完成事项</view>
<image src="../../static/done.png" mode="widthFix"></image>
<!-- <image src="../../static/done.png" mode="widthFix"></image> -->
</view>
<view @tap="todoFunc(1)" class="mc-part mc-part2" style="margin-right: 0;">
<image class="mc-bg-card" src="../../static/style/undone.png" mode=""></image>
<view class="mc-part-text">待完成事项</view>
<image style="transform: rotate(0deg);" src="../../static/undone.png" mode="widthFix"></image>
<!-- <image style="transform: rotate(0deg);" src="../../static/undone.png" mode="widthFix"></image> -->
</view>
</view>
<view class="attention-card">
<view class="part-title">
<!-- <view class="part-title">
注意事项
</view>
</view> -->
<view class="ac-parts">
<view @tap="toNote(0)" class="ac-part" style="background: linear-gradient(45deg, #ffa2a2,#ffd3d3, #ffffff00);">
<!-- <view @tap="toNote(0)" class="ac-part" style="background: linear-gradient(45deg, #ffa2a2,#ffd3d3, #ffffff00);">
术前注意事项
<uni-icons type="forward" color="#ffa2a2" size="20"></uni-icons>
</view> -->
<view @tap="toNote(0)" class="ac-part" >
<view class="note-text">术前注意事项</view>
<image class="note-bg" src="../../static/style/note1.png" mode=""></image>
</view>
<view @tap="toNote(1)" class="ac-part" style="background: linear-gradient(45deg, #f9b275,#fff3e9, #ffffff00);">
术中注意事项
<uni-icons type="forward" color="#f9b275" size="20"></uni-icons>
<view @tap="toNote(1)" class="ac-part" >
<view class="note-text">术中注意事项</view>
<image class="note-bg" src="../../static/style/note3.png" mode=""></image>
</view>
<view @tap="toNote(2)" class="ac-part" style="background: linear-gradient(45deg, #8fdc8a,#fdfdfd, #ffffff00);">
术后注意事项
<uni-icons type="forward" color="#8fdc8a" size="20"></uni-icons>
<view @tap="toNote(2)" class="ac-part" >
<view class="note-text">术后注意事项</view>
<image class="note-bg" src="../../static/style/note2.png" mode=""></image>
</view>
</view>
</view>
<view class="test-card" @tap="toExam">
<view class="test-text">视力自测小助手</view>
<image class="test-img" src="../../static/style/test.png" mode=""></image>
</view>
<aikefu />
<!-- 提示弹幕 -->
<view class="todayTodoListBox" v-if="todayTodoList.length>0">
<uni-icons type="sound-filled" color="#fc9467" size="30" style="margin-right: 5px;"></uni-icons>
<view class="tlb-item-box">
<view class="tlb-item" @tap="todoFunc(1)">
<view class="tlb-content ">{{todayTodoListShow.remindTime}}: &nbsp;{{todayTodoListShow.content}}</view>
</view>
</view>
</view>
<uni-popup ref="inputDialog" @tap="toBlur" :is-mask-click='false'>
<view class="pop-box">
<view class="pb-title">完善手术信息</view>
<view class="pb-title">您好, 请先登录</view>
<view class="pb-content">
<view class="pb-item">
<!-- <view class="pb-item">
<view class="pb-item-left">已经手术</view>
<view class="pb-item-right">
<radio-group @change="radioChange">
@@ -236,34 +342,89 @@
<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" /> -->
<uniDatetimePicker type="date" :clear-icon="false" v-model="surgery_time" @maskClick="maskClick" ></uniDatetimePicker>
</view>
</view>
<view class="pb-item">
<view class="pb-item-left">医院名称</view>
<view class="pb-item-right">
<!-- <uniEasyinput @tap.stop="focusFunc" suffixIcon="search" v-model="hValue" focus placeholder="请输入内容" @iconClick="onClickH"></uniEasyinput>
<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>
</view> -->
<uni-combox @input="onClickH" :candidates="hospitals" placeholder="请选择医院" @choosed="toChooseH" v-model="hValue"></uni-combox>
<picker @change="bindPickerChange" :value="h_index" :range="hospitals" range-key="name">
<view class="uni-input">{{hospitals[h_index]?.name}}</view>
</picker>
</view>
</view>
<view class="pb-item pb-item-btn" @tap="toSave">提交</view>
</view> -->
<!-- <view class="pb-item pb-item-btn" @tap="toSave">提交</view> -->
<!-- <view class="pb-item pb-item-btn" @tap="toSave">获取手机号</view> -->
<button class="buy-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">手机号登录</button>
</view>
</view>
<view class="pop-close" @tap="toClose">
<!-- <view class="pop-close" @tap="toClose">
关闭
</view>
<!-- <uni-popup-dialog ref="inputClose" mode="input" title="输入内容" value="对话框预置提示内容!"
placeholder="请输入内容" @confirm="dialogInputConfirm"></uni-popup-dialog> -->
</view> -->
</uni-popup>
</view>
</template>
<style scoped lang="scss">
.todayTodoListBox{
display: flex;
// align-items: center;
margin-top: 1vh;
.tlb-item-box{
color: #f97a44;
font-weight: 900;
font-size: 4.2vw;
display: flex;
align-items: center;
.tlb-item{
display: flex;
align-items: center;
}
}
}
.buy-btn{
display: block;
margin-top:1rem;
background-color: #26758d;
color: white;
border-radius: 50rpx;
font-weight: 200;
font-size: 24rpx;
width: 80%;
padding: 10rpx 0;
margin: 0 auto;
}
.test-card{
padding: 30rpx 20rpx;
margin: 20rpx 0;
margin-top: 60rpx;
position: relative;
width: 50%;
.test-text{
position: relative;
z-index: 2;
}
.test-img{
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
z-index: 1;
}
}
.bg-imgs-card{
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
image{
width: 100%;
height: 100%;
}
z-index: -1;
}
.pb-item-btn{
padding: 20rpx 0;
text-align: center;
@@ -336,17 +497,31 @@
font-weight: 900;
}
.attention-card{
margin-top: 20rpx;
// margin-top: 20rpx;
width: 100%;
.ac-parts{
margin-top: 20rpx;
.ac-part{
display: flex;
align-items: center;
justify-content: space-between;
// display: flex;
// align-items: center;
// justify-content: space-between;
padding:30rpx 20rpx;
color: white;
// color: white;
margin: 20rpx 0;
position: relative;
.note-text{
position: relative;
z-index: 2;
}
.note-bg{
position: absolute;
/* z-index: 1; */
height: 100%;
width: 100%;
right: 0px;
top: 0px;
z-index: 1;
}
}
}
}
@@ -355,13 +530,17 @@
.mc-part-text{
position: relative;
z-index: 10;
font-size: 36rpx;
font-size: 28rpx;
font-weight: 900;
display: flex;
align-items: center;
height: 100%;
}
width: 50%;
/* text-align: center; */
background: linear-gradient(200deg, #82d8f2, #ddecf0);
color: white;
background: linear-gradient(220deg, #9cd2bc, #fff);
// color: white;
color: #484848;
padding: 40rpx 20rpx;
margin: 0 20rpx;
border-radius: 20rpx;
@@ -370,16 +549,20 @@
overflow: hidden;
image{
position: absolute;
width: 66%;
right: 0;
bottom: -20%;
z-index: 1;
// transform: rotate(315deg);
transform: rotate(45deg);
left: 0;
top: 0px;
width: 100%;
height: 100%;
// position: absolute;
// width: 66%;
// right: 0;
// bottom: -20%;
// z-index: 1;
// transform: rotate(45deg);
}
}
.mc-part2{
background: linear-gradient(200deg,#bbf4d5, #50c053);
background: linear-gradient(220deg, #9cd2bc, #fff);
// text-align: right;
}
display: flex;
@@ -405,14 +588,16 @@
margin-top: 20rpx;
}
.page-box{
padding: 20rpx;
padding: 0 20rpx;
min-height: unset;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
// align-items: center;
justify-content: center;
position: relative;
height: 100%;
}
.logo {
@@ -433,6 +618,7 @@
font-size: 36rpx;
color: #8f8f94;
}
</style>
image{will-change: transform}
</style>

View File

@@ -99,31 +99,69 @@
uni.showLoading({
mask:true
})
const res = await api.getTodoist(list_box.value[c_index.value].queryParams)
uni.hideLoading();
if(res.code === 0) {
if(res.data && res.data.length > 0) {
// list.value.push(...res.data)
list_box.value[c_index.value].list.push(...res.data)
}
else{
list_box.value[c_index.value].queryParams.page--
}
}
else{
// 判断是否登录
let is_login = util.checkLogin()
if(!is_login) {
uni.showToast({
title:res.msg,
title:'请先登录',
icon:"error",
duration:2000,
mask:true,
success() {
if(res.code === 7) // 登录失败
{
store.afterFailLogin(2000)
store.afterFailLogin(2000)
}
})
return
}
// 判断是否有手术信息
let operation_info = null
if(uni.getStorageSync('operation_info')) {
operation_info = JSON.parse(uni.getStorageSync('operation_info'))
}
if(operation_info && operation_info.hospitalId) {
const res = await api.getHospitalInfo2({
hospitalId:operation_info.hospitalId,
timeNum:list_box.value[c_index.value].queryParams.statet
})
// return
// const res = await api.getTodoist(list_box.value[c_index.value].queryParams)
if(res.code === 0) {
if(res.data && res.data.length > 0) {
// list_box.value[c_index.value].list.push(...res.data)
list_box.value[c_index.value].list = res.data
}
else{
list_box.value[c_index.value].queryParams.page--
}
}
else{
uni.showToast({
title:res.msg,
icon:"error",
duration:2000,
mask:true,
success() {
if(res.code === 7) // 登录失败
{
store.afterFailLogin(2000)
}
}
})
}
} else {
uni.showToast({
title:'请填写手术信息',
icon:"error",
duration:2000,
mask:true,
success() {
setTimeout(() => {
store.toProfile()
},2000)
}
})
}
uni.hideLoading();
}
function tabChange(currentIndex) {
c_index.value = currentIndex
@@ -143,9 +181,9 @@
const handle_info = ref(null)
const handle_info_index = ref(0)
function handle_func(item,i) {
handle_info.value = item
handle_info_index.value = i
inputDialog.value.open()
// handle_info.value = item
// handle_info_index.value = i
// inputDialog.value.open()
}
function finishFunc() {
// api.todoFinished
@@ -174,22 +212,33 @@
}
}
})
}
</script>
}
</script>
<template>
<view class="todoBox page-box">
<cc-newsTabs :tabArr="tabArr" :o_index="c_index" @tabChange="tabChange"></cc-newsTabs>
<cc-newsTabs class="ccTabs" style="position: fixed;top: 0px;" :tabArr="tabArr" :o_index="c_index" @tabChange="tabChange"></cc-newsTabs>
<swiper :current="c_index" @change="scroll_func" :style="{'--size':swiper_h+'px'}" class="swiper" circular :indicator-dots="false" :autoplay="false" >
<swiper-item v-for="(item1,i1) in list_box">
<swiper-item v-for="(item1) in list_box" :key="item1" style="overflow: auto;">
<view class="todoBox">
<view v-for="(item,i) in item1.list" @tap="handle_func(item,i)" class="td-item swiper-item uni-bg-green">
<view class="td-content text-ellipsis-2">
{{item.content}}
<template v-if="item1.list.length>0" >
<view v-for="(item,i) in item1.list" @tap="handle_func(item,i)" :key="i" class="td-item swiper-item uni-bg-green">
<view class="td-content text-ellipsis-2">
<!-- {{item.content}} -->
<image
style="width: 100%;"
:src="item.content"
mode="widthFix"
/>
</view>
<view class="td-info small-text">
{{util.timestampToDate(item.CreatedAt)}}
</view>
</view>
<view class="td-info small-text">
{{util.timestampToDate(item.CreatedAt)}}
</view>
</view>
</template>
<template v-else>
<emptyCard />
</template>
</view>
</swiper-item>
</swiper>
@@ -214,11 +263,18 @@
</view>
</uni-popup>
</view>
</template>
</view>
</template>
<style scoped lang="scss">
.ccTabs{
position: fixed;
top: 0px;
width: 100%;
z-index: 100;
}
.swiper{
height: var(--size);
margin-top: 80rpx;
}
.todoBox{
padding: 20rpx;
@@ -277,5 +333,5 @@
.uni-popup__wrapper{
width: 100%;
}
}
}
</style>

193
pages/index/result.vue Normal file
View File

@@ -0,0 +1,193 @@
<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) => {
res_.value = JSON.parse(decodeURIComponent(e.res))
// console.log(res_.value)
// console.log(store.bgList)
// if(store.bgList.length>0) {
// bg_imgs.value = store.bgList
// }
randomFunc()
})
// 变量
const res_ = ref(null)
const userInfo = ref(null)
const bg_imgs = ref([
// {url:'/static/result1.jpg'},
// {url:'/static/result2.jpg'},
// {url:'/static/result3.jpg'},
])
const bg_index = ref(0)
const avatarUrl = ref(null)
const info = ref({left:'',right:''})
const show_ = ref(false)
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)
// 函数
function randomFunc() {
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))
uni.getImageInfo({
// src:bg_imgs.value[bg_index.value],
src: bg_list.value[bg_list_index.value],
success:function(res) {
avatarUrl.value = uni.getStorageSync('avatarUrl')
// info.value.left = parseFloat(res_.value.leftEyeVision)
// info.value.right = parseFloat(res_.value.rightEyeVision)
show_.value = true
// 判断度数长度是否只有一位
info.value.left = getRightNum(info.value.left)
info.value.right = getRightNum(info.value.right)
},
fail(err) {
console.log(err)
}
})
}
function getRightNum(num) {
if((num+'').length === 1) {
num = num+'.0'
}
return num
}
</script>
<template>
<view class="visionTestBox page-box">
<!-- <view class="actionBox" :style="{background:`url(${bg_imgs[bg_index]})`}">
测试
</view> -->
<view class="actionBox">
<view class="img-box">
<image style="width: 100%;" :src="bg_list[bg_list_index]" mode="widthFix"></image>
<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>
</view>
</view>
</view>
</view>
</template>
<style scoped lang="scss">
.avatar-box{
width: 100%;
position: absolute;
top:280rpx;
image{
width: 260rpx;
margin: 0px auto;
display: block;
border-radius: 50%;
}
}
.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;
color:gray;
.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;
}
</style>

View File

@@ -56,21 +56,28 @@
duration:2000
})
}
}
}
function toResult(params) {
console.log(params)
uni.redirectTo({
url:"/pages/index/result?res="+encodeURIComponent(JSON.stringify(params))
})
}
// encodeURIComponent(JSON.stringify(params))
</script>
<template>
<view class="visinoListBox page-box">
<view class="vl-item-box" v-if="list.length > 0">
<view class="vl-item" v-for="(item,i) in list">
<view class="vl-item" v-for="(item,i) in list" @tap="toResult(item)">
<view class="vl-title">{{util.timestampToDate(item.CreatedAt)}}</view>
<view class="vl-row-box">
<view class="vl-row">
<view class="vlr-left">右眼</view>
<view class="vlr-left">{{item.rightEyeVision}}</view>
<view class="vlr-right">{{item.rightEyeVision}}</view>
</view>
<view class="vl-row">
<view class="vlr-left">左眼</view>
<view class="vlr-left">{{item.leftEyeVision}}</view>
<view class="vlr-right">{{item.leftEyeVision}}</view>
</view>
</view>
</view>
@@ -83,15 +90,23 @@
.vl-item-box{
padding: 20rpx;
.vl-item{
margin-bottom: 20rpx;
padding: 20rpx;
/* border: 1px solid #eaeaea; */
border-radius: 20rpx;
box-shadow: 5px 5px 5px #f3f3f3;
.vl-title{
border-left: 4rpx solid red;
border-left: 10rpx solid #26758d;
padding-left: 5px;
margin-bottom: 10px;
}
.vl-row-box{
.vl-row{
display: flex;
align-items: center;
.vlr-left{
margin-right:20rpx
;color: gray;
}
.vlr-right{
margin-left: 20rpx;

View File

@@ -10,7 +10,6 @@
const store = useStore()
onLoad((e) => {
userInfo.value = JSON.parse(store.userInfo)
console.log(userInfo.value)
countDown.value = countDown_init
// if(!store.userInfo?.has_operation) { // 未填写手术信息
// setTimeout(()=>{
@@ -74,8 +73,14 @@
left:4,
right:4
})
const is_test = ref(true)
// 函数
function toStart() { // 开始测试
// if(is_test.value) {
// uni.navigateTo({
// url:'/pages/index/result'
// })
// }
inputDialog.value.close()
inputDialog2.value.open()
let s = setInterval(() => {
@@ -141,19 +146,23 @@
uni.showLoading({
mask:true
})
const res = await api.saveVision({
const params = {
leftEyeVision:vision_info.value.left+'',
rightEyeVision:vision_info.value.right+'',
userId:userInfo.value.userId
})
userId:userInfo.value?.userId || 0
}
const res = await api.saveVision(params)
uni.hideLoading()
if(res.code == 0) {
uni.showToast({
title:"保存成功",
icon:"success",
duration:2000,
success: function (res){
uni.navigateBack()
success: function (res1){
// uni.navigateBack()
uni.redirectTo({
url:"/pages/index/result?res="+encodeURIComponent(JSON.stringify(params))
})
}
})

View File

@@ -1,6 +1,6 @@
<script setup>
<script setup>
// 引入依赖
import { onLoad } from "@dcloudio/uni-app"
import { onLoad, onBackPress } from "@dcloudio/uni-app"
// import mySwiper from "@/components/mySwiper.vue"
import {ref,onMounted,nextTick,watch} from "vue"
import {useStore} from '@/store/index.js'
@@ -9,116 +9,37 @@
import custom from "@/utils/index.js"
onLoad((e) => {
token_info.value = JSON.parse(decodeURIComponent(e.token_info))
// is_login.value = custom.checkLogin()
// console.log(is_login.value)
})
onBackPress(() => {
return false
})
// 变量
const token_info = ref(null)
const avatarUrl = ref(null)
const nickname = ref('')
const res_form = ref(null)
watch(nickname,(v1,v2)=> {
console.log("watch",v1)
})
var isOperation = ref([ // 是否已手术
{
index:0,
name:"否"
},
{
index: 1,
name: "是"
}
])
// 函数
function onChooseAvatar(e) {
// const { avatarUrl } = e.detail
// console.log(avatarUrl)
avatarUrl.value = e.detail.avatarUrl
}
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(code){//
//清除token缓存
// wx.clearStorageSync();
if(!avatarUrl.value) {
uni.showToast({
title:"请选择头像!",
icon:"error",
duration:1500
})
return
}
if(!nickname.value) {
uni.showToast({
title:"请填写昵称!",
icon:"error",
duration:1500
})
return
}
//访问接口
// console.log(code.value);return
// const data={
// username:code,//手机号按钮获取的code
// type:'wechat_mini_app',
// identity:'user',
// password:'111',
// avatarUrl:avatarUrl.value,
// nickName:nickname.value
// }
// console.log('登录参数:',data);return;
// const res = await api.getToken(data)
// if(res.code === 200) {
// uni.setStorageSync('avatarUrl', avatarUrl.value);//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)
// }
uni.setStorageSync('avatarUrl', avatarUrl.value);//avatarUrl
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))
custom.uploadImage(avatarUrl.value,async (file)=>{
avatarUrl.value = file.data.file.url
uni.setStorageSync('avatarUrl', file.data.file.url);//头像链接
const up_res = await updateFunc() // 更新用户信息
// isInfo // 判断是否填过手术信息的字段(是否使用待定)
uni.switchTab({
url:"/pages/user/index"
})
})
}
else{
uni.clearStorage();
}
}
async function updateFunc(){ // 更新用户信息,通过此接口获取用户是否填写手术信息
let user_info = JSON.parse(uni.getStorageSync('userInfo'))
user_info.avatar = avatarUrl.value
user_info.id =user_info.userId
// console.log(user_info)
return await api.userinfoUpdae(user_info)
}
function nameInput(e) {
nickname.value = e.detail.value
// console.log('拿到的值:',e)
// console.log('nickname:',nickname.value)
}
async function updateInfoFunc() {
if(!avatarUrl.value) {
@@ -137,23 +58,25 @@
})
return
}
// let user_info = JSON.parse(uni.getStorageSync('userInfo'))
await custom.uploadImage(avatarUrl.value,async (file)=>{
avatarUrl.value = file.data.file.url
uni.setStorageSync('avatarUrl', file.data.file.url);//头像链接
token_info.value.nickname = nickname.value
token_info.value.avatar = avatarUrl.value
uni.setStorageSync('userInfo',JSON.stringify(token_info.value))
uni.setStorageSync('access_token','Bearer '+token_info.value.access_token);// 为了保险,token单独缓存一次
const up_res = await updateFunc() // 更新用户信息
uni.setStorageSync('access_token','Bearer '+token_info.value.access_token);// token单独缓存一次
store.checkLogin() // 检查一遍登录情况
uni.switchTab({
url:"/pages/user/index"
})
})
}
</script>
function bindOperationPickerChange(e) {
token_info.value.IsSurgery = e.detail.value
}
</script>
<template>
<view class="loginBox page-box img-part card-part" style="text-align:center">
<view class="base-info">
@@ -163,13 +86,60 @@
</button>
<input type="nickname" @blur="nameInput" class="weui-input" placeholder="请输入昵称" v-model="nickname" />
</view>
<!-- <view class="row-box">
<view class="rb-card" @tap="toDetail(5)">
<view class="rbc-content">
<view class="rbc-content-row rbc-content-left rbc-content-left-box">
<uni-icons type="paperplane" color="gray" size="26"></uni-icons>
已经手术</view>
<view class="rbc-content-row rbc-content-right">
<picker @change="bindOperationPickerChange" :value="token_info?.IsSurgery" :range="isOperation" range-key="name" >
<view class="rbc-content-row rbc-content-right rbc-content-right-box">
<view class="uni-input">{{ isOperation[token_info?.IsSurgery]?.name }}</view>
<uni-icons type="forward" color="gray" size="20"></uni-icons>
</view>
</picker>
</view>
</view>
</view>
</view> -->
<view class="btn-part">
<!-- <button class="buy-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">立即登录</button> -->
<button class="buy-btn" @tap="updateInfoFunc">立即登录</button>
</view>
</view>
</template>
</view>
</template>
<style scoped lang="scss">
.rbc-content-right-box,.rbc-content-left-box{
display: flex;
align-items: center;
justify-content: center;
}
.row-box{
padding: 20rpx 0;
.rb-card{
padding: 20rpx;
background: white;
margin-bottom: 2rpx;
.rbc-title{
}
.rbc-content-box{
margin-top: 10rpx;
.rbc-content-row{
width: 50%;
text-align: center;
// padding: 40rpx 20rpx;
// box-shadow: 10rpx 10rpx 10rpx #cdcdcd;
border-radius: 10rpx;
}
}
.rbc-content{
display: flex;
align-items: center;
justify-content: space-between;
}
}
}
.base-info{
padding: 50rpx 0;
}
@@ -200,7 +170,7 @@
border-radius: 50rpx;
font-weight: 200;
font-size: 24rpx;
width: 50%;
width: 80%;
padding: 10rpx 0;
}
.title-part{
@@ -225,5 +195,5 @@
}
.weui-input{
}
}
</style>

View File

@@ -66,7 +66,7 @@
}
function getPhoneNumber (e) {
// tel_code.value = e.detail.code
console.log(e)
// console.log(e)
getAccess_token({code:e.detail.code})
// console.log(e.detail.code) // 动态令牌
// console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
@@ -74,7 +74,7 @@
}
async function getAccess_token(params={}){//获取token 获取手机号
//清除token缓存
// wx.clearStorageSync();
wx.clearStorageSync();
//访问接口
const data={
username:params.code,//手机号按钮获取的code
@@ -86,6 +86,7 @@
const res = await api.getToken(data)
if(res.code === 200) {
// newUser.value = res.data.newUser
// res.data.newUser = true // 开发阶段专用,正式版请删除
if(res.data.newUser) { // 新用户,不做任何缓存动作,跳转登录页
let userId = res.data.userId
let res_p=await new Promise(resolve=>{
@@ -93,15 +94,17 @@
provider: 'weixin', //使用微信登录
success: function (loginRes) {
resolve(loginRes);
console.log(loginRes,'微信登录返回信息');
// console.log(loginRes,'微信登录返回信息');
}
});
});
// 正式版记住放开下面这行注释掉的代码
uni.setStorageSync('access_token','Bearer '+res.data.access_token);// token单独缓存一次
let res2=await api.wx_login({code:res_p.code},userId);
if(res2.code === 0) {
store.checkLogin()
toLogin(encodeURIComponent(JSON.stringify(res.data)))
// toLogin(encodeURIComponent(JSON.stringify(res.data)))
store.toProfile(encodeURIComponent(JSON.stringify(res.data)))
}
}
else{
@@ -145,7 +148,7 @@
uni.clearStorage();
}
}
</script>
</script>
<template>
<view class="user-box page-box">
<view class="userinfo-box" @tap="toUserInfo">
@@ -163,7 +166,7 @@
</view>
</view>
<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;display: none;">
<!-- <view class="rbc-title">手术历程</view> -->
<view class="rbc-content rbc-content-box">
<view class="rbc-content-row rbc-content-left">
@@ -207,8 +210,8 @@
</view>
</view>
</view>
</view>
</template>
</view>
</template>
<style scoped lang="scss">
.buy-btn{
display: inline-block;
@@ -282,5 +285,5 @@
}
.user-box{
background: #f6f6f6;
}
}
</style>

View File

@@ -71,9 +71,9 @@
}
function toDetail(item) {
let info = encodeURIComponent(JSON.stringify(item))
// console.log(info)
console.log(item)
uni.navigateTo({
url:"/pages/wikipedia/detail?info="+info+"&id="+item.id
url:"/pages/wikipedia/detail?info="+info+"&id="+item.ID
})
}
</script>
@@ -82,11 +82,11 @@
<view class="list-box">
<view class="lb-card" v-if="list.length > 0" v-for="(item,i) in list" @tap="toDetail(item)">
<view class="lb-left">
<image :src="item.cover_img" mode="aspectFill"></image>
<image :src="item.cover" mode="aspectFill"></image>
</view>
<view class="lb-right">
<view class="lb-title">{{item.title}}</view>
<view class="lb-content text-ellipsis-1 small-text">{{item.content}}</view>
<view class="lb-content text-ellipsis-1 small-text">{{item.introduction}}</view>
</view>
</view>
<emptyCard v-else></emptyCard>

View File

@@ -6,26 +6,34 @@
import {useStore} from '@/store/index.js'
const store = useStore()
import api from "@/api/index.js"
onLoad(() => {
// console.log(useStore.userInfo)
userinfo.value = JSON.parse(uni.getStorageSync('userInfo'))
console.log(userinfo.value)
avatar.value = uni.getStorageSync('avatarUrl')
if(uni.getStorageSync('operation_info')) {
h_info.value = JSON.parse(uni.getStorageSync('operation_info'))
if(h_info.value) {
// console.log(h_info.value)
getHospital(h_info.value.hospitalId)
import custom from "@/utils/index.js"
const h_index = ref(0)
onLoad(async (e) => {
await getHospitalList()
is_login.value = custom.checkLogin()
if(!is_login.value) { // 未登录
userinfo.value = JSON.parse(decodeURIComponent(e.token_info))
} else { // 已登录
userinfo.value = JSON.parse(uni.getStorageSync('userInfo'))
h_info.value = userinfo.value
h_info.value.surgery_time = h_info.value.SurgeryTime
userinfo.value.avatar = uni.getStorageSync('avatarUrl')
h_index.value = hospitals.value.findIndex((item,i) => {
return item.ID == userinfo.value.HospitalId
})
if(userinfo.value.HospitalId) {
getHospital(userinfo.value.HospitalId)
}
}
})
// 变量
const is_login = ref(false)
const h_queryParams = ref({
page:1,
pageSize:1000,
key:''
})
const hospitals = ref(null)
const hospitals = ref([])
const userinfo = ref({})
const avatar = ref(null)
const h_info = ref({})
@@ -42,7 +50,7 @@
hospitals.value = res.data.list
}
}
function onClickH() {
function onInputH() {
h_queryParams.value.key = hValue.value
getHospitalList()
@@ -102,27 +110,42 @@
return `${year}-${month}-${day}`;
}
function bindDateChange(e) {
console.log(e)
// console.log(e)
h_info.value.surgery_time = e.detail.value
}
function toChooseH(item) {
console.log(item)
// console.log(item)
choosed_h.value = item
hValue.value = item.name
// hospitals.value = null
}
async function sumbmitFunc() {
console.log(choosed_h.value,h_info.value,userinfo.value)
await custom.uploadImage(userinfo.value.avatar, async (file) => {
userinfo.value.avatar = file.data.file.url
})
let obj = {
id: userinfo.value.userId,
// isSurgery: 1, //是否已经手术 0手术1已经手术
// isSurgery: userinfo.value.isSurgery,//是否已经手术 0 - 未手术1 - 已经手术
surgery_time: h_info.value?.surgery_time, //手术时间
nickname: userinfo.value.nickname,
// avatar: '',
avatar: userinfo.value.avatar,
phone: userinfo.value.phone,
hospitalId:choosed_h.value?.ID
hospitalId:hospitals.value[h_index.value]?.ID
}
const res = await api.userinfoUpdae(obj)
if(!obj.hospitalId) {
uni.showToast({
title: "请选择医院",
icon: "error",
duration: 2000
})
return
}
obj.isSurgery = parseInt(userinfo.value.IsSurgery)
// if(!is_login.value) { // 新用户 - 先登录
// }
userinfo.value.SurgeryTime = obj.surgery_time
const res = await api.userinfoUpdae(obj) // 更新用户信息
if(res.code === 0) {
uni.showToast({
title:res.msg,
@@ -148,25 +171,54 @@
provider: 'weixin', //使用微信登录
success: function (loginRes) {
resolve(loginRes);
console.log(loginRes,'微信登录返回信息');
}
});
});
let res2=await api.wx_login({code:res.code},userId);
if(res2.code === 0) {
userinfo.value.HospitalId = hospitals.value[h_index.value]?.ID
h_info.value.hospitalId = userinfo.value.HospitalId
uni.setStorageSync('avatarUrl', userinfo.value.avatar);//avatarUrl
uni.setStorageSync('userInfo',JSON.stringify(userinfo.value))
uni.setStorageSync('operation_info', JSON.stringify(h_info.value))
// is_login.value = custom.checkLogin()
store.checkLogin()
}
else{
uni.clearStorage();
}
}
</script>
}
function bindPickerChange(e) {
// console.log(hospitals.value )
h_index.value = e.detail.value
}
function onChooseAvatar(e) {
// const { avatarUrl } = e.detail
// console.log(avatarUrl)
userinfo.value.avatar = e.detail.avatarUrl
}
var isOperation = ref([
{
index:0,
name:"否"
},
{
index: 1,
name: "是"
}
])
function bindOperationPickerChange(e) {
userinfo.value.IsSurgery = e.detail.value
// console.log("userinfo.value.IsSurgery is :",userinfo.value.IsSurgery)
}
</script>
<template>
<view class="userInfoBox page-box page-bg-gray">
<view class="avatar-box">
<image :src="avatar" mode="aspectFill"></image>
<!-- <image :src="avatar" mode="aspectFill"></image> -->
<button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar" style="border-radius: 50%;">
<image :src="userinfo?.avatar" mode="aspectFill"></image>
</button>
</view>
<view class="row-box">
<view class="rb-card" @tap="toDetail(1)">
@@ -191,34 +243,57 @@
</view>
</view>
</view>
<view class="rb-card" @tap="toDetail(3)">
<view class="rbc-content">
<view class="rbc-content-row rbc-content-left rbc-content-left-box">
<uni-icons type="calendar" color="gray" size="26"></uni-icons>
手术时间</view>
<view class="rbc-content-row rbc-content-right">
<!-- {{h_info?.surgery_time}} -->
<picker mode="date" :value="h_info?.surgery_time" :start="startDate" :end="endDate" @change="bindDateChange">
<view class="rbc-content-row rbc-content-right">
<view class="uni-input"> {{h_info?.surgery_time}}</view>
<uni-icons type="forward" color="gray" size="20"></uni-icons>
</view>
</picker>
<view class="rb-card" @tap="toDetail(5)">
<view class="rbc-content">
<view class="rbc-content-row rbc-content-left rbc-content-left-box">
<uni-icons type="paperplane" color="gray" size="26"></uni-icons>
已经手术</view>
<view class="rbc-content-row rbc-content-right">
<picker @change="bindOperationPickerChange" :value="userinfo.IsSurgery" :range="isOperation" range-key="name" >
<view class="rbc-content-row rbc-content-right">
<view class="uni-input">{{ isOperation[userinfo.IsSurgery]?.name }}</view>
<uni-icons type="forward" color="gray" size="20"></uni-icons>
</view>
</picker>
</view>
</view>
</view>
</view>
<view class="rb-card" @tap="toDetail(4)">
<view class="rbc-content">
<view class="rbc-content-row rbc-content-left rbc-content-left-box">
<uni-icons type="paperplane" color="gray" size="26"></uni-icons>
手术医院</view>
<view class="rbc-content-row rbc-content-right">
<!-- {{h_info?.name}} -->
<uni-combox @input="onClickH" :candidates="hospitals" placeholder="请选择医院" @choosed="toChooseH" v-model="hValue"></uni-combox>
<uni-icons type="forward" color="gray" size="20"></uni-icons>
</view>
</view>
</view>
<template>
<view class="rb-card" @tap="toDetail(3)">
<view class="rbc-content">
<view class="rbc-content-row rbc-content-left rbc-content-left-box">
<uni-icons type="calendar" color="gray" size="26"></uni-icons>
手术时间</view>
<view class="rbc-content-row rbc-content-right">
<!-- {{h_info?.surgery_time}} -->
<picker mode="date" :value="h_info?.surgery_time" :start="startDate" :end="endDate" @change="bindDateChange">
<view class="rbc-content-row rbc-content-right">
<view class="uni-input"> {{h_info?.surgery_time}}</view>
<uni-icons type="forward" color="gray" size="20"></uni-icons>
</view>
</picker>
</view>
</view>
</view>
<view class="rb-card" @tap="toDetail(4)">
<view class="rbc-content">
<view class="rbc-content-row rbc-content-left rbc-content-left-box">
<uni-icons type="paperplane" color="gray" size="26"></uni-icons>
手术医院</view>
<view class="rbc-content-row rbc-content-right">
<!-- {{h_info?.name}} -->
<!-- <uni-combox :border="false" @input="onInputH" :candidates="hospitals" placeholder="请选择医院" @choosed="toChooseH" v-model="userinfo.HospitalId"></uni-combox> -->
<!-- <uni-icons type="forward" color="gray" size="20"></uni-icons> -->
<picker @change="bindPickerChange" :value="h_index" :range="hospitals" range-key="name">
<view class="rbc-content-row rbc-content-right">
<view class="uni-input">{{hospitals[h_index]?.name}}</view>
<uni-icons type="forward" color="gray" size="20"></uni-icons>
</view>
</picker>
</view>
</view>
</view>
</template>
</view>
<!--修改姓名/电话 弹窗 -->
<uni-popup ref="inputDialog" >
@@ -239,9 +314,22 @@
</view>
</uni-popup>
<view class="pb-item pb-item-btn" style="margin-top: 40rpx;" @tap="sumbmitFunc">确定</view>
</view>
</template>
</view>
</template>
<style scoped lang="scss">
.avatar-wrapper{
width: 160rpx !important;
height: 160rpx;
padding: 0px;
margin: 0 auto;
overflow: hidden;
margin-bottom: 40rpx;
// border: 1px solid #26758d;
background: #ececec;
display: flex;
align-items: center;
justify-content: center;
}
.avatar-box{
display: flex;
align-items: center;
@@ -249,6 +337,14 @@
width: 100%;
padding: 20rpx 0;
background: #26758d;
button{
image{
width: 160rpx;
height: 160rpx;
background-color: white;
border-radius: 50%;
}
}
image{
width: 160rpx;
height: 160rpx;
@@ -368,5 +464,5 @@
.uni-popup__wrapper{
width: 100%;
}
}
}
</style>

View File

@@ -9,7 +9,11 @@
import emptyCard from "@/components/emptyCard.vue"
import api from "@/api/index.js"
import util from "@/utils"
const store = useStore()
onLoad((e) => {
if(uni.getStorageSync('userInfo')) {
userInfo.value = JSON.parse( uni.getStorageSync('userInfo'))
}
// console.log(e)
// a_info.value = JSON.parse(decodeURIComponent(e.info))
if(!e.id) {
@@ -24,6 +28,12 @@
getDetail(e.id)
})
// 变量
let strings = `<div style="text-align: center; "><p>&nbsp;测试内容222sdadd&nbsp;</p><figure class="image"><img src="https://jmyl-app.oss-cn-chengdu.aliyuncs.com/miniapp/uploads/2024-02-24/undone.png"/></figure></div>`
// `<p>&nbsp;测试内容222sdadd&nbsp;</p><figure class="image"><img src="https://jmyl-app.oss-cn-chengdu.aliyuncs.com/miniapp/uploads/2024-02-24/undone.png"></figure>`
// strings = strings.replaceAll("figure", "div");
// strings = strings.replaceAll("<img", "<img style='width:100%'");
console.log(strings)
const userInfo = ref(null)
// const content = ref(null)
const a_info = ref(null)
// 函数
@@ -31,6 +41,10 @@
const res = await api.getArticleDetail({id})
if(res.code == 0) {
a_info.value = res.data
if(a_info.value.content) {
a_info.value.content = a_info.value.content.replaceAll("figure", "div");
a_info.value.content = a_info.value.content.replaceAll("<img", "<img style='width:100%'");
}
}
else{
uni.showToast({
@@ -41,29 +55,53 @@
}
}
async function starFunc(type) { // 点击收藏
a_info.value.isStar = type
}
</script>
if(!userInfo.value) {
store.afterFailLogin(2000)
return
}
console.log(a_info.value)
if(type) { // 添加收藏
const res = await api.getArticleFavorite({
wz_id:a_info.value.ID,
userId:userInfo.value.userId,
cover:a_info.value.cover_img,
title:a_info.value.title,
introductions:''
},userInfo.value.userId)
}
else{ // 取消收藏
const res = await api.delArticleFavorite({
id:a_info.value.ID,
},userInfo.value.userId)
}
a_info.value.is_favorite = type
}
</script>
<template>
<view class="detailBox">
<view class="title">
{{a_info?.title}}
</view>
<view v-if="a_info" class="more-info small-text">{{util.timestampToDate(a_info?.CreatedAt)}}</view>
<view class="d-content" v-html="a_info?.content"></view>
<!-- <view class="d-content">
<rich-text :nodes="a_info?.content"></rich-text>
</view> -->
<view v-if="a_info" class="d-content" v-html="a_info.content">
</view>
<view class="action-box" v-if="a_info">
<view class="ab-item">
<uni-icons color="gray" type="eye" size="30"></uni-icons>
<view style="color: gray;">{{a_info?.reading_num}}</view>
</view>
<view class="ab-item">
<uni-icons color="#26758d" @tap="starFunc(0)" v-if="a_info?.isStar" type="star-filled" size="30"></uni-icons>
<uni-icons color="#26758d" @tap="starFunc(0)" v-if="a_info?.is_favorite" type="star-filled" size="30"></uni-icons>
<uni-icons color="gray" @tap="starFunc(1)" v-else type="star" size="30"></uni-icons>
</view>
</view>
<emptyCard title="暂无内容" v-if="!a_info"></emptyCard>
</view>
</template>
</view>
</template>
<style scoped lang="scss">
.action-box{
margin-top: 20px;
@@ -90,5 +128,5 @@
.d-content{
line-height: 50rpx;
}
}
}
</style>

View File

@@ -7,6 +7,7 @@
import {ref,onMounted,nextTick} from "vue"
import {useStore} from '@/store/index.js'
import api from "@/api/index"
import emptyCard from "@/components/emptyCard.vue"
// 生命周期
onLoad(() => {
getList()
@@ -55,7 +56,7 @@
}
}
function toDetail(item) {
let info = encodeURIComponent(JSON.stringify(item))
// let info = encodeURIComponent(JSON.stringify(item))
// console.log(info)
uni.navigateTo({
url:"./detail?id="+item.ID
@@ -68,7 +69,7 @@
</view>
<view class="list-box">
<view class="lb-card" v-for="(item,i) in list" @tap="toDetail(item)">
<view v-if="list.length>0" class="lb-card" v-for="(item,i) in list" @tap="toDetail(item)">
<view class="lb-left">
<image :src="item.cover_img" mode="aspectFill"></image>
</view>
@@ -77,6 +78,7 @@
<view class="lb-content text-ellipsis-1 small-text" v-html="item.content"></view>
</view>
</view>
<emptyCard v-else></emptyCard>
</view>
</view>
</template>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

BIN
static/kefu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
static/style/done.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

BIN
static/style/note1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

BIN
static/style/note2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

BIN
static/style/note3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

BIN
static/style/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

BIN
static/style/undone.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

View File

@@ -25,6 +25,7 @@ export const useStore = defineStore('main2', {
remark_text:'',
address:'',
operation_info:null, // 手术信息
bgList:[], // 测试结果背景图
}
},
actions:{
@@ -56,13 +57,14 @@ export const useStore = defineStore('main2', {
});
},
checkLogin(){ // 检查是否登录
let access_token = uni.getStorageSync('access_token')
// let visitState = uni.getStorageSync('visitState')
console.log(access_token)
if(access_token) {
this.access_token = access_token
// let access_token = uni.getStorageSync('access_token')
let u_info = uni.getStorageSync('userInfo')
// console.log("u_info is ",u_info)
if(u_info) {
this.access_token = uni.getStorageSync('access_token')
this.isLogin = true
this.userInfo = uni.getStorageSync('userInfo')
this.operation_info = uni.getStorageSync('operation_info')
// this.getUserInfo()
}
else{
@@ -157,6 +159,16 @@ export const useStore = defineStore('main2', {
// }
}
},
async getBgList(){
const res = await api.getBgList({page:1,pageSize:100})
// console.log(res)
if(res.code == 0) {
if(res.data && res.data.list && res.data.list.length>0 ) {
this.bgList = res.data.list
// console.log(this.bgList)
}
}
},
afterFailLogin(duration){
setTimeout(()=>{
uni.removeStorageSync('userInfo');
@@ -169,6 +181,87 @@ export const useStore = defineStore('main2', {
})
},duration)
},
async getAccess_token(params={}) {
//清除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) {
// newUser.value = res.data.newUser
// res.data.newUser = true // 开发阶段专用,正式版请删除或注释
if(res.data.newUser) { // 新用户,不做任何缓存动作,跳转登录页
let userId = res.data.userId
let res_p=await new Promise(resolve=>{
uni.login({
provider: 'weixin', //使用微信登录
success: function (loginRes) {
resolve(loginRes);
// console.log(loginRes,'微信登录返回信息');
}
});
});
// 正式版记住放开下面这行注释掉的代码
uni.setStorageSync('access_token','Bearer '+res.data.access_token);// 为了wx登录成功,必须token单独缓存一次
let res2= await api.wx_login({code:res_p.code},userId);
if(res2.code === 0) {
// this.checkLogin()
// this.toLogin(encodeURIComponent(JSON.stringify(res.data))) // 跳转登录页,但是我不想这么做
this.toProfile(encodeURIComponent(JSON.stringify(res.data)))
}
}
else{
let res_form = {}
uni.setStorageSync('avatarUrl', res.data.avatar);//avatarUrl
res_form = res.data
res_form.access_token = 'Bearer '+res.data.access_token
let userId = res.data.userId
uni.setStorageSync('access_token',res_form.access_token);// token单独缓存一次
this.wx_login(userId, res_form)
}
}
else{
uni.showToast({
icon:"error",
title:res.msg,
duration:2000
})
}
},
async wx_login(userId, res_form) {
let res=await new Promise(resolve=>{
uni.login({
provider: 'weixin', //使用微信登录
success: function (loginRes) {
resolve(loginRes);
}
});
});
let res2 = await api.wx_login({code:res.code},userId);
if(res2.code === 0) {
uni.setStorageSync('userInfo',JSON.stringify(res_form))
this.checkLogin()
}
else{
uni.clearStorage();
}
},
toLogin(token_info) {
uni.navigateTo({
url:"/pages/login/login?token_info="+token_info
})
},
toProfile(token_info = null) {
uni.navigateTo({
url:"/pages/user/userInfo?token_info="+token_info
})
}
}
})

View File

@@ -0,0 +1,23 @@
## 1.2.52023-03-29
- 新增 pattern.icon 属性,可自定义图标
## 1.2.42022-09-07
小程序端由于 style 使用了对象导致报错,[详情](https://ask.dcloud.net.cn/question/152790?item_id=211778&rf=false)
## 1.2.32022-09-05
- 修复 nvue 环境下,具有 tabBar 时fab 组件下部位置无法正常获取 --window-bottom 的bug详见[https://ask.dcloud.net.cn/question/110638?notification_id=826310](https://ask.dcloud.net.cn/question/110638?notification_id=826310)
## 1.2.22021-12-29
- 更新 组件依赖
## 1.2.12021-11-19
- 修复 阴影颜色不正确的bug
## 1.2.02021-11-19
- 优化 组件UI并提供设计资源详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-fab](https://uniapp.dcloud.io/component/uniui/uni-fab)
## 1.1.12021-11-09
- 新增 提供组件设计资源,组件样式调整
## 1.1.02021-07-30
- 组件兼容 vue3如何创建vue3项目详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
## 1.0.72021-05-12
- 新增 组件示例地址
## 1.0.62021-02-05
- 调整为uni_modules目录规范
- 优化 按钮背景色调整
- 优化 兼容pc端

View File

@@ -0,0 +1,491 @@
<template>
<view class="uni-cursor-point">
<view v-if="popMenu && (leftBottom||rightBottom||leftTop||rightTop) && content.length > 0" :class="{
'uni-fab--leftBottom': leftBottom,
'uni-fab--rightBottom': rightBottom,
'uni-fab--leftTop': leftTop,
'uni-fab--rightTop': rightTop
}" class="uni-fab"
:style="nvueBottom"
>
<view :class="{
'uni-fab__content--left': horizontal === 'left',
'uni-fab__content--right': horizontal === 'right',
'uni-fab__content--flexDirection': direction === 'vertical',
'uni-fab__content--flexDirectionStart': flexDirectionStart,
'uni-fab__content--flexDirectionEnd': flexDirectionEnd,
'uni-fab__content--other-platform': !isAndroidNvue
}" :style="{ width: boxWidth, height: boxHeight, backgroundColor: styles.backgroundColor }"
class="uni-fab__content" elevation="5">
<view v-if="flexDirectionStart || horizontalLeft" class="uni-fab__item uni-fab__item--first" />
<view v-for="(item, index) in content" :key="index" :class="{ 'uni-fab__item--active': isShow }"
class="uni-fab__item" @click="_onItemClick(index, item)">
<image :src="item.active ? item.selectedIconPath : item.iconPath" class="uni-fab__item-image"
mode="aspectFit" />
<text class="uni-fab__item-text"
:style="{ color: item.active ? styles.selectedColor : styles.color }">{{ item.text }}</text>
</view>
<view v-if="flexDirectionEnd || horizontalRight" class="uni-fab__item uni-fab__item--first" />
</view>
</view>
<view :class="{
'uni-fab__circle--leftBottom': leftBottom,
'uni-fab__circle--rightBottom': rightBottom,
'uni-fab__circle--leftTop': leftTop,
'uni-fab__circle--rightTop': rightTop,
'uni-fab__content--other-platform': !isAndroidNvue
}" class="uni-fab__circle uni-fab__plus" :style="{ 'background-color': styles.buttonColor, 'bottom': nvueBottom }" @click="_onClick">
<uni-icons class="fab-circle-icon" :type="styles.icon" :color="styles.iconColor" size="32"
:class="{'uni-fab__plus--active': isShow && content.length > 0}"></uni-icons>
<!-- <view class="fab-circle-v" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view>
<view class="fab-circle-h" :class="{'uni-fab__plus--active': isShow && content.length > 0}"></view> -->
</view>
</view>
</template>
<script>
let platform = 'other'
// #ifdef APP-NVUE
platform = uni.getSystemInfoSync().platform
// #endif
/**
* Fab 悬浮按钮
* @description 点击可展开一个图形按钮菜单
* @tutorial https://ext.dcloud.net.cn/plugin?id=144
* @property {Object} pattern 可选样式配置项
* @property {Object} horizontal = [left | right] 水平对齐方式
* @value left 左对齐
* @value right 右对齐
* @property {Object} vertical = [bottom | top] 垂直对齐方式
* @value bottom 下对齐
* @value top 上对齐
* @property {Object} direction = [horizontal | vertical] 展开菜单显示方式
* @value horizontal 水平显示
* @value vertical 垂直显示
* @property {Array} content 展开菜单内容配置项
* @property {Boolean} popMenu 是否使用弹出菜单
* @event {Function} trigger 展开菜单点击事件,返回点击信息
* @event {Function} fabClick 悬浮按钮点击事件
*/
export default {
name: 'UniFab',
emits: ['fabClick', 'trigger'],
props: {
pattern: {
type: Object,
default () {
return {}
}
},
horizontal: {
type: String,
default: 'left'
},
vertical: {
type: String,
default: 'bottom'
},
direction: {
type: String,
default: 'horizontal'
},
content: {
type: Array,
default () {
return []
}
},
show: {
type: Boolean,
default: false
},
popMenu: {
type: Boolean,
default: true
}
},
data() {
return {
fabShow: false,
isShow: false,
isAndroidNvue: platform === 'android',
styles: {
color: '#3c3e49',
selectedColor: '#007AFF',
backgroundColor: '#fff',
buttonColor: '#007AFF',
iconColor: '#fff',
icon: 'plusempty'
}
}
},
computed: {
contentWidth(e) {
return (this.content.length + 1) * 55 + 15 + 'px'
},
contentWidthMin() {
return '55px'
},
// 动态计算宽度
boxWidth() {
return this.getPosition(3, 'horizontal')
},
// 动态计算高度
boxHeight() {
return this.getPosition(3, 'vertical')
},
// 计算左下位置
leftBottom() {
return this.getPosition(0, 'left', 'bottom')
},
// 计算右下位置
rightBottom() {
return this.getPosition(0, 'right', 'bottom')
},
// 计算左上位置
leftTop() {
return this.getPosition(0, 'left', 'top')
},
rightTop() {
return this.getPosition(0, 'right', 'top')
},
flexDirectionStart() {
return this.getPosition(1, 'vertical', 'top')
},
flexDirectionEnd() {
return this.getPosition(1, 'vertical', 'bottom')
},
horizontalLeft() {
return this.getPosition(2, 'horizontal', 'left')
},
horizontalRight() {
return this.getPosition(2, 'horizontal', 'right')
},
// 计算 nvue bottom
nvueBottom() {
const safeBottom = uni.getSystemInfoSync().windowBottom;
// #ifdef APP-NVUE
return 30 + safeBottom
// #endif
// #ifndef APP-NVUE
return 30
// #endif
}
},
watch: {
pattern: {
handler(val, oldVal) {
this.styles = Object.assign({}, this.styles, val)
},
deep: true
}
},
created() {
this.isShow = this.show
if (this.top === 0) {
this.fabShow = true
}
// 初始化样式
this.styles = Object.assign({}, this.styles, this.pattern)
},
methods: {
_onClick() {
this.$emit('fabClick')
if (!this.popMenu) {
return
}
this.isShow = !this.isShow
},
open() {
this.isShow = true
},
close() {
this.isShow = false
},
/**
* 按钮点击事件
*/
_onItemClick(index, item) {
if (!this.isShow) {
return
}
this.$emit('trigger', {
index,
item
})
},
/**
* 获取 位置信息
*/
getPosition(types, paramA, paramB) {
if (types === 0) {
return this.horizontal === paramA && this.vertical === paramB
} else if (types === 1) {
return this.direction === paramA && this.vertical === paramB
} else if (types === 2) {
return this.direction === paramA && this.horizontal === paramB
} else {
return this.isShow && this.direction === paramA ? this.contentWidth : this.contentWidthMin
}
}
}
}
</script>
<style lang="scss" >
$uni-shadow-base:0 1px 5px 2px rgba($color: #000000, $alpha: 0.3) !default;
.uni-fab {
position: fixed;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
z-index: 10;
border-radius: 45px;
box-shadow: $uni-shadow-base;
}
.uni-cursor-point {
/* #ifdef H5 */
cursor: pointer;
/* #endif */
}
.uni-fab--active {
opacity: 1;
}
.uni-fab--leftBottom {
left: 15px;
bottom: 30px;
/* #ifdef H5 */
left: calc(15px + var(--window-left));
bottom: calc(30px + var(--window-bottom));
/* #endif */
// padding: 10px;
}
.uni-fab--leftTop {
left: 15px;
top: 30px;
/* #ifdef H5 */
left: calc(15px + var(--window-left));
top: calc(30px + var(--window-top));
/* #endif */
// padding: 10px;
}
.uni-fab--rightBottom {
right: 15px;
bottom: 30px;
/* #ifdef H5 */
right: calc(15px + var(--window-right));
bottom: calc(30px + var(--window-bottom));
/* #endif */
// padding: 10px;
}
.uni-fab--rightTop {
right: 15px;
top: 30px;
/* #ifdef H5 */
right: calc(15px + var(--window-right));
top: calc(30px + var(--window-top));
/* #endif */
// padding: 10px;
}
.uni-fab__circle {
position: fixed;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
width: 55px;
height: 55px;
background-color: #3c3e49;
border-radius: 45px;
z-index: 11;
// box-shadow: $uni-shadow-base;
}
.uni-fab__circle--leftBottom {
left: 15px;
bottom: 30px;
/* #ifdef H5 */
left: calc(15px + var(--window-left));
bottom: calc(30px + var(--window-bottom));
/* #endif */
}
.uni-fab__circle--leftTop {
left: 15px;
top: 30px;
/* #ifdef H5 */
left: calc(15px + var(--window-left));
top: calc(30px + var(--window-top));
/* #endif */
}
.uni-fab__circle--rightBottom {
right: 15px;
bottom: 30px;
/* #ifdef H5 */
right: calc(15px + var(--window-right));
bottom: calc(30px + var(--window-bottom));
/* #endif */
}
.uni-fab__circle--rightTop {
right: 15px;
top: 30px;
/* #ifdef H5 */
right: calc(15px + var(--window-right));
top: calc(30px + var(--window-top));
/* #endif */
}
.uni-fab__circle--left {
left: 0;
}
.uni-fab__circle--right {
right: 0;
}
.uni-fab__circle--top {
top: 0;
}
.uni-fab__circle--bottom {
bottom: 0;
}
.uni-fab__plus {
font-weight: bold;
}
// .fab-circle-v {
// position: absolute;
// width: 2px;
// height: 24px;
// left: 0;
// top: 0;
// right: 0;
// bottom: 0;
// /* #ifndef APP-NVUE */
// margin: auto;
// /* #endif */
// background-color: white;
// transform: rotate(0deg);
// transition: transform 0.3s;
// }
// .fab-circle-h {
// position: absolute;
// width: 24px;
// height: 2px;
// left: 0;
// top: 0;
// right: 0;
// bottom: 0;
// /* #ifndef APP-NVUE */
// margin: auto;
// /* #endif */
// background-color: white;
// transform: rotate(0deg);
// transition: transform 0.3s;
// }
.fab-circle-icon {
transform: rotate(0deg);
transition: transform 0.3s;
font-weight: 200;
}
.uni-fab__plus--active {
transform: rotate(135deg);
}
.uni-fab__content {
/* #ifndef APP-NVUE */
box-sizing: border-box;
display: flex;
/* #endif */
flex-direction: row;
border-radius: 55px;
overflow: hidden;
transition-property: width, height;
transition-duration: 0.2s;
width: 55px;
border-color: #DDDDDD;
border-width: 1rpx;
border-style: solid;
}
.uni-fab__content--other-platform {
border-width: 0px;
box-shadow: $uni-shadow-base;
}
.uni-fab__content--left {
justify-content: flex-start;
}
.uni-fab__content--right {
justify-content: flex-end;
}
.uni-fab__content--flexDirection {
flex-direction: column;
justify-content: flex-end;
}
.uni-fab__content--flexDirectionStart {
flex-direction: column;
justify-content: flex-start;
}
.uni-fab__content--flexDirectionEnd {
flex-direction: column;
justify-content: flex-end;
}
.uni-fab__item {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: center;
align-items: center;
width: 55px;
height: 55px;
opacity: 0;
transition: opacity 0.2s;
}
.uni-fab__item--active {
opacity: 1;
}
.uni-fab__item-image {
width: 20px;
height: 20px;
margin-bottom: 4px;
}
.uni-fab__item-text {
color: #FFFFFF;
font-size: 12px;
line-height: 12px;
margin-top: 2px;
}
.uni-fab__item--first {
width: 55px;
}
</style>

View File

@@ -0,0 +1,84 @@
{
"id": "uni-fab",
"displayName": "uni-fab 悬浮按钮",
"version": "1.2.5",
"description": "悬浮按钮 fab button ,点击可展开一个图标按钮菜单。",
"keywords": [
"uni-ui",
"uniui",
"按钮",
"悬浮按钮",
"fab"
],
"repository": "https://github.com/dcloudio/uni-ui",
"engines": {
"HBuilderX": ""
},
"directories": {
"example": "../../temps/example_temps"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
},
"uni_modules": {
"dependencies": ["uni-scss","uni-icons"],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"App": {
"app-vue": "y",
"app-nvue": "y"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y"
},
"快应用": {
"华为": "u",
"联盟": "u"
},
"Vue": {
"vue2": "y",
"vue3": "y"
}
}
}
}
}

View File

@@ -0,0 +1,9 @@
## Fab 悬浮按钮
> **组件名uni-fab**
> 代码块: `uFab`
点击可展开一个图形按钮菜单
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-fab)
#### 如使用过程中有任何问题或者您对uni-ui有一些好的建议欢迎加入 uni-ui 交流群871950839

View File

@@ -103,9 +103,20 @@ export default {
return { m: s * 1000, km: Number(s.toFixed(2)) }
},
checkLogin(){
let token = uni.getStorageSync('access_token')
console.log(token)
if(token){
// let token = uni.getStorageSync('access_token')
let u_info = uni.getStorageSync('userInfo')
if(u_info){
return true
}
else{
return false
}
},
// 有缓存信息,就访问登录接口,没有缓存就直接返回未登录
checkLoginPro(){
// let token = uni.getStorageSync('access_token')
let u_info = uni.getStorageSync('userInfo')
if(u_info){ // 有缓存信息,访问登录接口
return true
}
else{