From 42c5bb0952db41adbefa471701ca2779c695a701 Mon Sep 17 00:00:00 2001 From: Haiyi <1021441632@qq.com> Date: Wed, 19 Oct 2022 17:37:24 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=E9=94=80=E5=94=AE=E7=A0=81?= =?UTF-8?q?=E5=8D=95=E8=B7=B3=E8=BD=AC=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/constant.js | 2 + src/components/address/index.tsx | 98 ++++++++++---------- src/components/loadingCard/index.module.scss | 13 ++- src/components/loadingCard/index.tsx | 11 ++- src/pages/order/index.tsx | 4 +- src/pages/orderDetails/index.tsx | 5 +- src/pages/searchPage/index.tsx | 4 +- 7 files changed, 76 insertions(+), 61 deletions(-) diff --git a/src/common/constant.js b/src/common/constant.js index dc71e85..1647e3d 100644 --- a/src/common/constant.js +++ b/src/common/constant.js @@ -37,3 +37,5 @@ export const WX_APPID = 'wx64fe67f111d52457' export const SCENE = { SearchScene: 0, //商城面料搜索 } +//支付码单跳转链接 +export const PAY_H5_CODE_URL = CURRENT_ENV.includes('production') ? 'https://www.zzfzyc.com/cashier' : 'https://test.zzfzyc.com/cashier' \ No newline at end of file diff --git a/src/components/address/index.tsx b/src/components/address/index.tsx index 4dd9f83..b304084 100644 --- a/src/components/address/index.tsx +++ b/src/components/address/index.tsx @@ -6,17 +6,17 @@ import classnames from "classnames"; import Taro from "@tarojs/taro"; import { GetAddressListApi } from "@/api/addressList"; 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 = { - addressOnSelect?: (val:DefaultValueParm[]) => void, - addressOnChange?: (val:DefaultValueParm[]) => void, + addressOnSelect?: (val: DefaultValueParm[]) => void, + addressOnChange?: (val: DefaultValueParm[]) => void, addressOnClose?: () => void, - show?: true|false, - defaultValue?:DefaultValueParm[] - selectStatus?: false|true, //false不需要选择完整地址,true需要选择完整地址 + show?: true | false, + defaultValue?: DefaultValueParm[] + selectStatus?: false | true, //false不需要选择完整地址,true需要选择完整地址 } type AddresParam = { @@ -26,7 +26,7 @@ type AddresParam = { level_name?: string, name?: string, parent_id?: number, - + } @@ -38,13 +38,13 @@ export default memo(({ defaultValue = [], selectStatus = true }: Params) => { - //省 - const provinceList = useRef([]) - //市 - const cityList = useRef([]) - //区 - const areaList = useRef([]) - + //省 + const provinceList = useRef([]) + //市 + const cityList = useRef([]) + //区 + const areaList = useRef([]) + const [list, setList] = useState([]) const [selectIndex, setSelectIndex] = useState(0) //0 省, 1 市,2 区 const [selectId, setSelectId] = useState(1) //选中的id @@ -53,54 +53,54 @@ export default memo(({ const [areaStatus, setAreaStatus] = useState(false) //区镇是否存在 const [confirmBtnStatus, setConfirmBtnStatus] = useState(false) //确认按钮是否可用 - const [bottomStyle, setBottomStyle] = useState({width:'100rpx',left:'0rpx'}) //底部滚动条样式 + const [bottomStyle, setBottomStyle] = useState({ width: '100rpx', left: '0rpx' }) //底部滚动条样式 useEffect(() => { - if(selectArr.length == 0) { + if (selectArr.length == 0) { setSelectArr(defaultValue) - if(defaultValue.length > 1) setCityStatus(true) - if(defaultValue.length > 2) setAreaStatus(true) - if(defaultValue.length > 0) setConfirmBtnStatus(true) + if (defaultValue.length > 1) setCityStatus(true) + if (defaultValue.length > 2) setAreaStatus(true) + if (defaultValue.length > 0) setConfirmBtnStatus(true) } }, [defaultValue]) //获取地址 - const {fetchData} = GetAddressListApi() + const { fetchData } = GetAddressListApi() useEffect(() => { getProvince() }, []) - + //选中内容 const selectItem = (item) => { setSelectId(item.id) - if(selectIndex == 0) { - setSelectArr([{name:item.name, id:item.id, level:item.level}]) + if (selectIndex == 0) { + setSelectArr([{ name: item.name, id: item.id, level: item.level }]) getCity(item.id) setAreaStatus(false) setCityStatus(false) - } else if(selectIndex == 1){ - setSelectArr([selectArr[0], {name:item.name, id:item.id, level:item.level}]) + } else if (selectIndex == 1) { + setSelectArr([selectArr[0], { name: item.name, id: item.id, level: item.level }]) area(item.id) } 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') } - + } //地址数据 useEffect(() => { - if(selectArr && selectArr.length > 0) + if (selectArr && selectArr.length > 0) addressOnChange?.(selectArr) }, [selectArr]) - + //选中标题 const onSelectIndex = (index) => { setSelectIndex(index) - const selectid = selectArr[index]?selectArr[index].id:0 + const selectid = selectArr[index] ? selectArr[index].id : 0 setSelectId(selectid as number) - if(index == 0) { + if (index == 0) { getProvince() } else if (index == 1) { const id = selectArr[0]?.id @@ -114,9 +114,9 @@ export default memo(({ //获取省 const getProvince = async () => { - let res = await fetchData({parent_id: 1}) - provinceList.current = res.data.list||[] - if(provinceList.current.length > 0) { + let res = await fetchData({ parent_id: 1 }) + provinceList.current = res.data.list || [] + if (provinceList.current.length > 0) { setSelectIndex(0) setList(() => provinceList.current) getDomDes('#address_tab_0') @@ -125,9 +125,9 @@ export default memo(({ //获取市 const getCity = async (id) => { - let res = await fetchData({parent_id: id}) - cityList.current = res.data.list||[] - if(cityList.current.length > 0) { + let res = await fetchData({ parent_id: id }) + cityList.current = res.data.list || [] + if (cityList.current.length > 0) { setSelectIndex(1) setList(() => cityList.current) setCityStatus(true) @@ -141,9 +141,9 @@ export default memo(({ //获取区 const area = async (id) => { - let res = await fetchData({parent_id: id}) - areaList.current = res.data.list||[] - if(areaList.current.length > 0) { + let res = await fetchData({ parent_id: id }) + areaList.current = res.data.list || [] + if (areaList.current.length > 0) { setSelectIndex(2) setList(() => areaList.current) setAreaStatus(true) @@ -165,7 +165,7 @@ export default memo(({ const getDomDes = (id) => { setTimeout(() => { let query = Taro.createSelectorQuery(); - query.select(id).boundingClientRect(rect=>{ + query.select(id).boundingClientRect(rect => { let left = rect.left; let clientWidth = rect.width; console.log(clientWidth) @@ -180,7 +180,7 @@ export default memo(({ //点击标题栏 const selectTab = (index) => { onSelectIndex(index) - getDomDes('#address_tab_'+index) + getDomDes('#address_tab_' + index) } return ( @@ -192,9 +192,9 @@ export default memo(({ submitSelect()}>确定 - selectTab(0)} className={classnames(styles.address_item, {[styles.addresst_select]:(selectIndex == 0)})}>{selectArr[0]?selectArr[0].name:'请选择'} - {cityStatus&& selectTab(1)} className={classnames(styles.address_item, {[styles.addresst_select]:(selectIndex == 1)})}>{selectArr[1]?selectArr[1].name:'请选择'}} - {areaStatus&& selectTab(2)} className={classnames(styles.address_item, {[styles.addresst_select]:(selectIndex == 2)})}>{selectArr[2]?selectArr[2].name:'请选择'}} + selectTab(0)} className={classnames(styles.address_item, { [styles.addresst_select]: (selectIndex == 0) })}>{selectArr[0] ? selectArr[0].name : '请选择'} + {cityStatus && selectTab(1)} className={classnames(styles.address_item, { [styles.addresst_select]: (selectIndex == 1) })}>{selectArr[1] ? selectArr[1].name : '请选择'}} + {areaStatus && selectTab(2)} className={classnames(styles.address_item, { [styles.addresst_select]: (selectIndex == 2) })}>{selectArr[2] ? selectArr[2].name : '请选择'}} @@ -202,9 +202,11 @@ export default memo(({ {list.map(item => { return ( - selectItem(item)} className={classnames(styles.address_list_item, {[styles.addresst_select]:(selectId == item.id)})}> + selectItem(item)} className={classnames(styles.address_list_item, { [styles.addresst_select]: (selectId == item.id) })}> {item.name} - {(selectArr[selectIndex]?.id == item.id)&&} + {(selectArr[selectIndex]?.id == item.id) && + + } ) })} diff --git a/src/components/loadingCard/index.module.scss b/src/components/loadingCard/index.module.scss index 4c6cfa8..d0734ed 100644 --- a/src/components/loadingCard/index.module.scss +++ b/src/components/loadingCard/index.module.scss @@ -1,13 +1,20 @@ - -.loadingCard_main{ +.loadingCard_main { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; - .loading_text{ + + .loading_text { font-size: 26px; margin-top: 20px; color: $color_font_two; } + + .pic { + margin-bottom: 20px; + width: 410px; + height: 268px; + } + } \ No newline at end of file diff --git a/src/components/loadingCard/index.tsx b/src/components/loadingCard/index.tsx index 0053f4a..79efa2f 100644 --- a/src/components/loadingCard/index.tsx +++ b/src/components/loadingCard/index.tsx @@ -1,21 +1,24 @@ -import { View } from "@tarojs/components" +import { View, Image } from "@tarojs/components" import Loading from "@/components/loading" import style from "./index.module.scss" import { memo } from "react"; type Params = { title?: string, - loadingIcon?: false|true + loadingIcon?: false | true } export default memo(({ title = "加载中...", //显示的文字 loadingIcon = true //是否显示加载图标 -}:Params) => { +}: Params) => { console.log('loadingCard:::') return ( <> - {loadingIcon&&} + {loadingIcon && } + { + !loadingIcon && + } {title} diff --git a/src/pages/order/index.tsx b/src/pages/order/index.tsx index 1389c45..34c8280 100644 --- a/src/pages/order/index.tsx +++ b/src/pages/order/index.tsx @@ -32,7 +32,7 @@ interface filterObj { sale_mode?: Number | undefined, shipment_mode?: Number | undefined } - +import { PAY_H5_CODE_URL } from '@/common/constant' export default () => { //页码和页数 @@ -518,7 +518,7 @@ export default () => { itemObj.total_weight_error_discount / 100 ).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(), estimate_amount: (itemObj.estimate_amount / 100).toString(), total_sale_price: (itemObj.total_sale_price / 100).toString(), diff --git a/src/pages/orderDetails/index.tsx b/src/pages/orderDetails/index.tsx index 2f7bb02..b870029 100644 --- a/src/pages/orderDetails/index.tsx +++ b/src/pages/orderDetails/index.tsx @@ -30,6 +30,7 @@ import { alert, goLink } from '@/common/common' import { formatPriceDiv, formatDateTime, formatWeightDiv } from '@/common/format' import PayPopup from '../order/components/PayPopup' import IconFont from '@/components/iconfont/iconfont' +import { PAY_H5_CODE_URL } from '@/common/constant' export default () => { const router = useRouter() // useEffect(() => { @@ -437,7 +438,7 @@ export default () => { infoObj.total_weight_error_discount / 100 ).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(), estimate_amount: (infoObj.estimate_amount / 100).toString(), total_sale_price: (infoObj.total_sale_price / 100).toString(), @@ -538,7 +539,7 @@ export default () => { //申请退款 const handApplyMoney = () => { - + Taro.navigateTo({ url: '/pages/applyMoney/index?orderId=' + infoObj.id }) diff --git a/src/pages/searchPage/index.tsx b/src/pages/searchPage/index.tsx index f92be5d..95a84e8 100644 --- a/src/pages/searchPage/index.tsx +++ b/src/pages/searchPage/index.tsx @@ -218,7 +218,7 @@ export default memo(() => { }) const res = await historyFetch() if (res.data) { - setHistroyList([...res.data.list]) + setHistroyList([...res?.data?.list]) Taro.hideLoading() } } @@ -256,7 +256,7 @@ export default memo(() => { productFetch({ code_or_name: e }).then((res) => { if (res.data) { Taro.hideLoading() - setSearchList([...res.data.list]) + setSearchList([...res?.data?.list]) } }) }, 300)