Blame view

src/pages/address/addressList.vue 3.73 KB
7d6833f2c   范牧   地址列表
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
  <template>
    <view class="content">
      <view
        v-if="addressList.length !== 0"
        class="list"
      >
        <view
          v-for="(item, index) in addressList"
          :key="index"
          @tap="toEditAddress(item.add_id)"
          class="order-user"
        >
          <view class="order-user-head">
            <view class="name">
              <view
                v-if="item.default === '1'"
                class="default"
              ><text>默认</text></view>{{item.name}}
            </view>
            <text class="mobile">{{item.mobile}}</text>
          </view>
          <view class="order-user-body">
            <image src="../../static/myorder-paying-location.png"></image>
            <text class="address">{{item.address.replace(/[-]/g,' ')}}
  {{item.add_detail}}</text>
          </view>
          <image
            v-if="item.default === '1'"
            class="arrow"
            src="../../static/right.png"
          ></image>
          <image
            v-else
            class="arrow pen"
            src="../../static/icon-pen.png"
          ></image>
        </view>
      </view>
      <view
        v-else
        class="empty"
      >
        暂无收货地址
      </view>
      <button class="add">新建收货地址</button>
    </view>
  </template>
  
  <script>
  import store from '@/store'
  export default {
    data () {
      return {}
    },
    computed: {
      addressList () {
        return this.$store.state.address.list
      }
    },
    onLoad () {
      store.dispatch('address/list')
    },
    methods: {
      toEditAddress (addId) {
        console.log('addId', addId)
        uni.navigateTo({
          url: `addAddress?addId=${addId}`,
          fail: (error) => {
            console.error('跳转出现错误', error)
          }
        })
      }
    }
  }
  </script>
  
  <style lang="scss">
  .content {
    min-height: 100vh;
    background-color: #f2f2f2;
    padding-top: 20rpx;
    padding-bottom: 112rpx;
    .order-user {
      width: 670rpx;
      height: 228rpx;
      background: #ffffff;
      border-radius: 14rpx;
      margin: 0 auto;
      margin-bottom: 20rpx;
      position: relative;
      .order-user-head {
        display: flex;
        height: 108rpx;
        width: 100%;
        align-items: center;
        margin-left: 126rpx;
        .name {
          display: flex;
          justify-content: space-between;
          font-size: 14px;
          color: #333333;
          letter-spacing: -0.26px;
          margin-right: 20rpx;
          .default {
            height: 40rpx;
            width: 80rpx;
            background-color: #4a90e2;
            border-radius: 13px;
            border-radius: 13px;
            text-align: center;
            margin-right: 20rpx;
            text {
              font-size: 12px;
              color: #ffffff;
              letter-spacing: -0.23px;
            }
          }
        }
        .mobile {
          font-size: 14px;
          color: #999999;
          letter-spacing: -0.26px;
        }
      }
      .order-user-body {
        display: flex;
        width: 100%;
        image {
          width: 24px;
          height: 26px;
          margin: 12rpx 32rpx 0 40rpx;
        }
        .address {
          font-weight: bold;
          font-size: 14px;
          color: #333333;
          letter-spacing: -0.26px;
        }
      }
      .arrow {
        width: 6px;
        height: 12px;
        position: absolute;
        right: 40rpx;
        bottom: 104rpx;
      }
    }
    .empty {
      color: #666;
      font-size: 16px;
      text-align: center;
      padding-top: 30vh;
    }
    .add {
      position: fixed;
      bottom: 0;
      left: 0;
      height: 112rpx;
      width: 100%;
      background-color: #ff6b4a;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 16px;
      color: #ffffff;
      letter-spacing: -0.3px;
    }
  }
  </style>