123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- <template>
- <view class="container">
- <view class="row b-b" @click="getLocation">
- <text class="tit">常用地址</text>
- <view class="tit witch">{{ address || '请选择常用地址' }}</view>
- </view>
- </view>
- </template>
- <script>
- // #ifdef MP
- import { openMap } from '@/utils/rocessor.js';
- // #endif
- import { getUserInfo } from '@/api/login.js';
- import { changePoint } from '@/api/record.js';
- export default {
- data() {
- return {
- address: '', //常用地址
- commonly_lat: '',
- commonly_lng: ''
- };
- },
- onLoad() {
- this.userinfo();
- },
- methods: {
- // 获取当前位置
- getLocation() {
- let obj = this;
- // #ifdef MP
- openMap()
- .then(() => {
- uni.getLocation({
- type: 'gcj02',
- success(e) {
- uni.chooseLocation({
- latitude: e.latitude,
- longitude: e.longitude,
- success(e) {
- obj.commonly_lat = e.latitude;
- obj.commonly_lng = e.longitude;
- obj.address = e.address;
- obj.EditAddress();
- }
- });
- }
- });
- })
- .catch(e => {
- uni.showModal({
- title: '提示',
- content: '您未授权无法调用地图定位功能!',
- showCancel: false
- });
- });
- // #endif
- },
- //修改地址
- EditAddress() {
- let obj = this;
- changePoint({
- commonly_lat: obj.commonly_lat,
- commonly_lng: obj.commonly_lng,
- commonly_address:obj.address
- })
- .then((data ) => {
- console.log(data)
- obj.$api.msg('修改成功');
- })
- .catch(err => {
- obj.$api.msg(err.msg);
- });
- },
- userinfo() {
- let obj = this;
- getUserInfo({})
- .then(({ data }) => {
- obj.address = data.helper_info.commonly_address;
- })
- .catch(err => {});
- },
- confirm(e) {
- this.loding = true;
- bangding({
- phone: this.account,
- captcha: this.captcha
- })
- .then(({ data }) => {})
- .catch(err => {});
- }
- }
- };
- </script>
- <style lang="scss">
- page {
- background: $page-color-base;
- }
- .container {
- padding-top: 30rpx;
- }
- .witch {
- width: 75% !important;
- }
- .row {
- display: flex;
- align-items: center;
- position: relative;
- padding: 0 30rpx;
- height: 110rpx;
- background: #fff;
- .tit {
- flex-shrink: 0;
- width: 180rpx;
- font-size: 30rpx;
- color: $font-color-dark;
- }
- .input {
- flex: 1;
- font-size: 30rpx;
- color: $font-color-dark;
- }
- .iconlocation {
- font-size: 36rpx;
- color: $font-color-light;
- }
- }
- .add-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 690rpx;
- height: 80rpx;
- margin: 60rpx auto;
- font-size: $font-lg;
- color: #fff;
- background-color: $base-color;
- border-radius: 10rpx;
- // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
- }
- .bg-gray {
- background-color: $color-gray;
- }
- .code {
- color: #5dbc7c;
- font-size: 23rpx;
- border-left: 1px solid #eeeeee;
- width: 150rpx;
- flex-shrink: 0;
- text-align: center;
- }
- </style>
|