--我的页面更新新版本
--码单管理完成
This commit is contained in:
parent
6ba8a7b137
commit
14216d3b0a
56
src/api/company.ts
Normal file
56
src/api/company.ts
Normal file
@ -0,0 +1,56 @@
|
||||
import { useRequest } from "@/use/useHttp"
|
||||
|
||||
/**
|
||||
* 公司获取
|
||||
* @returns
|
||||
*/
|
||||
export const companyDetailApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/company/info`,
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 公司保存
|
||||
* @returns
|
||||
*/
|
||||
export const companyUpdateApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/company/info`,
|
||||
method: "put",
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 地址详情
|
||||
* @returns
|
||||
*/
|
||||
export const addressDetailApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/address`,
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 地址编辑
|
||||
* @returns
|
||||
*/
|
||||
export const addressEditApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/address`,
|
||||
method: "put",
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 地址删除
|
||||
* @returns
|
||||
*/
|
||||
export const addressDeleteApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/address`,
|
||||
method: "delete",
|
||||
})
|
||||
}
|
@ -29,3 +29,13 @@ import { useRequest } from "@/use/useHttp"
|
||||
method: "post",
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户昵称
|
||||
*/
|
||||
export const realNameUpdateApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/user`,
|
||||
method: "put",
|
||||
})
|
||||
}
|
||||
|
56
src/api/weightList.ts
Normal file
56
src/api/weightList.ts
Normal file
@ -0,0 +1,56 @@
|
||||
import { useRequest } from "@/use/useHttp"
|
||||
|
||||
/**
|
||||
* 码单列表获取
|
||||
* @returns
|
||||
*/
|
||||
export const weightListApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/title/list`,
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 码单添加
|
||||
* @returns
|
||||
*/
|
||||
export const weightAddApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/title`,
|
||||
method: "post",
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 码单详情
|
||||
* @returns
|
||||
*/
|
||||
export const weightDetailApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/title`,
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 码单编辑
|
||||
* @returns
|
||||
*/
|
||||
export const weightEditApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/title`,
|
||||
method: "put",
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 码单删除
|
||||
* @returns
|
||||
*/
|
||||
export const weightDeleteApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/title`,
|
||||
method: "delete",
|
||||
})
|
||||
}
|
@ -4,27 +4,91 @@ 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 { alert, retrieval } from "@/common/common";
|
||||
import { companyDetailApi, companyUpdateApi } from "@/api/company"
|
||||
import "./index.scss"
|
||||
|
||||
export default ()=>{
|
||||
const [showSiteModal, setShowSiteModal] = useState(false);
|
||||
|
||||
const handleSelectSite = ()=>{
|
||||
setShowSiteModal(true);
|
||||
}
|
||||
|
||||
// 获取公司信息
|
||||
const {fetchData: getFromData} = companyDetailApi();
|
||||
const getData = async ()=>{
|
||||
const result = await getFromData();
|
||||
console.log(result.data,"===");
|
||||
|
||||
setFormData({
|
||||
...result.data,
|
||||
|
||||
});
|
||||
}
|
||||
useEffect(()=>{
|
||||
getData();
|
||||
},[])
|
||||
// 保存
|
||||
const [formData, setFormData] = useState({
|
||||
aa: "",
|
||||
bb:"",
|
||||
cc:"",
|
||||
dd:""
|
||||
address_detail: "",
|
||||
city_id: 0,
|
||||
company_id: 0,
|
||||
company_long_name: "",
|
||||
company_name: "",
|
||||
company_type: [
|
||||
0
|
||||
],
|
||||
director: "",
|
||||
district_id: 0,
|
||||
phone: "",
|
||||
province_id: 0,
|
||||
site:"",
|
||||
siteArray: []
|
||||
})
|
||||
const rules = {
|
||||
company_name: [{
|
||||
message: "请输入公司名称"
|
||||
}],
|
||||
company_long_name: [{
|
||||
message: "请输入公司全称"
|
||||
}],
|
||||
director: [{
|
||||
message: "请输入联系人"
|
||||
}],
|
||||
phone: [{
|
||||
message: "请输入正确的电话号码", regex: /^1[3|5|6|9|2|8|7]\d{9}$/
|
||||
}],
|
||||
district_id: [{
|
||||
message: "请选择地址"
|
||||
}],
|
||||
address_detail: [{
|
||||
message: "请输入详细地址"
|
||||
}],
|
||||
}
|
||||
const {fetchData: saveFetch} = companyUpdateApi();
|
||||
const handleSave = ()=>{
|
||||
const pages = getCurrentPages();
|
||||
const prevPage = pages[pages.length-2];
|
||||
Taro.eventCenter.trigger('message:detail', { text: 'test' })
|
||||
retrieval(formData, rules).then(async ()=>{
|
||||
const result = await saveFetch({
|
||||
address_detail: formData.address_detail,
|
||||
city_id: formData.city_id,
|
||||
company_id: formData.company_id,
|
||||
company_long_name: formData.company_long_name,
|
||||
company_name: formData.company_name,
|
||||
company_type: formData.company_type,
|
||||
director: formData.director,
|
||||
district_id: formData.district_id,
|
||||
phone: formData.phone,
|
||||
province_id: formData.province_id
|
||||
});
|
||||
if(result.success){
|
||||
Taro.eventCenter.trigger('company:detail')
|
||||
Taro.navigateBack();
|
||||
alert.success("保存成功");
|
||||
}else{
|
||||
alert.error(result.msg);
|
||||
}
|
||||
}).catch(message=>{
|
||||
alert.none(message)
|
||||
})
|
||||
|
||||
Taro.navigateBack();
|
||||
}
|
||||
@ -34,12 +98,34 @@ export default ()=>{
|
||||
const handleActiveRadio = (index:number)=>{
|
||||
setRadioActive(index);
|
||||
}
|
||||
// 设置选择地址
|
||||
const handleSetSite = (ev:any)=>{
|
||||
if(ev.length>=3){
|
||||
setFormData({
|
||||
...formData,
|
||||
siteArray: ev,
|
||||
site: ev.map(item=>item.name+" "),
|
||||
province_id: ev[0]?.id,
|
||||
city_id: ev[1]?.id,
|
||||
district_id: ev[ev.length-1]?.id,
|
||||
})
|
||||
}else{
|
||||
alert.error("请选择完整地址");
|
||||
}
|
||||
}
|
||||
// 监听表单完善
|
||||
const [hozon, setHozon] = useState(false);
|
||||
useEffect(()=>{
|
||||
if(retrieval){
|
||||
retrieval(formData).then(()=>setHozon(true)).catch(()=>setHozon(false))
|
||||
}
|
||||
},[formData])
|
||||
|
||||
return (
|
||||
<View className="company">
|
||||
<FromList value={formData["aa"]} label="公司名称" placeholder="请输入收货人姓名"/>
|
||||
<FromList value={formData["bb"]} label="公司全称" placeholder="请输入收货人姓名"/>
|
||||
<FromList value={formData["bb"]} label="公司类型" placeholder="请输入收货人姓名">
|
||||
<FromList onInput={(ev:any)=>setFormData({...formData,company_name:ev.detail.value})} value={formData["company_name"]} label="公司名称" placeholder="请输入公司名称"/>
|
||||
<FromList onInput={(ev:any)=>setFormData({...formData,company_long_name:ev.detail.value})} value={formData["company_long_name"]} label="公司全称" placeholder="请输入公司全称"/>
|
||||
<FromList value={formData["company_type"]} label="公司类型">
|
||||
<View className="form-radio">
|
||||
{
|
||||
radioData.map((item,index)=>{
|
||||
@ -48,14 +134,15 @@ export default ()=>{
|
||||
}
|
||||
</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="请输入详细地址(街道、门牌号等)"/>
|
||||
<FromList onInput={(ev:any)=>setFormData({...formData,director:ev.detail.value})} value={formData["director"]} label="联系人" placeholder="请输入联系人"/>
|
||||
<FromList onInput={(ev:any)=>setFormData({...formData,phone:ev.detail.value})} value={formData["phone"]} label="联系方式" placeholder="请输入联系方式"/>
|
||||
<FromList value={formData["site"]} onClick={handleSelectSite} label="收货地址" type="select" placeholder="请选择/省/市/区"/>
|
||||
<FromList onInput={(ev:any)=>setFormData({...formData,address_detail:ev.detail.value})} value={formData["address_detail"]} label="详细地址" type="textarea" placeholder="请输入详细地址(街道、门牌号等)"/>
|
||||
|
||||
|
||||
<Button hoverClass="none" className="save-button" onClick={handleSave}>保存</Button>
|
||||
<Address addressOnClose={()=>setShowSiteModal(false)} show={showSiteModal}/>
|
||||
<Button style={{"background": hozon?'#007aff':''}} hoverClass="none" className="save-button" onClick={handleSave}>保存</Button>
|
||||
{/* <Address addressOnClose={()=>setShowSiteModal(false)} show={showSiteModal}/> */}
|
||||
<Address addressOnSelect={handleSetSite} defaultValue={[ {name: "广东省", id: 193, level: 2}, {name: "佛山市", id: 202, level:3}, {name: "高明区", id: 204, level:4}]} addressOnClose={()=>setShowSiteModal(false)} show={showSiteModal}/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
@ -52,6 +52,19 @@
|
||||
font-size: 44px;
|
||||
font-weight: 700;
|
||||
color: #000000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.arcd-info-left-certification{
|
||||
width: 94px;
|
||||
height: 28px;
|
||||
background: #C7F0DF;
|
||||
border-radius: 4px;
|
||||
display: flex;align-items: center;justify-content: center;
|
||||
font-size: 18px;
|
||||
font-weight: 400;
|
||||
color: #07C160;
|
||||
margin-left: 16px;
|
||||
}
|
||||
.arcd-info-left-phone{
|
||||
font-size: 24px;
|
||||
@ -78,6 +91,9 @@
|
||||
right: 0;top: 0;
|
||||
}
|
||||
|
||||
.card-main{
|
||||
margin: 20px auto 0;
|
||||
}
|
||||
.card-main-title{
|
||||
display: flex;justify-content: space-between;
|
||||
align-items: center;
|
||||
@ -120,10 +136,45 @@
|
||||
display: flex;align-items: center;justify-content: center;
|
||||
position: absolute;top: -10px;right: 0;
|
||||
}
|
||||
|
||||
.assets{
|
||||
|
||||
}
|
||||
.assets-title{
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: #3c3c3c;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.assets-content{
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3,1fr);
|
||||
}
|
||||
.assets-content>view{
|
||||
text-align: center;
|
||||
}
|
||||
.assets-content-item-top{
|
||||
color: #007aff;
|
||||
font-weight: 400;
|
||||
}
|
||||
.assets-content-item-top-before{
|
||||
font-size: 20px;
|
||||
}
|
||||
.assets-content-item-top-content{
|
||||
font-size: 36px;
|
||||
}
|
||||
.assets-content-item-top-after{
|
||||
font-size: 20px;
|
||||
}
|
||||
.assets-content-item-tips{
|
||||
font-size: 24px;
|
||||
font-weight: 400;
|
||||
color: #707070;
|
||||
}
|
||||
|
||||
.main-card{
|
||||
margin: 131px auto 0;
|
||||
}
|
||||
|
||||
.card-main-list-content-item{
|
||||
display: flex;align-items: center;
|
||||
justify-content: space-between;
|
||||
|
@ -1,13 +1,16 @@
|
||||
import { View, Image, Text, Navigator } from "@tarojs/components"
|
||||
import { memo } from "react"
|
||||
import { memo, useEffect, useState } from "react"
|
||||
import styles from './index.module.scss'
|
||||
import classnames from "classnames";
|
||||
import { useSelector } from "@/reducers/hooks";
|
||||
import { GetAdminUserInfoApi } from "@/api/user";
|
||||
|
||||
export default () => {
|
||||
|
||||
return (
|
||||
<View className={styles.main}>
|
||||
<Header />
|
||||
<Assets />
|
||||
<Main />
|
||||
</View>
|
||||
)
|
||||
@ -17,7 +20,24 @@ export default () => {
|
||||
const Header = memo(() => {
|
||||
let menu = [{ text: "待配布", icon: "icon-daipeibu" }, { text: "待付款", icon: "icon-daifukuan" },
|
||||
{ text: "待发货", icon: "icon-daifahuo" }, { text: "已发货", icon: "icon-yifahuo" },
|
||||
{ text: "退款/售后", icon: "icon-a-tuikuanshouhou" }]
|
||||
{ text: "退款/售后", icon: "icon-a-tuikuanshouhou" }];
|
||||
// 用户信息
|
||||
const { fetchData, state } = GetAdminUserInfoApi();
|
||||
const {userInfo} = useSelector(state => state.userInfo);
|
||||
const [mUserInfo, setMUserInfo] = useState({
|
||||
phone: ""
|
||||
});
|
||||
const getData = ()=>{
|
||||
fetchData();
|
||||
}
|
||||
useEffect(()=>{
|
||||
setMUserInfo({
|
||||
...mUserInfo,
|
||||
phone: userInfo?.phone?.replace(userInfo?.phone?.substring(3,7), "****") as string
|
||||
})
|
||||
getData();
|
||||
},[])
|
||||
|
||||
return (
|
||||
<View className={styles.header}>
|
||||
<View className={`${styles.crad} ${styles['header-card']}`}>
|
||||
@ -27,8 +47,14 @@ const Header = memo(() => {
|
||||
<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 className={styles['arcd-info-left-desc']}>
|
||||
<View className={styles['arcd-info-left-nickname']}>麦兜</View>
|
||||
<View className={styles['arcd-info-left-phone']}>131****1132</View>
|
||||
<View className={styles['arcd-info-left-nickname']}>
|
||||
{/* {state.data.user_name} */}
|
||||
麦兜
|
||||
<View className={styles['arcd-info-left-certification']}>
|
||||
已认证
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles['arcd-info-left-phone']}>佛山市带生纺织品有限公司</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles['card-info-right']}>
|
||||
@ -54,7 +80,7 @@ const Header = memo(() => {
|
||||
<View className={styles['card-main-title-content-item']}>
|
||||
<Text className={`iconfont ${item.icon}`}></Text>
|
||||
<View>{item.text}</View>
|
||||
<View className={styles['card-main-title-content-item-badge']}>99+</View>
|
||||
<View className={styles['card-main-title-content-item-badge']}>{index==2?"99+":10}</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
@ -67,30 +93,62 @@ const Header = memo(() => {
|
||||
)
|
||||
})
|
||||
|
||||
// 我的资产
|
||||
const Assets = () => {
|
||||
return (
|
||||
<View className={`${styles.assets} ${styles.crad} ${styles['main-card']}`}>
|
||||
<View className={`${styles['assets-title']}`}>我的资产</View>
|
||||
<View className={`${styles['assets-content']}`}>
|
||||
<View>
|
||||
<View className={`${styles['assets-content-item-top']}`}>
|
||||
<Text className={`${styles['assets-content-item-top-before']}`}>¥</Text>
|
||||
<Text className={`${styles['assets-content-item-top-content']}`}>0</Text>
|
||||
<Text className={`${styles['assets-content-item-top-after']}`}>.20</Text>
|
||||
</View>
|
||||
<Text className={`${styles['assets-content-item-tips']}`}>预存款</Text>
|
||||
</View>
|
||||
<View>
|
||||
<View className={`${styles['assets-content-item-top']}`}>
|
||||
<Text className={`${styles['assets-content-item-top-content']}`}>4</Text>
|
||||
<Text className={`${styles['assets-content-item-top-after']}`}>张</Text>
|
||||
</View>
|
||||
<Text className={`${styles['assets-content-item-tips']}`}>优惠券</Text>
|
||||
</View>
|
||||
<View>
|
||||
<View className={`${styles['assets-content-item-top']}`}>
|
||||
<Text className={`${styles['assets-content-item-top-before']}`}>¥</Text>
|
||||
<Text className={`${styles['assets-content-item-top-content']}`}>99999</Text>
|
||||
<Text className={`${styles['assets-content-item-top-after']}`}>.-00</Text>
|
||||
</View>
|
||||
<Text className={`${styles['assets-content-item-tips']}`}>授信额度</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
};
|
||||
|
||||
// 功能
|
||||
const Main = memo(() => {
|
||||
let menu = [{ text: "我的收藏", icon: "icon-shoucang" }, { text: "颜色对比", icon: "icon-yanseduibi" },
|
||||
{ text: "分享推广", icon: "icon-fenxiang" }, { text: "团队邀请", icon: "icon-yaoqingtuandui" }]
|
||||
return (
|
||||
<View className={`${styles.crad} ${styles['main-card']}`}>
|
||||
<View className={styles['card-main']}>
|
||||
<View className={styles['card-main-list-content']}>
|
||||
{
|
||||
menu.map((item, index) => {
|
||||
return (
|
||||
<View key={index} className={styles['card-main-list-content-item']}>
|
||||
<View className={styles['card-main-list-content-item-left']}>
|
||||
<Text className={`iconfont ${item.icon}`}></Text>
|
||||
<View>{item.text}</View>
|
||||
</View>
|
||||
<View className={styles['card-main-list-content-item-right']}>
|
||||
<Text className="iconfont icon-a-moreback"></Text>
|
||||
</View>
|
||||
<View className={`${styles.crad} ${styles['card-main']}`}>
|
||||
<View className={styles['card-main-list-content']}>
|
||||
{
|
||||
menu.map((item, index) => {
|
||||
return (
|
||||
<View key={index} className={styles['card-main-list-content-item']}>
|
||||
<View className={styles['card-main-list-content-item-left']}>
|
||||
<Text className={`iconfont ${item.icon}`}></Text>
|
||||
<View>{item.text}</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
<View className={styles['card-main-list-content-item-right']}>
|
||||
<Text className="iconfont icon-a-moreback"></Text>
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
|
@ -119,10 +119,13 @@
|
||||
background-color: white;
|
||||
border: none;
|
||||
outline: none;
|
||||
border-radius: none;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
.user-edit-popup-operation button::after,.user-edit-logout::after{
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
}
|
||||
.user-edit-popup-operation .user-edit-popup-operation-save{
|
||||
background: #007aff;
|
||||
color: #ffffff;
|
||||
|
@ -1,28 +1,56 @@
|
||||
|
||||
import { goLink } from "@/common/common";
|
||||
import { alert, goLink, isEmptyObject, retrieval } 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 { GetAdminUserInfoApi, realNameUpdateApi } from "@/api/user";
|
||||
import { memo, useCallback, useEffect, useState } from "react"
|
||||
import "./index.scss"
|
||||
|
||||
export default ()=>{
|
||||
// 用户信息
|
||||
const { fetchData, state } = GetAdminUserInfoApi();
|
||||
const getData = async ()=>{
|
||||
const result = await fetchData();
|
||||
setFormData({
|
||||
...formData,
|
||||
real_name: result.data.user_name
|
||||
})
|
||||
}
|
||||
useEffect(()=>{
|
||||
getData();
|
||||
},[])
|
||||
// 表单数据
|
||||
const [formData, setFormData] = useState({
|
||||
nickname: "麦兜"
|
||||
real_name: "麦兜"
|
||||
});
|
||||
|
||||
// 显示popup
|
||||
const [popupShow,setPopupShow] = useState(false);
|
||||
const triggerList = useCallback((key:string)=>{
|
||||
setPopupShow(true);
|
||||
},[])
|
||||
|
||||
// popup保存
|
||||
const handleTextareaSave = ()=>{
|
||||
|
||||
const { fetchData: realNameUpdateFetch } = realNameUpdateApi();
|
||||
const rules = {
|
||||
real_name: [{
|
||||
message: "请输入昵称"
|
||||
}]
|
||||
}
|
||||
Taro.eventCenter.on('message:detail', (message) => console.log(message))
|
||||
const handleTextareaSave = async (real_name)=>{
|
||||
retrieval({real_name},rules).then(async ()=>{
|
||||
const result = await realNameUpdateFetch({real_name});
|
||||
if(result.success){
|
||||
getData();
|
||||
setPopupShow(false);
|
||||
alert.success("保存成功");
|
||||
}else{
|
||||
alert.none(result.msg);
|
||||
}
|
||||
}).catch(message=>{
|
||||
alert.none(message);
|
||||
})
|
||||
}
|
||||
// Taro.eventCenter.on('message:detail', (message) => console.log(message))
|
||||
// 面面跳转
|
||||
const onNavigate = (url:string)=>{
|
||||
goLink(url);
|
||||
@ -46,7 +74,7 @@ export default ()=>{
|
||||
<View>点击编辑头像</View>
|
||||
</View>
|
||||
<View className="user-edit-content">
|
||||
<UserEditList onClick={()=>triggerList('nickname')} data={formData} label="昵称" placeholder="请输入" icon=""/>
|
||||
<UserEditList onClick={()=>triggerList('real_name')} data={state.data.user_name} 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=""/>
|
||||
@ -55,7 +83,7 @@ export default ()=>{
|
||||
</View>
|
||||
<Button hoverClass="none" className="user-edit-logout">退出当前账号</Button>
|
||||
|
||||
<PopupContent value="123" show={popupShow} setPopupShow={setPopupShow} save={handleTextareaSave}/>
|
||||
<PopupContent value={formData.real_name} show={popupShow} setPopupShow={setPopupShow} save={handleTextareaSave}/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@ -69,8 +97,10 @@ const UserEditList = memo((props:any)=>{
|
||||
</View>
|
||||
<View className="user-edit-list-right">
|
||||
<View>
|
||||
<View className="user-edit-list-right-placeholder">{props.placeholder}</View>
|
||||
{/* 请输入 */}
|
||||
{
|
||||
props.data?props.data:
|
||||
<View className="user-edit-list-right-placeholder">{props.placeholder}</View>
|
||||
}
|
||||
</View>
|
||||
<Text className="iconfont icon-a-moreback"></Text>
|
||||
</View>
|
||||
@ -81,13 +111,16 @@ const UserEditList = memo((props:any)=>{
|
||||
// popup内容
|
||||
const PopupContent = memo((props:any)=>{
|
||||
const [value, setValue] = useState("");
|
||||
useEffect(()=>{
|
||||
setValue(props.value);
|
||||
},[props.value])
|
||||
// popup输入长度
|
||||
const handleTextareaInput = (ev:any)=>{
|
||||
setValue(ev.detail.value.slice(0,20));
|
||||
}
|
||||
// 重置
|
||||
const handleTextareaReset = ()=>{
|
||||
|
||||
setValue("");
|
||||
}
|
||||
return (
|
||||
<Popup onClose={()=>props.setPopupShow(false)} title="修改昵称" show={props.show}>
|
||||
@ -99,7 +132,7 @@ const PopupContent = memo((props:any)=>{
|
||||
<Text className="user-edit-popup-tips">请设置2-20个字符,由中文、英文、数字、-和_组成</Text>
|
||||
<View className="user-edit-popup-operation">
|
||||
<Button onClick={handleTextareaReset} hoverClass="none" className="user-edit-popup-operation-reset">重置</Button>
|
||||
<Button onClick={props.save} hoverClass="none" className="user-edit-popup-operation-save">保存</Button>
|
||||
<Button onClick={()=>props.save(value)} hoverClass="none" className="user-edit-popup-operation-save">保存</Button>
|
||||
</View>
|
||||
</View>
|
||||
</Popup>
|
||||
|
@ -21,7 +21,10 @@
|
||||
margin: 18px auto 0;
|
||||
border: 1px solid #ffffff;
|
||||
}
|
||||
.weight-list-list:hover{
|
||||
.weight-list-list:first-child{
|
||||
margin-top: 0;
|
||||
}
|
||||
.address-active{
|
||||
border: 1px solid #68b4ff;
|
||||
box-shadow: 0px 0px 10px 0px rgba(0,122,255,0.27);
|
||||
}
|
||||
|
@ -1,53 +1,84 @@
|
||||
|
||||
import { Button, Navigator, ScrollView, Text, View } from "@tarojs/components"
|
||||
import { memo, useState } from "react"
|
||||
import { memo, useEffect, useState } from "react"
|
||||
import {weightListApi,weightDeleteApi} from "@/api/weightList"
|
||||
import "./index.scss"
|
||||
|
||||
import Taro, { showModal } from "@tarojs/taro"
|
||||
import { alert } from "@/common/common"
|
||||
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 WeightList = (props:Params)=>{
|
||||
const {fetchData, state} = weightListApi();
|
||||
const getData = ()=>{
|
||||
fetchData();
|
||||
}
|
||||
useEffect(()=>{
|
||||
Taro.eventCenter.on("weightList:refresh", getData);
|
||||
getData();
|
||||
return ()=>{
|
||||
Taro.eventCenter.off("weightList:refresh", 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:0});
|
||||
// 删除码单
|
||||
const {fetchData: deleteFetch} = weightDeleteApi()
|
||||
const handleDelete = (item:any)=>{
|
||||
showModal(({
|
||||
title: "提示",
|
||||
content: "是否删除码单?",
|
||||
async success(ev){
|
||||
if(ev.confirm){
|
||||
const result = await deleteFetch({id:item.id});
|
||||
if(result.success){
|
||||
alert.success("删除成功");
|
||||
getData();
|
||||
}else{
|
||||
alert.success(result.msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="weight-list-scroll-view">
|
||||
<ScrollView scrollY refresherEnabled={props.refresherEnabled} enhanced refresherTriggered={refreshState} onRefresherRefresh={handleRefresh}>
|
||||
<ScrollView scrollY refresherEnabled enhanced refresherTriggered={refreshState} onRefresherRefresh={handleRefresh}>
|
||||
{
|
||||
data.length>0?
|
||||
data.map((item,index)=>{
|
||||
// data.length>0?
|
||||
state?.data?.list?.length>0?
|
||||
state?.data?.list?.map((item,index)=>{
|
||||
return(
|
||||
<View onClick={()=>props.onSelect&&props.onSelect(item,index)} className="weight-list-list">
|
||||
<View onClick={()=>props.onSelect&&props.onSelect(item,index)} onLongPress={()=>handleDelete(item)} className={`weight-list-list ${item.is_default&&'address-active'}`}>
|
||||
<View className="weight-list-user">
|
||||
XL纺织
|
||||
<Text className="weight-list-list-default">默认</Text>
|
||||
{/* <Text className="weight-list-list-phone">1656488999</Text> */}
|
||||
{item.title}
|
||||
{
|
||||
item.is_default&&<Text className="weight-list-list-default">默认</Text>
|
||||
}
|
||||
</View>
|
||||
<View className="weight-list-list-bottom">
|
||||
<View className="weight-list-list-info">
|
||||
**省**市**区**街道****仓库
|
||||
<Text className="weight-list-list-phone">181****9790</Text>
|
||||
{item.purchaser_name}
|
||||
<Text className="weight-list-list-phone">{item.phone.replace(item.phone.substring(3,7), "****")}</Text>
|
||||
</View>
|
||||
<Navigator url="/pages/weightListAdd/index?type=edit" hoverClass="none" className="weight-list-edit">
|
||||
<Navigator url={`/pages/weightListAdd/index?type=edit&id=${item.id}`} hoverClass="none" className="weight-list-edit">
|
||||
<Text className="iconfont icon-bianji"></Text>
|
||||
</Navigator>
|
||||
</View>
|
||||
@ -63,6 +94,6 @@ const WeightList = memo((props:Params)=>{
|
||||
<Navigator url="/pages/weightListAdd/index?type=add" hoverClass="none" className="add-weight-list">添加新码单信息</Navigator>
|
||||
</View>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export default weightListManager;
|
@ -2,48 +2,103 @@
|
||||
import FromList from "@/components/FromList"
|
||||
import { Button, Input, Text, Textarea, View } from "@tarojs/components"
|
||||
import Taro, { setNavigationBarTitle, useRouter } from "@tarojs/taro"
|
||||
import {weightAddApi, weightDetailApi,weightEditApi} from "@/api/weightList"
|
||||
import { useEffect, useState } from "react"
|
||||
import { alert, retrieval } from "@/common/common"
|
||||
import "./index.scss"
|
||||
|
||||
export default ()=>{
|
||||
const {type} = useRouter().params;
|
||||
const {type,id} = useRouter().params;
|
||||
useEffect(()=>{
|
||||
if(type=="add"){
|
||||
setNavigationBarTitle({title:"添加码单信息"})
|
||||
}else{
|
||||
initalFormData();
|
||||
setNavigationBarTitle({title:"修改码单信息"})
|
||||
}
|
||||
},[])
|
||||
|
||||
},[]);
|
||||
// 获取编辑码单信息
|
||||
const {fetchData: getFromData} = weightDetailApi()
|
||||
const initalFormData = async ()=>{
|
||||
const detail = await getFromData({id});
|
||||
setFormData({
|
||||
title: detail.data.title,
|
||||
purchaser_name: detail.data.purchaser_name,
|
||||
phone: detail.data.phone,
|
||||
is_default: detail.data.is_default,
|
||||
id: detail.data.id,
|
||||
})
|
||||
}
|
||||
// 保存
|
||||
const [formData, setFormData] = useState({
|
||||
aa: "",
|
||||
bb:"",
|
||||
cc:"",
|
||||
dd:"",
|
||||
ee: 1
|
||||
title: "",
|
||||
purchaser_name: "",
|
||||
phone: "",
|
||||
is_default: false,
|
||||
id: 0
|
||||
})
|
||||
const handleSave = ()=>{
|
||||
Taro.navigateBack();
|
||||
const rules = {
|
||||
title: [{
|
||||
message: "请输入抬头"
|
||||
}],
|
||||
purchaser_name: [{
|
||||
message: "请输入客户名称"
|
||||
}],
|
||||
phone: [{
|
||||
message: "请输入正确的电话号码", regex: /^1[3|5|6|9|2|8|7]\d{9}$/
|
||||
}]
|
||||
}
|
||||
const handleSelectDefault = ()=>setFormData({...formData ,ee: formData.ee?0:1});
|
||||
const {fetchData} = weightAddApi()
|
||||
const {fetchData: editFetch} = weightEditApi()
|
||||
const handleSave = ()=>{
|
||||
retrieval(formData, rules).then(async ()=>{
|
||||
const result = type=="add"?await fetchData({
|
||||
title: formData.title,
|
||||
purchaser_name: formData.purchaser_name,
|
||||
phone: formData.phone,
|
||||
is_default: formData.is_default,
|
||||
}):await editFetch({
|
||||
title: formData.title,
|
||||
purchaser_name: formData.purchaser_name,
|
||||
phone: formData.phone,
|
||||
is_default: formData.is_default,
|
||||
id: formData.id
|
||||
});
|
||||
if(result.success){
|
||||
Taro.eventCenter.trigger("weightList:refresh");
|
||||
Taro.navigateBack();
|
||||
alert.success("保存成功");
|
||||
}else{
|
||||
alert.error(result.msg);
|
||||
}
|
||||
}).catch((message)=>{
|
||||
alert.none(message)
|
||||
})
|
||||
}
|
||||
// 监听表单完善
|
||||
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["bb"]} label="联系方式" placeholder="请输入码单显示联系号码"/>
|
||||
<FromList onInput={(ev:any)=>setFormData({...formData,title:ev.detail.value})} value={formData["title"]} label="抬头" placeholder="请输入码单显示抬头信息"/>
|
||||
<FromList onInput={(ev:any)=>setFormData({...formData,purchaser_name:ev.detail.value})} value={formData["purchaser_name"]} label="客户" placeholder="请输入码单显示客户名称"/>
|
||||
<FromList onInput={(ev:any)=>setFormData({...formData,phone:ev.detail.value})} value={formData["phone"]} label="联系方式" placeholder="请输入码单显示联系号码"/>
|
||||
<View className="add-address-default">
|
||||
<Text>设为默认地址</Text>
|
||||
<View onClick={handleSelectDefault}>
|
||||
<View onClick={()=>setFormData({...formData ,is_default: !formData.is_default})}>
|
||||
{
|
||||
formData.ee?<View className="add-address-default-active"><Text className="iconfont icon-a-tick1"/></View>
|
||||
formData.is_default?<View className="add-address-default-active"><Text className="iconfont icon-tick"/></View>
|
||||
:<View className="add-address-default-noactive"></View>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<Button hoverClass="none" className="add-address-save" onClick={handleSave}>保存</Button>
|
||||
<Button style={{"background": hozon?'#007aff':''}} hoverClass="none" className="add-address-save" onClick={handleSave}>保存</Button>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user