help.vue 10 KB

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