home.vue 6.17 KB
Newer Older
xulili's avatar
xulili committed
1
<template>
xulili's avatar
xulili committed
2 3 4 5 6 7 8 9 10 11 12 13 14
    <div class="main">
        <div class="lists">
            <div v-for="(item, index) of list.main" :key="index">
                <div class="list" @click="listClick(item.redirect)">
                    <div>
                        <img class="list-logo" :src="item.logoUrl" alt/>
                    </div>
                    <div class="list-infos">
                        <div class="list-info-title">{{item.name}}</div>
                        <div class="list-info-dsc">{{item.dsc}}</div>
                    </div>
                </div>
            </div>
Z's avatar
Z committed
15
        </div>
16
    </div>
xulili's avatar
xulili committed
17 18 19
</template>

<script>
xulili's avatar
xulili committed
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
  import {ApiTestCfPost, ApiTestEaPost} from "@/api/test/test";
  import {configWx, getUserInfo} from "@/utils/aCommon";
  import * as APIHome from "@/api/sidebar/home";
  import axios from "axios";

  const zlog = console.log.bind(console);

  export default {
    name: "home",
    data() {
      return {
        zcache: {
          nowUrl: "",
          preAuthCodeUrl: "",
          code: "",
          userId: "",
          userInfoResOld: "",
          userInfoResNew: ""
        },
        list: {
          main: [
            {
              name: "顾客画像",
              dsc: "欧亚会员画像,通过一方消费者数据结合三方数据为营业员展示顾客特点",
              redirect: "ManInfo",
              logoUrl: "/mainSale/1.png"
            },
            {
              name: "优惠券推送",
              dsc: "欧亚会员画像,通过一方消费者数据结合三方数据为营业员展示顾客特点",
              redirect: "Discount",
              logoUrl: "/mainSale/2.png"
            },
            {
              name: "爆品推送",
              dsc: "欧亚会员画像,通过一方消费者数据结合三方数据为营业员展示顾客特点",
              redirect: "GoodPost",
              logoUrl: "/mainSale/3.png"
            },
            {
              name: "营销工具箱",
              dsc: "欧亚营销工具箱,通过营销工具箱可以为营业员提供更多的在线营销工具",
              redirect: "register",
              logoUrl: "/mainSale/4.png"
            }
          ]
        }
      };
68
    },
xulili's avatar
xulili committed
69 70 71
    mounted() {
      this.zReadyUserId();
      this.zTestGetNowUrlInfo();
72
    },
xulili's avatar
xulili committed
73
    created() {
74
    },
xulili's avatar
xulili committed
75 76 77 78 79
    methods: {
      zReadyUserId() {
        if (this.$route.query.code === undefined){
          this.zTestPreAuthCode()
        } else {
xd's avatar
xd committed
80 81
          this.zTestGetNowUrlInfo()
          this.zTestGetUserInfoByOldToken()
xulili's avatar
xulili committed
82 83 84 85
        }
      },
      // 测试-获取当前Url信息
      zTestGetNowUrlInfo() {
xd's avatar
xd committed
86 87 88
        this.zcache.nowUrl = JSON.stringify(this.$route.query)
        this.zcache.code = String(this.$route.query.code)
        zlog("%c--->zTestGetNowUrlInfo: ", "color: orange;", this.zcache.nowUrl)
xulili's avatar
xulili committed
89 90 91 92 93 94
      },
      zTestPreAuthCode() {
        const basicInfo = {
          head: "https://open.weixin.qq.com/connect/oauth2/authorize?",
          // appId: "wwd1cdbca7b8b2b6c4",
          appId: "ww4df265003b43fa0d",
xd's avatar
xd committed
95
          redirectUrI: encodeURIComponent("oysales.oywanhao.com"),
xulili's avatar
xulili committed
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
          responseType: "code",
          scope: "snsapi_base",
          state: "ztest",
          tail: "#wechat_redirect"
        };

        let url =
          basicInfo.head +
          "appid=" +
          basicInfo.appId +
          "&redirect_uri=" +
          basicInfo.redirectUrI +
          "&response_type=" +
          basicInfo.responseType +
          "&scope=" +
          basicInfo.scope +
          "&state=" +
          basicInfo.state +
          basicInfo.tail;

        zlog("%c--->zTestPreAuthCode: Url =", "background: orange", url);
        this.zcache.preAuthCodeUrl = url;

        window.location.href = url;
      },
      // 测试-获取用户信息
      zTestGetUserInfoByOldToken() {
        let postData = {
          code: this.zcache.code,
        };
        let headerData = {
          agentId: "1000032",
          corpId: "ww4df265003b43fa0d"
        };
        this.zcache.userInfoResOld = "PostData:" + JSON.stringify(postData);
        axios({
          url: "http://139.155.48.151:8085/workWx/auth/oauth2/getUserInfo?code=" + this.zcache.code,
          method: "post",
          headers: headerData,
135
        })
xulili's avatar
xulili committed
136 137 138 139 140 141 142 143 144 145 146 147 148
          .then(res => {
            this.zcache.userInfoResNew = "RESOK:" + res.data.data.userId;
            sessionStorage.setItem("userId", String(res.data.data.userId));
            this.zcache.userId = String(res.data.data.userId);
          })
          .catch(err => {
            this.zcache.userInfoResNew = "RESERR.";
          });
      },
      listClick(inData) {
        this.$router.push({
          name: inData,
          params: {userId: this.zcache.userId}
149
        });
xulili's avatar
xulili committed
150 151 152
      },
    }
  };
xulili's avatar
xulili committed
153 154
</script>

xulili's avatar
xulili committed
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
<style scoped lang="scss">
    .main {
        background-color: white;
        width: 100%;
        height: 100%;

        display: flex;
        flex-direction: column;
        justify-content: start;
        overflow: scroll;
    }

    .lists {
        height: auto;
        padding: 4px 12px;
        padding-bottom: 40px;

        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        overflow: scroll;
    }

    .list {
        height: 140px;
        box-shadow: 0px 2px 4px 0px rgb(187, 187, 187);
        margin: 6px 0px;
        padding: 0px 12px;
        border-radius: 6px;

        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
    }

    .list-logo {
        /* border: 1px solid red; */
        width: 100px;
        height: 100px;
        border-radius: 6px;
    }

    .list-infos {
        /* border: 1px solid orange; */
        height: 100px;
        padding-left: 12px;

        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
    }

    .list-info-title {
        width: 100%;
        height: 18px;

        font-size: 16px;
        font-weight: bold;
        line-height: 18px;
    }

    .list-info-dsc {
        margin-top: 6px;
        width: 100%;
        height: 16px;

        font-size: 12px;
        font-weight: normal;
        line-height: 18px;
    }
xulili's avatar
xulili committed
228
</style>