help.vue 8.2 KB

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