carOwnerScreening.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <title>点亮五菱</title>
  8. <!--引入 element-ui 的样式,-->
  9. <link rel="stylesheet"
  10. href="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742018383195/element-ui.css">
  11. <!-- 必须先引入vue, 后使用element-ui -->
  12. <script
  13. src="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742017957144/vue.js"></script>
  14. <!-- 引入element 的组件库-->
  15. <script
  16. src="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742017747738/element-ui.js"></script>
  17. <script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
  18. <script>
  19. var vConsole = new window.VConsole();
  20. </script>
  21. </head>
  22. <style>
  23. body {
  24. margin: 0;
  25. padding: 0;
  26. }
  27. .box {
  28. width: 100vw;
  29. height: 100vh;
  30. box-sizing: border-box;
  31. background: #FAFAFA;
  32. }
  33. .page6 {
  34. width: 100vw;
  35. height: 100vh;
  36. background: url('./img/wl_carOwner.png') no-repeat center;
  37. background-size: 100vw 100vh;
  38. background-repeat: no-repeat;
  39. }
  40. .page6s {
  41. width: 100vw;
  42. height: 630px;
  43. background: url('./img/wl_bg.png') no-repeat center;
  44. background-size: 100vw 630px;
  45. background-repeat: no-repeat;
  46. }
  47. .page_title {
  48. font-weight: bold;
  49. font-size: 16px;
  50. color: #FFFFFF;
  51. padding-top: 98px;
  52. padding-left: 30px;
  53. }
  54. .page_tip {
  55. font-weight: bold;
  56. font-size: 24px;
  57. color: #FFFFFF;
  58. padding: 20px 0 20px 30px;
  59. }
  60. .select_box {
  61. display: flex;
  62. align-items: center;
  63. margin: 20px 25px 0;
  64. background: #FFFFFF;
  65. border-radius: 20px;
  66. opacity: 0.5;
  67. }
  68. .show_active {
  69. opacity: 1;
  70. }
  71. .option_img {
  72. width: 60px;
  73. height: 60px;
  74. }
  75. .option_text {
  76. font-weight: 500;
  77. font-size: 16px;
  78. color: #222222;
  79. padding-left: 20px;
  80. }
  81. .page_foot {
  82. position: fixed;
  83. bottom: 20px;
  84. width: 100%;
  85. }
  86. .foot_btn {
  87. font-weight: 500;
  88. font-size: 16px;
  89. color: #222222;
  90. padding: 15px 0;
  91. margin: 0 35px;
  92. background: #FFFFFF;
  93. text-align: center;
  94. border-radius: 20px;
  95. }
  96. .prize_form {
  97. background: #FFFFFF;
  98. border-radius: 15px;
  99. padding: 20px;
  100. margin: 0 15px;
  101. max-height: 300px;
  102. overflow-y: auto;
  103. }
  104. .prize_form .el-form-item {
  105. margin-bottom: 0;
  106. padding: 10px 0;
  107. }
  108. .prize_form .el-input {
  109. width: 220px;
  110. }
  111. .prize_form .el-input__inner {
  112. border: none;
  113. text-align: end;
  114. }
  115. .el-select-dropdown__item {
  116. white-space: normal;
  117. overflow: unset;
  118. height: auto;
  119. }
  120. .no_testDrive {
  121. font-size: 16px;
  122. color: #FFFFFF;
  123. line-height: 30px;
  124. padding-top: 140px;
  125. text-align: center;
  126. }
  127. .qw_name {
  128. font-weight: bold;
  129. font-size: 16px;
  130. color: #FFF96E;
  131. }
  132. .isWlCar_title {
  133. font-weight: 400;
  134. font-size: 18px;
  135. color: #744620;
  136. line-height: 30px;
  137. padding-top: 323px;
  138. text-align: center;
  139. }
  140. .qrcode_box {
  141. width: 201px;
  142. height: 201px;
  143. margin: 0 auto;
  144. padding: 15px;
  145. background: #FFFFFF;
  146. border-radius: 20px;
  147. box-sizing: border-box;
  148. margin-top: 40px;
  149. }
  150. .qrcode_img {
  151. width: 100%;
  152. }
  153. .qrcode_tip {
  154. height: 60px;
  155. font-size: 14px;
  156. color: #744620;
  157. text-align: center;
  158. background: #FEC99D;
  159. padding-top: 5px;
  160. box-sizing: border-box;
  161. }
  162. .testDrive_title {
  163. font-weight: bold;
  164. font-size: 24px;
  165. color: #FFFFFF;
  166. padding-top: 100px;
  167. padding-left: 30px;
  168. }
  169. .testDrive_tip {
  170. font-weight: 400;
  171. font-size: 14px;
  172. color: #FFFFFF;
  173. padding-top: 10px;
  174. padding-left: 30px;
  175. padding-bottom: 40px;
  176. }
  177. .noTestDrive_tip {
  178. font-weight: 400;
  179. font-size: 14px;
  180. color: #744620;
  181. padding-top: 10px;
  182. text-align: center;
  183. }
  184. </style>
  185. <body>
  186. <div id="box" class="box">
  187. <div v-if="isWlCar">
  188. <div class="page6s">
  189. <div class="isWlCar_title">
  190. <div>您是车主暂不能给朋友点亮哦~</div>
  191. <div>请添加菱骏服务官发起点亮活动</div>
  192. </div>
  193. <div class="qrcode_box">
  194. <img class="qrcode_img" src="./img/down.png" alt="">
  195. </div>
  196. </div>
  197. <div class="qrcode_tip">扫码添加菱骏服务官</div>
  198. </div>
  199. <div class="page6" v-else-if="noTestDrive">
  200. <div class="no_testDrive">
  201. <div>扫码添加<span class="qw_name"> Ling号玩家企微</span></div>
  202. <div>0元抽睛雨伞、量子香薰机等好礼</div>
  203. </div>
  204. <div class="qrcode_box">
  205. <img class="qrcode_img" src="./img/down.png" alt="">
  206. </div>
  207. <div class="noTestDrive_tip">扫码添加Ling号玩家</div>
  208. </div>
  209. <div class="page6" v-else>
  210. <div v-if="filter==1 || filter==2">
  211. <div class="page_title">帮助好友点亮五菱,即可参与现金抽奖</div>
  212. <div class="page_tip">{{filter==1 ? '请问您是五菱车主吗?' : '五菱汽车诚邀您参与试驾'}}</div>
  213. </div>
  214. <div v-if="filter==1">
  215. <div class="select_box" style="padding: 19px;" :class="selectData === 'one' ? 'show_active' : ''"
  216. @click="selectItem('one')">
  217. <img class="option_img" src="./img/wl_car.png" />
  218. <div class="option_text">我是五菱车主</div>
  219. </div>
  220. <div class="select_box" style="padding: 19px;" :class="selectData === 'two' ? 'show_active' : ''"
  221. @click="selectItem('two')">
  222. <img class="option_img" src="./img/wl_per.png" />
  223. <div class="option_text">还没有购入五菱汽车</div>
  224. </div>
  225. </div>
  226. <div v-else-if="filter==2">
  227. <div class="select_box" style="padding: 38px 35px;" :class="selectData === 'three' ? 'show_active' : ''"
  228. @click="selectItem('three')">
  229. <div class="option_text">预约试驾,帮好友点亮五菱</div>
  230. </div>
  231. <div class="select_box" style="padding: 38px 35px;" :class="selectData === 'four' ? 'show_active' : ''"
  232. @click="selectItem('four')">
  233. <div class="option_text">暂不预约</div>
  234. </div>
  235. </div>
  236. <div v-else-if="filter==3">
  237. <div class="testDrive_title">预约试驾</div>
  238. <div class="testDrive_tip">预约试驾即可帮助好友点亮五菱</div>
  239. <el-form ref="form" class="prize_form" label-position="left" label-width="90px">
  240. <el-form-item v-for="(item, index) in lightData.formProList" :key="index" :label="item.name"
  241. :required="Boolean(item.isNeed)">
  242. <el-cascader v-if="item.type === 10" v-model="item.value" :options="transformedData" @change="handleInfoCity">
  243. </el-cascader>
  244. <el-select v-if="item.type === 11" v-model="item.value" placeholder="请选择" @change="handlechange">
  245. <el-option v-for="(sto, sindex) in storeList" :key="sindex" :label="sto.name" :value="sto.name">
  246. </el-option>
  247. </el-select>
  248. <el-input v-if="item.type === 0" v-model="item.value" placeholder="请输入"></el-input>
  249. <el-input v-if="item.type === 1" type="textarea" autosize v-model="item.value" placeholder="请输入"></el-input>
  250. <el-input v-if="item.type === 2" type="number" v-model="item.value" placeholder="请输入"></el-input>
  251. <el-select v-if="item.type === 3" v-model="item.value" placeholder="请选择">
  252. <el-option v-for="sto in item.formProTagReqs" :key="sto.proValue" :label="sto.proValue" :value="sto.proValue">
  253. </el-option>
  254. </el-select>
  255. <el-col :span="22" v-if="item.type === 5">
  256. <el-date-picker v-model="item.value" type="date" placeholder="选择日期" style="width: 100%;">
  257. </el-col>
  258. <el-col :span="22" v-if="item.type === 6">
  259. <el-time-picker v-model="item.value" placeholder="请选择"></el-time-picker>
  260. </el-col>
  261. <el-col :span="22" v-if="item.type === 7">
  262. <el-date-picker v-if="item.type === 7" v-model="item.value" type="datetime" placeholder="选择日期时间"></el-date-picker>
  263. </el-col>
  264. </el-form-item>
  265. </el-form>
  266. </div>
  267. <div class="page_foot">
  268. <div class="foot_btn" @click="handleFormOk" v-if="filter==3">确认预约,马上抽奖</div>
  269. <div class="foot_btn" @click="handleOk" v-else>确认</div>
  270. </div>
  271. </div>
  272. </div>
  273. </body>
  274. <script>
  275. new Vue({
  276. el: '#box',
  277. data () {
  278. return {
  279. httpUrl: '',
  280. bId: null,
  281. env: '',
  282. lightData: {
  283. raffle1BizId: null,
  284. formProList: [],
  285. },
  286. province: '',
  287. city: '',
  288. transformedData: [],
  289. storeList: [],
  290. selectData: 'one',
  291. isWlCar: false,
  292. filter: 1,
  293. noTestDrive: false
  294. }
  295. },
  296. created () {
  297. this.bId = this.getQueryParam('bId')
  298. this.env = this.getQueryParam('env')
  299. if (!this.env || this.env === 'prod') {
  300. this.httpUrl = 'https://wlapi.wefanbot.com'
  301. } else {
  302. this.httpUrl = 'http://test.wefanbot.com:18993'
  303. // this.httpUrl = 'http://192.168.1.147:18993'
  304. }
  305. this.ifH5Type()
  306. },
  307. methods: {
  308. ifH5Type () {
  309. if (this.getQueryParam('openId') || localStorage.getItem('openId')) {
  310. if (!this.getQueryParam('externalUserid')) {
  311. this.gerQwAuth(this.bId);
  312. } else {
  313. this.getCityLevel()
  314. this.lightenOwner()
  315. }
  316. } else {
  317. // 走授权操作
  318. this.getAuth();
  319. }
  320. },
  321. getAuth () {
  322. // 获取url上的code
  323. let code = this.getQueryParam('code')
  324. if (code) {
  325. // 判断业务id是否生产环境业务id
  326. fetch(this.httpUrl + `/p/insuite/p/isProdId?id=${this.bId}`)
  327. .then(res => {
  328. return res.json()
  329. }).then(result => {
  330. let { data, msg } = result
  331. if (typeof data === 'boolean' && data) {
  332. this.httpUrl = 'https://wlapi.wefanbot.com'
  333. } else {
  334. this.httpUrl = 'http://test.wefanbot.com:18993'
  335. }
  336. this.getInfoByh5Code(this.getQueryParam('code'))
  337. })
  338. } else {
  339. let redirect_uri = window.location.href
  340. // code 不存在,走微信网页授权逻辑
  341. let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  342. window.location.replace(url)
  343. }
  344. },
  345. getInfoByh5Code(code) {
  346. fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
  347. .then(res => {
  348. return res.json()
  349. }).then(result => {
  350. let { data, code, msg } = result
  351. if (code === 1) {
  352. localStorage.setItem('openId', data.openId)
  353. this.ifH5Type()
  354. }
  355. })
  356. },
  357. // 企微授权
  358. gerQwAuth (bId) {
  359. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  360. fetch(this.httpUrl + `/p/insuite/p/getOAUrl?openId=${openId}&bId=${bId}`)
  361. .then(res => {
  362. return res.json()
  363. }).then(result => {
  364. let { data, code, msg } = result
  365. if (code === 1) {
  366. window.location.replace(data)
  367. } else {
  368. this.$message({
  369. message: msg,
  370. type: 'warning'
  371. })
  372. }
  373. })
  374. },
  375. lightenOwner () {
  376. let externalUserid = this.getQueryParam('externalUserid')
  377. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  378. const headers = new Headers();
  379. headers.append('police', 110);
  380. fetch(this.httpUrl + `/scrm/v1/wxcp-lighten-owner/p/lottery?externalUserid=${externalUserid}&openId=${openId}&bId=${this.bId}`, {
  381. method: 'GET',
  382. headers: headers
  383. })
  384. .then(res => {
  385. return res.json()
  386. }).then(result => {
  387. let { data, code, msg } = result
  388. if (code === 1) {
  389. this.lightData = data
  390. } else {
  391. this.$message({
  392. message: msg,
  393. })
  394. }
  395. })
  396. },
  397. // 获取城市数据
  398. getCityLevel () {
  399. fetch('https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/1000/1720161853377/pc-code.json')
  400. .then(res => {
  401. return res.json()
  402. }).then(result => {
  403. this.transformedData = this.transformData(result)
  404. })
  405. },
  406. handleInfoCity (value) {
  407. this.province = value[0]
  408. this.city = value[1]
  409. // 清空经销商类型的数据
  410. this.lightData.formProList.forEach(item => {
  411. if (item.type === 11) {
  412. item.value = ''
  413. }
  414. })
  415. this.storeList = []
  416. this.getStoreList()
  417. },
  418. getStoreList() {
  419. fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-store/p/findListByPage?city=${this.city}&province=${this.province}`, {
  420. method: 'post',
  421. body: JSON.stringify({
  422. page: 1,
  423. pageCount: 10000,
  424. }),
  425. headers: {
  426. 'Content-Type': 'application/json'
  427. }
  428. }).then(res => {
  429. return res.json()
  430. }).then(result => {
  431. let { data, code, msg } = result
  432. if (code === 1) {
  433. this.storeList = data.records
  434. } else {
  435. this.$message({
  436. message: msg,
  437. type: 'warning'
  438. })
  439. }
  440. })
  441. },
  442. // 省市数据做转换
  443. transformData (data) {
  444. return data.map(item => {
  445. // 创建一个新对象,避免直接修改原始对象
  446. const newItem = { ...item };
  447. // 重命名 text 为 label
  448. if (newItem.text) {
  449. newItem.label = newItem.text;
  450. newItem.value = newItem.text;
  451. delete newItem.text;
  452. }
  453. // 如果存在 children 数组,则递归处理每个子项
  454. if (newItem.children && Array.isArray(newItem.children)) {
  455. newItem.children = this.transformData(newItem.children);
  456. }
  457. return newItem;
  458. })
  459. },
  460. selectItem (type) {
  461. this.selectData = type
  462. },
  463. handleOk () {
  464. if (this.selectData === 'one') {
  465. this.isWlCar = true
  466. } else if (this.selectData === 'two') {
  467. this.filter = 2
  468. this.selectData = 'three'
  469. } else if (this.selectData === 'three') {
  470. this.filter = 3
  471. } else if (this.selectData === 'four') {
  472. this.noTestDrive = true
  473. }
  474. },
  475. handleFormOk () {
  476. // 填写了试驾表单
  477. const isValid = this.lightData.formProList.some(item => {
  478. if (item.isNeed && !item.value) {
  479. this.$message({
  480. message: '必填项不能为空',
  481. type: 'warning'
  482. })
  483. return true
  484. }
  485. if (this.containsAllChineseCharacters(item.name, '手机') && item.value.length !== 11) {
  486. this.$message({
  487. message: '请输入正确的手机号',
  488. type: 'warning'
  489. })
  490. return true
  491. }
  492. return false
  493. })
  494. if (isValid) return
  495. let cols = []
  496. cols = this.lightData.formProList.map(item => {
  497. return {
  498. name: item.name,
  499. type: item.type,
  500. value: item.type === 10 ? [item.value.join('')] : [item.value],
  501. }
  502. })
  503. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  504. this.loading = true
  505. fetch(this.httpUrl + `/scrm/v1/wxcp-lighten-client/p/formData?openId=${openId}`, {
  506. method: 'post',
  507. body: JSON.stringify({
  508. bid: this.bId,
  509. cols: cols,
  510. }),
  511. headers: {
  512. 'Content-Type': 'application/json'
  513. }
  514. }).then(res => {
  515. return res.json()
  516. }).then(result => {
  517. let { data, code, msg } = result
  518. if (code === 1) {
  519. let url = ''
  520. if (!this.env || this.env === 'prod') {
  521. url = `https://lottery.camlook.cn/?bId=${this.lightData.raffle1BizId}&h5Type=30`
  522. } else {
  523. url = `https://lottery.camlook.cn/?bId=${this.lightData.raffle1BizId}&env=dev&h5Type=30`
  524. }
  525. window.location.replace(url)
  526. } else {
  527. this.$message({
  528. message: msg,
  529. type: 'warning'
  530. })
  531. }
  532. }).finally(() => {
  533. this.loading = false
  534. })
  535. },
  536. // 检查字符串中是否包含所有指定的中文字符
  537. containsAllChineseCharacters(str, chineseChars) {
  538. // 将要检查的字符拆分为数组
  539. const charsArray = chineseChars.split('')
  540. // 遍历每个字符并检查是否存在
  541. for (const char of charsArray) {
  542. if (!str.includes(char)) {
  543. return false
  544. }
  545. }
  546. return true
  547. },
  548. // 截取url中的数据
  549. getQueryParam (paramName) {
  550. // 获取当前URL的查询字符串部分
  551. const queryString = window.location.search;
  552. // 创建一个URLSearchParams对象
  553. const urlParams = new URLSearchParams(queryString);
  554. // 返回指定参数的值,如果不存在则返回null
  555. return urlParams.get(paramName);
  556. },
  557. }
  558. })
  559. </script>
  560. </html>