获取当前位置兼容H5、小程序、app

master
chen 2022-04-15 18:44:40 +08:00
parent eb1c0ac14d
commit 8dbd9af5b9
15 changed files with 298 additions and 85 deletions

View File

@ -27,3 +27,18 @@ export function handleWorkOrderGet(data) {
export function handleWorkOrderSubmit(data) {
return request.post("/universal/api.order/process_order", data);
}
// 获取产品类型
export function getProductType() {
return request.get("/universal/api.project/project_type");
}
// 获取维保类型
export function getFaultType() {
return request.get("/universal/api.order/fault_type");
}
// 获取服务方式
export function getServiceMode() {
return request.get("/universal/api.order/fault_type");
}

View File

@ -9,8 +9,8 @@ console.log(ENV,'当前环境'); // development开发环境 test测试环
const hostapi = 'https://7and5.cn';
// #endif
// #ifdef H5
// const hostapi = '/web';
const hostapi = 'https://7and5.cn';
const hostapi = '/web';
// const hostapi = 'https://7and5.cn';
// #endif
// 清理所有缓存并前往授权页
const goLogin = () => {

View File

@ -104,13 +104,15 @@ const tools = {
},
// h5
getAddressH5(){
uni.getLocation({
type: 'wgs84',
success: (res)=> {
uni.showLoading({
title: '加载中',
title: '定位中...',
mask:true
});
uni.getLocation({
type: 'gcj02', // wgs84 gcj02
altitude: true,
// geocode: true, // wgs84
success: (res)=> {
let str = `output=jsonp&key=QNHBZ-55RKF-OMFJJ-NPU7O-EPSDH-ACBAA&location=${res.latitude},${res.longitude}`
jsonp('https://apis.map.qq.com/ws/geocoder/v1/?'+str,{}).then(res=>{
// console.log(res,'H5');

View File

@ -1,5 +1,11 @@
{
"pages": [{
"pages": [ {
"path": "pages/workOrder/punchCard",
"style": {
"navigationBarTitleText": "个人中心",
"navigationStyle": "custom" //
}
},{
"path": "pages/guide-page/guide-page",
"style": {
"navigationBarTitleText": "",

View File

@ -79,11 +79,16 @@
address:"湖南省长沙市高新开发区谷园路109号像素大厦1205"
},
],
list_rows:20,
page:1,
total:0
}
},
onLoad(op) {
if(op.key_word!=undefined) {
//
this.queryFunEv();
this.queryFunEv(op.key_word);
}
},
methods: {
//
@ -93,8 +98,14 @@
})
},
//
queryFunEv(){
queryFun({type_id:1}).then(res=>{
queryFunEv(keyword){
let params = {
type_id:1,
keyword,
list_rows:this.list_rows,
page:this.page
}
queryFun(params).then(res=>{
if(res.code) {
}

View File

@ -128,17 +128,27 @@
},
data() {
return {
list_rows:20,
page:1,
total:0
}
},
onLoad(op) {
//
this.queryFunEv();
if(op.key_word!=undefined) {
// ()
this.queryFunEv(op.key_word);
}
},
methods: {
//
queryFunEv(){
queryFun({type_id:3}).then(res=>{
// ()
queryFunEv(keyword){
let params = {
type_id:3,
keyword,
list_rows:this.list_rows,
page:this.page
}
queryFun(params).then(res=>{
if(res.code) {
}

View File

@ -116,11 +116,16 @@
},
],
list_rows:20,
page:1,
total:0
}
},
onLoad(op) {
//
this.queryFunEv();
if(op.key_word!=undefined) {
// ()
this.queryFunEv(op.key_word);
}
},
methods: {
projectDetailsFun(){
@ -128,9 +133,15 @@
url:"/pages/dataQuery/projectDetails"
})
},
//
// ()
queryFunEv(){
queryFun({type_id:2}).then(res=>{
let params = {
type_id:2,
keyword,
list_rows:this.list_rows,
page:this.page
}
queryFun(params).then(res=>{
if(res.code) {
}

View File

@ -190,7 +190,6 @@
'/pages/dataQuery/projectQuery',
'/pages/dataQuery/dataQuery'
]
uni.navigateTo({
url: `${urls[index]}?key_word=${this.key_word}`
})

View File

@ -13,7 +13,7 @@
</view>
</swiper-item>
</swiper>
<view class="indication-point fon24 disjcac">{{index}}/{{projectObj.completed_img.length}}</view>
<view class="indication-point fon24 disjcac">{{index}}/{{imgNum}}</view>
</view>
<view class="title">{{projectObj.project_name}}</view>
<view class="code">{{projectObj.project_number}}</view>
@ -117,6 +117,7 @@
},
],
projectObj:'',
imgNum:0,//
typeId:1,// 1 2: 3:
list_rows:200,
page:1,
@ -160,7 +161,7 @@
}).then(res => {
if (res.code) {
this.projectObj = res.data;
console.log(this.projectObj);
this.imgNum = this.projectObj.completed_img.length;
} else {
}

View File

@ -6,9 +6,9 @@
<view slot="content" style="margin: -30rpx -30rpx -0rpx;">
<view class="pad-s20 bacf">
<view class="project-list-input">
<input type="text" class="int" value="" placeholder="请输入关键字" placeholder-style="color:#999999;" />
<input @confirm="getData" type="text" @input="keywordInput" class="int" v-model="inputData" placeholder="请输入关键字" placeholder-style="color:#999999;" />
<view class="xian"></view>
<image class="search" src="../../static/iocn/ss.png" mode="aspectFill" lazy-load></image>
<image @tap="getData" class="search" src="../../static/iocn/ss.png" mode="aspectFill" lazy-load></image>
</view>
</view>
<view class="screen bbot mar-sx20">
@ -71,6 +71,7 @@
import footTabOne from "../../components/foot-tabs/foot-tab-one.vue"
import containerSubgroupTwo from '@/components/containers/container-subgroup-two.vue';
import pitera from '@/components/nothing/pitera.vue';
import {getProductType} from '@/jsFile/public-api.js';
export default {
components: {
footTabOne,
@ -84,7 +85,7 @@
})
return {
statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 40,
inputData: "",
inputData: "",//
date: currentDate,
initial_value:'产品类型',
array: [],
@ -113,6 +114,10 @@
this.getProjectType();
},
methods: {
//
keywordInput(){
this.dataList.page = 1;
},
//
getData() {
if(this.dataList.page==1) this.dataList.data = [];
@ -120,7 +125,8 @@
product_type:this.productType,
completion_time:this.completion_time,
list_rows: this.dataList.list_rows,
page: this.dataList.page
page: this.dataList.page,
keyword:this.inputData
}).then(res => {
if (res.code) {
//
@ -136,7 +142,7 @@
},
//
getProjectType(){
this.$requst.get('/universal/api.project/project_type').then(res=>{
getProductType().then(res=>{
if(res.code) {
this.array = res.data;
}

View File

@ -61,6 +61,7 @@
<script>
import yyMmDdHhSs from '@/components/dates/yy-mm-dd-hh-ss.vue';
import {getFaultType} from '@/jsFile/public-api.js';
import {
uploadImg
} from '@/jsFile/public-api.js';
@ -106,12 +107,8 @@
methods: {
//
getType() {
// /universal/api.order/fault_type
this.$requst.post('/universal/api.work_order/fault_type').then(res => {
// this.$toolAll.tools.showToast(res.msg);
if (res.code == 1) {
getFaultType().then(res=>{
if (res.code) {
this.faultTypeData = [...res.data]
} else {
@ -175,7 +172,6 @@
},
submitButton() {
this.data.fault_type = this.faultTypeData[this.indexType].id
if (this.data.is_device == 0) {
if (!this.data.device_name) {
this.$toolAll.tools.showToast("请填写设备名称或型号");
@ -186,34 +182,25 @@
this.$toolAll.tools.showToast("请扫描设备二维码");
return
}
}
if (!this.data.username) {
this.$toolAll.tools.showToast("请填写您的姓名");
return
}
var reg_tel =
/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/; //11
if (!reg_tel.test(this.data.phone)) {
if (this.$toolAll.tools.isPhone(this.data.phone)) {
this.$toolAll.tools.showToast("请正确填写您的电话");
return
}
console.log(this.data)
this.$requst.post('/universal/api.work_order/repair', this.data).then(res => {
if (res.code == 1) {
console.log(res)
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);
}
})
console.log(this.data)
},
mapFun() {

View File

@ -160,7 +160,7 @@
},
],
userInfo: {},
ifAuthentication:false,//
ifAuthentication:0,//
userHeadImg:''//
}
},
@ -229,10 +229,11 @@
this.headList[0].num = this.userInfo.credit
this.headList[1].num = this.userInfo.project_number
this.headList[2].num = this.userInfo.evaluate
this.percentageList[0].num= this.userInfo.reserve_rate-0
this.percentageList[1].num= this.userInfo.visit_rate-0
this.percentageList[2].num= this.userInfo.repair_rate-0
this.userHeadImg = this.userInfo.avatar;
this.percentageList[0].num= this.userInfo.reserve_rate*1//
this.percentageList[1].num= this.userInfo.visit_rate*1//
this.percentageList[2].num= this.userInfo.repair_rate*1//
this.userHeadImg = this.userInfo.avatar;//
this.ifAuthentication = this.userInfo.is_check;//0 1
}
})
},

View File

@ -195,8 +195,8 @@
<view class="mar-s30">
<scroll-view scroll-x>
<view :class="solutionList.length == 4 ? 'disjbac' : 'disac'">
<view @tap="goDetail(0,item.id)" class="posir flexs" v-for="(item,index) in solutionList" :key="index" style="width: 23%;height: 214rpx;" :style="{marginRight: solutionList.length != 4 ? '20rpx' : ''}">
<image style="width: 100%;height: 214rpx;" class="radius10 " :src="item.imgsrc" mode="aspectFill"></image>
<view @tap="goDetail(0,item.id)" class="posir flexs" v-for="(item,index) in solutionList" :key="index" style="width: 23%;height: 110px;" :style="{marginRight: solutionList.length != 4 ? '20rpx' : ''}">
<image style="width: 100%;height: 110px;" class="radius10 " :src="item.imgsrc" mode="aspectFill"></image>
<view class="posia solution-title clips1">{{item.title}}</view>
</view>
</view>
@ -246,8 +246,8 @@
},
data() {
return {
role: 2, // 1 2: 3: 4
role: uni.getStorageSync('type_id'), // 1 2: 3: 4
role: 1, // 1 2: 3: 4
// role: uni.getStorageSync('type_id'), // 1 2: 3: 4
statusHeight: uni.getSystemInfoSync().statusBarHeight + 50,
messageNumber: 0 ,//
noticeList:[{id:1,title:'2021年11月06日公司团建维保服务暂停一天服务暂停一天服务暂停一天。一天服务暂停一天服务暂停一天。'}],//
@ -348,6 +348,7 @@
this.contactPhone = homeObj.contact;//
this.project_count = homeObj.project_count;//
this.fault_count = homeObj.fault_count;//
//
if(homeObj.notice.length) {
homeObj.notice.forEach(item=>{
let obj = {

View File

@ -32,7 +32,10 @@
</view>
<view class="li">
<view class="title flexs">产品类型</view>
<input type="text" class="input" v-model="targetObj.productType" placeholder="请填写产品类型" :style="{color: targetObj.productType!='' ? '#000' : ''}" />
<!-- <input type="text" disabled class="input" v-model="targetObj.productType" placeholder="请填写产品类型" :style="{color: targetObj.productType!='' ? '#000' : ''}" /> -->
<picker class="input input-black" mode="selector" :value="productIndex" :range="productTypeList" :range-key="'name'" @change="changePicker(0,$event)">
<view>{{productTypeList[productIndex].name}}</view>
</picker>
</view>
<view class="li">
<view class="title flexs">安装位置</view>
@ -40,7 +43,10 @@
</view>
<view class="li">
<view class="title flexs">维保类型</view>
<input type="text" class="input" v-model="targetObj.faultType" placeholder="请填写维保类型(例:供电不足)" :style="{color: targetObj.faultType!='' ? '#000' : ''}" />
<!-- <input type="text" disabled class="input" v-model="targetObj.faultType" placeholder="请填写维保类型(例:供电不足)" :style="{color: targetObj.faultType!='' ? '#000' : ''}" /> -->
<picker class="input input-black" mode="selector" :value="faultIndex" :range="faultTypeList" :range-key="'name'" @change="changePicker(1,$event)">
<view>{{faultTypeList[faultIndex].name}}</view>
</picker>
</view>
<view class="li">
<view class="title flexs">紧急程度</view>
@ -73,7 +79,10 @@
</view>
<view class="li">
<view class="title flexs">服务方式</view>
<input type="text" v-model="targetObj.serviceMode" class="input input-black" placeholder="请填写服务方式(例:上门服务)" :style="{color: targetObj.serviceMode!='' ? '#000' : ''}" />
<!-- <input type="text" disabled v-model="targetObj.serviceMode" class="input input-black" placeholder="请填写服务方式(例:上门服务)" :style="{color: targetObj.serviceMode!='' ? '#000' : ''}" /> -->
<picker class="input input-black" mode="selector" :value="serviceModeIndex" :range="serviceModeList" :range-key="'name'" @change="changePicker(2,$event)">
<view>{{serviceModeList[serviceModeIndex].name}}</view>
</picker>
</view>
<view class="li">
<view class="title flexs">定位地址</view>
@ -88,9 +97,44 @@
<script>
import containerSubgroupTwo from '@/components/containers/container-subgroup-two.vue';
import statusNav from '../../components/status-nav.vue';
import footTabOne from "../../components/foot-tabs/foot-tab-one.vue"
import {handleWorkOrderGet,handleWorkOrderSubmit} from '../../jsFile/public-api.js';
import statusNav from '@/components/status-nav.vue';
import footTabOne from "@/components/foot-tabs/foot-tab-one.vue"
import {handleWorkOrderGet,handleWorkOrderSubmit,getProductType,getFaultType,getServiceMode,uploadImg} from '@/jsFile/public-api.js';
var QQMapWX = require('@/jsFile/map/qqmap-wx-jssdk.min.js');
var qqmapsdk = new QQMapWX({
key: 'QNHBZ-55RKF-OMFJJ-NPU7O-EPSDH-ACBAA'
});
// H5
const jsonp = function(url, data) {
return new Promise((resolve, reject) => {
// 1.url
let dataString = url.indexOf('?') === -1 ? '?' : '&'
let callbackName = `jsonpCB_${ Date.now() }`;
url += `${ dataString }callback=${ callbackName }`
if(data) {
// 2.url
for(let k in data) {
url += `&${ k }=${ data[k] }`
}
}
let scriptNode = document.createElement('script');
scriptNode.src = url;
// 3. callback
window[callbackName] = (result) => {
result ? resolve(result) : reject('没有返回数据');
delete window[callbackName];
document.body.removeChild(scriptNode);
}
// 4.
scriptNode.addEventListener('error', () => {
reject('接口返回数据失败');
delete window[callbackName];
document.body.removeChild(scriptNode);
}, false)
// 5.
document.body.appendChild(scriptNode)
})
}
export default {
components: {
footTabOne,
@ -124,7 +168,20 @@
faultReason:'',//
maintenancePersonnel:''//
},
flag:true
productTypeList:[
{id:1,name:'产品1'},{id:2,name:'产品2'},
],//
productIndex:0,//
faultTypeList:[
{id:1,name:'产品1'},{id:2,name:'产品2'},
],//
faultIndex:0,//
serviceModeList:[
{id:1,name:'上门服务'},{id:2,name:'线上服务'},
],//
serviceModeIndex:0,//
flag:true,
temporaryImg:[]//id
}
},
onShow() {
@ -136,8 +193,100 @@
this.orderId = op.id;
this.handleWorkOrderGet(this.orderId);
}
this.getProductType();
this.getFaultType();
this.getAddressH5();
},
methods: {
//
getAddress() {
},
getAddressH5(){
uni.getLocation({
type: 'gcj02',//wgs84 gcj02
altitude: true,
geocode: true,
success: (res)=> {
let str = `output=jsonp&key=QNHBZ-55RKF-OMFJJ-NPU7O-EPSDH-ACBAA&location=${res.latitude},${res.longitude}`
jsonp('https://apis.map.qq.com/ws/geocoder/v1/?'+str,{}).then(res=>{
console.log(res,'H5');
this.targetObj.address = `${res.result.address_component.province}${res.result.address_component.city}${res.result.address_component.district}${res.result.address_component.street || ''}(${res.result.address_component.street_number || ''})`
})
}
});
},
//
changePicker(index,e) {
switch (index){
case 0:
//
this.productIndex = e.detail.value;
this.targetObj.productType = this.productTypeList[this.productIndex].name;
break;
case 1:
//
this.faultIndex = e.detail.value;
this.targetObj.faultType = this.faultTypeList[this.faultIndex].name;
break;
case 2:
//
this.serviceModeIndex = e.detail.value;
this.targetObj.serviceMode = this.serviceModeList[this.serviceModeIndex].name;
break;
}
},
//
getProductType() {
getProductType().then(res=>{
if(res.code) {
this.productTypeList = res.data;
if(this.productTypeList.length) {
// this.productIndex = this.productTypeList.findIndex(item=>{return item.name==this.targetObj.productType});
//
this.productTypeList.forEach((item,index)=>{
if(item.name==this.targetObj.productType) {
this.productIndex = index;
}
})
}
}
})
},
//
getFaultType() {
getFaultType().then(res=>{
if(res.code) {
this.faultTypeList = res.data;
if(this.faultTypeList.length) {
// this.faultIndex = this.faultTypeList.findIndex(item=>{return item.name==this.targetObj.faultType});
//
this.faultTypeList.forEach((item,index)=>{
if(item.name==this.targetObj.faultType) {
this.faultIndex = index;
}
})
}
}
})
},
//
getServiceMode() {
getServiceMode().then(res=>{
if(res.code) {
this.serviceModeList = res.data;
if(this.serviceModeList.length) {
// this.serviceModeIndex = this.serviceModeList.findIndex(item=>{return item.name==this.targetObj.serviceMode});
//
this.serviceModeList.forEach((item,index)=>{
if(item.name==this.targetObj.serviceMode) {
this.serviceModeIndex = index;
}
})
}
}
})
},
//
handleWorkOrderGet(id){
let params = {
@ -150,10 +299,19 @@
this.targetObj.workOrderNo = dataObj.order_number;//
this.targetObj.projectNo = dataObj.project_number;//
this.targetObj.projectName = dataObj.project_name;//
this.targetObj.productType = dataObj.product_type;//
this.targetObj.installLocation = dataObj.installation_location;//
this.targetObj.faultType = dataObj.fault_type;//
this.targetObj.faultExplain = dataObj.failure_description;//
this.targetObj.urgentDegree = dataObj.emergency_level_view;//
this.targetObj.reporter = dataObj.order_contact;//
this.targetObj.declarationTime = dataObj.order_times;//
this.targetObj.address = dataObj.order_times;//
this.targetObj.serviceMode = dataObj.service_method_view;//
// this.targetObj.address = dataObj.order_times;//
//
this.getProductType();
//
this.getFaultType();
}
})
},
@ -164,9 +322,15 @@
sourceType:['album','camera'],
success: (res) => {
let imgsrc = res.tempFilePaths[0];
// id
uploadImg({path:imgsrc}).then(res=>{
if(res.code) {
this.temporaryImg.push(res.data.id);
this.targetObj.faultImgList.push(imgsrc);
}
})
}
})
},
//
goWorkOrderThree() {
@ -179,12 +343,12 @@
steps:1,
order_id:this.orderId || 14,//id
start_address:'四川省成都市成华区',//
a:this.targetObj.productType,//
b:this.targetObj.installLocation,//
c:this.targetObj.faultType,//
d:this.targetObj.faultExplain,//
e:this.targetObj.maintenanceImgList,//
f:this.targetObj.serviceMode//
product_type:this.productTypeList[this.productIndex].id,//
installation_location:this.targetObj.installLocation,//
fault_type:this.faultTypeList[this.faultIndex].id,//
failure_description:this.targetObj.faultExplain,//
fault_picture:this.temporaryImg.join(','),//
service_method:this.serviceModeList[this.serviceModeIndex].id//
}
handleWorkOrderSubmit(params).then(res=>{
if(res.code) {

View File

@ -139,7 +139,7 @@
//
this.imgList[3] = res.data.agreement_document;
//
this.imgList[3] = res.data.skills_certificate;
this.imgList[4] = res.data.skills_certificate;
}
})
},
@ -237,7 +237,6 @@
this.imgList.forEach((item,index)=>{
if(current==index) arr.push(item);
})
console.log(this.imgList);
if(arr.length) {
uni.previewImage({
current:current,