peng
5 天以前 2fd269af9df3653b058deee57bcd7a9f39ff28e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<template>
  <div></div>
</template>
 
<script>
import { getIMDetail } from "@/api/common";
import Storage from "@/plugins/storage";
import { getMemberMsg } from "@/api/login";
export default {
  data() {
    return {
      Storage,
      IMLink: "",
    };
  },
  methods: {
    // 跳转im客服
    async IMService(id, goodsId, skuId) {
 
      // 获取访问Token
      let accessToken = Storage.getItem("accessToken");
      await this.getIMDetailMethods();
      const userInfo = await getMemberMsg();
      if (userInfo.success) {
        //携带商品Id,在IM可以发送商品信息
        if(goodsId && skuId){
          window.open(
            this.IMLink + "?token=" + accessToken + "&id=" + id || this.storeMsg.storeId + "&goodsId=" + goodsId + "&skuId=" + skuId
          );
        }else{
          window.open(
            this.IMLink + "?token=" + accessToken + "&id=" + id || this.storeMsg.storeId
          );
        }
 
      } else {
        this.$Message.error("请登录后再联系客服");
        return;
      }
    },
    // 获取im信息
    async getIMDetailMethods() {
      let res = await getIMDetail();
      if (res.success) {
        this.IMLink = res.result;
      }
    },
  },
};
</script>
 
<style lang="scss" scoped></style>