| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>专属活码</title>
- <!--引入 element-ui 的样式,-->
- <link rel="stylesheet"
- href="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742018383195/element-ui.css">
- <!-- 必须先引入vue, 后使用element-ui -->
- <script
- src="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742017957144/vue.js"></script>
- <!-- 引入element 的组件库-->
- <script
- src="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742017747738/element-ui.js"></script>
- <script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
- <!-- <script>
- var vConsole = new window.VConsole();
- </script> -->
- </head>
- <style>
- body {
- margin: 0;
- padding: 0;
- }
- .box {
- width: 100vw;
- height: 100vh;
- box-sizing: border-box;
- }
- .page1 {
- background: #FAFAFA;
- }
- .page2 {
- background: #FFFFFF;
- }
- .ready_code_box {
- position: relative;
- padding-top: 70px;
- }
- .ready_code {
- width: 100%;
- }
- .code_tip {
- position: absolute;
- bottom: 7px;
- font-weight: bold;
- font-size: 24px;
- color: #222222;
- text-align: center;
- width: 100%;
- }
- .form_title {
- font-weight: bold;
- font-size: 24px;
- color: #222222;
- text-align: center;
- width: 100%;
- padding: 60px 0 7px;
- background: #FAFAFA;
- }
- .main_tip {
- color: #2885FF;
- }
- .page_tip {
- font-weight: 500;
- font-size: 14px;
- color: #222222;
- text-align: center;
- width: 100%;
- padding-top: 8px;
- }
- .page_tip_page2 {
- padding-bottom: 40px;
- }
- .form_list {
- background: #FFFFFF;
- }
- .page_btn {
- width: 305px;
- height: 52px;
- line-height: 52px;
- background: #222222;
- border-radius: 20px;
- font-weight: 500;
- font-size: 16px;
- color: #FFFFFF;
- text-align: center;
- }
- .el-form-item__label {
- padding-right: 0;
- font-weight: 500;
- font-size: 14px;
- color: #666666;
- }
- .el-input__inner {
- border: none;
- font-weight: 500;
- font-size: 14px;
- color: #222222;
- text-align: right;
- }
- .el-form-item {
- margin-bottom: 0;
- border-bottom: 1px solid #F9F9F9;
- padding: 10px 0;
- padding-left: 35px;
- }
- .live_code_box {
- position: relative;
- padding-top: 96px;
- width: 315px;
- height: 329px;
- margin: 0 auto;
- }
- .salesMan_style {
- text-align: center;
- line-height: 14px;
- padding-bottom: 10px;
- }
- .live_code_bg {
- width: 315px;
- }
- .live_code {
- width: 180px;
- position: absolute;
- top: 195px;
- left: 68px;
- }
- .live_code_tip {
- position: absolute;
- bottom: 0;
- font-weight: 500;
- font-size: 14px;
- color: #222222;
- width: 100%;
- text-align: center;
- }
- .foot_btn {
- display: flex;
- align-items: center;
- position: fixed;
- bottom: 40px;
- left: 30px;
- }
- .save_btn {
- width: 152px;
- height: 52px;
- line-height: 52px;
- text-align: center;
- border-radius: 20px;
- border: 1px solid #222222;
- box-sizing: border-box;
- font-weight: 500;
- font-size: 16px;
- color: #222222;
- margin-right: 11px;
- }
- .data_btn {
- width: 152px;
- height: 52px;
- line-height: 52px;
- text-align: center;
- background: #222222;
- border-radius: 20px;
- font-weight: 500;
- font-size: 16px;
- color: #FFFFFF;
- }
- </style>
- <body>
- <div id="box" class="box" :class="step === 2 ? 'page2' : 'page1'">
- <!-- 引导页面 -->
- <div v-if="step === 1">
- <div class="ready_code_box">
- <image class="ready_code" src="./img/ready_code.png"></image>
- <div class="code_tip">
- <span>生成我的</span>
- <span class="main_tip">专属活码</span>
- </div>
- </div>
- <div class="page_tip">引导门店客户添加,领取引流激励!</div>
- <div class="page_btn" style="margin: 150px auto 0;" @click="createQrcode">创建活码</div>
- </div>
- <!-- 创建活码 -->
- <div v-if="step === 2">
- <div class="form_title">
- <span>生成我的</span>
- <span class="main_tip">专属活码</span>
- </div>
- <div class="page_tip page1 page_tip_page2">引导门店客户添加,领取引流激励!</div>
- <div class="form_list">
- <el-form ref="form" :model="form" label-position="left" label-width="84px">
- <el-form-item label="顾问姓名:">
- <el-input v-model="form.salesMan" placeholder="请输入"></el-input>
- </el-form-item>
- <el-form-item label="经销商名称:">
- <el-input v-model="form.ownerDealerName" placeholder="请输入"></el-input>
- </el-form-item>
- <el-form-item label="经销商代码:">
- <el-input v-model="form.ownerDealerCode" placeholder="请输入"></el-input>
- </el-form-item>
- <el-form-item label="联系电话:">
- <el-input v-model="form.phone" placeholder="请输入"></el-input>
- </el-form-item>
- </el-form>
- </div>
- <div class="page_btn" style="margin: 177px auto 0;" @click="handleQrcode">创建活码</div>
- </div>
- <!-- 我的活码 -->
- <div v-if="step === 3">
- <div class="live_code_box">
- <div class="salesMan_style">{{salesMan}}</div>
- <image class="live_code_bg" src="./img/live_code_bg.png"></image>
- <image class="live_code" :src="qrCode"></image>
- <div class="live_code_tip">
- <div>扫描二维码,添加官方企业微信</div>
- <div>获取最新资讯</div>
- </div>
- </div>
- <div class="foot_btn">
- <div class="save_btn" @click="saveImage">保存二维码</div>
- <div class="data_btn" @click="showData">数据查看</div>
- </div>
- </div>
- </div>
- </body>
- <script>
- new Vue({
- el: '#box',
- data () {
- return {
- httpUrl: '',
- bId: null,
- env: '',
- memberId: null,
- corpId: null,
- step: null,
- qrCode: '',
- salesMan: '',
- form: {
- salesMan: '',
- ownerDealerName: '',
- ownerDealerCode: '',
- phone: ''
- },
- }
- },
- created () {
- this.bId = this.getQueryParam('bId')
- this.env = this.getQueryParam('env')
- if (!this.env || this.env === 'prod') {
- this.httpUrl = 'https://wlapi.wefanbot.com'
- } else {
- this.httpUrl = 'http://test.wefanbot.com:18993'
- }
- if (this.getQueryParam('memberId')) {
- // 已授权
- this.memberId = this.getQueryParam('memberId')
- this.corpId = this.getQueryParam('corpId')
- this.findQrCode()
- } else {
- // 授权
- this.getAuth()
- }
- },
- methods: {
- getAuth () {
- fetch(this.httpUrl + `/p/insuite/p/getRedirectUri?env=${this.env}&bId=${this.bId}`)
- .then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- window.location.replace(data)
- } else {
- this.$message({
- message: msg,
- type: 'warning'
- })
- }
- })
- },
- findQrCode () {
- fetch(this.httpUrl + '/scrm/v1/wxcp-live-code-counselor/p/findQrCodeByH5', {
- method: 'post',
- body: JSON.stringify({
- corpId: this.corpId,
- memberId: this.memberId,
- }),
- headers: {
- 'Content-Type': 'application/json'
- }
- }).then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (data && data.qrCode) {
- this.step = 3
- this.salesMan = data.salesMan
- this.qrCode = data.qrCode
- } else {
- this.$message.error(msg)
- this.step = 1
- }
- })
- },
- createQrcode () {
- this.step = 2
- },
- // 创建活码
- handleQrcode () {
- fetch(this.httpUrl + '/scrm/v1/wxcp-live-code-counselor/p/addByH5', {
- method: 'post',
- body: JSON.stringify({
- corpId: this.corpId,
- memberId: this.memberId,
- ...this.form
- }),
- headers: {
- 'Content-Type': 'application/json'
- }
- }).then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (data && data.qrCode) {
- this.step = 3
- this.qrCode = data.qrCode
- } else {
- this.$message.error(msg)
- this.step = 1
- }
- })
- },
- // 保存二维码
- saveImage () {
- const link = document.createElement('a')
- link.href = this.qrCode
- link.download = 'qrCode.jpg'
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- },
- // 查看数据
- showData () {
- window.location.href = `prize.html?httpUrl=${this.httpUrl}&corpId=${this.corpId}&memberId=${this.memberId}`;
- },
- // 截取url中的数据
- getQueryParam (paramName) {
- // 获取当前URL的查询字符串部分
- const queryString = window.location.search;
- // 创建一个URLSearchParams对象
- const urlParams = new URLSearchParams(queryString);
- // 返回指定参数的值,如果不存在则返回null
- return urlParams.get(paramName);
- },
- }
- })
- </script>
- </html>
|