| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469 |
- <!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;
- background: #FAFAFA;
- }
- .page6 {
- width: 100vw;
- height: 100vh;
- background: url('./img/wl_bg.png') no-repeat center;
- background-size: 100vw 100vh;
- background-repeat: no-repeat;
- }
- .wl_no {
- width: 100%;
- margin-top: 260px;
- }
- .wl_btn {
- width: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
- position: relative;
- margin-top: 150px;
- }
- .image_wrapper {
- position: relative;
- display: inline-block;
- }
- .image_wrapper img {
- height: 68px;
- display: block;
- /* 移除图片底部间隙 */
- }
- .btn_text {
- position: absolute;
- top: 46%;
- left: 50%;
- transform: translate(-50%, -46%);
- font-weight: 500;
- font-size: 20px;
- color: #FFFFFF;
- width: 100%;
- text-align: center;
- }
- .ask {
- background: #FEC99D;
- }
- .step {
- display: flex;
- justify-content: center;
- align-items: center;
- padding-top: 27px;
- }
- .step span {
- font-size: 14px;
- color: #BC7E4B;
- }
- .step_line {
- width: 30px;
- height: 1px;
- background: #BC7E4B;
- margin: 0 5px;
- }
- .ask_btn {
- display: flex;
- justify-content: center;
- align-items: center;
- gap: 10px;
- margin-top: 20px;
- }
- .ask_btn img {
- width: 50px;
- height: 50px;
- border-radius: 50%;
- }
- .activity_box {
- width: 100%;
- background: #FEE8D0;
- border-radius: 20px 20px 0 0;
- padding: 20px 15px;
- box-sizing: border-box;
- margin-top: 20px;
- }
- .lottery {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 10px;
- box-sizing: border-box;
- background: #FFFFFF;
- border-radius: 15px;
- margin-bottom: 15px;
- }
- .award {
- display: flex;
- align-items: center;
- gap: 10px;
- }
- .award_ac {
- width: 58px;
- height: 58px;
- border-radius: 10px;
- background: #F5E3D4;
- }
- .award_tip {
- font-size: 14px;
- color: #999999;
- }
- .award_title {
- font-weight: 500;
- font-size: 16px;
- color: #FF765B;
- padding-bottom: 5px;
- }
- .award_btn {
- font-weight: 500;
- font-size: 14px;
- color: #FFFFFF;
- padding: 3px 8px;
- background: #CCCCCC;
- border-radius: 13px;
- }
- .award_btn_ac {
- font-weight: 500;
- font-size: 14px;
- color: #FFFFFF;
- padding: 3px 8px;
- background: #FF7979;
- border-radius: 13px;
- }
- .prize_dialog {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.5);
- /* 半透明黑色 */
- z-index: 1000;
- /* 确保遮罩层在顶部 */
- transition: opacity 0.5s ease;
- /* 可选:添加透明度过渡效果 */
- }
- .dialog_body {
- width: 100%;
- height: 100%;
- z-index: 1001;
- /* 确保遮罩层在顶部 */
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- }
- .dialog_bg {
- max-width: 275px;
- height: 370px;
- border-radius: 20px;
- position: relative;
- object-fit: contain;
- }
- .save_btn {
- padding: 15px 77px;
- background: #FFFFFF;
- border-radius: 29px;
- font-weight: 500;
- font-size: 14px;
- color: #222222;
- margin-top: 20px;
- }
- .activity_title {
- font-weight: bold;
- font-size: 14px;
- color: #CB4E35;
- padding-top: 5px;
- padding-bottom: 15px;
- }
- .activity_msg {
- font-size: 14px;
- color: #CB4E35;
- }
- .activity_msg p {
- margin: 0;
- line-height: 24px;
- }
- </style>
- <body>
- <div id="box" class="box">
- <div class="page6">
- <img class="wl_no" v-if="!lightData.wxcpLightenClientList.length" src="./img/wl_no.png" />
- <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length === 1" src="./img/light_one.png" />
- <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length === 2" src="./img/light_two.png" />
- <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length === 3" src="./img/light_three.png" />
- <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length === 4" src="./img/light_four.png" />
- <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length === 5" src="./img/light_five.png" />
- <div class="wl_btn" @click="handleAsk">
- <div class="image_wrapper">
- <img class="btn_img" src="./img/wl_btn.png" />
- <div class="btn_text">{{lightData.raffle2.leftNum ? '点亮成功,解锁终极大奖' : '邀请好友点亮'}}</div>
- </div>
- </div>
- </div>
- <div class="ask">
- <div class="step">
- <span>1.生成海报</span>
- <span class="step_line"></span>
- <span>2.邀请好友</span>
- <span class="step_line"></span>
- <span>3.完成任务</span>
- </div>
- <div class="ask_btn">
- <img v-for="item in lightData.wxcpLightenClientList" :key="item.head.id" :src="item.head || require('img/ask_btn.png')" />
- <img v-for="i in (5-lightData.wxcpLightenClientList.length)" :key="i" src="img/ask_btn.png" />
- </div>
- <div class="activity_box">
- <div class="lottery">
- <div class="award">
- <img class="award_ac" src="img/lottery1.png" />
- <div class="award_tip">
- <div class="award_title">好运抽奖</div>
- <div>每邀{{lightData.wxcpLighten.raffle1ClientNum}}人抽1次奖,最多{{lightData.wxcpLighten.raffle1NumMax}}次</div>
- </div>
- </div>
- <div v-if="lightData.wxcpLighten.raffle1NumMax === lightData.raffle1.useNum" class="award_btn">已完成</div>
- <div v-else>
- <div v-if="lightData.raffle1.leftNum" class="award_btn_ac" @click="handleLottery(lightData.raffle1BizId)">去抽奖</div>
- <div v-else class="award_btn">未完成</div>
- </div>
- </div>
- <div class="lottery">
- <div class="award">
- <img class="award_ac" src="img/lottery2.png" />
- <div class="award_tip">
- <div class="award_title">终极大奖</div>
- <div>完全点亮即可抽取终极大奖!</div>
- </div>
- </div>
- <div v-if="lightData.wxcpLighten.raffle2NumMax === lightData.raffle2.useNum" class="award_btn">已完成</div>
- <div v-else>
- <div v-if="lightData.raffle2.leftNum" class="award_btn_ac" @click="handleLottery(lightData.raffle2BizId)">去抽奖</div>
- <div v-else class="award_btn">未完成</div>
- </div>
- </div>
- <div class="activity_title">活动信息</div>
- <div class="activity_msg" v-html="lightData.wxcpLighten.activityInfo"></div>
- </div>
- </div>
- <!-- 邀请弹窗 -->
- <div class="prize_dialog" v-if="showAskDialog">
- <div class="dialog_body">
- <img class="dialog_bg" :src="lightData.urlPost" />
- <div class="save_btn" @click="showAskDialog = false">长按图片保存</div>
- </div>
- </div>
- </div>
- </body>
- <script>
- new Vue({
- el: '#box',
- data () {
- return {
- httpUrl: '',
- bId: null,
- env: '',
- showAskDialog: false,
- lightData: {
- urlPost: '',
- wxcpLightenClientList: [],
- wxcpLighten: {
- activityInfo: '',
- raffle1ClientNum: null,
- raffle1NumMax: null, // 抽奖1总次数
- raffle2NumMax: null, // 抽奖2总次数
- },
- raffle1: {
- leftNum: null, // 抽奖1剩余次数
- useNum: null, // 抽奖1已使用次数
- },
- raffle2: {
- leftNum: null, // 抽奖2剩余次数
- useNum: null, // 抽奖2已使用次数
- },
- raffle1BizId: null,
- raffle2BizId: null,
- },
- }
- },
- 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'
- // this.httpUrl = 'http://192.168.1.147:18993'
- }
- this.ifH5Type()
- },
- methods: {
- ifH5Type () {
- if (this.getQueryParam('openId') || localStorage.getItem('openId')) {
- if (!this.getQueryParam('externalUserid')) {
- this.gerQwAuth(this.bId);
- } else {
- this.lightenShare()
- }
- } else {
- // 走授权操作
- this.getAuth();
- }
- },
- getAuth () {
- // 获取url上的code
- let code = this.getQueryParam('code')
- if (code) {
- // 判断业务id是否生产环境业务id
- fetch(this.httpUrl + `/p/insuite/p/isProdId?id=${this.bId}`)
- .then(res => {
- return res.json()
- }).then(result => {
- let { data, msg } = result
- if (typeof data === 'boolean' && data) {
- this.httpUrl = 'https://wlapi.wefanbot.com'
- } else {
- this.httpUrl = 'http://test.wefanbot.com:18993'
- }
- this.getInfoByh5Code(this.getQueryParam('code'))
- })
- } else {
- let redirect_uri = window.location.href
- // code 不存在,走微信网页授权逻辑
- let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
- window.location.replace(url)
- }
- },
- getInfoByh5Code(code) {
- fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
- .then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- localStorage.setItem('openId', data.openId)
- this.ifH5Type()
- }
- })
- },
- // 企微授权
- gerQwAuth (bId) {
- let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
- fetch(this.httpUrl + `/p/insuite/p/getOAUrl?openId=${openId}&bId=${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'
- })
- }
- })
- },
- lightenShare () {
- let externalUserid = this.getQueryParam('externalUserid')
- let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
- const headers = new Headers();
- headers.append('police', 110);
- fetch(this.httpUrl + `/scrm/v1/wxcp-lighten-share/p/lottery?externalUserid=${externalUserid}&openId=${openId}&bId=${this.bId}`, {
- method: 'GET',
- headers: headers
- })
- .then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- this.lightData = data
- } else {
- this.$message({
- message: msg,
- })
- }
- })
- },
- handleAsk () {
- this.showAskDialog = true
- },
- handleLottery (bizId) {
- let url = ''
- if (!this.env || this.env === 'prod') {
- url = `https://lottery.camlook.cn/?bId=${bizId}&h5Type=30`
- } else {
- url = `https://lottery.camlook.cn/?bId=${bizId}&env=dev&h5Type=30`
- }
- window.location.replace(url)
- },
- // 截取url中的数据
- getQueryParam (paramName) {
- // 获取当前URL的查询字符串部分
- const queryString = window.location.search;
- // 创建一个URLSearchParams对象
- const urlParams = new URLSearchParams(queryString);
- // 返回指定参数的值,如果不存在则返回null
- return urlParams.get(paramName);
- },
- }
- })
- </script>
- </html>
|