transferOrder.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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="type === '1' ? '无备注' : '请输入转单说明'" :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. placeholderText: '请输入拒绝原因',
  101. editable: true,
  102. success: async (res) => {
  103. if (res.confirm) {
  104. if (!res.content) {
  105. uni.showToast({
  106. title: '拒绝原因为必填,请重新输入',
  107. icon: 'none'
  108. })
  109. setTimeout(() => {
  110. this.handleRefuse()
  111. }, 1500)
  112. } else {
  113. const result = await this.$myRequest_repairs({
  114. url: '/repairRecord/transfer',
  115. method: 'post',
  116. data: {
  117. id: this.info.id,
  118. approverStatu: 0,
  119. refuseRemark: res.content
  120. }
  121. })
  122. // console.log(res)
  123. if (result.code === '200') {
  124. uni.showToast({
  125. title: '已拒绝该审核',
  126. icon: 'none'
  127. })
  128. setTimeout(() => {
  129. uni.reLaunch({
  130. url: '/pagesRepairs/box/box'
  131. })
  132. }, 1500)
  133. }
  134. }
  135. }
  136. }
  137. })
  138. },
  139. // 派单按钮回调
  140. handleSendOrders() {
  141. let info = JSON.stringify(this.info)
  142. uni.navigateTo({
  143. url: `/pagesRepairs/helpPeople/helpPeople?type=2&id=${this.recordId}&info=${info}`
  144. })
  145. },
  146. // 确认按钮回调
  147. handleAffirm() {
  148. if (!this.info.voice) {
  149. uni.showToast({
  150. title: '请录入转单语音说明',
  151. icon: 'none'
  152. })
  153. return
  154. }
  155. uni.showModal({
  156. title: '提示',
  157. content: '确认提交转单申请吗?',
  158. success: async (res) => {
  159. if (res.confirm) {
  160. const res = await this.$myRequest_repairs({
  161. url: '/repairRecord/transferApply',
  162. method: 'post',
  163. data: {
  164. recordId: this.recordId,
  165. userId: uni.getStorageSync('repairsUserInfo').userId,
  166. voice: this.info.voice,
  167. voiceLength: this.info.voiceLength,
  168. remark: this.info.remark
  169. }
  170. })
  171. // console.log(res)
  172. if (res.code === '200') {
  173. uni.showToast({
  174. title: '提交转单申请成功,请等待管理员审核',
  175. icon: 'none',
  176. duration: 3000
  177. })
  178. setTimeout(() => {
  179. uni.reLaunch({
  180. url: '/pagesRepairs/box/box'
  181. })
  182. }, 3000)
  183. }
  184. }
  185. }
  186. })
  187. },
  188. // 点击录音按钮回调
  189. handleRecording() {
  190. uni.getSetting({
  191. success: (res) => {
  192. if (!res.authSetting['scope.record']) {
  193. uni.authorize({
  194. scope: 'scope.record',
  195. success(res) {
  196. // 授权成功
  197. uni.showToast({
  198. title: '授权成功',
  199. icon: 'none'
  200. })
  201. },
  202. fail() {
  203. uni.showModal({
  204. content: '检测到您没打开麦克风权限,是否去设置打开?',
  205. confirmText: '确认',
  206. cancelText: '取消',
  207. success: (res) => {
  208. if (res.confirm) {
  209. uni.openSetting({
  210. success: (res) => {}
  211. })
  212. } else {
  213. uni.showToast({
  214. title: '获取麦克风权限失败',
  215. icon: 'none'
  216. })
  217. }
  218. }
  219. })
  220. }
  221. })
  222. } else {
  223. this.$refs.popup_recording.open('bottom')
  224. }
  225. },
  226. fail() {
  227. uni.showToast({
  228. title: '获取麦克风权限失败',
  229. icon: 'none'
  230. })
  231. }
  232. })
  233. },
  234. // 点击录音播放回调
  235. handlePlayRecording() {
  236. innerAudioContext.src = this.info.voice
  237. if (!this.playStatus) {
  238. this.playStatus = true
  239. innerAudioContext.play()
  240. this.timer = setInterval(() => {
  241. if (this.recordingImg == '../../static/images/repairsImg/recording.jpg') {
  242. this.recordingImg = '../../static/images/repairsImg/recording2.jpg'
  243. } else if (this.recordingImg == '../../static/images/repairsImg/recording2.jpg') {
  244. this.recordingImg = '../../static/images/repairsImg/recording3.jpg'
  245. } else if (this.recordingImg == '../../static/images/repairsImg/recording3.jpg') {
  246. this.recordingImg = '../../static/images/repairsImg/recording.jpg'
  247. }
  248. }, 300)
  249. //播放结束
  250. innerAudioContext.onEnded(() => {
  251. clearInterval(this.timer)
  252. this.timer = null
  253. this.recordingImg = '../../static/images/repairsImg/recording.jpg'
  254. this.playStatus = false
  255. })
  256. } else {
  257. clearInterval(this.timer)
  258. this.recordingImg = '../../static/images/repairsImg/recording.jpg'
  259. this.playStatus = false
  260. innerAudioContext.stop()
  261. }
  262. },
  263. // 删除录音回调
  264. handleDeleteRecording() {
  265. if (this.playStatus) {
  266. uni.showToast({
  267. title: '播放中不能删除',
  268. icon: 'none',
  269. mask: true
  270. })
  271. } else {
  272. uni.showModal({
  273. title: '提示',
  274. content: '确定删除录音吗?',
  275. success: (res) => {
  276. if (res.confirm) {
  277. this.info.voice = ''
  278. this.info.voiceLength = 0
  279. }
  280. }
  281. })
  282. }
  283. },
  284. // 自定义事件回调,获取录音文件路径
  285. getTempFilePath(path, time) {
  286. this.info.voice = path
  287. this.info.voiceLength = time
  288. this.$refs.popup_recording.close()
  289. }
  290. }
  291. }
  292. </script>
  293. <style lang="scss" scoped>
  294. .container {
  295. box-sizing: border-box;
  296. padding: 0 30rpx;
  297. .title {
  298. display: flex;
  299. align-items: center;
  300. height: 107rpx;
  301. font-size: 36rpx;
  302. font-weight: bold;
  303. }
  304. .box {
  305. display: flex;
  306. align-items: center;
  307. height: 94rpx;
  308. font-size: 32rpx;
  309. border-radius: 10rpx;
  310. border: 1rpx solid #cccccc;
  311. .box_info {
  312. flex: 1;
  313. }
  314. img {
  315. margin: 0 14rpx 0 30rpx;
  316. width: 48rpx;
  317. height: 48rpx;
  318. }
  319. }
  320. .voice {
  321. display: flex;
  322. align-items: center;
  323. height: 94rpx;
  324. font-size: 32rpx;
  325. color: #cccccc;
  326. border-radius: 10rpx;
  327. border: 1rpx solid #cccccc;
  328. .voice_box {
  329. display: flex;
  330. justify-content: center;
  331. align-items: center;
  332. margin: 0 38rpx 0 33rpx;
  333. width: 101rpx;
  334. height: 47rpx;
  335. border-radius: 33rpx;
  336. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  337. img {
  338. width: 33rpx;
  339. height: 33rpx;
  340. }
  341. }
  342. .item_recording {
  343. margin-left: 35rpx;
  344. display: flex;
  345. align-items: center;
  346. width: 230rpx;
  347. height: 65rpx;
  348. color: #000;
  349. border-radius: 100rpx;
  350. border: 1rpx solid #cccccc;
  351. img {
  352. margin: 0 12rpx;
  353. width: 40rpx;
  354. height: 40rpx;
  355. }
  356. }
  357. .recording_icon {
  358. margin-left: auto;
  359. margin-right: 35rpx;
  360. font-size: 40rpx;
  361. }
  362. }
  363. .popup_recording {
  364. width: 100%;
  365. height: 460rpx;
  366. background-color: #fff;
  367. }
  368. .textarea {
  369. height: 310rpx;
  370. border-radius: 10rpx;
  371. border: 1rpx solid #cccccc;
  372. textarea {
  373. box-sizing: border-box;
  374. padding: 25rpx 35rpx;
  375. width: 100%;
  376. font-size: 32rpx;
  377. }
  378. }
  379. .btn {
  380. position: absolute;
  381. bottom: 66rpx;
  382. display: flex;
  383. justify-content: center;
  384. align-items: center;
  385. margin: auto;
  386. width: 690rpx;
  387. height: 100rpx;
  388. color: #fff;
  389. font-size: 32rpx;
  390. border-radius: 12rpx;
  391. background-color: #6fb6b8;
  392. }
  393. .btn2 {
  394. position: absolute;
  395. bottom: 66rpx;
  396. display: flex;
  397. justify-content: space-between;
  398. align-items: center;
  399. margin: auto;
  400. width: 690rpx;
  401. height: 100rpx;
  402. font-size: 32rpx;
  403. .btn_box {
  404. display: flex;
  405. justify-content: center;
  406. align-items: center;
  407. width: 300rpx;
  408. height: 100rpx;
  409. border-radius: 12rpx;
  410. }
  411. .type {
  412. color: #fff;
  413. background-color: #6fb6b8;
  414. }
  415. .type2 {
  416. color: #6fb6b8;
  417. border: 1rpx solid #6fb6b8;
  418. }
  419. }
  420. }
  421. </style>