[baozhangchao] 2 yıl önce
ebeveyn
işleme
7a898f661f

BIN
src/assets/icons/selected.png Dosyayı Görüntüle


BIN
src/assets/icons/unSelected.png Dosyayı Görüntüle


src/pages/MyAddressList/AddressInfos/index.config.js → src/pages/AddressInfos/index.config.js Dosyayı Görüntüle


src/pages/MyAddressList/AddressInfos/index.jsx → src/pages/AddressInfos/index.jsx Dosyayı Görüntüle


src/pages/MyAddressList/AddressInfos/style.less → src/pages/AddressInfos/style.less Dosyayı Görüntüle


+ 23
- 73
src/pages/MyAddressList/index.jsx Dosyayı Görüntüle

1
-import { View, Image, Switch, Radio, RadioGroup } from "@tarojs/components"
1
+import { View, Image, Radio, RadioGroup } from "@tarojs/components"
2
 import Taro, { useDidShow } from "@tarojs/taro"
2
 import Taro, { useDidShow } from "@tarojs/taro"
3
-import { useState, useEffect, useMemo } from "react"
3
+import { useState, useEffect } from "react"
4
 import CustomNav from "@/components/CustomNav"
4
 import CustomNav from "@/components/CustomNav"
5
-import edit from "@/assets/icons/comm/edit.png"
6
-import userRight from '@/assets/mineImgaes/userRight.png'
7
 import withLayout from '@/layouts'
5
 import withLayout from '@/layouts'
8
 import deletes from "@/assets/icons/comm/deletes.png"
6
 import deletes from "@/assets/icons/comm/deletes.png"
9
 import ButtontWX from '@/components/ButtontWX'
7
 import ButtontWX from '@/components/ButtontWX'
10
 import { useModel } from "@/store"
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
 import './style.less'
13
 import './style.less'
16
 
14
 
17
 
15
 
20
   const [addresList, setAddresList] = useState([])
18
   const [addresList, setAddresList] = useState([])
21
   const $instance = Taro.getCurrentInstance()
19
   const $instance = Taro.getCurrentInstance()
22
   const { type } = $instance.router.params
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
   const addAddress = () => {
22
   const addAddress = () => {
32
-    Taro.navigateTo({ url: `/pages/MyAddressList/AddressInfos/index` })
23
+    Taro.navigateTo({ url: `/pages/AddressInfos/index` })
33
   }
24
   }
34
-
35
   const addressDeletess = (e) => {
25
   const addressDeletess = (e) => {
36
     Taro.showModal({
26
     Taro.showModal({
37
       title: '提示',
27
       title: '提示',
45
               duration: 2000
35
               duration: 2000
46
             })
36
             })
47
             getList()
37
             getList()
48
-
49
           })
38
           })
50
         } else if (res.cancel) {
39
         } else if (res.cancel) {
51
           console.log('用户点击取消')
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
       getList()
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
   const addressEdit = (e, res) => {
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
   const getList = () => {
56
   const getList = () => {
83
     getAddress().then((e) => {
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
       setAddresList(e.records)
58
       setAddresList(e.records)
88
     })
59
     })
89
   }
60
   }
90
   useDidShow(() => {
61
   useDidShow(() => {
62
+    console.log(9999);
91
     getList()
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
   const handleAddress = (e) => {
70
   const handleAddress = (e) => {
106
     if (e) {
71
     if (e) {
107
       setUserOrderAddress(e)
72
       setUserOrderAddress(e)
116
           })
81
           })
117
         }, 300)
82
         }, 300)
118
       })
83
       })
119
-
120
-      console.log('选择的地址存放在store', userOrderAddress);
121
-
122
-
123
-
124
     }
84
     }
125
-
126
-
127
-
128
   }
85
   }
