| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591 |
- <!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,minimum-scale=1,maximum-scale=1,user-scalable=no" />
- <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_carOwner.png') no-repeat center;
- background-size: 100vw 100vh;
- background-repeat: no-repeat;
- }
- .page6s {
- width: 100vw;
- height: 630px;
- background: url('./img/wl_bg.png') no-repeat center;
- background-size: 100vw 630px;
- background-repeat: no-repeat;
- }
- .page_title {
- font-weight: bold;
- font-size: 16px;
- color: #FFFFFF;
- padding-top: 98px;
- padding-left: 30px;
- }
- .page_tip {
- font-weight: bold;
- font-size: 24px;
- color: #FFFFFF;
- padding: 20px 0 20px 30px;
- }
- .select_box {
- display: flex;
- align-items: center;
- margin: 20px 25px 0;
- background: #FFFFFF;
- border-radius: 20px;
- opacity: 0.5;
- }
- .show_active {
- opacity: 1;
- }
- .option_img {
- width: 60px;
- height: 60px;
- }
- .option_text {
- font-weight: 500;
- font-size: 16px;
- color: #222222;
- padding-left: 20px;
- }
- .page_foot {
- position: fixed;
- bottom: 20px;
- width: 100%;
- }
- .foot_btn {
- font-weight: 500;
- font-size: 16px;
- color: #222222;
- padding: 15px 0;
- margin: 0 35px;
- background: #FFFFFF;
- text-align: center;
- border-radius: 20px;
- }
- .prize_form {
- background: #FFFFFF;
- border-radius: 15px;
- padding: 20px;
- margin: 0 15px;
- max-height: 300px;
- overflow-y: auto;
- }
- .prize_form .el-form-item {
- margin-bottom: 0;
- padding: 10px 0;
- }
- .prize_form .el-input {
- width: 220px;
- }
- .prize_form .el-input__inner {
- border: none;
- text-align: end;
- }
- .el-select-dropdown__item {
- white-space: normal;
- overflow: unset;
- height: auto;
- }
- .no_testDrive {
- font-size: 16px;
- color: #FFFFFF;
- line-height: 30px;
- padding-top: 140px;
- text-align: center;
- }
- .qw_name {
- font-weight: bold;
- font-size: 16px;
- color: #FFF96E;
- }
- .isWlCar_title {
- font-weight: 400;
- font-size: 18px;
- color: #744620;
- line-height: 30px;
- padding-top: 323px;
- text-align: center;
- }
- .qrcode_box {
- width: 201px;
- height: 201px;
- margin: 0 auto;
- padding: 15px;
- background: #FFFFFF;
- border-radius: 20px;
- box-sizing: border-box;
- margin-top: 40px;
- }
- .qrcode_img {
- width: 100%;
- }
- .qrcode_tip {
- height: 60px;
- font-size: 14px;
- color: #744620;
- text-align: center;
- background: #FEC99D;
- padding-top: 5px;
- box-sizing: border-box;
- }
- .testDrive_title {
- font-weight: bold;
- font-size: 24px;
- color: #FFFFFF;
- padding-top: 100px;
- padding-left: 30px;
- }
- .testDrive_tip {
- font-weight: 400;
- font-size: 14px;
- color: #FFFFFF;
- padding-top: 10px;
- padding-left: 30px;
- padding-bottom: 40px;
- }
- .noTestDrive_tip {
- font-weight: 400;
- font-size: 14px;
- color: #744620;
- padding-top: 10px;
- text-align: center;
- }
- </style>
- <body>
- <div id="box" class="box">
- <div v-if="isWlCar">
- <div class="page6s">
- <div class="isWlCar_title">
- <div>您是车主暂不能给朋友点亮哦~</div>
- <div>请添加菱骏服务官发起点亮活动</div>
- </div>
- <div class="qrcode_box">
- <img class="qrcode_img" src="./img/down.png" alt="">
- </div>
- </div>
- <div class="qrcode_tip">扫码添加菱骏服务官</div>
- </div>
- <div class="page6" v-else-if="noTestDrive">
- <div class="no_testDrive">
- <div>扫码添加<span class="qw_name"> Ling号玩家企微</span></div>
- <div>0元抽睛雨伞、量子香薰机等好礼</div>
- </div>
- <div class="qrcode_box">
- <img class="qrcode_img" src="./img/down.png" alt="">
- </div>
- <div class="noTestDrive_tip">扫码添加Ling号玩家</div>
- </div>
- <div class="page6" v-else>
- <div v-if="filter==1 || filter==2">
- <div class="page_title">帮助好友点亮五菱,即可参与现金抽奖</div>
- <div class="page_tip">{{filter==1 ? '请问您是五菱车主吗?' : '五菱汽车诚邀您参与试驾'}}</div>
- </div>
- <div v-if="filter==1">
- <div class="select_box" style="padding: 19px;" :class="selectData === 'one' ? 'show_active' : ''"
- @click="selectItem('one')">
- <img class="option_img" src="./img/wl_car.png" />
- <div class="option_text">我是五菱车主</div>
- </div>
- <div class="select_box" style="padding: 19px;" :class="selectData === 'two' ? 'show_active' : ''"
- @click="selectItem('two')">
- <img class="option_img" src="./img/wl_per.png" />
- <div class="option_text">还没有购入五菱汽车</div>
- </div>
- </div>
- <div v-else-if="filter==2">
- <div class="select_box" style="padding: 38px 35px;" :class="selectData === 'three' ? 'show_active' : ''"
- @click="selectItem('three')">
- <div class="option_text">预约试驾,帮好友点亮五菱</div>
- </div>
- <div class="select_box" style="padding: 38px 35px;" :class="selectData === 'four' ? 'show_active' : ''"
- @click="selectItem('four')">
- <div class="option_text">暂不预约</div>
- </div>
- </div>
- <div v-else-if="filter==3">
- <div class="testDrive_title">预约试驾</div>
- <div class="testDrive_tip">预约试驾即可帮助好友点亮五菱</div>
- <el-form ref="form" class="prize_form" label-position="left" label-width="90px">
- <el-form-item v-for="(item, index) in lightData.formProList" :key="index" :label="item.name"
- :required="Boolean(item.isNeed)">
- <el-cascader v-if="item.type === 10" v-model="item.value" :options="transformedData" @change="handleInfoCity">
- </el-cascader>
- <el-select v-if="item.type === 11" v-model="item.value" placeholder="请选择" @change="handlechange">
- <el-option v-for="(sto, sindex) in storeList" :key="sindex" :label="sto.name" :value="sto.name">
- </el-option>
- </el-select>
- <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-select v-if="item.type === 3" v-model="item.value" placeholder="请选择">
- <el-option v-for="sto in item.formProTagReqs" :key="sto.proValue" :label="sto.proValue" :value="sto.proValue">
- </el-option>
- </el-select>
- <el-col :span="22" v-if="item.type === 5">
- <el-date-picker v-model="item.value" type="date" placeholder="选择日期" style="width: 100%;">
- </el-col>
- <el-col :span="22" v-if="item.type === 6">
- <el-time-picker v-model="item.value" placeholder="请选择"></el-time-picker>
- </el-col>
- <el-col :span="22" v-if="item.type === 7">
- <el-date-picker v-if="item.type === 7" v-model="item.value" type="datetime" placeholder="选择日期时间"></el-date-picker>
- </el-col>
- </el-form-item>
- </el-form>
- </div>
- <div class="page_foot">
- <div class="foot_btn" @click="handleFormOk" v-if="filter==3">确认预约,马上抽奖</div>
- <div class="foot_btn" @click="handleOk" v-else>确认</div>
- </div>
- </div>
- </div>
- </body>
- <script>
- new Vue({
- el: '#box',
- data () {
- return {
- httpUrl: '',
- bId: null,
- env: '',
- lightData: {
- raffle1BizId: null,
- formProList: [],
- },
- province: '',
- city: '',
- transformedData: [],
- storeList: [],
- selectData: 'one',
- isWlCar: false,
- filter: 1,
- noTestDrive: false
- }
- },
- 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.getCityLevel()
- this.lightenOwner()
- }
- } 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'
- })
- }
- })
- },
- lightenOwner () {
- 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-owner/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,
- })
- }
- })
- },
- // 获取城市数据
- getCityLevel () {
- fetch('https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/1000/1720161853377/pc-code.json')
- .then(res => {
- return res.json()
- }).then(result => {
- this.transformedData = this.transformData(result)
- })
- },
- handleInfoCity (value) {
- this.province = value[0]
- this.city = value[1]
- // 清空经销商类型的数据
- this.lightData.formProList.forEach(item => {
- if (item.type === 11) {
- item.value = ''
- }
- })
- this.storeList = []
- this.getStoreList()
- },
- getStoreList() {
- fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-store/p/findListByPage?city=${this.city}&province=${this.province}`, {
- method: 'post',
- body: JSON.stringify({
- page: 1,
- pageCount: 10000,
- }),
- headers: {
- 'Content-Type': 'application/json'
- }
- }).then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- this.storeList = data.records
- } else {
- this.$message({
- message: msg,
- type: 'warning'
- })
- }
- })
- },
- // 省市数据做转换
- transformData (data) {
- return data.map(item => {
- // 创建一个新对象,避免直接修改原始对象
- const newItem = { ...item };
- // 重命名 text 为 label
- if (newItem.text) {
- newItem.label = newItem.text;
- newItem.value = newItem.text;
- delete newItem.text;
- }
- // 如果存在 children 数组,则递归处理每个子项
- if (newItem.children && Array.isArray(newItem.children)) {
- newItem.children = this.transformData(newItem.children);
- }
- return newItem;
- })
- },
- selectItem (type) {
- this.selectData = type
- },
- handleOk () {
- if (this.selectData === 'one') {
- this.isWlCar = true
- } else if (this.selectData === 'two') {
- this.filter = 2
- this.selectData = 'three'
- } else if (this.selectData === 'three') {
- this.filter = 3
- } else if (this.selectData === 'four') {
- this.noTestDrive = true
- }
- },
- handleFormOk () {
- // 填写了试驾表单
- const isValid = this.lightData.formProList.some(item => {
- if (item.isNeed && !item.value) {
- this.$message({
- message: '必填项不能为空',
- type: 'warning'
- })
- return true
- }
- if (this.containsAllChineseCharacters(item.name, '手机') && item.value.length !== 11) {
- this.$message({
- message: '请输入正确的手机号',
- type: 'warning'
- })
- return true
- }
- return false
- })
- if (isValid) return
- let cols = []
- cols = this.lightData.formProList.map(item => {
- return {
- name: item.name,
- type: item.type,
- value: item.type === 10 ? [item.value.join('')] : [item.value],
- }
- })
- let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
- this.loading = true
- fetch(this.httpUrl + `/scrm/v1/wxcp-lighten-client/p/formData?openId=${openId}`, {
- method: 'post',
- body: JSON.stringify({
- bid: this.bId,
- cols: cols,
- }),
- headers: {
- 'Content-Type': 'application/json'
- }
- }).then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- let url = ''
- if (!this.env || this.env === 'prod') {
- url = `https://lottery.camlook.cn/?bId=${this.lightData.raffle1BizId}&h5Type=30`
- } else {
- url = `https://lottery.camlook.cn/?bId=${this.lightData.raffle1BizId}&env=dev&h5Type=30`
- }
- window.location.replace(url)
- } else {
- this.$message({
- message: msg,
- type: 'warning'
- })
- }
- }).finally(() => {
- this.loading = false
- })
- },
- // 检查字符串中是否包含所有指定的中文字符
- containsAllChineseCharacters(str, chineseChars) {
- // 将要检查的字符拆分为数组
- const charsArray = chineseChars.split('')
- // 遍历每个字符并检查是否存在
- for (const char of charsArray) {
- if (!str.includes(char)) {
- return false
- }
- }
- return true
- },
- // 截取url中的数据
- getQueryParam (paramName) {
- // 获取当前URL的查询字符串部分
- const queryString = window.location.search;
- // 创建一个URLSearchParams对象
- const urlParams = new URLSearchParams(queryString);
- // 返回指定参数的值,如果不存在则返回null
- return urlParams.get(paramName);
- },
- }
- })
- </script>
- </html>
|