电子商城测试版v3
This commit is contained in:
parent
b2f17afe50
commit
06aeda9e6b
@ -86,7 +86,7 @@ import { useRequest } from "@/use/useHttp"
|
||||
export const SubscriptionMessageApi = () => {
|
||||
return useRequest({
|
||||
url: `/v1/mall/subscriptionMessage`,
|
||||
method: "post",
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,9 @@
|
||||
// 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://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.7:50002/lymarket` // 添
|
||||
export const BASE_URL = `http://192.168.1.42:50001/lymarket` // 杰
|
||||
// export const BASE_URL = `http://192.168.1.42:50001/lymarket` // 杰
|
||||
|
||||
// CDN
|
||||
// 生成密钥
|
||||
|
@ -50,3 +50,10 @@ export const SHARE_SCENE = {
|
||||
ShareDetail: {value:1, label:'详情分享'},
|
||||
SharePage : {value:2, label:'页面分享'},
|
||||
}
|
||||
|
||||
//订阅消息
|
||||
export const SUBSCRIPTION_MESSAGE_SCENE = {
|
||||
SubmitOrder: {value:1, label:'确认下单'},
|
||||
ToPay : {value:2, label:'去付款'},
|
||||
ApplyGoods: {value:3, label: '申请退款'}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import { CancelOrderApi, ReceiveOrderApi } from "@/api/order"
|
||||
import { alert, goLink } from "@/common/common"
|
||||
import { ORDER_STATUS, SALE_MODE } from "@/common/enum"
|
||||
import { ORDER_STATUS, SALE_MODE, SUBSCRIPTION_MESSAGE_SCENE } from "@/common/enum"
|
||||
import {Text, View } from "@tarojs/components"
|
||||
import Taro from "@tarojs/taro"
|
||||
import {useRef, memo, useState, useMemo } from "react"
|
||||
@ -8,6 +8,7 @@ import classnames from "classnames";
|
||||
import styles from './index.module.scss'
|
||||
import { AddShoppingCartApi } from "@/api/shopCart"
|
||||
import { ApplyRefundApi } from "@/api/salesAfterOrder"
|
||||
import { UseSubscriptionMessage } from "@/use/useCommonData"
|
||||
|
||||
type Param = {
|
||||
orderInfo: {
|
||||
@ -126,22 +127,29 @@ export default memo(({orderInfo, onClick}:Param) => {
|
||||
})
|
||||
}, [orderInfo])
|
||||
|
||||
|
||||
//订阅消息
|
||||
const {ApplyGoods} = SUBSCRIPTION_MESSAGE_SCENE
|
||||
const {openSubscriptionMessage} = UseSubscriptionMessage()
|
||||
|
||||
//点击按钮操作
|
||||
const submitBtns = (val, index) => {
|
||||
const submitBtns = async (val, index) => {
|
||||
if (val == 1) {
|
||||
cancelOrder()
|
||||
} else if (val == 6) {
|
||||
receiveOrder()
|
||||
} else if(val == 5) {
|
||||
if(!orderInfo?.av_return_roll) return alert.none('该订单没有可退条数')
|
||||
goLink('/pages/applyAfterSales/index',{id:orderInfo?.orderId})
|
||||
await openSubscriptionMessage({orderId: orderInfo?.orderId, scenes: ApplyGoods.value})
|
||||
goLink('/pages/applyAfterSales/index',{id:orderInfo?.orderId})
|
||||
} else if (val == 3) {
|
||||
await openSubscriptionMessage({orderId: orderInfo?.orderId, scenes: ApplyGoods.value})
|
||||
onClick?.(val)
|
||||
} else if(val == 8) {
|
||||
applyRefund()
|
||||
} else {
|
||||
onClick?.(val)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//取消订单
|
||||
@ -194,6 +202,7 @@ export default memo(({orderInfo, onClick}:Param) => {
|
||||
title: '确定退款?',
|
||||
success: async function async (res) {
|
||||
if(res.confirm) {
|
||||
await openSubscriptionMessage({orderId: orderInfo?.orderId, scenes: ApplyGoods.value})
|
||||
let res = await fetchDataApplyRefund({sale_order_id: orderInfo?.orderId})
|
||||
if(res.success) {
|
||||
alert.success('申请成功')
|
||||
|
@ -13,7 +13,7 @@ import { formatHashTag, formatImgUrl, formatPriceDiv } from "@/common/fotmat";
|
||||
import { setParam } from "@/common/system";
|
||||
import { debounce } from "@/common/util";
|
||||
import Counter from "../counter";
|
||||
import { ApplyOrderAccessApi, GetAdminUserInfoApi } from "@/api/user";
|
||||
import { ApplyOrderAccessApi, GetAdminUserInfoApi, SubscriptionMessageApi } from "@/api/user";
|
||||
|
||||
type param = {
|
||||
show?: true|false,
|
||||
@ -213,9 +213,11 @@ export default ({show = false, onClose}: param) => {
|
||||
|
||||
//去结算
|
||||
const {fetchData: useFetchData} = GetAdminUserInfoApi()
|
||||
const {fetchData: applyOrderAccessFetchData} = ApplyOrderAccessApi()
|
||||
const orderDetail = debounce( async () => {
|
||||
let res = await useFetchData()
|
||||
if(res.data.order_access_status !== 3) {
|
||||
if(res.data.order_access_status == 1) applyOrderAccessFetchData()
|
||||
Taro.showModal({
|
||||
title: '提示',
|
||||
content: '暂未开通下单权限功能,稍后有客服联系您,请注意接受电话。',
|
||||
@ -223,7 +225,6 @@ export default ({show = false, onClose}: param) => {
|
||||
confirmText: '我知道',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消')
|
||||
}
|
||||
@ -256,7 +257,7 @@ export default ({show = false, onClose}: param) => {
|
||||
getShoppingCart()
|
||||
}
|
||||
}, 300)
|
||||
|
||||
|
||||
return (
|
||||
<View className={styles.shop_cart_main}>
|
||||
<Popup showTitle={false} show={showPopup} onClose={() => closePopup()} >
|
||||
|
@ -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";
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { SubscriptionMessageApi } from "@/api/user"
|
||||
import Taro from "@tarojs/taro"
|
||||
import dayjs from "dayjs"
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
|
||||
@ -58,3 +60,32 @@ export const useTimeCountDown = () => {
|
||||
timeStatus
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//订阅消息hook
|
||||
export const UseSubscriptionMessage = () => {
|
||||
const {fetchData: fetchDataMessage} = SubscriptionMessageApi()
|
||||
const openSubscriptionMessage = ({orderId = 0, scenes = 0}:{orderId?: number, scenes: number}) => {
|
||||
return new Promise(async (resolve) => {
|
||||
let params:{sale_order_id?: number, scenes?: number} = {}
|
||||
orderId&&(params.sale_order_id = orderId)
|
||||
params.scenes = scenes
|
||||
let res = await fetchDataMessage(params)
|
||||
if(res.success&&res.data.TemplateID&&res.data.TemplateID.length > 0) {
|
||||
Taro.requestSubscribeMessage({
|
||||
tmplIds: res.data.TemplateID,
|
||||
complete: function (res) {
|
||||
resolve(res)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
resolve(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
openSubscriptionMessage
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user