2022-01-01 09:47:29 +00:00
< template >
< view >
<!-- 状态栏 -- >
< status -nav :titleVal ="'写日记'" :statusTitle ="true" > < / s t a t u s - n a v >
< view : style = "{paddingTop: statusHNH+'px'}" class = "pad-zy20" >
< view class = "mar-s30 bacf pad20" style = "border-radius: 20rpx 20rpx 0 0;" >
<!-- 日记标题 -- >
< view class = "disac mar-s20" >
< view class = "mar-y20 flexs titlel2" > 日记标题 < / view >
< view class = "width100 radius10 pad-zy20 borbot-cc height-68" >
< input v -model = " diary_title " class = "fon28 height-68" type = "text" value = "" placeholder = "今天是2021年的最后一天" placeholder -style = " color : # 999999 ; " / >
< / view >
< / view >
<!-- 详细内容 -- >
< view class = "dis mar-s20" >
< view class = "mar-y20 flexs mar-s20 titlel2" > 详细内容 < / view >
< view class = "width100 radius10 pad20 borbot-cc" style = "height: 300rpx;" >
< textarea v -model = " diary_content " class = "fon28" maxlength = "500" style = "height: 300rpx;width: auto;" placeholder = "请输入详细内容" placeholder -style = " color : # 999999 ; " / >
2022-01-03 07:54:22 +00:00
<!-- < editor id = "editor" class = "ql-container" :placeholder ="placeholder" @ready ="onEditorReady" > < / editor > - - >
2022-01-01 09:47:29 +00:00
< / view >
< / view >
<!-- 选择病种 -- >
< view class = "disac pad-s32" >
< view class = "flexs mar-y20 titlel2" > 选择病种 < / view >
<!-- 下拉列表 -- >
< view @tap ="openXial(0)" class = "disjbac width100 radius10 pad-zy20 xiala posir" >
< view > { { disease } } < / view >
< image :class ="isdisease?'zhuan':'nozhuan'" src = "/static/public/sanj.png" mode = "aspectFill" > < / image >
< view v-if ="isdisease" class="posia bacf radius10 xial-box mar-s20" >
< view class = "pad-zy20 xial-item-box" >
< view @tap ="chooseXia(indexl,0)" :class ="diseaseCurrent==indexl?'pcol':''" v-for ="(iteml,indexl) in diseaseArr" :key ="indexl" > {{ iteml.title }} < / view >
< / view >
< / view >
< / view >
< / view >
<!-- 关联医生 -- >
< view class = "disac pad-s32" >
< view class = "flexs mar-y20 titlel2" > 关联医生 < / view >
<!-- 下拉列表 -- >
< view @tap ="openXial(1)" class = "disjbac width100 radius10 pad-zy20 xiala posir" >
< view > { { diary _doctor } } < / view >
< image :class ="isdiary_doctor?'zhuan':'nozhuan'" src = "/static/public/sanj.png" mode = "aspectFill" > < / image >
< view v-if ="isdiary_doctor" class="posia bacf radius10 xial-box mar-s20" >
< view class = "pad-zy20 xial-item-box" >
< view @tap ="chooseXia(indexl,1)" :class ="diary_doctorCurrent==indexl?'pcol':''" v-for ="(iteml,indexl) in diary_doctorArr" :key ="indexl" > {{ iteml.title }} < / view >
< / view >
< / view >
< / view >
< / view >
<!-- 添加封面 -- >
< view class = "dis mar-s20" >
< view class = "mar-y20 flexs titlel2" > 添加封面 < / view >
< view class = "width100" >
2022-01-03 07:54:22 +00:00
< view v-if ="fengImg!=''" class="posir" style="width: 32%;" >
2022-01-01 09:47:29 +00:00
< image :src ="fengImg" class = "diary-item-img" style = "width: 100%;" mode = "aspectFill" > < / image >
< image @tap ="clearfengImg" src = "../../static/public/closequan.png" class = "posia" style = "width: 20px;height: 20px;right: 10rpx;top: 10rpx;" mode = "" > < / image >
< / view >
< image v -else @tap ="updataImg(0)" class = "diary-item-img" src = "../../static/public/diary-add.png" mode = "aspectFill" > < / image >
< / view >
< / view >
<!-- 添加图片 -- >
< view class = "dis mar-s20" >
< view class = "mar-y20 flexs titlel2" > 添加图片 < / view >
< view class = "width100 disac fw" >
< view v-for ="(item,index) in imgArr" :key="index" class="diary-item-img posir" >
< image :src ="item" mode = "aspectFill" class = "addImg" > < / image >
< image @tap ="clearaddImg(index)" src = "../../static/public/closequan.png" class = "posia" style = "width: 20px;height: 20px;right: 10rpx;top: 10rpx;" mode = "" > < / image >
< / view >
< image v-if ="imgArr.length!=9" @tap="updataImg(1)" class="diary-item-img" src="../../static/public/diary-add.png" mode="aspectFill" > < / image >
< / view >
< / view >
<!-- 底部按钮 -- >
< view style = "margin-top: 87rpx;margin-bottom: 30rpx;" >
2022-01-03 07:54:22 +00:00
< view @tap ="submit" class = "fon30 radius20 tc colf bold" style = "margin: 0 83rpx;height: 90rpx;line-height: 90rpx;" :style ="{background:publicColor}" > 立即提交 < / view >
2022-01-01 09:47:29 +00:00
< / view >
< / view >
< / view >
2022-03-04 08:48:40 +00:00
<!-- 用户信息授权 , 手机号授权 -- >
< auth -userInfo -mobileInfo > < / a u t h - u s e r I n f o - m o b i l e I n f o >
2022-01-01 09:47:29 +00:00
< / view >
< / template >
< script >
import { base64ToPath } from '@/jsFile/base64-src.js' ;
import { checkBanner } from '@/jsFile/publicAPI.js' ;
export default {
data ( ) {
return {
2022-03-04 08:48:40 +00:00
statusHNH : uni . getStorageSync ( 'electric_nav_height' ) ,
2022-01-01 09:47:29 +00:00
publicColor : uni . getStorageSync ( 'publicColor' ) ,
optionObj : '' ,
diary _title : '' , //日记标题
diary _content : '' , //详细内容
disease : '请选择病种' , //病种
disease _id : '' , //病种id
isdisease : false ,
diseaseArr : [ ] ,
diseaseCurrent : 0 ,
diary _doctor : '请选择关联医生' , //医生
diary _doctor _id : '' , //医生id
isdiary _doctor : false ,
diary _doctorArr : [ ] ,
diary _doctorCurrent : 0 ,
fengImg : '' ,
imgArr : [ ] ,
2022-01-03 07:54:22 +00:00
placeholder : '开始输入...'
2022-01-01 09:47:29 +00:00
}
} ,
onShow ( ) {
2022-03-04 08:48:40 +00:00
this . $toolAll . tools . isLogin ( ) ;
2022-01-01 09:47:29 +00:00
} ,
onLoad ( options ) {
2022-03-21 01:44:07 +00:00
if ( uni . getStorageSync ( 'phone_active' ) != 0 && uni . getStorageSync ( 'is_active' ) != 0 ) {
2022-03-04 08:48:40 +00:00
// 查询要编辑日记的信息
if ( options . id != undefined ) {
this . checkDiaryInfo ( options . id ) ;
}
this . diseaseEv ( ) ;
this . chooseEv ( ) ;
2022-01-01 09:47:29 +00:00
}
} ,
methods : {
2022-01-03 07:54:22 +00:00
onEditorReady ( ) {
// #ifdef MP-BAIDU
this . editorCtx = requireDynamicLib ( 'editorLib' ) . createEditorContext ( 'editorId' ) ;
// #endif
// #ifdef APP-PLUS || H5 ||MP-WEIXIN
uni . createSelectorQuery ( ) . select ( '#editor' ) . context ( ( res ) => {
this . editorCtx = res . context
} ) . exec ( )
// #endif
2022-01-01 09:47:29 +00:00
} ,
openXial ( index ) {
if ( index == 0 ) {
this . isdisease = ! this . isdisease
}
if ( index == 1 ) {
this . isdiary _doctor = ! this . isdiary _doctor
}
} ,
chooseXia ( index , num ) { //预约类别选择事件
if ( num == 0 ) {
this . diseaseCurrent = index
this . disease = this . diseaseArr [ index ] . title
this . disease _id = this . diseaseArr [ index ] . id
} else {
this . diary _doctorCurrent = index
this . diary _doctor = this . diary _doctorArr [ index ] . title
this . diary _doctor _id = this . diary _doctorArr [ index ] . id
}
} ,
// 病种列表事件
diseaseEv ( ) {
this . $requst . post ( 'archives/disease' ) . then ( res => {
// console.log('病种列表:',res);
if ( res . code == 0 && res . data . length != 0 ) {
this . diseaseArr = [ ]
res . data . forEach ( item => {
let obj = {
id : item . id ,
title : item . name ,
pid : item . pid ,
sort : item . sort
}
this . diseaseArr . push ( obj )
} )
// this.disease = this.diseaseArr[0].title;
// this.disease_id = this.diseaseArr[0].id;
}
} , error => { } )
} ,
chooseEv ( ) { //查询医生列表
this . $requst . post ( 'user/doctor-list' , { page : 1 , size : 1000 } ) . then ( res => {
if ( res . code == 0 ) {
this . diary _doctorArr = [ ] ;
if ( res . data . list . length ) {
res . data . list . forEach ( item => {
let obj = {
id : item . id ,
title : item . name
}
this . diary _doctorArr . push ( obj )
} )
// this.diary_doctor = this.diary_doctorArr[0].title
// this.diary_doctor_id = this.diary_doctorArr[0].id
} else this . $toolAll . tools . showToast ( '暂无医生可选' ) ;
} else this . $toolAll . tools . showToast ( res . msg ) ;
} )
} ,
2022-01-03 07:54:22 +00:00
// 图片上传
2022-01-01 09:47:29 +00:00
updataImg ( index ) {
if ( index == 0 ) {
uni . chooseImage ( {
count : 1 ,
sourceType : [ 'album' ] ,
success : ( res ) => {
let tempImg = res . tempFilePaths [ 0 ] ;
this . $requst . upload ( 'file/upload/image' , { file : tempImg } ) . then ( res => {
this . fengImg = this . $http + res . data . src ;
this . $toolAll . tools . showToast ( '图片上传成功(*^▽^*)' )
} , error => { } )
}
} )
} else {
uni . chooseImage ( {
count : 9 ,
sourceType : [ 'album' ] ,
success : ( res ) => {
let tempImg = res . tempFilePaths ;
let num = 0 ;
for ( var i = 0 ; i < tempImg . length ; i ++ ) {
num ++ ;
this . $requst . upload ( 'file/upload/image' , { file : tempImg [ i ] } ) . then ( res => {
if ( this . imgArr . length != 9 ) {
this . imgArr . push ( this . $http + res . data . src ) ;
}
if ( num == tempImg . length ) {
this . $toolAll . tools . showToast ( '上传成功(*^▽^*)' )
} else {
this . $toolAll . tools . showToast ( '上传中...' )
}
} , error => { } )
}
}
} )
}
} ,
clearfengImg ( ) {
this . fengImg = '' ;
} ,
clearaddImg ( index ) {
this . imgArr . splice ( index , 1 ) ;
} ,
2022-01-03 07:54:22 +00:00
// 保存图片
2022-01-01 09:47:29 +00:00
submit ( ) {
if ( this . diary _title == '' ) {
this . $toolAll . tools . showToast ( '请输入日记标题' ) ;
} else if ( this . diary _content == '' ) {
this . $toolAll . tools . showToast ( '请输入详细内容' ) ;
} else if ( this . disease _id == '' ) {
this . $toolAll . tools . showToast ( '请选择病种' ) ;
} else if ( this . diary _doctor _id == '' ) {
this . $toolAll . tools . showToast ( '请关联医生' ) ;
} else if ( this . fengImg == '' ) {
this . $toolAll . tools . showToast ( '请添加封面图' ) ;
} else {
let params = {
title : this . diary _title ,
images : this . imgArr . join ( ',' ) ,
cover : this . fengImg ,
disease _id : this . disease _id ,
disease _name : this . disease ,
content : this . diary _content ,
doctor _id : this . diary _doctor _id ,
doctor _name : this . diary _doctor ,
id : ''
}
2022-01-03 07:54:22 +00:00
console . log ( params ) ;
this . $requst . post ( 'user/diary-save' , params ) . then ( res => {
2022-01-01 09:47:29 +00:00
if ( res . code == 0 ) {
this . $toolAll . tools . showToast ( '保存成功' ) ;
uni . navigateBack ( { delta : 1 } )
} else this . $toolAll . tools . showToast ( res . msg ) ;
} , error => { } )
}
} ,
// 查询要编辑日记的信息
// checkDiaryInfo(id){
// this.$requst.get('user/diary-info',{id:id}).then(res=>{
// if(res.code==0){
// if(this.page==1) this.dataList = [];
// this.total = res.data.total;
// } else this.$toolAll.tools.showToast(res.msg);
// },error=>{})
// }
}
}
< / script >
< style >
< / style >