Authored by 张文文

获取地址列表接口调试

1 <template> 1 <template>
2 <LayoutApp title="选择地址" :show-back="true"> 2 <LayoutApp title="选择地址" :show-back="true">
3 - <AddressItem :list="list"></AddressItem> 3 + <AddressItem :list="addressList"></AddressItem>
4 </LayoutApp> 4 </LayoutApp>
5 </template> 5 </template>
6 6
7 <script> 7 <script>
8 import Layout from "../../../components/layout/layout-app"; 8 import Layout from "../../../components/layout/layout-app";
9 import AddressItem from "./components/address-item"; 9 import AddressItem from "./components/address-item";
10 -import axios from "axios";  
11 10
12 import { createNamespacedHelpers } from "vuex"; 11 import { createNamespacedHelpers } from "vuex";
13 const { mapState, mapMutations, mapActions } = createNamespacedHelpers( 12 const { mapState, mapMutations, mapActions } = createNamespacedHelpers(
@@ -21,9 +20,7 @@ export default { @@ -21,9 +20,7 @@ export default {
21 AddressItem 20 AddressItem
22 }, 21 },
23 data() { 22 data() {
24 - return {  
25 - list: [{ name: "hahaha" }, { name: "hahaha" }]  
26 - }; 23 + return {};
27 }, 24 },
28 computed: { 25 computed: {
29 ...mapState(["addressList"]) 26 ...mapState(["addressList"])
@@ -60,6 +60,7 @@ @@ -60,6 +60,7 @@
60 60
61 <div :class="submitClass" @touchend="onSubmit">确定</div> 61 <div :class="submitClass" @touchend="onSubmit">确定</div>
62 </div> 62 </div>
  63 + <!-- <AddressAct></AddressAct> -->
63 </LayoutApp> 64 </LayoutApp>
64 </template> 65 </template>
65 66
@@ -68,6 +69,7 @@ import Layout from "../../../components/layout/layout-app"; @@ -68,6 +69,7 @@ import Layout from "../../../components/layout/layout-app";
68 import Input from "./components/input"; 69 import Input from "./components/input";
69 import FormItem from "./components/form-item"; 70 import FormItem from "./components/form-item";
70 import Radio from "./components/radio"; 71 import Radio from "./components/radio";
  72 +import AddressAct from "./components/address-act";
71 73
72 import { createNamespacedHelpers } from "vuex"; 74 import { createNamespacedHelpers } from "vuex";
73 const { mapState, mapMutations, mapActions } = createNamespacedHelpers( 75 const { mapState, mapMutations, mapActions } = createNamespacedHelpers(
@@ -80,7 +82,8 @@ export default { @@ -80,7 +82,8 @@ export default {
80 LayoutApp: Layout, 82 LayoutApp: Layout,
81 CInput: Input, 83 CInput: Input,
82 FormItem, 84 FormItem,
83 - Radio 85 + Radio,
  86 + AddressAct
84 }, 87 },
85 data() { 88 data() {
86 return { 89 return {
  1 +<template>
  2 + <div class="address-select-component" v-show="true">
  3 + <div class="address-select-box">
  4 + <div class="component-title">
  5 + <span class="title">所在地区</span>
  6 + <span class="iconfont close" @click="closeAddBox">&#xe623;</span>
  7 + </div>
  8 + <ul class="head-address-ul">
  9 + <li
  10 + v-if="province.title"
  11 + :class="{ 'head-address-li': common.titleActive, 'disable': !supportChangeProvince}"
  12 + @click="clickTitle('province')"
  13 + >{{province.title}}</li>
  14 + <li
  15 + v-if="city.title"
  16 + :class="{ 'head-address-li': province.titleActive }"
  17 + @click="clickTitle('city')"
  18 + >{{city.title}}</li>
  19 + <li
  20 + v-if="area.title"
  21 + :class="{ 'head-address-li': city.titleActive }"
  22 + @click="clickTitle('area')"
  23 + >{{area.title}}</li>
  24 + <li v-if="street.title" :class="{ 'head-address-li': area.titleActive }">{{street.title}}</li>
  25 + </ul>
  26 + <div class="address-container">
  27 + <div class="address-content">
  28 + <ul v-if="province.showList" class="address-ul">
  29 + <li
  30 + v-for="(pprovince, index) in provinces"
  31 + :key="index"
  32 + @click="switchAddress(pprovince.id, pprovince.caption)"
  33 + >
  34 + {{pprovince.caption}}
  35 + <span
  36 + v-if="pprovince.id === province.id"
  37 + class="iconfont icon-v"
  38 + ></span>
  39 + </li>
  40 + </ul>
  41 + <ul v-if="city.showList" class="address-ul">
  42 + <li
  43 + v-for="(pcity, index) in citys"
  44 + :key="index"
  45 + @click="switchAddress(pcity.id, pcity.caption)"
  46 + >
  47 + {{pcity.caption}}
  48 + <span v-if="pcity.id === city.id" class="iconfont icon-v"></span>
  49 + </li>
  50 + </ul>
  51 + <ul v-if="area.showList" class="address-ul">
  52 + <li
  53 + v-for="(parea, index) in areas"
  54 + :key="index"
  55 + @click="switchAddress(parea.id, parea.caption)"
  56 + >
  57 + {{parea.caption}}
  58 + <span v-if="parea.id === area.id" class="iconfont icon-v"></span>
  59 + </li>
  60 + </ul>
  61 + <ul v-if="street.showList" class="address-ul">
  62 + <li
  63 + v-for="(pstreet, index) in streets"
  64 + :key="index"
  65 + @click="switchAddress(pstreet.id, pstreet.caption)"
  66 + >
  67 + {{pstreet.caption}}
  68 + <span v-if="pstreet.id === street.id" class="iconfont icon-v"></span>
  69 + </li>
  70 + </ul>
  71 + </div>
  72 + </div>
  73 + </div>
  74 + </div>
  75 +</template>
  76 +
  77 +<script>
  78 +export default {
  79 + data() {
  80 + return {
  81 + supportChangeProvince: true, // 是否支持修改省
  82 + provinces: [],
  83 + citys: [],
  84 + areas: [],
  85 + streets: [],
  86 + show: false,
  87 + common: {
  88 + titleActive: true
  89 + },
  90 + province: {
  91 + id: "",
  92 + title: "",
  93 + allTitle: "",
  94 + showList: true,
  95 + titleActive: false
  96 + },
  97 + city: {
  98 + id: "",
  99 + title: "",
  100 + allTitle: "",
  101 + showList: false,
  102 + titleActive: false
  103 + },
  104 + area: {
  105 + id: "",
  106 + title: "",
  107 + allTitle: "",
  108 + showList: false,
  109 + titleActive: false
  110 + },
  111 + street: {
  112 + id: "",
  113 + title: "",
  114 + allTitle: "",
  115 + showList: false,
  116 + titleActive: false
  117 + }
  118 + };
  119 + }
  120 + // methods: {
  121 + // /* 返回标题处理 */
  122 + // returnTitle() {
  123 + // let getTitle = "";
  124 + // let returnTitle = "";
  125 +
  126 + // if (this.supportChangeProvince) {
  127 + // getTitle =
  128 + // this.province.allTitle +
  129 + // this.city.allTitle +
  130 + // this.area.allTitle +
  131 + // this.street.allTitle;
  132 + // } else {
  133 + // getTitle =
  134 + // this.city.allTitle + this.area.allTitle + this.street.allTitle;
  135 + // }
  136 +
  137 + // if (getTitle.length > 11) {
  138 + // returnTitle = getTitle.substr(0, 5) + "..." + getTitle.substr(-5);
  139 + // } else {
  140 + // returnTitle = getTitle;
  141 + // }
  142 +
  143 + // return returnTitle;
  144 + // },
  145 +
  146 + // /* 标题长度处理 */
  147 + // titleHandle(caption) {
  148 + // if (caption.length > 3) {
  149 + // return caption.substring(0, 3) + "...";
  150 + // } else {
  151 + // return caption;
  152 + // }
  153 + // },
  154 +
  155 + // /* 选择地址后的显示控制 */
  156 + // changeShow(id, caption) {
  157 + // switch ((id + "").length) {
  158 + // case 2:
  159 + // this.province.id = id;
  160 + // this.province.allTitle = caption;
  161 + // this.province.title = this.titleHandle(caption);
  162 + // this.city.title = "请选择";
  163 + // this.city.showList = this.province.titleActive = true;
  164 + // this.province.showList = this.area.showList = this.street.showList = false;
  165 + // this.common.titleActive = this.city.titleActive = this.area.titleActive = this.street.titleActive = false;
  166 + // break;
  167 + // case 4:
  168 + // this.city.id = id;
  169 + // this.city.allTitle = caption;
  170 + // this.city.title = this.titleHandle(caption);
  171 + // this.area.title = "请选择";
  172 + // this.area.showList = this.city.titleActive = true;
  173 + // this.province.showList = this.city.showList = this.street.showList = false;
  174 + // this.province.titleActive = this.area.titleActive = this.street.titleActive = false;
  175 + // break;
  176 + // case 6:
  177 + // this.area.id = id;
  178 + // this.area.allTitle = caption;
  179 + // this.area.title = this.titleHandle(caption);
  180 + // this.street.title = "请选择";
  181 + // this.street.showList = this.area.titleActive = true;
  182 + // this.province.showList = this.city.showList = this.area.showList = false;
  183 + // this.province.titleActive = this.city.titleActive = this.street.titleActive = false;
  184 + // break;
  185 + // case 9:
  186 + // this.street.id = id;
  187 + // this.street.allTitle = caption;
  188 + // this.street.title = this.titleHandle(caption);
  189 + // this.street.showList = this.street.titleActive = true;
  190 + // this.province.showList = this.city.showList = this.area.showList = false;
  191 + // this.province.titleActive = this.city.titleActive = this.area.titleActive = false;
  192 + // break;
  193 + // default:
  194 + // this.province.title = "请选择";
  195 + // this.province.showList = this.province.titleActive = true;
  196 + // this.city.showList = this.area.showList = this.street.showList = false;
  197 + // this.city.titleActive = this.area.titleActive = this.street.titleActive = false;
  198 + // break;
  199 + // }
  200 + // },
  201 +
  202 + // /* 获取地址数据绑定 */
  203 + // switchAddress(id, caption) {
  204 + // if (!id) {
  205 + // id = 0;
  206 + // }
  207 +
  208 + // this.changeShow(id, caption);
  209 +
  210 + // $.get(
  211 + // "/home/getaddress.json",
  212 + // {
  213 + // id: id
  214 + // },
  215 + // resultData => {
  216 + // /* 结果返回 */
  217 + // if (resultData.length < 1) {
  218 + // areaCode.val(id);
  219 + // let returnTitle = this.returnTitle();
  220 +
  221 + // area.val(returnTitle);
  222 + // this.show = false;
  223 +
  224 + // // this.$emit("modify.addressAct", {
  225 + // // code: id,
  226 + // // area: returnTitle
  227 + // // });
  228 + // }
  229 +
  230 + // /* 数据绑定 */
  231 + // switch ((id + "").length) {
  232 + // case 2:
  233 + // this.citys = resultData;
  234 + // break;
  235 + // case 4:
  236 + // this.areas = resultData;
  237 + // break;
  238 + // case 6:
  239 + // this.streets = resultData;
  240 + // break;
  241 + // default:
  242 + // this.provinces = resultData;
  243 + // break;
  244 + // }
  245 + // }
  246 + // );
  247 + // },
  248 +
  249 + // /* 关闭地址选择组件 */
  250 + // closeAddBox() {
  251 + // this.show = false;
  252 + // },
  253 +
  254 + // /* 点击地址标题时的处理 */
  255 + // clickTitle(type) {
  256 + // switch (type) {
  257 + // case "province":
  258 + // if (!this.supportChangeProvince) {
  259 + // return false;
  260 + // }
  261 + // if (this.provinces.length < 1) {
  262 + // this.switchAddress();
  263 + // }
  264 + // this.province.titleActive = this.province.showList = true;
  265 + // this.city.titleActive = this.area.titleActive = this.street.titleActive = false;
  266 + // this.city.title = this.area.title = this.street.title = "";
  267 + // break;
  268 + // case "city":
  269 + // this.city.titleActive = this.city.showList = true;
  270 + // this.province.titleActive = this.area.titleActive = this.street.titleActive = false;
  271 + // this.province.showList = this.area.showList = this.street.showList = false;
  272 + // this.area.title = this.street.title = "";
  273 + // break;
  274 + // case "area":
  275 + // this.area.titleActive = this.area.showList = true;
  276 + // this.province.titleActive = this.city.titleActive = this.street.titleActive = false;
  277 + // this.province.showList = this.city.showList = this.street.showList = false;
  278 + // this.street.title = "";
  279 + // break;
  280 + // default:
  281 + // break;
  282 + // }
  283 + // }
  284 + // },
  285 + // created: function() {
  286 + // this.switchAddress();
  287 + // }
  288 +};
  289 +</script>
  290 +
  291 +<style lang="scss">
  292 +.disable {
  293 + color: #a6a6a6;
  294 +}
  295 +
  296 +.icon-v:before {
  297 + content: "\e6ea";
  298 +}
  299 +
  300 +.address-select-component {
  301 + position: fixed;
  302 + bottom: 0;
  303 + left: 0;
  304 + top: 0;
  305 + width: 100%;
  306 + background: rgba(0, 0, 0, 0.5);
  307 +
  308 + .address-select-box {
  309 + position: absolute;
  310 + bottom: 0;
  311 + left: 0;
  312 + right: 0;
  313 + background: #fff;
  314 +
  315 + .component-title {
  316 + text-align: center;
  317 + line-height: 80px;
  318 + font-size: 32px;
  319 + color: #ccc;
  320 + padding: 0 30px;
  321 +
  322 + .close {
  323 + float: right;
  324 + }
  325 + }
  326 +
  327 + .head-address-ul {
  328 + margin: 0 0 0 30px;
  329 + padding: 0;
  330 + list-style: none;
  331 + overflow: hidden;
  332 + background-color: white;
  333 + font-size: 24px;
  334 + color: #444;
  335 +
  336 + li {
  337 + display: block;
  338 + float: left;
  339 + height: 40px;
  340 + line-height: 40px;
  341 + position: relative;
  342 + margin-right: 70px;
  343 + }
  344 +
  345 + li:last-child {
  346 + margin-right: 30px;
  347 + }
  348 +
  349 + .head-address-li {
  350 + color: #f23030;
  351 + }
  352 +
  353 + .head-address-li:after {
  354 + width: 100%;
  355 + height: 1px;
  356 + border-bottom: 2px solid #f23030;
  357 + position: absolute;
  358 + bottom: 0;
  359 + left: 0;
  360 + content: "";
  361 + }
  362 + }
  363 +
  364 + .head-address-ul:after {
  365 + content: "";
  366 + width: 100%;
  367 + height: 1px;
  368 + position: absolute;
  369 + border-bottom: 1px solid #e3e5e9;
  370 + left: 0;
  371 + bottom: 0;
  372 + transform: scaleY(0.5);
  373 + -webkit-transform: scaleY(0.5);
  374 + }
  375 +
  376 + .address-container {
  377 + margin: 0;
  378 + overflow: hidden;
  379 + height: 100%;
  380 + width: 100%;
  381 + border-top: solid 1px #ccc;
  382 +
  383 + .address-content {
  384 + transform: translate(0, 0) translateZ(0);
  385 + height: 620px;
  386 + }
  387 + }
  388 +
  389 + .address-ul {
  390 + padding: 0;
  391 + margin: 0;
  392 + list-style: none;
  393 + height: 100%;
  394 + overflow: auto;
  395 + font-size: 24px;
  396 + color: #232326;
  397 +
  398 + li {
  399 + height: 80px;
  400 + line-height: 80px;
  401 + padding-left: 30px;
  402 + position: relative;
  403 + overflow: hidden;
  404 +
  405 + span {
  406 + color: #f23030;
  407 + font-size: 14px;
  408 + }
  409 + }
  410 +
  411 + li:after {
  412 + content: "";
  413 + width: 100%;
  414 + height: 1px;
  415 + position: absolute;
  416 + left: 0;
  417 + bottom: 0;
  418 + transform: scaleY(0.5);
  419 + -webkit-transform: scaleY(0.5);
  420 + }
  421 + }
  422 + }
  423 +}
  424 +</style>
@@ -6,12 +6,13 @@ @@ -6,12 +6,13 @@
6 <div class="user-item"> 6 <div class="user-item">
7 <div class="user-info"> 7 <div class="user-info">
8 <div class="extra"> 8 <div class="extra">
9 - <p class="name">WUNA</p>  
10 - <p class="mobile">183****8888</p>  
11 - <div class="tag-btn">默认</div> 9 + <p class="name">{{item.consignee}}</p>
  10 + <p class="mobile">{{item.mobile}}</p>
  11 + <div v-if="item.is_default === 'Y'" class="tag-btn">默认</div>
  12 + <div v-if="item.tag_code" class="tag-btn">{{item.tag}}</div>
12 <div class="option-btn" :data-item="item" :data-add="false" @click="toEditorPage">编辑</div> 13 <div class="option-btn" :data-item="item" :data-add="false" @click="toEditorPage">编辑</div>
13 </div> 14 </div>
14 - <p class="address">江苏省 南京市 建邺区 江陵江东街 国家广告产业园5栋17楼新与力传媒</p> 15 + <p class="address">{{item.area}}{{item.address}}</p>
15 <div class="border-line"></div> 16 <div class="border-line"></div>
16 </div> 17 </div>
17 </div> 18 </div>
@@ -45,14 +46,15 @@ export default { @@ -45,14 +46,15 @@ export default {
45 }, 46 },
46 methods: { 47 methods: {
47 toOrderPage(item) { 48 toOrderPage(item) {
48 - console.log("toOrderPage");  
49 - // this.$router.push({  
50 - // name: "author",  
51 - // params: {  
52 - // id: item.userId,  
53 - // type: item.userType || 1  
54 - // }  
55 - // }); 49 + this.$router.push({
  50 + name: "detail",
  51 + params: {
  52 + consignee: item.consignee,
  53 + mobile: item.mobile,
  54 + area: item.area,
  55 + address: item.address
  56 + }
  57 + });
56 }, 58 },
57 toEditorPage(event) { 59 toEditorPage(event) {
58 event.stopPropagation(); 60 event.stopPropagation();
@@ -60,9 +62,14 @@ export default { @@ -60,9 +62,14 @@ export default {
60 let item = event.currentTarget.dataset.item || {}; 62 let item = event.currentTarget.dataset.item || {};
61 63
62 if (isAdd) { 64 if (isAdd) {
63 - console.log("toAddPage"); 65 + this.$router.push({
  66 + name: "addressEdit"
  67 + });
64 } else { 68 } else {
65 - console.log("toEditorPage"); 69 + this.$router.push({
  70 + name: "addressEdit",
  71 + item: item
  72 + });
66 } 73 }
67 } 74 }
68 }, 75 },
@@ -12,7 +12,6 @@ export default { @@ -12,7 +12,6 @@ export default {
12 uid: '500031912', 12 uid: '500031912',
13 }); 13 });
14 14
15 - console.log('----------', result.data);  
16 if (result.code === 200) { 15 if (result.code === 200) {
17 commit(Types.FETCH_USER_ADDRESS_LIST, { 16 commit(Types.FETCH_USER_ADDRESS_LIST, {
18 list: get(result, 'data', []) 17 list: get(result, 'data', [])