index.vue 12.7 KB
Newer Older
1
<template>
2 3 4 5 6 7 8
  <div class="main">
    <div class="contents">
      <div class="zListActive">
        <div class="inputs">
          <div class="button" @click="zReadySetVoucherList">ReLoad</div>
        </div>
      </div>
xulili's avatar
xulili committed
9
      <div v-for="item of zlist.voucher" :key="item.coupon_id" >
Z's avatar
Z committed
10 11
        <div class="content">
          <div class="content-imgs">
Z's avatar
Z committed
12
            <img class="imgs-img" :src="zcache.defaultImgUrl" alt />
Z's avatar
Z committed
13 14 15 16
          </div>
          <div class="content-infos">
            <div class="infos-mains">
              <div class="mains">
Z's avatar
Z committed
17 18
                <div class="main-usedPercent">活动ID:{{item.action_id}}</div>
                <div class="main-money">{{item.coupon_title}}</div>
Z's avatar
Z committed
19 20
              </div>
              <div class="buttons">
21
                <button class="button-send" @click="zVoucherPick(item.action_id, item.coupon_id)">推送</button>
Z's avatar
Z committed
22 23 24
              </div>
            </div>
            <div class="infos-tips">
Z's avatar
Z committed
25 26
              <div class="tip-shareMan">优惠券ID:{{item.coupon_id}}</div>
              <!-- <div class="tip-commision">佣金:¥ {{item.commision}}</div> -->
Z's avatar
Z committed
27 28 29 30
            </div>
          </div>
        </div>
      </div>
31
    </div>
32
  </div>
33 34 35
</template>

<script>
36 37 38
// import { ApiTestCfPost, ApiTestEaPost } from "@/api/test/main";
import { ApiEaPost, ApiEaActiveList } from "@/api/test/test";
import { configWx, getUserInfo } from "@/utils/aCommon";
39 40
// import * as APISidebarEA from "@/api/sidebar/ea";
import { getVoucherList, getVoucherWxUrl } from "@/api/sidebar/ea";
Z's avatar
Z committed
41
import { getUserInfoByUserId } from "@/api/sidebar/voucher";
42 43 44 45 46 47 48 49 50 51 52 53
import Vue from "vue";
import { Field } from "vant";
const zlog = console.log.bind(console);

Vue.use(Field);

