help.vue 11 KB

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