129
   return (
86
   return (
130
     <View className='page-index'>
87
     <View className='page-index'>
137
           {
94
           {
138
             addresList.map((item, index) => {
95
             addresList.map((item, index) => {
139
               return (
96
               return (
140
-                <View className='addressList-box' key={index}>
97
+                <View className='addressList-box' key={item.addressId}>
141
                   <View className='addressList-box-addressTop'>
98
                   <View className='addressList-box-addressTop'>
142
                     {
99
                     {
143
                       item.isDefault ?
100
                       item.isDefault ?
144
-                        <View className='addressList-box-addressTop-redText'>默认地址</View> : ''
101
+                        <View className='addressList-box-addressTop-redText'>默认地址</View> : null
145
                     }
102
                     }
146
                     <View className='addressList-box-addressTop-title'>我的地址{index + 1}</View>
103
                     <View className='addressList-box-addressTop-title'>我的地址{index + 1}</View>
147
                   </View>
104
                   </View>
157
                       {
114
                       {
158
                         !type ? <>
115
                         !type ? <>
159
                           <View>
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
                           </View>
121
                           </View>
165
-
166
                           <View className='addressList-box-addressBotton-addressDelete' onClick={() => addressDeletess(item.addressId)}>
122
                           <View className='addressList-box-addressBotton-addressDelete' onClick={() => addressDeletess(item.addressId)}>
167
                             <View>
123
                             <View>
168
                               删除
124
                               删除
169
                             </View>
125
                             </View>
170
                             <Image src={deletes} />
126
                             <Image src={deletes} />
171
-
172
                           </View>
127
                           </View>
173
                         </>
128
                         </>
174
                           : <View className='orderAddressa' onClick={() => handleAddress(item.address)}>
129
                           : <View className='orderAddressa' onClick={() => handleAddress(item.address)}>
175
                             选择此地址
130
                             选择此地址
176
                           </View>
131
                           </View>
177
                       }
132
                       }
178
-
179
                     </View>
133
                     </View>
180
                   </View>
134
                   </View>
181
                 </View>
135
                 </View>
182
               )
136
               )
183
             })
137
             })
184
           }
138
           }
185
-
186
           <View className='bottomButtom' >
139
           <View className='bottomButtom' >
187
             <ButtontWX onClick={addAddress} formType='submit' butText='+新增地址' butWidth={315} butHeight={49} butFontSize={16} butBorderRadius={49} />
140
             <ButtontWX onClick={addAddress} formType='submit' butText='+新增地址' butWidth={315} butHeight={49} butFontSize={16} butBorderRadius={49} />
188
           </View>
141
           </View>
189
-
190
         </View>
142
         </View>
191
       </scroll-view>
143
       </scroll-view>
192
     </View >
144
     </View >
193
   )
145
   )
194
-})
195
-
196
-
146
+})

+ 5
- 31
src/pages/MyAddressList/style.less Dosyayı Görüntüle

51
       align-items: center;
51
       align-items: center;
52
       > View {
52
       > View {
53
         font-size: 30px;
53
         font-size: 30px;
54
-
55
-        .radio-group {
56
-          display: inline-block;
57
-
58
-          .wx-radio-input {
59
-            position: relative;
60
-            display: flex;
61
-            left: 2vw;
62
-            height: 40rpx;
63
-            width: 40rpx;
64
-            margin-top: -4rpx;
65
-            border-radius: 50%;
66
-            border: 2rpx solid #999;
67
-            background: transparent;
68
-          }
69
-        }
70
-
71
-        // .wx-radio-input.wx-radio-input-checked::before {
72
-        //   /* 去除对号 */
73
-        //   content: "";
74
-        //   /* background: #fff; */
75
-        //   width: 40rpx;
76
-        //   height: 40rpx;
77
-        //   border-radius: 50%;
78
-        //   /* background: red; */
79
-        //   background-color: rgb(216, 216, 216);
80
-        //   /* 居中 */
81
-        //   margin-top: 0rpx;
82
-        //   display: flex;
83
-        //   position: relative;
84
-        // }
54
+        display: flex;
85
       }
55
       }
86
       .orderAddressa {
56
       .orderAddressa {
87
         font-size: 34px;
57
         font-size: 34px;
88
         font-weight: 800;
58
         font-weight: 800;
89
       }
59
       }
60
+      .selectImgClass{
61
+        width: 50px;
62
+        height: 50px;
63
+      }
90
     }
64
     }
91
     &-addressDelete {
65
     &-addressDelete {
92
       display: flex;
66
       display: flex;

+ 0
- 2
src/pages/index/index.jsx Dosyayı Görüntüle

38
 
38
 
39
   console.log("🚀 ~ file: index.jsx ~ line 24 ~ withLayout ~ tab", tab)
39
   console.log("🚀 ~ file: index.jsx ~ line 24 ~ withLayout ~ tab", tab)
40
   const [currentTab, setCurrentTab] = useState(0)
40
   const [currentTab, setCurrentTab] = useState(0)
41
-  const [isDidShow, setIsDidShow] = useState(0)
42
-  const [tabsIndex, setTabsIndex] = useState(0)
43
 
41
 
44
 
42
 
45
 
43
 

+ 1
- 1
src/routes.js Dosyayı Görüntüle

38
   },
38
   },
39
   {
39
   {
40
     title: '我的详细地址',
40
     title: '我的详细地址',
41
-    page: 'pages/MyAddressList/AddressInfos/index',
41
+    page: 'pages/AddressInfos/index',
42
   },
42
   },
43
 
43
 
44
   {
44
   {

+ 1
- 1
src/store/userData.js Dosyayı Görüntüle

13
 
13
 
14
 
14
 
15
 
15
 
16
-  console.log("🚀 来自store的打印 person数据", person)
16
+  // console.log("🚀 来自store的打印 person数据", person)
17
 
17
 
18
 
18
 
19
 
19