submitOrder.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <!-- 选择问诊人 -->
  5. <view class="chose-people">
  6. <view class="title-box">
  7. <text class="title">选择问诊人</text>
  8. <view class="add-box">
  9. <image src="@/static/images/add26.png" mode=""></image>
  10. <text @click="addPeople">添加</text>
  11. </view>
  12. </view>
  13. <view class="peop-list">
  14. <view v-for="(item,index) in patient" :key="index" :class="patientId == item.patientId?'item active':'item'" @click="chosePatient(item)">
  15. <view class="name">{{ item.patientName }}</view>
  16. <view class="info">
  17. <text class="sex" v-if="item.gender==1">男</text>
  18. <text class="sex" v-if="item.gender==2">女</text>
  19. <text class="ege">{{utils.getAge(item.birthday)}}岁</text>
  20. </view>
  21. <!-- 选中的对号角标 -->
  22. <image v-if="patientId == item.patientId" class="active-img" src="@/static/images/sel_right50.png" mode=""></image>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 病情描述 -->
  27. <view class="desc">
  28. <textarea
  29. v-model="remark"
  30. placeholder="请描述您的病情..."
  31. placeholder-style="color:#999999;font-size:30rpx;"
  32. />
  33. <!-- 上传图片描述 -->
  34. <view class="upload-des">
  35. <view class="label-box">
  36. <text class="black">上传疾病部位照片</text>
  37. <text class="gray">(选填)</text>
  38. </view>
  39. <view class="num-box">
  40. <text class="black">{{ imgList.length }}</text>
  41. <text class="gray">/3</text>
  42. </view>
  43. </view>
  44. <!-- 多图上传 -->
  45. <view class="upload-box">
  46. <!-- 上传的图片列表 -->
  47. <view class="img-item" v-for="(item,index) in imgList" :key="index" @tap="viewImage" :data-url="imgList[index]">
  48. <image class="img" :src="item" mode="aspectFill"></image>
  49. <image class="close-img" src="@/static/images/close32.png" mode="" @tap.stop="delImg" :data-index="index"></image>
  50. </view>
  51. <!-- 上传图片按钮 -->
  52. <view class="uoload-btn" @tap="chooseImage" v-if="imgList.length<3">
  53. <image src="@/static/images/photo.png" mode=""></image>
  54. <text>上传照片</text>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="btn-box">
  60. <view class="btn" @click="submitOrder()">发布问诊</view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import {getPatientList} from '@/api/patient'
  66. import {uploadOSS} from '@/api/common.js'
  67. import {create} from '@/api/doctorOrder.js'
  68. export default {
  69. data() {
  70. return {
  71. patient:[],
  72. patientId:null,
  73. priceId:null,
  74. doctorId:null,
  75. remark:"",
  76. // 选择上传的图片
  77. imgList: [],
  78. photos:[],
  79. };
  80. },
  81. onLoad(option) {
  82. this.doctorId=option.doctorId;
  83. this.priceId=option.priceId;
  84. this.getPatientList();
  85. uni.$on('refreshPatient', () => {
  86. this.getPatientList()
  87. })
  88. },
  89. methods:{
  90. getPatientList(){
  91. uni.showLoading({
  92. title:"正在加载中"
  93. })
  94. getPatientList().then(
  95. res => {
  96. uni.hideLoading()
  97. if(res.code==200){
  98. this.patient=res.data;
  99. }else{
  100. uni.showToast({
  101. icon:'none',
  102. title: "请求失败",
  103. });
  104. }
  105. },
  106. rej => {}
  107. );
  108. },
  109. // 选中问诊人
  110. chosePatient(item) {
  111. this.patientId = item.patientId
  112. },
  113. // 添加问诊人
  114. addPeople() {
  115. uni.navigateTo({
  116. url:"pages_user/user/addPatient?type=add"
  117. })
  118. },
  119. // 选择上传的图片
  120. chooseImage() {
  121. var that = this;
  122. uni.showActionSheet({
  123. itemList: ['相册', '拍照'],
  124. success: function(res) {
  125. if (res.tapIndex == 0) {
  126. //从相册选择
  127. that.chooseImageFunction('album')
  128. } else if (res.tapIndex == 1) {
  129. //拍照
  130. that.chooseImageFunction('camera')
  131. }
  132. },
  133. fail: function(res) {
  134. }
  135. });
  136. },
  137. chooseImageFunction: function(type) {
  138. var that = this;
  139. uni.chooseImage({
  140. count: 3, // 默认9
  141. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  142. sourceType: [type],
  143. success: (res) => {
  144. uni.uploadFile({
  145. url: uni.getStorageSync('requestPath')+'/app/common/uploadOSS', //仅为示例,非真实的接口地址
  146. filePath: res.tempFilePaths[0],
  147. name: 'file',
  148. formData: {
  149. 'user': 'test' // 上传附带参数
  150. },
  151. success: (uploadFileRes) => {
  152. // 根据接口具体返回格式 赋值具体对应url
  153. if (this.imgList.length != 0) {
  154. this.imgList = this.imgList.concat(res.tempFilePaths)
  155. } else {
  156. this.imgList = res.tempFilePaths
  157. }
  158. this.photos = this.photos.concat(JSON.parse(uploadFileRes.data).url)
  159. }
  160. });
  161. }
  162. });
  163. },
  164. // 查看图片
  165. viewImage(e) {
  166. uni.previewImage({
  167. urls: this.imgList,
  168. current: e.currentTarget.dataset.url
  169. });
  170. },
  171. // 删除上传的图片
  172. delImg(e) {
  173. var that = this;
  174. uni.showModal({
  175. title: '提示',
  176. content: '确定要删除照片吗?',
  177. cancelText: '取消',
  178. confirmText: '确定',
  179. success: res => {
  180. if (res.confirm) {
  181. that.imgList.splice(e.currentTarget.dataset.index, 1)
  182. this.photos.splice(e.currentTarget.dataset.index, 1);
  183. }
  184. },
  185. })
  186. },
  187. submitOrder() {
  188. if(this.remark==""){
  189. uni.showToast({
  190. icon:'none',
  191. title: '请输入描述信息',
  192. });
  193. return;
  194. }
  195. if(this.patientId==null){
  196. uni.showToast({
  197. icon:'none',
  198. title: '请选择患者',
  199. });
  200. return;
  201. }
  202. let data = {patientId:this.patientId,title:this.remark,doctorId:this.doctorId,priceId:this.priceId,imgs:this.photos.toString()};
  203. create(data).then(
  204. res => {
  205. if(res.code==200){
  206. setTimeout(function(){
  207. uni.redirectTo({
  208. url: './paymentOrder?orderId='+res.order.orderId
  209. })
  210. },200);
  211. return;
  212. }
  213. else{
  214. uni.showToast({
  215. icon:'none',
  216. title: res.msg,
  217. });
  218. }
  219. },
  220. rej => {}
  221. );
  222. },
  223. }
  224. }
  225. </script>
  226. <style lang="scss">
  227. page{
  228. height: 100%;
  229. }
  230. .content{
  231. height: 100%;
  232. display: flex;
  233. flex-direction: column;
  234. justify-content: space-between;
  235. .inner{
  236. flex: 1;
  237. padding: 20upx;
  238. box-sizing: border-box;
  239. .chose-people{
  240. box-sizing: border-box;
  241. min-height: 247upx;
  242. background: #FFFFFF;
  243. border-radius: 16upx;
  244. padding: 40upx 30upx 30upx;
  245. .title-box{
  246. display: flex;
  247. align-items: center;
  248. justify-content: space-between;
  249. .title{
  250. font-size: 32upx;
  251. font-family: PingFang SC;
  252. font-weight: bold;
  253. color: #111111;
  254. }
  255. .add-box{
  256. display: flex;
  257. align-items: center;
  258. image{
  259. width: 26upx;
  260. height: 26upx;
  261. margin-right: 11upx;
  262. }
  263. text{
  264. font-size: 28upx;
  265. font-family: PingFang SC;
  266. font-weight: 500;
  267. color: #111111;
  268. }
  269. }
  270. }
  271. .peop-list{
  272. display: flex;
  273. flex-wrap: wrap;
  274. margin-top: 30upx;
  275. .item{
  276. box-sizing: border-box;
  277. padding: 18upx 30upx;
  278. width: 31.28%;
  279. height: 110upx;
  280. background: #F7F7F7;
  281. border-radius: 16upx;
  282. margin: 0 20upx 10upx 0;
  283. border: 2upx solid #F7F7F7;
  284. display: flex;
  285. flex-direction: column;
  286. justify-content: space-between;
  287. &:nth-child(3n){
  288. margin-right: 0;
  289. }
  290. &.active{
  291. background: rgba(230, 250, 247, 0);
  292. border: 2upx solid #018C39;
  293. position: relative;
  294. }
  295. .active-img{
  296. width: 50upx;
  297. height: 50upx;
  298. position: absolute;
  299. right: -2upx;
  300. bottom: -2upx;
  301. }
  302. .name{
  303. font-size: 30upx;
  304. line-height: 1;
  305. font-family: PingFang SC;
  306. font-weight: bold;
  307. color: #111111;
  308. }
  309. .info{
  310. display: flex;
  311. align-items: center;
  312. .sex,
  313. .ege{
  314. font-size: 26upx;
  315. font-family: PingFang SC;
  316. line-height: 1;
  317. font-weight: 500;
  318. color: #666666;
  319. }
  320. .ege{
  321. margin-left: 19upx;
  322. }
  323. }
  324. }
  325. }
  326. }
  327. .desc{
  328. box-sizing: border-box;
  329. height: 619upx;
  330. background: #FFFFFF;
  331. border-radius: 16upx;
  332. margin-top: 20upx;
  333. padding: 40upx 30upx;
  334. textarea{
  335. width: 100%;
  336. height: 280upx;
  337. }
  338. }
  339. .upload-des{
  340. display: flex;
  341. align-items: center;
  342. justify-content: space-between;
  343. padding-top: 40upx;
  344. border-top: 1px solid #F0F0F0;
  345. .label-box{
  346. display: flex;
  347. align-items: center;
  348. .black{
  349. font-size: 28upx;
  350. font-family: PingFang SC;
  351. font-weight: bold;
  352. color: #111111;
  353. }
  354. .gray{
  355. font-size: 28upx;
  356. font-family: PingFang SC;
  357. color: #999999;
  358. }
  359. }
  360. .num-box{
  361. display: flex;
  362. align-items: center;
  363. .black{
  364. font-size: 24upx;
  365. font-family: PingFang SC;
  366. color: #111111;
  367. }
  368. .gray{
  369. font-size: 24upx;
  370. font-family: PingFang SC;
  371. color: #999999;
  372. }
  373. }
  374. }
  375. .upload-box{
  376. display: flex;
  377. flex-wrap: wrap;
  378. padding-top: 30upx;
  379. .img-item{
  380. width: 160upx;
  381. height: 160upx;
  382. border-radius: 16upx;
  383. overflow: hidden;
  384. position: relative;
  385. margin-right: 20upx;
  386. .img{
  387. width: 100%;
  388. height: 100%;
  389. }
  390. .close-img{
  391. width: 32upx;
  392. height: 32upx;
  393. position: absolute;
  394. top: 4upx;
  395. right: 4upx;
  396. }
  397. }
  398. .uoload-btn{
  399. width: 160upx;
  400. height: 160upx;
  401. background: #F7F7F7;
  402. border-radius: 16upx;
  403. display: flex;
  404. flex-direction: column;
  405. align-items: center;
  406. justify-content: center;
  407. image{
  408. width: 40upx;
  409. height: 32upx;
  410. margin-bottom: 16upx;
  411. }
  412. text{
  413. font-size: 22upx;
  414. font-family: PingFang SC;
  415. font-weight: 500;
  416. color: #666666;
  417. line-height: 1;
  418. }
  419. }
  420. }
  421. }
  422. .btn-box{
  423. height: 121upx;
  424. background: #FFFFFF;
  425. display: flex;
  426. align-items: center;
  427. justify-content: center;
  428. .btn{
  429. width: 91.73%;
  430. height: 88upx;
  431. line-height: 88upx;
  432. font-size: 30upx;
  433. font-family: PingFang SC;
  434. font-weight: bold;
  435. color: #FFFFFF;
  436. text-align: center;
  437. background: #018C39;
  438. border-radius: 44upx;
  439. }
  440. }
  441. }
  442. </style>