购物车添加数量组件
This commit is contained in:
parent
fab3cd8b86
commit
b82dad781a
@ -32,3 +32,14 @@ export const DelShoppingCartApi = () => {
|
|||||||
method: "delete",
|
method: "delete",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改购物车数量
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export const UpdateShoppingCartApi = () => {
|
||||||
|
return useRequest({
|
||||||
|
url: `/v1/mall/shoppingCart/productColor`,
|
||||||
|
method: "put",
|
||||||
|
})
|
||||||
|
}
|
@ -171,6 +171,12 @@ export default {
|
|||||||
pages: [
|
pages: [
|
||||||
"index",
|
"index",
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
root: "pages/collection",
|
||||||
|
pages: [
|
||||||
|
"index",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
// export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞
|
// export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞
|
||||||
// export const BASE_URL = `https://test.zzfzyc.com/lymarket` // 测试环境
|
// export const BASE_URL = `https://test.zzfzyc.com/lymarket` // 测试环境
|
||||||
// export const BASE_URL = `http://192.168.1.30:40001/lymarket` // 发
|
// export const BASE_URL = `http://192.168.1.30:40001/lymarket` // 发
|
||||||
export const BASE_URL = `http://192.168.1.30:50001/lymarket` // 发
|
// export const BASE_URL = `http://192.168.1.30:50001/lymarket` // 发
|
||||||
// export const BASE_URL = `https://dev.zzfzyc.com/lymarket` // 开发环境
|
// export const BASE_URL = `https://dev.zzfzyc.com/lymarket` // 开发环境
|
||||||
// export const BASE_URL = `https://www.zzfzyc.com/lymarket` // 正式环境
|
// export const BASE_URL = `https://www.zzfzyc.com/lymarket` // 正式环境
|
||||||
// export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞
|
// export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞
|
||||||
// export const BASE_URL = `http://192.168.1.224:50002/lymarket` // 添
|
export const BASE_URL = `http://192.168.1.224:50002/lymarket` // 添
|
||||||
// export const BASE_URL = `http://192.168.1.15:50001/lymarket` // 杰
|
// export const BASE_URL = `http://192.168.1.15:50001/lymarket` // 杰
|
||||||
|
|
||||||
// CDN
|
// CDN
|
||||||
|
@ -11,12 +11,14 @@ type params = {
|
|||||||
onChange?:(val:number) => void,
|
onChange?:(val:number) => void,
|
||||||
onBlue?:(val:number) => void, //失去焦点触发
|
onBlue?:(val:number) => void, //失去焦点触发
|
||||||
onClickBtn?:(val:number) => void,
|
onClickBtn?:(val:number) => void,
|
||||||
unit?: string
|
unit?: string,
|
||||||
|
disable?: true|false, //是否禁用
|
||||||
}
|
}
|
||||||
export default ({minNum = 0, maxNum = 10000, step=1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = ''}: params) => {
|
export default ({minNum = 0, maxNum = 10000, step=1, digits = 0, defaultNum = 0, onChange, onBlue, onClickBtn, unit = '', disable = false}: params) => {
|
||||||
const [value, setValue] = useState<any>({count:defaultNum})
|
const [value, setValue] = useState<any>({count:defaultNum})
|
||||||
|
|
||||||
const onPlus = () => {
|
const onPlus = () => {
|
||||||
|
if(disable) return false
|
||||||
let {count} = value
|
let {count} = value
|
||||||
let num_res = Big(count).add(step).toNumber()
|
let num_res = Big(count).add(step).toNumber()
|
||||||
num_res = num_res >= maxNum?maxNum:num_res
|
num_res = num_res >= maxNum?maxNum:num_res
|
||||||
@ -26,6 +28,7 @@ export default ({minNum = 0, maxNum = 10000, step=1, digits = 0, defaultNum = 0,
|
|||||||
onClickBtn?.(parseFloat(num_res))
|
onClickBtn?.(parseFloat(num_res))
|
||||||
}
|
}
|
||||||
const minus = () => {
|
const minus = () => {
|
||||||
|
if(disable) return false
|
||||||
let {count} = value
|
let {count} = value
|
||||||
let num_res = Big(count).minus(step).toNumber()
|
let num_res = Big(count).minus(step).toNumber()
|
||||||
num_res = num_res < minNum?minNum:num_res
|
num_res = num_res < minNum?minNum:num_res
|
||||||
@ -102,6 +105,7 @@ export default ({minNum = 0, maxNum = 10000, step=1, digits = 0, defaultNum = 0,
|
|||||||
onInput={onInputEven}
|
onInput={onInputEven}
|
||||||
onBlur={onBluerEven}
|
onBlur={onBluerEven}
|
||||||
type='digit'
|
type='digit'
|
||||||
|
disabled={disable}
|
||||||
/>
|
/>
|
||||||
<View className={styles.unit}>{unit}</View>
|
<View className={styles.unit}>{unit}</View>
|
||||||
</View>
|
</View>
|
||||||
|
@ -6,6 +6,7 @@ import Taro from "@tarojs/taro"
|
|||||||
import {useRef, memo, useState, useMemo } from "react"
|
import {useRef, memo, useState, useMemo } from "react"
|
||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import { AddShoppingCartApi } from "@/api/shopCart"
|
||||||
|
|
||||||
type Param = {
|
type Param = {
|
||||||
orderInfo: {
|
orderInfo: {
|
||||||
@ -180,6 +181,7 @@ export default memo(({orderInfo, onClick}:Param) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//显示更多按钮
|
//显示更多按钮
|
||||||
const [showMore, setShowMore] = useState(false)
|
const [showMore, setShowMore] = useState(false)
|
||||||
const styleTop = useMemo(() => {
|
const styleTop = useMemo(() => {
|
||||||
|
@ -17,6 +17,11 @@
|
|||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.count_all{
|
||||||
|
font-size: 22px;
|
||||||
|
color: #ABABAB;
|
||||||
|
padding: 30px 20px;
|
||||||
|
}
|
||||||
.search{
|
.search{
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@ -104,6 +109,15 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
|
.btn_count{
|
||||||
|
width: 235px;
|
||||||
|
height: 64px;
|
||||||
|
background-color: #ECF5FF;
|
||||||
|
border-radius: 40px 0px 16px 0px;
|
||||||
|
padding: 0 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
.price{
|
.price{
|
||||||
font-size: $font_size;
|
font-size: $font_size;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
|
@ -8,7 +8,7 @@ import styles from "./index.module.scss"
|
|||||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import { alert, goLink } from "@/common/common";
|
import { alert, goLink } from "@/common/common";
|
||||||
import {GetShoppingCartApi, DelShoppingCartApi} from "@/api/shopCart"
|
import {GetShoppingCartApi, DelShoppingCartApi, UpdateShoppingCartApi} from "@/api/shopCart"
|
||||||
import { formatHashTag, formatImgUrl, formatPriceDiv } from "@/common/fotmat";
|
import { formatHashTag, formatImgUrl, formatPriceDiv } from "@/common/fotmat";
|
||||||
import { setParam } from "@/common/system";
|
import { setParam } from "@/common/system";
|
||||||
import { debounce } from "@/common/util";
|
import { debounce } from "@/common/util";
|
||||||
@ -189,15 +189,25 @@ export default ({show = false, onClose}: param) => {
|
|||||||
return item.sale_mode == 0? '条':'米'
|
return item.sale_mode == 0? '条':'米'
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
//预估金额
|
//预估金额和总条数
|
||||||
const estimatePrice = useMemo(() => {
|
const estimatePrice = useMemo(() => {
|
||||||
let count = 0
|
let estimate_amount = 0
|
||||||
|
let product_list = new Set() //面料
|
||||||
|
let color_count = 0 //颜色数量
|
||||||
|
let all_count = 0 //总数量
|
||||||
list.map(item => {
|
list.map(item => {
|
||||||
if(item.select) count += item.estimate_amount
|
if(item.select) {
|
||||||
|
estimate_amount += item.estimate_amount
|
||||||
|
product_list.add(item.product_id)
|
||||||
|
color_count++
|
||||||
|
all_count += item.sale_mode == 0?item.roll: (item.length)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return Number(formatPriceDiv(count))
|
let all_count_text = selectIndex == 0?all_count + '条': (all_count/100) + '米'
|
||||||
|
return {price: Number(formatPriceDiv(estimate_amount)), countText: `已选${product_list.size}种面料,${color_count}个颜色,共${all_count_text}`, color_count}
|
||||||
},[list])
|
},[list])
|
||||||
|
|
||||||
|
|
||||||
//去结算
|
//去结算
|
||||||
const orderDetail = debounce(() => {
|
const orderDetail = debounce(() => {
|
||||||
getSelectId()
|
getSelectId()
|
||||||
@ -205,18 +215,27 @@ export default ({show = false, onClose}: param) => {
|
|||||||
alert.error('请选择面料')
|
alert.error('请选择面料')
|
||||||
} else {
|
} else {
|
||||||
let ids = selectIds.current.join('-')
|
let ids = selectIds.current.join('-')
|
||||||
setParam({ids, sale_mode:selectIndex})
|
setParam({ids, sale_mode:selectIndex}) //临时存储
|
||||||
closePopup()
|
closePopup()
|
||||||
goLink('/pages/order/comfirm')
|
goLink('/pages/order/comfirm')
|
||||||
}
|
}
|
||||||
}, 500)
|
}, 500)
|
||||||
|
|
||||||
//计数组件
|
//计数组件-当后端修改完成才修改前端显示
|
||||||
const getInputValue = (num, item) => {
|
const {fetchData: fetchDataUpdateShoppingCart} = UpdateShoppingCartApi()
|
||||||
|
const [UpdateShoppingCartLoading, setUpdateShoppingCartLoading] = useState(false)
|
||||||
|
const getInputValue = async (num, item) => {
|
||||||
|
let roll = item.sale_mode == 0?parseFloat(num):0
|
||||||
|
let length = item.sale_mode != 0?(parseFloat(num)*100):0
|
||||||
|
setUpdateShoppingCartLoading(() => true)
|
||||||
|
let res = await fetchDataUpdateShoppingCart({id: item.id, roll, length})
|
||||||
|
setUpdateShoppingCartLoading(() => false)
|
||||||
|
if(res.success) {
|
||||||
item.count = parseFloat(num)
|
item.count = parseFloat(num)
|
||||||
setList([...list])
|
setList([...list])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className={styles.shop_cart_main}>
|
<View className={styles.shop_cart_main}>
|
||||||
@ -229,6 +248,7 @@ export default ({show = false, onClose}: param) => {
|
|||||||
删除所选
|
删除所选
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
<View className={styles.count_all}>{estimatePrice.countText}</View>
|
||||||
<View className={styles.search}>
|
<View className={styles.search}>
|
||||||
{selectList.map((item) => {
|
{selectList.map((item) => {
|
||||||
return <View key={item.value} onClick={() => selectProduct(item.value)} className={classnames(styles.search_item, (selectIndex==item.value)&&styles.search_item_select)}>{item.title}</View>
|
return <View key={item.value} onClick={() => selectProduct(item.value)} className={classnames(styles.search_item, (selectIndex==item.value)&&styles.search_item_select)}>{item.title}</View>
|
||||||
@ -254,6 +274,7 @@ export default ({show = false, onClose}: param) => {
|
|||||||
<View className={styles.count}>
|
<View className={styles.count}>
|
||||||
<View className={styles.price}><text>¥</text>{formatPirce(item.sale_price)}<text>/{selectList[selectIndex].eunit}</text></View>
|
<View className={styles.price}><text>¥</text>{formatPirce(item.sale_price)}<text>/{selectList[selectIndex].eunit}</text></View>
|
||||||
{/* <View className={styles.long}>×{formatCount(item)}</View> */}
|
{/* <View className={styles.long}>×{formatCount(item)}</View> */}
|
||||||
|
<View className={styles.btn_count}>
|
||||||
<Counter
|
<Counter
|
||||||
onBlue={(e) => getInputValue(e, item)}
|
onBlue={(e) => getInputValue(e, item)}
|
||||||
defaultNum={item.count}
|
defaultNum={item.count}
|
||||||
@ -263,9 +284,11 @@ export default ({show = false, onClose}: param) => {
|
|||||||
unit={formatUnit(item)}
|
unit={formatUnit(item)}
|
||||||
minNum={selectList[selectIndex].minNum}
|
minNum={selectList[selectIndex].minNum}
|
||||||
maxNum={selectList[selectIndex].maxNum}
|
maxNum={selectList[selectIndex].maxNum}
|
||||||
|
disable={UpdateShoppingCartLoading}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
</View>
|
||||||
})}
|
})}
|
||||||
</View>
|
</View>
|
||||||
</InfiniteScroll>}
|
</InfiniteScroll>}
|
||||||
@ -281,11 +304,11 @@ export default ({show = false, onClose}: param) => {
|
|||||||
<View className={classnames('iconfont', 'icon-gouwuche', styles.miconfont)}></View>
|
<View className={classnames('iconfont', 'icon-gouwuche', styles.miconfont)}></View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.price_con}>
|
<View className={styles.price_con}>
|
||||||
<View className={styles.price_real}><text>¥</text>{estimatePrice}</View>
|
<View className={styles.price_real}><text>¥</text>{estimatePrice.price}</View>
|
||||||
<View className={styles.price_forecast}>预估金额</View>
|
<View className={styles.price_forecast}>预估金额</View>
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.goPay} onClick={() => orderDetail()}>
|
<View className={styles.goPay} onClick={() => orderDetail()}>
|
||||||
去结算
|
去结算({estimatePrice.color_count})
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
4
src/pages/collection/index.config.ts
Normal file
4
src/pages/collection/index.config.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export default {
|
||||||
|
navigationBarTitleText: '我的收藏',
|
||||||
|
enableShareAppMessage: true,
|
||||||
|
}
|
0
src/pages/collection/index.module.scss
Normal file
0
src/pages/collection/index.module.scss
Normal file
12
src/pages/collection/index.tsx
Normal file
12
src/pages/collection/index.tsx
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import Search from "@/components/search"
|
||||||
|
import { View } from "@tarojs/components"
|
||||||
|
import styles from './index.module.scss'
|
||||||
|
export default () => {
|
||||||
|
return (
|
||||||
|
<View className={styles.main}>
|
||||||
|
<View className={styles.search}>
|
||||||
|
<Search style={{width: '100%'}} debounceTime={300} changeOnSearch={(e) => console.log(e)} placeholder="请输入面料关键词" placeIcon="out" showBtn={true} />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
@ -296,7 +296,7 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
|||||||
// </InfiniteScroll>}
|
// </InfiniteScroll>}
|
||||||
<View className={styles.color_con}>
|
<View className={styles.color_con}>
|
||||||
<VirtualList
|
<VirtualList
|
||||||
height={500} /* 列表的高度 */
|
height={400} /* 列表的高度 */
|
||||||
width='100%' /* 列表的宽度 */
|
width='100%' /* 列表的宽度 */
|
||||||
itemData={list} /* 渲染列表的数据 */
|
itemData={list} /* 渲染列表的数据 */
|
||||||
itemCount={list.length} /* 渲染列表的长度 */
|
itemCount={list.length} /* 渲染列表的长度 */
|
||||||
|
@ -20,7 +20,6 @@ export type AddressInfoParam = {
|
|||||||
}
|
}
|
||||||
type Param = {
|
type Param = {
|
||||||
onSelect?: (val:any) => void, //选择地址
|
onSelect?: (val:any) => void, //选择地址
|
||||||
defaultValue?: AddressInfoParam|null, //默认值
|
|
||||||
disabled?: false|true, //true禁用后只用于展示
|
disabled?: false|true, //true禁用后只用于展示
|
||||||
onChangeShipmentMode?: (val: number) => void, //返回收货方式
|
onChangeShipmentMode?: (val: number) => void, //返回收货方式
|
||||||
status?: 1|2, //1确认订单时使用, 2订单流程
|
status?: 1|2, //1确认订单时使用, 2订单流程
|
||||||
@ -35,7 +34,7 @@ type Param = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, status = 2}: Param, ref) => {
|
export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, status = 2, disabled = false}: Param, ref) => {
|
||||||
|
|
||||||
|
|
||||||
const [addressInfo, setAddressInfo] = useState<any>()
|
const [addressInfo, setAddressInfo] = useState<any>()
|
||||||
@ -46,6 +45,7 @@ export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, stat
|
|||||||
}
|
}
|
||||||
}, [orderInfo])
|
}, [orderInfo])
|
||||||
|
|
||||||
|
|
||||||
//地址格式
|
//地址格式
|
||||||
const formatAddress = useMemo(() => {
|
const formatAddress = useMemo(() => {
|
||||||
if(addressInfo?.province_name) {
|
if(addressInfo?.province_name) {
|
||||||
@ -58,7 +58,7 @@ export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, stat
|
|||||||
//打开地址列表
|
//打开地址列表
|
||||||
const [showAddressList, setShowAddressList] = useState(false)
|
const [showAddressList, setShowAddressList] = useState(false)
|
||||||
const changeShow = () => {
|
const changeShow = () => {
|
||||||
if(receivingStatus == 2 && !logisticsShow)
|
if(receivingStatus == 2 && !logisticsShow && !disabledSelect)
|
||||||
setShowAddressList(() => true)
|
setShowAddressList(() => true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +72,7 @@ export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, stat
|
|||||||
const {fetchData: shipmentModeFetchData} = EditSaleOrderShipmentModeApi()
|
const {fetchData: shipmentModeFetchData} = EditSaleOrderShipmentModeApi()
|
||||||
const onReceivingStatus = (value, e) => {
|
const onReceivingStatus = (value, e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
if(!disabledSelect) return false
|
||||||
changeReceivingStatus(value)
|
changeReceivingStatus(value)
|
||||||
}
|
}
|
||||||
const changeReceivingStatus = debounce(async (value) => {
|
const changeReceivingStatus = debounce(async (value) => {
|
||||||
@ -123,9 +124,21 @@ export default memo(forwardRef(({onSelect, onChangeShipmentMode, orderInfo, stat
|
|||||||
SaleOrderStatusAlreadyReceipt,
|
SaleOrderStatusAlreadyReceipt,
|
||||||
SaleOrderStatusComplete,
|
SaleOrderStatusComplete,
|
||||||
SaleOrderStatusRefund,
|
SaleOrderStatusRefund,
|
||||||
SaleOrderStatusCancel
|
SaleOrderStatusCancel,
|
||||||
} = ORDER_STATUS
|
} = ORDER_STATUS
|
||||||
|
|
||||||
|
//禁用
|
||||||
|
const disabledSelect = useMemo(() => {
|
||||||
|
let statusList = [
|
||||||
|
SaleOrderStatusWaitingReceipt.value,
|
||||||
|
SaleOrderStatusAlreadyReceipt.value,
|
||||||
|
SaleOrderStatusComplete.value,
|
||||||
|
SaleOrderStatusRefund.value,
|
||||||
|
SaleOrderStatusCancel.value,
|
||||||
|
]
|
||||||
|
return (statusList.includes(orderInfo?.status!)||disabled)
|
||||||
|
}, [orderInfo, disabled])
|
||||||
|
|
||||||
//根据订单状态判断是否显示物流
|
//根据订单状态判断是否显示物流
|
||||||
const logisticsShowList = [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value, SaleOrderStatusCancel.value]
|
const logisticsShowList = [SaleOrderStatusWaitingReceipt.value, SaleOrderStatusAlreadyReceipt.value, SaleOrderStatusComplete.value, SaleOrderStatusRefund.value, SaleOrderStatusCancel.value]
|
||||||
const logisticsShow = useMemo(() => {
|
const logisticsShow = useMemo(() => {
|
||||||
|
@ -4,12 +4,14 @@ import {
|
|||||||
CancelOrderApi
|
CancelOrderApi
|
||||||
} from "@/api/order";
|
} from "@/api/order";
|
||||||
import { GetOrderPayApi } from "@/api/orderPay";
|
import { GetOrderPayApi } from "@/api/orderPay";
|
||||||
|
import { AddShoppingCartApi } from "@/api/shopCart";
|
||||||
import { alert, goLink } from "@/common/common";
|
import { alert, goLink } from "@/common/common";
|
||||||
import { ORDER_STATUS } from "@/common/enum";
|
import { ORDER_STATUS } from "@/common/enum";
|
||||||
import { formatDateTime, formatPriceDiv } from "@/common/fotmat";
|
import { formatDateTime, formatPriceDiv } from "@/common/fotmat";
|
||||||
import OrderBtns from "@/components/orderBtns";
|
import OrderBtns from "@/components/orderBtns";
|
||||||
import Popup from "@/components/popup";
|
import Popup from "@/components/popup";
|
||||||
import SearchInput from "@/components/searchInput";
|
import SearchInput from "@/components/searchInput";
|
||||||
|
import ShopCart from "@/components/shopCart";
|
||||||
import { Text, Textarea, View } from "@tarojs/components"
|
import { Text, Textarea, View } from "@tarojs/components"
|
||||||
import Taro, { useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro";
|
import Taro, { useDidShow, usePullDownRefresh, useRouter } from "@tarojs/taro";
|
||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
@ -97,7 +99,8 @@ import styles from './index.module.scss'
|
|||||||
name: orderDetail?.target_user_name,
|
name: orderDetail?.target_user_name,
|
||||||
phone: orderDetail?.target_user_phone,
|
phone: orderDetail?.target_user_phone,
|
||||||
shipment_mode: orderDetail?.shipment_mode,
|
shipment_mode: orderDetail?.shipment_mode,
|
||||||
id: orderDetail?.id
|
id: orderDetail?.id,
|
||||||
|
sale_mode: orderDetail?.sale_mode,
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [orderDetail])
|
}, [orderDetail])
|
||||||
@ -152,6 +155,9 @@ import styles from './index.module.scss'
|
|||||||
toPay()
|
toPay()
|
||||||
} else if(val == 3) {
|
} else if(val == 3) {
|
||||||
setRefundShow(true)
|
setRefundShow(true)
|
||||||
|
} else if(val == 7) {
|
||||||
|
//再购
|
||||||
|
addShopCart()
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [orderDetail])
|
}, [orderDetail])
|
||||||
@ -199,6 +205,40 @@ import styles from './index.module.scss'
|
|||||||
setRefundShow(false)
|
setRefundShow(false)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//添加购物车
|
||||||
|
const [showCart, setShowCart] = useState(false)
|
||||||
|
const {fetchData:addFetchData} = AddShoppingCartApi()
|
||||||
|
const addShopCart = async () => {
|
||||||
|
let color_list:{product_color_id: number, roll?: number, length?: number}[] = []
|
||||||
|
orderDetail?.product_list.map(pitem => {
|
||||||
|
pitem?.product_colors.map(citem => {
|
||||||
|
if(orderDetail?.sale_mode == 0) {
|
||||||
|
return color_list.push({product_color_id: citem.id, roll: citem.roll})
|
||||||
|
} else {
|
||||||
|
return color_list.push({product_color_id: citem.id, length: citem.length})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
const state = await addFetchData({
|
||||||
|
sale_mode: orderDetail?.sale_mode,
|
||||||
|
color_list
|
||||||
|
})
|
||||||
|
if(state.success) {
|
||||||
|
Taro.showToast({
|
||||||
|
title:'已加入购物车'
|
||||||
|
})
|
||||||
|
setShowCart(true)
|
||||||
|
} else {
|
||||||
|
Taro.showToast({
|
||||||
|
icon:'none',
|
||||||
|
title: state.msg
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View className={styles.order_main}>
|
<View className={styles.order_main}>
|
||||||
<OrderState orderInfo={orderDetail} onRefresh={refresh}/>
|
<OrderState orderInfo={orderDetail} onRefresh={refresh}/>
|
||||||
@ -238,6 +278,7 @@ import styles from './index.module.scss'
|
|||||||
</Popup>
|
</Popup>
|
||||||
<Payment onSubmitSuccess={onPaySuccess} show={payMentShow} onClose={closePayShow} orderInfo={orderDetail} />
|
<Payment onSubmitSuccess={onPaySuccess} show={payMentShow} onClose={closePayShow} orderInfo={orderDetail} />
|
||||||
<ApplyRefund show={refundShow} onClose={applyRefundClose}/>
|
<ApplyRefund show={refundShow} onClose={applyRefundClose}/>
|
||||||
|
<ShopCart show={showCart} onClose={() => setShowCart(false)}/>
|
||||||
<View className="common_safe_area_y"></View>
|
<View className="common_safe_area_y"></View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
@ -25,7 +25,7 @@ export default memo(({return_address = '', return_phone = '', onLogistics, stage
|
|||||||
//是否显示地址
|
//是否显示地址
|
||||||
const showAddress = useMemo(() => {
|
const showAddress = useMemo(() => {
|
||||||
return stage != ReturnStageApplying.value
|
return stage != ReturnStageApplying.value
|
||||||
}, [])
|
}, [stage])
|
||||||
|
|
||||||
//上传物流
|
//上传物流
|
||||||
const upLogistics = useMemo(() => {
|
const upLogistics = useMemo(() => {
|
||||||
|
@ -110,7 +110,7 @@ export const useRequest = (options:option = {
|
|||||||
success: false, // 请求是否成功
|
success: false, // 请求是否成功
|
||||||
data: {},
|
data: {},
|
||||||
msg: '',
|
msg: '',
|
||||||
loading: true,
|
loading: false,
|
||||||
error: null,
|
error: null,
|
||||||
query: {},
|
query: {},
|
||||||
filter: null,
|
filter: null,
|
||||||
@ -127,7 +127,7 @@ export const useRequest = (options:option = {
|
|||||||
const {login} = useLoginRequest()
|
const {login} = useLoginRequest()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('变化::', state.loading)
|
console.log('变化1::', state.loading)
|
||||||
}, [state.loading])
|
}, [state.loading])
|
||||||
// 请求函数
|
// 请求函数
|
||||||
const fetchData = async (sub_options?:any) => {
|
const fetchData = async (sub_options?:any) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user