| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484 |
- <template>
- <view class="container">
- <view class="title" v-if="type === '1'">申请人</view>
- <view class="box" v-if="type === '1'">
- <img src="../../static/images/repairsImg/people.png" />
- <view class="box_info">{{ info.userName }}</view>
- </view>
- <view class="title">协作对象</view>
- <view class="box" @click="handleHelpPeople">
- <img src="../../static/images/repairsImg/peoples.png" />
- <view class="box_info" :class="{ color: !peoples }">{{ peoples ? peoples : '请选择协作对象' }}</view>
- <img v-if="type !== '1'" class="img" src="../../static/images/repairsImg/right.png" />
- </view>
- <view class="title">转单语音说明</view>
- <!-- 录音区域 -->
- <view class="voice">
- <view class="voice_box" v-if="!info.voice" @click="handleRecording">
- <img src="../../static/images/repairsImg/voice.png" />
- </view>
- <view v-if="!info.voice" @click="handleRecording">点击录音</view>
- <view class="item_recording" v-if="info.voice" @click="handlePlayRecording">
- <img :src="recordingImg" />
- {{ info.voiceLength || 0 }}″
- </view>
- <view class="recording_icon" v-if="info.voice && type !== '1'" @click="handleDeleteRecording">×</view>
- </view>
- <!-- 录音弹窗区域 -->
- <uni-popup :safe-area="true" background-color="#fff" ref="popup_recording">
- <view class="popup_recording">
- <recording @getTempFilePath="getTempFilePath" />
- </view>
- </uni-popup>
- <view class="title">备注</view>
- <view class="textarea">
- <textarea placeholder-style="color:#CCCCCC" placeholder="请输入协作说明" :disabled="type === '1'" v-model="info.remark"></textarea>
- </view>
- <view class="btn2" v-if="type === '1'">
- <view class="btn_box type" @click="handleDispose(0)">拒绝</view>
- <view class="btn_box type2" @click="handleDispose(1)">派单</view>
- </view>
- <view class="btn" v-else @click="handleAffirm">确认</view>
- </view>
- </template>
- <script>
- import recording from '../components/recording.vue'
- const innerAudioContext = uni.createInnerAudioContext()
- export default {
- components: {
- recording
- },
- data() {
- return {
- // 页面类型
- type: null,
- // 录音图片地址
- recordingImg: '../../static/images/repairsImg/recording.jpg',
- // 播放状态
- playStatus: false,
- // 定时器标识
- timer: null,
- // 订单id
- recordId: '',
- info: {
- // 申请人
- userName: '',
- // 协作对象数组
- collaboratorDatas: [],
- // 语音地址
- voice: '',
- // 备注
- remark: '',
- // 录音时长
- voiceLength: 0
- }
- }
- },
- computed: {
- // 协作对象
- peoples() {
- let temList = []
- temList = this.info.collaboratorDatas.map((ele) => ele.userName || ele.name)
- let res = temList.toString()
- return res
- },
- idList() {
- let temList = []
- this.info.collaboratorDatas.forEach((ele) => {
- temList.push(ele.id)
- })
- return temList
- }
- },
- mounted() {
- //在ios下静音时播放没有声音,默认为true,改为false就好了。
- uni.setInnerAudioOption({
- obeyMuteSwitch: false
- })
- },
- onLoad(options) {
- this.recordId = options.id
- if (options.type) {
- this.type = options.type
- this.getHelpData()
- }
- uni.$on('addCheckList', this.addCheckList)
- },
- methods: {
- // 拒绝 派单 按钮回调
- async handleDispose(type) {
- const res = await this.$myRequest_repairs({
- url: '/repairRecord/cooperationOrders',
- method: 'post',
- data: {
- id: this.info.id,
- collaborator: this.idList,
- approverStatu: type
- }
- })
- // console.log(res)
- if (res.code === '200') {
- uni.showToast({
- title: `${type === 0 ? '已拒绝该审核' : '派单成功'}`,
- icon: 'none'
- })
- setTimeout(() => {
- uni.reLaunch({
- url: '/pagesRepairs/box/box'
- })
- }, 1500)
- }
- },
- // 获取审核订单详细数据
- async getHelpData() {
- const res = await this.$myRequest_repairs({
- url: '/repairRecord/cooperationDetail',
- data: {
- recordId: this.recordId
- }
- })
- // console.log(res)
- if (res.code === '200') {
- this.info = res.data
- }
- },
- addCheckList(e) {
- this.info.collaboratorDatas = e.data
- },
- // 确认按钮回调
- handleAffirm() {
- if (!this.peoples) {
- uni.showToast({
- title: '请选择协作对象',
- icon: 'none'
- })
- return
- }
- if (!this.info.voice) {
- uni.showToast({
- title: '请录入转单语音说明',
- icon: 'none'
- })
- return
- }
- uni.showModal({
- title: '提示',
- content: '确认提交协作申请吗?',
- success: async (res) => {
- if (res.confirm) {
- let temList = this.info.collaboratorDatas.map((ele) => ele.id)
- const res = await this.$myRequest_repairs({
- url: '/repairRecord/collaborateApply',
- method: 'post',
- data: {
- recordId: this.recordId,
- userId: uni.getStorageSync('repairsUserInfo').userId,
- voice: this.info.voice,
- voiceLength: this.info.voiceLength,
- collaborator: temList,
- remark: this.info.remark
- }
- })
- // console.log(res)
- if (res.code === '200') {
- uni.showToast({
- title: '提交协作申请成功,请等待管理员审核',
- icon: 'none',
- duration: 3000
- })
- setTimeout(() => {
- uni.reLaunch({
- url: '/pagesRepairs/box/box'
- })
- }, 3000)
- }
- }
- }
- })
- },
- handleHelpPeople() {
- if (this.type !== '1') {
- uni.navigateTo({
- url: `/pagesRepairs/helpPeople/helpPeople?id=${this.recordId}`
- })
- }
- },
- // 点击录音按钮回调
- handleRecording() {
- uni.getSetting({
- success: (res) => {
- if (!res.authSetting['scope.record']) {
- uni.authorize({
- scope: 'scope.record',
- success(res) {
- // 授权成功
- uni.showToast({
- title: '授权成功',
- icon: 'none'
- })
- },
- fail() {
- uni.showModal({
- content: '检测到您没打开麦克风权限,是否去设置打开?',
- confirmText: '确认',
- cancelText: '取消',
- success: (res) => {
- if (res.confirm) {
- uni.openSetting({
- success: (res) => {}
- })
- } else {
- uni.showToast({
- title: '获取麦克风权限失败',
- icon: 'none'
- })
- }
- }
- })
- }
- })
- } else {
- this.$refs.popup_recording.open('bottom')
- }
- },
- fail() {
- uni.showToast({
- title: '获取麦克风权限失败',
- icon: 'none'
- })
- }
- })
- },
- // 点击录音播放回调
- handlePlayRecording() {
- innerAudioContext.src = this.info.voice
- if (!this.playStatus) {
- this.playStatus = true
- innerAudioContext.play()
- this.timer = setInterval(() => {
- if (this.recordingImg == '../../static/images/repairsImg/recording.jpg') {
- this.recordingImg = '../../static/images/repairsImg/recording2.jpg'
- } else if (this.recordingImg == '../../static/images/repairsImg/recording2.jpg') {
- this.recordingImg = '../../static/images/repairsImg/recording3.jpg'
- } else if (this.recordingImg == '../../static/images/repairsImg/recording3.jpg') {
- this.recordingImg = '../../static/images/repairsImg/recording.jpg'
- }
- }, 300)
- //播放结束
- innerAudioContext.onEnded(() => {
- clearInterval(this.timer)
- this.timer = null
- this.recordingImg = '../../static/images/repairsImg/recording.jpg'
- this.playStatus = false
- })
- } else {
- clearInterval(this.timer)
- this.recordingImg = '../../static/images/repairsImg/recording.jpg'
- this.playStatus = false
- innerAudioContext.stop()
- }
- },
- // 删除录音回调
- handleDeleteRecording() {
- if (this.playStatus) {
- uni.showToast({
- title: '播放中不能删除',
- icon: 'none',
- mask: true
- })
- } else {
- uni.showModal({
- title: '提示',
- content: '确定删除录音吗?',
- success: (res) => {
- if (res.confirm) {
- this.info.voice = ''
- this.info.voiceLength = 0
- }
- }
- })
- }
- },
- // 自定义事件回调,获取录音文件路径
- getTempFilePath(path, time) {
- this.info.voice = path
- this.info.voiceLength = time
- this.$refs.popup_recording.close()
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- box-sizing: border-box;
- padding: 0 30rpx;
- height: 100vh;
- overflow-y: auto;
- .title {
- display: flex;
- align-items: center;
- height: 107rpx;
- font-size: 36rpx;
- font-weight: bold;
- }
- .box {
- display: flex;
- align-items: center;
- height: 94rpx;
- font-size: 32rpx;
- border-radius: 10rpx;
- border: 1rpx solid #cccccc;
- .box_info {
- flex: 1;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .color {
- color: #ccc;
- }
- img {
- margin: 0 14rpx 0 30rpx;
- width: 48rpx;
- height: 48rpx;
- }
- .img {
- width: 40rpx;
- height: 40rpx;
- }
- }
- .voice {
- display: flex;
- align-items: center;
- height: 94rpx;
- font-size: 32rpx;
- color: #cccccc;
- border-radius: 10rpx;
- border: 1rpx solid #cccccc;
- .voice_box {
- display: flex;
- justify-content: center;
- align-items: center;
- margin: 0 38rpx 0 33rpx;
- width: 101rpx;
- height: 47rpx;
- border-radius: 33rpx;
- box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
- img {
- width: 33rpx;
- height: 33rpx;
- }
- }
- .item_recording {
- margin-left: 35rpx;
- display: flex;
- align-items: center;
- width: 230rpx;
- height: 65rpx;
- color: #000;
- border-radius: 100rpx;
- border: 1rpx solid #cccccc;
- img {
- margin: 0 12rpx;
- width: 40rpx;
- height: 40rpx;
- }
- }
- .recording_icon {
- margin-left: auto;
- margin-right: 35rpx;
- font-size: 40rpx;
- }
- }
- .popup_recording {
- width: 100%;
- height: 460rpx;
- background-color: #fff;
- }
- .textarea {
- height: 310rpx;
- border-radius: 10rpx;
- border: 1rpx solid #cccccc;
- textarea {
- box-sizing: border-box;
- padding: 25rpx 35rpx;
- width: 100%;
- font-size: 32rpx;
- }
- }
- .btn {
- position: absolute;
- bottom: 66rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- margin: auto;
- width: 690rpx;
- height: 100rpx;
- color: #fff;
- font-size: 32rpx;
- border-radius: 12rpx;
- background-color: #6fb6b8;
- }
- .btn2 {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin: 200rpx auto 70rpx;
- width: 690rpx;
- height: 100rpx;
- font-size: 32rpx;
- .btn_box {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 300rpx;
- height: 100rpx;
- border-radius: 12rpx;
- }
- .type {
- color: #fff;
- background-color: #6fb6b8;
- }
- .type2 {
- color: #6fb6b8;
- border: 1rpx solid #6fb6b8;
- }
- }
- }
- </style>
|