home.vue 6.42 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
  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"
            }
xd's avatar
xd committed
65 66
          ],
          logoUrl: "/mainSale/1.png"
xulili's avatar
xulili committed
67 68
        }
      };
69
    },
xulili's avatar
xulili committed
70
    mounted() {
71 72 73
      if (sessionStorage.getItem("userId")) {
        this.zcache.userId = sessionStorage.getItem("userId")
      }else{
xd's avatar
xd committed
74
        this.zReadyUserId();
75 76 77
        this.zTestGetNowUrlInfo();
      }
      
78
    },
xulili's avatar
xulili committed
79
    created() {
80
    },
xulili's avatar
xulili committed
81 82 83 84 85
    methods: {
      zReadyUserId() {
        if (this.$route.query.code === undefined){
          this.zTestPreAuthCode()
        } else {
xd's avatar
xd committed
86 87
          this.zTestGetNowUrlInfo()
          this.zTestGetUserInfoByOldToken()
xulili's avatar
xulili committed
88 89 90 91
        }
      },
      // 测试-获取当前Url信息
      zTestGetNowUrlInfo() {
xd's avatar
xd committed
92 93 94
        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
95 96 97 98 99 100
      },
      zTestPreAuthCode() {
        const basicInfo = {
          head: "https://open.weixin.qq.com/connect/oauth2/authorize?",
          // appId: "wwd1cdbca7b8b2b6c4",
          appId: "ww4df265003b43fa0d",
xd's avatar
xd committed
101
          redirectUrI: encodeURIComponent("oysales.oywanhao.com"),
xulili's avatar
xulili committed
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 135 136 137 138 139 140
          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,
141
        })
xulili's avatar
xulili committed
142
          .then(res => {
143 144
            this.zcache.userInfoResNew = "RESOK:" + res.data.data.userId
            sessionStorage.setItem("userId", String(res.data.data.userId))
xulili's avatar
xulili committed
145
            this.zcache.userId = String(res.data.data.userId);
146
            sessionStorage.setItem("userId", String(res.data.data.userId))
xulili's avatar
xulili committed
147 148 149 150 151
          })
          .catch(err => {
            this.zcache.userInfoResNew = "RESERR.";
          });
      },
152
      listClick(inData) {        
xulili's avatar
xulili committed
153 154 155
        this.$router.push({
          name: inData,
          params: {userId: this.zcache.userId}
156
        });
xulili's avatar
xulili committed
157 158 159
      },
    }
  };
xulili's avatar
xulili committed
160 161
</script>

xulili's avatar
xulili committed
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 228 229 230 231 232 233 234
<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
235
</style>