diff --git a/src/api/order.ts b/src/api/order.ts index e3f35cd..9de7525 100644 --- a/src/api/order.ts +++ b/src/api/order.ts @@ -41,4 +41,13 @@ export const adoptionGiveOther = (data) => { method: 'PUT', data }) +} + +// 接受赠送 +export const receiveGift = (data) => { + return request({ + url: 'wechat/v1/adoption-order/receiveGift', + method: 'PUT', + data + }) } \ No newline at end of file diff --git a/src/pageMe/inviteFriends/index.tsx b/src/pageMe/inviteFriends/index.tsx index 1cdd878..48a6949 100644 --- a/src/pageMe/inviteFriends/index.tsx +++ b/src/pageMe/inviteFriends/index.tsx @@ -25,7 +25,7 @@ export default function InviteFriends() { const { data } = await adoptionOrderPage({ serialNumber: "JHLS202407012565376", pageNo: 1, - pageSize: 20, + pageSize: 100, openId: userOpenId }) const { list } = data; diff --git a/src/pageMe/myOrder/index.tsx b/src/pageMe/myOrder/index.tsx index 47ad806..098c85c 100644 --- a/src/pageMe/myOrder/index.tsx +++ b/src/pageMe/myOrder/index.tsx @@ -4,8 +4,8 @@ import HeaderNation from "../../components/HeaderNation"; import OuterFrame from "../../components/OuterFrame"; import StatusBar from "../../components/StatusBar"; import Divider from "../../components/Divider"; -import { orderPage } from "../../api/order"; -import { useEffect, useState } from "react"; +import { adoptionOrderPage } from "../../api/user"; +import { useState } from "react"; import Taro, { useDidShow } from "@tarojs/taro"; import NoData from "../../components/NoData"; import * as dayjs from 'dayjs' @@ -36,7 +36,7 @@ export default function MyOrder() { const openId = Taro.getStorageSync("USER_OPEN_ID") const [dataList, setDataList] = useState>([]) const getDataList = async () => { - const { data } = await orderPage({ + const { data } = await adoptionOrderPage({ pageNo: 1, pageSize: 100, serialNumber: 'JHLS202407012565376', diff --git a/src/pages/login/index.tsx b/src/pages/login/index.tsx index c528d1d..2b14412 100644 --- a/src/pages/login/index.tsx +++ b/src/pages/login/index.tsx @@ -4,20 +4,50 @@ import { useEffect, useState } from "react" import LoginForm from "../../components/LoginForm" import { supabase } from "../../api/supabaseClient" import { createUser, getPlan, getUserByCode } from "../../api/user" +import { receiveGift } from '../../api/order' import { IMG_BASE_URL } from "../../config" import useStore from "../../storage/index" const loginBg = IMG_BASE_URL + 'pages/bg.png' const Login = () => { + const [showForm, setShowForm] = useState(true) const userOpenId = Taro.getStorageSync("USER_OPEN_ID") - if (userOpenId) { - Taro.redirectTo({ url: '/pagesHome/index' }) - return null + + // 接受订单? + const acceptOrder = () => { + Taro.showModal({ + title: '接受赠送订单', + content: '是否接受朋友赠送的订单?', + success: async (res) => { + if (res.confirm) { + console.log('用户点击确定') + const { data } = await receiveGift({ + orderId: shareId, + receivedId: userOpenId + '_' + new Date().valueOf().toString() + }) + Taro.redirectTo({ url: '/pagesHome/index' }) + } else if (res.cancel) { + Taro.redirectTo({ url: '/pagesHome/index' }) + } + } + }) } + const { router } = getCurrentInstance() // 通过分享链接打开此页面, shareId 其实是 orderNumber const shareId = router && router.params && router.params.shareId console.log("通过分享链接打开,shareId=", shareId); + if (userOpenId) { + if (shareId) { + // 如果用户已经登录,但是有朋友赠送的订单 + // 不显示设置头像昵称弹窗,显示是否接受赠送 + setShowForm(false) + acceptOrder() + } else { + Taro.redirectTo({ url: '/pagesHome/index' }) + return null + } + } // Taro.navigateTo({ url: '/pageMe/myCertificate/index' }) const setUserAvatar = useStore((store:any) => store.setUserAvatar) @@ -50,7 +80,7 @@ const Login = () => { useEffect(() => { checkUserStatus() }, []) - const [showForm, setShowForm] = useState(true) + return ( @@ -111,7 +141,11 @@ const Login = () => { if (_data.buyerImg) setUserAvatar(_data.buyerImg) if (_data.nickName) setUserName(_data.nickName) Taro.setStorage({ key: 'USER_OPEN_ID', data: data1.openid }) - Taro.redirectTo({ url: '/pagesHome/index' }) + if (shareId) { + acceptOrder() + } else { + Taro.redirectTo({ url: '/pagesHome/index' }) + } } }} /> diff --git a/src/pagesHome/monitor.tsx b/src/pagesHome/monitor.tsx index 21ab789..e7f1dca 100644 --- a/src/pagesHome/monitor.tsx +++ b/src/pagesHome/monitor.tsx @@ -143,14 +143,18 @@ export default function Monitor() { const openId = Taro.getStorageSync("USER_OPEN_ID") const { data } = await adoptionOrderPage({ pageNo: 1, - pageSize: 5, + pageSize: 100, serialNumber: 'JHLS202407012565376', openId }) const { list } = data if (Array.isArray(list)) { console.log("LIST", list); - setAdoptionNum(list.length) + setAdoptionNum(list.filter(item => { + // TODO: 在这里把取消的订单和未付款的订单过滤掉 + if (item.status === '0' || item.status === '4') return false; + return true + }).length) } } useEffect(() => { getAdoptionOrderInfo() }, []) @@ -172,14 +176,18 @@ export default function Monitor() { const { data } = await adoptionOrderPage({ serialNumber: 'JHLS202407012565376', pageNo: 1, - pageSize: 10, + pageSize: 100, openId: userOpenId }) const { list } = data; console.log("LIII", list); if (Array.isArray(list)) { - const details = list.map(item => (item.detail.specs)) + const details = list.filter(item => { + if (!item.detail) return false + if (item.status === '0' || item.status === '4') return false; + return true + }).map(item => (item.detail.specs)) console.log("LIST111", details); let specsArr:any = [] diff --git a/src/pagesHome/plotSelector.tsx b/src/pagesHome/plotSelector.tsx index d0d5c0c..78bfafb 100644 --- a/src/pagesHome/plotSelector.tsx +++ b/src/pagesHome/plotSelector.tsx @@ -161,19 +161,19 @@ export default function PlotSelector({ selected, onChange }) { const { data } = await adoptionOrderPage({ openId: userOpenId, pageNo: 1, - pageSize: 20, + pageSize: 100, serialNumber: 'JHLS202407012565376' }) const { list } = data; console.log("认养订单", list); if (Array.isArray(list)) { - setMyOrderIdList(list.map(item => (item.plotId))) - console.log("list.map(item => (item.id))", list.map(item => (item.plotId))); - + // TODO: 把取消付款的过滤掉 + setMyOrderIdList(list.filter(item => { + if (item.status === '0' || item.status === '4') return false + return true + }).map(item => (item.plotId))) } - - } useEffect(() => { getOrderList() }, []) diff --git a/src/userInfo/confirmOrder/index.tsx b/src/userInfo/confirmOrder/index.tsx index c18b95f..fb67ce6 100644 --- a/src/userInfo/confirmOrder/index.tsx +++ b/src/userInfo/confirmOrder/index.tsx @@ -6,10 +6,9 @@ import { APP_FULL_HEIGHT, formatMoney, IMG_BASE_URL } from "../../config"; import { useEffect, useState } from "react"; import arrow from './assets/arrow.png' import Taro, { getCurrentInstance, useDidShow } from "@tarojs/taro" -import { adoptionOrderUpdate, orderPage, getOrderInfoById } from "../../api/order"; +import { adoptionOrderUpdate, getOrderInfoById } from "../../api/order"; import * as dayjs from 'dayjs' import useStore from "../../storage"; -import { addressPage } from "../../api/me"; const positionIcon = IMG_BASE_URL + 'position.png' @@ -166,7 +165,7 @@ export default function ConfirmOrder() { 倒计时: - + {