Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
render() {
const { banner, brands, products_list, effects } = this.props;
return (
);
}
}
updateState = idx => {
if (this.props.scroll) {
// 标签栏滚动
switch (ENV) {
case Taro.ENV_TYPE.WEAPP:
case Taro.ENV_TYPE.ALIPAY:
case Taro.ENV_TYPE.SWAN:
const index = Math.max(idx - 1, 0)
this.setState({
_scrollIntoView: `tab${index}`
})
break
case Taro.ENV_TYPE.WEB: {
const index = Math.max(idx - 1, 0)
const prevTabItem = this.tabHeaderRef.childNodes[index]
prevTabItem && this.setState({
_scrollTop: prevTabItem.offsetTop,
_scrollLeft: prevTabItem.offsetLeft
})
break
}
onClick (data) {
const { tagList } = this.state
const findIndex = this.state.tagList.findIndex(item => item.name === data.name)
const active = !tagList[findIndex].active
tagList[findIndex].active = active
const content = `您点击的 tag 标签名是:${data.name},点击前是否选中:${data.active},点击后:${active}`
this.setState({ tagList })
if (Taro.getEnv() === Taro.ENV_TYPE.WEAPP) Taro.showModal({ content, showCancel: false })
else if (Taro.getEnv() === Taro.ENV_TYPE.WEB) alert(content)
console.log(data)
}
goToPage = e => {
if (Taro.getEnv() === Taro.ENV_TYPE.WEB) {
Taro.navigateTo({
url: e.currentTarget.dataset.url,
});
} else {
Taro.switchTab({
url: e.currentTarget.dataset.url,
});
}
};
handleRemoveImg = idx => {
const { files = [] } = this.props
if (ENV === Taro.ENV_TYPE.WEB) {
window.URL.revokeObjectURL(files[idx].url)
}
const newFiles = files.filter((file, i) => i !== idx)
this.props.onChange(newFiles, 'remove', idx)
}
constructor () {
super(...arguments)
const isWEAPP = Taro.getEnv() === Taro.ENV_TYPE.WEAPP
const offset = isWEAPP ? parseInt(Taro.pxTransform(this.props.size).replace('rpx')) : this.props.size
const windowWidth = isWEAPP ? Taro.getSystemInfoSync().windowWidth : window.innerWidth
const windowHeight = isWEAPP ? Taro.getSystemInfoSync().windowHeight : window.innerHeight
this.state = {
position: {
left: `${(windowWidth * 0.85) - offset}px`,
top: `${(windowHeight * 0.90) - offset}px`
},
offset,
movableRangeWidth: (windowWidth * 0.95) - (2 * offset),
movableRangeHeight: (windowHeight * 0.95) - (2 * offset),
backgroundColor: this.props.backgroundColor,
isWEAPP,
}
}
componentDidMount () {
const env = Taro.getEnv()
this.setState({
isWeapp: env === Taro.ENV_TYPE.WEAPP,
isAlipay: env === Taro.ENV_TYPE.ALIPAY,
})
}
import Taro from '@tarojs/taro'
import { View, Form, Text } from '@tarojs/components'
import { AtButton, AtForm, AtFab } from 'taro-ui'
import DocsHeader from '../../components/doc-header'
import './index.scss'
export default class ButtonPage extends Taro.Component {
config = {
navigationBarTitleText: 'Taro UI'
}
state = {
isWEAPP: Taro.getEnv() === Taro.ENV_TYPE.WEAPP,
isALIPAY: Taro.getEnv() === Taro.ENV_TYPE.ALIPAY,
}
onButtonClick () {
const content = [...arguments].find(item => typeof item === 'string')
const ENV = Taro.getEnv()
if (ENV === 'WEAPP') Taro.showModal({ content: content || '您点击了按钮!', showCancel: false })
else if (ENV === 'WEB') alert(content || '您点击了按钮!')
}
onShareAppMessage () {
return {
title: 'Taro UI',
path: '/pages/index/index',
imageUrl: 'http://storage.360buyimg.com/mtd/home/share1535013100318.jpg'
}
constructor () {
super(...arguments)
const animElemId = `J_${Math.ceil(Math.random() * 10e5).toString(36)}`
this.state = {
show: true,
animElemId,
dura: 15,
isWEAPP: Taro.getEnv() === Taro.ENV_TYPE.WEAPP,
isALIPAY: Taro.getEnv() === Taro.ENV_TYPE.ALIPAY,
isWEB: Taro.getEnv() === Taro.ENV_TYPE.WEB,
}
}
import Taro from '@tarojs/taro'
import { View, Form } from '@tarojs/components'
import { AtButton, AtForm } from 'taro-ui'
import DocsHeader from '../../components/doc-header'
import './index.scss'
export default class ButtonPage extends Taro.Component {
config = {
navigationBarTitleText: 'Taro UI'
}
state = {
isWEAPP: Taro.getEnv() === Taro.ENV_TYPE.WEAPP,
isALIPAY: Taro.getEnv() === Taro.ENV_TYPE.ALIPAY,
}
onButtonClick () {
const content = [...arguments].find(item => typeof item === 'string')
const ENV = Taro.getEnv()
if (ENV === 'WEAPP') Taro.showModal({ content: content || '您点击了!', showCancel: false })
else if (ENV === 'WEB') alert(content || '您点击了!')
}
onShareAppMessage () {
return {
title: 'Taro UI',
path: '/pages/index/index',
imageUrl: 'http://storage.360buyimg.com/mtd/home/share1535013100318.jpg'
}
}