|
@@ -0,0 +1,158 @@
|
|
|
+<template>
|
|
|
+ <div class="address-position">
|
|
|
+ <scroller>
|
|
|
+ <!--姓名-->
|
|
|
+ <group>
|
|
|
+ <x-input title="姓名" v-model="userName" is-type="china-name" @on-blur="nameBlur"></x-input>
|
|
|
+ </group>
|
|
|
+ <!--手机-->
|
|
|
+ <group>
|
|
|
+ <x-input title="手机" v-model="userMobile" is-type="china-mobile" @on-blur="mobileBlur" :max="11"></x-input>
|
|
|
+ </group>
|
|
|
+ <!--定位地址-->
|
|
|
+ <group>
|
|
|
+ <cell value-align="left" :border-intent="true" :is-link="true" :title="positionName" link="/addressPoisiton"></cell>
|
|
|
+ </group>
|
|
|
+ <!--详细地址-->
|
|
|
+ <group>
|
|
|
+ <x-input title="详细地址" v-model='userAddress' @on-blur="addressBlur" placeholder="填写详细地址如15号楼1单元201室"></x-input>
|
|
|
+ </group>
|
|
|
+ </scroller>
|
|
|
+ <!--确认地址-->
|
|
|
+ <div @click="right" class="btnAddress">确认地址</div>
|
|
|
+ <!--展示报错信息-->
|
|
|
+ <alert v-model="showAlert" :title="(alertTitle)"> {{ (alertContent) }}</alert>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import {XInput, Group, Cell, Alert, TransferDomDirective as TransferDom} from 'vux'
|
|
|
+ import config from '../../config/config'
|
|
|
+ // import axios from 'axios'
|
|
|
+ // import qs from 'qs'
|
|
|
+ export default {
|
|
|
+ name: 'home',
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ userName: config.addressAdd.userName,
|
|
|
+ userMobile: config.addressAdd.userMobile,
|
|
|
+ positionName: config.addressAdd.positionName,
|
|
|
+ userAddress: config.addressAdd.userAddress,
|
|
|
+ showAlert: false, // 是否显示弹出框
|
|
|
+ alertTitle: '抱歉', // 弹窗标题
|
|
|
+ alertContent: '' // 弹窗内容
|
|
|
+ }
|
|
|
+ },
|
|
|
+ directives: {
|
|
|
+ TransferDom
|
|
|
+ },
|
|
|
+ components: {XInput, Group, Cell, Alert},
|
|
|
+ beforeCreate () {
|
|
|
+// localStorage.setItem('positionName', '请定位您的小区或者街道')
|
|
|
+ if (localStorage.getItem('positionName')) {
|
|
|
+ console.log('true')
|
|
|
+ } else {
|
|
|
+ console.log('false')
|
|
|
+ localStorage.setItem('positionName', '请定位您的小区或者街道')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {},
|
|
|
+ created () {
|
|
|
+ console.log(localStorage.getItem('positionName'))
|
|
|
+ if (localStorage.getItem('positionName')) {
|
|
|
+ console.log('true')
|
|
|
+ } else {
|
|
|
+ console.log('false')
|
|
|
+ localStorage.setItem('positionName', '请定位您的小区或者街道')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ nameBlur (evl) {
|
|
|
+ config.addressAdd.userName = evl
|
|
|
+ },
|
|
|
+ mobileBlur (evl) {
|
|
|
+ config.addressAdd.userMobile = evl
|
|
|
+ },
|
|
|
+ addressBlur (evl) {
|
|
|
+ config.addressAdd.userAddress = evl
|
|
|
+ },
|
|
|
+ right () {
|
|
|
+ // 姓名不为空
|
|
|
+ if (!this.userName) {
|
|
|
+// this.alertTitle = '抱歉'
|
|
|
+ this.alertContent = '请输入您的姓名'
|
|
|
+ this.showAlert = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 手机号码格式必须正确
|
|
|
+ if (!config.addressAdd.userMobile) {
|
|
|
+ this.alertContent = '请输入正确手记号码'
|
|
|
+ this.showAlert = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 用户地址不为空
|
|
|
+ if (!this.userAddress) {
|
|
|
+ this.alertContent = '请输入您的详细地址'
|
|
|
+ this.showAlert = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ console.log(config.addressPio)
|
|
|
+ config.addressDetail = {
|
|
|
+ 'province': config.addressPio.city,
|
|
|
+ 'city': config.addressPio.city,
|
|
|
+ 'area': config.addressPio.city,
|
|
|
+ 'detail': '',
|
|
|
+ 'poi': {
|
|
|
+ 'uid': config.addressPio.uid,
|
|
|
+ 'name': config.addressPio.name
|
|
|
+ }
|
|
|
+ }
|
|
|
+// let param = {
|
|
|
+// request_from: 'weixin',
|
|
|
+// name: this.userName,
|
|
|
+// mobile: this.userMobile,
|
|
|
+// user_id: config.userId,
|
|
|
+// address_position: config.addressPio.location,
|
|
|
+// address: addressDetail
|
|
|
+// }
|
|
|
+// getAddressAdd(param)
|
|
|
+// axios.get('api/shop/addAddress&request_from=weixin&name=' + this.userName + '&mobile=' + config.addressAdd.userMobile + '&user_id=' + config.userId + '&address_position=' + JSON.stringify(config.addressPio.location) + '&address=' + JSON.stringify(addressDetail)).then(function (res) {
|
|
|
+// if (res.data.data.success) {
|
|
|
+// this.$router.go(-1)
|
|
|
+// }
|
|
|
+// })
|
|
|
+// this.$router.go(-1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // function getAddressAdd (val) {
|
|
|
+ // axios.get('api/shop/addAddress' + qs.stringify(val)).then(function (res) {
|
|
|
+ // console.log(res)
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+</script>
|
|
|
+
|
|
|
+<!-- 添加“scoped”属性来限制CSS到此组件 -->
|
|
|
+<style lang="less">
|
|
|
+ .btnAddress {
|
|
|
+ webkit-touch-callout: none;
|
|
|
+ -webkit-user-select: none;
|
|
|
+ -khtml-user-select: none;
|
|
|
+ -moz-user-select: none;
|
|
|
+ -ms-user-select: none;
|
|
|
+ user-select: none;
|
|
|
+
|
|
|
+ width: 100%;
|
|
|
+ padding: 3% 0;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 20px;
|
|
|
+ margin: 0 auto;
|
|
|
+ position: absolute;
|
|
|
+ bottom: 0;
|
|
|
+ background-color: #997e03;
|
|
|
+ &:active{
|
|
|
+ background-color: #bd9f03;
|
|
|
+ color: #bababa;
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|