feat: 主要完成了分享功能
This commit is contained in:
parent
d8d5469671
commit
9fa8c96910
@ -48,6 +48,7 @@ const config = {
|
||||
},
|
||||
webpackChain(chain, webpack) {
|
||||
chain.merge({
|
||||
performance: { maxEntrypointSize: 100000000, maxAssetSize: 300000000 },
|
||||
plugin: {
|
||||
install: {
|
||||
plugin: UnifiedWebpackPluginV5,
|
||||
|
@ -5,8 +5,8 @@
|
||||
"appid": "wx2062eafa5dfc8ffb",
|
||||
"setting": {
|
||||
"urlCheck": true,
|
||||
"es6": true,
|
||||
"enhance": true,
|
||||
"es6": false,
|
||||
"enhance": false,
|
||||
"compileHotReLoad": false,
|
||||
"postcss": false,
|
||||
"preloadBackgroundData": false,
|
||||
|
@ -3,6 +3,6 @@
|
||||
"projectname": "crab-wxapp",
|
||||
"setting": {
|
||||
"compileHotReLoad": true,
|
||||
"urlCheck": true
|
||||
"urlCheck": false
|
||||
}
|
||||
}
|
@ -28,7 +28,6 @@ export const request = ({
|
||||
}
|
||||
if (isToken) header['Authorization'] = 'Bearer ' + Taro.getStorageSync('token')
|
||||
Taro.showLoading({ title: '加载中...' })
|
||||
console.log("发起请求中");
|
||||
|
||||
wx.request({
|
||||
url: baseUrl + url + (requestParams ? ('?' + requestParams) : ''),
|
||||
|
@ -30,4 +30,12 @@ export const addressDelete = (params) => {
|
||||
method: 'DELETE',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
export const updateAddress = (data) => {
|
||||
return request({
|
||||
url: 'wechat/v1/adoption-order/updateaddress',
|
||||
method: 'PUT',
|
||||
data
|
||||
})
|
||||
}
|
@ -25,10 +25,20 @@ export const tickPage = (params) => {
|
||||
})
|
||||
}
|
||||
|
||||
// 根据ID获取订单信息
|
||||
export const getOrderInfoById = (params) => {
|
||||
return request({
|
||||
url: 'wechat/v1/ticket/page',
|
||||
url: 'wechat/v1/adoption-order/get',
|
||||
method: 'GET',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
// 赠送好友
|
||||
export const adoptionGiveOther = (data) => {
|
||||
return request({
|
||||
url: 'wechat/v1/adoption-order/giveOther',
|
||||
method: 'PUT',
|
||||
data
|
||||
})
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import { Image, View, PageContainer, Input } from "@tarojs/components";
|
||||
import { Image, View, PageContainer, Input, Button } from "@tarojs/components";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { useState } from "react";
|
||||
import { APPID, IMG_BASE_URL, SECRET } from "../../config";
|
||||
import { IMG_BASE_URL } from "../../config";
|
||||
|
||||
const larvea = IMG_BASE_URL + 'pagesHome/larvea.png'
|
||||
|
||||
@ -9,7 +9,7 @@ export default function LoginForm(props) {
|
||||
const { show, setShow, onConfirm } = props
|
||||
const [userNickName, setUserNickName] = useState<string>('')
|
||||
const [userSignature, setUserSignature] = useState<string>('')
|
||||
const [avatar, setAvatar] = useState<string>('')
|
||||
const [avatar, setAvatar] = useState<string>(larvea)
|
||||
return (
|
||||
<PageContainer
|
||||
show={show}
|
||||
@ -21,60 +21,36 @@ export default function LoginForm(props) {
|
||||
<View className="px-5 py-5 pb-8">
|
||||
<View>设置你的头像和昵称</View>
|
||||
<View className="w-full flex flex-col items-center">
|
||||
<View className="rounded-full p-1 bg-white py-[1rem]" onClick={() => {
|
||||
Taro.chooseImage({
|
||||
success: (e) => {
|
||||
console.log("e", e);
|
||||
console.log("e", e);
|
||||
const { tempFilePaths } = e;
|
||||
if (Array.isArray(tempFilePaths) && tempFilePaths.length === 0) return
|
||||
let res = ''
|
||||
try {
|
||||
const base64 = Taro.getFileSystemManager().readFileSync(tempFilePaths[0], "base64");
|
||||
if (base64) {
|
||||
res = "data:image/jpg;base64," + base64;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("=> utilssearch.ts error imgToBase64", error);
|
||||
throw error;
|
||||
} finally {
|
||||
setAvatar(res)
|
||||
}
|
||||
}
|
||||
})
|
||||
}}>
|
||||
<View className="w-[120px] h-[120px] rounded-full overflow-hidden relative">
|
||||
<Image src={avatar ? avatar : larvea} className="w-full h-full" mode="aspectFill" />
|
||||
<View className="rounded-full p-1 bg-white py-[1rem]">
|
||||
<Button openType="chooseAvatar" onChooseAvatar={(e) => {
|
||||
const tempAvatarUrl = e.detail.avatarUrl
|
||||
if (!tempAvatarUrl) return
|
||||
let res = ''
|
||||
try {
|
||||
const base64 = Taro.getFileSystemManager().readFileSync(tempAvatarUrl, "base64");
|
||||
if (base64) res = "data:image/jpg;base64," + base64;
|
||||
} catch (error) {
|
||||
console.warn("=> utilssearch.ts error imgToBase64", error);
|
||||
throw error;
|
||||
} finally { setAvatar(res) }
|
||||
}} className="w-[120px] h-[120px] rounded-full overflow-hidden relative p-0">
|
||||
<Image src={avatar} className="w-[120px] h-[120px]" mode="aspectFit" />
|
||||
<View className="flex justify-center w-full py-[.1rem] absolute bottom-0 bg-[#00000090] text-[#fff] text-[.6rem]">
|
||||
设置
|
||||
</View>
|
||||
</View>
|
||||
</Button>
|
||||
</View>
|
||||
<View className="p-[1rem] mb-[.8rem] rounded-[.3rem] bg-[#f5f5f5] shadow-md w-[88%] flex justify-between items-center">
|
||||
<Input value={userNickName} placeholder="请输入昵称" style={{ width: 'calc(100% - 6rem)' }} onInput={(e) => {
|
||||
setUserNickName((e.target as any).value)
|
||||
}} />
|
||||
<View className="text-[#5EC45F]" onClick={() => {
|
||||
Taro.getUserProfile({
|
||||
desc: '用于完善会员资料',
|
||||
success: async (res) => {
|
||||
const { userInfo, signature } = res;
|
||||
const { nickName, avatarUrl } = userInfo;
|
||||
if (nickName) setUserNickName(nickName)
|
||||
if (avatarUrl) setAvatar(avatarUrl)
|
||||
Taro.login({
|
||||
success: (_res) => {
|
||||
console.log("RES LOGIN", _res);
|
||||
const { code } = _res
|
||||
if (signature) setUserSignature(code) // 先用code顶替
|
||||
}
|
||||
})
|
||||
},
|
||||
fail: (error) => {
|
||||
console.warn("error", error);
|
||||
}
|
||||
})
|
||||
}}>使用微信昵称</View>
|
||||
<Input
|
||||
type="nickname"
|
||||
value={userNickName}
|
||||
placeholder="请输入昵称"
|
||||
style={{ width: 'calc(100% - 6rem)' }}
|
||||
onInput={(e) => {
|
||||
console.log("nickName =>", e);
|
||||
setUserNickName((e.target as any).value)
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<View
|
||||
className="text-[#ffffff] rounded-full flex justify-center items-center !bg-[#5ec45f] !w-[88%] py-3 h-[3rem] mb-[2rem]"
|
||||
@ -92,6 +68,11 @@ export default function LoginForm(props) {
|
||||
success: (_res_) => {
|
||||
const { code } = _res_
|
||||
if (code) setUserSignature(code)
|
||||
if (onConfirm) onConfirm({
|
||||
openId: code,
|
||||
nickName: userNickName,
|
||||
buyerImg: avatar
|
||||
})
|
||||
},
|
||||
fail: () => {
|
||||
Taro.showToast({
|
||||
|
@ -1,11 +1,12 @@
|
||||
import { View, ScrollView, Image, Text } from "@tarojs/components";
|
||||
import { View, ScrollView, Image, Text, Button } from "@tarojs/components";
|
||||
import { APP_FULL_HEIGHT, formatMoney, IMG_BASE_URL } from "../../config";
|
||||
import HeaderNation from "../../components/HeaderNation";
|
||||
import OuterFrame from "../../components/OuterFrame";
|
||||
import StatusBar from "../../components/StatusBar";
|
||||
import Taro, { getCurrentInstance } from "@tarojs/taro"
|
||||
import Taro, { getCurrentInstance, useShareAppMessage } from "@tarojs/taro"
|
||||
import { useEffect, useState } from "react";
|
||||
import { adoptionOrderPage } from "../../api/user";
|
||||
import { adoptionGiveOther } from '../../api/order'
|
||||
import dayjs from "dayjs";
|
||||
|
||||
const poster1 = IMG_BASE_URL + 'pageMe/poster1.png'
|
||||
@ -31,11 +32,42 @@ export default function InviteFriends() {
|
||||
console.log("订单", list);
|
||||
|
||||
if (Array.isArray(list)) {
|
||||
const _item = list.filter(item => item.id === id)
|
||||
const _item = list.filter(item => item.orderNumber === id)
|
||||
console.log("选中订单", _item);
|
||||
|
||||
if (_item.length > 0) setCurOrderItem(_item[0])
|
||||
}
|
||||
}
|
||||
useEffect(() => { getOrderInfo() }, [])
|
||||
|
||||
useShareAppMessage(async (res) => {
|
||||
const userOpenId = Taro.getStorageSync("USER_OPEN_ID")
|
||||
const { data } = await adoptionGiveOther({
|
||||
originalOrderNumber: id,
|
||||
openId: userOpenId
|
||||
})
|
||||
console.log("赠送接口返回", data);
|
||||
if (!data) {
|
||||
Taro.showToast({
|
||||
title: '赠送失败!',
|
||||
icon: 'error',
|
||||
duration: 1400
|
||||
})
|
||||
return {}
|
||||
}
|
||||
console.log("useShareAppMessage", res)
|
||||
if (res.from === 'button') {
|
||||
// 来自页面内分享按钮
|
||||
} else {
|
||||
// 右上角分享好友
|
||||
}
|
||||
|
||||
return {
|
||||
title: '大闸蟹认养小程序', // 分享卡片的title
|
||||
path: 'pages/login/index?shareId=' + curOrderItem.orderNumber, // 分享卡片的小程序路径
|
||||
imageUrl: poster1 // 分享卡片的图片链接
|
||||
};
|
||||
})
|
||||
return (
|
||||
<OuterFrame>
|
||||
<StatusBar />
|
||||
@ -100,7 +132,7 @@ export default function InviteFriends() {
|
||||
</ScrollView>
|
||||
<View style={{ height: bottomNavBarHeight + 'px' }} className="flex flex-col items-center pt-2">
|
||||
<View className="pb-2 text-[24px] text-[#5EC45F]">让我们一起来云养蟹吧!</View>
|
||||
<View className="primary-btn w-[85%] h-[2.3rem]">赠送好友</View>
|
||||
<Button openType="share" className="bg-[#70cc37] rounded-full w-[85%] text-[#fff]">赠送好友</Button>
|
||||
</View>
|
||||
</OuterFrame>
|
||||
)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { View, ScrollView, Image, Text } from "@tarojs/components";
|
||||
import { View, ScrollView, Image, Text, Button } from "@tarojs/components";
|
||||
import { APP_FULL_HEIGHT, IMG_BASE_URL } from "../../config";
|
||||
import HeaderNation from "../../components/HeaderNation";
|
||||
import OuterFrame from "../../components/OuterFrame";
|
||||
@ -47,19 +47,21 @@ export default function MyCertificate() {
|
||||
<Image src={card} className="w-full relative z-0 absolute top-0 left-0" mode="widthFix" />
|
||||
</View>
|
||||
</ScrollView>
|
||||
<View style={{ height: bottomNavBarHeight + 'px' }} className="flex justify-evenly pt-2">
|
||||
<View className="default-btn w-[45%] h-[2.3rem]">赠送好友</View>
|
||||
<View className="primary-btn w-[45%] h-[2.3rem]" onClick={() => {
|
||||
<View style={{ height: bottomNavBarHeight + 'px' }} className="flex justify-evenly pt-0 items-center">
|
||||
<Button className="w-[45%] rounded-full bg-[#fff] text-[#74ce38] shadow-md" onClick={() => {
|
||||
Taro.navigateBack()
|
||||
Taro.navigateTo({ url: '/pageMe/myOrder/index' })
|
||||
}}>赠送好友</Button>
|
||||
<Button openType="share" className="w-[45%] rounded-full bg-[#74ce38] text-[#fff]" onClick={() => {
|
||||
Taro.useShareAppMessage(() => {
|
||||
console.log("SSS");
|
||||
|
||||
return {
|
||||
title: '这是一个分享页面', // 分享卡片的title
|
||||
path: 'pageMe/inviteFriends/index', // 分享卡片的小程序路径
|
||||
imageUrl: card // 分享卡片的图片链接
|
||||
}
|
||||
})
|
||||
}}>保存并分享</View>
|
||||
// Taro.showShareMenu({ withShareTicket: true })
|
||||
}}>保存并分享</Button>
|
||||
</View>
|
||||
</OuterFrame>
|
||||
)
|
||||
|
@ -57,7 +57,7 @@ export default function MyOrder() {
|
||||
<View className="flex justify-between items-start py-1 pb-2">
|
||||
<View className="pr-3 grow">{item.planName}</View>
|
||||
<View
|
||||
className="text-[#fa6642] w-[4rem] break-normal"
|
||||
className="text-[#fa6642] w-[4.6rem] break-normal"
|
||||
style={{
|
||||
color: item.status === '0' ? '#fa6642' : '#1ed76d'
|
||||
}}
|
||||
@ -70,15 +70,16 @@ export default function MyOrder() {
|
||||
</View>
|
||||
<View className="flex justify-between items-center">
|
||||
<View className="text-[#999999] text-[20px]">{dayjs(item.createTime).format('YYYY-MM-DD HH:mm:ss')}</View>
|
||||
<View
|
||||
className="primary-btn !px-2 !py-1 text-[.8rem]"
|
||||
onClick={() => {
|
||||
if (item.status === '0') Taro.navigateTo({ url: '/userInfo/confirmOrder/index?id=' + item.id }) // 未付款
|
||||
if (item.status === '1') Taro.navigateTo({ url: '/pageMe/inviteFriends/index?id=' + item.id }) // 送好友
|
||||
}}
|
||||
>{
|
||||
OperationMap[item.status]
|
||||
}</View>
|
||||
<View
|
||||
className="primary-btn !px-2 !py-1 text-[.8rem]"
|
||||
style={{ display: item.isPresented === '1' ? 'none' : 'block' }}
|
||||
onClick={() => {
|
||||
if (item.status === '0') Taro.navigateTo({ url: '/userInfo/confirmOrder/index?id=' + item.id }) // 未付款
|
||||
if (item.status === '1') Taro.navigateTo({ url: '/pageMe/inviteFriends/index?id=' + item.orderNumber }) // 送好友
|
||||
}}
|
||||
>{
|
||||
OperationMap[item.status]
|
||||
}</View>
|
||||
</View>
|
||||
<View
|
||||
className="bg-[#F4F7F3] text-[#5EC45F] text-[20px] p-[.4rem] px-2 mt-2 mb-[-.3rem]"
|
||||
|
@ -1,14 +1,15 @@
|
||||
import { View, ScrollView, Image, Text } from "@tarojs/components";
|
||||
import { View, ScrollView, Image, Text, Button } from "@tarojs/components";
|
||||
import { APP_FULL_HEIGHT, IMG_BASE_URL } from "../../config";
|
||||
import HeaderNation from "../../components/HeaderNation";
|
||||
import OuterFrame from "../../components/OuterFrame";
|
||||
import StatusBar from "../../components/StatusBar";
|
||||
import Taro from "@tarojs/taro"
|
||||
import Taro, { useShareAppMessage } from "@tarojs/taro"
|
||||
import './index.scss'
|
||||
import { useEffect, useState } from "react";
|
||||
import { adoptionOrderCircle } from "../../api/adoption";
|
||||
|
||||
const imgBg = IMG_BASE_URL + 'pages/bg_new.png'
|
||||
const homeBigBg = IMG_BASE_URL + '/pagesHome/homeBigBg.png'
|
||||
|
||||
interface CrabOwerItem {
|
||||
id: string
|
||||
@ -56,6 +57,14 @@ export default function AdoptionCircle() {
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
useShareAppMessage(() => {
|
||||
return {
|
||||
title: '大闸蟹认养小程序', // 分享卡片的title
|
||||
path: 'pages/login/index', // 分享卡片的小程序路径
|
||||
imageUrl: imgBg // 分享卡片的图片链接
|
||||
};
|
||||
})
|
||||
return (
|
||||
<OuterFrame>
|
||||
<StatusBar />
|
||||
@ -78,7 +87,7 @@ export default function AdoptionCircle() {
|
||||
<View className="w-full bg-white box-border text-[25px] grow shadow-xl rounded-xl">
|
||||
<View className="bg-[#f2fbeb] rounded-md p-3 px-5 flex items-center justify-between">
|
||||
<View className="text-[#5D8D4F]">邀请好友认养,提升好人缘!</View>
|
||||
<View className="bg-[#5ec45f] p-[8px] px-4 rounded-full text-white">分享</View>
|
||||
<Button openType="share" className="bg-[#5ec45f] rounded-full text-white text-[23px] mx-0">分享</Button>
|
||||
</View>
|
||||
<ScrollView
|
||||
type="nested"
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Button, Input, View, Image } from "@tarojs/components"
|
||||
import Taro from "@tarojs/taro"
|
||||
import Taro, { getCurrentInstance } from "@tarojs/taro"
|
||||
import { useEffect, useState } from "react"
|
||||
import LoginForm from "../../components/LoginForm"
|
||||
import { supabase } from "../../api/supabaseClient"
|
||||
@ -9,6 +9,11 @@ import useStore from "../../storage/index"
|
||||
|
||||
const loginBg = IMG_BASE_URL + 'pages/bg.png'
|
||||
const Login = () => {
|
||||
const { router } = getCurrentInstance()
|
||||
// 通过分享链接打开此页面, shareId 其实是 orderNumber
|
||||
const shareId = router && router.params && router.params.shareId
|
||||
console.log("通过分享链接打开,shareId=", shareId);
|
||||
|
||||
// Taro.navigateTo({ url: '/pageMe/myCertificate/index' })
|
||||
const setUserAvatar = useStore((store:any) => store.setUserAvatar)
|
||||
const setUserName = useStore((store:any) => store.setUserName)
|
||||
|
@ -84,6 +84,7 @@ export default function Adoption() {
|
||||
if (Array.isArray(data)) setRuleList(data.map(item => ({ ...item, value: 0 })))
|
||||
}
|
||||
const applyCount = (id, value) => {
|
||||
if (value < 0) return
|
||||
setRuleList(ruleList.map(item => {
|
||||
if (item.id === id) return { ...item, value }
|
||||
return item
|
||||
@ -219,16 +220,13 @@ export default function Adoption() {
|
||||
<View className="flex justify-between py-1 text-[24px] items-center">
|
||||
<View>{item.specs}(¥{formatMoney(item.singlePrice)}/份)</View>
|
||||
<View className="flex space-x-1 items-center">
|
||||
<View className="relative z-10 px-1" onClick={() => {
|
||||
applyCount(item.id, item.value-- )
|
||||
<View className="relative z-10 w-[1.3rem] h-[1.3rem] text-[.9rem] bg-[#f5f5f5] flex justify-center items-center" onClick={() => {
|
||||
applyCount(item.id, item.value - 1 )
|
||||
}}>-</View>
|
||||
<Input value={item.value} className="w-[2.4rem] text-[.6rem] text-center relative z-0" type='number' placeholder='选择数量' onInput={(e) => {
|
||||
console.log("rule Input", e.target);
|
||||
<Input disabled value={item.value} className="w-[2.1rem] text-[.6rem] text-center relative z-0 mx-1" type='number' placeholder='选择数量' onInput={(e) => {
|
||||
applyCount(item.id, +(e.target as any).value)
|
||||
}}/>
|
||||
<View className="relative z-10 px-1" onClick={() => {
|
||||
console.log("+1", item.value + 1);
|
||||
|
||||
<View className="relative z-10 w-[1.3rem] h-[1.3rem] text-[.9rem] bg-[#f5f5f5] flex justify-center items-center" onClick={() => {
|
||||
applyCount(item.id, item.value + 1 )
|
||||
}}>+</View>
|
||||
</View>
|
||||
@ -244,13 +242,15 @@ export default function Adoption() {
|
||||
<View>(¥5/只)</View>
|
||||
</View>
|
||||
<View className="flex space-x-1 items-center">
|
||||
<View className="relative z-10 px-1" onClick={() => {
|
||||
setAmountCount((parseInt(amountCount) - 1).toString())
|
||||
<View className="relative z-10 w-[1.3rem] h-[1.3rem] text-[.9rem] bg-[#f5f5f5] flex justify-center items-center" onClick={() => {
|
||||
const _val = parseInt(amountCount) - 1
|
||||
if (_val < 0) return
|
||||
setAmountCount(_val.toString())
|
||||
}}>-</View>
|
||||
<Input value={amountCount} className="w-[2.4rem] text-[.6rem] text-center relative z-0" type='number' placeholder='选择数量' onInput={(e) => {
|
||||
<Input disabled value={amountCount} className="w-[2.4rem] text-[.6rem] text-center relative z-0" type='number' placeholder='选择数量' onInput={(e) => {
|
||||
setAmountCount((e.target as any).value)
|
||||
}}/>
|
||||
<View className="relative z-10 px-1" onClick={() => {
|
||||
<View className="relative z-10 w-[1.3rem] h-[1.3rem] text-[.9rem] bg-[#f5f5f5] flex justify-center items-center" onClick={() => {
|
||||
setAmountCount((parseInt(amountCount) + 1).toString())
|
||||
}}>+</View>
|
||||
</View>
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { View,Image,Text, ScrollView } from "@tarojs/components";
|
||||
import { View,Image,Text, ScrollView, Button } from "@tarojs/components";
|
||||
import './index.scss'
|
||||
import Taro from "@tarojs/taro";
|
||||
import Taro, { useShareAppMessage } from "@tarojs/taro";
|
||||
import { IMG_BASE_URL } from "../config";
|
||||
import useStore from "../storage";
|
||||
import { useEffect, useState } from "react";
|
||||
@ -25,7 +25,7 @@ const CropGrowth = ({ belongPlot, type, updatePeriod }) => {
|
||||
const { list } = data;
|
||||
console.log("getDataList", list);
|
||||
if (Array.isArray(list)) {
|
||||
setDataList(list)
|
||||
setDataList(list.map(item => ({ ...item, imgId: item.imgId.replace("http://117.73.12.97:9000", "https://www.zhuangbeizz.cn/minio")})))
|
||||
if (list.length > 0) {
|
||||
updatePeriod(list[0])
|
||||
}
|
||||
@ -191,6 +191,14 @@ export default function Monitor() {
|
||||
}
|
||||
}
|
||||
useEffect(() => { getMyOrder() }, [])
|
||||
|
||||
useShareAppMessage(() => {
|
||||
return {
|
||||
title: '大闸蟹认养小程序', // 分享卡片的title
|
||||
path: 'pages/login/index', // 分享卡片的小程序路径
|
||||
imageUrl: headerBg // 分享卡片的图片链接
|
||||
};
|
||||
})
|
||||
return (
|
||||
<View className="relative">
|
||||
<AdoptionCircle />
|
||||
@ -219,10 +227,10 @@ export default function Monitor() {
|
||||
<View className="text-[22px] mt-1">大闸蟹当前状态</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className="flex items-center justify-center rounded-full px-[12px] py-[5px]" style={{ border: '1px solid #5EC45F' }}>
|
||||
<Button openType="share" className="flex items-center justify-center rounded-full mx-0" style={{ border: '1px solid #5EC45F' }}>
|
||||
<Image src={shareIcon} className="w-[.8rem] h-[.6rem]" />
|
||||
<View className="text-[#5EC45F] text-[20px] ml-[3px]">分享</View>
|
||||
</View>
|
||||
</Button>
|
||||
</View>
|
||||
<View className="flex justify-between text-[20px] text-[#5EC45F] mt-1">
|
||||
<View>{year}.{month}</View>
|
||||
|
@ -5,13 +5,15 @@ import { View, ScrollView, Image } from "@tarojs/components";
|
||||
import { APP_FULL_HEIGHT, IMG_BASE_URL } from "../../config";
|
||||
import noData from './assets/noData.png'
|
||||
import { useEffect, useState } from "react";
|
||||
import Taro, { useDidShow } from "@tarojs/taro";
|
||||
import { addressCreate, addressPage } from "../../api/me";
|
||||
import Taro, { getCurrentInstance, useDidShow } from "@tarojs/taro";
|
||||
import { addressCreate, addressPage, updateAddress } from "../../api/me";
|
||||
|
||||
const arrow = IMG_BASE_URL + 'arrow.png'
|
||||
|
||||
export default function Address() {
|
||||
const bottomNavBarHeight = 80
|
||||
const { router } = getCurrentInstance()
|
||||
const orderId = router?.params?.orderId
|
||||
const NoData = () => {
|
||||
return (
|
||||
<View className="flex flex-col items-center bg-white m-3 p-5 py-10 rounded-xl shadow-md">
|
||||
@ -25,7 +27,17 @@ export default function Address() {
|
||||
return (
|
||||
<View className="p-3 pb-0" key={item.id}>
|
||||
<View className="bg-white p-4 px-5 flex items-center rounded-xl shadow-md" onClick={
|
||||
() => Taro.navigateTo({ url: '/userInfo/addAddress/index?edit=true&id=' + item.id })
|
||||
async () => {
|
||||
if (!orderId) Taro.navigateTo({ url: '/userInfo/addAddress/index?edit=true&id=' + item.id })
|
||||
else {
|
||||
const data = await updateAddress({
|
||||
id: orderId, addressNumber: item.addressNumber
|
||||
})
|
||||
console.log("更新地址", data);
|
||||
|
||||
Taro.navigateBack()
|
||||
}
|
||||
}
|
||||
}>
|
||||
<View className="grow">
|
||||
<View className="text-[30px] flex space-x-2 items-center">
|
||||
@ -52,6 +64,8 @@ export default function Address() {
|
||||
const openId = Taro.getStorageSync("USER_OPEN_ID")
|
||||
const { data } = await addressPage({ openId })
|
||||
const { list } = data
|
||||
console.log("Address List", list);
|
||||
|
||||
if (Array.isArray(list)) setAddressList(list)
|
||||
}
|
||||
useDidShow(() => {
|
||||
@ -60,7 +74,7 @@ export default function Address() {
|
||||
return (
|
||||
<OuterFrame>
|
||||
<StatusBar />
|
||||
<HeaderNation title="收货地址"></HeaderNation>
|
||||
<HeaderNation title={orderId ? '选择收货地址' : "收货地址"}></HeaderNation>
|
||||
<ScrollView
|
||||
type="nested"
|
||||
scrollY
|
||||
@ -81,36 +95,41 @@ export default function Address() {
|
||||
style={{ height: bottomNavBarHeight + 'px' }}
|
||||
className="bg-[#f5f5f5] p-2 flex items-start pt-3 justify-evenly w-full"
|
||||
>
|
||||
<View className="default-btn w-[45%]" onClick={() => {
|
||||
Taro.chooseAddress({
|
||||
success: async (e) => {
|
||||
console.log("E", e);
|
||||
const userOpenId = Taro.getStorageSync("USER_OPEN_ID")
|
||||
const { data, code } = await addressCreate({
|
||||
openId: userOpenId,
|
||||
contact: e.userName,
|
||||
phoneNumber: e.telNumber,
|
||||
areaInfo: e.provinceName + '/' + e.cityName + '/' + e.countyName,
|
||||
fullAddress: e.detailInfo,
|
||||
zipCode: e.postalCode,
|
||||
isDefault: '1',
|
||||
remark: "",
|
||||
userId: "",
|
||||
deptId: "",
|
||||
tenant: "158"
|
||||
{
|
||||
orderId ? <>
|
||||
<View className="default-btn w-[45%]" onClick={() => {
|
||||
Taro.chooseAddress({
|
||||
success: async (e) => {
|
||||
console.log("E", e);
|
||||
const userOpenId = Taro.getStorageSync("USER_OPEN_ID")
|
||||
const { data, code } = await addressCreate({
|
||||
openId: userOpenId,
|
||||
contact: e.userName,
|
||||
phoneNumber: e.telNumber,
|
||||
areaInfo: e.provinceName + '/' + e.cityName + '/' + e.countyName,
|
||||
fullAddress: e.detailInfo,
|
||||
zipCode: e.postalCode,
|
||||
isDefault: '1',
|
||||
remark: "",
|
||||
userId: "",
|
||||
deptId: "",
|
||||
tenant: "158"
|
||||
})
|
||||
if (code === 0) getAddressList()
|
||||
else Taro.showToast({
|
||||
title: '保存失败!',
|
||||
icon: 'error',
|
||||
duration: 1400
|
||||
})
|
||||
}
|
||||
})
|
||||
if (code === 0) getAddressList()
|
||||
else Taro.showToast({
|
||||
title: '保存失败!',
|
||||
icon: 'error',
|
||||
duration: 1400
|
||||
})
|
||||
}
|
||||
})
|
||||
}}>导入微信地址</View>
|
||||
<View className="primary-btn w-[45%]" onClick={() => {
|
||||
Taro.navigateTo({ url: '/userInfo/addAddress/index' })
|
||||
}}>新增收货地址</View>
|
||||
}}>导入微信地址</View>
|
||||
<View className="primary-btn w-[45%]" onClick={() => {
|
||||
Taro.navigateTo({ url: '/userInfo/addAddress/index' })
|
||||
}}>新增收货地址</View>
|
||||
</> : <>
|
||||
</>
|
||||
}
|
||||
</View>
|
||||
</OuterFrame>
|
||||
)
|
||||
|
@ -44,63 +44,45 @@ const CalcLeftTime = ({ time }) => {
|
||||
export default function ConfirmOrder() {
|
||||
const userAvatar = useStore((store:any) => store.userAvatar)
|
||||
const bottomNavBarHeight = 130
|
||||
// 倒计时
|
||||
const [leftTime, setLeftTime] = useState(100)
|
||||
const Divider = () => {
|
||||
return (
|
||||
<View className="bg-[#25252525] w-[calc(100% - 8px)] ml-[4px] h-[1px] my-1"></View>
|
||||
)
|
||||
}
|
||||
|
||||
const [orderInfo, setOrderInfo] = useState<any>({})
|
||||
const { router } = getCurrentInstance()
|
||||
console.log("ID" , router && router.params && router.params.id);
|
||||
const OrderId = router && router.params && router.params.id
|
||||
|
||||
// 获取订单信息
|
||||
const getOrderInfo = async () => {
|
||||
if (!OrderId) return
|
||||
const userOpenId = Taro.getStorageSync("USER_OPEN_ID")
|
||||
const { data } = await getOrderInfoById({
|
||||
id: OrderId,
|
||||
serialNumber: 'JHLS202407012565376',
|
||||
openId: userOpenId
|
||||
})
|
||||
const { list } = data;
|
||||
if (!Array.isArray(list)) return
|
||||
const _orderItem = list.filter(item => {
|
||||
if (item.id === OrderId) return true;
|
||||
return false
|
||||
})
|
||||
console.log("_orderItem", _orderItem[0]);
|
||||
|
||||
if (_orderItem && _orderItem.length > 0) setOrderInfo(_orderItem[0])
|
||||
const { data } = await getOrderInfoById({ orderId: OrderId })
|
||||
if (data.orderId === OrderId) setOrderInfo(data)
|
||||
else {
|
||||
Taro.navigateBack()
|
||||
Taro.showToast({
|
||||
title: '获取订单失败!',
|
||||
icon: 'error',
|
||||
duration: 1400
|
||||
})
|
||||
Taro.showToast({ title: '获取订单失败!', icon: 'error', duration: 1400 })
|
||||
}
|
||||
}
|
||||
useEffect(() => {
|
||||
getOrderInfo()
|
||||
}, [])
|
||||
useDidShow(() => { getOrderInfo() })
|
||||
|
||||
const [defaultAdd, setDefaultAdd] = useState<any>({
|
||||
id: ''
|
||||
})
|
||||
const getAddress = async () => {
|
||||
const userOpenId = Taro.getStorageSync("USER_OPEN_ID")
|
||||
const { data } = await addressPage({
|
||||
openId: userOpenId
|
||||
})
|
||||
const { list } = data;
|
||||
console.log("List", list);
|
||||
if (!Array.isArray(list)) return
|
||||
const _defaultAdd = list.filter(item => (item.isDefault === '1'))[0]
|
||||
if (_defaultAdd) setDefaultAdd(_defaultAdd)
|
||||
const formatSpecs = (orderDetailList) => {
|
||||
if (Array.isArray(orderDetailList)) {
|
||||
const arr = orderDetailList.map(item => (item.specs.specs))
|
||||
return arr.join(';\n')
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
// 订单超时 返回true
|
||||
const diabledPay = () => {
|
||||
if (!orderInfo?.orderCreateTime) return false
|
||||
const now = new Date().valueOf()
|
||||
const limitTime = orderInfo.orderCreateTime + 1000 * 60 * 15
|
||||
if (limitTime - now < 0) return true
|
||||
return false
|
||||
}
|
||||
useDidShow(() => { getAddress() })
|
||||
|
||||
return (
|
||||
<OuterFrame>
|
||||
<StatusBar />
|
||||
@ -115,52 +97,61 @@ export default function ConfirmOrder() {
|
||||
className="pb-1 box-border overflow-hidden box-border"
|
||||
>
|
||||
<View className="p-3">
|
||||
<View className="bg-white p-4 px-5 flex items-center rounded-xl shadow-md" style={{ display: defaultAdd.id ? 'flex' : 'none' }}>
|
||||
<View className="grow">
|
||||
<View className="text-[30px]">
|
||||
<Text>{defaultAdd.contact}</Text>
|
||||
<Text className="pl-[.4rem]">{defaultAdd.phoneNumber}</Text>
|
||||
</View>
|
||||
<View className="text-[26px] mt-1">{defaultAdd.fullAddress}</View>
|
||||
</View>
|
||||
<Image src={arrow} className="w-[14px] h-[20px]" onClick={() => {
|
||||
Taro.navigateTo({ url: '/userInfo/address/index' })
|
||||
}} />
|
||||
</View>
|
||||
<View
|
||||
className="text-[.7rem] bg-white p-4 px-5 flex items-center justify-center rounded-xl shadow-md"
|
||||
style={{ display: defaultAdd.id ? 'none' : 'flex' }}
|
||||
onClick={() => {
|
||||
Taro.navigateTo({ url: '/userInfo/address/index' })
|
||||
}}
|
||||
>
|
||||
<Image src={positionIcon} className="w-[.7rem] h-[.7rem] mr-[.3rem]" mode="heightFix" />
|
||||
<View>请新增收货物地址</View>
|
||||
</View>
|
||||
<View className="bg-white p-3 mt-2 rounded-xl shadow-md">
|
||||
<View className="flex items-center">
|
||||
<Image src={userAvatar} className="w-[3rem] h-[3rem] rounded-md shadow-sm" mode="aspectFill" />
|
||||
<View className="pl-2">
|
||||
<View>{orderInfo.plotName}</View>
|
||||
<View className="text-[22px] text-[#999999] mt-[.3rem]">{orderInfo?.detail?.specs?.map(item => (item.specs)).join(';')}</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className="flex justify-between items-center text-[24px] mt-2">
|
||||
<View className="text-[#999999]">预计收获日期:</View>
|
||||
<View style={{ display: orderInfo.expectStart ? 'block' : 'none' }}>
|
||||
<Text>{dayjs(orderInfo.expectStart).format("YYYY-MM-DD")}</Text>
|
||||
<Text>-</Text>
|
||||
<Text>{dayjs(orderInfo.expectEnd).format("YYYY-MM-DD")}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className="w-full py-2"><Divider /></View>
|
||||
<View className="flex flex-row-reverse text-[#FF663F]">
|
||||
<View>
|
||||
<Text className="text-[22px]">合计</Text>
|
||||
<Text className="pl-[.4rem] text-[26px]">¥{formatMoney(orderInfo.orderAmount || 0)}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
{
|
||||
orderInfo?.orderId ? (
|
||||
<>
|
||||
{
|
||||
orderInfo?.addressInfo?.id ? <View className="bg-white p-4 px-5 flex items-center rounded-xl shadow-md flex">
|
||||
<View className="grow">
|
||||
<View className="text-[30px]">
|
||||
<Text>{orderInfo.addressInfo.contact}</Text>
|
||||
<Text className="pl-[.4rem]">{orderInfo.addressInfo.phoneNumber}</Text>
|
||||
</View>
|
||||
<View className="text-[26px] mt-1">
|
||||
<Text>{orderInfo.addressInfo.areaInfo}</Text>
|
||||
<Text className="pl-2">{orderInfo.addressInfo.fullAddress}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<Image src={arrow} className="w-[14px] h-[20px]" onClick={() => {
|
||||
Taro.navigateTo({ url: '/userInfo/address/index?orderId=' + OrderId })
|
||||
}} />
|
||||
</View> : <View
|
||||
className="text-[1.1rem] bg-white p-4 px-5 flex items-center justify-center rounded-xl shadow-md flex"
|
||||
onClick={() => {
|
||||
Taro.navigateTo({ url: '/userInfo/address/index?orderId=' + OrderId })
|
||||
}}
|
||||
>
|
||||
<Image src={positionIcon} className="w-[1rem] h-[1rem] mr-[.3rem]" mode="heightFix" />
|
||||
<View className="text-[.9rem] pl-[.3rem]">请新增收货物地址</View>
|
||||
</View>
|
||||
}
|
||||
<View className="bg-white p-3 mt-2 rounded-xl shadow-md">
|
||||
<View className="flex items-center">
|
||||
<Image src={userAvatar} className="w-[3rem] h-[3rem] rounded-md shadow-sm" mode="aspectFill" />
|
||||
<View className="pl-2">
|
||||
<View>{orderInfo.plotName}</View>
|
||||
<View className="text-[22px] text-[#999999] mt-[.3rem]">{formatSpecs(orderInfo.orderDetailList)}</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className="flex justify-between items-center text-[24px] mt-2">
|
||||
<View className="text-[#999999]">预计收获日期:</View>
|
||||
<View style={{ display: orderInfo.orderExpectStart ? 'block' : 'none' }}>
|
||||
<Text>{dayjs(orderInfo.orderExpectStart).format("YYYY-MM-DD")}</Text>
|
||||
<Text>---</Text>
|
||||
<Text>{dayjs(orderInfo.orderExpectEnd).format("YYYY-MM-DD")}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className="w-full py-2"><Divider /></View>
|
||||
<View className="flex flex-row-reverse text-[#FF663F]">
|
||||
<View>
|
||||
<Text className="text-[22px]">合计</Text>
|
||||
<Text className="pl-[.4rem] text-[26px]">¥{formatMoney(orderInfo.orderAmount || 0)}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
) : null
|
||||
}
|
||||
</View>
|
||||
</ScrollView>
|
||||
<View
|
||||
@ -170,13 +161,21 @@ export default function ConfirmOrder() {
|
||||
<View className="py-2">
|
||||
<Text>倒计时:</Text>
|
||||
<Text className="pl-1">
|
||||
<CalcLeftTime time={orderInfo.createTime + 1000 * 60 * 15} />
|
||||
<CalcLeftTime time={orderInfo.orderCreateTime + 1000 * 60 * 15} />
|
||||
</Text>
|
||||
</View>
|
||||
<View className="!py-[26px] primary-btn w-[85%]" onClick={async () => {
|
||||
<View className="!py-[26px] px-[16px] text-center text-[#fff] rounded-full w-[85%]" style={{ backgroundColor: diabledPay() ? '#777777' : '#63c632' }} onClick={async () => {
|
||||
if (diabledPay()) {
|
||||
Taro.showToast({
|
||||
title: '订单超时!',
|
||||
icon: 'error',
|
||||
duration: 1400
|
||||
})
|
||||
return
|
||||
}
|
||||
const id = router && router.params && router.params.id
|
||||
if (!id) return
|
||||
if (!defaultAdd.id) {
|
||||
if (!orderInfo?.addressInfo?.id) {
|
||||
Taro.showToast({
|
||||
title: '请选择地址',
|
||||
icon: 'error',
|
||||
|
Loading…
Reference in New Issue
Block a user