✨ feat(ID1000902):【内部小程序】订单补充发货信息
This commit is contained in:
parent
5e3b81e7ce
commit
35c6ecaf50
@ -85,3 +85,13 @@ export const GetClassList = () => {
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅模板id
|
||||
*/
|
||||
export const SubscriptionMessageApi = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mp/subscriptionMessage',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
@ -10,3 +10,14 @@ export const LoginApi = () => {
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @returns
|
||||
*/
|
||||
export const MpuserwechatBinding = () => {
|
||||
return useRequest({
|
||||
url: '/v1/mp/user/wechatBinding',
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import IconFont from '@/components/iconfont/iconfont'
|
||||
import { useSelector } from '@/reducers/hooks'
|
||||
import { TabBarType } from '@/constants/tabbar'
|
||||
import type { TabBarAction } from '@/reducers/tabBar'
|
||||
import { UseSubscriptionMessage } from '@/use/useCommon'
|
||||
|
||||
type IconfontName = Parameters<typeof IconFont>['0']['name']
|
||||
|
||||
@ -22,6 +23,8 @@ type TabBarIndexMap = Record<number, {
|
||||
}>
|
||||
|
||||
const CustomTabBar: FC = () => {
|
||||
const { openSubscriptionMessage } = UseSubscriptionMessage()
|
||||
|
||||
const { selectedId, tabItem } = useSelector((state) => {
|
||||
return state.tabBarData
|
||||
})
|
||||
@ -39,8 +42,12 @@ const CustomTabBar: FC = () => {
|
||||
dispatch({ type: TabBarType.SET_SELECTED, data: { tabItem, selectedId: id } })
|
||||
}
|
||||
const handleSelectTabItem = (id: TabBarIndexMap[number]['id']) => {
|
||||
return () => {
|
||||
return async() => {
|
||||
setSelected(id)
|
||||
if (id === 3) {
|
||||
await openSubscriptionMessage({ scenes: 1 })
|
||||
}
|
||||
console.log(id, 'item')
|
||||
Taro.switchTab({ url: tabItem?.find(item => item.id === id)?.pagePath as string })
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import Remark from '../orderDetails/components//remark'
|
||||
import styles from './index.module.scss'
|
||||
import Popup from '@/components/popup'
|
||||
import { debounce } from '@/common/util'
|
||||
import { UseSubscriptionMessage } from '@/use/useCommon'
|
||||
import {
|
||||
MpSaleOrderPost,
|
||||
MpSaleOrderPreview,
|
||||
@ -191,6 +192,7 @@ const SubmitOrder = () => {
|
||||
url: '/pages/addressManager/index?orderId=' + '-100' + `&purchaser_id=${router.params.purchaser_id}`,
|
||||
})
|
||||
}
|
||||
const { openSubscriptionMessage } = UseSubscriptionMessage()
|
||||
|
||||
// 提交订单
|
||||
const { fetchData: postFetch } = MpSaleOrderPost()
|
||||
@ -222,6 +224,7 @@ const SubmitOrder = () => {
|
||||
cancelText: '取消',
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
await openSubscriptionMessage({ scenes: 1 })
|
||||
Taro.showLoading({
|
||||
title: '请稍等...',
|
||||
mask: true,
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
page{
|
||||
page {
|
||||
position: relative;
|
||||
|
||||
}
|
||||
.main {
|
||||
background: linear-gradient(to bottom, $color_main 25%, $color_bg_one 42%);
|
||||
@ -29,7 +28,6 @@ page{
|
||||
font-size: 20px;
|
||||
background-color: rgba($color: #000000, $alpha: 0.33);
|
||||
}
|
||||
|
||||
}
|
||||
.topBar {
|
||||
display: flex;
|
||||
@ -59,21 +57,38 @@ page{
|
||||
display: block;
|
||||
font-size: 36px;
|
||||
font-weight: 600;
|
||||
@include common_ellipsis()
|
||||
@include common_ellipsis();
|
||||
}
|
||||
.userno {
|
||||
display: block;
|
||||
font-size: 28px;
|
||||
color: $color_font_two;
|
||||
@include common_ellipsis()
|
||||
@include common_ellipsis();
|
||||
}
|
||||
.userTitle {
|
||||
color: #626262;
|
||||
font-weight: 600;
|
||||
font-size: $font_size;
|
||||
margin-left: 20px;
|
||||
.flexBox {
|
||||
min-width: 80%;
|
||||
justify-content: space-between;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.userTitle {
|
||||
color: #626262;
|
||||
font-weight: 600;
|
||||
font-size: $font_size;
|
||||
margin-left: 20px;
|
||||
}
|
||||
.receiveBox {
|
||||
border: 2px solid #2596fe;
|
||||
width: 108px;
|
||||
text-align: center;
|
||||
line-height: 32px;
|
||||
height: 32px;
|
||||
border-radius: 10px;
|
||||
color: #1890ff;
|
||||
font-size: 22px;
|
||||
}
|
||||
}
|
||||
.grid-container{
|
||||
|
||||
.grid-container {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||
grid-column-gap: 32px;
|
||||
@ -91,7 +106,6 @@ page{
|
||||
font-weight: 600;
|
||||
color: $color_font_one;
|
||||
margin-bottom: 20px;
|
||||
|
||||
}
|
||||
.layoutDescription {
|
||||
font-size: 24px;
|
||||
|
||||
@ -19,6 +19,7 @@ import type { IconNames } from '@/components/iconfont/iconfont'
|
||||
import useUserInfo from '@/use/useUserInfo'
|
||||
import { useSelector } from '@/reducers/hooks'
|
||||
import { BASE_URL } from '@/common/constant'
|
||||
import useGetCode from '@/use/useGetCode'
|
||||
|
||||
// 用户头像
|
||||
const UserAvatar = ({ src }: { src?: string }) => {
|
||||
@ -182,6 +183,16 @@ const UserInfo: FC = () => {
|
||||
setStatistics([...arrTwo])
|
||||
})
|
||||
|
||||
// 微信授权获取code
|
||||
const { UseGetCode } = useGetCode()
|
||||
const handReceive = async() => {
|
||||
try {
|
||||
await UseGetCode()
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err, 'err')
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<LayoutBlock circle customStyle={{ paddingTop: '10px', paddingBottom: '10px' }}>
|
||||
@ -206,7 +217,10 @@ const UserInfo: FC = () => {
|
||||
</Tag>
|
||||
<Divider direction="vertical"></Divider>
|
||||
{/* 职责 */}
|
||||
<Text className={styles.userTitle}>{userInfo.userInfo.duty_name}</Text>
|
||||
<View className={styles.flexBox}>
|
||||
<Text className={styles.userTitle}>{userInfo.userInfo.duty_name}</Text>
|
||||
<View className={styles.receiveBox} onClick={() => handReceive()}>接收消息</View>
|
||||
</View>
|
||||
</View>
|
||||
</LayoutBlock>
|
||||
{
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { useRouter } from '@tarojs/taro'
|
||||
import Taro, { useRouter } from '@tarojs/taro'
|
||||
import dayjs from 'dayjs'
|
||||
import type { SetStateAction } from 'react'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useSelector } from '@/reducers/hooks'
|
||||
|
||||
import { SubscriptionMessageApi } from '@/api/index'
|
||||
// 倒计时hook
|
||||
export const useTimeCountDown = () => {
|
||||
const [showTime, setShowTime] = useState({
|
||||
@ -65,31 +65,34 @@ export const useTimeCountDown = () => {
|
||||
}
|
||||
|
||||
// 订阅消息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)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
export const UseSubscriptionMessage = () => {
|
||||
const { fetchData: fetchDataMessage } = SubscriptionMessageApi()
|
||||
const openSubscriptionMessage = ({ orderId = 0, scenes = 0 }: { orderId?: number; scenes: number }) => {
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async(resolve) => {
|
||||
const params: { sale_order_id?: number; scenes?: number } = {}
|
||||
orderId && (params.sale_order_id = orderId)
|
||||
params.scenes = scenes
|
||||
const res = await fetchDataMessage(params)
|
||||
if (res.success && res.data.TemplateID && res.data.TemplateID.length > 0) {
|
||||
Taro.requestSubscribeMessage({
|
||||
tmplIds: res.data.TemplateID,
|
||||
complete(res) {
|
||||
console.log('qqqqqq')
|
||||
resolve(res)
|
||||
},
|
||||
})
|
||||
}
|
||||
else {
|
||||
resolve(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// return {
|
||||
// openSubscriptionMessage,
|
||||
// }
|
||||
// }
|
||||
return {
|
||||
openSubscriptionMessage,
|
||||
}
|
||||
}
|
||||
|
||||
type NormalPropsType = Record<string | symbol | number, any>
|
||||
interface Options {
|
||||
|
||||
38
src/use/useGetCode.ts
Normal file
38
src/use/useGetCode.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import Taro, { useRouter } from '@tarojs/taro'
|
||||
import { alert } from '@/common/common'
|
||||
import { MpuserwechatBinding } from '@/api/login/login'
|
||||
import useUserInfo from '@/use/useUserInfo'
|
||||
|
||||
export default () => {
|
||||
const { fetchData: loginFetch } = MpuserwechatBinding()
|
||||
const { setToken, setSessionKey, setUserInfo, userInfo } = useUserInfo()
|
||||
|
||||
const UseGetCode = () => {
|
||||
Taro.login({
|
||||
async success(res) {
|
||||
const code = res.code
|
||||
if (code) {
|
||||
console.log(`获取用户登录凭证:${code}`)
|
||||
const state = await loginFetch({ js_code: code, user_id: userInfo.userInfo.user_id })
|
||||
if (state.data) {
|
||||
// setToken(state.data.token)
|
||||
setSessionKey(state.data.session_key)
|
||||
// setUserInfo({ ...userInfo.userInfo, token: state?.data?.token || '' })
|
||||
alert.none('链接成功,可开始接收服务信息啦!')
|
||||
}
|
||||
else {
|
||||
return alert.none(`${state?.msg}`)
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log(`获取用户登录态失败:${res.errMsg}`)
|
||||
return alert.error(`${res?.errMsg}`)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
UseGetCode,
|
||||
}
|
||||
}
|
||||
@ -148,7 +148,7 @@ export const useRequest = (
|
||||
...{
|
||||
header: {
|
||||
Platform: 3,
|
||||
// Appid: WX_APPID,
|
||||
Appid: WX_APPID,
|
||||
Authorization: token || stateRef.current.token,
|
||||
},
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user