洪海涛 8 жил өмнө
parent
commit
afbbdeb468

+ 7 - 1
www/vue/index.html

@@ -4,7 +4,7 @@
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
   <script type="text/javascript" src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
-  <script type="text/javascript" src = 'http://webapi.amap.com/maps?v=1.3&key=ea4228b685c663ac62af7da3a0702c97'></script>
+  <script type="text/javascript" src='http://webapi.amap.com/maps?v=1.3&key=ea4228b685c663ac62af7da3a0702c97'></script>
   <title>vue</title>
   <style>
     html, body {
@@ -19,6 +19,12 @@
       padding: 0;
     }
 
+    ul, li {
+      list-style: none;
+      margin: 0;
+      padding: 0;
+    }
+
     a {
       text-decoration: initial;
     }

+ 2 - 1
www/vue/src/App.vue

@@ -30,6 +30,7 @@
     left: 0;
     right: 0;
     bottom: 0;
-    background-color: rgba(211, 211, 211, 0.3);
+    /*background-color: rgba(211, 211, 211, 0.3);*/
+    background-color: white;
   }
 </style>

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 47 - 3
www/vue/src/components/address/addresList.vue


+ 158 - 0
www/vue/src/components/address/addressDetail.vue

@@ -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>

+ 2 - 1
www/vue/src/components/address/addressPoisiton.vue

@@ -9,6 +9,7 @@
       @on-cancel="onCancel"
       @on-submit="onSubmit"
       cancel-text="搜索"
+      placeholder="请输入您的小区或者街道"
       @on-result-click="onResultClick"
       ref="search"></search>
     <!--<div style="padding:15px;">-->
@@ -68,7 +69,7 @@
     data () {
       return {
         results: [],
-        value: '壹管家'
+        value: ''
       }
     }
   }

+ 1 - 5
www/vue/src/components/home.vue

@@ -36,11 +36,7 @@
     components: {
       XSwitch
     },
-    ready () {
-      this.$nextTick(() => {
-        this.$refs.scrollerBottom.reset({top: 0})
-      })
-    },
+    ready () {},
     computed: mapState({
       userInfo: state => state.userInfo,
       productInfo: state => state.product.productInfo

+ 6 - 1
www/vue/src/components/mine.vue

@@ -12,6 +12,7 @@
 </template>
 <script type="text/javascript">
   import { mapActions } from 'vuex'
+  import config from '../config/config'
   export default({
     data () {
       return {
@@ -19,11 +20,15 @@
         products: this.$store.state.product.products
       }
     },
-    created () {},
+    created () {
+      console.log(this.$store.state.user)
+      console.log(config.shopAddress)
+    },
     methods: {
       ...mapActions([]),
       btn: function (a) {
         console.log(this.$store.state.product.products)
+        console.log(this.$store.state.user)
       }
     }
   })

+ 2 - 2
www/vue/src/components/navigation.vue

@@ -6,12 +6,12 @@
         <img slot="icon-active" :src='iconHomeActive'>
         <span slot="label">首页</span>
       </tabbar-item>
-      <tabbar-item link="/order">
+      <tabbar-item link="/addressList">
         <img slot="icon" :src='iconOrder'>
         <img slot="icon-active" :src='iconOrderActive'>
         <span slot="label">订单</span>
       </tabbar-item>
-      <tabbar-item link="/addressList">
+      <tabbar-item link="/mine">
         <img slot="icon" :src='iconMine'>
         <img slot="icon-active" :src='iconMineActive'>
         <span slot="label">我的</span>

+ 2 - 2
www/vue/src/config/api.js

@@ -97,9 +97,9 @@ export default ({
     })
   },
   // 新增地址
-  addressAdd: function (cb) {
+  addressAdd: function () {
     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(config.addressDetail)).then(function (res) {
-      cb(res.data.data)
+      config.b = res.data.data
     })
   }
 })

+ 3 - 1
www/vue/src/config/config.js

@@ -19,6 +19,7 @@ let addressAdd = {
 }
 let addressDetail = {}
 let addressPio = []
+let showPosition = ''
 if (uri.indexOf('common.yiguanjia.me') > -1) {
   test = false
 }
@@ -53,5 +54,6 @@ export default {
   xNumberValue: xNumberValue,
   addressPio: addressPio,
   addressAdd: addressAdd,
-  addressDetail: addressDetail
+  addressDetail: addressDetail,
+  showPosition: showPosition
 }

+ 4 - 1
www/vue/src/store/user.js

@@ -2,15 +2,18 @@
  * Created by north on 2017/6/12.
  */
 import api from '../config/api'
+import config from '../config/config'
 
 export default {
   state: {
-    userInfo: {}
+    userInfo: {},
+    shopAddress: []
   },
   mutations: {
     // 注意,这里可以设置 state 属性,但是不能异步调用,异步操作写到 actions 中
     USERINFO (state, userInfo) {
       state.userInfo = userInfo
+      config.shopAddress = userInfo.shop_address
     }
   },
   actions: {

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно