feat:销售码单跳转支付

This commit is contained in:
Haiyi 2022-10-19 17:37:24 +08:00
parent 4b75ef1493
commit 42c5bb0952
7 changed files with 76 additions and 61 deletions

View File

@ -37,3 +37,5 @@ export const WX_APPID = 'wx64fe67f111d52457'
export const SCENE = { export const SCENE = {
SearchScene: 0, //商城面料搜索 SearchScene: 0, //商城面料搜索
} }
//支付码单跳转链接
export const PAY_H5_CODE_URL = CURRENT_ENV.includes('production') ? 'https://www.zzfzyc.com/cashier' : 'https://test.zzfzyc.com/cashier'

View File

@ -6,17 +6,17 @@ import classnames from "classnames";
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
import { GetAddressListApi } from "@/api/addressList"; import { GetAddressListApi } from "@/api/addressList";
import { alert } from "@/common/common"; import { alert } from "@/common/common";
import IconFont from "../iconfont/iconfont";
type DefaultValueParm = { name: string, id: string | number, level?: number | string }
type DefaultValueParm = {name: string, id:string|number, level?: number|string}
type Params = { type Params = {
addressOnSelect?: (val:DefaultValueParm[]) => void, addressOnSelect?: (val: DefaultValueParm[]) => void,
addressOnChange?: (val:DefaultValueParm[]) => void, addressOnChange?: (val: DefaultValueParm[]) => void,
addressOnClose?: () => void, addressOnClose?: () => void,
show?: true|false, show?: true | false,
defaultValue?:DefaultValueParm[] defaultValue?: DefaultValueParm[]
selectStatus?: false|true, //false不需要选择完整地址true需要选择完整地址 selectStatus?: false | true, //false不需要选择完整地址true需要选择完整地址
} }
type AddresParam = { type AddresParam = {
@ -53,20 +53,20 @@ export default memo(({
const [areaStatus, setAreaStatus] = useState(false) //区镇是否存在 const [areaStatus, setAreaStatus] = useState(false) //区镇是否存在
const [confirmBtnStatus, setConfirmBtnStatus] = useState(false) //确认按钮是否可用 const [confirmBtnStatus, setConfirmBtnStatus] = useState(false) //确认按钮是否可用
const [bottomStyle, setBottomStyle] = useState({width:'100rpx',left:'0rpx'}) //底部滚动条样式 const [bottomStyle, setBottomStyle] = useState({ width: '100rpx', left: '0rpx' }) //底部滚动条样式
useEffect(() => { useEffect(() => {
if(selectArr.length == 0) { if (selectArr.length == 0) {
setSelectArr(defaultValue) setSelectArr(defaultValue)
if(defaultValue.length > 1) setCityStatus(true) if (defaultValue.length > 1) setCityStatus(true)
if(defaultValue.length > 2) setAreaStatus(true) if (defaultValue.length > 2) setAreaStatus(true)
if(defaultValue.length > 0) setConfirmBtnStatus(true) if (defaultValue.length > 0) setConfirmBtnStatus(true)
} }
}, [defaultValue]) }, [defaultValue])
//获取地址 //获取地址
const {fetchData} = GetAddressListApi() const { fetchData } = GetAddressListApi()
useEffect(() => { useEffect(() => {
getProvince() getProvince()
}, []) }, [])
@ -74,16 +74,16 @@ export default memo(({
//选中内容 //选中内容
const selectItem = (item) => { const selectItem = (item) => {
setSelectId(item.id) setSelectId(item.id)
if(selectIndex == 0) { if (selectIndex == 0) {
setSelectArr([{name:item.name, id:item.id, level:item.level}]) setSelectArr([{ name: item.name, id: item.id, level: item.level }])
getCity(item.id) getCity(item.id)
setAreaStatus(false) setAreaStatus(false)
setCityStatus(false) setCityStatus(false)
} else if(selectIndex == 1){ } else if (selectIndex == 1) {
setSelectArr([selectArr[0], {name:item.name, id:item.id, level:item.level}]) setSelectArr([selectArr[0], { name: item.name, id: item.id, level: item.level }])
area(item.id) area(item.id)
} else { } else {
setSelectArr([selectArr[0], selectArr[1], {name:item.name, id:item.id, level:item.level}]) setSelectArr([selectArr[0], selectArr[1], { name: item.name, id: item.id, level: item.level }])
getDomDes('#address_tab_2') getDomDes('#address_tab_2')
} }
@ -91,16 +91,16 @@ export default memo(({
//地址数据 //地址数据
useEffect(() => { useEffect(() => {
if(selectArr && selectArr.length > 0) if (selectArr && selectArr.length > 0)
addressOnChange?.(selectArr) addressOnChange?.(selectArr)
}, [selectArr]) }, [selectArr])
//选中标题 //选中标题
const onSelectIndex = (index) => { const onSelectIndex = (index) => {
setSelectIndex(index) setSelectIndex(index)
const selectid = selectArr[index]?selectArr[index].id:0 const selectid = selectArr[index] ? selectArr[index].id : 0
setSelectId(selectid as number) setSelectId(selectid as number)
if(index == 0) { if (index == 0) {
getProvince() getProvince()
} else if (index == 1) { } else if (index == 1) {
const id = selectArr[0]?.id const id = selectArr[0]?.id
@ -114,9 +114,9 @@ export default memo(({
//获取省 //获取省
const getProvince = async () => { const getProvince = async () => {
let res = await fetchData({parent_id: 1}) let res = await fetchData({ parent_id: 1 })
provinceList.current = res.data.list||[] provinceList.current = res.data.list || []
if(provinceList.current.length > 0) { if (provinceList.current.length > 0) {
setSelectIndex(0) setSelectIndex(0)
setList(() => provinceList.current) setList(() => provinceList.current)
getDomDes('#address_tab_0') getDomDes('#address_tab_0')
@ -125,9 +125,9 @@ export default memo(({
//获取市 //获取市
const getCity = async (id) => { const getCity = async (id) => {
let res = await fetchData({parent_id: id}) let res = await fetchData({ parent_id: id })
cityList.current = res.data.list||[] cityList.current = res.data.list || []
if(cityList.current.length > 0) { if (cityList.current.length > 0) {
setSelectIndex(1) setSelectIndex(1)
setList(() => cityList.current) setList(() => cityList.current)
setCityStatus(true) setCityStatus(true)
@ -141,9 +141,9 @@ export default memo(({
//获取区 //获取区
const area = async (id) => { const area = async (id) => {
let res = await fetchData({parent_id: id}) let res = await fetchData({ parent_id: id })
areaList.current = res.data.list||[] areaList.current = res.data.list || []
if(areaList.current.length > 0) { if (areaList.current.length > 0) {
setSelectIndex(2) setSelectIndex(2)
setList(() => areaList.current) setList(() => areaList.current)
setAreaStatus(true) setAreaStatus(true)
@ -165,7 +165,7 @@ export default memo(({
const getDomDes = (id) => { const getDomDes = (id) => {
setTimeout(() => { setTimeout(() => {
let query = Taro.createSelectorQuery(); let query = Taro.createSelectorQuery();
query.select(id).boundingClientRect(rect=>{ query.select(id).boundingClientRect(rect => {
let left = rect.left; let left = rect.left;
let clientWidth = rect.width; let clientWidth = rect.width;
console.log(clientWidth) console.log(clientWidth)
@ -180,7 +180,7 @@ export default memo(({
//点击标题栏 //点击标题栏
const selectTab = (index) => { const selectTab = (index) => {
onSelectIndex(index) onSelectIndex(index)
getDomDes('#address_tab_'+index) getDomDes('#address_tab_' + index)
} }
return ( return (
@ -192,9 +192,9 @@ export default memo(({
<View onClick={() => submitSelect()}></View> <View onClick={() => submitSelect()}></View>
</View> </View>
<View className={styles.address_select}> <View className={styles.address_select}>
<View id="address_tab_0" onClick={() => selectTab(0)} className={classnames(styles.address_item, {[styles.addresst_select]:(selectIndex == 0)})}>{selectArr[0]?selectArr[0].name:'请选择'}</View> <View id="address_tab_0" onClick={() => selectTab(0)} className={classnames(styles.address_item, { [styles.addresst_select]: (selectIndex == 0) })}>{selectArr[0] ? selectArr[0].name : '请选择'}</View>
{cityStatus&&<View id="address_tab_1" onClick={() => selectTab(1)} className={classnames(styles.address_item, {[styles.addresst_select]:(selectIndex == 1)})}>{selectArr[1]?selectArr[1].name:'请选择'}</View>} {cityStatus && <View id="address_tab_1" onClick={() => selectTab(1)} className={classnames(styles.address_item, { [styles.addresst_select]: (selectIndex == 1) })}>{selectArr[1] ? selectArr[1].name : '请选择'}</View>}
{areaStatus&&<View id="address_tab_2" onClick={() => selectTab(2)} className={classnames(styles.address_item, {[styles.addresst_select]:(selectIndex == 2)})}>{selectArr[2]?selectArr[2].name:'请选择'}</View>} {areaStatus && <View id="address_tab_2" onClick={() => selectTab(2)} className={classnames(styles.address_item, { [styles.addresst_select]: (selectIndex == 2) })}>{selectArr[2] ? selectArr[2].name : '请选择'}</View>}
<View style={bottomStyle} className={styles.bottom_index}></View> <View style={bottomStyle} className={styles.bottom_index}></View>
</View> </View>
<View className={styles.address_list}> <View className={styles.address_list}>
@ -202,9 +202,11 @@ export default memo(({
<View className={styles.address_scroll_list}> <View className={styles.address_scroll_list}>
{list.map(item => { {list.map(item => {
return ( return (
<View onClick={() => selectItem(item)} className={classnames(styles.address_list_item, {[styles.addresst_select]:(selectId == item.id)})}> <View onClick={() => selectItem(item)} className={classnames(styles.address_list_item, { [styles.addresst_select]: (selectId == item.id) })}>
<View className={styles.address_list_item_name}>{item.name}</View> <View className={styles.address_list_item_name}>{item.name}</View>
{(selectArr[selectIndex]?.id == item.id)&&<View className={`iconfont icon-lujing ${styles.address_iconfont}` }></View>} {(selectArr[selectIndex]?.id == item.id) &&
<IconFont name={'icon-lujing'} color={'#327fff'} size={30}></IconFont>
}
</View> </View>
) )
})} })}

View File

@ -1,13 +1,20 @@
.loadingCard_main {
.loadingCard_main{
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
height: 100%; height: 100%;
.loading_text{
.loading_text {
font-size: 26px; font-size: 26px;
margin-top: 20px; margin-top: 20px;
color: $color_font_two; color: $color_font_two;
} }
.pic {
margin-bottom: 20px;
width: 410px;
height: 268px;
}
} }

View File

@ -1,21 +1,24 @@
import { View } from "@tarojs/components" import { View, Image } from "@tarojs/components"
import Loading from "@/components/loading" import Loading from "@/components/loading"
import style from "./index.module.scss" import style from "./index.module.scss"
import { memo } from "react"; import { memo } from "react";
type Params = { type Params = {
title?: string, title?: string,
loadingIcon?: false|true loadingIcon?: false | true
} }
export default memo(({ export default memo(({
title = "加载中...", //显示的文字 title = "加载中...", //显示的文字
loadingIcon = true //是否显示加载图标 loadingIcon = true //是否显示加载图标
}:Params) => { }: Params) => {
console.log('loadingCard:::') console.log('loadingCard:::')
return ( return (
<> <>
<View className={style.loadingCard_main}> <View className={style.loadingCard_main}>
{loadingIcon&&<Loading/>} {loadingIcon && <Loading />}
{
!loadingIcon && <Image className={style.pic} mode='aspectFill' lazyLoad src={'https://cdn.zzfzyc.com/empty.png'}></Image>
}
<View className={style.loading_text}>{title}</View> <View className={style.loading_text}>{title}</View>
</View> </View>
</> </>

View File

@ -32,7 +32,7 @@ interface filterObj {
sale_mode?: Number | undefined, sale_mode?: Number | undefined,
shipment_mode?: Number | undefined shipment_mode?: Number | undefined
} }
import { PAY_H5_CODE_URL } from '@/common/constant'
export default () => { export default () => {
//页码和页数 //页码和页数
@ -518,7 +518,7 @@ export default () => {
itemObj.total_weight_error_discount / 100 itemObj.total_weight_error_discount / 100
).toString(), ).toString(),
order_total_num: itemObj.total_number.toString(), order_total_num: itemObj.total_number.toString(),
qrcode: "", qrcode: `${PAY_H5_CODE_URL}?sale_order_no=${itemObj.order_no}`,
order_total_weight: (itemObj.total_weight / 1000).toString(), order_total_weight: (itemObj.total_weight / 1000).toString(),
estimate_amount: (itemObj.estimate_amount / 100).toString(), estimate_amount: (itemObj.estimate_amount / 100).toString(),
total_sale_price: (itemObj.total_sale_price / 100).toString(), total_sale_price: (itemObj.total_sale_price / 100).toString(),

View File

@ -30,6 +30,7 @@ import { alert, goLink } from '@/common/common'
import { formatPriceDiv, formatDateTime, formatWeightDiv } from '@/common/format' import { formatPriceDiv, formatDateTime, formatWeightDiv } from '@/common/format'
import PayPopup from '../order/components/PayPopup' import PayPopup from '../order/components/PayPopup'
import IconFont from '@/components/iconfont/iconfont' import IconFont from '@/components/iconfont/iconfont'
import { PAY_H5_CODE_URL } from '@/common/constant'
export default () => { export default () => {
const router = useRouter() const router = useRouter()
// useEffect(() => { // useEffect(() => {
@ -437,7 +438,7 @@ export default () => {
infoObj.total_weight_error_discount / 100 infoObj.total_weight_error_discount / 100
).toString(), ).toString(),
order_total_num: infoObj.total_number.toString(), order_total_num: infoObj.total_number.toString(),
qrcode: "", qrcode: `${PAY_H5_CODE_URL}?sale_order_no=${infoObj.order_no}`,
order_total_weight: (infoObj.total_weight / 1000).toString(), order_total_weight: (infoObj.total_weight / 1000).toString(),
estimate_amount: (infoObj.estimate_amount / 100).toString(), estimate_amount: (infoObj.estimate_amount / 100).toString(),
total_sale_price: (infoObj.total_sale_price / 100).toString(), total_sale_price: (infoObj.total_sale_price / 100).toString(),

View File

@ -218,7 +218,7 @@ export default memo(() => {
}) })
const res = await historyFetch() const res = await historyFetch()
if (res.data) { if (res.data) {
setHistroyList([...res.data.list]) setHistroyList([...res?.data?.list])
Taro.hideLoading() Taro.hideLoading()
} }
} }
@ -256,7 +256,7 @@ export default memo(() => {
productFetch({ code_or_name: e }).then((res) => { productFetch({ code_or_name: e }).then((res) => {
if (res.data) { if (res.data) {
Taro.hideLoading() Taro.hideLoading()
setSearchList([...res.data.list]) setSearchList([...res?.data?.list])
} }
}) })
}, 300) }, 300)