Commit 4e9d88ff79d23d6d1fae728ea41a112ca15bcc89

Authored by 范牧
1 parent 53e23d4958
Exists in master

新建地址修改

src/pages/address/addAddress.vue
... ... @@ -77,7 +77,11 @@
77 77 </view>
78 78 <button
79 79 form-type="submit"
  80 + class="button" v-if="addId">编辑</button>
  81 + <button
  82 + form-type="submit"
80 83 class="button"
  84 + v-else
81 85 >保存并使用</button>
82 86 </form>
83 87 </template>
... ... @@ -195,7 +199,11 @@ export default {
195 199 if (this.addId) {
196 200 params.add_id = this.addId
197 201 }
198   - store.dispatch('address/edit', params)
  202 + store.dispatch('address/edit', params).then(() => {
  203 + uni.navigateBack({
  204 + delta: 1
  205 + })
  206 + })
199 207 }
200 208 }
201 209 }
... ...
src/pages/address/addressList.vue
... ... @@ -43,7 +43,7 @@
43 43 >
44 44 暂无收货地址
45 45 </view>
46   - <button class="add">新建收货地址</button>
  46 + <button @tap="toAddAddress" class="add">新建收货地址</button>
47 47 </view>
48 48 </template>
49 49  
... ... @@ -65,6 +65,15 @@ export default {
65 65 store.dispatch('address/list')
66 66 },
67 67 methods: {
  68 + toAddAddress() {
  69 + console.log('aaaaa-a')
  70 + uni.navigateTo({
  71 + url: 'addAddress',
  72 + fail: (error) => {
  73 + console.error('跳转出现错误', error)
  74 + }
  75 + })
  76 + },
68 77 toEditAddress (addId) {
69 78 console.log('addId', addId)
70 79 uni.navigateTo({
... ...
src/store/modules/address.js
... ... @@ -19,10 +19,12 @@ const mutations = {
19 19  
20 20 const actions = {
21 21 edit(mutations, param, success) {
22   - request({
  22 + return new Promise((resolve) => request({
23 23 url: editAddress,
24 24 data: param,
25   - success,
  25 + success: () => {
  26 + resolve()
  27 + },
26 28 fail: () => {
27 29 uni.showModal({
28 30 content: '编辑失败',
... ... @@ -32,7 +34,7 @@ const actions = {
32 34 complete: (res) => {
33 35 console.log('complete status === > ', res)
34 36 }
35   - })
  37 + }))
36 38 },
37 39 list({ commit }) {
38 40 request({
... ...