| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- <!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://unpkg.com/element-ui/lib/theme-chalk/index.css">
- <!-- 必须先引入vue, 后使用element-ui -->
- <script src="./js/vue.js"></script>
- <!-- 引入element 的组件库-->
- <script src="https://unpkg.com/element-ui/lib/index.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/signup_bg.png') no-repeat top;
- background-size: 100vw 210px;
- background-repeat: no-repeat;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .page_title {
- font-weight: 800;
- font-size: 40px;
- color: #FFFFFF;
- position: fixed;
- top: 40px;
- left: 20px;
- }
- .form_content {
- width: 100%;
- height: calc(100vh - 180px);
- margin-top: 180px;
- background: #FFFFFF;
- border-radius: 20px 20px 0px 0px;
- padding: 20px 20px 66px;
- overflow-y: auto;
- box-sizing: border-box;
- }
- .foot_btn {
- position: fixed;
- bottom: 14px;
- padding: 0 35px;
- width: 100%;
- box-sizing: border-box;
- }
- .signUp_btn {
- height: 52px;
- line-height: 52px;
- background: #1677FF;
- 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;
- }
- .page6s {
- width: 100vw;
- height: 100vh;
- background: url('./img/signup_success.png') no-repeat center;
- background-size: 100vw 100vh;
- background-repeat: no-repeat;
- }
- .succ_tip {
- padding-top: 240px;
- font-weight: bold;
- font-size: 24px;
- color: #222222;
- line-height: 40px;
- text-align: center;
- }
- .signup_page {
- width: 100vw;
- height: 100vh;
- background: url('./img/sign_up.png') no-repeat center;
- background-size: 100vw 100vh;
- background-repeat: no-repeat;
- }
- .signup_title {
- font-weight: bold;
- font-size: 24px;
- color: #FFFFFF;
- padding-top: 80px;
- text-align: center;
- line-height: 41px;
- }
- .fail_box {
- margin: 80px 20px 0;
- height: 287px;
- background: linear-gradient(#D5E6FF 50%, #FFFFFF 100%);
- border-radius: 20px;
- box-sizing: border-box;
- text-align: center;
- }
- .fail_img {
- width: 246px;
- height: 144px;
- margin-top: -20px;
- }
- .fail_title {
- font-weight: 500;
- font-size: 20px;
- color: #222222;
- line-height: 30px;
- padding: 20px 0;
- }
- .fail_tip {
- font-weight: 400;
- font-size: 16px;
- color: #666666;
- line-height: 30px;
- }
- </style>
- <body>
- <div id="box" class="box">
- <div class="page6" v-if="step === 1">
- <div class="page_title">核销领取礼品</div>
- <div class="form_content">
- <el-form ref="form" label-position="left" label-width="100px">
- <el-form-item label="核销码:" required>
- <el-input v-model="verificationCode" placeholder="请输入"></el-input>
- </el-form-item>
- <el-form-item v-for="(item, index) in toshopData.formProList" :key="index" :label="item.name + ':'"
- :required="Boolean(item.isNeed)">
- <el-input v-if="item.type === 0" v-model="item.value" placeholder="请输入"></el-input>
- <el-input v-if="item.type === 1" type="textarea" autosize v-model="item.value" placeholder="请输入"></el-input>
- <el-input v-if="item.type === 2" type="number" v-model="item.value" placeholder="请输入"></el-input>
- <el-date-picker v-if="item.type === 5" v-model="item.value" type="date" placeholder="选择日期">
- <el-time-picker v-if="item.type === 6" v-model="item.value" placeholder="请选择"></el-time-picker>
- <el-date-picker v-if="item.type === 7" v-model="item.value" type="datetime" placeholder="选择日期时间"></el-date-picker>
- </el-form-item>
- </el-form>
- </div>
- <div class="foot_btn">
- <div class="signUp_btn" @click="toSignUp">核销</div>
- </div>
- </div>
- <div class="page6s" v-else-if="step === 2">
- <div class="succ_tip">
- <div>感谢参与{{toshopData.name}}活动</div>
- <div>请联系门店顾问领取礼品</div>
- </div>
- </div>
- <div class="signup_page" v-else-if="step === 3">
- <div class="signup_title">{{toshopData.name}}</div>
- <div class="fail_box">
- <img class="fail_img" src="./img/fail_img.png" />
- <div class="fail_title">很遗憾,您不在此次活动范围内</div>
- <div class="fail_tip">
- <div>后续有活动我们将第一时间通知您</div>
- <div>敬请关注</div>
- </div>
- </div>
- </div>
- </div>
- </body>
- <script>
- new Vue({
- el: '#box',
- data() {
- return {
- httpUrl: '',
- bId: null,
- env: '',
- openId: '',
- toshopData: {
- name: '',
- formProList: [],
- },
- step: 1,
- verificationCode: '',
- }
- },
- 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.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) {
- 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
- localStorage.setItem('openId', data.openId)
- this.ifH5Type()
- }
- })
- } 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)
- }
- },
- // 企微授权
- 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-toshop-verification/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.toshopData = data
- } else {
- this.$message({
- message: msg,
- })
- }
- })
- },
- toSignUp() {
- let cols = []
- cols = this.toshopData.formProList.map(item => {
- return {
- name: item.name,
- type: item.type,
- value: [item.value]
- }
- })
- fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-verification/p/formData?openId=${this.openId}`, {
- method: 'post',
- body: JSON.stringify({
- bid: this.bId,
- cols: cols,
- verificationCode: this.verificationCode
- }),
- headers: {
- 'Content-Type': 'application/json'
- }
- }).then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- if (data.client.state === 3) {
- // 已核销(已提交核销表单)
- this.step = 2
- } else if (data.client.state === -1) {
- // 不符合资格
- this.step = 3
- }
- } else if (code === 2) {
- this.$message({
- message: '核销码无效',
- type: 'warning'
- })
- } else {
- this.$message({
- message: msg,
- type: 'warning'
- })
- }
- })
- },
- // 截取url中的数据
- getQueryParam(paramName) {
- // 获取当前URL的查询字符串部分
- const queryString = window.location.search;
- // 创建一个URLSearchParams对象
- const urlParams = new URLSearchParams(queryString);
- // 返回指定参数的值,如果不存在则返回null
- return urlParams.get(paramName);
- },
- }
- })
- </script>
- </html>
|