[baozhangchao] 2 år sedan
förälder
incheckning
7a898f661f

Binär
src/assets/icons/selected.png Visa fil


Binär
src/assets/icons/unSelected.png Visa fil


src/pages/MyAddressList/AddressInfos/index.config.js → src/pages/AddressInfos/index.config.js Visa fil


src/pages/MyAddressList/AddressInfos/index.jsx → src/pages/AddressInfos/index.jsx Visa fil


src/pages/MyAddressList/AddressInfos/style.less → src/pages/AddressInfos/style.less Visa fil


+ 23
- 73
src/pages/MyAddressList/index.jsx Visa fil

@@ -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
+})

+ 5
- 31
src/pages/MyAddressList/style.less Visa fil

@@ -51,42 +51,16 @@
51 51
       align-items: center;
52 52
       > View {
53 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 56
       .orderAddressa {
87 57
         font-size: 34px;
88 58
         font-weight: 800;
89 59
       }
60
+      .selectImgClass{
61
+        width: 50px;
62
+        height: 50px;
63
+      }
90 64
     }
91 65
     &-addressDelete {
92 66
       display: flex;

+ 0
- 2
src/pages/index/index.jsx Visa fil

@@ -38,8 +38,6 @@ export default withLayout((props) => {
38 38
 
39 39
   console.log("🚀 ~ file: index.jsx ~ line 24 ~ withLayout ~ tab", tab)
40 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 Visa fil

@@ -38,7 +38,7 @@ const Pages = [
38 38
   },
39 39
   {
40 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 Visa fil

@@ -13,7 +13,7 @@ export default () => {
13 13
 
14 14
 
15 15
 
16
-  console.log("🚀 来自store的打印 person数据", person)
16
+  // console.log("🚀 来自store的打印 person数据", person)
17 17
 
18 18
 
19 19