Commit 8b03ef4b authored by liumiss's avatar liumiss

地图

parent bd2c2bce
module.exports = {
presets: ["@vue/app"]
presets: ["@vue/app"],
plugins: [
['import', {
libraryName: 'vant',
libraryDirectory: 'es',
style: true
}, 'vant']
]
};
......@@ -711,6 +711,15 @@
"regexpu-core": "^4.5.4"
}
},
"@babel/polyfill": {
"version": "7.4.4",
"resolved": "https://registry.npmjs.org/@babel/polyfill/-/polyfill-7.4.4.tgz",
"integrity": "sha512-WlthFLfhQQhh+A2Gn5NSFl0Huxz36x86Jn+E9OW7ibK8edKPq+KLy4apM1yDpQ8kJOVi1OVjpP4vSDLdrI04dg==",
"requires": {
"core-js": "^2.6.5",
"regenerator-runtime": "^0.13.2"
}
},
"@babel/preset-env": {
"version": "7.3.4",
"resolved": "https://registry.npm.taobao.org/@babel/preset-env/download/@babel/preset-env-7.3.4.tgz",
......@@ -766,7 +775,6 @@
"version": "7.5.5",
"resolved": "https://registry.npm.taobao.org/@babel/runtime/download/@babel/runtime-7.5.5.tgz",
"integrity": "sha1-dPulbTXvvspEQJHHhQzNSU/S8TI=",
"dev": true,
"requires": {
"regenerator-runtime": "^0.13.2"
}
......@@ -980,11 +988,15 @@
"integrity": "sha1-aQoUdbhPKohP0HzXl8APXzE1bqg=",
"dev": true
},
"@vant/icons": {
"version": "1.1.13",
"resolved": "https://registry.npmjs.org/@vant/icons/-/icons-1.1.13.tgz",
"integrity": "sha512-r2EoKDQ4Xh82fo5jVY/m/+LZFfRhHp+ViagySExzlJ7t6JFtmK1OqB6HdFkXXbfEzB/48BvGoPVifFoYzke6KQ=="
},
"@vue/babel-helper-vue-jsx-merge-props": {
"version": "1.0.0",
"resolved": "https://registry.npm.taobao.org/@vue/babel-helper-vue-jsx-merge-props/download/@vue/babel-helper-vue-jsx-merge-props-1.0.0.tgz",
"integrity": "sha1-BI/leZWNpAj7eosqPsBQtQpmEEA=",
"dev": true
"integrity": "sha1-BI/leZWNpAj7eosqPsBQtQpmEEA="
},
"@vue/babel-plugin-transform-vue-jsx": {
"version": "1.0.0",
......@@ -1711,6 +1723,15 @@
"integrity": "sha1-l6ERlkmyEa0zaR2fn0hqjsn74KM=",
"dev": true
},
"amap-js": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/amap-js/-/amap-js-1.2.1.tgz",
"integrity": "sha512-kEgT6dyNalnQF90PAZ1GPZbhAvanT0xtPFcOa00gkHO6HzEm8pKpi/tMrPa3DryiMQ7V6EGJCGSzhx3MHum+hw==",
"requires": {
"@babel/polyfill": "^7.2.5",
"http-jsonp": "^1.1.1"
}
},
"amdefine": {
"version": "1.0.1",
"resolved": "https://registry.npm.taobao.org/amdefine/download/amdefine-1.0.1.tgz",
......@@ -2085,6 +2106,16 @@
"object.assign": "^4.1.0"
}
},
"babel-plugin-import": {
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/babel-plugin-import/-/babel-plugin-import-1.12.0.tgz",
"integrity": "sha512-3Fo7sJ2Hm71y1VJS7eMA/E7J5+roKJmzwia5BxzUQREBs6CRylwtvQq8m39W8nplG4Y7rZwOCndh5MzRTSmHpA==",
"dev": true,
"requires": {
"@babel/helper-module-imports": "^7.0.0",
"@babel/runtime": "^7.0.0"
}
},
"babel-plugin-module-resolver": {
"version": "3.2.0",
"resolved": "https://registry.npm.taobao.org/babel-plugin-module-resolver/download/babel-plugin-module-resolver-3.2.0.tgz",
......@@ -6361,6 +6392,11 @@
}
}
},
"http-jsonp": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/http-jsonp/-/http-jsonp-1.1.1.tgz",
"integrity": "sha512-ZXegkBJDtoCGzGjnsoHuandNUJGe5jwIdeetVJIOLYJUO7mzR9SOjFQv9acO3zekHALLiPMnNJbt1LLDzprU3A=="
},
"http-parser-js": {
"version": "0.4.10",
"resolved": "https://registry.npm.taobao.org/http-parser-js/download/http-parser-js-0.4.10.tgz",
......@@ -9485,8 +9521,7 @@
"regenerator-runtime": {
"version": "0.13.3",
"resolved": "https://registry.npm.taobao.org/regenerator-runtime/download/regenerator-runtime-0.13.3.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fregenerator-runtime%2Fdownload%2Fregenerator-runtime-0.13.3.tgz",
"integrity": "sha1-fPanfY9cb2Drc8X8GVWyzrAea/U=",
"dev": true
"integrity": "sha1-fPanfY9cb2Drc8X8GVWyzrAea/U="
},
"regenerator-transform": {
"version": "0.14.1",
......@@ -11443,6 +11478,17 @@
"spdx-expression-parse": "^3.0.0"
}
},
"vant": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/vant/-/vant-2.1.3.tgz",
"integrity": "sha512-trrMTGNXPOKvQz2fMNMyQi7rvvF5u5mmbBAqmEyHMHUAQzO9JJYck9jyVbB7tQ8KvKFl8arvVXJqIkFghQeMtw==",
"requires": {
"@babel/runtime": "7.x",
"@vant/icons": "1.1.13",
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
"vue-lazyload": "1.2.3"
}
},
"vary": {
"version": "1.1.2",
"resolved": "http://registry.npm.taobao.org/vary/download/vary-1.1.2.tgz",
......@@ -11536,6 +11582,11 @@
"integrity": "sha1-J1b0bLMlgFTF9HI96K5+hzAqHM8=",
"dev": true
},
"vue-lazyload": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/vue-lazyload/-/vue-lazyload-1.2.3.tgz",
"integrity": "sha512-DC0ZwxanbRhx79tlA3zY5OYJkH8FYp3WBAnAJbrcuoS8eye1P73rcgAZhyxFSPUluJUTelMB+i/+VkNU/qVm7g=="
},
"vue-loader": {
"version": "15.7.1",
"resolved": "https://registry.npm.taobao.org/vue-loader/download/vue-loader-15.7.1.tgz?cache=0&sync_timestamp=1563435501637&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-loader%2Fdownload%2Fvue-loader-15.7.1.tgz",
......
......@@ -8,9 +8,11 @@
"lint": "vue-cli-service lint"
},
"dependencies": {
"amap-js": "^1.2.1",
"amfe-flexible": "^2.2.1",
"core-js": "^2.6.5",
"cube-ui": "~1.12.15",
"vant": "^2.1.3",
"vue": "^2.6.10",
"vue-router": "^3.0.3"
},
......@@ -20,6 +22,7 @@
"@vue/cli-service": "^3.10.0",
"@vue/eslint-config-prettier": "^5.0.0",
"babel-eslint": "^10.0.1",
"babel-plugin-import": "^1.12.0",
"eslint": "^5.16.0",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-vue": "^5.0.0",
......
......@@ -16,12 +16,10 @@
continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
<script type="text/javascript"
src="https://webapi.amap.com/maps?v=1.4.15&key=c066bb79c8747e4d84aa9e86276f8174&plugin=AMap.Geolocation,AMap.Scale,AMap.OverView,AMap.ToolBar"></script>
<!-- <script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script> -->
src="https://webapi.amap.com/maps?v=1.4.15&key=55a08526973b576b5d43ad51aa46932f&plugin=AMap.Geolocation,AMap.Scale,AMap.OverView,AMap.ToolBar"></script>
<script src="//webapi.amap.com/ui/1.0/main.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -14,4 +14,18 @@ export const getCode = (phone, type = 'login_or_register') => request('/common/s
export const loginByCode = (phone, code) => request('login/code', {
phone,
code
}, 'get');
\ No newline at end of file
}, 'get');
// 新增收货地址
export const addReceivingAddress = (Data) => request('/user/address', Data, 'POST');
// 编辑收货地址
export const editReceivingAddress = (Data) => request('/user/address/update', Data, 'POST');
// 获取收货地址
export const getReceivingAddress = () => request('/user/address', {}, 'GET');
// 删除收货地址
export const deleteReceivingAddress = (address_id) => request('/user/address/delete', { address_id }, 'POST');
html, body
height: 100%
overflow: hidden
\ No newline at end of file
overflow: hidden
font-size:16px
background: #f7f8fa
@import "./variable"
@import '~common/stylus/mixin.styl';
@import '~common/stylus/base.styl';
.cube-checker-item {
boder-1px();
}
.cube-form-item_required .cube-form-label::before
display:none
......@@ -7,7 +13,9 @@
.text-primary{
color:$color-light-blue
}
.text-light-grey{
color:$color-light-grey
}
.text-extra-small{
font-size: $font-size-12
......@@ -23,4 +31,43 @@
}
.text-extra-large{
font-size: $font-size-20
}
\ No newline at end of file
}
.line::after {
position: absolute;
box-sizing: border-box;
content: " ";
pointer-events: none;
right: 0;
bottom: 0;
left: 16px;
border-bottom: 1px solid #ebedf0;
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
}
.section{
margin-top:10px;
background-color: #fff;
}
.section-hd{
line-height: 40px;
padding:4px 10px;
font-size: 18px;
font-weight: 600;
}
.cube-loading{
display: flex;
justify-content: center;
height: 100px;
align-items: center;
}
.cube-slide-dots{
bottom:4px;
}
.cube-slide-dots span{
height:2px;
}
\ No newline at end of file
import CubePage from "../../components/cube-page.vue";
function plugin (Vue){
if(plugin.installed)return;
Vue.component('cube-page',CubePage)
}
export default plugin;
\ No newline at end of file
export function MAP(key='c066bb79c8747e4d84aa9e86276f8174') {
return new Promise(function (resolve, reject) {
window.init = function () {
resolve(AMap)
};
let script = document.createElement("script");
script.type = "text/javascript";
script.src = "//webapi.amap.com/maps?v=1.4.6&key="+key+"&callback=init";
script.onerror = reject;
document.head.appendChild(script);
})
}
// 获取地理位置
export const mapGeolocation = (map) => {
let location = null;
export function MAP(key = 'c066bb79c8747e4d84aa9e86276f8174') {
return new Promise(function (resolve, reject) {
window.init = function () {
resolve(AMap)
};
let script = document.createElement("script");
script.type = "text/javascript";
script.src = "//webapi.amap.com/maps?v=1.4.6&key=" + key + "&callback=init";
script.onerror = reject;
document.head.appendChild(script);
})
}
map.plugin("AMap.Geolocation", function () {
var geolocation = new AMap.Geolocation({
// 是否使用高精度定位,默认:true
enableHighAccuracy: true,
// 设置定位超时时间,默认:无穷大
timeout: 10000,
// 定位按钮的停靠位置的偏移量,默认:Pixel(10, 20)
buttonOffset: new AMap.Pixel(10, 20),
// 定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
zoomToAccuracy: true,
// 定位按钮的排放位置, RB表示右下
buttonPosition: "RB"
});
geolocation.getCurrentPosition();
AMap.event.addListener(geolocation, "complete", function (data) {
location = data;
console.log(data)
});
AMap.event.addListener(geolocation, "error", function (data) {
console.log(data);
});
});
return location;
export default {
onRouterLink(vm,route, query) {
if (query) {
vm.$router.push({ name: route, query: query })
return;
}
vm.$router.push({ name: route })
}
}
\ No newline at end of file
<template>
<div class="cube-page" :class="type">
<!-- <header class="header">
<h1>{{title}}</h1>
<i @click="back" class="cubeic-back"></i>
</header> -->
<div class="wrapper">
<section v-show="desc" class="desc"><slot name="desc">{{desc}}</slot></section>
<main class="content">
<slot name="content">{{content}}</slot>
</main>
</div>
</div>
</template>
<script type="text/ecmascript-6">
export default {
props: {
title: {
type: String,
default: '',
required: true
},
type: {
type: String,
default: ''
},
desc: {
type: String,
default: ''
},
content: {
type: String,
default: ''
}
},
methods: {
back() {
this.$router.back()
}
}
}
</script>
<style lang="stylus" rel="stylesheet/stylus">
@import "~@/common/stylus/variable.styl"
.cube-page
position: absolute
z-index: 10
top: 0
left: 0
width: 100%
height: 100%
background: #f7f8fa
.header
position: relative
height: 44px
line-height: 44px
text-align: center
background-color: #edf0f4
box-shadow: 0 1px 6px #ccc
-webkit-backface-visibility: hidden
backface-visibility: hidden
z-index: 5
h1
font-size: 16px
font-weight: 700
.cubeic-back
position: absolute
top: 0
left: 0
padding: 0 15px
color: #fc9153
>.wrapper
height: calc(100% - 44px)
overflow-x: hidden
overflow-y: auto
// -webkit-overflow-scrolling: touch
.desc
padding: 10px
margin: 10px 0
line-height: 20px
font-size: 14px
.content
// margin: 10px
&.option-demo
.wrapper
background-color: $color-white
.title
font-size: $fontsize-large
font-weight: 500
color: $color-dark-grey
padding: 15px
border-bottom: 1px solid rgba(0, 0, 0, .1)
margin-bottom: 15px
.options
margin-bottom: 15px
.option-list
.group
margin-bottom: 15px
border: 1px solid rgba(0, 0, 0, .1)
border-radius: $radius-size-medium
.item
height: 52px
border-bottom: 1px solid rgba(0, 0, 0, .1)
&.sub
font-size: $fontsize-medium
background-color: $color-light-grey-opacity
&.first
box-shadow: 0 1px 1px 1px #eee inset
&.last
border-bottom: none
.demo
margin-bottom: 15px
.methods
.method-list
.group
margin-bottom: 15px
border: 1px solid rgba(0, 0, 0, .1)
border-radius: $radius-size-medium
.item
button
height: 40px
font-size: $fontsize-large
.item
background-color: $color-active-light-gray
border-bottom: 1px solid rgba(0, 0, 0, .1)
button
width: 100%
border-bottom-left-radius: $radius-size-medium
border-bottom-right-radius: $radius-size-medium
background-color: $color-orange
box-shadow: 0 0 0 1px $color-orange
border: none
outline: none
color: $color-white
</style>
<template>
<div>
<div class="van-search" style="background: rgb(255, 255, 255);">
<div class="van-search__content van-search__content--square">
<div class="van-cell van-cell--borderless van-field">
<div class="van-field__left-icon">
<i class="van-icon cubeic-search text-medium"></i>
</div>
<div class="van-cell__value van-cell__value--alone">
<div class="van-field__body">
<input type="search" placeholder="请输入搜索关键词" class="van-field__control text-base" />
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<style lang="css" scoped>
.van-search,
.van-search__content {
display: flex;
}
.van-search {
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
box-sizing: border-box;
padding: 10px 12px;
}
.van-search__content {
-webkit-box-flex: 1;
-webkit-flex: 1;
flex: 1;
padding-left: 8px;
background-color: #f7f8fa;
border-radius: 2px;
}
.van-search__content--round {
border-radius: 17px;
}
.van-search__label {
padding: 0 5px;
color: #323233;
font-size: 14px;
line-height: 34px;
}
.van-search .van-cell {
-webkit-box-flex: 1;
-webkit-flex: 1;
flex: 1;
padding: 5px 8px 5px 0;
background-color: transparent;
}
.van-search .van-cell__left-icon {
color: #969799;
}
.van-search--show-action {
padding-right: 0;
}
.van-search input::-webkit-search-cancel-button,
.van-search input::-webkit-search-decoration,
.van-search input::-webkit-search-results-button,
.van-search input::-webkit-search-results-decoration {
display: none;
}
.van-search .van-cell {
display: flex;
flex: 1;
font-size: 14px;
line-height: 24px;
padding: 5px 8px 5px 0;
background-color: transparent;
}
.van-cell__value {
position: relative;
overflow: hidden;
color: #969799;
text-align: right;
vertical-align: middle;
}
.van-field__body {
display: flex;
align-items: center;
height: 100%;
}
.van-search input {
display: block;
box-sizing: border-box;
width: 100%;
margin: 0;
padding: 0;
color: #323233;
text-align: left;
background-color: transparent;
border: 0;
resize: none;
}
.van-search__action {
padding: 0 8px;
color: #323233;
font-size: 14px;
line-height: 34px;
}
.van-search__action:active {
background-color: #f2f3f5;
}
</style>
\ No newline at end of file
<template>
<div class>
<li class="card" v-for="(item,index) in options" :key="item.id">
<div @click="onItemClick(item, index)" class="card-inner">
<div class="card-thumb">
<van-image width="90" height="90" fit="contain" :src="$globalUrlFile+item.icon"></van-image>
</div>
<div class="card-content">
<h2 class="card-title" v-html="item.name"></h2>
<p class="item-desc" v-html="item.category_name"></p>
</div>
</div>
</li>
</div>
</template>
<script>
var b = {
shop_id: 1,
name: "清吧",
address: "重庆市,市辖区,涪陵区",
icon: "files/shop/77/image/a4558aa3-ccb2-4f2c-b5db-1461a25c12a9.jpg",
phone: "15389926297",
shop_type: "restaurant",
category_name: "其他",
address_detail: "聚贤大道116号"
};
export default {
data() {
return {};
},
props: ["options"],
computed: {},
methods: {}
};
</script>
<style lang="stylus" scoped>
.card {
position: relative;
box-sizing: border-box;
padding: 8px 16px;
color: #323233;
font-size: 12px;
// border-bottom: 1px solid #eee;
// background-color: #fafafa;
.card-inner {
display: flex;
}
.card-thumb {
position: relative;
flex: none;
margin-right: 8px;
}
.card-content {
position: relative;
display: flex;
flex: 1;
flex-direction: column;
min-width: 0;
min-height: 90px;
border-bottom: 1px solid #eee;
}
.card-title {
min-height: 34px;
font-weight: 600;
line-height: 24px;
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
}
</style>
......@@ -17,7 +17,7 @@ const $http = axios.create({
});
$http.interceptors.request.use(config => {
let defaultOpstion = { identity: "shop" };
let defaultOpstion = { identity: "normal" };
if (config.method == 'get' || config.method == 'delete') {
Object.assign(config.params, defaultOpstion)
} else {
......
......@@ -46,7 +46,8 @@ import {
Swipe,
Sticky,
ScrollNav,
ScrollNavBar
ScrollNavBar,
RecycleList
} from 'cube-ui'
Vue.use(Button)
......@@ -86,3 +87,5 @@ Vue.use(Swipe)
Vue.use(Sticky)
Vue.use(ScrollNav)
Vue.use(ScrollNavBar)
Vue.use(RecycleList)
......@@ -5,25 +5,46 @@ import vuex from 'vuex'
import 'amfe-flexible'
import store from './store'
import './cube-ui'
import './vant';
import VueAMap from 'vue-amap';
import './common/stylus/index.styl'
import { globalUrlFile, defaultImg } from '../src/config/env'
import components from './common/utils/components'
Vue.config.productionTip = false;
// 全局注册组件
Vue.use(components);
Vue.use(vuex);
Vue.use(VueAMap);
// setTimeout(() => {
VueAMap.initAMapApiLoader({
key: 'c066bb79c8747e4d84aa9e86276f8174',
// key:'41db0da27afa32dc85f51cceb4cfcf9a',
plugin: ['AMap.Geolocation', 'AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
// 默认高德 sdk 版本为 1.4.4
v: '1.4.4',
uiVersion: '1.0.11' // 版本号
});
// }, 200);
// VueAMap.initAMapApiLoader({
// key: 'c066bb79c8747e4d84aa9e86276f8174',
// // key:'41db0da27afa32dc85f51cceb4cfcf9a',
// plugin: ['AMap.Geolocation', 'AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
// // 默认高德 sdk 版本为 1.4.4
// v: '1.4.4',
// uiVersion: '1.0.11' // 版本号
// });
Vue.use(VueAMap);
VueAMap.initAMapApiLoader({
key: '55a08526973b576b5d43ad51aa46932f',
plugin: ['AMap.Geolocation','AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
// 默认高德 sdk 版本为 1.4.4
v: '1.4.4',
uiVersion: '1.0.11' // 版本号
});
Vue.prototype.$defaultImg = defaultImg;// 图片所在域名地址
Vue.prototype.$globalUrlFile = globalUrlFile;// 文件所在域名地址
......
......@@ -4,7 +4,11 @@ const home = r => require.ensure([], () => r(require('./views/home/index.vue')))
const login = r => require.ensure([], () => r(require('./views/login/login.vue')))
const orderIndex = r => require.ensure([], () => r(require('./views/order/index.vue')))
const mineIndex = r => require.ensure([], () => r(require('./views/mine/index.vue')))
// const login = r => require.ensure([], () => r(require('./views/login/login.vue')))
const sellAddress = r => require.ensure([], () => r(require('./views/address/select-address.vue')))
const addAddress = r => require.ensure([], () => r(require('./views/address/add-address.vue')))
const address = r => require.ensure([], () => r(require('./views/address/address.vue')))
const choiseLocation = r => require.ensure([], () => r(require('./views/location/choise.vue')))
Vue.use(Router);
......@@ -31,7 +35,36 @@ export default new Router({
path: "/mine",
name: "mineIndex",
component: mineIndex
}
},
{
path: "/address/select",
name: "sellAddress",
component: sellAddress
},
{
path: '/address/add',
name: 'addAddress',
component: addAddress,
meta: { title: '新增地址', keepAlive: false }
},
{
path: '/address',
name: 'address',
component: address,
meta: { title: '收货地址', keepAlive: false }
},
/*{
path: '/address/edit/:id',
name: 'editAddress',
component: editAddress,
meta: { title: '修改地址', keepAlive: false }
}, */
{
path: '/location/choise',
name: 'choiseLocation',
component: choiseLocation,
meta: { title: '收货地址', keepAlive: false }
},
]
});
......@@ -2,13 +2,34 @@ import { mapGeolocation } from '../common/utils/mUtils'
export default {
// 获取当前地理位置
GET_LOCATION(commit, map) {
let msg = mapGeolocation(map)
console.log(msg)
let location = { lat: msg.position.lat, lng: msg.position.lng, formattedAddress: msg.position.formattedAddress };
commit('RECORD_ADDRESS', location)
GET_LOCATION({ commit, state }, map) {
// if (state.location && state.location.lat) return;
map.plugin("AMap.Geolocation", function () {
var geolocation = new AMap.Geolocation({
enableHighAccuracy: true,//是否使用高精度定位,默认:true
timeout: 10000, //超过10秒后停止定位,默认:无穷大
maximumAge: 0, //定位结果缓存0毫秒,默认:0
convert: true, //自动偏移坐标,偏移后的坐标为高德坐标,默认:true
showButton: true, //显示定位按钮,默认:true
buttonPosition: 'LB', //定位按钮停靠位置,默认:'LB',左下角
buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
showMarker: true, //定位成功后在定位到的位置显示点标记,默认:true
showCircle: true, //定位成功后用圆圈表示定位精度范围,默认:true
panToLocation: true, //定位成功后将定位到的位置作为地图中心点,默认:true
zoomToAccuracy: true //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
});
geolocation.getCurrentPosition();
AMap.event.addListener(geolocation, "complete", function (data) {
let location = { lat: data.position.lat, lng: data.position.lng, formattedAddress: data.formattedAddress };
commit('RECORD_ADDRESS', location)
console.log(data)
});
AMap.event.addListener(geolocation, "error", function (data) {
console.log(data);
});
});
},
}
\ No newline at end of file
......@@ -6,7 +6,9 @@ import actions from './actions'
Vue.use(Vuex)
const state = {
location:{}
location:{lat:'',lng:'',formattedAddress:''}
// location:'定位中'
}
export default new Vuex.Store({
state,
......
export default {
// 记录当前地理位置
RECORD_ADDRESS(state, {
lat,
lng,
formattedAddress
}) {
state.location = {lat,lng,formattedAddress};
RECORD_ADDRESS(state, info) {
state.location = info;
console.log( info)
},
// 重新定位
REFRESH_LOCATION(state, info) {
state.location = info;
console.log( info)
},
}
\ No newline at end of file
import Vue from 'vue'
import {
Search,
Image,
Grid,
GridItem,
AddressList,
Row, Col,
Cell, CellGroup ,
Field,
Button
} from 'vant'
Vue.use(Search)
Vue.use(Image)
Vue.use(Grid)
Vue.use(GridItem)
Vue.use(AddressList);
Vue.use(Row).use(Col);
Vue.use(Cell).use(CellGroup);
Vue.use(Field)
Vue.use(Button)
<template>
<div class="add-address">
<van-cell-group>
<van-field v-model="receiverName" label="联系人" placeholder="姓名" clearable />
<van-row class="sex">
<van-col span="10" offset="7">
<cube-checker v-model="checkerSex" :options="sexOptions" type="radio" class="text-base" />
</van-col>
</van-row>
<van-field v-model="receiverTel" label="电话" type="tel" placeholder="手机号" clearable />
<van-field
ref="area"
class="area"
v-model="receiverArea"
label="地址"
placeholder="选择收货地址"
@click="onChoiseLocation('choiseLocation')"
@focus="$refs.area.blur()"
/>
<van-field v-model="detailedAddress" clearable label="门牌号" placeholder="例:5号楼230室" />
<van-row class="van-cell">
<van-col span="7" class="van-cell__title van-field__label"><span>标签</span></van-col>
<van-col span="18">
<cube-checker
v-model="checkerType"
:options="typeOptions"
type="radio"
class="text-base"
/>
</van-col>
</van-row>
</van-cell-group>
<div class="van-address-edit__buttons">
<van-button class="save" type="danger" size="large" @click="onSave">确定</van-button>
</div>
</div>
</template>
<script>
import { addReceivingAddress } from "../../common/serve";
import utils from "../../common/utils/mUtils";
export default {
data() {
return {
checkerSex: [],
sexOptions: [
{
value: 1,
text: "先生"
},
{
value: 2,
text: "女士"
}
],
checkerType: [],
typeOptions: [
{
value: 1,
text: "家"
},
{
value: 2,
text: "公司"
},
{
value: 3,
text: "学校"
}
],
receiverName: "", //收货人姓名
receiverTel: "", //收货人手机号
detailedAddress: "", //详细地址
receiverArea: "", //收货地址
show: false //默认不显示地区选择
};
},
computed: {},
methods: {
//添加收货地址
async onSave() {
let Data = {
name: "地址名",
address: "地址信息",
lat: "121.513211",
lng: "31.300676",
phone: this.receiverTel,
user_name: this.receiverName,
address_detail: this.detailedAddress,
address_suffix: "231",
area: {},
is_default: 1
};
let res = await addReceivingAddress(Data);
if (res.code === 0) {
this.$toast.success("添加地址成功");
if (this.orderAddress) {
this.$router.push({ name: "confirmOrder" });
} else {
this.$router.push({ name: "address" });
}
}
},
onChoiseLocation(route) {
utils.onRouterLink(this,route);
}
}
};
</script>
<style lang="stylus" rel="stylesheet/stylus">
@import '~common/stylus/mixin.styl';
@import '~common/stylus/variable.styl';
.sex {
padding: 10px 0;
}
.van-cell__title span{
font-weight: 600;
}
.cube-checker-item {
border-1px();
line-height: 14px;
&_active {
border-1px($color-light-blue);
color: $color-light-blue;
background: #f5fbff;
}
}
.van-address-edit__buttons {
padding: 32px 16px;
}
</style>
\ No newline at end of file
<template>
<div>
123
</div>
</template>
<template>
<cube-page type="recycle-list" title="RecycleList">
<div slot="content" class="scroll-list-wrap">
<van-search placeholder="请输入搜索关键词" shape="round"></van-search>
<div class="scroll-list-wrap">
<cube-scroll ref="scroll">
<section class="section">
<div class="cube-index-list-anchor">当前定位</div>
<van-cell :title="curLocation" icon="shop-o">
<i slot="icon" class="cubeic-navigation text-primary text-medium"></i>
<span slot="right-icon" class="text-primary" @click="onRefreshLocation">重新定位</span>
</van-cell>
</section>
<section class="section">
<van-cell>
<span slot="title" class="text-extra-small text-light-grey">收货地址</span>
<span slot="right-icon" class="text-primary" @click="onLink('address')">管理地址</span>
</van-cell>
<van-row v-for="address in addressList" :key="address.id">
<van-col span="22" offset="2">
<div class="van-cell van-address-item line">
<div class="van-cell__value van-cell__value--alone van-address-item__value">
<div class="van-address-item__name">{{address.area}}</div>
<div class>{{address.address_detail}}</div>
<div class="text-light-grey">{{address.name}}&nbsp;&nbsp;{{address.tel}}</div>
</div>
</div>
</van-col>
</van-row>
<van-row>
<van-col span="22" offset="2">
<van-cell title="新增地址" is-link class="text-primary" @click="onLink('addAddress')" />
</van-col>
</van-row>
</section>
</cube-scroll>
</div>
</div>
</cube-page>
</template>
<script>
import { getReceivingAddress } from "../../common/serve";
import { mapState } from "vuex";
import utils from "../../common/utils/mUtils";
let map = {};
export default {
data() {
return {
chosenAddressId: "-1", // 字符串类型!!!
addressList: []
};
},
computed: {
...mapState(["location"]),
curLocation() {
return this.location.formattedAddress
? this.location.formattedAddress
: "定位中...";
}
},
created() {
setTimeout(() => {
map = new AMap.Map("amap", {
resizeEnable: true,
zoom: 16
});
this.$store.dispatch("GET_LOCATION", map);
}, 20);
this.getReceivingAddress();
},
methods: {
async getReceivingAddress() {
let res = await getReceivingAddress();
let _data = res.data;
_data.forEach(el => {
let _obj = {
id: el.id.toString(),
name: el.name,
tel: el.phone,
address: el.area.full_name + "," + el.address_detail,
area_id: el.area_id,
area: el.area.full_name,
address_detail: el.address_detail,
user_name: el.name,
is_default: el.is_default
};
this.addressList.push(_obj);
});
},
onSelect() {},
onRefreshLocation() {
// 重新定位后,调用定位api
this.$store.commit("REFRESH_LOCATION", "定位中...");
this.$store.dispatch("GET_LOCATION", map);
},
onLink(route) {
utils.onRouterLink({ name: route });
}
}
};
</script>
<style scoped>
.cube-page > .wrapper .content {
margin: 0;
}
.cube-index-list-anchor {
background-color: transparent;
}
.van-address-item__name {
font-weight: 600;
}
</style>
<template>
<div>
<div class="scroll-list-wrap">
<cube-sticky :pos="scrollY">
<cube-scroll :scroll-events="scrollEvents" @scroll="scrollHandler">
<div class="location">
<cube-page type="recycle-list" title="RecycleList">
<div slot="content" class="scroll-list-wrap">
<cube-loading v-if="loading" :size="40"></cube-loading>
<cube-sticky v-else :pos="scrollY">
<cube-scroll
ref="scroll"
:scroll-events="scrollEvents"
@scroll="scrollHandler"
:data="msg"
:options="options"
@pulling-down="onPullingDown"
@pulling-up="onPullingUp"
>
<cube-loading v-if="loading" :size="40"></cube-loading>
<!-- 收货地址定位 -->
<div class="location" @click="onRouterLink('sellAddress')">
<i class="cubeic-location text-primary text-extra-large"></i>
<span class="text-medium">中国创业实训基地</span>
<span class="text-medium">{{location.formattedAddress?location.formattedAddress:'定位中...'}}</span>
<div class="location-action">
<i class="cubeic-select text-extra-small"></i>
</div>
<div id="amap"></div>
</div>
<ul>
<li>title</li>
</ul>
<!-- 搜索框 -->
<cube-sticky-ele ele-key="11">
<ul class="sticky-header">
<van-search></van-search>
<van-search placeholder="请输入搜索关键词" shape="round"></van-search>
</ul>
</cube-sticky-ele>
<ul>
<li v-for="(item,index) in shops" :key="index">{{item}}</li>
</ul>
<!-- 轮播图 -->
<section class="slide-container">
<cube-slide ref="slide" :data="slideData" :interval="3000">
<cube-slide-item
v-for="(item, index) in slideData"
:key="index"
@click.native="onSlideEvent(item, index)"
>
<a :href="item.url">
<van-image width="100%" :src="item.image"></van-image>
</a>
</cube-slide-item>
</cube-slide>
</section>
<section>
<van-grid :border="false">
<van-grid-item v-for="(grid,index) in gridsData" :key="index" :text="grid.name">
<div slot="icon">
<van-image width="36" height="36" :src="grid.img"></van-image>
</div>
</van-grid-item>
</van-grid>
</section>
<!-- 附近商家 -->
<section class="section">
<div class="section-hd">附件商家</div>
<ul class="cards">
<shop-list :options="shopsData"></shop-list>
</ul>
</section>
</cube-scroll>
</cube-sticky>
</div>
<footGuide default="home"></footGuide>
</div>
</cube-page>
</template>
<script>
import CubePage from "../../components/cube-page.vue";
import footGuide from "../../components/footer";
import vanSearch from "../../components/search";
import shopList from "../../components/shop-list";
import { mapGeolocation, MAP } from "../../common/utils/mUtils";
import { mapState } from "vuex";
var map = {};
var b = {
code: 0,
data: {
shop_id: 1,
name: "清吧",
address: "重庆市,市辖区,涪陵区",
icon: "files/shop/22/image/f41c3564-6c41-4ed1-9526-fe23f560c839.jpg",
phone: "15389926297",
shop_type: "restaurant",
category_name: "其他",
address_detail: "聚贤大道116号"
},
message: ""
shop_id: 1,
name: "清吧",
address: "重庆市,市辖区,涪陵区",
icon: "files/shop/77/image/a4558aa3-ccb2-4f2c-b5db-1461a25c12a9.jpg",
phone: "15389926297",
shop_type: "restaurant",
category_name: "其他",
address_detail: "聚贤大道116号"
};
var c = [
{
url: "http://www.didichuxing.com/",
image:
"https://y.gtimg.cn/music/photo_new/T003R720x288M000001pf9Sy13Evav.jpg?max_age=2592000"
},
{
url: "http://www.didichuxing.com/",
image:
"https://y.gtimg.cn/music/photo_new/T003R720x288M000001EwfWs4QSIl6.jpg?max_age=2592000"
},
{
url: "http://www.didichuxing.com/",
image:
"https://y.gtimg.cn/music/photo_new/T003R720x288M000001pf9Sy13Evav.jpg?max_age=2592000"
}
];
var d = [
{
img:
"https://fuss10.elemecdn.com/2/35/696aa5cf9820adada9b11a3d14bf5jpeg.jpeg",
name: "甜品饮料"
},
{
img:
"https://fuss10.elemecdn.com/4/34/ea0d51c9608310cf41faa5de6b8efjpeg.jpeg",
name: "甜品饮料1"
},
{
img:
"https://fuss10.elemecdn.com/2/35/696aa5cf9820adada9b11a3d14bf5jpeg.jpeg",
name: "甜品饮料2"
},
{
img:
"https://fuss10.elemecdn.com/4/34/ea0d51c9608310cf41faa5de6b8efjpeg.jpeg",
name: "甜品饮料3"
},
{
img:
"https://fuss10.elemecdn.com/2/35/696aa5cf9820adada9b11a3d14bf5jpeg.jpeg",
name: "甜品饮料4"
}
];
export default {
data() {
return {
location: [121.50886, 31.25373],
shops: [b, b, b],
loading: false,
gridsData: d,
shopsData: [b, b, b],
scrollEvents: ["scroll"],
scrollY: 0
scrollY: 0,
msg: [], // 用来渲染列表的数组
options: {
pullDownRefresh: {
threshold: 90,
stop: 40
// txt: "刷新成功"
}, // 配置下拉刷新
pullUpLoad: {
threshold: 0,
txt: {
// more: "上拉加载更多",
// noMore: "没有更多数据"
}
} // 配置上拉加载,若要关闭可直接 pullUpLoad:false
},
slideData: c
};
},
created() {
MAP()
.then(function(AMap) {
map = new AMap.Map("amap", {
resizeEnable: true,
zoom: 15
});
this.$store.dispatch("GET_LOCATION", map);
})
.catch(err => {
});
/* setTimeout(() => {
map = new AMap.Map("amap", {
resizeEnable: true,
zoom: 15
});
this.$store.dispatch("GET_LOCATION", map);
// this.location = mapGeolocation(map);
}, 20); */
setTimeout(() => {
map = new AMap.Map("amap", {
resizeEnable: true,
zoom: 16
});
this.$store.dispatch("GET_LOCATION", map);
}, 20);
if (this.location.lat) {
this.loading = false;
}
},
computed: {
...mapState(["location"])
},
components: {
footGuide,
vanSearch
CubePage,
shopList
},
methods: {
scrollHandler({ y }) {
this.scrollY = -y;
},
onBtnClick() {},
onSlideEvent(item, index) {
console.log(item, index);
},
onRouterLink(route,query){
if(query){
this.$router.push({name:route,query:query})
return;
}
this.$router.push({name:route})
},
// 获取数据
loadData() {
return;
api
.allMsg({})
.then(res => {
if (res.Code == 200) {
this.msg = res.Response;
}
})
.catch(err => {
console.log(err);
});
},
// 触发下拉刷新
onPullingDown() {
console.log("下拉刷新");
// 模拟更新数据
setTimeout(() => {
if (Math.random() > 0.5) {
// 如果有新数据
console.log("有新数据");
this.msg.unshift(1);
} else {
// 如果没有新数据,调用 forceUpdate(), 显示成功文案,延迟 stopTime 时间完成刷新
this.$refs.scroll.forceUpdate();
}
}, 1000);
},
// 触发上拉加载
onPullingUp() {
console.log("上拉加载");
// 模拟更新数据
setTimeout(() => {
if (Math.random() > 0.5) {
// 如果有新数据
let newPage = [1, 2, 3, 4, 5, 6];
console.log("有新数据");
this.msg = this.msg.concat(newPage);
} else {
// 如果没有新数据
this.$refs.scroll.forceUpdate();
}
}, 1000);
}
}
};
</script>
<style lang="stylus" scoped>
.cube-page {
background-color: #fff;
}
.scroll-list-wrap {
position: fixed;
top: 0;
......@@ -98,4 +258,31 @@ export default {
left: 0;
right: 0;
}
.location {
height: 50px;
line-height: 50px;
padding: 0 10px;
.location-action {
position: absolute;
right: 0;
top: 0;
left: 60%;
background-color: #fff;
}
}
.slide-container {
height: 100px;
margin: 10px;
border-radius: 2px;
overflow: hidden;
box-shadow: 0 2px 10px #ddd;
}
.cards {
overflow: hidden;
background-color: #fff;
}
</style>
\ No newline at end of file
<template>
<div>
<div class="amap-page-container">
<el-amap
vid="amap"
:plugin="plugin"
:center="center"
:map-manager="amapManager"
:zoom="zoom"
:events="events"
:scrollWheel="false"
class="amap-demo"
></el-amap>
</div>
<div class="location-box">
<cube-scroll ref="scroll">
<van-cell-group>
<van-cell
v-for="(item,index) in poisData"
:key="index"
icon="location-o"
:title="item.name"
:label="item.address"
@click="selectAddress(item.id)"
/>
</van-cell-group>
<cube-loading v-if="poisData==null" :size="20">正在定位</cube-loading>
</cube-scroll>
</div>
</div>
</template>
<script>
import VueAMap from "vue-amap";
let amapManager = new VueAMap.AMapManager();
export default {
computed: {
lang() {
return this.$store.state.lang;
}
},
data() {
let self = this;
return {
zoom: 16,
center: [121.59996, 31.197646],
center2: [121.59996, 31.197646],
amapManager,
nowLocation: {
id: null,
address: null
},
poisData: null,
lng: 0,
lat: 0,
lng2: 0,
lat2: 0,
loaded: false,
plugin: [
{
pName: "Geolocation",
events: {
init(o) {
// o 是高德地图定位插件实例
o.getCurrentPosition((status, result) => {
if (result && result.position) {
self.lng = result.position.lng;
self.lat = result.position.lat;
self.center = [self.lng, self.lat];
self.loaded = true;
self.$nextTick();
} else {
self.loaded = true;
}
});
}
}
}
],
events: {
init(map) {
AMapUI.loadUI(["misc/PositionPicker"], function(PositionPicker) {
var positionPicker = new PositionPicker({
mode: "dragMap", //设定为拖拽地图模式,可选'dragMap'、'dragMarker',默认为'dragMap'
map: map //依赖地图对象
});
positionPicker.on("success", function(positionResult) {
self.nowLocation = positionResult.regeocode.pois[0];
console.log(positionResult);
self.lng2 = positionResult.position.lng;
self.lat2 = positionResult.position.lat;
self.center2 = [self.lng2, self.lat2];
if (self.loaded) {
self.poisData = positionResult.regeocode.pois;
}
});
positionPicker.start();
//TODO:事件绑定、结果处理等
});
AMapUI.loadUI(["control/BasicControl"], function(BasicControl) {
//缩放控件
map.addControl(
new BasicControl.Zoom({
position: "rb", //left top,左上角
showZoomNum: false //显示zoom值
})
);
});
}
}
};
},
methods: {
selectAddress(id) {
let pItem = null;
for (let i = 0; this.poisData.length; i++) {
if (this.poisData[i].id == id) {
pItem = this.poisData[i];
break;
}
}
const curChoise = this.poisData.find(item => item.id == id);
console.log(curChoise)
},
goBack() {
/* if(this.locationRequest){
this.$router.push({name: this.locationRequest,params:{action:true}});
}else{
this.$router.push({name: 'dish',params:{action:true}});
} */
},
projectCallBackData() {},
add() {
this.$router.push({ name: "addressAdd", params: { action: true } });
}
}
};
</script>
<style scoped>
.amap-demo {
height: 200px;
}
.location-box {
position: absolute;
top: 250px;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.van-cell__title span {
font-size: 14px;
}
</style>
\ No newline at end of file
......@@ -5,6 +5,12 @@ function resolve(dir) {
}
module.exports = {
configureWebpack: {
externals: {
'AMap': 'AMap',
'AMapUI': 'AMapUI'
}
},
css: {
loaderOptions: {
stylus: {
......@@ -31,5 +37,5 @@ module.exports = {
.use(webpack.ContextReplacementPlugin,
[/moment[/\\]locale$/, /zh-cn/])
},
baseUrl: ''
lintOnSave: false
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment