lightUpWl.html 11 KB

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