--增加判断对象为空方法

--增加表单检索方法
--增加公司资料编辑页面
--增加码单管理页面
--增加码单添加页面
--编辑个人资料、地址管理、码单管理引入图标
This commit is contained in:
li tong bao
2022-04-25 18:09:23 +08:00
parent fa9a6b5d98
commit c6c3b8e21c
27 changed files with 8807 additions and 8643 deletions
-3
View File
@@ -1,3 +0,0 @@
export default {
navigationBarTitleText: '新增收货地址'
}
-64
View File
@@ -1,64 +0,0 @@
.add-address{
.form-list{
display: flex;
justify-content: space-between;
margin: 30px 30px 0;
}
.form-list-label{
font-size: 28px;
font-weight: 700;
color: #000000;
margin-top: 20px;
}
.form-list-right{
width: 506px;
min-height: 80px;
background: #f6f6f6;
border-radius: 20px;
padding: 10px 20px;
box-sizing: border-box;
font-size: 26px;
font-weight: 400;
display: flex;justify-content: space-between;
align-items: center;
}
.form-list-right input,.form-list-right textarea{
flex: 0 0 auto;
min-height: 100%;
width: 100%;
color: #000000;
}
.form-list-right textarea{
height: 186px;
border-radius: 10px;
}
.form-list-right .phcolor{
color: #ababab;
}
.form-list-right-placeholder{
color: #ababab;
}
.form-list-right-enter{
}
.add-address-default{
display: flex;align-items: center;justify-content: space-between;
margin: 70px 30px 0;
font-size: 26px;
font-weight: 700;
color: #000000;
}
.add-address-save{
width: 668px;
height: 82px;
background: #007aff;
border-radius: 40px;
font-size: 32px;
font-weight: 400;
color: #ffffff;
display: flex;align-items: center;justify-content: center;
margin: 620px auto 0;
}
}
-76
View File
@@ -1,76 +0,0 @@
import Address from "@/components/address"
import { Button, Input, Text, Textarea, View } from "@tarojs/components"
import { useState } from "react"
import "./index.scss"
export default ()=>{
const [showSiteModal, setShowSiteModal] = useState(false);
const handleSelectSite = ()=>{
setShowSiteModal(true);
}
// 保存
const [formData, setFormData] = useState({
aa: "",
bb:"",
cc:"",
dd:""
})
const handleSave = ()=>{
}
return (
<View className="add-address">
<FromList value={formData["aa"]} label="联系人" placeholder="请输入收货人姓名"/>
<FromList value={formData["bb"]} label="联系方式" placeholder="请输入收货人姓名"/>
<FromList value={formData["cc"]} onClick={handleSelectSite} label="收地址" type="select" placeholder="请选择/省/市/区"/>
<FromList value={formData["dd"]} label="详细地址" type="textarea" placeholder="请输入详细地址(街道、门牌号等)"/>
<View className="add-address-default">
<Text>设为默认地址</Text>
<View>1</View>
</View>
<Button hoverClass="none" className="add-address-save" onClick={handleSave}>保存</Button>
<Address addressOnClose={()=>setShowSiteModal(false)} show={showSiteModal}/>
</View>
)
}
// 表单列表
const FromList = (props:ListParams)=>{
const {type="input",value=""} = props;
return (
<View className="form-list">
<View className="form-list-label">{props.label}</View>
<View onClick={props?.onClick} className="form-list-right">
{
props.children??(
type=="input"?<Input value={value} placeholder-class="phcolor" onInput={props?.onInput} placeholder={props.placeholder} />:
type=="textarea"?<Textarea value={value} placeholder-class="phcolor" onInput={props?.onInput} placeholder={props.placeholder} />:
<>
{
props.value?<View>{value}</View>:
<View className="form-list-right-placeholder">
{props.placeholder}
</View>
}
<View className="form-list-right-enter">1</View>
</>
)
}
</View>
</View>
)
}
interface ListParams{
label: string, //左边label
onInput?: ()=>any, // 输入框输入
onClick?:()=>any, //点击列表
placeholder?:string, // 提示文本
children?: any, // 插槽
type?: string // 类型:1.input,2.textarea,3.select
value?: any
}
+3
View File
@@ -0,0 +1,3 @@
export default {
navigationBarTitleText: ''
}
+23
View File
@@ -0,0 +1,23 @@
.add-address{
display: flex;
flex-direction: column;
.add-address-default{
display: flex;align-items: center;justify-content: space-between;
margin: 70px 30px 0;
font-size: 26px;
font-weight: 700;
color: #000000;
}
.add-address-save{
width: 668px;
height: 82px;
background: #68b4ff;
border-radius: 40px;
font-size: 32px;
font-weight: 400;
color: #ffffff;
display: flex;align-items: center;justify-content: center;
margin: 620px auto 0;
}
}
+59
View File
@@ -0,0 +1,59 @@
import { retrieval } from "@/common/common"
import Address from "@/components/address"
import FromList from "@/components/FromList"
import { Button, Input, Text, Textarea, View } from "@tarojs/components"
import Taro, { setNavigationBarTitle, useRouter } from "@tarojs/taro"
import { useEffect, useState } from "react"
import "./index.scss"
export default ()=>{
const [showSiteModal, setShowSiteModal] = useState(false);
const {type} = useRouter().params;
useEffect(()=>{
if(type=="add"){
setNavigationBarTitle({title:"新增收货地址"})
}else{
setNavigationBarTitle({title:"编辑收货地址"})
}
},[])
const handleSelectSite = ()=>{
setShowSiteModal(true);
}
// 保存
const [formData, setFormData] = useState({
aa: "1",
bb:"2",
cc:"aa",
dd:"d"
})
const handleSave = ()=>{
Taro.navigateBack();
}
const [hozon, setHozon] = useState(false);
useEffect(()=>{
if(retrieval){
retrieval(formData).then(()=>setHozon(true)).catch(()=>setHozon(false))
}
},[formData])
return (
<View className="add-address">
<FromList value={formData["aa"]} label="联系人" placeholder="请输入收货人姓名"/>
<FromList value={formData["bb"]} label="联系方式" placeholder="请输入收货人姓名"/>
<FromList value={formData["cc"]} onClick={handleSelectSite} label="收地址" type="select" placeholder="请选择/省/市/区"/>
<FromList value={formData["dd"]} label="详细地址" type="textarea" placeholder="请输入详细地址(街道、门牌号等)"/>
<View className="add-address-default">
<Text>设为默认地址</Text>
<View>1</View>
</View>
<Button style={{"background": hozon?'#007aff':''}} hoverClass="none" className={`add-address-save`} onClick={handleSave}>
保存
</Button>
<Address addressOnClose={()=>setShowSiteModal(false)} show={showSiteModal}/>
</View>
)
}
+3
View File
@@ -0,0 +1,3 @@
export default {
navigationBarTitleText: '公司资料'
}
+44
View File
@@ -0,0 +1,44 @@
.company{
display: flex;
flex-direction: column;
.save-button{
width: 668px;
height: 82px;
background: #007aff;
border-radius: 40px;
font-size: 32px;
font-weight: 400;
color: #ffffff;
display: flex;align-items: center;justify-content: center;
margin: 320px auto 0;
}
.form-radio{
display: flex;
flex-wrap: wrap;align-items: center;
}
.form-radio view{
height: 54px;
background: #f0f0f0;
border-radius: 28px;
font-size: 24px;
font-weight: 400;
color: #707070;
padding: 10px 28px;
box-sizing: border-box;
display: flex;align-items: center;justify-content: center;
margin: 10px;
border: 2px solid #f0f0f0;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
}
.form-radio .form-radio-active{
background: #ecf5ff;
border: 2px solid #cde5ff;
}
}
+61
View File
@@ -0,0 +1,61 @@
import Address from "@/components/address"
import FromList from "@/components/FromList"
import { Button, Input, Text, Textarea, View } from "@tarojs/components"
import Taro, { getCurrentPages, useRouter } from "@tarojs/taro"
import { useEffect, useState } from "react"
import "./index.scss"
export default ()=>{
const [showSiteModal, setShowSiteModal] = useState(false);
const handleSelectSite = ()=>{
setShowSiteModal(true);
}
// 保存
const [formData, setFormData] = useState({
aa: "",
bb:"",
cc:"",
dd:""
})
const handleSave = ()=>{
const pages = getCurrentPages();
const prevPage = pages[pages.length-2];
Taro.eventCenter.trigger('message:detail', { text: 'test' })
Taro.navigateBack();
}
// 单选
const radioData = ['布行','二批','制衣厂'];
const [radioActive, setRadioActive] = useState(0);
const handleActiveRadio = (index:number)=>{
setRadioActive(index);
}
return (
<View className="company">
<FromList value={formData["aa"]} label="公司名称" placeholder="请输入收货人姓名"/>
<FromList value={formData["bb"]} label="公司全称" placeholder="请输入收货人姓名"/>
<FromList value={formData["bb"]} label="公司类型" placeholder="请输入收货人姓名">
<View className="form-radio">
{
radioData.map((item,index)=>{
return <View onClick={()=>handleActiveRadio(index)} className={radioActive==index?'form-radio-active':''} key={index}>{item}</View>
})
}
</View>
</FromList>
<FromList value={formData["bb"]} label="联系人" placeholder="请输入收货人姓名"/>
<FromList value={formData["bb"]} label="联系方式" placeholder="请输入收货人姓名"/>
<FromList value={formData["cc"]} onClick={handleSelectSite} label="收地址" type="select" placeholder="请选择/省/市/区"/>
<FromList value={formData["dd"]} label="详细地址" type="textarea" placeholder="请输入详细地址(街道、门牌号等)"/>
<Button hoverClass="none" className="save-button" onClick={handleSave}>保存</Button>
<Address addressOnClose={()=>setShowSiteModal(false)} show={showSiteModal}/>
</View>
)
}
+1 -1
View File
@@ -43,7 +43,7 @@ const Header = memo(()=>{
return (
<View className={styles['card-main-title-content-item']}>
<Image src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F1113%2F052420110515%2F200524110515-2-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1652840455&t=6d2fd53931578ef6e213a929a77d059c"/>
<View>待配布</View>
<View>{item.text}</View>
</View>
)
})
+4
View File
@@ -50,6 +50,9 @@
.user-edit-list-right-placeholder{
color: #cccccc;
}
.user-edit-list-right .icon-a-moreback{
font-size: 30px;
}
.user-edit-logout{
width: 668px;
@@ -67,6 +70,7 @@
.user-edit-popup-content{
margin: 0 auto;
width: 658px;
padding-bottom: 50px;
}
.user-edit-popup-input{
width: 658px;
+26 -10
View File
@@ -1,6 +1,8 @@
import { goLink } from "@/common/common";
import Popup from "@/components/popup";
import { Button, Image, Text, Textarea, View } from "@tarojs/components"
import Taro, { chooseMedia } from "@tarojs/taro";
import { memo, useCallback, useState } from "react"
import "./index.scss"
@@ -20,24 +22,40 @@ export default ()=>{
const handleTextareaSave = ()=>{
}
Taro.eventCenter.on('message:detail', (message) => console.log(message))
// 面面跳转
const onNavigate = (url:string)=>{
goLink(url);
}
// 肖像编辑
const handleSelectRortrait = ()=>{
chooseMedia({
count: 1,
mediaType: ["image"],
success(ev){
console.log(ev);
}
})
}
return (
<View className="user-edit">
<View className="user-edit-portrait">
<View onClick={handleSelectRortrait} className="user-edit-portrait">
<Image src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F1113%2F052420110515%2F200524110515-2-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1652840455&t=6d2fd53931578ef6e213a929a77d059c"/>
<View>点击编辑头像</View>
</View>
<View className="user-edit-content">
<UserEditList onClick={()=>triggerList('nickname')} data={formData} label="昵称" placeholder="请输入" icon=""/>
<UserEditList label="公司/组织" placeholder="请输入" icon=""/>
<UserEditList label="地址管理" placeholder="添加 / 修改收货地址" icon=""/>
<UserEditList label="码单管理" placeholder="修改码单抬头 / 客户 / 电话等显示信息" icon=""/>
<UserEditList onClick={()=>onNavigate("/pages/company/index")} label="公司/组织" placeholder="请输入" icon=""/>
<UserEditList onClick={()=>onNavigate("/pages/addressManager/index")} label="地址管理" placeholder="添加 / 修改收货地址" icon=""/>
<UserEditList onClick={()=>onNavigate("/pages/weightList/index")} label="码单管理" placeholder="修改码单抬头 / 客户 / 电话等显示信息" icon=""/>
<UserEditList label="完善资料" placeholder="完善资料加入会员,申请更多优惠" icon=""/>
<UserEditList label="账号解绑" placeholder="解除账号与所属公司/组织的绑定关系" icon=""/>
</View>
<Button hoverClass="none" className="user-edit-logout">退出当前账号</Button>
<PopupContent show={popupShow} setPopupShow={setPopupShow} save={handleTextareaSave}/>
<PopupContent value="123" show={popupShow} setPopupShow={setPopupShow} save={handleTextareaSave}/>
</View>
)
}
@@ -54,7 +72,7 @@ const UserEditList = memo((props:any)=>{
<View className="user-edit-list-right-placeholder">{props.placeholder}</View>
{/* 请输入 */}
</View>
<Text>1</Text>
<Text className="iconfont icon-a-moreback"></Text>
</View>
</View>
)
@@ -63,9 +81,7 @@ const UserEditList = memo((props:any)=>{
// popup内容
const PopupContent = memo((props:any)=>{
// popup输入长度
const [inputLength, setInputLength] = useState(0);
const handleTextareaInput = (ev:any)=>{
setInputLength(ev.detail.value.length);
}
// 重置
const handleTextareaReset = ()=>{
@@ -75,8 +91,8 @@ const PopupContent = memo((props:any)=>{
<Popup onClose={()=>props.setPopupShow(false)} title="修改昵称" show={props.show}>
<View className="user-edit-popup-content">
<View className="user-edit-popup-input">
<Textarea onInput={handleTextareaInput} maxlength={20}/>
<Text>{inputLength}/20</Text>
<Textarea value={props.value} onInput={handleTextareaInput} maxlength={20}/>
<Text>{props.value.length}/20</Text>
</View>
<Text className="user-edit-popup-tips">请设置2-20个字符,由中文、英文、数字、-和_组成</Text>
<View className="user-edit-popup-operation">
+3
View File
@@ -0,0 +1,3 @@
export default {
navigationBarTitleText: '码单管理'
}
+92
View File
@@ -0,0 +1,92 @@
.weight-list-manager{
height: 100vh;
.weight-list-scroll-view{
height: 100%;
box-sizing: border-box;
position: relative;
scroll-view{
height: 100%;
box-sizing: border-box;
}
.weight-list-list{
width: 704px;
height: 156px;
background: #ffffff;
border-radius: 20px;
box-shadow: 2px 4px 12px 0px rgba(0,0,0,0.16);
padding: 30px;
box-sizing: border-box;
margin: 18px auto 0;
border: 1px solid #ffffff;
}
.weight-list-list:hover{
border: 1px solid #68b4ff;
box-shadow: 0px 0px 10px 0px rgba(0,122,255,0.27);
}
.weight-list-list:last-child{
margin-bottom: 300px;
}
.weight-list-user{
font-size: 28px;
font-family: Microsoft YaHei, Microsoft YaHei-Bold;
font-weight: 700;
text-align: left;
color: #000000;
display: flex;align-items: center;
}
.weight-list-list-default{
width: 58px;
height: 28px;
background: #cde5ff;
border-radius: 6px;
font-size: 20px;
font-weight: 400;
text-align: center;
color: #007aff;
margin-left: 30px;
}
.weight-list-list-phone{
font-size: 24px;
font-weight: 400;
color: #ababab;
margin-left: 30px;
}
.weight-list-edit .icon-bianji{
font-size: 40px;
}
.weight-list-list-info{
font-size: 24px;
font-weight: 400;
color: #3c3c3c;
}
.weight-list-list-bottom{
display: flex;justify-content: space-between;
margin-top: 18px;
}
.add-weight-list{
width: 668px;
height: 82px;
background: #007aff;
border-radius: 40px;
font-size: 32px;
font-weight: 400;
color: #ffffff;
display: flex;align-items: center;justify-content: center;
position: absolute;bottom: 8%;left: 50%;
transform: translateX(-50%);
}
.weight-list-no-data{
font-size: 24px;
font-weight: 400;
text-align: center;
color: #707070;
height: 100%;
padding-top: 40%;
box-sizing: border-box;
}
}
}
+65
View File
@@ -0,0 +1,65 @@
import { Button, Navigator, ScrollView, Text, View } from "@tarojs/components"
import { memo, useState } from "react"
import "./index.scss"
const weightListManager = ()=>{
return(
<View className="weight-list-manager">
<WeightList />
</View>
)
}
interface Params{
refresherEnabled?: boolean,//是否开启刷新
onSelect?: (item:any,index:number)=>void,//列表选择
}
// 码单列表
const WeightList = memo((props:Params)=>{
// 处理刷新
const [refreshState, setRefreshState] = useState(false);
const handleRefresh = ()=>{
setRefreshState(true);
setTimeout(()=>{
setRefreshState(false);
},500)
}
const data = Array.from({length:15});
return (
<View className="weight-list-scroll-view">
<ScrollView scrollY refresherEnabled={props.refresherEnabled} enhanced refresherTriggered={refreshState} onRefresherRefresh={handleRefresh}>
{
data.length>0?
data.map((item,index)=>{
return(
<View onClick={()=>props.onSelect&&props.onSelect(item,index)} className="weight-list-list">
<View className="weight-list-user">
XL纺织
<Text className="weight-list-list-default">默认</Text>
{/* <Text className="weight-list-list-phone">1656488999</Text> */}
</View>
<View className="weight-list-list-bottom">
<View className="weight-list-list-info">
**省**市**区**街道****仓库
<Text className="weight-list-list-phone">181****9790</Text>
</View>
<Navigator url="/pages/weightListAdd/index?type=edit" hoverClass="none" className="weight-list-edit">
<Text className="iconfont icon-bianji"></Text>
</Navigator>
</View>
</View>
);
}):
<View className="weight-list-no-data">暂未添加地址</View>
}
</ScrollView>
<Navigator url="/pages/weightListAdd/index?type=add" hoverClass="none" className="add-weight-list">添加新码单信息</Navigator>
</View>
)
})
export default weightListManager;
+3
View File
@@ -0,0 +1,3 @@
export default {
navigationBarTitleText: ''
}
+23
View File
@@ -0,0 +1,23 @@
.add-address{
display: flex;
flex-direction: column;
.add-address-default{
display: flex;align-items: center;justify-content: space-between;
margin: 70px 30px 0;
font-size: 26px;
font-weight: 700;
color: #000000;
}
.add-address-save{
width: 668px;
height: 82px;
background: #68b4ff;
border-radius: 40px;
font-size: 32px;
font-weight: 400;
color: #ffffff;
display: flex;align-items: center;justify-content: center;
margin: 620px auto 0;
}
}
+42
View File
@@ -0,0 +1,42 @@
import FromList from "@/components/FromList"
import { Button, Input, Text, Textarea, View } from "@tarojs/components"
import Taro, { setNavigationBarTitle, useRouter } from "@tarojs/taro"
import { useEffect, useState } from "react"
import "./index.scss"
export default ()=>{
const {type} = useRouter().params;
useEffect(()=>{
if(type=="add"){
setNavigationBarTitle({title:"添加码单信息"})
}else{
setNavigationBarTitle({title:"修改码单信息"})
}
},[])
// 保存
const [formData, setFormData] = useState({
aa: "",
bb:"",
cc:"",
dd:""
})
const handleSave = ()=>{
Taro.navigateBack();
}
return (
<View className="add-address">
<FromList value={formData["aa"]} label="抬头" placeholder="请输入码单显示抬头信息"/>
<FromList value={formData["bb"]} label="客户" placeholder="请输入码单显示客户名称"/>
<FromList value={formData["bb"]} label="联系方式" placeholder="请输入码单显示联系号码"/>
<View className="add-address-default">
<Text>设为默认地址</Text>
<View>1</View>
</View>
<Button hoverClass="none" className="add-address-save" onClick={handleSave}>保存</Button>
</View>
)
}