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

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
      <!-- <button class="testButton" @click="zTestPreAuthCode">preAuthCodeUrl</button>
      <div class="fkwindow">{{zcache.preAuthCodeUrl}}</div> -->
<!-- 
      <button class="testButton" @click="zTestGetNowUrlInfo">nowUrlInfo</button>
      <div class="fkwindow">{{zcache.nowUrl}}</div> -->

      <!-- <button class="testButton" @click="zTestGetUserInfoByOldToken">GetUserInfoByOldToken</button>
      <div class="fkwindow">{{zcache.userInfoResOld}}</div> -->

      <!-- <button class="testButton" @click="zTestGetUserInfoByNewToken">GetUserInfoByNewToken</button> -->
      <!-- <button class="testButton" @click="zTestGetUserInfoByNewToken">RES</button> -->
      <!-- <div
        style="border:1px solid limegreen;padding:4px;height: 100px; width: 100%; overflow: auto; font-size:14px;word-wrap:break-word;"
      >{{zcache.userInfoResNew}}</div> -->
    </div>
36

Z's avatar
Z committed
37 38
    <div class="menus">
      <div class="menu" @click="buttonMainMarketingClick">精准营销</div>
Z's avatar
Z committed
39
      <div class="menu activeMenu" @click="buttonSingleMarketingClick">一对一营销侧边栏</div>
Z's avatar
Z committed
40
    </div>
41
  </div>
xulili's avatar
xulili committed
42 43 44
</template>

<script>
45
import { ApiTestCfPost, ApiTestEaPost } from "@/api/test/test";
46 47 48 49
import { configWx, getUserInfo } from "@/utils/aCommon";
import * as APIHome from "@/api/sidebar/home";
import axios from "axios";
const zlog = console.log.bind(console);
50

51 52
export default {
  name: "home",
Z's avatar
Z committed
53 54
  data() {
    return {
55 56 57 58 59 60 61 62
      zcache: {
        nowUrl: "",
        preAuthCodeUrl: "",
        code: "",
        userId: "",
        userInfoResOld: "",
        userInfoResNew: ""
      },
Z's avatar
Z committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
      list: {
        main: [
          {
            name: "顾客画像",
            dsc:
              "亿百分会员画像,通过一方消费者数据结合三方数据为营业员展示顾客特点",
            redirect: "Discount",
            logoUrl: "/mainSale/test-city.png"
          },
          {
            name: "优惠券推送",
            dsc:
              "亿百分会员画像,通过一方消费者数据结合三方数据为营业员展示顾客特点",
            redirect: "Discount",
            logoUrl: "/mainSale/test-city.png"
          },
          {
            name: "爆品推送",
            dsc:
              "亿百分会员画像,通过一方消费者数据结合三方数据为营业员展示顾客特点",
            redirect: "Discount",
            logoUrl: "/mainSale/test-city.png"
          }
        ]
      }
    };
  },
90
  mounted() {
Z's avatar
Z committed
91
    // this.zReadyUserId()
92 93 94
    // this.zTestGetNowUrlInfo();
  },
  created() {
Z's avatar
Z committed
95
    this.zReadyUserId()
96 97 98
    // this.zReadyUserId();
    // this.zTestGetNowUrlInfo();
  },
99
  methods: {
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
    zReadyUserId() {
      zlog(
        "%c--->this.zcache.code =",
        "color: orange;",
        this.$route.query.code
      );
      if (this.$route.query.code === undefined) {
        this.zTestPreAuthCode();
      } else {
        this.zTestGetNowUrlInfo()
        this.zTestGetUserInfoByOldToken()
      }

      // if(this.zcache.code === "") {
      //   this.zTestGetUserInfoByOldToken()
      // } else {
      //   this.zTestPreAuthCode()
      // }
    },
    // 测试-获取当前Url信息
    zTestGetNowUrlInfo() {
      this.zcache.nowUrl = JSON.stringify(this.$route.query);
      this.zcache.code = String(this.$route.query.code);

      zlog("%c--->zTestGetNowUrlInfo: ", "color: orange;", this.zcache.nowUrl);
    },
    // 测试-获取预授权码
Z's avatar
Z committed
127
      // redirectUrI: encodeURIComponent(location.href.split('#')[0]),
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 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
    zTestPreAuthCode() {
      const basicInfo = {
        head: "https://open.weixin.qq.com/connect/oauth2/authorize?",
        appId: "wwd1cdbca7b8b2b6c4",
        redirectUrI: encodeURIComponent("qywx2.100smartdata.com"),
        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: "1000015",
        corpId: "wwd1cdbca7b8b2b6c4"
      };

      // url: "http://139.155.48.151:8085/workWx/auth/oauth2/getUserInfo",
      // headers: header,
      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,
        data: postData
      })
        .then(res => {
          // this.zcache.userInfoResNew = "RESOK:" + JSON.stringify(res.data);
          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(res => {
          this.zcache.userInfoResNew = "RESERR.";
        });
    },
    zTestGetUserInfoByNewToken() {
      // let basicInfo = {
      //   token: sessionStorage.getItem("XToken"),
      //   code: this.$route.query
      // };
      // getUserInfo()
      //   .then(res => {
      //     zlog('%c--->getUserInfo: res =', 'background: red;')
      //   })
      // let token =
      //   "2CjH4hx8dtY_uQYjRggRk0NxtuBrpYC9Z7kqytWgys2AlIUWzCFEGeYfVCM3Ywq16M-WA7n7oMWMNMJl8JXxEgiTNIsil-Z7YzoDoeVaoilwIaukTBfppmkqQZd7uxfxK8I5CDXDB2GtZI_ufke6ln9n30vfq7p6Q8BzBplmoRLXR21qLgVmcfEcaHO0UbcnVTyHStG0FVad-dZY_AsJ-g";
      // let code = this.zcache.code;
      // let url = `https://qyapi.weixin.qq.com/cgi-bin/service/getuserinfo3rd?suite_access_token=${token}&code=${code}`;
      // axios
      //   .get(url)
      //   .then(function(res) {
      //     zcache("$c--->axios: res.", "background: red.");
      //     this.zcache.userInfoResNew = JSON.stringify(res);
      //   })
      //   .catch(function(err) {
      //     zcache("$c--->axios: err.", "background: red.");
      //   });
    },

Z's avatar
Z committed
213 214 215 216 217 218 219 220
    // disClick() {
    //   this.$router.push("Discount");
    // },
    // mainSaleClick() {
    //   this.$router.push("MainSale");
    // },

    listClick(inData) {
221 222 223 224
      // this.$router.push(inData);
      // this.$router.push({name: inData, transData: {userId: this.zcache.code}})
      this.$router.push({name: inData, params: {userId: this.zcache.userId}})
      // this.$router.push({name: inData, params: {userId: 'SEGA'}})
225
    },
Z's avatar
Z committed
226 227 228
    buttonSingleMarketingClick() {
      // this.$router.push("");
    },
Z's avatar
Z committed
229
    buttonMainMarketingClick() {
230
      this.$router.push("MainSale");
231 232
    },

233
    testButton(inCode) {}
xulili's avatar
xulili committed
234
  }
235
};
xulili's avatar
xulili committed
236 237 238
</script>

