transferOrder.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <view class="container">
  3. <view class="title" v-if="type === '1'">申请人</view>
  4. <view class="box" v-if="type === '1'">
  5. <img src="../../static/images/repairsImg/people.png" />
  6. <view class="box_info">{{ info.userName }}</view>
  7. </view>
  8. <view class="title">转单语音说明</view>
  9. <!-- 录音区域 -->
  10. <view class="voice">
  11. <view class="voice_box" v-if="!info.voice" @click="handleRecording">
  12. <img src="../../static/images/repairsImg/voice.png" />
  13. </view>
  14. <view v-if="!info.voice" @click="handleRecording">点击录音</view>
  15. <view class="item_recording" v-if="info.voice" @click="handlePlayRecording">
  16. <img :src="recordingImg" />
  17. {{ info.voiceLength || 0 }}″
  18. </view>
  19. <view class="recording_icon" v-if="info.voice && type !== '1'" @click="handleDeleteRecording">×</view>
  20. </view>
  21. <!-- 录音弹窗区域 -->
  22. <uni-popup :safe-area="true" background-color="#fff" ref="popup_recording">
  23. <view class="popup_recording">
  24. <recording @getTempFilePath="getTempFilePath" />
  25. </view>
  26. </uni-popup>
  27. <view class="title">备注</view>
  28. <view class="textarea">
  29. <textarea placeholder-style="color:#CCCCCC" placeholder="请输入转单说明" :disabled="type === '1'" v-model="info.remark"></textarea>
  30. </view>
  31. <view class="btn2" v-if="type === '1'">
  32. <view class="btn_box type" @click="handleRefuse">拒绝</view>
  33. <view class="btn_box type2" @click="handleSendOrders">派单</view>
  34. </view>
  35. <view class="btn" v-else @click="handleAffirm">确认</view>
  36. </view>
  37. </template>
  38. <script>
  39. import recording from '../components/recording.vue'
  40. const innerAudioContext = uni.createInnerAudioContext()
  41. export default {
  42. components: {
  43. recording
  44. },
  45. data() {
  46. return {
  47. // 页面类型
  48. type: null,
  49. // 录音图片地址
  50. recordingImg: '../../static/images/repairsImg/recording.jpg',
  51. // 播放状态
  52. playStatus: false,
  53. // 定时器标识
  54. timer: null,
  55. // 订单id
  56. recordId: '',
  57. info: {
  58. // 申请人
  59. userName: '',
  60. // 语音地址
  61. voice: '',
  62. // 备注
  63. remark: '',
  64. // 语音时长
  65. voiceLength: 0
  66. }
  67. }
  68. },
  69. mounted() {
  70. //在ios下静音时播放没有声音,默认为true,改为false就好了。
  71. uni.setInnerAudioOption({
  72. obeyMuteSwitch: false
  73. })
  74. },
  75. onLoad(options) {
  76. this.recordId = options.id
  77. if (options.type) {
  78. this.type = options.type
  79. this.getData()
  80. }
  81. },
  82. methods: {
  83. // 获取转单审核详细数据
  84. async getData() {
  85. const res = await this.$myRequest_repairs({
  86. url: '/repairRecord/transferDetail',
  87. data: {
  88. recordId: this.recordId
  89. }
  90. })
  91. // console.log(res)
  92. if (res.code === '200') {
  93. this.info = res.data
  94. }
  95. },
  96. // 拒绝按钮回调
  97. handleRefuse() {
  98. uni.showModal({
  99. title: '提示',
  100. content: '确定拒绝该审核吗?',
  101. success: async (res) => {
  102. if (res.confirm) {
  103. const res = await this.$myRequest_repairs({
  104. url: '/repairRecord/transfer',
  105. method: 'post',
  106. data: {
  107. id: this.info.id,
  108. approverStatu: 0
  109. }
  110. })
  111. // console.log(res)
  112. if (res.code === '200') {
  113. uni.showToast({
  114. title: '已拒绝该审核',
  115. icon: 'none'
  116. })
  117. setTimeout(() => {
  118. uni.reLaunch({
  119. url: '/pagesRepairs/box/box'
  120. })
  121. }, 1500)
  122. }
  123. }
  124. }
  125. })
  126. },
  127. // 派单按钮回调
  128. handleSendOrders() {
  129. let info = JSON.stringify(this.info)
  130. uni.navigateTo({
  131. url: `/pagesRepairs/helpPeople/helpPeople?type=2&id=${this.recordId}&info=${info}`
  132. })
  133. },
  134. // 确认按钮回调
  135. handleAffirm() {
  136. if (!this.info.voice) {
  137. uni.showToast({
  138. title: '请录入转单语音说明',
  139. icon: 'none'
  140. })
  141. return
  142. }
  143. uni.showModal({
  144. title: '提示',
  145. content: '确认提交转单申请吗?',
  146. success: async (res) => {
  147. if (res.confirm) {
  148. const res = await this.$myRequest_repairs({
  149. url: '/repairRecord/transferApply',
  150. method: 'post',
  151. data: {
  152. recordId: this.recordId,
  153. userId: uni.getStorageSync('repairsUserInfo').userId,
  154. voice: this.info.voice,
  155. voiceLength: this.info.voiceLength,
  156. remark: this.info.remark
  157. }
  158. })
  159. // console.log(res)
  160. if (res.code === '200') {
  161. uni.showToast({
  162. title: '提交转单申请成功,请等待管理员审核',
  163. icon: 'none',
  164. duration: 3000
  165. })
  166. setTimeout(() => {
  167. uni.reLaunch({
  168. url: '/pagesRepairs/box/box'
  169. })
  170. }, 3000)
  171. }
  172. }
  173. }
  174. })
  175. },
  176. // 点击录音按钮回调
  177. handleRecording() {
  178. uni.getSetting({
  179. success: (res) => {
  180. if (!res.authSetting['scope.record']) {
  181. uni.authorize({
  182. scope: 'scope.record',
  183. success(res) {
  184. // 授权成功
  185. uni.showToast({
  186. title: '授权成功',
  187. icon: 'none'
  188. })
  189. },
  190. fail() {
  191. uni.showModal({
  192. content: '检测到您没打开麦克风权限,是否去设置打开?',
  193. confirmText: '确认',
  194. cancelText: '取消',
  195. success: (res) => {
  196. if (res.confirm) {
  197. uni.openSetting({
  198. success: (res) => {}
  199. })
  200. } else {
  201. uni.showToast({
  202. title: '获取麦克风权限失败',
  203. icon: 'none'
  204. })
  205. }
  206. }
  207. })
  208. }
  209. })
  210. } else {
  211. this.$refs.popup_recording.open('bottom')
  212. }
  213. },
  214. fail() {
  215. uni.showToast({
  216. title: '获取麦克风权限失败',
  217. icon: 'none'
  218. })
  219. }
  220. })
  221. },
  222. // 点击录音播放回调
  223. handlePlayRecording() {
  224. innerAudioContext.src = this.info.voice
  225. if (!this.playStatus) {
  226. this.playStatus = true
  227. innerAudioContext.play()
  228. this.timer = setInterval(() => {
  229. if (this.recordingImg == '../../static/images/repairsImg/recording.jpg') {
  230. this.recordingImg = '../../static/images/repairsImg/recording2.jpg'
  231. } else if (this.recordingImg == '../../static/images/repairsImg/recording2.jpg') {
  232. this.recordingImg = '../../static/images/repairsImg/recording3.jpg'
  233. } else if (this.recordingImg == '../../static/images/repairsImg/recording3.jpg') {
  234. this.recordingImg = '../../static/images/repairsImg/recording.jpg'
  235. }
  236. }, 300)
  237. //播放结束
  238. innerAudioContext.onEnded(() => {
  239. clearInterval(this.timer)
  240. this.timer = null
  241. this.recordingImg = '../../static/images/repairsImg/recording.jpg'
  242. this.playStatus = false
  243. })
  244. } else {
  245. clearInterval(this.timer)
  246. this.recordingImg = '../../static/images/repairsImg/recording.jpg'
  247. this.playStatus = false
  248. innerAudioContext.stop()
  249. }
  250. },
  251. // 删除录音回调
  252. handleDeleteRecording() {
  253. if (this.playStatus) {
  254. uni.showToast({
  255. title: '播放中不能删除',
  256. icon: 'none',
  257. mask: true
  258. })
  259. } else {
  260. uni.showModal({
  261. title: '提示',
  262. content: '确定删除录音吗?',
  263. success: (res) => {
  264. if (res.confirm) {
  265. this.info.voice = ''
  266. this.info.voiceLength = 0
  267. }
  268. }
  269. })
  270. }
  271. },
  272. // 自定义事件回调,获取录音文件路径
  273. getTempFilePath(path, time) {
  274. this.info.voice = path
  275. this.info.voiceLength = time
  276. this.$refs.popup_recording.close()
  277. }
  278. }
  279. }
  280. </script>
  281. <style lang="scss" scoped>
  282. .container {
  283. box-sizing: border-box;
  284. padding: 0 30rpx;
  285. .title {
  286. display: flex;
  287. align-items: center;
  288. height: 107rpx;
  289. font-size: 36rpx;
  290. font-weight: bold;
  291. }
  292. .box {
  293. display: flex;
  294. align-items: center;
  295. height: 94rpx;
  296. font-size: 32rpx;
  297. border-radius: 10rpx;
  298. border: 1rpx solid #cccccc;
  299. .box_info {
  300. flex: 1;
  301. }
  302. img {
  303. margin: 0 14rpx 0 30rpx;
  304. width: 48rpx;
  305. height: 48rpx;
  306. }
  307. }
  308. .voice {
  309. display: flex;
  310. align-items: center;
  311. height: 94rpx;
  312. font-size: 32rpx;
  313. color: #cccccc;
  314. border-radius: 10rpx;
  315. border: 1rpx solid #cccccc;
  316. .voice_box {
  317. display: flex;
  318. justify-content: center;
  319. align-items: center;
  320. margin: 0 38rpx 0 33rpx;
  321. width: 101rpx;
  322. height: 47rpx;
  323. border-radius: 33rpx;
  324. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  325. img {
  326. width: 33rpx;
  327. height: 33rpx;
  328. }
  329. }
  330. .item_recording {
  331. margin-left: 35rpx;
  332. display: flex;
  333. align-items: center;
  334. width: 230rpx;
  335. height: 65rpx;
  336. color: #000;
  337. border-radius: 100rpx;
  338. border: 1rpx solid #cccccc;
  339. img {
  340. margin: 0 12rpx;
  341. width: 40rpx;
  342. height: 40rpx;
  343. }
  344. }
  345. .recording_icon {
  346. margin-left: auto;
  347. margin-right: 35rpx;
  348. font-size: 40rpx;
  349. }
  350. }
  351. .popup_recording {
  352. width: 100%;
  353. height: 460rpx;
  354. background-color: #fff;
  355. }
  356. .textarea {
  357. height: 310rpx;
  358. border-radius: 10rpx;
  359. border: 1rpx solid #cccccc;
  360. textarea {
  361. box-sizing: border-box;
  362. padding: 25rpx 35rpx;
  363. width: 100%;
  364. font-size: 32rpx;
  365. }
  366. }
  367. .btn {
  368. position: absolute;
  369. bottom: 66rpx;
  370. display: flex;
  371. justify-content: center;
  372. align-items: center;
  373. margin: auto;
  374. width: 690rpx;
  375. height: 100rpx;
  376. color: #fff;
  377. font-size: 32rpx;
  378. border-radius: 12rpx;
  379. background-color: #6fb6b8;
  380. }
  381. .btn2 {
  382. position: absolute;
  383. bottom: 66rpx;
  384. display: flex;
  385. justify-content: space-between;
  386. align-items: center;
  387. margin: auto;
  388. width: 690rpx;
  389. height: 100rpx;
  390. font-size: 32rpx;
  391. .btn_box {
  392. display: flex;
  393. justify-content: center;
  394. align-items: center;
  395. width: 300rpx;
  396. height: 100rpx;
  397. border-radius: 12rpx;
  398. }
  399. .type {
  400. color: #fff;
  401. background-color: #6fb6b8;
  402. }
  403. .type2 {
  404. color: #6fb6b8;
  405. border: 1rpx solid #6fb6b8;
  406. }
  407. }
  408. }
  409. </style>