lightUpWl.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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_bg.png') no-repeat;
  38. background-size: 100%;
  39. background-repeat: no-repeat;
  40. }
  41. .wl_no {
  42. width: 100%;
  43. margin-top: 260px;
  44. }
  45. .wl_btn {
  46. width: 100%;
  47. display: flex;
  48. justify-content: center;
  49. align-items: center;
  50. position: relative;
  51. margin-top: 98px;
  52. }
  53. .image_wrapper {
  54. position: relative;
  55. display: inline-block;
  56. }
  57. .image_wrapper img {
  58. height: 68px;
  59. display: block;
  60. /* 移除图片底部间隙 */
  61. }
  62. .btn_text {
  63. position: absolute;
  64. top: 46%;
  65. left: 50%;
  66. transform: translate(-50%, -46%);
  67. font-weight: 500;
  68. font-size: 20px;
  69. color: #FFFFFF;
  70. width: 100%;
  71. text-align: center;
  72. }
  73. .ask {
  74. background: #FEC99D;
  75. }
  76. .step {
  77. display: flex;
  78. justify-content: center;
  79. align-items: center;
  80. padding-top: 27px;
  81. }
  82. .step span {
  83. font-size: 14px;
  84. color: #BC7E4B;
  85. }
  86. .step_line {
  87. width: 30px;
  88. height: 1px;
  89. background: #BC7E4B;
  90. margin: 0 5px;
  91. }
  92. .ask_btn {
  93. display: flex;
  94. justify-content: center;
  95. align-items: center;
  96. margin-top: 20px;
  97. }
  98. .ask_btn img {
  99. width: 50px;
  100. height: 50px;
  101. margin-right: 10px;
  102. border-radius: 50%;
  103. }
  104. .ask_btn img:last-child {
  105. margin-right: 0;
  106. }
  107. .activity_box {
  108. width: 100%;
  109. background: #FEE8D0;
  110. border-radius: 20px 20px 0 0;
  111. padding: 20px 15px;
  112. box-sizing: border-box;
  113. margin-top: 20px;
  114. }
  115. .lottery {
  116. display: flex;
  117. justify-content: space-between;
  118. align-items: center;
  119. padding: 10px;
  120. box-sizing: border-box;
  121. background: #FFFFFF;
  122. border-radius: 15px;
  123. margin-bottom: 15px;
  124. }
  125. .award {
  126. display: flex;
  127. align-items: center;
  128. gap: 10px;
  129. }
  130. .award_ac {
  131. width: 58px;
  132. height: 58px;
  133. border-radius: 10px;
  134. background: #F5E3D4;
  135. }
  136. .award_tip {
  137. font-size: 14px;
  138. color: #999999;
  139. }
  140. .award_title {
  141. font-weight: 500;
  142. font-size: 16px;
  143. color: #FF765B;
  144. padding-bottom: 5px;
  145. }
  146. .award_btn {
  147. font-weight: 500;
  148. font-size: 14px;
  149. color: #FFFFFF;
  150. padding: 3px 8px;
  151. background: #CCCCCC;
  152. border-radius: 13px;
  153. }
  154. .award_btn_ac {
  155. font-weight: 500;
  156. font-size: 14px;
  157. color: #FFFFFF;
  158. padding: 3px 8px;
  159. background: #FF7979;
  160. border-radius: 13px;
  161. }
  162. .prize_dialog {
  163. position: fixed;
  164. top: 0;
  165. left: 0;
  166. width: 100%;
  167. height: 100%;
  168. background-color: rgba(0, 0, 0, 0.5);
  169. /* 半透明黑色 */
  170. z-index: 1000;
  171. /* 确保遮罩层在顶部 */
  172. transition: opacity 0.5s ease;
  173. /* 可选:添加透明度过渡效果 */
  174. }
  175. .dialog_body {
  176. width: 100%;
  177. height: 100%;
  178. z-index: 1001;
  179. /* 确保遮罩层在顶部 */
  180. display: flex;
  181. flex-direction: column;
  182. align-items: center;
  183. justify-content: center;
  184. }
  185. .dialog_bg {
  186. max-width: 275px;
  187. height: 370px;
  188. border-radius: 20px;
  189. position: relative;
  190. object-fit: contain;
  191. }
  192. .save_btn {
  193. padding: 15px 77px;
  194. background: #FFFFFF;
  195. border-radius: 29px;
  196. font-weight: 500;
  197. font-size: 14px;
  198. color: #222222;
  199. margin-top: 20px;
  200. }
  201. .activity_title {
  202. font-weight: bold;
  203. font-size: 14px;
  204. color: #CB4E35;
  205. padding-top: 5px;
  206. padding-bottom: 15px;
  207. }
  208. .activity_msg {
  209. font-size: 14px;
  210. color: #CB4E35;
  211. }
  212. .activity_msg p {
  213. margin: 0;
  214. line-height: 24px;
  215. }
  216. .el-dialog {
  217. width: 335px;
  218. border-radius: 20px;
  219. }
  220. .el-dialog__header {
  221. text-align: center;
  222. }
  223. .el-dialog__title {
  224. font-weight: 500;
  225. font-size: 16px;
  226. color: #222222;
  227. }
  228. .prize_form .el-form-item {
  229. padding: 0;
  230. margin-bottom: 10px;
  231. }
  232. .prize_form .el-input__inner {
  233. text-align: left;
  234. }
  235. .prize_form .el-form-item__label {
  236. line-height: 20px;
  237. }
  238. .dialog-footer {
  239. text-align: center;
  240. }
  241. .dialog-footer button {
  242. width: 119px;
  243. height: 46px;
  244. background: #FFB34B;
  245. border-radius: 20px;
  246. font-weight: 500;
  247. font-size: 16px;
  248. color: #FFFFFF;
  249. border: none;
  250. }
  251. </style>
  252. <body>
  253. <div id="box" class="box">
  254. <div class="page6">
  255. <img class="wl_no" v-if="!lightData.wxcpLightenClientList.length" src="./img/wl_no.png" />
  256. <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length === 1" src="./img/light_one.png" />
  257. <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length === 2" src="./img/light_two.png" />
  258. <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length === 3" src="./img/light_three.png" />
  259. <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length === 4" src="./img/light_four.png" />
  260. <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length >= 5" src="./img/light_five.png" />
  261. <div class="wl_btn" @click="handleAsk">
  262. <div class="image_wrapper">
  263. <img class="btn_img" src="./img/wl_btn.png" />
  264. <div class="btn_text">{{lightData.raffle2.leftNum ? '成功点亮' : '邀请好友点亮'}}</div>
  265. </div>
  266. </div>
  267. </div>
  268. <div class="ask">
  269. <div class="step">
  270. <span>1.生成海报</span>
  271. <span class="step_line"></span>
  272. <span>2.邀请好友</span>
  273. <span class="step_line"></span>
  274. <span>3.完成任务</span>
  275. </div>
  276. <div class="ask_btn">
  277. <img v-for="item in lightData.wxcpLightenClientList.slice(0, 5)" :key="item.head.id"
  278. :src="item.head || require('img/ask_btn.png')" />
  279. <div v-if="lightData.wxcpLightenClientList.length < 5">
  280. <img v-for="i in (5-lightData.wxcpLightenClientList.length)" :key="i" src="img/ask_btn.png" />
  281. </div>
  282. </div>
  283. <div class="activity_box">
  284. <div v-if="lightData.wxcpLighten.raffeSwitch">
  285. <div class="lottery">
  286. <div class="award">
  287. <img class="award_ac" src="img/lottery1.png" />
  288. <div class="award_tip">
  289. <div class="award_title">好运抽奖</div>
  290. <div>每邀{{lightData.wxcpLighten.raffle1ClientNum}}人抽1次奖,最多{{lightData.wxcpLighten.raffle1NumMax}}次</div>
  291. </div>
  292. </div>
  293. <div v-if="lightData.wxcpLighten.raffle1NumMax === lightData.raffle1.useNum" class="award_btn">已完成</div>
  294. <div v-else>
  295. <div v-if="lightData.raffle1.leftNum" class="award_btn_ac" @click="handleLottery(lightData.raffle1BizId)">
  296. 去抽奖</div>
  297. <div v-else class="award_btn">未完成</div>
  298. </div>
  299. </div>
  300. <div class="lottery">
  301. <div class="award">
  302. <img class="award_ac" src="img/lottery2.png" />
  303. <div class="award_tip">
  304. <div class="award_title">终极大奖</div>
  305. <div>完全点亮即可抽取终极大奖!</div>
  306. </div>
  307. </div>
  308. <div v-if="lightData.wxcpLighten.raffle2NumMax === lightData.raffle2.useNum" class="award_btn">已完成</div>
  309. <div v-else>
  310. <div v-if="lightData.raffle2.leftNum" class="award_btn_ac" @click="handleLottery(lightData.raffle2BizId)">
  311. 去抽奖</div>
  312. <div v-else class="award_btn">未完成</div>
  313. </div>
  314. </div>
  315. </div>
  316. <div class="activity_title">活动信息</div>
  317. <div class="activity_msg" v-html="lightData.wxcpLighten.activityInfo"></div>
  318. </div>
  319. </div>
  320. <!-- 邀请弹窗 -->
  321. <div class="prize_dialog" v-if="showAskDialog">
  322. <div class="dialog_body">
  323. <img class="dialog_bg" :src="lightData.urlPost" />
  324. <div class="save_btn" @click="showAskDialog = false">长按图片保存</div>
  325. </div>
  326. </div>
  327. <el-dialog title="填写信息" :visible.sync="showDialog" :show-close="false" :close-on-click-modal="false"
  328. :close-on-press-escape="false">
  329. <el-form :model="lightData" class="prize_form" label-position="top">
  330. <el-form-item label="门店">
  331. <el-input v-model="lightData.store"></el-input>
  332. </el-form-item>
  333. <el-form-item label="顾问名称" required>
  334. <el-input v-model="lightData.referrer"></el-input>
  335. </el-form-item>
  336. <el-form-item label="领取奖励手机号" required>
  337. <el-input type="number" v-model="lightData.referrerPhone"></el-input>
  338. </el-form-item>
  339. <div>注意:请您及时前往五菱汽车小程序/App,使用登记的手机号登录/注册,以免影响后续奖励无法发放。</div>
  340. </el-form>
  341. <div slot="footer" class="dialog-footer">
  342. <el-button type="warning" :loading="loading" @click="handleSaveRefer">确 定</el-button>
  343. </div>
  344. </el-dialog>
  345. </div>
  346. </body>
  347. <script>
  348. new Vue({
  349. el: '#box',
  350. data() {
  351. return {
  352. httpUrl: '',
  353. bId: null,
  354. env: '',
  355. showAskDialog: false,
  356. lightData: {
  357. urlPost: '',
  358. wxcpLightenClientList: [],
  359. wxcpLighten: {
  360. activityInfo: '',
  361. raffeSwitch: 0,
  362. raffle1ClientNum: null,
  363. raffle1NumMax: null, // 抽奖1总次数
  364. raffle2NumMax: null, // 抽奖2总次数
  365. type: null,
  366. },
  367. raffle1: {
  368. leftNum: null, // 抽奖1剩余次数
  369. useNum: null, // 抽奖1已使用次数
  370. },
  371. raffle2: {
  372. leftNum: null, // 抽奖2剩余次数
  373. useNum: null, // 抽奖2已使用次数
  374. },
  375. raffle1BizId: null,
  376. raffle2BizId: null,
  377. referrer: '', // 顾问名称
  378. store: '', // 门店
  379. referrerPhone: '', // 领取奖励手机号
  380. },
  381. showDialog: false, // 填写顾问名称信息弹窗
  382. loading: false, // 提交按钮loading
  383. }
  384. },
  385. created() {
  386. this.bId = this.getQueryParam('bId')
  387. this.env = this.getQueryParam('env')
  388. if (!this.env || this.env === 'prod') {
  389. this.httpUrl = 'https://wlapi.wefanbot.com'
  390. } else {
  391. this.httpUrl = 'https://test.wefanbot.com:28993'
  392. // this.httpUrl = 'http://192.168.1.147:18993'
  393. }
  394. localStorage.removeItem('openId')
  395. this.ifH5Type()
  396. },
  397. methods: {
  398. ifH5Type() {
  399. if (this.getQueryParam('openId') || localStorage.getItem('openId')) {
  400. if (!this.getQueryParam('externalUserid')) {
  401. this.gerQwAuth(this.bId);
  402. } else {
  403. this.lightenShare()
  404. }
  405. } else {
  406. // 走授权操作
  407. this.getAuth();
  408. }
  409. },
  410. getAuth() {
  411. // 获取url上的code
  412. let code = this.getQueryParam('code')
  413. if (code) {
  414. // 判断业务id是否生产环境业务id
  415. fetch(this.httpUrl + `/p/insuite/p/isProdId?id=${this.bId}`)
  416. .then(res => {
  417. return res.json()
  418. }).then(result => {
  419. let { data, msg } = result
  420. if (typeof data === 'boolean' && data) {
  421. this.httpUrl = 'https://wlapi.wefanbot.com'
  422. } else {
  423. this.httpUrl = 'http://test.wefanbot.com:18993'
  424. }
  425. this.getInfoByh5Code(this.getQueryParam('code'))
  426. })
  427. } else {
  428. let redirect_uri = window.location.href
  429. // code 不存在,走微信网页授权逻辑
  430. let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  431. window.location.replace(url)
  432. }
  433. },
  434. getInfoByh5Code(code) {
  435. fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
  436. .then(res => {
  437. return res.json()
  438. }).then(result => {
  439. let { data, code, msg } = result
  440. if (code === 1) {
  441. localStorage.setItem('openId', data.openId)
  442. this.ifH5Type()
  443. }
  444. })
  445. },
  446. // 企微授权
  447. gerQwAuth(bId) {
  448. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  449. fetch(this.httpUrl + `/p/insuite/p/getOAUrl?openId=${openId}&bId=${bId}`)
  450. .then(res => {
  451. return res.json()
  452. }).then(result => {
  453. let { data, code, msg } = result
  454. if (code === 1) {
  455. window.location.replace(data)
  456. } else {
  457. this.$message({
  458. message: msg,
  459. type: 'warning'
  460. })
  461. }
  462. })
  463. },
  464. lightenShare() {
  465. let externalUserid = this.getQueryParam('externalUserid')
  466. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  467. const headers = new Headers();
  468. headers.append('police', 110);
  469. fetch(this.httpUrl + `/scrm/v1/wxcp-lighten-share/p/lottery?externalUserid=${externalUserid}&openId=${openId}&bId=${this.bId}`, {
  470. method: 'GET',
  471. headers: headers
  472. })
  473. .then(res => {
  474. return res.json()
  475. }).then(result => {
  476. let { data, code, msg } = result
  477. if (code === 1) {
  478. this.lightData = data
  479. if (data.wxcpLighten.type === 2 && (!data.referrer || !data.referrerPhone)) {
  480. this.showDialog = true
  481. }
  482. } else {
  483. this.$message({
  484. message: msg,
  485. })
  486. }
  487. })
  488. },
  489. handleAsk() {
  490. this.showAskDialog = true
  491. },
  492. handleLottery(bizId) {
  493. let url = ''
  494. if (!this.env || this.env === 'prod') {
  495. url = `https://lottery2.camlook.cn/?bId=${bizId}&h5Type=30`
  496. } else {
  497. url = `https://lottery2.camlook.cn/?bId=${bizId}&env=dev&h5Type=30`
  498. }
  499. window.location.replace(url)
  500. },
  501. handleSaveRefer() {
  502. if (!this.lightData.referrer) {
  503. this.$message({
  504. message: '请填写顾问名称',
  505. type: 'warning'
  506. })
  507. return
  508. }
  509. if (!this.lightData.referrerPhone) {
  510. this.$message({
  511. message: '请填写领取奖励手机号',
  512. type: 'warning'
  513. })
  514. return
  515. }
  516. this.loading = true
  517. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  518. fetch(this.httpUrl + `/scrm/v1/wxcp-lighten-owner/p/updateReferrer?openId=${openId}&bId=${this.bId}`, {
  519. method: 'post',
  520. body: JSON.stringify({
  521. referrer: this.lightData.referrer, // 顾问名称
  522. store: this.lightData.store, // 门店
  523. referrerPhone: this.lightData.referrerPhone, // 领取奖励手机号
  524. }),
  525. headers: {
  526. 'Content-Type': 'application/json'
  527. }
  528. }).then(res => {
  529. return res.json()
  530. }).then(result => {
  531. let { data, code, msg } = result
  532. if (code === 1) {
  533. this.$message({
  534. message: '提交成功!',
  535. type: 'success'
  536. })
  537. this.showDialog = false
  538. this.lightenShare()
  539. }
  540. }).finally(() => {
  541. this.loading = false
  542. })
  543. },
  544. // 截取url中的数据
  545. getQueryParam(paramName) {
  546. // 获取当前URL的查询字符串部分
  547. const queryString = window.location.search;
  548. // 创建一个URLSearchParams对象
  549. const urlParams = new URLSearchParams(queryString);
  550. // 返回指定参数的值,如果不存在则返回null
  551. return urlParams.get(paramName);
  552. },
  553. }
  554. })
  555. </script>
  556. </html>