--对接地址列表

This commit is contained in:
li tong bao
2022-05-12 09:57:28 +08:00
parent 45e50a6a79
commit fcb9caa221
21 changed files with 241 additions and 3792 deletions
+25 -13
View File
@@ -1,7 +1,8 @@
import { Button, Navigator, ScrollView, Text, View } from "@tarojs/components"
import { memo, useState } from "react"
import { memo, useEffect, useState } from "react"
import "./index.scss"
import {addressListApi} from "@/api/addressManager"
interface Params{
refresherEnabled?: boolean,//是否开启刷新
@@ -11,13 +12,21 @@ interface Params{
// 地址列表
const AddressList = memo((props:Params)=>{
const {fetchData, state} = addressListApi()
// 获取数据
const getData = ()=>{
fetchData();
}
useEffect(()=>{
getData();
},[])
// 处理刷新
const [refreshState, setRefreshState] = useState(false);
const handleRefresh = ()=>{
const handleRefresh = async ()=>{
setRefreshState(true);
setTimeout(()=>{
setRefreshState(false);
},500)
await fetchData();
setRefreshState(false);
}
const data = Array.from({length:15});
@@ -25,21 +34,24 @@ const AddressList = memo((props:Params)=>{
<View className="address-scroll-view">
<ScrollView scrollY refresherEnabled={props.refresherEnabled} enhanced refresherTriggered={refreshState} onRefresherRefresh={handleRefresh}>
{
data.length>0?
data.map((item,index)=>{
state?.data?.list?.length>0?
state?.data?.list?.map((item,index)=>{
// data.length>0?
// data.map((item,index)=>{
return(
<View onClick={()=>props.onSelect&&props.onSelect(item,index)} className={`address-list ${index==0&&'address-active'}`}>
<View onClick={()=>props.onSelect&&props.onSelect(item,index)} className={`address-list ${item.is_default&&'address-active'}`}>
<View className="address-user">
XL纺织
{item.name}
{
index==0?<Text className="address-list-default">默认</Text>:
<Text className="address-list-phone">1656488999</Text>
item.is_default?<Text className="address-list-default">默认</Text>:
<Text className="address-list-phone">{item.phone}</Text>
}
</View>
<View className="address-list-bottom">
<View className="address-list-info">
**省**市**区**街道****仓库
<Text className="address-list-phone">181****9790</Text>
{/* **省**市**区**街道****仓库 */}
{item.province_name+item.city_name+item.district_name} {item.address_detail}
<Text className="address-list-phone">{item.phone}</Text>
</View>
<Navigator url="/pages/addressAdd/index?type=edit" hoverClass="none" className="address-edit">
<Text className="iconfont icon-bianji"></Text>
+6
View File
@@ -28,6 +28,11 @@
width: 100%;
display: flex;align-items: center;
}
.form-list-input view{
height: 100%;
padding: 0 10px;
box-sizing: border-box;
}
.form-list-input text{
width: 30px;
min-width: 30px;
@@ -38,6 +43,7 @@
display: flex;align-items: center;
justify-content: center;
flex: 1;
color: white;
}
.form-list-right input,.form-list-right textarea{
// flex: 0 0 auto;
+8 -2
View File
@@ -5,7 +5,7 @@ import "./index.scss"
interface ListParams{
label: string, //左边label
onInput?: ()=>any, // 输入框输入
onInput?: (ev:Object)=>void, // 输入框输入
onClick?:()=>any, //点击列表
placeholder?:string, // 提示文本
children?: any, // 插槽
@@ -28,7 +28,9 @@ const FromList = memo((props:ListParams)=>{
type=="input"?
<View className="form-list-input">
<Input value={value} placeholder-class="phcolor" onInput={props?.onInput} placeholder={props.placeholder} />
{value&&<Text className="iconfont icon-qingkong"/>}
{value&&
<View><Text onClick={()=>props.onInput&&props.onInput({detail: {value: ""}})} className="iconfont icon-qingkong"/></View>
}
</View>:
type=="textarea"?<Textarea value={value} placeholder-class="phcolor" onInput={props?.onInput} placeholder={props.placeholder} />:
<>
@@ -47,4 +49,8 @@ const FromList = memo((props:ListParams)=>{
</View>
)
})
const A = ()=>{
}
export default FromList;