电子商城测试版v3
This commit is contained in:
+16
-20
@@ -5,16 +5,16 @@ import { View } from "@tarojs/components"
|
||||
import Taro, { useDidShow, usePullDownRefresh} from "@tarojs/taro";
|
||||
import classnames from "classnames";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import AddressInfo from "./components/addressInfo";
|
||||
import KindList from "./components/kindList";
|
||||
import Remark from "./components/remark";
|
||||
import styles from './comfirm.module.scss'
|
||||
import { getParam } from "@/common/system";
|
||||
import useLogin from "@/use/useLogin";
|
||||
import { alert, goLink } from "@/common/common";
|
||||
import ShipmentMode from "../editOrder/components/shipmentMode";
|
||||
import SubmitOrderBtn from "./components/submitOrderBtn";
|
||||
import AddressInfoDetail from "./components/addressInfoDetail";
|
||||
import { SubscriptionMessageApi } from "@/api/user";
|
||||
import { SUBSCRIPTION_MESSAGE_SCENE } from "@/common/enum";
|
||||
import { UseSubscriptionMessage } from "@/use/useCommonData";
|
||||
|
||||
export default () => {
|
||||
|
||||
@@ -134,9 +134,13 @@ import AddressInfoDetail from "./components/addressInfoDetail";
|
||||
}
|
||||
}, [formatPreViewOrder])
|
||||
|
||||
//订阅消息
|
||||
const {SubmitOrder} = SUBSCRIPTION_MESSAGE_SCENE
|
||||
const {openSubscriptionMessage} = UseSubscriptionMessage()
|
||||
|
||||
//提交订单
|
||||
const {fetchData: saleOrderFetchData} = SaleOrderApi()
|
||||
const submitOrderEven = () => {
|
||||
const submitOrderEven = async () => {
|
||||
if(!submitOrderData?.shipment_mode) {
|
||||
alert.error('请选择收货方式')
|
||||
return false
|
||||
@@ -145,28 +149,20 @@ import AddressInfoDetail from "./components/addressInfoDetail";
|
||||
alert.error('请选择地址')
|
||||
return false
|
||||
}
|
||||
|
||||
Taro.showModal({
|
||||
title: '确定提交?',
|
||||
success: async function (res) {
|
||||
if (res.confirm) {
|
||||
const res = await saleOrderFetchData(submitOrderData)
|
||||
if(res.success) {
|
||||
goLink('/pages/order/index',{id: res.data.id}, 'redirectTo')
|
||||
} else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
}
|
||||
})
|
||||
await openSubscriptionMessage({scenes: SubmitOrder.value})
|
||||
const res = await saleOrderFetchData(submitOrderData)
|
||||
if(res.success) {
|
||||
goLink('/pages/order/index',{id: res.data.id}, 'redirectTo')
|
||||
} else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
}
|
||||
|
||||
//页面下拉刷新
|
||||
usePullDownRefresh(() => {
|
||||
getSaleOrderPreView()
|
||||
})
|
||||
|
||||
return (
|
||||
<View className={styles.order_main}>
|
||||
<AddressInfoDetail orderInfo={defaultAddress} onSelect={getAddress} onChangeShipmentMode={selectShipmentMode} status={1}/>
|
||||
|
||||
@@ -11,7 +11,8 @@ import ScanPay from "../scanPay";
|
||||
import { GetOrderPayApi, SubmitOrderPayApi, GetPrepayOrderPayApi, SubmitPrepayOrderPayApi } from "@/api/orderPay";
|
||||
import { formatPriceDiv } from "@/common/fotmat";
|
||||
import {alert} from "@/common/common"
|
||||
import { ORDER_STATUS, PAYMENT_METHOD, PAYMENT_METHOD_PARAM } from "@/common/enum";
|
||||
import { ORDER_STATUS, PAYMENT_METHOD, PAYMENT_METHOD_PARAM, SUBSCRIPTION_MESSAGE_SCENE } from "@/common/enum";
|
||||
import { UseSubscriptionMessage } from "@/use/useCommonData";
|
||||
|
||||
type Param = {
|
||||
show?: true|false,
|
||||
@@ -21,11 +22,13 @@ type Param = {
|
||||
}
|
||||
|
||||
type OrderInfo = {
|
||||
id?: number, //销售单id
|
||||
should_collect_order_id?: number, //应付单id
|
||||
pre_collect_order_id?: number, //预付单id
|
||||
status?: number, //订单状态
|
||||
payment_method?: 0|PAYMENT_METHOD_PARAM //支付方式
|
||||
sale_mode?: number //订单类型 0:大货 1剪板 2散剪
|
||||
sale_mode?: number, //订单类型 0:大货 1剪板 2散剪
|
||||
[val: string]: any
|
||||
}
|
||||
|
||||
type PayStatus = 1|2|3|4|5|null //1:预存款, 2:账期,3:线下汇款, 4:扫码支付, 5:货到付款
|
||||
@@ -88,28 +91,36 @@ export default memo(({show = false, onClose, orderInfo, onSubmitSuccess}:Param)
|
||||
const periodSelectData = (val) => {
|
||||
setSubmitData((e) => ({...e, payment_method:val}))
|
||||
}
|
||||
|
||||
//订阅消息
|
||||
const {ToPay} = SUBSCRIPTION_MESSAGE_SCENE
|
||||
const {openSubscriptionMessage} = UseSubscriptionMessage()
|
||||
|
||||
//提交支付
|
||||
const {fetchData: submitFetchData} = SubmitOrderPayApi() //应收单提交
|
||||
const {fetchData: submitPrepayOrderFetchData} = SubmitPrepayOrderPayApi() //预付单提交
|
||||
const submitPay = async () => {
|
||||
if(submitData.payment_method === null) {
|
||||
alert.error('请选择支付方式')
|
||||
return false
|
||||
}
|
||||
alert.loading('正在支付')
|
||||
let res:any = null
|
||||
if(orderInfo?.should_collect_order_id) {
|
||||
res = await submitFetchData(submitData)
|
||||
} else {
|
||||
res = await submitPrepayOrderFetchData(submitData)
|
||||
}
|
||||
if(res.success) {
|
||||
alert.success('支付成功')
|
||||
onSubmitSuccess?.()
|
||||
} else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
if(submitData.payment_method === null) {
|
||||
alert.error('请选择支付方式')
|
||||
return false
|
||||
}
|
||||
//账期支付,或预付款并且不是剪板才会订阅
|
||||
if((submitData.payment_method == PaymentMethodAccountPeriod.value || orderInfo?.status == SaleorderstatusWaitingPrePayment.value)&& orderInfo?.sale_mode != 1) {
|
||||
await openSubscriptionMessage({orderId: orderInfo?.id, scenes: ToPay.value})
|
||||
}
|
||||
alert.loading('正在支付')
|
||||
let res:any = null
|
||||
if(orderInfo?.should_collect_order_id) {
|
||||
res = await submitFetchData(submitData)
|
||||
} else {
|
||||
res = await submitPrepayOrderFetchData(submitData)
|
||||
}
|
||||
if(res.success) {
|
||||
alert.success('支付成功')
|
||||
onSubmitSuccess?.()
|
||||
} else {
|
||||
alert.none(res.msg)
|
||||
}
|
||||
}
|
||||
|
||||
//预付款
|
||||
@@ -122,7 +133,6 @@ export default memo(({show = false, onClose, orderInfo, onSubmitSuccess}:Param)
|
||||
|
||||
//是否显示七天账期
|
||||
const show_account_payment = useMemo(() => {
|
||||
console.log('orderInfo?.status::123',orderInfo)
|
||||
//剪板合散剪不显示
|
||||
if(orderInfo?.sale_mode != 0) return false
|
||||
//支付方式是账期支付,不显示
|
||||
@@ -151,7 +161,7 @@ export default memo(({show = false, onClose, orderInfo, onSubmitSuccess}:Param)
|
||||
<Popup show={show} showTitle={false} onClose={onClose} >
|
||||
<View className={styles.payment_con}>
|
||||
<View className={classnames('iconfont icon-a-moreback', styles.miconfont_title)} onClick={onClose}></View>
|
||||
<View className={styles.title}>订单支付</View>
|
||||
<View className={styles.title}>待支付款项</View>
|
||||
<View className={styles.amount}>
|
||||
<AmountShow status={2} number={formatPriceDiv(payInfo?.should_collect_money - payInfo?.amount_paid)}/>
|
||||
</View>
|
||||
@@ -215,7 +225,7 @@ export default memo(({show = false, onClose, orderInfo, onSubmitSuccess}:Param)
|
||||
</View>
|
||||
</Popup>
|
||||
<OfflinePay show={offlinePayShow} onClose={() => setofflinePayShow(false)} offlineInfo={payInfo?.offline_remittance_information}/>
|
||||
<ScanPay show={scanPayShow} onClose={() => setScanPayShow(false)}/>
|
||||
<ScanPay orderInfo={orderInfo} show={scanPayShow} onClose={() => setScanPayShow(false)} />
|
||||
</View>
|
||||
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ import styles from './index.module.scss'
|
||||
import Popup from "@/components/popup";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { alert } from "@/common/common";
|
||||
import { formatImgUrl } from "@/common/fotmat";
|
||||
import { formatDateTime, formatHashTag, formatImgUrl, formatPriceDiv, formatWeightDiv } from "@/common/fotmat";
|
||||
import useCheckAuthorize from "@/use/useCheckAuthorize";
|
||||
import { GetPayCode } from "@/api/onlinePay";
|
||||
import LoadingCard from "@/components/loadingCard";
|
||||
@@ -13,45 +13,91 @@ import LoadingCard from "@/components/loadingCard";
|
||||
|
||||
type Param = {
|
||||
show?: true|false,
|
||||
onClose?: () => void
|
||||
onClose?: () => void,
|
||||
company?: string,
|
||||
qrcode?: string,
|
||||
orderInfo?: any,
|
||||
|
||||
}
|
||||
|
||||
|
||||
type Item = {
|
||||
type ListParam = {
|
||||
product_code: string,
|
||||
product_name: string,
|
||||
product_color_code: string,
|
||||
product_color_name: string,
|
||||
num: string,
|
||||
weight: string,
|
||||
length: string,
|
||||
sale_price: string,
|
||||
total_price: string
|
||||
}
|
||||
type CodeParam = {
|
||||
title: string,
|
||||
company: string,
|
||||
order_type: string,
|
||||
sale_user: string,
|
||||
order_created_time: string,
|
||||
order_no: string,
|
||||
department: string,
|
||||
shipment_mode: string,
|
||||
target_user_name: string,
|
||||
target_address: string,
|
||||
target_description: string,
|
||||
pay_account: string,
|
||||
bank_account_name: string,
|
||||
bank_name: string,
|
||||
pay_type: string,
|
||||
client: string,
|
||||
phone: string,
|
||||
order_total_length: string,
|
||||
order_total_price: string,
|
||||
qrcode: string,
|
||||
order_total_weight: string,
|
||||
list: Item[]
|
||||
}
|
||||
export default memo(({show = true, onClose}:Param) => {
|
||||
export default memo(({show = true, onClose, company, orderInfo}:Param) => {
|
||||
const [detail, setDetail] = useState<any>()
|
||||
|
||||
useEffect(() => {
|
||||
if(orderInfo) {
|
||||
console.log('orderInfo::',orderInfo)
|
||||
let lists:ListParam[] = []
|
||||
orderInfo.product_list?.map(pitem => {
|
||||
pitem?.product_colors?.map(citem => {
|
||||
lists.push({
|
||||
product_code: formatHashTag(pitem.code, '', 'name')!,
|
||||
product_name: pitem.name,
|
||||
product_color_code: formatHashTag(citem.code)!,
|
||||
product_color_name: citem.name,
|
||||
num: citem.roll + '',
|
||||
length: (citem.length/100) + '',
|
||||
weight: formatWeightDiv(citem.estimate_weight) + '',
|
||||
sale_price: formatPriceDiv(citem.sale_price) + '',
|
||||
total_price: formatPriceDiv(citem.estimate_amount) + '',
|
||||
})
|
||||
})
|
||||
})
|
||||
setDetail(() => ({
|
||||
title: "面料销售电子确认单",
|
||||
company: orderInfo.company_name, //后端公司
|
||||
order_type: orderInfo.sale_mode_name, //类型:大货
|
||||
sale_user: orderInfo.sale_user_name, //业务员
|
||||
order_created_time: formatDateTime(orderInfo.create_time),
|
||||
order_no: orderInfo.order_no,
|
||||
shipment_mode: orderInfo.shipment_mode_name, //发货方式
|
||||
target_user_name: userName(orderInfo), //收件人
|
||||
target_address: address(orderInfo), //收货地址
|
||||
target_description: orderInfo.remark, //发货备注
|
||||
pay_account:"1234567890123450001", //专属收款账号
|
||||
bank_account_name:"佛山市浩川长盛科技有限公司", //账户名称
|
||||
bank_name:"招商银行佛山分行禅城支行", //开户银行
|
||||
pay_type:"", //支付方式, 可不传
|
||||
client: orderInfo.purchaser_name, //客户名称
|
||||
phone: userPhone(orderInfo), //收货手机号码
|
||||
order_total_length: (orderInfo.total_number/100) + '', //订单布匹长度
|
||||
order_total_price: formatPriceDiv(orderInfo.total_sale_price) + '', //订单价格
|
||||
order_total_num: orderInfo.total_number + '',
|
||||
qrcode:"", //跳转链接
|
||||
order_total_weight: formatWeightDiv(orderInfo.total_estimate_weight) + '', //订单布匹重量
|
||||
list: lists
|
||||
}))
|
||||
}
|
||||
}, [orderInfo])
|
||||
|
||||
//收货地址
|
||||
const address = (addressInfo) => {
|
||||
if(addressInfo?.shipment_mode == 2) {
|
||||
return addressInfo?.province_name?addressInfo.province_name + addressInfo.city_name + addressInfo.district_name + addressInfo.address_detail:''
|
||||
} else {
|
||||
return addressInfo?.take_goods_address
|
||||
}
|
||||
}
|
||||
|
||||
//收件人
|
||||
const userName = (addressInfo) => {
|
||||
return addressInfo?.shipment_mode == 2? orderInfo.target_user_name: ''
|
||||
}
|
||||
|
||||
//手机号
|
||||
const userPhone = (addressInfo) => {
|
||||
return addressInfo?.shipment_mode == 2? orderInfo.target_user_phone : orderInfo.take_goods_phone
|
||||
}
|
||||
|
||||
|
||||
//获取支付二维码
|
||||
const [payCodeImage, setPayCodeImage] = useState<string>('')
|
||||
@@ -61,30 +107,7 @@ export default memo(({show = true, onClose}:Param) => {
|
||||
})
|
||||
const {fetchData, state} = GetPayCode()
|
||||
const getCore = async () => {
|
||||
let res = await fetchData({
|
||||
title: "面料销售电子确认单",
|
||||
company: "什么什么公司123",
|
||||
order_type: "散剪",
|
||||
sale_user: "小崔",
|
||||
order_created_time:"2022/02/01 12:32:13",
|
||||
order_no:"XS-211005888",
|
||||
department:"嘻嘻嘻",
|
||||
shipment_mode:"自提",
|
||||
target_user_name:"大崔",
|
||||
target_address:"阿斯顿发斯蒂芬",
|
||||
target_description:"无",
|
||||
pay_account:"1234567890123450001",
|
||||
bank_account_name:"佛山市浩川长盛科技有限公司",
|
||||
bank_name:"招商银行佛山分行禅城支行",
|
||||
pay_type:"现结",
|
||||
client:"客户名称",
|
||||
phone:"15818085802",
|
||||
order_total_length:"12",
|
||||
order_total_price:"63000",
|
||||
qrcode:"https://www.zzfzyc.com/checkorder/XS-211005888",
|
||||
order_total_weight:"300.00",
|
||||
list: [{product_code:'5215',product_name:'26S双纱亲水滑爽棉',product_color_code:'053',product_color_name:'洋红',num:'4',weight:'123.23',sale_price:'43',total_price:'4510.7'}]
|
||||
})
|
||||
let res = await fetchData(detail)
|
||||
const base64 = res.data.base64
|
||||
setPayCodeImage(() => base64)
|
||||
const time = new Date().valueOf()
|
||||
@@ -98,7 +121,6 @@ export default memo(({show = true, onClose}:Param) => {
|
||||
data: fileData.current.base64,
|
||||
encoding: 'base64',
|
||||
})
|
||||
|
||||
}
|
||||
useEffect(() => {
|
||||
if(show)
|
||||
|
||||
@@ -5,8 +5,9 @@ import {
|
||||
} from "@/api/order";
|
||||
import { GetOrderPayApi } from "@/api/orderPay";
|
||||
import { AddShoppingCartApi } from "@/api/shopCart";
|
||||
import { SubscriptionMessageApi } from "@/api/user";
|
||||
import { alert, goLink } from "@/common/common";
|
||||
import { ORDER_STATUS } from "@/common/enum";
|
||||
import { ORDER_STATUS, SUBSCRIPTION_MESSAGE_SCENE } from "@/common/enum";
|
||||
import { formatDateTime, formatImgUrl, formatPriceDiv } from "@/common/fotmat";
|
||||
import OrderBtns from "@/components/orderBtns";
|
||||
import Popup from "@/components/popup";
|
||||
|
||||
Reference in New Issue
Block a user