help.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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">张三</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 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="!recordingPath" @click="handleRecording">
  18. <img src="../../static/images/repairsImg/voice.png" />
  19. </view>
  20. <view v-if="!recordingPath" @click="handleRecording">点击录音</view>
  21. <view class="item_recording" v-if="recordingPath" @click="handlePlayRecording">
  22. <img :src="recordingImg" />
  23. {{ recordingTime }}″
  24. </view>
  25. <view class="recording_icon" v-if="recordingPath" @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="请输入协作说明" v-model="desc"></textarea>
  36. </view>
  37. <view class="btn2" v-if="type === '1'">
  38. <view class="btn_box type">拒绝</view>
  39. <view class="btn_box type2">派单</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. type: null,
  54. peoples: '',
  55. desc: '',
  56. // 录音文件路径
  57. recordingPath: '',
  58. // 录音图片地址
  59. recordingImg: '../../static/images/repairsImg/recording.jpg',
  60. // 录音时长
  61. recordingTime: 0,
  62. // 播放状态
  63. playStatus: false,
  64. // 定时器标识
  65. timer: null
  66. }
  67. },
  68. mounted() {
  69. //在ios下静音时播放没有声音,默认为true,改为false就好了。
  70. uni.setInnerAudioOption({
  71. obeyMuteSwitch: false
  72. })
  73. },
  74. onLoad(options) {
  75. console.log(options)
  76. if (options.type) {
  77. this.type = options.type
  78. }
  79. uni.$on('addCheckList', this.addCheckList)
  80. },
  81. methods: {
  82. addCheckList(e) {
  83. // console.log(e)
  84. let temList = []
  85. e.data.forEach((ele) => {
  86. temList.push(ele.name)
  87. })
  88. this.peoples = temList.toString()
  89. },
  90. // 确认按钮回调
  91. handleAffirm() {
  92. uni.showModal({
  93. title: '提示',
  94. content: '确认提交协作申请吗?',
  95. success: (res) => {
  96. if (res.confirm) {
  97. console.log(this.recordingPath)
  98. console.log(this.desc)
  99. console.log(this.peoples)
  100. uni.showToast({
  101. title: '提交协作申请成功,请等待管理员审核',
  102. icon: 'none',
  103. duration: 3000
  104. })
  105. setTimeout(() => {
  106. uni.redirectTo({
  107. url: '/pagesRepairs/box/box'
  108. })
  109. }, 3000)
  110. }
  111. }
  112. })
  113. },
  114. handleHelpPeople() {
  115. uni.navigateTo({
  116. url: '/pagesRepairs/helpPeople/helpPeople'
  117. })
  118. },
  119. // 点击录音按钮回调
  120. handleRecording() {
  121. uni.getSetting({
  122. success: (res) => {
  123. if (!res.authSetting['scope.record']) {
  124. uni.authorize({
  125. scope: 'scope.record',
  126. success(res) {
  127. // 授权成功
  128. uni.showToast({
  129. title: '授权成功',
  130. icon: 'none'
  131. })
  132. },
  133. fail() {
  134. uni.showModal({
  135. content: '检测到您没打开麦克风权限,是否去设置打开?',
  136. confirmText: '确认',
  137. cancelText: '取消',
  138. success: (res) => {
  139. if (res.confirm) {
  140. uni.openSetting({
  141. success: (res) => {}
  142. })
  143. } else {
  144. uni.showToast({
  145. title: '获取麦克风权限失败',
  146. icon: 'none'
  147. })
  148. }
  149. }
  150. })
  151. }
  152. })
  153. } else {
  154. this.$refs.popup_recording.open('bottom')
  155. }
  156. },
  157. fail() {
  158. uni.showToast({
  159. title: '获取麦克风权限失败',
  160. icon: 'none'
  161. })
  162. }
  163. })
  164. },
  165. // 点击录音播放回调
  166. handlePlayRecording() {
  167. innerAudioContext.src = this.recordingPath
  168. if (!this.playStatus) {
  169. this.playStatus = true
  170. innerAudioContext.play()
  171. this.timer = setInterval(() => {
  172. if (this.recordingImg == '../../static/images/repairsImg/recording.jpg') {
  173. this.recordingImg = '../../static/images/repairsImg/recording2.jpg'
  174. } else if (this.recordingImg == '../../static/images/repairsImg/recording2.jpg') {
  175. this.recordingImg = '../../static/images/repairsImg/recording3.jpg'
  176. } else if (this.recordingImg == '../../static/images/repairsImg/recording3.jpg') {
  177. this.recordingImg = '../../static/images/repairsImg/recording.jpg'
  178. }
  179. }, 300)
  180. //播放结束
  181. innerAudioContext.onEnded(() => {
  182. clearInterval(this.timer)
  183. this.timer = null
  184. this.recordingImg = '../../static/images/repairsImg/recording.jpg'
  185. this.playStatus = false
  186. })
  187. } else {
  188. clearInterval(this.timer)
  189. this.recordingImg = '../../static/images/repairsImg/recording.jpg'
  190. this.playStatus = false
  191. innerAudioContext.stop()
  192. }
  193. },
  194. // 删除录音回调
  195. handleDeleteRecording() {
  196. if (this.playStatus) {
  197. uni.showToast({
  198. title: '播放中不能删除',
  199. icon: 'none',
  200. mask: true
  201. })
  202. } else {
  203. uni.showModal({
  204. title: '提示',
  205. content: '确定删除录音吗?',
  206. success: (res) => {
  207. if (res.confirm) {
  208. this.recordingPath = ''
  209. this.recordingTime = 0
  210. }
  211. }
  212. })
  213. }
  214. },
  215. // 自定义事件回调,获取录音文件路径
  216. getTempFilePath(path, time) {
  217. this.recordingPath = path
  218. this.recordingTime = time
  219. this.$refs.popup_recording.close()
  220. }
  221. }
  222. }
  223. </script>
  224. <style lang="scss" scoped>
  225. .container {
  226. box-sizing: border-box;
  227. padding: 0 30rpx;
  228. height: 100vh;
  229. overflow-y: auto;
  230. .title {
  231. display: flex;
  232. align-items: center;
  233. height: 107rpx;
  234. font-size: 36rpx;
  235. font-weight: bold;
  236. }
  237. .box {
  238. display: flex;
  239. align-items: center;
  240. height: 94rpx;
  241. font-size: 32rpx;
  242. border-radius: 10rpx;
  243. border: 1rpx solid #cccccc;
  244. .box_info {
  245. flex: 1;
  246. }
  247. .color {
  248. color: #ccc;
  249. }
  250. img {
  251. margin: 0 14rpx 0 30rpx;
  252. width: 48rpx;
  253. height: 48rpx;
  254. }
  255. .img {
  256. width: 40rpx;
  257. height: 40rpx;
  258. }
  259. }
  260. .voice {
  261. display: flex;
  262. align-items: center;
  263. height: 94rpx;
  264. font-size: 32rpx;
  265. color: #cccccc;
  266. border-radius: 10rpx;
  267. border: 1rpx solid #cccccc;
  268. .voice_box {
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. margin: 0 38rpx 0 33rpx;
  273. width: 101rpx;
  274. height: 47rpx;
  275. border-radius: 33rpx;
  276. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  277. img {
  278. width: 33rpx;
  279. height: 33rpx;
  280. }
  281. }
  282. .item_recording {
  283. margin-left: 35rpx;
  284. display: flex;
  285. align-items: center;
  286. width: 230rpx;
  287. height: 65rpx;
  288. color: #000;
  289. border-radius: 100rpx;
  290. border: 1rpx solid #cccccc;
  291. img {
  292. margin: 0 12rpx;
  293. width: 40rpx;
  294. height: 40rpx;
  295. }
  296. }
  297. .recording_icon {
  298. margin-left: auto;
  299. margin-right: 35rpx;
  300. font-size: 40rpx;
  301. }
  302. }
  303. .popup_recording {
  304. width: 100%;
  305. height: 460rpx;
  306. background-color: #fff;
  307. }
  308. .textarea {
  309. height: 310rpx;
  310. border-radius: 10rpx;
  311. border: 1rpx solid #cccccc;
  312. textarea {
  313. box-sizing: border-box;
  314. padding: 25rpx 35rpx;
  315. width: 100%;
  316. font-size: 32rpx;
  317. }
  318. }
  319. .btn {
  320. position: absolute;
  321. bottom: 66rpx;
  322. display: flex;
  323. justify-content: center;
  324. align-items: center;
  325. margin: auto;
  326. width: 690rpx;
  327. height: 100rpx;
  328. color: #fff;
  329. font-size: 32rpx;
  330. border-radius: 12rpx;
  331. background-color: #6fb6b8;
  332. }
  333. .btn2 {
  334. display: flex;
  335. justify-content: space-between;
  336. align-items: center;
  337. margin: 200rpx auto 70rpx;
  338. width: 690rpx;
  339. height: 100rpx;
  340. font-size: 32rpx;
  341. .btn_box {
  342. display: flex;
  343. justify-content: center;
  344. align-items: center;
  345. width: 300rpx;
  346. height: 100rpx;
  347. border-radius: 12rpx;
  348. }
  349. .type {
  350. color: #fff;
  351. background-color: #6fb6b8;
  352. }
  353. .type2 {
  354. color: #6fb6b8;
  355. border: 1rpx solid #6fb6b8;
  356. }
  357. }
  358. }
  359. </style>