transferOrder.vue 11 KB

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