|
|
@@ -0,0 +1,209 @@
|
|
|
+<config>
|
|
|
+{
|
|
|
+ "navigationBarTitleText": "选择地址",
|
|
|
+ "navigationBarBackgroundColor": "#ffffff",
|
|
|
+ "navigationBarTextStyle": "black",
|
|
|
+ "backgroundTextStyle":"light"
|
|
|
+}
|
|
|
+</config>
|
|
|
+<template>
|
|
|
+ <div class="container">
|
|
|
+ <van-empty v-if="empty" image="/native/imgs/kong_png_shouhuodizhi.png" description="你还没有收货地址哦~">
|
|
|
+ <van-button type="primary" block @click="address">新增地址</van-button>
|
|
|
+ </van-empty>
|
|
|
+
|
|
|
+ <template v-else>
|
|
|
+ <div class="list">
|
|
|
+ <address-info
|
|
|
+ @choose="choose"
|
|
|
+ :info="item"
|
|
|
+ v-for="(item, index) in addressList"
|
|
|
+ :key="index"
|
|
|
+ ></address-info>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="bottom">
|
|
|
+ <van-button type="primary" block @click="address">新增地址</van-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import AddressInfo from '../components/AddressInfo.vue';
|
|
|
+export default {
|
|
|
+ components: { AddressInfo },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ addressList: [],
|
|
|
+ empty: false,
|
|
|
+ pageType: 'list'
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ addRess() {
|
|
|
+ this.showLoading();
|
|
|
+ this.empty = false;
|
|
|
+ this.$http
|
|
|
+ .get('/address/showMy')
|
|
|
+ .then(res => {
|
|
|
+ this.addressList = res;
|
|
|
+ this.hideLoading();
|
|
|
+ if (res.length === 0) {
|
|
|
+ this.empty = true;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ this.hideLoading();
|
|
|
+ if (e.error) {
|
|
|
+ this.toast(e.rror);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ address() {
|
|
|
+ this.navigateTo('/pages/receiving');
|
|
|
+ },
|
|
|
+ // 添加到确认订单
|
|
|
+ add(item) {
|
|
|
+ let pages = getCurrentPages();
|
|
|
+ let prevPage = pages[pages.length - 2];
|
|
|
+ prevPage.rootVM.userAddressId = item.id;
|
|
|
+ prevPage.rootVM.addressList = item;
|
|
|
+ wx.navigateBack();
|
|
|
+ },
|
|
|
+ choose(info) {
|
|
|
+ if (this.pageType === 'order') {
|
|
|
+ let pages = getCurrentPages();
|
|
|
+ let prevPage = pages[pages.length - 2];
|
|
|
+ prevPage.rootVM.userAddressId = info.id;
|
|
|
+ prevPage.rootVM.addressList = info;
|
|
|
+ wx.navigateBack();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onShow() {
|
|
|
+ this.addRess();
|
|
|
+ },
|
|
|
+ onLoad(options) {
|
|
|
+ if (options.type === 'order') {
|
|
|
+ this.pageType = 'order';
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="less" scoped>
|
|
|
+.container {
|
|
|
+ // background: #f5f7fa;
|
|
|
+ // padding-top: 8px;
|
|
|
+ // padding-bottom: 100px;
|
|
|
+ .box {
|
|
|
+ padding: 8px 20px;
|
|
|
+ .box-con {
|
|
|
+ background: #ffffff;
|
|
|
+ border-radius: 12px;
|
|
|
+ padding: 16px 0 16px 16px;
|
|
|
+ .box-con-top {
|
|
|
+ display: flex;
|
|
|
+ margin-bottom: 8px;
|
|
|
+ p {
|
|
|
+ width: 68px;
|
|
|
+ height: 24px;
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #c8c9cc;
|
|
|
+ line-height: 24px;
|
|
|
+ }
|
|
|
+ .box-con-span {
|
|
|
+ height: 24px;
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #000000;
|
|
|
+ line-height: 24px;
|
|
|
+ }
|
|
|
+ .box-con-code {
|
|
|
+ height: 24px;
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #000000;
|
|
|
+ line-height: 24px;
|
|
|
+ margin-left: 14px;
|
|
|
+ }
|
|
|
+ .box-con-sp {
|
|
|
+ width: 235px;
|
|
|
+ height: 24px;
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #000000;
|
|
|
+ line-height: 24px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .box-con-buttom {
|
|
|
+ display: flex;
|
|
|
+ margin: 40px 10px 0 0;
|
|
|
+ justify-content: flex-end;
|
|
|
+ .box-con-default {
|
|
|
+ width: 60px;
|
|
|
+ height: 32px;
|
|
|
+ border-radius: 4px;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 32px;
|
|
|
+ border: 1px solid #000;
|
|
|
+ font-size: 13px;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #c8c9cc;
|
|
|
+ margin-right: 16px;
|
|
|
+ }
|
|
|
+ .box-con-edit {
|
|
|
+ width: 60px;
|
|
|
+ height: 32px;
|
|
|
+ background: #ffffff;
|
|
|
+ border-radius: 4px;
|
|
|
+ border: 1px solid #ff6c00;
|
|
|
+ font-size: 13px;
|
|
|
+ font-weight: bold;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 32px;
|
|
|
+ color: #ff6c00;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .container-but {
|
|
|
+ width: 290px;
|
|
|
+ height: 48px;
|
|
|
+ background: #ff6c00;
|
|
|
+ border-radius: 12px;
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #ffffff;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 48px;
|
|
|
+ margin: 6px 43px;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.list {
|
|
|
+ background-color: @bg;
|
|
|
+ padding: 16px;
|
|
|
+ min-height: 100vh;
|
|
|
+
|
|
|
+ .address + .address {
|
|
|
+ margin-top: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .address {
|
|
|
+ &:last-child {
|
|
|
+ margin-bottom: 100px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.bottom {
|
|
|
+ position: fixed;
|
|
|
+ bottom: 0;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ padding: 6px 43px;
|
|
|
+ background-color: #fff;
|
|
|
+ .bottom(6px);
|
|
|
+}
|
|
|
+</style>
|