forked from gxwebsoft/mp-10550
优化细节
This commit is contained in:
@@ -202,6 +202,7 @@ function Cart() {
|
||||
src={item.image}
|
||||
width="80"
|
||||
height="80"
|
||||
lazyLoad={false}
|
||||
radius="8"
|
||||
className="flex-shrink-0"
|
||||
/>
|
||||
|
||||
@@ -21,7 +21,7 @@ const MyPage = () => {
|
||||
<Swiper defaultValue={0} height={item?.height} indicator style={{ height: item?.height + 'px', display: 'none' }}>
|
||||
{item?.imageList?.map((item) => (
|
||||
<Swiper.Item key={item}>
|
||||
<Image width="100%" height="100%" src={item.url} mode={'scaleToFill'} style={{ height: item.height + 'px' }} />
|
||||
<Image width="100%" height="100%" src={item.url} mode={'scaleToFill'} lazyLoad={false} style={{ height: item.height + 'px' }} />
|
||||
</Swiper.Item>
|
||||
))}
|
||||
</Swiper>
|
||||
|
||||
@@ -27,7 +27,7 @@ const BestSellers = () => {
|
||||
{list?.map((item, index) => {
|
||||
return (
|
||||
<div key={index} className={'flex flex-col rounded-lg bg-white shadow-sm w-full mb-5'}>
|
||||
<Image src={item.image} mode={'scaleToFill'}
|
||||
<Image src={item.image} mode={'aspectFit'} lazyLoad={false}
|
||||
radius="10px 10px 0 0" height="180"
|
||||
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}/>
|
||||
<div className={'flex flex-col p-2 rounded-lg'}>
|
||||
|
||||
0
src/pages/index/GoodsList.scss
Normal file
0
src/pages/index/GoodsList.scss
Normal file
67
src/pages/index/GoodsList.tsx
Normal file
67
src/pages/index/GoodsList.tsx
Normal file
@@ -0,0 +1,67 @@
|
||||
import {useEffect, useState} from "react";
|
||||
import {Image} from '@nutui/nutui-react-taro'
|
||||
import {Share} from '@nutui/icons-react-taro'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {ShopGoods} from "@/api/shop/shopGoods/model";
|
||||
import {pageShopGoods} from "@/api/shop/shopGoods";
|
||||
import './GoodsList.scss'
|
||||
|
||||
|
||||
const BestSellers = () => {
|
||||
const [list, setList] = useState<ShopGoods[]>([])
|
||||
|
||||
const reload = () => {
|
||||
pageShopGoods({}).then(res => {
|
||||
setList(res?.list || []);
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
reload()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={'py-3'}>
|
||||
<div className={'flex flex-wrap justify-between items-start rounded-lg px-2'}>
|
||||
{list?.map((item, index) => {
|
||||
return (
|
||||
<div key={index} className={'flex flex-col rounded-lg bg-white shadow-sm mb-5'} style={{
|
||||
width: '48%'
|
||||
}}>
|
||||
<Image src={item.image} mode={'scaleToFill'} lazyLoad={false}
|
||||
radius="10px 10px 0 0" height="180"
|
||||
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}/>
|
||||
<div className={'flex flex-col p-2 rounded-lg'}>
|
||||
<div>
|
||||
<div className={'car-no text-sm'}>{item.name}</div>
|
||||
<div className={'flex justify-between text-xs py-1'}>
|
||||
<span className={'text-orange-500'}>{item.comments}</span>
|
||||
<span className={'text-gray-400'}>已售 {item.sales}</span>
|
||||
</div>
|
||||
<div className={'flex justify-between items-center py-2'}>
|
||||
<div className={'flex text-red-500 text-xl items-baseline'}>
|
||||
<span className={'text-xs'}>¥</span>
|
||||
<span className={'font-bold text-2xl'}>{item.price}</span>
|
||||
</div>
|
||||
<div className={'buy-btn'}>
|
||||
<div className={'cart-icon'}>
|
||||
<Share size={20} className={'mx-4 mt-2'}
|
||||
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}/>
|
||||
</div>
|
||||
<div className={'text-white pl-4 pr-5'}
|
||||
onClick={() => Taro.navigateTo({url: '/shop/goodsDetail/index?id=' + item.goodsId})}>购买
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default BestSellers
|
||||
@@ -9,8 +9,8 @@ import {getOrganization} from "@/api/system/organization";
|
||||
import {myUserVerify} from "@/api/system/userVerify";
|
||||
import {CmsWebsite} from "@/api/cms/cmsWebsite/model";
|
||||
import {User} from "@/api/system/user/model";
|
||||
import './Header.scss';
|
||||
import MySearch from "./MySearch";
|
||||
import './Header.scss';
|
||||
|
||||
const Header = () => {
|
||||
const [userInfo, setUserInfo] = useState<User>()
|
||||
@@ -93,7 +93,7 @@ const Header = () => {
|
||||
success: function () {
|
||||
if (code) {
|
||||
Taro.request({
|
||||
url: 'https://server.websoft.top/api/wx-login/loginByMpWxPhone',
|
||||
url: 'https://server.gxwebsoft.com/api/wx-login/loginByMpWxPhone',
|
||||
method: 'POST',
|
||||
data: {
|
||||
code,
|
||||
@@ -135,7 +135,7 @@ const Header = () => {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
reload()
|
||||
reload().then()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
|
||||
@@ -16,7 +16,7 @@ const Login = (props:any) => {
|
||||
success: function () {
|
||||
if (code) {
|
||||
Taro.request({
|
||||
url: 'https://server.websoft.top/api/wx-login/loginByMpWxPhone',
|
||||
url: 'https://server.gxwebsoft.com/api/wx-login/loginByMpWxPhone',
|
||||
method: 'POST',
|
||||
data: {
|
||||
code,
|
||||
|
||||
@@ -11,14 +11,25 @@ const Page = () => {
|
||||
const [navItems, setNavItems] = useState<CmsNavigation[]>([])
|
||||
|
||||
const reload = async () => {
|
||||
// 读取栏目
|
||||
const menus = await listCmsNavigation({model: 'links', hide: 0});
|
||||
setNavItems(menus || [])
|
||||
// 读取首页菜单
|
||||
const home = await listCmsNavigation({model: 'index'});
|
||||
if (home && home.length > 0) {
|
||||
// 读取首页导航条
|
||||
const menus = await listCmsNavigation({parentId: home[0].navigationId, hide: 0});
|
||||
setNavItems(menus || [])
|
||||
}
|
||||
};
|
||||
|
||||
const onNav = (row: CmsNavigation) => {
|
||||
console.log(row, 'eee')
|
||||
Taro.navigateTo({url: `${row.path}`})
|
||||
console.log('nav = ', row)
|
||||
console.log('path = ', `/${row.model}${row.path}`)
|
||||
if (row.model == 'goods') {
|
||||
return Taro.navigateTo({url: `/shop/category/index?id=${row.navigationId}`})
|
||||
}
|
||||
if (row.model == 'article') {
|
||||
return Taro.navigateTo({url: `/cms/category/index?id=${row.navigationId}`})
|
||||
}
|
||||
return Taro.navigateTo({url: `${row.path}`})
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +47,7 @@ const Page = () => {
|
||||
navItems.map((item, index) => (
|
||||
<div key={index} className={'text-center'} onClick={() => onNav(item)}>
|
||||
<div className={'flex flex-col justify-center items-center p-1'}>
|
||||
<Image src={item.icon} height={36} width={36}/>
|
||||
<Image src={item.icon} height={36} width={36} lazyLoad={false}/>
|
||||
<div className={'mt-1 text-gray-600'} style={{fontSize: '14px'}}>{item?.title}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,10 +4,13 @@ import Taro from '@tarojs/taro';
|
||||
import {useShareAppMessage, useShareTimeline} from "@tarojs/taro"
|
||||
import {useEffect} from "react";
|
||||
import {getSiteInfo} from "@/api/layout";
|
||||
import {Sticky} from '@nutui/nutui-react-taro'
|
||||
import Menu from "./Menu";
|
||||
import Banner from "./Banner";
|
||||
import './index.scss'
|
||||
|
||||
// import GoodsList from "./GoodsList";
|
||||
|
||||
function Home() {
|
||||
|
||||
useShareTimeline(() => {
|
||||
@@ -94,18 +97,21 @@ function Home() {
|
||||
Taro.getUserInfo({
|
||||
success: (res) => {
|
||||
const avatar = res.userInfo.avatarUrl;
|
||||
console.log(avatar,'avatarUrl')
|
||||
console.log(avatar, 'avatarUrl')
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Header/>
|
||||
<Sticky threshold={0}>
|
||||
<Header/>
|
||||
</Sticky>
|
||||
<div className={'flex flex-col mt-12'}>
|
||||
<Menu />
|
||||
<Banner />
|
||||
<Menu/>
|
||||
<Banner/>
|
||||
<BestSellers/>
|
||||
{/*<GoodsList/>*/}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -25,7 +25,7 @@ const OrderIcon = () => {
|
||||
success: function () {
|
||||
if (code) {
|
||||
Taro.request({
|
||||
url: 'https://server.websoft.top/api/wx-login/loginByMpWxPhone',
|
||||
url: 'https://server.gxwebsoft.com/api/wx-login/loginByMpWxPhone',
|
||||
method: 'POST',
|
||||
data: {
|
||||
code,
|
||||
@@ -187,13 +187,13 @@ const OrderIcon = () => {
|
||||
<div className={'flex flex-col justify-center items-center'} onClick={() => {
|
||||
onLogin(item, index)
|
||||
}}>
|
||||
<Image src={item.icon} height={28} width={28}/>
|
||||
<Image src={item.icon} height={28} width={28} lazyLoad={false}/>
|
||||
<div className={'mt-2'} style={{fontSize: '15px'}}>{item?.title}</div>
|
||||
</div>
|
||||
:
|
||||
<Button className={'text-white'} open-type="getPhoneNumber" onGetPhoneNumber={handleGetPhoneNumber}>
|
||||
<div className={'flex flex-col justify-center items-center'}>
|
||||
<Image src={item.icon} height={28} width={28}/>
|
||||
<Image src={item.icon} height={28} width={28} lazyLoad={false}/>
|
||||
<div className={'mt-2 text-gray-700'} style={{fontSize: '15px'}}>{item?.title}</div>
|
||||
</div>
|
||||
</Button>
|
||||
|
||||
@@ -107,7 +107,7 @@ function UserCard() {
|
||||
success: function () {
|
||||
if (code) {
|
||||
Taro.request({
|
||||
url: 'https://server.websoft.top/api/wx-login/loginByMpWxPhone',
|
||||
url: 'https://server.gxwebsoft.com/api/wx-login/loginByMpWxPhone',
|
||||
method: 'POST',
|
||||
data: {
|
||||
code,
|
||||
|
||||
Reference in New Issue
Block a user