addDocRecord.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <view class="text-content">
  5. <view class="title">
  6. <text class="black">健康记录</text>
  7. </view>
  8. <textarea class="textArea" maxlength="200" @input="contentInput" placeholder="请填写健康记录,我们会匹配专业的医师为您回复"></textarea>
  9. </view>
  10. <view class="img-content">
  11. <view class="title">
  12. <text class="black">上传图片</text>
  13. </view>
  14. <view class="upload-img">
  15. <view class="img" v-for="(item,index) in imgList" :key="index" >
  16. <image :src="item" mode="aspectFill" @click="previewImage(index)"></image>
  17. <view class="del" @click="delImg(index)" >
  18. <image src="/static/images/del2.png"></image>
  19. </view>
  20. </view>
  21. <view class="chose-img" @tap="chooseImage(1)" v-if="imgList.length<4">
  22. <image src="/static/images/adds.png"></image>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="btn-box">
  28. <view class="sub-btn" @click="submit()">提交记录</view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import {getDocDetails,addDocRecord} from '@/api/doc.js'
  34. export default {
  35. data() {
  36. return {
  37. imgList: [],
  38. docId:null,
  39. form: {
  40. images:[],
  41. title:""
  42. }
  43. };
  44. },
  45. onLoad(option) {
  46. this.docId=option.docId;
  47. },
  48. methods:{
  49. contentInput(e) {
  50. this.form.title = e.detail.value
  51. },
  52. // 选择图片
  53. chooseImage(type) {
  54. var that=this;
  55. uni.chooseImage({
  56. count: 4, //默认9
  57. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  58. sourceType: ['album', 'camera'], //从相册选择
  59. success: (res) => {
  60. uni.uploadFile({
  61. url: uni.getStorageSync('requestPath')+'/app/common/uploadOSS', //仅为示例,非真实的接口地址
  62. filePath: res.tempFilePaths[0],
  63. name: 'file',
  64. success: (res) => {
  65. that.imgList.push(JSON.parse( res.data).url)
  66. }
  67. });
  68. }
  69. });
  70. },
  71. //图片预览
  72. previewImage(index){
  73. //预览图片
  74. uni.previewImage({
  75. urls: this.imgList,
  76. current: this.imgList[index]
  77. });
  78. },
  79. delImg(index) {
  80. uni.showModal({
  81. title: '提示',
  82. content: '确定要删除这张图片吗?',
  83. cancelText: '取消',
  84. confirmText: '确定',
  85. success: res => {
  86. if (res.confirm) {
  87. this.imgList.splice(index, 1);
  88. }
  89. }
  90. })
  91. },
  92. submit(){
  93. var that=this;
  94. if(this.form.title==""){
  95. uni.showToast({
  96. icon:'none',
  97. title: "请输入健康记录内容"
  98. });
  99. return;
  100. }
  101. uni.showLoading({
  102. title:"正在处理中"
  103. })
  104. var data={
  105. docId:this.docId,
  106. title:this.form.title,
  107. images:this.imgList.toString()
  108. }
  109. addDocRecord(data).then(
  110. res => {
  111. if(res.code==200){
  112. uni.hideLoading()
  113. uni.showToast({
  114. icon:'success',
  115. title:res.msg,
  116. });
  117. uni.$emit('refreshDocRecord');
  118. setTimeout(function(){
  119. uni.navigateBack({
  120. delta:1
  121. })
  122. },200);
  123. }else{
  124. uni.showToast({
  125. icon:'none',
  126. title: res.msg,
  127. });
  128. }
  129. },
  130. rej => {}
  131. );
  132. },
  133. }
  134. }
  135. </script>
  136. <style lang="scss">
  137. page{
  138. height: 100%;
  139. }
  140. .content{
  141. height: 100%;
  142. display: flex;
  143. flex-direction: column;
  144. justify-content: space-between;
  145. .inner{
  146. height: calc(100% - 120upx);
  147. padding: 20upx;
  148. .text-content{
  149. box-sizing: border-box;
  150. min-height: 286upx;
  151. background: #FFFFFF;
  152. border-radius: 16upx;
  153. padding: 40upx 30upx 22upx;
  154. margin-top: 20upx;
  155. .title{
  156. display: flex;
  157. align-items: center;
  158. align-items: flex-end;
  159. .black{
  160. font-size: 32upx;
  161. font-family: PingFang SC;
  162. font-weight: bold;
  163. color: #111111;
  164. line-height: 1;
  165. }
  166. .gray{
  167. font-size: 26upx;
  168. font-family: PingFang SC;
  169. color: #999999;
  170. line-height: 1;
  171. margin-left: 10upx;
  172. }
  173. }
  174. .textArea{
  175. margin: 30rpx 0rpx 0rpx 0rpx;
  176. width: 100%;
  177. }
  178. }
  179. .img-content{
  180. box-sizing: border-box;
  181. min-height: 286upx;
  182. background: #FFFFFF;
  183. border-radius: 16upx;
  184. padding: 40upx 30upx 22upx;
  185. margin-top: 20upx;
  186. margin-bottom: 20upx;
  187. .title{
  188. display: flex;
  189. align-items: center;
  190. align-items: flex-end;
  191. .black{
  192. font-size: 32upx;
  193. font-family: PingFang SC;
  194. font-weight: bold;
  195. color: #111111;
  196. line-height: 1;
  197. margin-left: 10upx;
  198. }
  199. .gray{
  200. font-size: 28upx;
  201. font-family: PingFang SC;
  202. color: #999999;
  203. line-height: 1;
  204. margin-left: 10upx;
  205. }
  206. }
  207. .textArea{
  208. margin: 30rpx 0rpx 0rpx 0rpx;
  209. width: 100%;
  210. }
  211. .upload-img{
  212. margin: 30rpx 0rpx 0rpx 0rpx;
  213. width: 100%;
  214. display: flex;
  215. align-items: flex-start;
  216. .img{
  217. margin-right: 10rpx;
  218. width: 100rpx;
  219. height: 100rpx;
  220. position: relative;
  221. image{
  222. width: 100%;
  223. height: 100%;
  224. }
  225. .del{
  226. right:0rpx;
  227. top:0rpx;
  228. position: absolute;
  229. image{
  230. width: 30rpx;
  231. height:30rpx;
  232. }
  233. }
  234. }
  235. .chose-img{
  236. box-sizing: border-box;
  237. border-radius: 5rpx;
  238. border: 1px solid #eee;
  239. display: flex;
  240. align-items: center;
  241. justify-content: center;
  242. width: 100rpx;
  243. height: 100rpx;
  244. image{
  245. width: 50rpx;
  246. height: 50rpx;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. .btn-box{
  253. height: 120upx;
  254. padding: 0 30upx;
  255. display: flex;
  256. align-items: center;
  257. justify-content: center;
  258. background: #FFFFFF;
  259. .sub-btn{
  260. width: 100%;
  261. height: 88upx;
  262. line-height: 88upx;
  263. text-align: center;
  264. font-size: 30upx;
  265. font-family: PingFang SC;
  266. font-weight: bold;
  267. color: #FFFFFF;
  268. background: #018C39;
  269. border-radius: 44upx;
  270. }
  271. }
  272. }
  273. </style>