Browse Source

add locate

dev
刘嘉炜 7 days ago
parent
commit
b2cc22b7f4
  1. 63
      src/subpackage/groupon/pages/stadiums.vue
  2. 7
      src/subpackage/order/pages/detail.vue

63
src/subpackage/groupon/pages/stadiums.vue

@ -3,25 +3,30 @@ import { onLoad } from '@dcloudio/uni-app';
import { reactive, ref, watch, onMounted, getCurrentInstance } from "vue"; import { reactive, ref, watch, onMounted, getCurrentInstance } from "vue";
import searchBar from "../components/search_bar.vue"; import searchBar from "../components/search_bar.vue";
import { countCity, stadiumFind } from "../api"; import { countCity, stadiumFind } from "../api";
import { routeTo, showModal } from '@/utils/polish';
import { routeTo, showModal, showLoad, hideLoad } from '@/utils/polish';
import { debounce } from '@/utils'; import { debounce } from '@/utils';
const cityLs = ref([]); const cityLs = ref([]);
const cityName = ref(''); // const cityName = ref(''); //
const stadiumKey = ref(''); // const stadiumKey = ref(''); //
const stadiumLs = ref([]); const stadiumLs = ref([]);
const appid = tt.getEnvInfoSync()?.microapp?.appId ?? ''; const appid = tt.getEnvInfoSync()?.microapp?.appId ?? '';
const locationInfo = ref({}); //
let ticketInfo = null; // let ticketInfo = null; //
watch(cityName, val=>{ watch(cityName, val=>{
stadiumLs.value = []; stadiumLs.value = [];
stadiumFind({
data: {
let _query = {
appid: appid, appid: appid,
city: val ?? '', city: val ?? '',
key: stadiumKey.value ?? '', key: stadiumKey.value ?? '',
},
})
}
let _locVal = locationInfo.value;
if(_locVal?.latitude && _locVal?.longitude){
_query['lat'] = _locVal.latitude;
_query['lng'] = _locVal.longitude;
}
stadiumFind({ data: _query })
.then(sRes=> { .then(sRes=> {
if(val !== cityName.value) return; // if(val !== cityName.value) return; //
let _ls = sRes?.data?.list || []; let _ls = sRes?.data?.list || [];
@ -37,8 +42,10 @@ onLoad(opts => {
console.log('城市列表--->', res); console.log('城市列表--->', res);
return cityLs.value = res.data?.list || []; return cityLs.value = res.data?.list || [];
}) })
.then(cityLs => {
.then(async cityLs => {
if(!cityLs?.length) return showModal({ content: '暂无城市' }); if(!cityLs?.length) return showModal({ content: '暂无城市' });
let _loaction = await getLocationInfo();
if(_loaction?.latitude)locationInfo.value = _loaction;
cityName.value = cityLs[0]?.city ?? ''; cityName.value = cityLs[0]?.city ?? '';
}) })
}); });
@ -50,6 +57,28 @@ onMounted(() =>{
ticketInfo = data?.ticket ?? null; ticketInfo = data?.ticket ?? null;
}) })
}) })
async function getLocationInfo(){
let setting, location;
try{setting = await uni.getSetting({})}catch(err){console.error(err)};
//
if(setting?.authSetting['scope.userLocation'] === false){
let modalRes = await uni.showModal({
title: '提示',
content: '请打开位置授权,你的具体位置信息,用于自动匹配附近门店',
showCancel: true,
})
if(modalRes.confirm)try{
let _settingInfo = await uni.openSetting({});
if(_settingInfo?.authSetting['scope.userLocation'] === true){
location = await uni.getLocation({type: 'gcj02'})
}
}catch(err){ console.error(err) };
}else{
try{ location = await uni.getLocation({type: 'gcj02'}) }catch(err){ console.error(err) };
}
console.log('获取到的位置信息--->', location);
return location;
}
// //
function getBusinessTime(stadiumInfo){ function getBusinessTime(stadiumInfo){
let _businessTime = stadiumInfo?.business_times || []; let _businessTime = stadiumInfo?.business_times || [];
@ -103,13 +132,17 @@ function openMap(res){
// //
function searchKeyConfrim(val){ function searchKeyConfrim(val){
stadiumLs.value = []; stadiumLs.value = [];
stadiumFind({
data: {
appid: appid,
city: cityName.value,
key: val,
},
})
let _locVal = locationInfo.value;
let _query = {
appid: appid,
city: cityName.value,
key: val,
}
if(_locVal?.latitude && _locVal?.longitude){
_query['lat'] = _locVal.latitude;
_query['lng'] = _locVal.longitude;
}
stadiumFind({ data: _query })
.then(stadiumRes => { .then(stadiumRes => {
let _ls = stadiumRes?.data?.list || []; let _ls = stadiumRes?.data?.list || [];
stadiumLs.value = _ls; stadiumLs.value = _ls;
@ -251,7 +284,7 @@ function toNextStep(stadiumInfo){
padding-left: 30upx; padding-left: 30upx;
padding-right: 12upx; padding-right: 12upx;
.sr-icons{ .sr-icons{
margin-top: 12upx;
margin-top: 40upx;
@include ctf(center); @include ctf(center);
@include phoneIcon; @include phoneIcon;
@include navigationIcon; @include navigationIcon;

7
src/subpackage/order/pages/detail.vue

@ -9,7 +9,7 @@ import cancelModal from "../components/detail/cancel_modal.vue";
import venueInfoAsync from "@/subpackage/groupon/components/venue_info.vue"; import venueInfoAsync from "@/subpackage/groupon/components/venue_info.vue";
import { orderGet, cancelCheck, orderCancel, getCreateOrderProxyData } from "../api"; import { orderGet, cancelCheck, orderCancel, getCreateOrderProxyData } from "../api";
import { get_zh_day } from "@/utils"; import { get_zh_day } from "@/utils";
import { showLoad, hideLoad, showNone } from "@/utils/polish";
import { showLoad, hideLoad, showNone, showModal } from "@/utils/polish";
import { previewBase64Image } from "@/utils"; import { previewBase64Image } from "@/utils";
const orderInfo = ref({}); const orderInfo = ref({});
const cancelModalRef = ref(null); const cancelModalRef = ref(null);
@ -192,7 +192,8 @@ function serverOrderCancel({ brand_id, order_no, reason }){
function imError(e){ function imError(e){
console.warn('imError', e); console.warn('imError', e);
showNone(e?.detail?.errMsg ?? '客服功能异常,请稍后重试');
showModal({ content: e?.detail?.errMsg ?? '客服功能异常,请稍后重试' });
} }
@ -294,7 +295,7 @@ function imError(e){
<view class="od-fixed"> <view class="od-fixed">
<!-- <view class="od-fixed"> --> <!-- <view class="od-fixed"> -->
<button class="of-im-btn" open-type="lifeIm" @error="imError">
<button class="of-im-btn" open-type="im" data-im-id="oxydsh" @error="imError">
<view class="oib-icon">&#xe625;</view> <view class="oib-icon">&#xe625;</view>
<view class="oib-txt">客服</view> <view class="oib-txt">客服</view>
</button> </button>

Loading…
Cancel
Save