How to use the vant.Toast.success function in vant

To help you get started, we’ve selected a few vant 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 hanyucd / vue-mall-mobile / mall / src / pages / Register / index.vue View on Github external
let method = 'post';
        let path = Url.registerApi;
        let params = {
          userName: this.userName,
          passWord: this.passWord
        };
        try {
          this.loading = true; // 开启按钮注册状态
          let res = await registerUser(path, method, params);
          console.log(res)
          // 将 token & 用户名存储到 localStorage 中
          localStorage.setItem('token', res.token);
          localStorage.setItem('userName', res.userName);
          // 注册成功提示
          Toast.success({
            duration: 1000,
            message: res.message
          });
          // 1.5 秒后跳转到首页
          let timer = setTimeout(() => {
            this.$router.push({ name: 'Home' }); // 注册成功跳转到首页
            clearTimeout(timer); // 清除定时器
          }, 1500);
        } catch (error) {
          console.log(error)
          this.$toast.fail('注册失败');
        } finally {
          this.loading = false;
        }
      }
    }
github Zkliang1991 / Zkliang1991.github.io / 1901 / vue / hechenxi / src / views / login.vue View on Github external
this.$axios.post("/vue/login", this.loginInfo).then(res => {
          console.log(res.data);
          if (!!res.data.type) {
            window.sessionStorage.userInfo = JSON.stringify({
              token: res.data.token
            });
            window.localStorage.setItem('username',res.data.result.username)
            Toast.success("登录成功 即将跳转");
            this.$router.push({ name: "home" });
          }
        });
      } else {
github jgchenu / Mobile-electricity-provider2 / src / components / pages / Goods.vue View on Github external
let cartInfo = localStorage.cartInfo
        ? JSON.parse(localStorage.cartInfo)
        : [];
      let isHaveGood = cartInfo.find(cart => cart.goodId === this.goodId);
      console.log("ishave", isHaveGood);
      if (!isHaveGood) {
        let newGoodsInfo = {
          goodId: this.goodsInfo.ID,
          name: this.goodsInfo.NAME,
          price: this.goodsInfo.PRESENT_PRICE,
          image: this.goodsInfo.IMAGE1,
          count: 1
        };
        cartInfo.push(newGoodsInfo);
        localStorage.cartInfo = JSON.stringify(cartInfo);
        Toast.success("添加成功");
      } else {
        Toast.success("已有此商品");
      }
      this.$router.push({ name: "Cart" });
    }
  },
github jgchenu / Mobile-electricity-provider2 / src / components / pages / Register.vue View on Github external
.then(res => {
          console.log(res);
          if (res.data.code === 200) {
            Toast.success(res.data.message);
            this.$router.push("/");
          } else {
            console.log(res.data.message);
            this.openLoading = false;
            Toast.fail("注册失败");
          }
        })
        .catch(err => {
github geekape / applet-h5-shop / mpvue / wap / src / pages / shop / comment / index.vue View on Github external
}).then((res) => {
        console.log(res)
        if(res.code == 0) {
          Toast.fail(res.msg)
        } else {
          Toast.success(res.msg)
          this.$router.replace('/center')
        }
        
      })
    },
github czero1995 / fancy-store / src / views / cart / Cart.vue View on Github external
async onAddCart(item) {
            let res = await apiAddCart(item.productId);
            if (res.data.code === 0) {
                Toast.success({
                    message: this.$t("m.message.addSuccess"),
                    duration: 500
                });
                item.num++;
            } else {
                Toast.fail({
                    message: res.data.msg,
                    position: "bottom"
                });
            }

            this.onCalAllCoach();
        },
        async onCutCart(item) {
github jgchenu / Mobile-electricity-provider2 / src / components / pages / Login.vue View on Github external
created(){
    if (localStorage.userInfo) {
      Toast.success('你已经登录过了')
      this.$router.push('/')
    }
  },
  methods: {
github czero1995 / fancy-store / src / views / category / Category.vue View on Github external
async onAddCart(item) {
            let res = await apiAddCart(item.uid);
            if (res.data.code === 0) {
                Toast.success({
                    message: this.$t("m.message.addSuccess"),
                    duration: 500
                });
            } else {
                Toast.fail({
                    message: res.data.msg,
                    position: "bottom"
                });
            }
        },
        onDetail(id) {
github czero1995 / fancy-store / src / views / detail / Detail.vue View on Github external
async onBuy() {
            if (this.isBuy) {
                this.setOrders([this.detailInfo]);
                this.$router.push("./orderwait");
                if (!this.cartNum) {
                    let res = await apiActionCart(this.$route.query.uid, "add");
                    if (res.data.code === 0) {
                        Toast.success({
                            message: this.$t("m.message.addSuccess"),
                            duration: 500
                        });
                    } else {
                        Toast.fail({
                            message: res.data.msg,
                            position: "bottom"
                        });
                    }
                    this.addCartModel = false;
                }
            }
        },
        ...mapMutations({
github czero1995 / fancy-store / src / views / product / Product.vue View on Github external
async onAddCart(item) {
            let res = await apiAddCart(item.uid);
            if (res.data.code === 0) {
                Toast.success({
                    message: this.$t("m.message.addSuccess"),
                    duration: 500
                });
            } else {
                Toast.fail({
                    message: res.data.msg,
                    position: "bottom"
                });
            }
        },
        onCategory(index) {