<template>
  <div>
    <van-nav-bar class="navBar" title="下单成功"   />
    <div style="    background-color: rgb(74, 202, 109);
    color: #fff;
    width: 132px;
    height: 132px;
    border-radius: 106px;
    text-align: center;
    line-height: 190px;    margin: 38% auto 80px;">
      <van-icon name="success"  size="80"/>
    </div>
    <van-row gutter="20" style="text-align: center">
      <van-col span="12"><van-button icon="home" style="width: 120px" size="small" round  type="primary" @click="goback">去首页</van-button>
      </van-col>
      <van-col span="12"><van-button icon="guide-o"  style="width: 120px" size="small" round  type="info" @click="visite">继续拜访</van-button></van-col>
    </van-row>
  </div>
</template>

<script>
import {addstoreRegister, addVisitsPosition, checkVisit, mobileReposition} from "@/api";
import axios from "axios";
import home from "@/assets/Icon/home.png";
import {getVisitsParams} from "@/api/inventory";
export default {
  name: "success",
  data(){
    return{
      fromValue:{},
      home:home,
    }
  },
  created() {
    this.addstoreRegister()
  },
  watch: {
    $route(to, from) {
      if (to.path == "/success") {
        this.addstoreRegister()
      }
    }
  },
  methods: {
    addstoreRegister() {
      getVisitsParams({storeCode: this.$route.query.storeCode}).then(res => {
        this.fromValue = res.data
      })
    },
    goback() {
      window.location.replace(window.location.origin + "/mobile/")
    },
    visite() {
      if (this.fromValue != undefined) {
        if (this.fromValue.url != undefined) {
          window.location.replace(window.location.origin + "/mobile" + this.fromValue.url)
        } else {
          this.$dialog.alert({
            message: "拜访地址有误，请联系管理员！",
          }).then(() => {
          });
        }
      } else {
        this.$dialog.alert({
          message: "拜访地址有误，请联系管理员！",
        }).then(() => {
        });
      }
    }
  }
}
</script>
