flying-monkey/pagesA/repairsPage/repairsPage.vue

519 lines
16 KiB
Vue
Raw Normal View History

2022-03-17 05:47:40 +00:00
<template>
<view class="content">
2022-03-28 09:42:48 +00:00
<status-nav navBarTitle="添加报修" returnColor="#c2c2c2"></status-nav>
<container-subgroup>
<view slot="content" style="margin: 0 -30rpx;">
<view class="repairs-nav" style="margin-top: -30rpx;">
2022-05-13 09:39:50 +00:00
<view class="li" @click="repairsNavFun(index)" :class="current==index ?'on':''"
v-for="(item,index) in navDataState" :key="index">
{{item}}
2022-03-28 09:42:48 +00:00
</view>
</view>
<view class="repairs-hint padding">
<image class="icon" src="../../static/iocn/lp.png" mode="aspectFill"></image>
<view class="text">
请务必拍好维保照片或视频上传,便于技术工程师作为判断依据,带齐 相关维保设备高效为您提供服务
2022-03-28 09:42:48 +00:00
</view>
</view>
<view class="fault-type-title padding">维保类型</view>
2022-03-28 09:42:48 +00:00
<view class="padding fault-type-content">
2022-03-31 09:58:34 +00:00
<view class="li" @click="repairsTypeFun(index)" :class="index==indexType?'on':''"
2022-03-28 09:42:48 +00:00
v-for="(item,index) in faultTypeData">
2022-03-31 09:58:34 +00:00
{{item.name}}
2022-03-28 09:42:48 +00:00
</view>
</view>
<view class="padding">
2022-05-13 09:39:50 +00:00
<view class="devicename" v-if="current==0">
<input type="text" class="fon28 width100 col3" v-model="data.project_number" placeholder="请填写设备编号或扫描二维码" />
<image @click="scanCodeFun" class="sm flexs" src="../../static/iocn/sm.png" lazy-load mode=""></image>
2022-03-28 09:42:48 +00:00
</view>
2022-05-13 09:39:50 +00:00
<input v-else v-model="data.device_name" class="devicename" placeholder="请填写设备名称和型号(例:华为LED" />
2022-04-01 08:56:35 +00:00
<view class="fault-pictures radius10" @click="chooseImg">
2022-05-13 09:39:50 +00:00
<image class="fault-pictures-img" v-if="imgsrcArr.length>=1" :src="imgsrcArr[0]" mode="aspectFill"></image>
2022-04-01 06:35:42 +00:00
<view class="fault-pictures-con" v-else>
2022-04-06 08:07:18 +00:00
<image class="img" src="../../static/iocn/gz.png" lazy-load mode="aspectFill"></image>
<view class="text">添加维保图片</view>
2022-04-06 08:07:18 +00:00
</view>
2022-03-28 09:42:48 +00:00
</view>
<textarea v-model="data.fault_describe" class="fault-description radius10" placeholder="维保情况描述"
2022-03-28 09:42:48 +00:00
placeholder-class="fault-description-text" />
<view class="detailed-address inputCss">
2022-05-13 09:39:50 +00:00
<input type="text" v-model="data.service_address" class="fon26 width100 mar-y20" placeholder="请输入详细的上门服务地址" placeholder-class="inputCss-input" />
<image @click="mapFun" src="../../static/iocn/map.png" class="map flexs" mode="aspectFill"></image>
2022-03-28 09:42:48 +00:00
</view>
2022-05-13 09:39:50 +00:00
<input type="text" class="inputCss" v-model="data.username" placeholder="请填写您的姓名" placeholder-class="inputCss-input" />
<input type="number" maxlength="11" class="inputCss" v-model="data.phone" placeholder="请填写联系电话" placeholder-class="inputCss-input" />
<input type="text" class="inputCss" @tap="openDatetimePicker" disabled v-model="data.visit_time" placeholder="请选择上门时间" placeholder-class="inputCss-input" />
<yy-mm-dd-hh-ss ref="myPicker" @submit="handleSubmit" :start-year="2022" :end-year="2122"></yy-mm-dd-hh-ss>
<button class="submit-button" @click="submitButton()" type="default">提交维保申报</button>
2022-03-28 09:42:48 +00:00
</view>
</view>
</container-subgroup>
2022-03-17 05:47:40 +00:00
</view>
</template>
<script>
2022-04-01 06:35:42 +00:00
import yyMmDdHhSs from '@/components/dates/yy-mm-dd-hh-ss.vue';
import {getFaultType} from '@/jsFile/public-api.js';
2022-04-06 08:07:18 +00:00
import {
uploadImg
} from '@/jsFile/public-api.js';
2022-05-13 09:39:50 +00:00
// 引入qrcode.js 必须导出qrcode.js
var qrcode = require('@/jsFile/qrcode.js');
2022-03-17 05:47:40 +00:00
export default {
2022-04-01 06:35:42 +00:00
components: {
yyMmDdHhSs
},
2022-03-17 05:47:40 +00:00
data() {
return {
single: "2021-04-3",
2022-03-31 09:58:34 +00:00
data: {
is_device: 0,
fault_type: "",
2022-04-07 03:08:28 +00:00
device_name: "",
2022-04-01 06:35:42 +00:00
project_number: "",
2022-04-06 08:07:18 +00:00
service_address: "",
2022-03-31 09:58:34 +00:00
username: "",
2022-04-06 08:07:18 +00:00
fault_picture: "",
fault_describe: "",
2022-03-31 09:58:34 +00:00
phone: "",
2022-04-01 06:35:42 +00:00
visit_time: ""
2022-03-28 10:09:23 +00:00
},
2022-04-06 08:07:18 +00:00
imgsrcArr: [],
2022-03-31 09:58:34 +00:00
indexType: 0,
2022-05-13 09:39:50 +00:00
navDataState: ["有设备","无设备"],
current:0,
2022-03-31 09:58:34 +00:00
faultTypeData: []
2022-03-17 05:47:40 +00:00
}
},
2022-03-31 09:58:34 +00:00
onLoad() {
this.getType()
2022-03-28 10:09:23 +00:00
},
2022-04-06 08:07:18 +00:00
2022-03-17 05:47:40 +00:00
methods: {
2022-05-13 09:39:50 +00:00
submitButton() {
this.data.fault_type = this.faultTypeData[this.indexType].id
if(this.current) {
if (!this.data.device_name) {
this.$toolAll.tools.showToast("请填写设备名称或型号");
return
}
} else {
if (!this.data.project_number) {
this.$toolAll.tools.showToast("请填写设备编号");
return
}
}
if (!this.data.username) {
this.$toolAll.tools.showToast("请填写您的姓名");
return
}
if (this.$toolAll.tools.isPhone(this.data.phone)) {
this.$toolAll.tools.showToast("请正确填写您的电话");
return
}
this.data.is_device = this.current ? 0 : 1;//0:表示无设备 1表示有设备
this.$requst.post('/universal/api.order/repair', this.data).then(res => {
if (res.code) {
this.$toolAll.tools.showToast('提交成功');
setTimeout(()=>{
uni.navigateBack({delta:1})
},1000)
} else {
this.$toolAll.tools.showToast(res.msg);
}
})
},
// 获取维保类型
2022-03-31 09:58:34 +00:00
getType() {
getFaultType().then(res=>{
if (res.code) {
this.faultTypeData = [...res.data]
} else {
}
})
2022-03-28 10:09:23 +00:00
},
2022-04-01 06:35:42 +00:00
openDatetimePicker() {
this.$refs.myPicker.show();
},
handleSubmit(e) {
2022-05-13 09:39:50 +00:00
this.data.visit_time = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:00`;
2022-03-17 05:47:40 +00:00
},
2022-04-01 06:35:42 +00:00
// 获取图片
chooseImg() {
uni.chooseImage({
count: 1,
sourceType: ['album', 'camera'],
success: (res) => {
2022-04-06 08:07:18 +00:00
this.imgsrcArr = []
2022-04-01 06:35:42 +00:00
let imgsrc = res.tempFilePaths;
imgsrc.forEach(item => {
this.imgsrcArr.push(item);
})
2022-05-13 09:39:50 +00:00
uploadImg({path: res.tempFilePaths[0]}).then(res => {
if (res.code) {
2022-04-06 08:07:18 +00:00
this.$toolAll.tools.showToast('上传成功');
this.data.fault_picture = res.data.id
}
2022-04-06 03:41:09 +00:00
})
2022-05-13 09:39:50 +00:00
},fail:(err)=> {
this.$toolAll.tools.checkQx(err.code);
2022-04-01 06:35:42 +00:00
}
})
2022-03-31 09:58:34 +00:00
},
2022-03-28 09:42:48 +00:00
scanCodeFun() {
2022-05-13 09:39:50 +00:00
// #ifdef APP-PLUS || MP-WEIXIN
uni.scanCode({
onlyFromCamera:false, // 是否只能从相机扫码,不允许从相册选择图片
scanType: ['qrCode'], // barCode一维码 qrCode二维码 datamatrixData Matrix 码, pdf417PDF417 条码
autoDecodeCharset:true, // 是否启用自动识别字符编码功能,默认为否
success: function (res) {
console.log('条码类型:' + res.scanType);
console.log('条码内容:' + res.result);
}
});
// #endif
// #ifdef H5
this.scanCode();
// #endif
2022-03-17 05:47:40 +00:00
},
2022-05-13 09:39:50 +00:00
scanCode() {
let that = this
// 调用uni提供的调用相机api
uni.chooseImage({
sizeType: ['original'],
count: 1,
success: (res)=> {
qrcode.decode(this.getObjectURL(res.tempFiles[0]))
qrcode.callback = (codeRes) => {
if (codeRes.indexOf('error') >= 0) {
// 二维码识别失败
console.log('不合法二维码:' + codeRes);
} else {
// 二维码识别成功
let r = this.decodeStr(codeRes)
// this.qrCodeRes = r
console.log(r);
}
}
// const tempFilePaths = res.tempFilePaths[0] // 获取到二维码图片的链接
// qrcode.decode(tempFilePaths); // 解析二维码图片
// qrcode.callback = function(res1) {
// // 解析失败返回 error decoding QR Code
// if (res1 == "error decoding QR Code") {
// uni.showToast({
// title: "识别二维码失败,请重新上传!",
// duration: 2000,
// icon: 'none'
// })
// } else {
// // 解析成功返回二维码链接
// console.log(res1)
// }
// }
},fail:(err)=> {
this.$toolAll.tools.checkQx(err.code);
}
});
},
// 获取文件地址函数
getObjectURL(file) {
var url = null
if (window.createObjectURL !== undefined) { // basic
url = window.createObjectURL(file)
} else if (window.URL !== undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(file)
} else if (window.webkitURL !== undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(file)
}
2022-05-13 09:39:50 +00:00
return url
},
// 解码,输出:中文
decodeStr(str) {
var out, i, len, c;
var char2, char3;
out = "";
len = str.length;
i = 0;
while (i < len) {
c = str.charCodeAt(i++);
switch (c >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
// 0xxxxxxx
out += str.charAt(i - 1);
break;
case 12:
case 13:
// 110x xxxx 10xx xxxx
char2 = str.charCodeAt(i++);
out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
break;
case 14:
// 1110 xxxx 10xx xxxx 10xx xxxx
char2 = str.charCodeAt(i++);
char3 = str.charCodeAt(i++);
out += String.fromCharCode(((c & 0x0F) << 12) |
((char2 & 0x3F) << 6) |
((char3 & 0x3F) << 0));
break;
}
}
return out;
},
2022-03-28 09:42:48 +00:00
mapFun() {
2022-04-06 08:07:18 +00:00
const that = this
2022-03-31 09:58:34 +00:00
uni.getLocation({
type: 'gcj02', //返回可以用于uni.openLocation的经纬度
success: function(res) {
const latitude = res.latitude;
const longitude = res.longitude;
uni.chooseLocation({
success: function(res) {
2022-04-06 08:07:18 +00:00
that.data.service_address = res.address
2022-03-31 09:58:34 +00:00
}
});
// uni.openLocation({
// latitude: latitude,
// longitude: longitude,
// success: function () {
// console.log('success');
// }
// });
}
});
2022-03-28 09:42:48 +00:00
},
repairsNavFun(index) {
2022-05-13 09:39:50 +00:00
this.current = index;
2022-03-28 09:42:48 +00:00
},
repairsTypeFun(index) {
2022-03-31 09:58:34 +00:00
this.indexType = index
2022-05-13 09:39:50 +00:00
}
2022-03-17 05:47:40 +00:00
}
}
</script>
<style>
.repairs-nav {
display: flex;
background-color: #FFFFFF;
justify-content: space-between;
}
.repairs-nav .li {
width: 50%;
padding: 30rpx 0rpx;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
font-size: 28rpx;
color: #343536;
2022-03-28 09:42:48 +00:00
border-bottom: 2rpx solid rgba(0, 0, 0, 0);
2022-03-17 05:47:40 +00:00
}
.repairs-nav .on {
color: #00a2ea;
border-bottom: 2rpx solid #00a2ea;
}
.content {
background-color: #F7F7F7;
min-height: 100vh;
}
.repairs-hint {
width: 100%;
height: 123rpx;
background-color: #FFFFFF;
display: flex;
padding-top: 20rpx;
box-sizing: border-box;
margin-top: 23rpx;
border-top: 2rpx solid #e7e7e7;
border-bottom: 2rpx solid #e7e7e7;
}
.repairs-hint .icon {
width: 30rpx;
height: 27rpx;
margin-right: 15rpx;
margin-top: 8rpx;
}
.repairs-hint .text {
flex: 1;
color: #5e5e5e;
font-size: 22rpx;
line-height: 40rpx;
}
.fault-type-title {
margin-top: 14rpx;
2022-05-13 09:39:50 +00:00
/* width: 100%; */
2022-03-17 05:47:40 +00:00
line-height: 80rpx;
margin-bottom: 13rpx;
border-top: 2rpx solid #e7e7e7;
border-bottom: 2rpx solid #e7e7e7;
height: 80rpx;
background-color: #FFFFFF;
color: #434242;
}
.fault-type-content {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.fault-type-content .li {
width: 160rpx;
height: 59rpx;
background-color: #FFFFFF;
font-size: 26rpx;
color: #5e5e5e;
2022-03-28 09:42:48 +00:00
box-sizing: border-box;
2022-03-17 05:47:40 +00:00
text-align: center;
line-height: 59rpx;
border-radius: 22rpx;
border: 2rpx solid #eeeeee;
margin-bottom: 15rpx;
}
.fault-type-content .on {
color: #FFFFFF;
border: none;
background-color: #00a2ea;
}
.information {}
.devicename {
width: 100%;
height: 78rpx;
border-radius: 10rpx;
background-color: #FFFFFF;
padding: 0 16rpx;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
color: #9f9898;
font-size: 26rpx;
line-height: 78rpx;
}
.fault-pictures {
display: flex;
align-items: center;
justify-content: center;
margin-top: 18rpx;
height: 320rpx;
box-sizing: border-box;
width: 100%;
background-color: #FFFFFF;
flex-direction: column;
}
2022-04-06 08:07:18 +00:00
.fault-pictures-con {
display: flex;
flex-direction: column;
align-items: center;
}
2022-03-17 05:47:40 +00:00
.fault-pictures .img {
width: 87rpx;
margin-bottom: 27rpx;
height: 87rpx;
}
.fault-pictures .text {
font-size: 30rpx;
color: #9f9898;
}
.fault-description {
height: 193rpx;
width: 100%;
box-sizing: border-box;
margin-top: 23rpx;
padding: 23rpx 19rpx;
background-color: #FFFFFF;
}
.fault-description-text {
color: #9f9898;
font-size: 26rpx
}
.inputCss {
height: 78rpx;
width: 100%;
box-sizing: border-box;
padding: 0rpx 17rpx;
2022-04-01 08:56:35 +00:00
font-size: 26rpx;
2022-03-17 05:47:40 +00:00
border-radius: 10rpx;
background-color: #FFFFFF;
2022-04-01 08:56:35 +00:00
color: #000000;
2022-03-17 05:47:40 +00:00
display: flex;
margin-top: 20rpx;
align-items: center;
}
.detailed-address {
justify-content: space-between;
}
.inputCss-input-input {
2022-04-01 08:56:35 +00:00
font-size: 26rpx;
2022-03-17 05:47:40 +00:00
color: #9f9898;
2022-04-01 06:35:42 +00:00
2022-03-17 05:47:40 +00:00
}
.detailed-address .map {
width: 151rpx;
height: 59rpx;
background-color: #F7F7F7;
}
.uni-datetime-pickerCss {
margin-top: 20rpx;
}
.submit-button {
width: 100%;
margin-top: 44rpx;
border-radius: 50rpx;
height: 90rpx;
background-color: #02A2ea;
line-height: 90rpx;
color: #FFFFFF;
text-align: center;
font-size: 30rpx;
}
2022-03-28 09:42:48 +00:00
.devicename .sm {
2022-03-17 05:47:40 +00:00
width: 42rpx;
height: 36rpx;
}
2022-04-06 08:07:18 +00:00
.fault-pictures-img {
2022-04-01 06:35:42 +00:00
width: 100%;
height: 100%;
2022-04-06 08:07:18 +00:00
2022-04-01 06:35:42 +00:00
}
2022-03-17 05:47:40 +00:00
</style>