| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- <!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/red_packet.png') no-repeat center;
- background-size: 100vw 100vh;
- background-repeat: no-repeat;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .cash_prize {
- width: 325px;
- height: 192px;
- background: #FFFFFF;
- border-radius: 20px;
- padding: 20px 20px 15px;
- box-sizing: border-box;
- }
- .cash_prize_title {
- font-weight: 500;
- font-size: 14px;
- color: #222222;
- text-align: center;
- padding-bottom: 15px;
- }
- .cash_input input {
- height: 50px;
- background: #F4F4F4;
- border-radius: 20px;
- text-align: start;
- }
- .cash_btn {
- width: 100%;
- height: 52px;
- margin-top: 20px;
- }
- .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-tip {
- width: 100%;
- height: 100px;
- }
- .dialog-bg {
- width: 295px;
- height: 251px;
- position: relative;
- }
- .prize-msg {
- position: absolute;
- text-align: center;
- }
- .money-title {
- font-weight: 500;
- font-size: 16px;
- color: #FF4E4E;
- padding-top: 90px;
- padding-bottom: 10px;
- }
- .money-content {
- margin-bottom: 30px;
- height: 60px;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .prize-money {
- font-weight: bold;
- font-size: 60px;
- color: #FF4E4E;
- }
- .prize-unit {
- font-weight: 500;
- font-size: 16px;
- color: #FF4E4E;
- padding-left: 10px;
- padding-top: 28px;
- }
- .dialog-btn {
- width: 235px;
- height: 52px;
- margin-bottom: 10px;
- }
- .money-tip {
- font-weight: 400;
- font-size: 12px;
- color: #999999;
- margin-bottom: 15px;
- }
- .dialog-close {
- width: 30px;
- height: 30px;
- margin-top: 20px;
- }
- </style>
- <body>
- <div id="box" class="box">
- <div class="page6">
- <div class="cash_prize">
- <div class="cash_prize_title">请输入您的兑换码</div>
- <el-input v-model="input" placeholder="请输入" class="cash_input"></el-input>
- <el-button type="warning" round class="cash_btn" @click="getMoney">领取</el-button>
- </div>
- <!-- 奖励弹窗 -->
- <div class="prize_dialog" v-if="showPrizeDialog">
- <div class="dialog-body">
- <img class="dialog-tip" src="./img/dialog-tip.png" />
- <img class="dialog-bg" src="./img/dialog-bg.png" />
- <div class="prize-msg">
- <div class="money-title">微信红包</div>
- <div class="money-content">
- <span class="prize-money">{{prizeMoney}}</span>
- <span class="prize-unit">元</span>
- </div>
- <img class="dialog-btn" src="./img/dialog-btn.png" @click="closePop" />
- <div class="money-tip">红包到账会有延迟情况,请以实际为准</div>
- </div>
- <img class="dialog-close" src="./img/dialog-close.png" @click="closePop" />
- </div>
- </div>
- </div>
- </div>
- </body>
- <script>
- new Vue({
- el: '#box',
- data () {
- return {
- httpUrl: '',
- bId: null,
- env: '',
- input: '',
- showPrizeDialog: false,
- prizeMoney: 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.getAuth()
- },
- methods: {
- getAuth () {
- // 获取url上的code
- let code = this.getQueryParam('code')
- if (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) {
- this.openId = data.openId
- }
- })
- } 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)
- }
- },
- getMoney () {
- fetch(this.httpUrl + '/scrm/v1/wxcp-live-code-counselor/p/prizeCode', {
- method: 'post',
- body: JSON.stringify({
- code: this.input,
- openId: this.openId,
- }),
- headers: {
- 'Content-Type': 'application/json'
- }
- }).then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (data) {
- this.prizeMoney = data.money
- this.showPrizeDialog = true
- } else {
- this.$message({
- message: msg,
- type: 'warning'
- })
- }
- })
- },
- closePop () {
- this.showPrizeDialog = false
- this.input = ''
- this.prizeMoney = null
- },
- // 截取url中的数据
- getQueryParam (paramName) {
- // 获取当前URL的查询字符串部分
- const queryString = window.location.search;
- // 创建一个URLSearchParams对象
- const urlParams = new URLSearchParams(queryString);
- // 返回指定参数的值,如果不存在则返回null
- return urlParams.get(paramName);
- },
- }
- })
- </script>
- </html>
|