1
This commit is contained in:
parent
d0f069937b
commit
8c3e4e9bc1
12
src/api/addressList.ts
Normal file
12
src/api/addressList.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
import { useRequest } from "@/use/useHttp"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取行政地区列表
|
||||||
|
*/
|
||||||
|
export const GetAddressListApi = () => {
|
||||||
|
return useRequest({
|
||||||
|
url: `/v1/mall/district/list`,
|
||||||
|
method: "get",
|
||||||
|
})
|
||||||
|
}
|
11
src/api/order.ts
Normal file
11
src/api/order.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { useRequest } from "@/use/useHttp"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下单现货销售单
|
||||||
|
*/
|
||||||
|
export const SaleOrderApi = () => {
|
||||||
|
return useRequest({
|
||||||
|
url: `/v1/mall/saleOrder`,
|
||||||
|
method: "post",
|
||||||
|
})
|
||||||
|
}
|
@ -4,6 +4,8 @@ import Drawer from "@/components/popup";
|
|||||||
import styles from "./index.module.scss"
|
import styles from "./index.module.scss"
|
||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
|
import { GetAddressListApi } from "@/api/addressList";
|
||||||
|
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
addressOnSelect?: ({}:{name: string, id:string|number}) => void,
|
addressOnSelect?: ({}:{name: string, id:string|number}) => void,
|
||||||
@ -15,90 +17,47 @@ export default memo(({
|
|||||||
addressOnSelect,
|
addressOnSelect,
|
||||||
addressOnClose,
|
addressOnClose,
|
||||||
show = false
|
show = false
|
||||||
|
|
||||||
}: Params) => {
|
}: Params) => {
|
||||||
const list1 = [
|
|
||||||
{
|
|
||||||
name:'广东1',
|
|
||||||
id:1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'广东2',
|
|
||||||
id:2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'广东3',
|
|
||||||
id:3
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'广东4',
|
|
||||||
id:4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'广东5',
|
|
||||||
id:5
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'广东6',
|
|
||||||
id:6
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
const list2 = [
|
//获取地址
|
||||||
{
|
const {fetchData} = GetAddressListApi()
|
||||||
name:'佛山1佛山1佛山1佛山1佛山1',
|
useEffect(() => {
|
||||||
id:7
|
getAddressList()
|
||||||
},
|
setList(provinceList)
|
||||||
{
|
}, [])
|
||||||
name:'佛山2',
|
|
||||||
id:8
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'佛山3',
|
|
||||||
id:9
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'佛山4',
|
|
||||||
id:10
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'佛山5',
|
|
||||||
id:11
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'佛山6',
|
|
||||||
id:12
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
const list3 = [
|
const condition = useRef({parent_id:1})
|
||||||
{
|
const getAddressList = async () => {
|
||||||
name:'禅城区1',
|
let res = await fetchData(condition.current)
|
||||||
id:13
|
const lists = res.data.list||[]
|
||||||
},
|
if(selectIndex == 0) {
|
||||||
{
|
setProvinceList(lists)
|
||||||
name:'禅城区2',
|
} else if(selectIndex == 1) {
|
||||||
id:14
|
setCityList(lists)
|
||||||
},
|
} else {
|
||||||
{
|
setAreaList(lists)
|
||||||
name:'禅城区3',
|
|
||||||
id:15
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'禅城区4',
|
|
||||||
id:16
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'禅城区5',
|
|
||||||
id:17
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'禅城区6',
|
|
||||||
id:18
|
|
||||||
}
|
}
|
||||||
]
|
setList(lists)
|
||||||
|
}
|
||||||
|
|
||||||
const [list, setList] = useState(list1)
|
|
||||||
|
type AddresParam = {
|
||||||
|
ad_code?: string,
|
||||||
|
id?: number,
|
||||||
|
level?: number,
|
||||||
|
level_name?: string,
|
||||||
|
name?: string,
|
||||||
|
parent_id?: number
|
||||||
|
}
|
||||||
|
//省
|
||||||
|
const [provinceList, setProvinceList] = useState<AddresParam[]>([])
|
||||||
|
//市
|
||||||
|
const [cityList, setCityList] = useState<AddresParam[]>([])
|
||||||
|
//区
|
||||||
|
const [areaList, setAreaList] = useState<AddresParam[]>([])
|
||||||
|
|
||||||
|
|
||||||
|
const [list, setList] = useState<AddresParam[]>([])
|
||||||
const [selectIndex, setSelectIndex] = useState(0) //0 省, 1 市,2 区
|
const [selectIndex, setSelectIndex] = useState(0) //0 省, 1 市,2 区
|
||||||
const [selectId, setSelectId] = useState(0) //选中的id
|
const [selectId, setSelectId] = useState(0) //选中的id
|
||||||
const [selectArr, setSelectArr] = useState<any>([]) //选中的省市区
|
const [selectArr, setSelectArr] = useState<any>([]) //选中的省市区
|
||||||
@ -132,8 +91,7 @@ export default memo(({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(selectIndex == 0) {
|
if(selectIndex == 0) {
|
||||||
setList(list1)
|
setList(provinceList)
|
||||||
// getDomDes('#address_tab_0')
|
|
||||||
} else if (selectIndex == 1) {
|
} else if (selectIndex == 1) {
|
||||||
getCity()
|
getCity()
|
||||||
} else {
|
} else {
|
||||||
@ -142,27 +100,22 @@ export default memo(({
|
|||||||
}, [selectIndex])
|
}, [selectIndex])
|
||||||
|
|
||||||
//获取市
|
//获取市
|
||||||
const getCity = () => {
|
const getCity = async () => {
|
||||||
|
await getAddressList()
|
||||||
setTimeout(() => {
|
if(cityList.length > 0) {
|
||||||
if(list2.length > 0) {
|
setSelectIndex(1)
|
||||||
setSelectIndex(1)
|
setCityStatus(true)
|
||||||
setList(() => { return list2 })
|
getDomDes('#address_tab_1')
|
||||||
setCityStatus(true)
|
} else {
|
||||||
getDomDes('#address_tab_1')
|
setCityStatus(false)
|
||||||
} else {
|
}
|
||||||
setCityStatus(false)
|
|
||||||
}
|
|
||||||
},10)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取区
|
//获取区
|
||||||
const area = () => {
|
const area = () => {
|
||||||
// setAreaStatus(false)
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if(list3.length > 0) {
|
if(areaList.length > 0) {
|
||||||
setSelectIndex(2)
|
setSelectIndex(2)
|
||||||
setList(() => { return list3 })
|
|
||||||
setAreaStatus(true)
|
setAreaStatus(true)
|
||||||
getDomDes('#address_tab_2')
|
getDomDes('#address_tab_2')
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {Image, ScrollView, View, Text } from "@tarojs/components"
|
import {Image, ScrollView, View, Text, CustomWrapper } from "@tarojs/components"
|
||||||
import Popup from "@/components/popup"
|
import Popup from "@/components/popup"
|
||||||
import LoadingCard from "@/components/loadingCard";
|
import LoadingCard from "@/components/loadingCard";
|
||||||
import Search from "@/components/search";
|
import Search from "@/components/search";
|
||||||
@ -27,20 +27,24 @@ type param = {
|
|||||||
export default memo(({show = false, onClose, title = '', productId = 0}: param) => {
|
export default memo(({show = false, onClose, title = '', productId = 0}: param) => {
|
||||||
const {adminUserInfo} = useSelector(state => state.userInfo)
|
const {adminUserInfo} = useSelector(state => state.userInfo)
|
||||||
|
|
||||||
const selectList = [
|
const [selectList, setSelectList] = useState([
|
||||||
{id: 0, step:1, digits:0, maxNum:100000, defaultNum:1, title:'大货', unit:'件', eunit:'kg'},
|
{id: 0, step:1, digits:0, maxNum:100000, defaultNum:1, title:'大货', unit:'件', eunit:'kg', priceField:'bulk_price'},
|
||||||
{id: 1, step:1, digits:2, maxNum:9.99, defaultNum:1, title:'剪板', unit:'米', eunit:'m'},
|
{id: 1, step:1, digits:2, maxNum:9.99, defaultNum:1, title:'剪板', unit:'米', eunit:'m', priceField:'length_cut_price'},
|
||||||
{id: 2, step:1, digits:2, minNum:10, maxNum:100000, defaultNum:10, title:'散剪', unit:'米', eunit:'kg'},
|
{id: 2, step:1, digits:2, minNum:10, maxNum:100000, defaultNum:10, title:'散剪', unit:'米', eunit:'kg', priceField:'weight_cut_price'},
|
||||||
]
|
])
|
||||||
const [selectIndex, setSelectIndex] = useState(0)
|
const [selectIndex, setSelectIndex] = useState(0)
|
||||||
const selectProduct = (index:number) => {
|
const selectProduct = (index:number) => {
|
||||||
setSelectIndex(() => index)
|
setSelectIndex(() => index)
|
||||||
//重置数据
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//重置数据
|
||||||
|
useEffect(() => {
|
||||||
const newList = initList(list)
|
const newList = initList(list)
|
||||||
setList([...newList])
|
setList([...newList])
|
||||||
condition.current.code_or_name = null
|
condition.current.code_or_name = null
|
||||||
setSearchShow(false)
|
setSearchShow(false)
|
||||||
}
|
}, [selectIndex])
|
||||||
|
|
||||||
//获取面料颜色列表
|
//获取面料颜色列表
|
||||||
const {fetchData:colorFetchData, state: colorState} = GetColorList()
|
const {fetchData:colorFetchData, state: colorState} = GetColorList()
|
||||||
@ -176,19 +180,6 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//显示金额
|
|
||||||
const priceFormat = (item) => {
|
|
||||||
let price = 0
|
|
||||||
if(selectIndex == 0) {
|
|
||||||
price = formatMillionYuan(item.bulk_price, 100).num
|
|
||||||
} else if(selectIndex == 1) {
|
|
||||||
price = formatMillionYuan(item.length_cut_price, 100).num
|
|
||||||
} else {
|
|
||||||
price = formatMillionYuan(item.weight_cut_price, 100).num
|
|
||||||
}
|
|
||||||
return <View className={styles.priceText}><Text>¥</Text>{Number(price) }<Text>{' /' + selectList[selectIndex].eunit}</Text></View>
|
|
||||||
}
|
|
||||||
|
|
||||||
//筛选数据
|
//筛选数据
|
||||||
const searchInput = (e) => {
|
const searchInput = (e) => {
|
||||||
condition.current.code_or_name = e
|
condition.current.code_or_name = e
|
||||||
@ -202,6 +193,13 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
|||||||
setSearchShow(false)
|
setSearchShow(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//格式化金额
|
||||||
|
const formatPrice = useCallback((item) => {
|
||||||
|
const price = Number(formatMillionYuan(item[selectList[selectIndex].priceField], 100).num)
|
||||||
|
return <View className={styles.priceText}><Text>¥</Text>{price}<Text> /{selectList[selectIndex].eunit}</Text></View>
|
||||||
|
}, [selectIndex])
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className={styles.shop_cart_main}>
|
<View className={styles.shop_cart_main}>
|
||||||
|
|
||||||
@ -229,35 +227,39 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
|||||||
|
|
||||||
<View className={styles.product_color_con}>
|
<View className={styles.product_color_con}>
|
||||||
{(list.length <= 0 && colorState.loading)&&<LoadingCard/>}
|
{(list.length <= 0 && colorState.loading)&&<LoadingCard/>}
|
||||||
{(list.length > 0&& !colorState.loading)&&<InfiniteScroll moreStatus={false}>
|
{(list.length > 0&& !colorState.loading)&&
|
||||||
<View className={styles.color_con}>
|
|
||||||
{list.map(item => {
|
<InfiniteScroll moreStatus={false}>
|
||||||
return <View className={styles.item}>
|
<View className={styles.color_con}>
|
||||||
<View className={styles.item_color}>
|
{list.map(item => {
|
||||||
<Image src={item.texture_url}/>
|
return <View className={styles.item} key={item.id}>
|
||||||
|
<View className={styles.item_color}>
|
||||||
|
<Image src={item.texture_url}/>
|
||||||
|
</View>
|
||||||
|
<View className={styles.item_con}>
|
||||||
|
<View className={styles.title}>{formatHashTag(item.code, item.name)}</View>
|
||||||
|
<View className={styles.num}>
|
||||||
|
{formatPrice(item)}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<View className={styles.btn_con}>
|
||||||
|
{!item.show&&<View className={styles.btn} onClick={() => onAdd(item)}>添加</View>
|
||||||
|
||<View className={styles.btn_count}>
|
||||||
|
<Counter
|
||||||
|
onBlue={(e) => getInputValue(e, item)}
|
||||||
|
defaultNum={item.count}
|
||||||
|
step={selectList[selectIndex].step}
|
||||||
|
digits={selectList[selectIndex].digits}
|
||||||
|
onClickBtn={(e) => getInputValue(e, item)}
|
||||||
|
unit={selectList[selectIndex].unit}
|
||||||
|
minNum={selectList[selectIndex].minNum}
|
||||||
|
maxNum={selectList[selectIndex].maxNum}
|
||||||
|
/>
|
||||||
|
</View>}
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.item_con}>
|
})}
|
||||||
<View className={styles.title}>{formatHashTag(item.code, item.name)}</View>
|
</View>
|
||||||
<View className={styles.num}>{priceFormat(item)}</View>
|
|
||||||
</View>
|
|
||||||
<View className={styles.btn_con}>
|
|
||||||
{!item.show&&<View className={styles.btn} onClick={() => onAdd(item)}>添加</View>
|
|
||||||
||<View className={styles.btn_count}>
|
|
||||||
<Counter
|
|
||||||
onBlue={(e) => getInputValue(e, item)}
|
|
||||||
defaultNum={item.count}
|
|
||||||
step={selectList[selectIndex].step}
|
|
||||||
digits={selectList[selectIndex].digits}
|
|
||||||
onClickBtn={(e) => getInputValue(e, item)}
|
|
||||||
unit={selectList[selectIndex].unit}
|
|
||||||
minNum={selectList[selectIndex].minNum}
|
|
||||||
maxNum={selectList[selectIndex].maxNum}
|
|
||||||
/>
|
|
||||||
</View>}
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
})}
|
|
||||||
</View>
|
|
||||||
</InfiniteScroll>}
|
</InfiniteScroll>}
|
||||||
{(list.length <= 0 && !colorState.loading)&&<View className={styles.noData}>暂无此商品</View>}
|
{(list.length <= 0 && !colorState.loading)&&<View className={styles.noData}>暂无此商品</View>}
|
||||||
</View>
|
</View>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
import { Button, Image, RichText, ScrollView, Swiper, SwiperItem, Text, View } from '@tarojs/components'
|
import { Button, CustomWrapper, Image, RichText, ScrollView, Swiper, SwiperItem, Text, View } from '@tarojs/components'
|
||||||
import Taro, { useDidShow, usePullDownRefresh, useRouter, useShareAppMessage } from '@tarojs/taro';
|
import Taro, { useDidShow, usePullDownRefresh, useRouter, useShareAppMessage } from '@tarojs/taro';
|
||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
import DesSwiper from './components/swiper';
|
import DesSwiper from './components/swiper';
|
||||||
@ -170,7 +170,9 @@ export default (props:params) => {
|
|||||||
|| <View className={styles.buy_btn} onClick={(e) => placeOrder(e)}>开始下单</View>
|
|| <View className={styles.buy_btn} onClick={(e) => placeOrder(e)}>开始下单</View>
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
<OrderCount show={showOrderCount} onClose={() => setShowOrderCount(false)} title={productName} productId={productInfo.id}/>
|
<CustomWrapper>
|
||||||
|
<OrderCount show={showOrderCount} onClose={() => setShowOrderCount(false)} title={productName} productId={productInfo.id}/>
|
||||||
|
</CustomWrapper>
|
||||||
<ShopCart show={showCart} onClose={() => setShowCart(false)}/>
|
<ShopCart show={showCart} onClose={() => setShowCart(false)}/>
|
||||||
<Preview value={colorInfo} show={showPreview} onClose={() => setShowPreview(false)}/>
|
<Preview value={colorInfo} show={showPreview} onClose={() => setShowPreview(false)}/>
|
||||||
<View className='common_safe_area_y'></View>
|
<View className='common_safe_area_y'></View>
|
||||||
|
@ -99,7 +99,7 @@ export default () => {
|
|||||||
const {fetchData: fetchDataUserInfo} = GetWxUserInfoApi()
|
const {fetchData: fetchDataUserInfo} = GetWxUserInfoApi()
|
||||||
const getSelfUserInfo = async () => {
|
const getSelfUserInfo = async () => {
|
||||||
return new Promise((reslove, reject) => {
|
return new Promise((reslove, reject) => {
|
||||||
if(userInfo.adminUserInfo.is_authorize_name) {
|
if(userInfo.adminUserInfo?.is_authorize_name) {
|
||||||
reslove(true)
|
reslove(true)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ export default () => {
|
|||||||
const {fetchData: fetchDataUserPhone} = GetPhoneNumberApi()
|
const {fetchData: fetchDataUserPhone} = GetPhoneNumberApi()
|
||||||
const getPhoneNumber = (code) =>{
|
const getPhoneNumber = (code) =>{
|
||||||
return new Promise( async (reslove, reject) => {
|
return new Promise( async (reslove, reject) => {
|
||||||
if(userInfo.adminUserInfo.is_authorize_phone) {
|
if(userInfo.adminUserInfo?.is_authorize_phone) {
|
||||||
reslove(true)
|
reslove(true)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user