lightUpWl.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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.0">
  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_bg.png') no-repeat center;
  37. background-size: 100vw 100vh;
  38. background-repeat: no-repeat;
  39. }
  40. .wl_no {
  41. width: 100%;
  42. margin-top: 260px;
  43. }
  44. .wl_btn {
  45. width: 100%;
  46. display: flex;
  47. justify-content: center;
  48. align-items: center;
  49. position: relative;
  50. margin-top: 150px;
  51. }
  52. .image_wrapper {
  53. position: relative;
  54. display: inline-block;
  55. }
  56. .image_wrapper img {
  57. height: 68px;
  58. display: block;
  59. /* 移除图片底部间隙 */
  60. }
  61. .btn_text {
  62. position: absolute;
  63. top: 46%;
  64. left: 50%;
  65. transform: translate(-50%, -46%);
  66. font-weight: 500;
  67. font-size: 20px;
  68. color: #FFFFFF;
  69. width: 100%;
  70. text-align: center;
  71. }
  72. .ask {
  73. background: #FEC99D;
  74. }
  75. .step {
  76. display: flex;
  77. justify-content: center;
  78. align-items: center;
  79. padding-top: 27px;
  80. }
  81. .step span {
  82. font-size: 14px;
  83. color: #BC7E4B;
  84. }
  85. .step_line {
  86. width: 30px;
  87. height: 1px;
  88. background: #BC7E4B;
  89. margin: 0 5px;
  90. }
  91. .ask_btn {
  92. display: flex;
  93. justify-content: center;
  94. align-items: center;
  95. gap: 10px;
  96. margin-top: 20px;
  97. }
  98. .ask_btn img {
  99. width: 50px;
  100. height: 50px;
  101. border-radius: 50%;
  102. }
  103. .activity_box {
  104. width: 100%;
  105. background: #FEE8D0;
  106. border-radius: 20px 20px 0 0;
  107. padding: 20px 15px;
  108. box-sizing: border-box;
  109. margin-top: 20px;
  110. }
  111. .lottery {
  112. display: flex;
  113. justify-content: space-between;
  114. align-items: center;
  115. padding: 10px;
  116. box-sizing: border-box;
  117. background: #FFFFFF;
  118. border-radius: 15px;
  119. margin-bottom: 15px;
  120. }
  121. .award {
  122. display: flex;
  123. align-items: center;
  124. gap: 10px;
  125. }
  126. .award_ac {
  127. width: 58px;
  128. height: 58px;
  129. border-radius: 10px;
  130. background: #F5E3D4;
  131. }
  132. .award_tip {
  133. font-size: 14px;
  134. color: #999999;
  135. }
  136. .award_title {
  137. font-weight: 500;
  138. font-size: 16px;
  139. color: #FF765B;
  140. padding-bottom: 5px;
  141. }
  142. .award_btn {
  143. font-weight: 500;
  144. font-size: 14px;
  145. color: #FFFFFF;
  146. padding: 3px 8px;
  147. background: #CCCCCC;
  148. border-radius: 13px;
  149. }
  150. .award_btn_ac {
  151. font-weight: 500;
  152. font-size: 14px;
  153. color: #FFFFFF;
  154. padding: 3px 8px;
  155. background: #FF7979;
  156. border-radius: 13px;
  157. }
  158. .prize_dialog {
  159. position: fixed;
  160. top: 0;
  161. left: 0;
  162. width: 100%;
  163. height: 100%;
  164. background-color: rgba(0, 0, 0, 0.5);
  165. /* 半透明黑色 */
  166. z-index: 1000;
  167. /* 确保遮罩层在顶部 */
  168. transition: opacity 0.5s ease;
  169. /* 可选:添加透明度过渡效果 */
  170. }
  171. .dialog_body {
  172. width: 100%;
  173. height: 100%;
  174. z-index: 1001;
  175. /* 确保遮罩层在顶部 */
  176. display: flex;
  177. flex-direction: column;
  178. align-items: center;
  179. justify-content: center;
  180. }
  181. .dialog_bg {
  182. max-width: 275px;
  183. height: 370px;
  184. border-radius: 20px;
  185. position: relative;
  186. object-fit: contain;
  187. }
  188. .save_btn {
  189. padding: 15px 77px;
  190. background: #FFFFFF;
  191. border-radius: 29px;
  192. font-weight: 500;
  193. font-size: 14px;
  194. color: #222222;
  195. margin-top: 20px;
  196. }
  197. .activity_title {
  198. font-weight: bold;
  199. font-size: 14px;
  200. color: #CB4E35;
  201. padding-top: 5px;
  202. padding-bottom: 15px;
  203. }
  204. .activity_msg {
  205. font-size: 14px;
  206. color: #CB4E35;
  207. }
  208. .activity_msg p {
  209. margin: 0;
  210. line-height: 24px;
  211. }
  212. </style>
  213. <body>
  214. <div id="box" class="box">
  215. <div class="page6">
  216. <img class="wl_no" v-if="!lightData.wxcpLightenClientList.length" src="./img/wl_no.png" />
  217. <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length === 1" src="./img/light_one.png" />
  218. <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length === 2" src="./img/light_two.png" />
  219. <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length === 3" src="./img/light_three.png" />
  220. <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length === 4" src="./img/light_four.png" />
  221. <img class="wl_no" v-else-if="lightData.wxcpLightenClientList.length === 5" src="./img/light_five.png" />
  222. <div class="wl_btn" @click="handleAsk">
  223. <div class="image_wrapper">
  224. <img class="btn_img" src="./img/wl_btn.png" />
  225. <div class="btn_text">{{lightData.raffle2.leftNum ? '点亮成功,解锁终极大奖' : '邀请好友点亮'}}</div>
  226. </div>
  227. </div>
  228. </div>
  229. <div class="ask">
  230. <div class="step">
  231. <span>1.生成海报</span>
  232. <span class="step_line"></span>
  233. <span>2.邀请好友</span>
  234. <span class="step_line"></span>
  235. <span>3.完成任务</span>
  236. </div>
  237. <div class="ask_btn">
  238. <img v-for="item in lightData.wxcpLightenClientList" :key="item.head.id" :src="item.head || require('img/ask_btn.png')" />
  239. <img v-for="i in (5-lightData.wxcpLightenClientList.length)" :key="i" src="img/ask_btn.png" />
  240. </div>
  241. <div class="activity_box">
  242. <div class="lottery">
  243. <div class="award">
  244. <img class="award_ac" src="img/lottery1.png" />
  245. <div class="award_tip">
  246. <div class="award_title">好运抽奖</div>
  247. <div>每邀{{lightData.wxcpLighten.raffle1ClientNum}}人抽1次奖,最多{{lightData.wxcpLighten.raffle1NumMax}}次</div>
  248. </div>
  249. </div>
  250. <div v-if="lightData.wxcpLighten.raffle1NumMax === lightData.raffle1.useNum" class="award_btn">已完成</div>
  251. <div v-else>
  252. <div v-if="lightData.raffle1.leftNum" class="award_btn_ac" @click="handleLottery(lightData.raffle1BizId)">去抽奖</div>
  253. <div v-else class="award_btn">未完成</div>
  254. </div>
  255. </div>
  256. <div class="lottery">
  257. <div class="award">
  258. <img class="award_ac" src="img/lottery2.png" />
  259. <div class="award_tip">
  260. <div class="award_title">终极大奖</div>
  261. <div>完全点亮即可抽取终极大奖!</div>
  262. </div>
  263. </div>
  264. <div v-if="lightData.wxcpLighten.raffle2NumMax === lightData.raffle2.useNum" class="award_btn">已完成</div>
  265. <div v-else>
  266. <div v-if="lightData.raffle2.leftNum" class="award_btn_ac" @click="handleLottery(lightData.raffle2BizId)">去抽奖</div>
  267. <div v-else class="award_btn">未完成</div>
  268. </div>
  269. </div>
  270. <div class="activity_title">活动信息</div>
  271. <div class="activity_msg" v-html="lightData.wxcpLighten.activityInfo"></div>
  272. </div>
  273. </div>
  274. <!-- 邀请弹窗 -->
  275. <div class="prize_dialog" v-if="showAskDialog">
  276. <div class="dialog_body">
  277. <img class="dialog_bg" :src="lightData.urlPost" />
  278. <div class="save_btn" @click="showAskDialog = false">长按图片保存</div>
  279. </div>
  280. </div>
  281. </div>
  282. </body>
  283. <script>
  284. new Vue({
  285. el: '#box',
  286. data () {
  287. return {
  288. httpUrl: '',
  289. bId: null,
  290. env: '',
  291. showAskDialog: false,
  292. lightData: {
  293. urlPost: '',
  294. wxcpLightenClientList: [],
  295. wxcpLighten: {
  296. activityInfo: '',
  297. raffle1ClientNum: null,
  298. raffle1NumMax: null, // 抽奖1总次数
  299. raffle2NumMax: null, // 抽奖2总次数
  300. },
  301. raffle1: {
  302. leftNum: null, // 抽奖1剩余次数
  303. useNum: null, // 抽奖1已使用次数
  304. },
  305. raffle2: {
  306. leftNum: null, // 抽奖2剩余次数
  307. useNum: null, // 抽奖2已使用次数
  308. },
  309. raffle1BizId: null,
  310. raffle2BizId: null,
  311. },
  312. }
  313. },
  314. created () {
  315. this.bId = this.getQueryParam('bId')
  316. this.env = this.getQueryParam('env')
  317. if (!this.env || this.env === 'prod') {
  318. this.httpUrl = 'https://wlapi.wefanbot.com'
  319. } else {
  320. this.httpUrl = 'http://test.wefanbot.com:18993'
  321. // this.httpUrl = 'http://192.168.1.147:18993'
  322. }
  323. this.ifH5Type()
  324. },
  325. methods: {
  326. ifH5Type () {
  327. if (this.getQueryParam('openId') || localStorage.getItem('openId')) {
  328. if (!this.getQueryParam('externalUserid')) {
  329. this.gerQwAuth(this.bId);
  330. } else {
  331. this.lightenShare()
  332. }
  333. } else {
  334. // 走授权操作
  335. this.getAuth();
  336. }
  337. },
  338. getAuth () {
  339. // 获取url上的code
  340. let code = this.getQueryParam('code')
  341. if (code) {
  342. // 判断业务id是否生产环境业务id
  343. fetch(this.httpUrl + `/p/insuite/p/isProdId?id=${this.bId}`)
  344. .then(res => {
  345. return res.json()
  346. }).then(result => {
  347. let { data, msg } = result
  348. if (typeof data === 'boolean' && data) {
  349. this.httpUrl = 'https://wlapi.wefanbot.com'
  350. } else {
  351. this.httpUrl = 'http://test.wefanbot.com:18993'
  352. }
  353. this.getInfoByh5Code(this.getQueryParam('code'))
  354. })
  355. } else {
  356. let redirect_uri = window.location.href
  357. // code 不存在,走微信网页授权逻辑
  358. let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  359. window.location.replace(url)
  360. }
  361. },
  362. getInfoByh5Code(code) {
  363. fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
  364. .then(res => {
  365. return res.json()
  366. }).then(result => {
  367. let { data, code, msg } = result
  368. if (code === 1) {
  369. localStorage.setItem('openId', data.openId)
  370. this.ifH5Type()
  371. }
  372. })
  373. },
  374. // 企微授权
  375. gerQwAuth (bId) {
  376. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  377. fetch(this.httpUrl + `/p/insuite/p/getOAUrl?openId=${openId}&bId=${bId}`)
  378. .then(res => {
  379. return res.json()
  380. }).then(result => {
  381. let { data, code, msg } = result
  382. if (code === 1) {
  383. window.location.replace(data)
  384. } else {
  385. this.$message({
  386. message: msg,
  387. type: 'warning'
  388. })
  389. }
  390. })
  391. },
  392. lightenShare () {
  393. let externalUserid = this.getQueryParam('externalUserid')
  394. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  395. const headers = new Headers();
  396. headers.append('police', 110);
  397. fetch(this.httpUrl + `/scrm/v1/wxcp-lighten-share/p/lottery?externalUserid=${externalUserid}&openId=${openId}&bId=${this.bId}`, {
  398. method: 'GET',
  399. headers: headers
  400. })
  401. .then(res => {
  402. return res.json()
  403. }).then(result => {
  404. let { data, code, msg } = result
  405. if (code === 1) {
  406. this.lightData = data
  407. } else {
  408. this.$message({
  409. message: msg,
  410. })
  411. }
  412. })
  413. },
  414. handleAsk () {
  415. this.showAskDialog = true
  416. },
  417. handleLottery (bizId) {
  418. let url = ''
  419. if (!this.env || this.env === 'prod') {
  420. url = `https://lottery.camlook.cn/?bId=${bizId}&h5Type=30`
  421. } else {
  422. url = `https://lottery.camlook.cn/?bId=${bizId}&env=dev&h5Type=30`
  423. }
  424. window.location.replace(url)
  425. },
  426. // 截取url中的数据
  427. getQueryParam (paramName) {
  428. // 获取当前URL的查询字符串部分
  429. const queryString = window.location.search;
  430. // 创建一个URLSearchParams对象
  431. const urlParams = new URLSearchParams(queryString);
  432. // 返回指定参数的值,如果不存在则返回null
  433. return urlParams.get(paramName);
  434. },
  435. }
  436. })
  437. </script>
  438. </html>