transferOrder.vue 8.2 KB

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