export default {
  name: "discountIndex",
  data() {
    return {
      zcache: {
        storeId: 1,
Z's avatar
Z committed
54
        userId: "",
55
        unionId: "",
Z's avatar
Z committed
56
        userInfo: "",
57
        defaultImgUrl: "/mainSale/2.png",
58 59 60 61
        now: {
          activeId: "",
          voucherId: "",
        }
62 63 64 65 66 67 68 69 70 71 72 73 74 75
      },
      zlist: {
        voucher: [],
        voucherUrl: ""
      },
      test: {
        list: {
          main: [
            {
              imgUrl: "/mainSale/test-city.png",
              usedPercent: "10",
              money: "100",
              shareMan: "Alice",
              commision: "11"
76
            },
77 78 79 80 81 82
            {
              imgUrl: "/mainSale/test-city.png",
              usedPercent: "20",
              money: "200",
              shareMan: "Bob",
              commision: "22"
83
            }
84
          ]
85
        }
86 87
      },
      dis: {}
88
    };
89 90
  },
  created() {
Z's avatar
Z committed
91 92
    this.zcache.userId = this.$route.params.userId;
    this.zReadyGetUserFromId();
93
    this.getAgentAuth();
94
    this.zReadySetVoucherList()
95 96 97 98 99 100 101 102
  },
  mounted() {
  },
  methods: {
    // 测试-获取预授权码
    zTestPreAuthCode() {
      const basicInfo = {
        head: "https://open.weixin.qq.com/connect/oauth2/authorize?",
103 104
        // appId: "wwd1cdbca7b8b2b6c4",
        appId: "ww4df265003b43fa0d",
xd's avatar
xd committed
105
        redirectUrI: encodeURIComponent("oysales.oywanhao.com"),
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
        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);
      // window.location.href = url
    },
    zReadyGetUserFromId() {
Z's avatar
Z committed
129 130
      let postData = {
        param: this.zcache.userId
131
        // param: 'ZhouHeQiang'
132
      }
Z's avatar
Z committed
133 134
      getUserInfoByUserId(postData)
        .then(res => {
Z's avatar
Z committed
135
          // alert(`--->userInfoFromId: res = ${JSON.stringify(res.data[0])}`);
Z's avatar
Z committed
136
          this.zcache.userInfo = String(res.data[0].departmentId);
xd's avatar
xd committed
137
          // storeId 暂时写死
Z's avatar
Z committed
138
          this.zcache.storeId = 1;
139
          // this.zcache.storeId = Number(res.data[0].stall);
Z's avatar
Z committed
140 141
          this.zReadySetVoucherList();
        })
142
        .catch(err => {})
143
    },
xd's avatar
xd committed
144
    // 获取优惠券列表
145
    zReadySetVoucherList() {
xd's avatar
xd committed
146
      // alert('获取优惠券')
147 148
      this.zReadyDelVoucherList();
      const postData = {
xd's avatar
xd committed
149
        appCode: "0696",    // j接口编码
150 151 152 153
        // mdid: this.zcache.storeId 
        mdid: 1 
      }
      getVoucherList(postData).then(res => {
xd's avatar
xd committed
154
        // alert('getVoucherList')
155 156
        zlog("%c--->VoucherList: RD =", "background: limegreen;", res);
        this.zVoucherSet(res.result.coupons);
157 158
        })
        .catch(err => {
Z's avatar
Z committed
159
        });
160 161 162 163 164
    },
    zReadyDelVoucherList() {
      this.zVoucherDel();
      this.zVoucherUrlDel();
    },
165

166
    zVoucherPick(inActiveId, inVoucherId) {
167 168 169
      this.zcache.now.activeId = String(inActiveId)
      this.zcache.now.voucherId = String(inVoucherId)

170
      this.zVoucherUrlDel();
171

172 173 174 175 176
      const postData = {
        appCode: "0697",
        action_id: Number(inActiveId),
        coupon_id: Number(inVoucherId)
      };
177

178
      zlog("%c--->VoucherWxUrl: PD =", "background: red;", postData);
179

180
      getVoucherWxUrl(postData).then(res => {
181
        this.zVoucherUrlSet(res.result.link)
xd's avatar
xd committed
182
        // alert('获取列表成功')
183 184
      });
    },
185 186 187

    zpick(inMsgType, inUrl) {
      switch (inMsgType) {
188

189 190 191 192 193 194 195 196 197 198 199
        case "text":
          wx.invoke(
            "sendChatMessage",
            {
              msgtype: "text", //消息类型,必填
              text: {
                content: inUrl
              }
            },
            function(res) {
              if (res.err_msg == "sendChatMessage:ok") {
xd's avatar
xd committed
200
                // alert("--->discount.vue: zpick: text 分享成功!")
201
              } else if (res.err_msg != "sendChatMessage:ok") {
xd's avatar
xd committed
202
                // alert('分享失败')
203 204 205 206 207
              }
            }
          );
          break;
        case "h5":
xulili's avatar
xulili committed
208
          // alert(`--->discount.vue: zpick: H5: IN.`);
xd's avatar
xd committed
209
          // alert('zpick')
210 211 212
          wx.invoke(
            "sendChatMessage",
            {
213 214
              msgtype: "news", //消息类型,必填
               news: {
xd's avatar
xd committed
215
                link: `http://oysales.oywanhao.com/qrCode?Url=${inUrl}&activeId=${this.zcache.now.activeId}&voucherId=${this.zcache.now.voucherId}&unionId=1234`, //H5消息页面url 必填
216
                title: "领取优惠券", //H5消息标题
217 218 219 220 221
                desc: inUrl, //H5消息摘要
                imgUrl: inUrl //H5消息封面图片URL
              }
            },
            function(res) {
xd's avatar
xd committed
222
              // alert('sendChatMessage')
223
              if (res.err_msg == "sendChatMessage:ok") {
xd's avatar
xd committed
224
                // alert("--->discount.vue: zpick: h5 分享成功!")
225
              } else if (res.err_msg != "sendChatMessage:ok") {
xd's avatar
xd committed
226
                // alert(`--->discount.vue: zpick: h5 分享失败.`)
xulili's avatar
xulili committed
227 228 229
                // alert(
                //   `--->discount.vue: zpick: h5 分享失败: res =${res.err_msg}`
                // );
230 231 232 233 234 235 236
              }
            }
          );
          break;
        default:
          break;
      }
237 238
    },
    zVoucherSet(inArray) {
xd's avatar
xd committed
239
      // alert('zVoucherSet')
240
      this.zlist.voucher = inArray;
241

242 243 244 245 246 247
    },
    zVoucherDel() {
      this.zlist.voucher = [];
    },
    zVoucherUrlSet(inData) {
      this.zlist.voucherUrl = String(inData);
248
      this.zpick('h5', String(inData))
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
    },
    zVoucherUrlDel() {
      this.zlist.voucherUrl = "";
    },
    // testEaPost() {
    //   let postData = {
    //     appCode: '0603',
    //     condType: 1,
    //     condValue: '138069094',
    //   };
    //   ApiEaPost(postData).then(res => {
    //     console.log(res);
    //   });
    // },

    // testEaPost() {
    //   let postData = {
    //     appCode: '0606',
    //     crmActionDate: '2019-12-12'
    //   };
    //   ApiEaPost(postData).then(res => {
    //     // console.log(res);
    //   });
    // },

    testEaPost() {
      let postData = {
        appCode: "0696",
        mdid: 1
      };
      ApiEaActiveList(postData).then(res => {
        // console.log(res);
      });
    },

    // testEaPost() {
    //   let postData = {
    //     appCode: '0608',
    //     content: 'text',
    //     phone: '18801342762',
    //   };
    //   ApiEaPost(postData).then(res => {
    //     // console.log(res);
    //   });
    // },

    buttonSingleMarketingClick() {
      // this.$router.push("");
    },
    buttonMainMarketingClick() {
      this.$router.push("MainSale");
300
    }
301 302 303
  }
};
</script>
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 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396
<style scoped>
.main {
  background-color: white;
  width: 100%;
  height: 100%;

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

.tops {
  border: 2px solid lightblue;
  width: 100%;
  height: 100px;
}

.contents {
  /* border: 2px solid lightpink; */
  width: 100%;
  height: 100%;
  padding: 16px;
  padding-bottom: 40px;
}

.content {
  border: 0px solid orange;
  height: 100px;
  width: 100%;
  padding: 4px 0px;
  margin-bottom: 16px;

  border-radius: 4px;
  box-shadow: 0px 2px 4px 0px rgb(187, 187, 187);

  display: flex;
  flex-direction: row;
  justify-content: start;
}

.content-imgs {
  /* border: 1px solid pink; */
  width: 20%;
  height: 100%;

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

.imgs-img {
  width: 50px;
  height: 50px;
  margin-top: 10px;
  border-radius: 50%;
  object-fit: cover;
}

.content-infos {
  /* border: 1px solid orange; */
  width: 80%;
  height: 100%;
}

.infos-mains {
  height: 70%;
  width: 100%;
  /* border: 1px solid green; */

  display: flex;
  flex-direction: row;
  justify-content: start;
}

.mains {
  /* border: 1px solid red; */
  width: 70%;
  height: 100%;

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

.main-usedPercent {
  font-size: 14px;
  color: grey;
}

.main-money {
  /* border: 1px solid lightgreen; */
Z's avatar
Z committed
397 398
  /* font-size: 24px; */
  font-size: 20px;
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
}

.buttons {
  /* border: 1px solid darkorange; */
  /* background-color: bisque; */
  width: 30%;
  height: 100%;

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

.button-send {
  border: 0px solid blue;
  height: 40px;
  width: 60px;
  border-radius: 4px;
  background-color: rgba(68, 93, 251, 1);
  color: white;

  font-size: 16px;
}

.infos-tips {
  height: 30%;
  width: 100%;
  /* border: 1px solid red; */
  border-top: 1px dashed gray;
  padding-top: 6px;

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

.tip-shareMan {
  /* border: 1px solid orange; */
  width: 70%;
  height: 100%;

  font-size: 14px;
  line-height: 16px;
  color: rgb(150, 150, 150);
}

.tip-commision {
  /* border: 1px solid green; */
  width: 30%;
  height: 100%;

  font-size: 14px;
  line-height: 16px;
  color: rgb(150, 150, 150);
}

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

.zListActive {
  /*border: 1px solid limegreen;*/
  width: 100%;
  height: auto;
Z's avatar
Z committed
492
  margin-bottom: 16px;
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568

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

.zListActive > .inputs {
  /*border: 1px solid dodgerblue;*/
  width: 100%;
  height: auto;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.zListActive > .inputs > .input {
  /*border-bottom: 2px solid red;*/
  border-color: dodgerblue;
  border-radius: 4px;
  width: 70%;
  height: 40px;
  font-size: 16px;
}

.zListActive > .inputs > .button {
  border: 1px solid dodgerblue;
  border-radius: 4px;
  width: 40%;
  height: 40px;
  font-size: 14px;
  line-height: 36px;
  text-align: center;
}

.zListActive > .lists {
  /*border: 1px solid red;*/
  width: 100%;
  height: auto;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
}

.zListActive > .lists > .item {
  border: 1px solid red;
  width: 100%;
  height: 100px;
  margin-bottom: 16px;
  padding: 4px 4px;

  border-radius: 4px;
  box-shadow: 0px 2px 4px 0px rgb(187, 187, 187);

  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: flex-start;
  font-size: 14px;
}

.zListActive > .lists > .voucherUrl {
  border: 1px solid orange;
  width: 100%;
  height: 100px;
  margin-bottom: 16px;
  padding: 4px 4px;

  border-radius: 4px;
  box-shadow: 0px 2px 4px 0px rgb(187, 187, 187);

  display: flex;
  flex-direction: column;
Z's avatar
Z committed
569
  justify-content: center;
570 571
  align-items: flex-start;
  font-size: 14px;
Z's avatar
Z committed
572
  /* text-wrap: none; */
573
}
574
</style>