商城测试版v7
This commit is contained in:
parent
87bcda1c38
commit
2b4017274a
@ -1,7 +1,9 @@
|
|||||||
import { formatImgUrl } from "@/common/fotmat";
|
import { formatImgUrl } from "@/common/fotmat";
|
||||||
|
import Preview from "@/pages/details/components/preview";
|
||||||
import { Image, View } from "@tarojs/components";
|
import { Image, View } from "@tarojs/components";
|
||||||
import { memo, useMemo } from "react";
|
import { memo, useMemo, useState } from "react";
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import Taro from "@tarojs/taro";
|
||||||
|
|
||||||
//该组件宽高为100%需调整外层元素宽高
|
//该组件宽高为100%需调整外层元素宽高
|
||||||
type Param = {
|
type Param = {
|
||||||
@ -9,9 +11,10 @@ type Param = {
|
|||||||
texture_url?: string, //纹理图路径
|
texture_url?: string, //纹理图路径
|
||||||
lab?: {l:number, a:number, b:number}, //lab
|
lab?: {l:number, a:number, b:number}, //lab
|
||||||
rgb?: {r:number, g:number, b:number} //rgb
|
rgb?: {r:number, g:number, b:number} //rgb
|
||||||
}
|
},
|
||||||
|
checkStatus: false|true
|
||||||
}
|
}
|
||||||
export default memo(({value}:Param) => {
|
export default memo(({value, checkStatus = false}:Param) => {
|
||||||
//lab是否都是0
|
//lab是否都是0
|
||||||
const rgbStyle = useMemo(() => {
|
const rgbStyle = useMemo(() => {
|
||||||
if(value?.lab&&(value.lab.l||value.lab.a||value.lab.b)) {
|
if(value?.lab&&(value.lab.l||value.lab.a||value.lab.b)) {
|
||||||
@ -20,11 +23,28 @@ export default memo(({value}:Param) => {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}, [value])
|
}, [value])
|
||||||
|
|
||||||
|
const [showPreview, setShowPreview] = useState(false)
|
||||||
|
const onClickShow = () => {
|
||||||
|
setShowPreview(() => true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const onShowImage = () => {
|
||||||
|
if(!checkStatus) return false
|
||||||
|
Taro.previewImage({
|
||||||
|
current: formatImgUrl(value?.texture_url, '!w800'), // 当前显示
|
||||||
|
urls: [formatImgUrl(value?.texture_url, '!w800')] // 需要预览的图片http链接列表
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<View className={styles.labAndImg_main}>
|
<View className={styles.labAndImg_main}>
|
||||||
{value?.texture_url&&<Image mode="aspectFill" src={formatImgUrl(value?.texture_url)}></Image>}
|
{value?.texture_url&&<Image mode="aspectFill" onClick={() => onShowImage()} src={formatImgUrl(value?.texture_url)}></Image>}
|
||||||
{(!value?.texture_url&&rgbStyle)&&<View className={styles.boxColor} style={{...rgbStyle}}></View>}
|
{(!value?.texture_url&&rgbStyle)&&<View className={styles.boxColor} onClick={() => onClickShow()} style={{...rgbStyle}}></View>}
|
||||||
{(!value?.texture_url&&!rgbStyle)&&<Image mode="aspectFill" src={formatImgUrl('')}></Image>}
|
{(!value?.texture_url&&!rgbStyle)&&<Image mode="aspectFill" src={formatImgUrl('')}></Image>}
|
||||||
</View>
|
</View>
|
||||||
|
<Preview value={rgbStyle} show={showPreview} onClose={() => setShowPreview(false)}/>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
})
|
})
|
@ -18,6 +18,11 @@
|
|||||||
margin-top: 100px;
|
margin-top: 100px;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
.rgb{
|
||||||
|
width: 600px;
|
||||||
|
height: 600px;
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
image{
|
image{
|
||||||
width:100%;
|
width:100%;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
|
@ -1,25 +1,21 @@
|
|||||||
import LabAndImg from "@/components/LabAndImg"
|
import { View } from "@tarojs/components"
|
||||||
import { Image, View } from "@tarojs/components"
|
import { useMemo } from "react"
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
export type colorItem = {
|
|
||||||
title: string,
|
|
||||||
lab: {l:number, a:number, b:number},
|
|
||||||
rgb: {r:number, g:number, b:number},
|
|
||||||
texture_url: string
|
|
||||||
}
|
|
||||||
export type colorParams = {
|
export type colorParams = {
|
||||||
value?: colorItem,
|
value?: { backgroundColor: string; }|null,
|
||||||
show?: false|true
|
show?: false|true
|
||||||
onClose?: () => void
|
onClose?: () => void
|
||||||
}
|
}
|
||||||
export default ({value, show = false, onClose}: colorParams) => {
|
export default ({value, show = false, onClose}: colorParams) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{show&&<View className={styles.main} catch-move="true" onClick={() => onClose?.()}>
|
{show&&<View className={styles.main} catch-move="true" onClick={() => onClose?.()}>
|
||||||
<View className={styles.con}>
|
<View className={styles.con}>
|
||||||
<LabAndImg value={{lab:value?.lab,rgb:value?.rgb,texture_url:value?.texture_url}}/>
|
<View className={styles.rgb} style={value!}></View>
|
||||||
<View className={styles.name}>{value?.title}</View>
|
<View className={styles.name}>{'颜色'}</View>
|
||||||
</View>
|
</View>
|
||||||
</View>}
|
</View>}
|
||||||
</>
|
</>
|
||||||
|
@ -239,7 +239,6 @@ export default (props:Params) => {
|
|||||||
<OrderCount show={showOrderCount} onClose={() => setShowOrderCount(false)} title={productName} productId={productInfo.id}/>
|
<OrderCount show={showOrderCount} onClose={() => setShowOrderCount(false)} title={productName} productId={productInfo.id}/>
|
||||||
</CustomWrapper>
|
</CustomWrapper>
|
||||||
<ShopCart show={showCart} onClose={() => setShowCart(false)}/>
|
<ShopCart show={showCart} onClose={() => setShowCart(false)}/>
|
||||||
<Preview value={colorInfo} show={showPreview} onClose={() => setShowPreview(false)}/>
|
|
||||||
<AddCollection show={collectionShow} onAdd={onAdd} onClose={closeCollection}/>
|
<AddCollection show={collectionShow} onAdd={onAdd} onClose={closeCollection}/>
|
||||||
<View className='common_safe_area_y'></View>
|
<View className='common_safe_area_y'></View>
|
||||||
</View>
|
</View>
|
||||||
|
@ -115,7 +115,6 @@ import styles from './index.module.scss'
|
|||||||
take_goods_address: orderDetail?.take_goods_address,
|
take_goods_address: orderDetail?.take_goods_address,
|
||||||
take_goods_phone: orderDetail?.take_goods_phone
|
take_goods_phone: orderDetail?.take_goods_phone
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [orderDetail])
|
}, [orderDetail])
|
||||||
|
|
||||||
//订单备注
|
//订单备注
|
||||||
|
Loading…
x
Reference in New Issue
Block a user