Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Taro from '@tarojs/taro'
import PropTypes from 'prop-types'
import { View, ScrollView } from '@tarojs/components'
import classNames from 'classnames'
import _findIndex from 'lodash/findIndex'
import AtComponent from '../../common/component'
import AtList from '../../components/list/index'
import AtListItem from '../../components/list/item/index'
import AtToast from '../../components/toast/index'
import { delayQuerySelector, uuid, initTestEnv, isTest } from '../../common/utils'
initTestEnv()
const ENV = Taro.getEnv()
class AtIndexes extends AtComponent {
constructor () {
super(...arguments)
this.state = {
_scrollIntoView: '',
_scrollTop: 0,
_tipText: '',
_isShowToast: false,
isWEB: Taro.getEnv() === Taro.ENV_TYPE.WEB,
}
// 右侧导航高度
this.menuHeight = 0
// 右侧导航距离顶部高度
this.startTop = 0
// 右侧导航元素高度
onItemClick (index) {
const ENV = Taro.getEnv()
let content
if (typeof index !== 'number') {
content = ''
} else {
content = `你点击了第 ${+index + 1} 个项目`
}
if (ENV === 'WEAPP') content && Taro.showModal({ content, showCancel: false })
else if (ENV === 'WEB') content && alert(content)
}
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 || '您点击了!')
}
makePhoneCall() {
if (Taro.getEnv() === Taro.ENV_TYPE.WEB) {
window.location.href = 'tel:123456';
} else {
Taro.makePhoneCall({
phoneNumber: '123456',
});
}
}
componentDidMount () {
const env = Taro.getEnv()
this.setState({
isWeapp: env === Taro.ENV_TYPE.WEAPP,
isAlipay: env === Taro.ENV_TYPE.ALIPAY,
})
}