IncidentAttachment.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="container" @touchmove.stop.prevent>
  3. <view class="container_head">
  4. {{incidentData.reqAttachment ? '报修图片' : ''}}{{incidentData.reqAttachment && incidentData.callID ? '及' : ''}}{{incidentData.callID ? '录音' : ''}}
  5. </view>
  6. <view class="container_form">
  7. <view class="repairImgList" v-if="incidentData.reqAttachment">
  8. <image class="repairImg" :src="img.previewUrl" mode="aspectFill" v-for="(img, i) in pageData.repairImgList" :key="i" @click="previewImg(i)"></image>
  9. </view>
  10. <view class="audio" v-if="incidentData.callID">
  11. <sy-audio ref="audio" isCountDown :src='pageData.audioSrc' audioTitle="" subheading=""></sy-audio>
  12. </view>
  13. </view>
  14. <view class="container_foot">
  15. <view class="foot_btns">
  16. <view class="know" @click="know">知道了</view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="mask" @touchmove.stop.prevent></view>
  21. </template>
  22. <script setup>
  23. import { defineEmits, ref, reactive, defineProps } from 'vue'
  24. import { onLoad } from '@dcloudio/uni-app'
  25. import { useLoginUserStore } from '@/stores/loginUser'
  26. import { api_wechatRequesterIncident, api_callrecord, api_getRecordCall } from "@/http/api.js"
  27. const emit = defineEmits(['cancelEmit', 'knowEmit']);
  28. const { incidentData } = defineProps({
  29. incidentData: Object,
  30. });
  31. const loginUserStore = useLoginUserStore();
  32. // 页面数据
  33. const pageData = reactive({
  34. repairImgList: [],//报修图片
  35. audioSrc: '',//音频
  36. });
  37. const audio = ref(null);
  38. // 取消
  39. function cancel(){
  40. emit('cancelEmit')
  41. }
  42. // 确认
  43. function know(){
  44. audio.value && audio.value.audioDestroy()
  45. emit('knowEmit');
  46. }
  47. // 预览图片
  48. function previewImg(index){
  49. uni.previewImage({
  50. current: index,
  51. urls: pageData.repairImgList.map(v => v.previewUrl),
  52. longPressActions: {
  53. itemList: ['发送给朋友', '保存图片', '收藏'],
  54. success: function(data) {
  55. console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  56. },
  57. fail: function(err) {
  58. console.log(err.errMsg);
  59. }
  60. }
  61. });
  62. }
  63. // 获取报修图片
  64. function getRepairImgs() {
  65. uni.showLoading({
  66. title: "加载中",
  67. mask: true,
  68. });
  69. api_wechatRequesterIncident(incidentData.id).then((res) => {
  70. uni.hideLoading();
  71. res.data = res.data || [];
  72. res.data.forEach(v => {
  73. v.previewUrl = location.origin + "/file" + v.relativeFilePath;
  74. })
  75. pageData.repairImgList = res.data;
  76. });
  77. }
  78. // 获取通话音频
  79. function getCallrecord() {
  80. uni.showLoading({
  81. title: "加载中",
  82. mask: true,
  83. });
  84. let postData = {
  85. idx: 0,
  86. sum: 1,
  87. callAccept:incidentData.callID
  88. // callrecord: {callAccept: incidentData.callID},
  89. };
  90. api_callrecord(postData).then((res0) => {
  91. if(res0.status==200){
  92. api_getRecordCall({
  93. path:res0.list[0].path,
  94. hosId:loginUserStore.loginUser.user.currentHospital.id
  95. }).then((res)=>{
  96. uni.hideLoading();
  97. if(res.state == 200){
  98. // res.list = res.list || [];
  99. pageData.audioSrc = location.origin + res.relativePath;
  100. }else{
  101. uni.showToast({
  102. icon: 'none',
  103. title: res.error || '请求数据失败!'
  104. });
  105. }
  106. })
  107. }
  108. });
  109. }
  110. onLoad((option) => {
  111. incidentData.reqAttachment && getRepairImgs();
  112. incidentData.callID && getCallrecord();
  113. })
  114. </script>
  115. <style lang="scss" scoped>
  116. .mask{
  117. position: fixed;
  118. left: 0;
  119. top: 0;
  120. right: 0;
  121. bottom: 0;
  122. background-color: rgba(0, 0, 0, 0.4);
  123. z-index: 999;
  124. }
  125. .container{
  126. position: fixed;
  127. left: 50%;
  128. top: 50%;
  129. transform: translate(-50%, -50%);
  130. z-index: 9999;
  131. width: 690rpx;
  132. background-color: #fff;
  133. border-radius: 10rpx;
  134. .container_head{
  135. padding: 55rpx;
  136. font-size: 32rpx;
  137. color: #333;
  138. text-align: center;
  139. }
  140. .container_form{
  141. padding: 0 55rpx;
  142. .repairImgList{
  143. margin-bottom: 55rpx;
  144. display: flex;
  145. justify-content: space-between;
  146. align-items: center;
  147. gap: 15rpx;
  148. .repairImg{
  149. width: 184rpx;
  150. height: 186rpx;
  151. }
  152. }
  153. .audio{
  154. margin-bottom: 45rpx;
  155. }
  156. }
  157. .container_foot{
  158. .foot_btns{
  159. display: flex;
  160. border-top: 1rpx solid #DDDDDD;
  161. .know{
  162. flex: 1;
  163. font-size: 32rpx;
  164. padding: 30rpx;
  165. display: flex;
  166. justify-content: center;
  167. color: $uni-primary;
  168. }
  169. }
  170. }
  171. }
  172. </style>