| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835 |
- <template>
- <view class="container">
- <!-- 公告区域 -->
- <view class="notice">
- <uni-notice-bar show-icon single speed="10" :scrollable="true" background-color="#fff" color="#000" :text="repairsNotice" />
- </view>
- <view class="gap"></view>
- <!-- 报修区域 -->
- <view class="box_item">
- <view class="item_title">
- 报修区域
- <text>*</text>
- </view>
- <view class="item_info" :class="{ item_color: repairsArea }" @click="handleSelectArea">
- {{ repairsArea ? repairsArea : '请选择报修区域' }}
- </view>
- <view class="item_icon" @click="handleSelectArea">
- <img src="../../static/images/repairsImg/right.png" />
- </view>
- </view>
- <!-- 详细地址区域 -->
- <view class="box_item">
- <view class="item_title">
- 详细地址
- <text>*</text>
- </view>
- <view class="item_info">
- <view class="item_input">
- <input placeholder-style="color:#CCCCCC" type="text" placeholder="请输入详细地址" v-model="repairsAddress" />
- </view>
- </view>
- </view>
- <!-- 报修物品区域 -->
- <view class="box_item">
- <view class="item_title">
- 报修物品
- <text>*</text>
- </view>
- <view class="item_info" :class="{ item_color: repairsGoods }" @click="handleSelectGoods">
- {{ repairsGoods ? repairsGoods : '请选择报修物品' }}
- </view>
- <view class="item_icon" @click="handleSelectGoods">
- <img src="../../static/images/repairsImg/right.png" />
- </view>
- </view>
- <!-- 故障描述 -->
- <view class="box_item2">
- <view class="item2_title">故障描述</view>
- <view class="item2_info">
- <view class="item2_textarea">
- <textarea placeholder-style="color:#CCCCCC" placeholder="请输入故障描述" v-model="repairsDescription"></textarea>
- </view>
- </view>
- </view>
- <!-- 报修录音区域 -->
- <view class="box_item">
- <view class="item_title">报修录音</view>
- <view class="item_info" v-if="!recordingPath">
- <view class="info_icon" @click="handleRecording">
- <img src="../../static/images/repairsImg/voice.png" />
- </view>
- <view class="info_tips" @click="handleRecording">点击录音</view>
- </view>
- <view class="item_recording" v-else @click="handlePlayRecording">
- <img :src="recordingImg" />
- {{ recordingTime }}″
- </view>
- <view class="recording_icon" v-if="recordingPath" @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="box_item3">
- <view class="item3_title">
- 上传照片
- <span>*</span>
- <text>(可上传三张,请上传局部图和区域图)</text>
- </view>
- <uni-file-picker
- ref="filePicker"
- limit="3"
- v-model="imgList"
- fileMediatype="image"
- :image-styles="imageStyles"
- mode="grid"
- @select="select"
- @delete="handleDelete"
- ></uni-file-picker>
- </view>
- <!-- 报修姓名区域 -->
- <view class="box_item">
- <view class="item_title">
- 报修姓名
- <text>*</text>
- </view>
- <view class="item_info">
- <view class="item_input">
- <input placeholder-style="color:#CCCCCC" type="text" placeholder="请输入报修姓名" v-model="repairsName" />
- </view>
- </view>
- </view>
- <!-- 联系电话区域 -->
- <view class="box_item">
- <view class="item_title">
- 联系电话
- <text>*</text>
- </view>
- <view class="item_info">
- <view class="item_input">
- <input placeholder-style="color:#CCCCCC" type="number" placeholder="请输入联系电话" maxlength="11" v-model="repairsPhone" />
- </view>
- </view>
- </view>
- <!-- 底部区域 -->
- <view class="foot">
- <view class="foot_btn" @click="handleAffirmSub">确认提交</view>
- <view class="foot_phone" @click="handleCallPhone(urgencyPhoneHjh)">黄家湖紧急电话 {{ urgencyPhoneHjh }}</view>
- <view class="foot_phone" @click="handleCallPhone(urgencyPhoneMxh)">墨轩湖紧急电话 {{ urgencyPhoneMxh }}</view>
- <view class="foot_phone" @click="handleCallPhone(searchPhone)">服务监督电话 {{ searchPhone }}</view>
- </view>
- <!-- 消息通知按钮区域 -->
- <view class="fixed" @tap="handleClickFixed">
- <view class="fixed_box">
- <img src="../../static/images/repairsImg/message.png" />
- 消息通知
- </view>
- </view>
- <!-- 用于图片压缩的canvas画布 -->
- <canvas
- :style="{
- width: cw + 'px',
- height: cw + 'px',
- position: 'absolute',
- zIndex: -1,
- left: '-10000rpx',
- top: '-10000rpx'
- }"
- canvas-id="zipCanvas"
- ></canvas>
- <!--画布结束-->
- </view>
- </template>
- <script>
- import recording from '../components/recording.vue'
- // 图片压缩方法
- import getLessLimitSizeImage from '../util/imageCompress.js'
- const innerAudioContext = uni.createInnerAudioContext()
- export default {
- components: {
- recording
- },
- data() {
- return {
- // 报修公告
- repairsNotice: '',
- // 报修区域
- repairsArea: '',
- // 地址ID
- addressId: null,
- // 报修地址
- repairsAddress: '',
- // 报修物品
- repairsGoods: '',
- // 报修物品ID
- articleId: '',
- // 故障描述
- repairsDescription: '',
- // 报修姓名
- repairsName: '',
- // 联系电话
- repairsPhone: '',
- // 黄家湖紧急电话
- urgencyPhoneHjh: '',
- // 墨轩湖紧急电话
- urgencyPhoneMxh: '',
- // 服务电话
- searchPhone: '',
- // 播放状态
- playStatus: false,
- // 定时器标识
- timer: null,
- // 录音图片地址
- recordingImg: '../../static/images/repairsImg/recording.jpg',
- // 录音文件路径
- recordingPath: '',
- // 录音时长
- recordingTime: 0,
- // 显示的图片数据
- imgList: [],
- // 上传的图片数据
- subImgList: [],
- // 图片上传框的样式
- imageStyles: {
- width: 60,
- height: 60
- },
- //画板边长默认是屏幕宽度,正方形画布
- cw: uni.getSystemInfoSync().windowWidth,
- // 当前校区Id
- schoolId: null,
- // 楼栋Id
- buildId: null
- }
- },
- mounted() {
- // 页面之间通讯监听自定义事件
- uni.$on('addRepairsArea', this.addRepairsArea)
- uni.$on('addRepairsGoods', this.addRepairsGoods)
- //在ios下静音时播放没有声音,默认为true,改为false静音时播放有声音
- uni.setInnerAudioOption({
- obeyMuteSwitch: false
- })
- // 获取用户默认姓名
- this.repairsName = uni.getStorageSync('repairsUserInfo').userName
- // 获取用户默认手机号码
- this.repairsPhone = uni.getStorageSync('repairsUserInfo').userPhone
- this.getRepairNotice()
- this.getSetPhone()
- },
- methods: {
- // 获取首页公告展示数据
- async getRepairNotice() {
- const res = await this.$myRequest_repairs({
- url: '/repairNoticeSetting/queryRepairNoticeSettingByTop'
- })
- // console.log(res)
- if (res.code === '200') {
- this.repairsNotice = res.data.noticeStr
- }
- },
- // 获取紧急电话和服务监督电话
- async getSetPhone() {
- const res = await this.$myRequest_repairs({
- url: '/repairSystemSetting/queryRepairSystemSetting'
- })
- // console.log(res)
- if (res.code === '200') {
- this.urgencyPhoneHjh = res.data.emergencyCall
- this.urgencyPhoneMxh = res.data.emergencyMxh
- this.searchPhone = res.data.servicePhone
- }
- },
- // 确认提交按钮回调
- handleAffirmSub() {
- // 验证提交数据是否符合标准
- const flag = this.handleValidate()
- if (flag) {
- uni.showModal({
- title: '提示',
- content: '确认提交吗?',
- success: async (res) => {
- if (res.confirm) {
- const repairsUserInfo = uni.getStorageSync('repairsUserInfo')
- const res = await this.$myRequest_repairs({
- url: '/repairRecord/insertRepairRecord',
- method: 'post',
- data: {
- // 报修区域
- areaId: this.repairsArea,
- // 详细地址
- address: this.repairsAddress,
- // 报修物品ID
- articleId: this.articleId,
- // 故障描述
- description: this.repairsDescription,
- // 报修录音
- voice: this.recordingPath,
- // 报修录音时长
- voiceLength: this.recordingTime,
- // 故障图片集合
- images: this.subImgList,
- // 报修姓名
- userName: this.repairsName,
- // 报修电话
- userPhone: this.repairsPhone,
- // 报修人ID
- userId: repairsUserInfo.userId,
- // 校区ID
- schoolId: this.schoolId,
- // 地址ID
- buildId: this.addressId
- }
- })
- // console.log(res)
- if (res.code === '200') {
- uni.showToast({
- title: res.message,
- icon: 'success',
- mask: true
- })
- // 不是用户报修的单,则跳转回首页
- if (repairsUserInfo.routes.includes('首页')) {
- setTimeout(() => {
- uni.reLaunch({
- url: '/pagesRepairs/box/box'
- })
- }, 1500)
- } else {
- setTimeout(() => {
- uni.$emit('goToMyRepairs', {
- show: 'myRepairs',
- title: '我的报修'
- })
- }, 1500)
- }
- }
- }
- }
- })
- }
- },
- // 验证信息是否符合规范
- handleValidate() {
- const reName = /^[\u4e00-\u9fa5]{2,4}$/
- const rePhone = /^1[3-9]\d{9}$/
- if (!this.repairsArea) {
- uni.showToast({
- title: '请选择报修区域',
- icon: 'none'
- })
- return
- }
- if (!this.repairsAddress) {
- uni.showToast({
- title: '请输入详细地址',
- icon: 'none'
- })
- return
- }
- if (!this.repairsGoods) {
- uni.showToast({
- title: '请选择报修物品',
- icon: 'none'
- })
- return
- }
- if (this.subImgList.length == 0) {
- uni.showToast({
- title: '请上传报修照片',
- icon: 'none'
- })
- return
- }
- if (!this.repairsName) {
- uni.showToast({
- title: '请输入报修姓名',
- icon: 'none'
- })
- return false
- }
- if (!reName.test(this.repairsName)) {
- uni.showToast({
- title: '姓名格式有误',
- icon: 'none'
- })
- return false
- }
- if (!this.repairsPhone) {
- uni.showToast({
- title: '请输入联系电话',
- icon: 'none'
- })
- return false
- }
- if (!rePhone.test(this.repairsPhone)) {
- uni.showToast({
- title: '电话号码格式有误',
- icon: 'none'
- })
- return false
- }
- return true
- },
- // 全局自定义事件
- addRepairsArea(e) {
- // console.log(e)
- this.repairsArea = e.data
- this.schoolId = e.schoolId
- this.buildId = e.buildId
- this.addressId = e.addressId
- },
- // 全局自定义事件
- addRepairsGoods(e) {
- // console.log(e)
- this.repairsGoods = e.data
- this.articleId = e.articleId
- },
- // 删除录音回调
- handleDeleteRecording() {
- if (this.playStatus) {
- uni.showToast({
- title: '播放中不能删除',
- icon: 'none',
- mask: true
- })
- } else {
- uni.showModal({
- title: '提示',
- content: '确定删除录音吗?',
- success: (res) => {
- if (res.confirm) {
- this.recordingPath = ''
- this.recordingTime = 0
- }
- }
- })
- }
- },
- // 点击录音播放回调
- handlePlayRecording() {
- innerAudioContext.src = this.recordingPath
- 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()
- }
- },
- // 自定义事件回调,获取录音文件路径
- getTempFilePath(path, time) {
- this.recordingPath = path
- this.recordingTime = time
- this.$refs.popup_recording.close()
- },
- // 选择图片回调
- select(e) {
- // console.log(e)
- e.tempFiles.forEach((item) => {
- //这里的id和页面中写的html代码的canvas的id要一致
- let canvasId = 'zipCanvas'
- //原图的路径
- let imagePath = item.path
- //大小限制1024kb
- let limitSize = 1024 * 3
- //初始绘画区域是画布自身的宽度也就是屏幕宽度
- let drawWidth = uni.getSystemInfoSync().windowWidth
- let that = this
- getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, that, (resPath) => {
- uni.showLoading({
- title: '上传中'
- })
- uni.uploadFile({
- url: `https://chtech.ncjti.edu.cn/campusMaintenance/repair-api/repair/api/repairRecord/uploadFile`,
- filePath: resPath,
- name: 'file',
- header: {
- token: uni.getStorageSync('repairsUserInfo').token,
- user_head: uni.getStorageSync('repairsUserInfo').userhead
- },
- success: (uploadFileRes) => {
- // console.log(JSON.parse(uploadFileRes.data))
- this.subImgList.push(JSON.parse(uploadFileRes.data).data.resultUrl)
- this.imgList.push({
- url: item.path,
- name: ''
- })
- uni.hideLoading()
- },
- fail: () => {
- uni.showToast({
- title: '上传失败',
- icon: 'error'
- })
- }
- })
- })
- })
- },
- // 删除图片回调
- handleDelete(e) {
- // console.log(e);
- const num = this.imgList.findIndex((v) => v.url === e.tempFilePath)
- this.subImgList.splice(num, 1)
- this.imgList.splice(num, 1)
- },
- // 点击报修区域回调
- handleSelectArea() {
- this.repairsAddress = ''
- this.repairsGoods = ''
- uni.navigateTo({
- url: `/pagesRepairs/selectArea/selectArea?schoolId=${this.schoolId}&buildId=${this.buildId}&addressId=${this.addressId}`
- })
- },
- // 点击报修物品回调
- handleSelectGoods() {
- if (this.schoolId) {
- uni.navigateTo({
- url: `/pagesRepairs/selectGoods/selectGoods?schoolId=${this.schoolId}`
- })
- } else {
- uni.showToast({
- title: '请先选择报修区域',
- icon: 'none'
- })
- }
- },
- // 点击消息通知按钮回调
- handleClickFixed() {
- uni.navigateTo({
- url: '/pagesRepairs/message/message'
- })
- },
- // 点击电话号码回调
- handleCallPhone(phone) {
- uni.makePhoneCall({
- phoneNumber: phone
- })
- },
- // 点击录音按钮回调
- 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'
- })
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- width: 100vw;
- height: calc(100vh - 152rpx);
- overflow-y: auto;
- .notice {
- height: 90rpx;
- }
- .gap {
- height: 12rpx;
- background-color: #f2f2f2;
- }
- .box_item {
- display: flex;
- align-items: center;
- margin: 0 30rpx;
- height: 105rpx;
- font-size: 28rpx;
- border-bottom: 1rpx solid #e6e6e6;
- .item_title {
- width: 190rpx;
- font-weight: bold;
- text {
- margin-left: 5rpx;
- color: #d43030;
- }
- }
- .item_info {
- flex: 1;
- display: flex;
- align-items: center;
- padding: 0 10rpx;
- height: 100%;
- color: #cccccc;
- .item_input {
- width: 100%;
- height: 105rpx;
- input {
- height: 105rpx;
- line-height: 105rpx;
- color: #000;
- }
- }
- .info_icon {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 79rpx;
- height: 37rpx;
- border-radius: 33rpx;
- border: 1rpx solid #e6e6e6;
- img {
- width: 26rpx;
- height: 26rpx;
- }
- }
- .info_tips {
- margin-left: 33rpx;
- font-size: 28rpx;
- color: #cccccc;
- }
- }
- .item_color {
- color: #000;
- }
- .item_icon {
- width: 38rpx;
- height: 38rpx;
- img {
- width: 100%;
- height: 100%;
- }
- }
- .item_recording {
- display: flex;
- align-items: center;
- width: 200rpx;
- height: 50rpx;
- border-radius: 100rpx;
- border: 1rpx solid #cccccc;
- img {
- margin: 0 12rpx;
- width: 40rpx;
- height: 40rpx;
- }
- }
- .recording_icon {
- margin-left: auto;
- font-size: 40rpx;
- }
- }
- .box_item2 {
- display: flex;
- align-items: center;
- margin: 0 30rpx;
- height: 237rpx;
- font-size: 28rpx;
- border-bottom: 1rpx solid #e6e6e6;
- .item2_title {
- width: 190rpx;
- font-weight: bold;
- text {
- margin-left: 5rpx;
- color: #d43030;
- }
- }
- .item2_info {
- flex: 1;
- padding: 0 10rpx;
- .item2_textarea {
- display: flex;
- align-items: center;
- width: 100%;
- height: 237rpx;
- textarea {
- box-sizing: border-box;
- padding: 20rpx;
- width: 500rpx;
- height: 176rpx;
- border: 1rpx solid #e6e6e6;
- border-radius: 6rpx;
- }
- }
- }
- }
- .box_item3 {
- margin: 0 30rpx;
- height: 246rpx;
- border-bottom: 1rpx solid #e6e6e6;
- .item3_title {
- height: 95rpx;
- line-height: 95rpx;
- font-size: 28rpx;
- font-weight: bold;
- span {
- margin-left: 5rpx;
- color: #d43030;
- }
- text {
- font-size: 24rpx;
- color: #808080;
- font-weight: 400;
- }
- }
- }
- .foot {
- display: flex;
- flex-direction: column;
- align-items: center;
- margin: 0 30rpx;
- height: 407rpx;
- .foot_btn {
- margin-top: 167rpx;
- width: 100%;
- height: 100rpx;
- line-height: 100rpx;
- text-align: center;
- color: #fff;
- font-size: 32rpx;
- border-radius: 12rpx;
- background-color: #6fb6b8;
- }
- .foot_phone {
- margin-top: 30rpx;
- color: #b3b3b3;
- font-size: 24rpx;
- }
- }
- .fixed {
- z-index: 2;
- position: fixed;
- right: 0;
- bottom: 200rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- width: 211rpx;
- height: 90rpx;
- border-radius: 150rpx 0 0 150rpx;
- border: 1rpx solid #d9d9d9;
- background-color: #fff;
- box-shadow: 0 0 7rpx #d9d9d9;
- .fixed_box {
- display: flex;
- align-items: center;
- font-size: 28rpx;
- img {
- margin-right: 10rpx;
- width: 38rpx;
- height: 38rpx;
- }
- }
- }
- .popup_recording {
- width: 100%;
- height: 460rpx;
- background-color: #fff;
- }
- }
- </style>
|