|
@@ -1,17 +1,15 @@
|
1
|
|
-import { View, Image, Switch, Radio, RadioGroup } from "@tarojs/components"
|
|
1
|
+import { View, Image, Radio, RadioGroup } from "@tarojs/components"
|
2
|
2
|
import Taro, { useDidShow } from "@tarojs/taro"
|
3
|
|
-import { useState, useEffect, useMemo } from "react"
|
|
3
|
+import { useState, useEffect } from "react"
|
4
|
4
|
import CustomNav from "@/components/CustomNav"
|
5
|
|
-import edit from "@/assets/icons/comm/edit.png"
|
6
|
|
-import userRight from '@/assets/mineImgaes/userRight.png'
|
7
|
5
|
import withLayout from '@/layouts'
|
8
|
6
|
import deletes from "@/assets/icons/comm/deletes.png"
|
9
|
7
|
import ButtontWX from '@/components/ButtontWX'
|
10
|
8
|
import { useModel } from "@/store"
|
11
|
|
-
|
12
|
|
-
|
13
|
|
-import { addressDefault, getAddress, addressDelete, addressUpdate } from "@/services/address"
|
14
|
|
-
|
|
9
|
+import { addressDefault, getAddress, addressDelete } from "@/services/address"
|
|
10
|
+import edit from "@/assets/icons/comm/edit.png"
|
|
11
|
+import selectImg from "@/assets/icons/selected.png"
|
|
12
|
+import unSelectImg from "@/assets/icons/unSelected.png"
|
15
|
13
|
import './style.less'
|
16
|
14
|
|
17
|
15
|
|
|
@@ -20,18 +18,10 @@ export default withLayout((props) => {
|
20
|
18
|
const [addresList, setAddresList] = useState([])
|
21
|
19
|
const $instance = Taro.getCurrentInstance()
|
22
|
20
|
const { type } = $instance.router.params
|
23
|
|
-
|
24
|
|
-
|
25
|
|
- console.log("🚀 ~ file: index.jsx ~ line 23 ~ withLayout ~ orderAddress", type)
|
26
|
|
-
|
27
|
|
-
|
28
|
|
- const { setUserOrderAddress, userOrderAddress } = useModel('userData')
|
29
|
|
-
|
30
|
|
-
|
|
21
|
+ const { setUserOrderAddress } = useModel('userData')
|
31
|
22
|
const addAddress = () => {
|
32
|
|
- Taro.navigateTo({ url: `/pages/MyAddressList/AddressInfos/index` })
|
|
23
|
+ Taro.navigateTo({ url: `/pages/AddressInfos/index` })
|
33
|
24
|
}
|
34
|
|
-
|
35
|
25
|
const addressDeletess = (e) => {
|
36
|
26
|
Taro.showModal({
|
37
|
27
|
title: '提示',
|
|
@@ -45,63 +35,38 @@ export default withLayout((props) => {
|
45
|
35
|
duration: 2000
|
46
|
36
|
})
|
47
|
37
|
getList()
|
48
|
|
-
|
49
|
38
|
})
|
50
|
39
|
} else if (res.cancel) {
|
51
|
40
|
console.log('用户点击取消')
|
52
|
41
|
}
|
53
|
42
|
}
|
54
|
43
|
})
|
55
|
|
-
|
56
|
44
|
}
|
57
|
|
- const [switchBool, setSwitchBool] = useState()
|
58
|
|
- // const [switchValue, setSwitchValue] = useState('')
|
59
|
45
|
|
60
|
|
- const handelSwitch = (a, e) => {
|
61
|
|
- const { value } = e.detail
|
62
|
|
- addressDefault(a).then((se) => {
|
63
|
|
- console.log('e', se);
|
|
46
|
+ const handelSwitch = (id) => {
|
|
47
|
+ addressDefault(id).then((res) => {
|
64
|
48
|
getList()
|
|
49
|
+ console.log(addresList);
|
65
|
50
|
})
|
66
|
|
- // if (value == '') {
|
67
|
|
- // setSwitchBool(!!value)
|
68
|
|
-
|
69
|
|
- // } else {
|
70
|
|
- // setSwitchBool(!value)
|
71
|
|
- // }
|
72
|
51
|
|
73
|
52
|
}
|
74
|
53
|
const addressEdit = (e, res) => {
|
75
|
|
- console.log('e', e);
|
76
|
|
- Taro.navigateTo({ url: `/pages/MyAddressList/AddressInfos/index?addressId=${e}&address=${res}` })
|
77
|
|
-
|
|
54
|
+ Taro.navigateTo({ url: `/pages/AddressInfos/index?addressId=${e}&address=${res}` })
|
78
|
55
|
}
|
79
|
|
-
|
80
|
|
-
|
81
|
|
-
|
82
|
56
|
const getList = () => {
|
83
|
57
|
getAddress().then((e) => {
|
84
|
|
- console.log('地址列表', e);
|
85
|
|
- // let abccList = e.records.sort((a, b) => b.isDefault - a.isDefault)
|
86
|
|
- // console.log("🚀 ~ file: index.jsx ~ line 75 ~ getAddress ~ abccList", abccList)
|
87
|
58
|
setAddresList(e.records)
|
88
|
59
|
})
|
89
|
60
|
}
|
90
|
61
|
useDidShow(() => {
|
|
62
|
+ console.log(9999);
|
91
|
63
|
getList()
|
92
|
|
-
|
93
|
64
|
})
|
94
|
65
|
|
95
|
|
- useEffect(() => {
|
96
|
|
- getList()
|
97
|
|
-
|
98
|
|
-
|
99
|
|
- }, [])
|
|
66
|
+ // useEffect(() => {
|
|
67
|
+ // getList()
|
|
68
|
+ // }, [])
|
100
|
69
|
|
101
|
|
- const srcor = (e) => {
|
102
|
|
- console.log('评分', e.detail);
|
103
|
|
-
|
104
|
|
- }
|
105
|
70
|
const handleAddress = (e) => {
|
106
|
71
|
if (e) {
|
107
|
72
|
setUserOrderAddress(e)
|
|
@@ -116,15 +81,7 @@ export default withLayout((props) => {
|
116
|
81
|
})
|
117
|
82
|
}, 300)
|
118
|
83
|
})
|
119
|
|
-
|
120
|
|
- console.log('选择的地址存放在store', userOrderAddress);
|
121
|
|
-
|
122
|
|
-
|
123
|
|
-
|
124
|
84
|
}
|
125
|
|
-
|
126
|
|
-
|
127
|
|
-
|
128
|
85
|
}
|
129
|
86
|
return (
|
130
|
87
|
<View className='page-index'>
|
|
@@ -137,11 +94,11 @@ export default withLayout((props) => {
|
137
|
94
|
{
|
138
|
95
|
addresList.map((item, index) => {
|
139
|
96
|
return (
|
140
|
|
- <View className='addressList-box' key={index}>
|
|
97
|
+ <View className='addressList-box' key={item.addressId}>
|
141
|
98
|
<View className='addressList-box-addressTop'>
|
142
|
99
|
{
|
143
|
100
|
item.isDefault ?
|
144
|
|
- <View className='addressList-box-addressTop-redText'>默认地址</View> : ''
|
|
101
|
+ <View className='addressList-box-addressTop-redText'>默认地址</View> : null
|
145
|
102
|
}
|
146
|
103
|
<View className='addressList-box-addressTop-title'>我的地址{index + 1}</View>
|
147
|
104
|
</View>
|
|
@@ -157,40 +114,33 @@ export default withLayout((props) => {
|
157
|
114
|
{
|
158
|
115
|
!type ? <>
|
159
|
116
|
<View>
|
160
|
|
- 设为默认地址:
|
161
|
|
- <RadioGroup className='radio-group' onChange={(res) => handelSwitch(item.addressId, res)} >
|
162
|
|
- <Radio color='#FC5531' checked={item.isDefault}></Radio>
|
163
|
|
- </RadioGroup>
|
|
117
|
+ 设为默认地址:{
|
|
118
|
+ item.isDefault ?
|
|
119
|
+ <Image src={selectImg} className='selectImgClass' />
|
|
120
|
+ : <Image src={unSelectImg} className='selectImgClass' onClick={() => handelSwitch(item.addressId)} />}
|
164
|
121
|
</View>
|
165
|
|
-
|
166
|
122
|
<View className='addressList-box-addressBotton-addressDelete' onClick={() => addressDeletess(item.addressId)}>
|
167
|
123
|
<View>
|
168
|
124
|
删除
|
169
|
125
|
</View>
|
170
|
126
|
<Image src={deletes} />
|
171
|
|
-
|
172
|
127
|
</View>
|
173
|
128
|
</>
|
174
|
129
|
: <View className='orderAddressa' onClick={() => handleAddress(item.address)}>
|
175
|
130
|
选择此地址
|
176
|
131
|
</View>
|
177
|
132
|
}
|
178
|
|
-
|
179
|
133
|
</View>
|
180
|
134
|
</View>
|
181
|
135
|
</View>
|
182
|
136
|
)
|
183
|
137
|
})
|
184
|
138
|
}
|
185
|
|
-
|
186
|
139
|
<View className='bottomButtom' >
|
187
|
140
|
<ButtontWX onClick={addAddress} formType='submit' butText='+新增地址' butWidth={315} butHeight={49} butFontSize={16} butBorderRadius={49} />
|
188
|
141
|
</View>
|
189
|
|
-
|
190
|
142
|
</View>
|
191
|
143
|
</scroll-view>
|
192
|
144
|
</View >
|
193
|
145
|
)
|
194
|
|
-})
|
195
|
|
-
|
196
|
|
-
|
|
146
|
+})
|