Blame view

src/pages/address/addressList.vue 4.92 KB
7d6833f2c   范牧   地址列表
1
2
3
4
5
6
7
8
9
  <template>
    <view class="content">
      <view
        v-if="addressList.length !== 0"
        class="list"
      >
        <view
          v-for="(item, index) in addressList"
          :key="index"
7d6833f2c   范牧   地址列表
10
          class="order-user"
323398550   范牧   若干功能添加
11
          @tap="toOrder(item.add_id)"
7d6833f2c   范牧   地址列表
12
13
14
15
16
17
18
19
20
21
22
23
        >
          <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>
1b4b4938a   Adam   auto commit the c...
24
25
26
27
            <!-- <text class="address">{{item.address.replace(/[-]/g,' ')}}
  {{item.add_detail}}</text> -->
            <text class="address">{{item.province}}{{item.city}}{{item.address}}
  {{item.add_detail}}</text>
7d6833f2c   范牧   地址列表
28
29
          </view>
          <image
ba260b3f9   BigBoss   修改
30
            @click.stop="toEditAddress(item.add_id)"
7d6833f2c   范牧   地址列表
31
32
33
34
35
            v-if="item.default === '1'"
            class="arrow"
            src="../../static/right.png"
          ></image>
          <image
ba260b3f9   BigBoss   修改
36
            @click.stop="toEditAddress(item.add_id)"
7d6833f2c   范牧   地址列表
37
38
39
40
41
42
43
44
45
46
47
48
            v-else
            class="arrow pen"
            src="../../static/icon-pen.png"
          ></image>
        </view>
      </view>
      <view
        v-else
        class="empty"
      >
        暂无收货地址
      </view>
4e9d88ff7   范牧   新建地址修改
49
      <button @tap="toAddAddress" class="add">新建收货地址</button>
7d6833f2c   范牧   地址列表
50
51
52
53
54
55
56
57
58
59
60
61
62
63
    </view>
  </template>
  
  <script>
  import store from '@/store'
  export default {
    data () {
      return {}
    },
    computed: {
      addressList () {
        return this.$store.state.address.list
      }
    },
323398550   范牧   若干功能添加
64
65
66
67
    onLoad ({ edit }) {
      if (edit) {
        this.edit = true
      }
1b4b4938a   Adam   auto commit the c...
68
69
70
      store.dispatch('address/list',{
  		uid:1
  	})
7d6833f2c   范牧   地址列表
71
    },
ba260b3f9   BigBoss   修改
72
    onShow() {
1b4b4938a   Adam   auto commit the c...
73
74
75
      store.dispatch('address/list',{
  		uid:1
  	})
ba260b3f9   BigBoss   修改
76
    },
7d6833f2c   范牧   地址列表
77
    methods: {
4e9d88ff7   范牧   新建地址修改
78
79
80
81
82
83
84
85
86
      toAddAddress() {
        console.log('aaaaa-a')
        uni.navigateTo({
          url: 'addAddress',
          fail: (error) => {
            console.error('跳转出现错误', error)
          }
        })
      },
7d6833f2c   范牧   地址列表
87
88
89
90
91
92
93
94
      toEditAddress (addId) {
        console.log('addId', addId)
        uni.navigateTo({
          url: `addAddress?addId=${addId}`,
          fail: (error) => {
            console.error('跳转出现错误', error)
          }
        })
323398550   范牧   若干功能添加
95
96
97
      },
      toOrder (addId) {
        if (this.edit) {
ba260b3f9   BigBoss   修改
98
99
100
101
102
103
104
105
106
107
108
109
  		  let pages = getCurrentPages();
  		  let prevPage = pages[pages.length - 2]; //上一个页面
  		  const addressId=addId
  		  // console.log(addressId)
  		  prevPage.onShow(addressId);
  		  uni.navigateBack();
          // uni.navigateTo({
          //   url: `../confirmOrder/confirmOrder?addressId=${addId}`,
          //   fail: (error) => {
          //     console.error('跳转出现错误', error)
          //   }
          // })
323398550   范牧   若干功能添加
110
        }
7d6833f2c   范牧   地址列表
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
      }
    }
  }
  </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;
ba260b3f9   BigBoss   修改
135
136
        padding-left: 126rpx;
  	  box-sizing: border-box;
7d6833f2c   范牧   地址列表
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
        .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 {
156736a2e   尹聃   样式修改
153
154
155
              display: flex;
              justify-content: center;
              align-items: center;
7d6833f2c   范牧   地址列表
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
              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 {
156736a2e   尹聃   样式修改
184
        width: 12px;
7d6833f2c   范牧   地址列表
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
        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>