Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
}
componentDidMount() {
Taro.eventCenter.on('login_success', (res)=>{
Taro.startPullDownRefresh()
})
Taro.showLoading({title: GLOBAL_CONFIG.LOADING_TEXT})
this.getActivityList()
if (!hasLogin()) {
Taro.showModal({
content: 'Login to view yours activity?',
showCancel: true,
cancelText: 'No',
cancelColor: '#7f7f7f',
confirmText: 'Yeah',
confirmColor: '#2d8cf0',
success(res) {
if (res.confirm) {
Taro.navigateTo({
url: '/pages/login/login'
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
logout() {
Taro.showModal({
content: 'Are you sure?',
showCancel: true,
cancelText: 'No',
cancelColor: '#7f7f7f',
confirmText: 'Yeah',
confirmColor: '#2d8cf0',
success(res) {
if (res.confirm) {
Taro.setStorageSync('Authorization', '')
Taro.setStorageSync('userInfo', null)
Taro.navigateBack()
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
updateManager.onUpdateReady(() => {
Taro.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
updateManager.applyUpdate()
}
}
})
})
updateManager.onUpdateFailed(() => {
delete = () => {
Taro.showModal({
content: '是否删除该地址?',
}).then(res => {
if (res.confirm) {
this.props.dispatch({
type: 'addressUpdate/removeAddress',
});
}
});
};
onGotoMore () {
if (Taro.getEnv() === Taro.ENV_TYPE.WEB) {
alert('您点击了更多!')
} else {
Taro.showModal({
content: '点击了更多!',
cancelText: '取消'
})
}
}
handlerGobackClick() {
if (_isFunction(super.handlerGobackClick)) {
super.handlerGobackClick();
} else {
Taro.showModal({
title: '你点击了返回',
content: '是否确认放回',
success: e => {
if (e.confirm) {
const pages = Taro.getCurrentPages();
if (pages.length >= 2) {
Taro.navigateBack({
delta: 1
});
} else {
Taro.navigateTo({
url: '/pages/index/index'
});
}
}
}
code
}
})
switch (response.statusCode) {
case 200:
await Taro.setStorage({
key: 'token',
data: response.data
})
Taro.eventCenter.trigger('user::logged_in', response.data)
Taro.navigateBack()
break
case 404:
const result = await Taro.showModal({
title: '是否创建新用户',
content: '请求绑定的用户不存在,是否要创建一个新用户?'
})
if (result.confirm) {
this.setState({
action: 'register',
submitButtonText: '注册用户',
wxUserLogin: true
})
Taro.setNavigationBarTitle({
title: '注册用户'
})
}
default: