index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view>
  3. <!--prescription/prescriptionInformation/index.wxml-->
  4. <view class="drugUsers bgfff r20">
  5. <view>用药人</view>
  6. <view class="add" @tap="goUrl" data-url="prescription/drugUsers/index"><image src="/static/pages/images/jia.png" class="jia"></image>新建用药人</view>
  7. </view>
  8. <view class="case bgfff r20">
  9. <view class="top">
  10. <view> <text class="red">*</text>请上传医生开具的处方单</view>
  11. <view class="dflex look">查看示例<image src="/static/pages/images/more.png" class="right"></image></view>
  12. </view>
  13. <view class="content">
  14. <view>1、处方单不等一病历本、检查结果、伤患结果、伤患照片等</view>
  15. <view>2、处方单需在有效期使用</view>
  16. <view>3、处方单信息需与有预约单的用药人、药品名称、规格、剂型、数量等信息一致...</view>
  17. </view>
  18. <image src="/static/pages/images/upload.png" class="upload" @tap="uploadAvatar" v-if="avatar.length<=0"></image>
  19. <view class="dflex" v-else>
  20. <view v-for="(item, index) in avatar" :key="index" class="pz">
  21. <image :src="avatar[index]" class="scpz"></image>
  22. <image src="/prescription/static/prescription/image/imagecuo.png" class="cuo" @tap="cleanimage" :data-index="index"></image>
  23. </view>
  24. <image src="/static/pages/images/upload.png" class="scpz" @tap="uploadAvatar" v-if="avatar.length<3"></image>
  25. </view>
  26. </view>
  27. <view class="bot fixed bgfff dflex" :style="'padding: ' + (bottomBlankHeight + 20) + 'rpx 0rpx'">
  28. <view class="addcart">获取处方</view>
  29. <view class="mbglinear gmbtn"><text>完</text>成</view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. // prescription/prescriptionInformation/index.js
  35. const app = getApp();
  36. const req = require("../../utils/request.js");
  37. export default {
  38. data() {
  39. return {
  40. bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
  41. avatar: []
  42. };
  43. },
  44. components: {},
  45. props: {},
  46. /**
  47. * 生命周期函数--监听页面加载
  48. */
  49. onLoad: function (options) {},
  50. /**
  51. * 生命周期函数--监听页面初次渲染完成
  52. */
  53. onReady: function () {},
  54. /**
  55. * 生命周期函数--监听页面显示
  56. */
  57. onShow: function () {},
  58. methods: {
  59. goUrl(e) {
  60. let url = e.currentTarget.dataset.url;
  61. app.globalData.openPage(url);
  62. },
  63. //上传图片
  64. uploadAvatar() {
  65. let that = this;
  66. uni.chooseImage({
  67. count: 3,
  68. sizeType: ['original', 'compressed'],
  69. sourceType: ['album', 'camera'],
  70. success: function ({
  71. tempFilePaths
  72. }) {
  73. var promise = Promise.all(tempFilePaths.map((tempFilePath, index) => {
  74. return new Promise(function (resolve, reject) {
  75. req.loadIng("上传中");
  76. req.uploadFile('/api/upload', tempFilePath, res => {
  77. // console.log(res);
  78. that.setData({
  79. avatar: that.avatar.concat(res.src)
  80. });
  81. uni.showToast({
  82. title: '上传成功',
  83. icon: 'success',
  84. duration: 2000
  85. });
  86. // console.log(that.avatar);
  87. });
  88. });
  89. }));
  90. promise.then(function (results) {
  91. // console.log(results);
  92. }).catch(function (err) {
  93. // console.log(err);
  94. });
  95. }
  96. });
  97. },
  98. // 删除图片
  99. cleanimage(event) {
  100. let index = event.currentTarget.dataset.index;
  101. let arr = this.avatar;
  102. arr.splice(index, 1);
  103. this.setData({
  104. avatar: arr
  105. });
  106. }
  107. }
  108. };
  109. </script>
  110. <style>
  111. @import "./index.css";
  112. </style>