123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449 |
- <template>
- <div class="userInfo_top-box">
- <div class="go_landing">
- <div class="center_landing">
- <div class="center_landingl">
- <p class="center_text">
- <span class="telnum">{{ $t("homePage.CallName") }}</span
- >{{ $t("taps.Telnum") }} <br /><router-link
- class="contact"
- to="/contact"
- >{{ $t("homePage.us") }}</router-link
- >
- </p>
- <el-row class="block-col-2">
- <el-col>
- <el-select v-model="locale" placeholder="" @change="changeLocale">
- <el-option
- v-for="item in list"
- :key="item.value"
- :label="item.name"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-col>
- </el-row>
- </div>
- <div class="center_landingr">
- <el-row class="block-col-2" v-if="tokenShow">
- <el-col>
- <el-dropdown trigger="click">
- <span class="el-dropdown-link">
- {{ info.name || info.nickname
- }}<i class="el-icon-arrow-down el-icon--right"></i>
- </span>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item
- @click.native="$router.push({ name: 'address' })"
- >{{ $t("checkout.Addre") }}</el-dropdown-item
- >
- <el-dropdown-item
- @click.native="$router.push({ name: 'orderList' })"
- >{{ $t("checkout.Order") }}</el-dropdown-item
- >
- <el-dropdown-item @click.native="signOut">{{
- $t("checkout.Sign")
- }}</el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </el-col>
- </el-row>
- <div class="login_b" v-if="!tokenShow">
- <el-button
- class="buttom"
- type="primary"
- icon="el-icon-user-solid"
- @click="$router.push({ name: 'login' })"
- >{{ $t("landing.registration") }}</el-button
- >
- </div>
- <div
- class="goshopping_box"
- @click="$router.push({ name: 'mycart' })"
- @mouseenter="mouseenterMycar"
- >
- <p class="center_text mycart_t">
-
- <img
- src="@/assets/img/gouwugouwuchedinggou.png"
- class="images-mycar"
- />
- {{ $t("homePage.basket") }}
- <span class="goshopping_text" v-if="num > 0">({{ num }})</span>
- </p>
- <div
- class="taps_cart"
- :class="mycartShow ? 'mycart_aps' : ''"
- @mouseleave="mouseleaveMycar"
- >
- <dissMycart
- v-show="mycartShow"
- :list="listCart"
- :count="cartTotal"
- ref="dissMycart"
- ></dissMycart>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import Bus from "@/js/bus";
- import dissMycart from "./diss-mycart";
- var that = this;
- export default {
- name: "userInfo",
- components: {
- dissMycart
- },
- data() {
- return {
- listCart: [],
- cartTotal: 0,
- mycartShow: localStorage.getItem("cartTap") === "1",
- info: "",
-
- locale: this.$util.localeStorage()
- ? this.$t("homePage.English")
- : this.$t("homePage.Chinese"),
- tokenShow: !!localStorage.getItem("token"),
- list: [
- {
- id: 1,
- value: "en",
-
- name: this.$t("homePage.English")
- },
- {
- id: 2,
- value: "cn",
-
- name: this.$t("homePage.Chinese")
- }
- ],
- num: JSON.parse(localStorage.getItem("shoppingNum"))
- };
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
- created() {
- this.info = JSON.parse(localStorage.getItem("info"));
- this.getList();
- },
- mounted() {
- let _this = this;
- Bus.$on("onmycar", val => {
-
-
- if (val == 1) {
-
- this.showList = false;
- this.mouseenterMycar();
-
- } else {
- _this.mouseleaveMycar();
- }
- });
- window.addEventListener("setItemEvent", function(e) {
-
-
- if (e.key === "shoppingNum") {
- _this.num = e.newValue;
- }
-
-
-
-
-
-
-
-
- });
- },
- methods: {
- changeLocale(e) {
- sessionStorage.removeItem("tdk");
- localStorage.removeItem("token");
- if (e == "en") {
- window.location.href = "https://crs.sanyoubio.com";
- } else {
- window.location.href = "https://crs.sanyoubio.com.cn";
- }
- },
- signOut() {
- let data = JSON.parse(localStorage.getItem("shoppingCart"));
- if (data) {
- localStorage.setItem("shoppingNum", JSON.stringify(data.length));
- } else {
- localStorage.setItem("shoppingNum", JSON.stringify(0));
- }
- localStorage.removeItem("user");
- localStorage.removeItem("token");
- localStorage.removeItem("info");
- this.$router.push({
- name: "login"
- });
- },
- mouseenterMycar() {
- this.mycartShow = true;
- this.getList();
- },
- mouseleaveMycar() {
- this.mycartShow = false;
- },
- getList() {
- let that = this;
- let data = JSON.parse(localStorage.getItem("shoppingCart"));
- let arry = [];
- if (JSON.parse(localStorage.getItem("token"))) {
- if (data && data.length > 0) {
- data.forEach(item => {
- var obj = {
- checked: true,
- id: item.id,
- number: item.number,
- productCatalog: item.productCatalog,
- skuId: item.skuId
- };
- arry.push(obj);
- });
- } else {
- arry = null;
- }
- this.$api
- .post("cart/index", {
- cartList: arry
- })
- .then(res => {
- if (res.code == 0) {
- this.listCart = res.data.cartList;
- that.cartTotal = res.data.cartTotal.checkedGoodsDiscount;
- } else {
-
- }
- });
- } else {
- if (data && data.length > 0) {
- that.listCart = [];
- that.cartTotal = 0;
- data.forEach(item => {
- that.listCart.push(item);
- if (this.$util.localeStorage()) {
- that.cartTotal += item.number * item.discountPrice;
- } else {
- that.cartTotal += item.number * item.cnDiscountPrice;
- }
- });
- }
- }
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- @media screen and (min-width: 751px) and (max-width: 9999px) {
- .userInfo_top-box {
- .go_landing {
- // background-color: #273949;
- .center_landing {
- margin: 0 auto;
- display: flex;
- justify-content: space-between;
- // align-items: center;
- align-content: center;
- .center_landingl {
- text-align: center;
- font-weight: 500;
- .block-col-2 /deep/ {
- cursor: pointer;
- .el-col {
- .el-select {
- width: 100px;
- height: 30px;
- .el-input__inner {
- border: none;
- height: 26px;
- line-height: 26px;
- font-size: 12px;
- // background-color: rgba(0, 0, 0, 0);
- }
- .el-input__suffix {
- .el-input__suffix-inner {
- display: block;
- height: 100%;
- .el-input__icon {
- line-height: 26px;
- }
- }
- }
- }
- }
- .el-dropdown {
- height: 50px;
- line-height: 50px;
- width: 100px;
- display: block;
- }
- .el-dropdown-link {
- color: #fff;
- margin-left: 20px;
- }
- .el-icon-arrow-down {
- margin-left: 10px;
- // color: red;
- }
- .el-dropdown:hover {
- background: #005bab;
- // color: red;
- }
- }
- .center_text {
- color: #005bab;
- cursor: pointer;
- font-weight: 600;
- font-size: 12px;
- .telnum {
- color: #000;
- margin-right: 4px;
- font-weight: 500;
- }
- .contact {
- color: #005bab;
- }
- }
- }
- .center_landingr {
- margin-left: 20px;
- .block-col-2 /deep/ {
- cursor: pointer;
- .el-dropdown {
- height: 28px;
- line-height: 28px;
- width: 100px;
- display: block;
- text-align: right;
- }
- .el-dropdown-link {
- color: #000;
- margin-left: 20px;
- font-size: 12px;
- }
- .el-icon-arrow-down {
- margin-left: 6px;
- }
- .el-dropdown:hover {
- background: #fff;
- }
- }
- .center_text {
- color: #fff;
- cursor: pointer;
- }
- .login_b {
- display: block;
- color: #000;
- .buttom /deep/ {
- background-color: rgba(0, 0, 0, 0);
- border: none;
- color: #000 !important;
- padding: 6px 8px !important;
- font-size: 12px;
- .el-icon-user-solid {
- color: #005bab !important;
- }
- }
- }
- }
- }
- }
- }
- .goshopping_box {
- position: relative;
- .goshopping_text {
- font-size: 14px;
- }
- .taps_cart {
- display: none;
- position: absolute;
- top: 35px;
- z-index: 1000;
- // left: 50%;
- right: 0;
- // transform: translateX(-50%);
- }
- .mycart_aps {
- display: block !important;
- }
- }
- .cardpmd {
- display: none;
- }
- .landingpmd_imgf {
- display: none;
- }
- .center_text {
- color: #fff;
- a {
- color: #fff;
- cursor: pointer;
- text-decoration: none;
- }
- a:hover {
- color: #005bab;
- cursor: pointer;
- text-decoration: none;
- }
- }
- .mycart_t /deep/ {
- display: flex;
- align-items: center;
- color: #000 !important;
- justify-content: right;
- padding-right: 8px;
- font-weight: 500;
- font-size: 12px;
- .images-mycar {
- width: 30px;
- margin-right: 6px;
- }
- .el-icon-shopping-cart-2 {
- // color: #005BAB;
- color: red;
- font-weight: 600;
- font-size: 30px;
- margin-right: 6px;
- }
- .goshopping_text {
- margin-left: 6px;
- color: #005bab;
- }
- }
- }
- // @media screen and (min-width: 751px) and (max-width: 1600px) {
- // .taps_cart{
- // display: none;
- // position: absolute;
- // top: 30px;
- // z-index: 99;
- // left: -50% !important;
- // // transform: translateX(-50%);
- // }
- // }
- </style>
|