How to use the @tarojs/taro.showModal function in @tarojs/taro

To help you get started, we’ve selected a few @tarojs/taro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NervJS / taro-ui-demo / src / pages / view / tag / index.js View on Github external
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)
  }
github huangjianke / Gitter / src / pages / activity / index.js View on Github external
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('用户点击取消')
          }
        }
      })
github huangjianke / Gitter / src / pages / account / about.js View on Github external
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('用户点击取消')
        }
      }
    })
github huangjianke / Gitter / src / app.js View on Github external
updateManager.onUpdateReady(() => {
        Taro.showModal({
          title: '更新提示',
          content: '新版本已经准备好,是否重启应用?',
          success(res) {
            if (res.confirm) {
              updateManager.applyUpdate()
            }
          }
        })
      })
      updateManager.onUpdateFailed(() => {
github EasyTuan / taro-msparis / src / pages / addressUpdate / index.js View on Github external
delete = () => {
    Taro.showModal({
      content: '是否删除该地址?',
    }).then(res => {
      if (res.confirm) {
        this.props.dispatch({
          type: 'addressUpdate/removeAddress',
        });
      }
    });
  };
github NervJS / taro-ui-demo / src / pages / view / noticebar / index.js View on Github external
onGotoMore () {
    if (Taro.getEnv() === Taro.ENV_TYPE.WEB) {
      alert('您点击了更多!')
    } else {
      Taro.showModal({
        content: '点击了更多!',
        cancelText: '取消'
      })
    }
  }
github lingxiaoyi / Taro-navigation-bar / src / pages / demo / mixin.js View on Github external
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'
                });
              }
            }
          }
github ninghao / w-store-app / src / pages / user / account.js View on Github external
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: