| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | 
							- // 文档地址 https://lbs.qq.com/service/webService/webServiceGuide/search/webServiceSearch
 
- // 注意当前请求仅打包后有效
 
- import request from '@/utils/request'
 
- import {
 
- 	ref
 
- } from "vue"
 
- import {
 
- 	jsonp
 
- } from "@/utils/common.js"
 
- import config from '@/config.js'
 
- // 关键词不全
 
- const httpUrl = "https://apis.map.qq.com/ws/place/v1/search"
 
- const Key = config.mapKey
 
- export function useCustomMap() {
 
- 	// 关键字 范围 页码 数量 成功回调 失败回调
 
- 	function getPositionSearchByKeyword(keyword, boundary, successFun, errorFun, options) {
 
- 		let cpage = options.page || 1;
 
- 		let csize = options.size || 20;
 
- 		let cboundary = boundary; //'nearby(39.992870,116.310250,1000)'
 
- 		uni.showLoading({
 
- 			title: '加载中'
 
- 		})
 
- 		// #ifdef H5
 
- 		jsonp(httpUrl, {
 
- 			key: Key,
 
- 			output: "jsonp",
 
- 			keyword: keyword,
 
- 			boundary: cboundary,
 
- 			page_size: csize,
 
- 			page_index: cpage,
 
- 		}).then(res => {
 
- 			successFun && successFun(res)
 
- 		}).catch(err => {
 
- 			errorFun && errorFun(err);
 
- 		}).finally(() => {
 
- 			uni.hideLoading();
 
- 		})
 
- 		// #endif
 
- 		// #ifdef APP
 
- 		uni.request({
 
- 			url: httpUrl,
 
- 			method: 'get',
 
- 			data: {
 
- 				key: Key,
 
- 				output: "JSON",
 
- 				keyword: keyword,
 
- 				boundary: cboundary,
 
- 				page_size: csize,
 
- 				page_index: cpage,
 
- 			},
 
- 			timeout: 20000,
 
- 		}).then(res => {
 
- 			successFun && successFun(res)
 
- 		}).catch(err => {
 
- 			console.log('err')
 
- 			errorFun && errorFun(err);
 
- 		}).finally(() => {
 
- 			uni.hideLoading();
 
- 		})
 
- 		// #endif
 
- 	}
 
- 	return {
 
- 		getPositionSearchByKeyword
 
- 	}
 
- }
 
 
  |