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