IncidentAttachment.vue 5.3 KB

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