<style scoped>
Z's avatar
Z committed
239 240 241 242 243 244
/* button {
  border: 1px solid gray;
  margin: 2px;
  border-radius: 4px;
  padding: 4px;
} */
245

Z's avatar
Z committed
246 247 248 249 250 251 252 253
.main {
  background-color: white;
  width: 100%;
  height: 100%;

  display: flex;
  flex-direction: column;
  justify-content: start;
254
  overflow: scroll;
Z's avatar
Z committed
255 256 257 258 259
}
.lists {
  /* border: 2px solid red; */
  height: auto;
  padding: 4px 12px;
260 261
  /* margin-bottom: 20px; */
  padding-bottom: 40px;
Z's avatar
Z committed
262 263 264 265

  display: flex;
  flex-direction: column;
  justify-content: flex-start;
266 267
  align-items: flex-start;
  overflow: scroll;
Z's avatar
Z committed
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
}
.list {
  height: 140px;
  /* border: 2px solid orange; */
  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; */
290
  width: 100;
Z's avatar
Z committed
291
  height: 100px;
292
  padding-left: 12px;
Z's avatar
Z committed
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344

  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;
}

.menus {
  border-top: 1px solid rgb(194, 194, 194);

  position: fixed;
  bottom: 0px;
  left: 0px;
  width: 100%;
  height: 50px;
  background-color: white;

  display: flex;
  flex-direction: row;
  justify-content: start;
  align-items: center;
}
.menu {
  /* border: 1px solid red; */
  height: 50px;
  /* width: 120px; */
  width: 50%;
  line-height: 50px;
  text-align: center;
  font-size: 14px;
  color: black;
}
.activeMenu {
  color: lightcoral;
}
xulili's avatar
xulili committed
345
</style>
346 347

<style scoped>
348 349 350 351 352 353 354 355 356 357 358 359 360 361
.testButton {
  border: 1px solid red;
  /* width: 140px; */
  width: auto;
  font-size: 14px;
  margin-top: 4px;
  padding-bottom: 4px;
}
.fkwindow {
  border: 1px solid limegreen;
  padding: 4px;
  height: 100px;
  width: 100%;
  overflow: auto;
362
  font-size: 14px;
363
  word-wrap: break-word;
364 365
}
</style>