|
@@ -1,26 +1,89 @@
|
|
|
-import React from 'react'
|
|
|
+import React, { useCallback, useMemo, useState } from 'react'
|
|
|
import styles from './index.module.scss'
|
|
|
+import classNames from 'classnames'
|
|
|
+import { myInfo1 } from '@/pages/A2show/data'
|
|
|
+
|
|
|
+const tabArr = [
|
|
|
+ { name: '玉镖', bs: 'yu_01', info: '玉镖(鞘尾)' },
|
|
|
+ { name: '剑身', bs: 'jian_02', info: '剑身' },
|
|
|
+ { name: '玉璏', bs: 'yu_03', info: '玉璏(鞘中部)' }
|
|
|
+]
|
|
|
+const objAc = myInfo1.find(v => v.title === '工艺')!.text!
|
|
|
|
|
|
type Props = {
|
|
|
cutModelFu: (val: string) => void
|
|
|
}
|
|
|
|
|
|
function A0btn({ cutModelFu }: Props) {
|
|
|
+ const [tab, setTab] = useState('')
|
|
|
+
|
|
|
+ const [zhiCss, setZhiCss] = useState('')
|
|
|
+
|
|
|
+ const cutFu = useCallback(
|
|
|
+ (bs: string) => {
|
|
|
+ if (tab === bs) {
|
|
|
+ setTab('')
|
|
|
+ cutModelFu('')
|
|
|
+ } else {
|
|
|
+ setZhiCss(bs === 'yu_01' ? '5%' : bs === 'yu_03' ? '56%' : '31%')
|
|
|
+ setTab(bs)
|
|
|
+ cutModelFu(bs)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ [cutModelFu, tab]
|
|
|
+ )
|
|
|
+
|
|
|
+ const infoObj = useMemo(() => {
|
|
|
+ let obj = {
|
|
|
+ title: '玉柄铁剑',
|
|
|
+ text: ''
|
|
|
+ }
|
|
|
+ if (tab) {
|
|
|
+ const tabBs = tabArr.find(v => v.bs === tab)!.info
|
|
|
+
|
|
|
+ obj = {
|
|
|
+ title: tabBs,
|
|
|
+ text: Reflect.get(objAc, tabBs)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return obj
|
|
|
+ }, [tab])
|
|
|
+
|
|
|
return (
|
|
|
- <div className={styles.A0btn}>
|
|
|
- <button onClick={() => cutModelFu('yu_01')} style={{ padding: '10px' }}>
|
|
|
- 显示 BS1
|
|
|
- </button>
|
|
|
- <button onClick={() => cutModelFu('jian_02')} style={{ padding: '10px' }}>
|
|
|
- 显示 BS2
|
|
|
- </button>
|
|
|
- <button onClick={() => cutModelFu('yu_03')} style={{ padding: '10px' }}>
|
|
|
- 显示 BS3
|
|
|
- </button>
|
|
|
- <button onClick={() => cutModelFu('')} style={{ padding: '10px' }}>
|
|
|
- 显示全部
|
|
|
- </button>
|
|
|
- </div>
|
|
|
+ <>
|
|
|
+ <div className={styles.A0top}>123</div>
|
|
|
+
|
|
|
+ <div className={styles.A0btn}>
|
|
|
+ {/* 指示图 */}
|
|
|
+ <div className='A0btnZhi'>
|
|
|
+ <img
|
|
|
+ className='A0btnZhi1'
|
|
|
+ style={{ opacity: tab ? 1 : 0, left: zhiCss }}
|
|
|
+ src={`${serverUrl}model/zhi.png`}
|
|
|
+ alt=''
|
|
|
+ />
|
|
|
+ <img src={`${serverUrl}model/jianYing.png`} alt='' />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ {/* 按钮 */}
|
|
|
+ <div className='A0btnBox'>
|
|
|
+ {tabArr.map(item => (
|
|
|
+ <div
|
|
|
+ className={classNames(tab === item.bs ? 'A0btnRow' : '')}
|
|
|
+ key={item.name}
|
|
|
+ onClick={() => cutFu(item.bs)}
|
|
|
+ style={{
|
|
|
+ backgroundImage: `url(${serverUrl}model/btn${
|
|
|
+ tab === item.bs ? 'Ac' : ''
|
|
|
+ }.png)`
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {item.name}
|
|
|
+ </div>
|
|
|
+ ))}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </>
|
|
|
)
|
|
|
}
|
|
|
|