|
|
@ -3,25 +3,30 @@ import { onLoad } from '@dcloudio/uni-app'; |
|
|
|
import { reactive, ref, watch, onMounted, getCurrentInstance } from "vue"; |
|
|
|
import searchBar from "../components/search_bar.vue"; |
|
|
|
import { countCity, stadiumFind } from "../api"; |
|
|
|
import { routeTo, showModal } from '@/utils/polish'; |
|
|
|
import { routeTo, showModal, showLoad, hideLoad } from '@/utils/polish'; |
|
|
|
import { debounce } from '@/utils'; |
|
|
|
const cityLs = ref([]); |
|
|
|
const cityName = ref(''); // 当前城市 |
|
|
|
const stadiumKey = ref(''); // 搜索门店 |
|
|
|
const stadiumLs = ref([]); |
|
|
|
const appid = tt.getEnvInfoSync()?.microapp?.appId ?? ''; |
|
|
|
|
|
|
|
const locationInfo = ref({}); // 定位信息 |
|
|
|
let ticketInfo = null; // 票券信息 |
|
|
|
|
|
|
|
watch(cityName, val=>{ |
|
|
|
stadiumLs.value = []; |
|
|
|
stadiumFind({ |
|
|
|
data: { |
|
|
|
let _query = { |
|
|
|
appid: appid, |
|
|
|
city: val ?? '', |
|
|
|
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=> { |
|
|
|
if(val !== cityName.value) return; // 值在多次变化时候直接丢掉 |
|
|
|
let _ls = sRes?.data?.list || []; |
|
|
@ -37,8 +42,10 @@ onLoad(opts => { |
|
|
|
console.log('城市列表--->', res); |
|
|
|
return cityLs.value = res.data?.list || []; |
|
|
|
}) |
|
|
|
.then(cityLs => { |
|
|
|
.then(async cityLs => { |
|
|
|
if(!cityLs?.length) return showModal({ content: '暂无城市' }); |
|
|
|
let _loaction = await getLocationInfo(); |
|
|
|
if(_loaction?.latitude)locationInfo.value = _loaction; |
|
|
|
cityName.value = cityLs[0]?.city ?? ''; |
|
|
|
}) |
|
|
|
}); |
|
|
@ -50,6 +57,28 @@ onMounted(() =>{ |
|
|
|
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){ |
|
|
|
let _businessTime = stadiumInfo?.business_times || []; |
|
|
@ -103,13 +132,17 @@ function openMap(res){ |
|
|
|
// 搜索门店 |
|
|
|
function searchKeyConfrim(val){ |
|
|
|
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 => { |
|
|
|
let _ls = stadiumRes?.data?.list || []; |
|
|
|
stadiumLs.value = _ls; |
|
|
@ -251,7 +284,7 @@ function toNextStep(stadiumInfo){ |
|
|
|
padding-left: 30upx; |
|
|
|
padding-right: 12upx; |
|
|
|
.sr-icons{ |
|
|
|
margin-top: 12upx; |
|
|
|
margin-top: 40upx; |
|
|
|
@include ctf(center); |
|
|
|
@include phoneIcon; |
|
|
|
@include navigationIcon; |
|
|
|