transferOrder.vue 8.1 KB

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