carOwnerScreening.html 19 KB

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