lightUpWl.html 11 KB

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