|
@@ -1,13 +1,13 @@
|
1
|
|
-import { View, Image, Switch, Button, Textarea } from "@tarojs/components"
|
|
1
|
+import { View, Image, Switch, Radio, RadioGroup } from "@tarojs/components"
|
2
|
2
|
import Taro from "@tarojs/taro"
|
3
|
|
-import { useState } from "react"
|
|
3
|
+import { useState, useEffect } from "react"
|
4
|
4
|
import CustomNav from "@/components/CustomNav"
|
5
|
5
|
import edit from "@/assets/icons/comm/edit.png"
|
6
|
6
|
import userRight from '@/assets/mineImgaes/userRight.png'
|
7
|
7
|
|
8
|
8
|
import deletes from "@/assets/icons/comm/deletes.png"
|
9
|
9
|
import ButtontWX from '@/components/ButtontWX'
|
10
|
|
-import { useEffect } from "react"
|
|
10
|
+
|
11
|
11
|
|
12
|
12
|
import { addressDefault, getAddress, addressDelete, addressUpdate } from "@/services/address"
|
13
|
13
|
|
|
@@ -38,10 +38,23 @@ export default (props) => {
|
38
|
38
|
})
|
39
|
39
|
|
40
|
40
|
}
|
|
41
|
+ const [switchBool, setSwitchBool] = useState()
|
|
42
|
+ // const [switchValue, setSwitchValue] = useState('')
|
41
|
43
|
|
42
|
|
- const handelSwitch = (e) => {
|
|
44
|
+ const handelSwitch = (a, e) => {
|
43
|
45
|
const { value } = e.detail
|
44
|
|
- console.log('e', value);
|
|
46
|
+ // console.log('e', !!value);
|
|
47
|
+ console.log('a,e', a, value);
|
|
48
|
+ addressDefault(a).then((se) => {
|
|
49
|
+ console.log('e', se);
|
|
50
|
+ getList()
|
|
51
|
+ })
|
|
52
|
+ // if (value == '') {
|
|
53
|
+ // setSwitchBool(!!value)
|
|
54
|
+
|
|
55
|
+ // } else {
|
|
56
|
+ // setSwitchBool(!value)
|
|
57
|
+ // }
|
45
|
58
|
|
46
|
59
|
}
|
47
|
60
|
const addressEdit = (e) => {
|
|
@@ -51,23 +64,18 @@ export default (props) => {
|
51
|
64
|
|
52
|
65
|
|
53
|
66
|
const getList = () => {
|
54
|
|
- // getAddress().then((e) => {
|
55
|
|
- // console.log('地址列表', e);
|
56
|
|
- // setAddresList(e.records)
|
57
|
|
-
|
58
|
|
-
|
59
|
|
- // })
|
60
|
|
- }
|
61
|
|
-
|
62
|
|
- useEffect(() => {
|
63
|
|
- // getList()
|
64
|
67
|
getAddress().then((e) => {
|
65
|
68
|
console.log('地址列表', e);
|
66
|
69
|
setAddresList(e.records)
|
|
70
|
+ })
|
|
71
|
+ }
|
|
72
|
+
|
|
73
|
+ useEffect(() => {
|
|
74
|
+ getList()
|
67
|
75
|
|
68
|
76
|
|
69
|
|
- })
|
70
|
|
- }, [])
|
|
77
|
+ console.log('执行了', switchBool,);
|
|
78
|
+ }, [switchBool,])
|
71
|
79
|
|
72
|
80
|
|
73
|
81
|
|
|
@@ -97,7 +105,14 @@ export default (props) => {
|
97
|
105
|
|
98
|
106
|
<View className='addressList-box-addressBotton-setAddress'>
|
99
|
107
|
<View>
|
100
|
|
- 设为默认地址: <Switch name='isDefault' onChange={handelSwitch} type='checkbox' />
|
|
108
|
+
|
|
109
|
+ 设为默认地址:
|
|
110
|
+
|
|
111
|
+ <RadioGroup className='radio-group' onChange={(res) => handelSwitch(item.addressId, res)} >
|
|
112
|
+ <Radio color='#FC5531' checked={item.isDefault}></Radio>
|
|
113
|
+ </RadioGroup>
|
|
114
|
+
|
|
115
|
+
|
101
|
116
|
</View>
|
102
|
117
|
|
103
|
118
|
<View className='addressList-box-addressBotton-addressDelete' onClick={() => addressDeletess(item.addressId)}>
|