help.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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. console.log(options)
  103. if (options.type) {
  104. this.type = options.type
  105. this.getHelpData()
  106. }
  107. this.recordId = options.id
  108. uni.$on('addCheckList', this.addCheckList)
  109. },
  110. methods: {
  111. // 拒绝 派单 按钮回调
  112. async handleDispose(type) {
  113. const res = await this.$myRequest_repairs({
  114. url: '/repairRecord/cooperationOrders',
  115. method: 'post',
  116. data: {
  117. id: this.info.id,
  118. collaborator: this.idList,
  119. approverStatu: type
  120. }
  121. })
  122. console.log(res)
  123. if (res.code === '200') {
  124. uni.showToast({
  125. title: `${type === 0 ? '已拒绝该审核' : '派单成功'}`,
  126. icon: 'none'
  127. })
  128. setTimeout(() => {
  129. uni.reLaunch({
  130. url: '/pagesRepairs/box/box'
  131. })
  132. }, 1500)
  133. }
  134. },
  135. // 获取审核订单详细数据
  136. async getHelpData() {
  137. const res = await this.$myRequest_repairs({
  138. url: '/repairRecord/cooperationDetail',
  139. data: {
  140. recordId: this.recordId
  141. }
  142. })
  143. // console.log(res)
  144. if (res.code === '200') {
  145. this.info = res.data
  146. }
  147. },
  148. addCheckList(e) {
  149. this.info.collaboratorDatas = e.data
  150. },
  151. // 确认按钮回调
  152. handleAffirm() {
  153. if (!this.peoples) {
  154. uni.showToast({
  155. title: '请选择协作对象',
  156. icon: 'none'
  157. })
  158. return
  159. }
  160. if (!this.info.voice) {
  161. uni.showToast({
  162. title: '请录入转单语音说明',
  163. icon: 'none'
  164. })
  165. return
  166. }
  167. uni.showModal({
  168. title: '提示',
  169. content: '确认提交协作申请吗?',
  170. success: async (res) => {
  171. if (res.confirm) {
  172. const res = await this.$myRequest_repairs({
  173. url: '/repairRecord/collaborateApply',
  174. method: 'post',
  175. data: {
  176. recordId: this.recordId,
  177. userId: uni.getStorageSync('repairsUserInfo').userId,
  178. voice: this.info.voice,
  179. voiceLength: this.info.voiceLength,
  180. collaborator: this.info.collaboratorDatas,
  181. remark: this.info.remark
  182. }
  183. })
  184. console.log(res)
  185. if (res.code === '200') {
  186. uni.showToast({
  187. title: '提交协作申请成功,请等待管理员审核',
  188. icon: 'none',
  189. duration: 3000
  190. })
  191. setTimeout(() => {
  192. uni.reLaunch({
  193. url: '/pagesRepairs/box/box'
  194. })
  195. }, 3000)
  196. }
  197. }
  198. }
  199. })
  200. },
  201. handleHelpPeople() {
  202. if (this.type !== '1') {
  203. uni.navigateTo({
  204. url: `/pagesRepairs/helpPeople/helpPeople?id=${this.recordId}`
  205. })
  206. }
  207. },
  208. // 点击录音按钮回调
  209. handleRecording() {
  210. uni.getSetting({
  211. success: (res) => {
  212. if (!res.authSetting['scope.record']) {
  213. uni.authorize({
  214. scope: 'scope.record',
  215. success(res) {
  216. // 授权成功
  217. uni.showToast({
  218. title: '授权成功',
  219. icon: 'none'
  220. })
  221. },
  222. fail() {
  223. uni.showModal({
  224. content: '检测到您没打开麦克风权限,是否去设置打开?',
  225. confirmText: '确认',
  226. cancelText: '取消',
  227. success: (res) => {
  228. if (res.confirm) {
  229. uni.openSetting({
  230. success: (res) => {}
  231. })
  232. } else {
  233. uni.showToast({
  234. title: '获取麦克风权限失败',
  235. icon: 'none'
  236. })
  237. }
  238. }
  239. })
  240. }
  241. })
  242. } else {
  243. this.$refs.popup_recording.open('bottom')
  244. }
  245. },
  246. fail() {
  247. uni.showToast({
  248. title: '获取麦克风权限失败',
  249. icon: 'none'
  250. })
  251. }
  252. })
  253. },
  254. // 点击录音播放回调
  255. handlePlayRecording() {
  256. innerAudioContext.src = this.info.voice
  257. if (!this.playStatus) {
  258. this.playStatus = true
  259. innerAudioContext.play()
  260. this.timer = setInterval(() => {
  261. if (this.recordingImg == '../../static/images/repairsImg/recording.jpg') {
  262. this.recordingImg = '../../static/images/repairsImg/recording2.jpg'
  263. } else if (this.recordingImg == '../../static/images/repairsImg/recording2.jpg') {
  264. this.recordingImg = '../../static/images/repairsImg/recording3.jpg'
  265. } else if (this.recordingImg == '../../static/images/repairsImg/recording3.jpg') {
  266. this.recordingImg = '../../static/images/repairsImg/recording.jpg'
  267. }
  268. }, 300)
  269. //播放结束
  270. innerAudioContext.onEnded(() => {
  271. clearInterval(this.timer)
  272. this.timer = null
  273. this.recordingImg = '../../static/images/repairsImg/recording.jpg'
  274. this.playStatus = false
  275. })
  276. } else {
  277. clearInterval(this.timer)
  278. this.recordingImg = '../../static/images/repairsImg/recording.jpg'
  279. this.playStatus = false
  280. innerAudioContext.stop()
  281. }
  282. },
  283. // 删除录音回调
  284. handleDeleteRecording() {
  285. if (this.playStatus) {
  286. uni.showToast({
  287. title: '播放中不能删除',
  288. icon: 'none',
  289. mask: true
  290. })
  291. } else {
  292. uni.showModal({
  293. title: '提示',
  294. content: '确定删除录音吗?',
  295. success: (res) => {
  296. if (res.confirm) {
  297. this.info.voice = ''
  298. this.info.voiceLength = 0
  299. }
  300. }
  301. })
  302. }
  303. },
  304. // 自定义事件回调,获取录音文件路径
  305. getTempFilePath(path, time) {
  306. this.info.voice = path
  307. this.info.voiceLength = time
  308. this.$refs.popup_recording.close()
  309. }
  310. }
  311. }
  312. </script>
  313. <style lang="scss" scoped>
  314. .container {
  315. box-sizing: border-box;
  316. padding: 0 30rpx;
  317. height: 100vh;
  318. overflow-y: auto;
  319. .title {
  320. display: flex;
  321. align-items: center;
  322. height: 107rpx;
  323. font-size: 36rpx;
  324. font-weight: bold;
  325. }
  326. .box {
  327. display: flex;
  328. align-items: center;
  329. height: 94rpx;
  330. font-size: 32rpx;
  331. border-radius: 10rpx;
  332. border: 1rpx solid #cccccc;
  333. .box_info {
  334. flex: 1;
  335. overflow: hidden;
  336. text-overflow: ellipsis;
  337. white-space: nowrap;
  338. }
  339. .color {
  340. color: #ccc;
  341. }
  342. img {
  343. margin: 0 14rpx 0 30rpx;
  344. width: 48rpx;
  345. height: 48rpx;
  346. }
  347. .img {
  348. width: 40rpx;
  349. height: 40rpx;
  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. display: flex;
  427. justify-content: space-between;
  428. align-items: center;
  429. margin: 200rpx auto 70rpx;
  430. width: 690rpx;
  431. height: 100rpx;
  432. font-size: 32rpx;
  433. .btn_box {
  434. display: flex;
  435. justify-content: center;
  436. align-items: center;
  437. width: 300rpx;
  438. height: 100rpx;
  439. border-radius: 12rpx;
  440. }
  441. .type {
  442. color: #fff;
  443. background-color: #6fb6b8;
  444. }
  445. .type2 {
  446. color: #6fb6b8;
  447. border: 1rpx solid #6fb6b8;
  448. }
  449. }
  450. }
  451. </style>