IncidentAttachment.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. callLog:{
  88. callAccept:incidentData.callID
  89. }
  90. // callrecord: {callAccept: incidentData.callID},
  91. };
  92. api_callrecord(postData).then((res0) => {
  93. if(res0.status==200){
  94. api_getRecordCall({
  95. path:res0.list[0].path,
  96. hosId:loginUserStore.loginUser.user.currentHospital.id
  97. }).then((res)=>{
  98. uni.hideLoading();
  99. if(res.state == 200){
  100. // res.list = res.list || [];
  101. pageData.audioSrc = location.origin + res.relativePath;
  102. }else{
  103. uni.showToast({
  104. icon: 'none',
  105. title: res.error || '请求数据失败!'
  106. });
  107. }
  108. })
  109. }
  110. });
  111. }
  112. onLoad((option) => {
  113. incidentData.reqAttachment && getRepairImgs();
  114. incidentData.callID && getCallrecord();
  115. })
  116. </script>
  117. <style lang="scss" scoped>
  118. .mask{
  119. position: fixed;
  120. left: 0;
  121. top: 0;
  122. right: 0;
  123. bottom: 0;
  124. background-color: rgba(0, 0, 0, 0.4);
  125. z-index: 999;
  126. }
  127. .container{
  128. position: fixed;
  129. left: 50%;
  130. top: 50%;
  131. transform: translate(-50%, -50%);
  132. z-index: 9999;
  133. width: 690rpx;
  134. background-color: #fff;
  135. border-radius: 10rpx;
  136. .container_head{
  137. padding: 55rpx;
  138. font-size: 32rpx;
  139. color: #333;
  140. text-align: center;
  141. }
  142. .container_form{
  143. padding: 0 55rpx;
  144. .repairImgList{
  145. margin-bottom: 55rpx;
  146. display: flex;
  147. justify-content: space-between;
  148. align-items: center;
  149. gap: 15rpx;
  150. .repairImg{
  151. width: 184rpx;
  152. height: 186rpx;
  153. }
  154. }
  155. .audio{
  156. margin-bottom: 45rpx;
  157. }
  158. }
  159. .container_foot{
  160. .foot_btns{
  161. display: flex;
  162. border-top: 1rpx solid #DDDDDD;
  163. .know{
  164. flex: 1;
  165. font-size: 32rpx;
  166. padding: 30rpx;
  167. display: flex;
  168. justify-content: center;
  169. color: $uni-primary;
  170. }
  171. }
  172. }
  173. }
  174. </style>