index.html 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>活动</title>
  6. <meta name="viewport"
  7. content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  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 src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
  16. <!-- <script>
  17. var vConsole = new window.VConsole();
  18. </script> -->
  19. </head>
  20. <style>
  21. body {
  22. margin: 0;
  23. padding: 0;
  24. }
  25. #box {
  26. width: 100vw;
  27. height: 100vh;
  28. box-sizing: border-box;
  29. }
  30. .lotteryPage {
  31. width: 100%;
  32. height: 620px;
  33. background: url('./img/lottery-bg.png');
  34. background-size: 100% 620px;
  35. background-repeat: no-repeat;
  36. position: relative;
  37. }
  38. .prize_content {
  39. padding: 267px 61px 0 60px;
  40. display: flex;
  41. flex-wrap: wrap;
  42. justify-content: center;
  43. gap: 10px;
  44. }
  45. .prize_item {
  46. width: 78px;
  47. height: 78px;
  48. background: url('./img/prize-bg.png');
  49. background-size: 78px 78px;
  50. background-repeat: no-repeat;
  51. display: flex;
  52. justify-content: center;
  53. align-items: center;
  54. flex-direction: column;
  55. font-weight: 400;
  56. font-size: 10px;
  57. color: #CC745A;
  58. box-sizing: border-box;
  59. }
  60. .prize_img {
  61. width: 48px;
  62. height: 48px;
  63. padding-bottom: 3px;
  64. }
  65. .lottery_btn {
  66. position: absolute;
  67. bottom: -14px;
  68. display: flex;
  69. flex-direction: column;
  70. align-items: center;
  71. width: 100%;
  72. }
  73. .btn_img {
  74. width: 290px;
  75. }
  76. .lottery_tip {
  77. text-align: center;
  78. font-size: 14px;
  79. color: #FFFFFF;
  80. font-weight: 600;
  81. line-height: 14px;
  82. }
  83. .rule {
  84. width: 100%;
  85. height: 509px;
  86. background: linear-gradient(180deg, #FF6C52 0%, #FFBA9B 100%);
  87. margin-top: -50px;
  88. padding: 65px 15px 40px;
  89. box-sizing: border-box;
  90. }
  91. .rule_body {
  92. height: 404px;
  93. background: #FEE8D0;
  94. border-radius: 20px;
  95. padding: 20px 15px;
  96. box-sizing: border-box;
  97. }
  98. .tabs {
  99. display: flex;
  100. justify-content: space-around;
  101. align-items: center;
  102. padding: 0 2px;
  103. margin: 0 auto;
  104. width: 255px;
  105. height: 34px;
  106. background: rgba(255, 125, 97, 0.2);
  107. border-radius: 17px 17px 17px 17px;
  108. }
  109. .tab_link {
  110. border: none;
  111. outline: none;
  112. cursor: pointer;
  113. transition: 0.3s;
  114. color: #FF765B;
  115. background: unset;
  116. width: 125px;
  117. height: 30px;
  118. border-radius: 17px
  119. }
  120. .tab_link:active {
  121. background: rgba(255, 125, 97, 0.2);
  122. }
  123. .tab_link.active {
  124. background: #FFFFFF;
  125. }
  126. .tab_content {
  127. p {
  128. font-weight: 400;
  129. font-size: 14px;
  130. color: #CB4E35;
  131. margin-top: 20px;
  132. }
  133. }
  134. .record_list {
  135. overflow-y: auto;
  136. height: 300px;
  137. margin-top: 18px;
  138. }
  139. .record_item {
  140. width: 315px;
  141. height: 72px;
  142. background: #FEDFC9;
  143. border-radius: 10px;
  144. padding: 9px 10px 8px;
  145. display: flex;
  146. align-items: center;
  147. margin: 0 auto 10px;
  148. box-sizing: border-box;
  149. }
  150. .record_img {
  151. width: 55px;
  152. height: 55px;
  153. border-radius: 10px;
  154. margin-right: 8px;
  155. }
  156. .get_btn {
  157. width: 72px;
  158. height: 30px;
  159. background: #FF4646;
  160. border-radius: 17px;
  161. font-size: 14px;
  162. color: #FFFFFF;
  163. margin-left: 30px;
  164. padding: 0;
  165. }
  166. .prize_name {
  167. font-size: 14px;
  168. font-weight: 500;
  169. color: #FF4646;
  170. }
  171. .prize_time {
  172. font-size: 12px;
  173. color: #FF6767;
  174. }
  175. .el-dialog {
  176. width: 335px;
  177. border-radius: 20px;
  178. }
  179. .el-dialog__header {
  180. text-align: center;
  181. }
  182. .el-dialog__title {
  183. font-weight: 500;
  184. font-size: 16px;
  185. color: #222222;
  186. }
  187. .el-dialog__body {
  188. height: 260px;
  189. overflow-y: auto;
  190. }
  191. .prize_form .el-form-item {
  192. padding: 0;
  193. }
  194. .prize_form .el-form-item__label {
  195. line-height: 20px;
  196. }
  197. .prize_form .el-input {
  198. width: 295px;
  199. }
  200. .prize_form .el-input__inner {
  201. text-align: left;
  202. }
  203. .prize_form .el-input.is-active .el-input__inner,
  204. .prize_form .el-input__inner:focus {
  205. border: 1px solid #FF4646;
  206. }
  207. .prize_form .el-textarea.is-active .el-textarea__inner,
  208. .prize_form .el-textarea__inner:focus {
  209. border: 1px solid #FF4646;
  210. }
  211. .el-radio__input.is-checked .el-radio__inner {
  212. border-color: #FF4646;
  213. background: #FF4646;
  214. }
  215. .el-radio__input.is-checked+.el-radio__label {
  216. color: #FF4646;
  217. }
  218. .el-select .el-input.is-focus .el-input__inner {
  219. border-color: #FF4646;
  220. }
  221. .dialog-footer {
  222. text-align: center;
  223. }
  224. .dialog-footer button {
  225. width: 100%;
  226. height: 46px;
  227. background: #FF4646;
  228. border-radius: 20px;
  229. font-weight: 500;
  230. font-size: 16px;
  231. color: #FFFFFF;
  232. border: none;
  233. }
  234. .prize_dialog {
  235. position: fixed;
  236. top: 0;
  237. left: 0;
  238. width: 100%;
  239. height: 100%;
  240. background-color: rgba(0, 0, 0, 0.5);
  241. /* 半透明黑色 */
  242. z-index: 1000;
  243. /* 确保遮罩层在顶部 */
  244. transition: opacity 0.5s ease;
  245. /* 可选:添加透明度过渡效果 */
  246. }
  247. .dialog-body {
  248. width: 100%;
  249. height: 100%;
  250. z-index: 1001;
  251. /* 确保遮罩层在顶部 */
  252. display: flex;
  253. flex-direction: column;
  254. align-items: center;
  255. justify-content: center;
  256. }
  257. .dialog-tip {
  258. width: 100%;
  259. height: 100px;
  260. }
  261. .dialog-bg {
  262. width: 295px;
  263. height: 251px;
  264. position: relative;
  265. }
  266. .prize-msg {
  267. position: absolute;
  268. text-align: center;
  269. }
  270. .money-title {
  271. font-weight: 500;
  272. font-size: 16px;
  273. color: #FF4E4E;
  274. padding-top: 90px;
  275. padding-bottom: 10px;
  276. }
  277. .money-content {
  278. margin-bottom: 30px;
  279. height: 60px;
  280. display: flex;
  281. justify-content: center;
  282. align-items: center;
  283. }
  284. .prize-money {
  285. font-weight: bold;
  286. font-size: 60px;
  287. color: #FF4E4E;
  288. }
  289. .prize-unit {
  290. font-weight: 500;
  291. font-size: 16px;
  292. color: #FF4E4E;
  293. padding-left: 10px;
  294. padding-top: 28px;
  295. }
  296. .dialog-btn {
  297. width: 235px;
  298. height: 52px;
  299. margin-bottom: 10px;
  300. }
  301. .money-tip {
  302. font-weight: 400;
  303. font-size: 12px;
  304. color: #999999;
  305. margin-bottom: 15px;
  306. }
  307. .goods-img {
  308. width: 100px;
  309. height: 100px;
  310. margin: 70px 0 10px;
  311. }
  312. .goods-name {
  313. font-weight: 500;
  314. font-size: 16px;
  315. color: #222222;
  316. margin-bottom: 20px;
  317. }
  318. .dialog-close {
  319. width: 30px;
  320. height: 30px;
  321. margin-top: 20px;
  322. }
  323. .actives {
  324. border: 2px solid #df2727;
  325. border-radius: 15px;
  326. }
  327. .event_notice {
  328. width: 30px;
  329. height: 84px;
  330. background: rgba(255, 255, 255, 0.5);
  331. border-radius: 15px 0px 0px 15px;
  332. border: 1px solid #FFFFFF;
  333. font-weight: 500;
  334. font-size: 14px;
  335. color: #FF4E4E;
  336. position: absolute;
  337. right: 0;
  338. top: 20%;
  339. writing-mode: vertical-rl;
  340. text-align: center;
  341. padding-right: 4px;
  342. }
  343. .qrcode {
  344. width: 100vw;
  345. height: 100vh;
  346. box-sizing: border-box;
  347. display: flex;
  348. align-items: center;
  349. justify-content: center;
  350. flex-direction: column;
  351. }
  352. .qrcode-msg {
  353. text-align: center;
  354. font-size: 18px;
  355. }
  356. .alert_dialog {
  357. z-index: 999;
  358. position: fixed;
  359. top: 0;
  360. left: 0;
  361. width: 100%;
  362. }
  363. </style>
  364. <body>
  365. <div id="box">
  366. <!-- 二维码 -->
  367. <div class="qrcode" v-if="qrCodeData.qrCode || qrCodeData.msg">
  368. <img class="qrcode-img" :src="qrCodeData.qrCode" />
  369. <div class="qrcode-msg">{{qrCodeData.msg}}</div>
  370. </div>
  371. <el-alert v-if="showError" class="alert_dialog" :title="errorMsg" :closable="false" type="error" show-icon>
  372. </el-alert>
  373. <div v-if="(h5Type == 19 && !qrCodeData.qrCode) || (h5Type == 30 && !qrCodeData.qrCode)">
  374. <div class="lotteryPage">
  375. <div class="event_notice" @click="handleRule">
  376. <span>活动须知</span>
  377. </div>
  378. <div class="prize_content">
  379. <div :class="['prize_item', { actives: isSpinning && index === currentIndex }]"
  380. v-for="(item, index) in prizesList" :key="index">
  381. <img class="prize_img" :src="item.img"></img>
  382. <div>{{item.name}}</div>
  383. </div>
  384. </div>
  385. <div class="lottery_btn">
  386. <img class="btn_img" src="./img/btn.png" @click="handleLottery"></img>
  387. <div class="lottery_tip">已抽奖{{useNum}}次,还剩{{remainNum}}次机会</div>
  388. </div>
  389. </div>
  390. <div class="rule">
  391. <div class="rule_body">
  392. <div class="tabs">
  393. <Button class="tab_link" :class="{ 'active': activeName === 'tab1' }"
  394. @click="changeTab('tab1')">活动信息</Button>
  395. <Button class="tab_link" :class="{ 'active': activeName === 'tab2' }"
  396. @click="changeTab('tab2')">抽奖记录</Button>
  397. </div>
  398. <div v-if="activeName === 'tab1'" class="tab_content record_list" v-html="activeMsg"></div>
  399. <div v-if="activeName === 'tab2'" class="record_list">
  400. <div class="record_item" v-for="(item, index) in lotteryRecords" :key="index">
  401. <img class="record_img" :src="item.img" mode="widthFix" />
  402. <div>
  403. <div class="prize_name">{{item.name}}</div>
  404. <div class="prize_time">{{timeFormat(item.raffleTime)}}</div>
  405. </div>
  406. <el-button :disabled="item.status == -1 || item.status == 1" class="get_btn"
  407. @click="handleOpenForm(item.id)">{{item.status == 1 ? '已领取' : (item.status == -1 ? '审核中'
  408. : '领取')}}</el-button>
  409. </div>
  410. </div>
  411. </div>
  412. </div>
  413. <!-- 奖励弹窗 -->
  414. <div class="prize_dialog" v-if="showPrizeDialog">
  415. <div class="dialog-body">
  416. <img class="dialog-tip" src="./img/dialog-tip.png" />
  417. <img class="dialog-bg" src="./img/dialog-bg.png" />
  418. <div class="prize-msg" v-if="prizeData.acceptType === 2">
  419. <div class="money-title">微信红包</div>
  420. <div class="money-content">
  421. <span class="prize-money">{{prizeData.money}}</span>
  422. <span class="prize-unit">元</span>
  423. </div>
  424. <img class="dialog-btn" src="./img/dialog-btn.png" @click="showPrizeDialog = false" />
  425. <div class="money-tip">红包到账会有延迟情况,请以实际为准</div>
  426. </div>
  427. <div class="prize-msg" v-if="prizeData.acceptType === 0 || prizeData.acceptType === 1">
  428. <img class="goods-img" :src="prizeData.img" />
  429. <div class="goods-name">{{prizeData.name}}</div>
  430. <img class="dialog-btn" src="./img/dialog-btn.png" @click="showPrizeDialog = false" />
  431. </div>
  432. <img class="dialog-close" src="./img/dialog-close.png" @click="showPrizeDialog = false" />
  433. </div>
  434. </div>
  435. </div>
  436. <!-- 活动须知弹框 -->
  437. <el-dialog title="活动须知" :visible.sync="showRuleDialog">
  438. <div>以下隐私协议是本产品对用户隐私保护的许诺,请您务必仔细阅读本协议,以了解我们关于管理您个人信息的情况。本隐私协议的全部条款属于本产品用户服务协议的重要部份之一。<br />
  439. 为了给您提供更准确、更有针对性的服务,本产品可能会以如下方式,使用您授权的个人信息。但本产品会以高度的勤勉义务对待这些信息,在未征得您许可的情况下,不会将这些信息对外公开或向第三方提供。<br />
  440. 请务必遵守《微信开放平台协议》、《微信公众平台协议》、《企业微信服务协议》、《企业微信隐私保护协议》、《微信商户号服务协议》、《微信外部链接内容管理规范》等微信相关管理规范,我们不承担因违反上述管理规范所导致的任何责任。<br />
  441. 一、您已经认真阅读参与的活动信息,自愿参加相关活动。您自愿并乐意将活动链接、海报、文案等信息转发分享到微信朋友圈、微信群、微信聊天等渠道,并不是因为诱导的情况下参与相关活动、分享相关活动。<br />
  442. 二、您自愿选择服务或提供信息的情况下收集您的个人信息(包括但不限于,微信昵称,微信头像,微信地址,微信关联手机号等),并将这些信息进行整合,以便向您提供更好的用户服务。<br />
  443. 三、保有您的使用记录在如下情况下,本产品会遵照您的意愿或法律的规定披露您的个人信息(包括但不限于,微信昵称,微信头像,微信地址,微信关联手机号等),由此引发的问题将由您个人承担: <br />
  444. 1)事先获得您的授权<br />
  445. 2)只有获取您的个人资料,才能提供您所要求的服务 <br />
  446. 3)根据有关的法律法规要求<br />
  447. 4)按照相关政府主管部门的要求 <br />
  448. 5)为维护本产品的合法权益<br />
  449. 6)您同意让第三方共享资料<br />
  450. 7)我们发现您违反了本产品的服务条款或使用规定 <br />
  451. 8)我们需要向代表我们提供产品或服务的公司提供资料 (除非我们另行通知您,否则这些公司无权使用您的身份识别资料)<br />
  452. 四、本《隐私协议》不适用于以下情况: <br />
  453. 1)通过我们的服务而接入的第三方服务(包括任何第三方网站)收集的信息。本政策仅适用于我们所收集的信息,并不适用于任何第三方提供的服务或第三方的信息使用规则,我们对任何第三方使用由您提供的信息不承担任何责任。<br />
  454. 2)通过在我们服务中进行广告服务的其他公司或机构所收集的信息。<br />
  455. </div>
  456. </el-dialog>
  457. <el-dialog title="收货地址" :visible.sync="showDialog">
  458. <el-form :model="form" class="prize_form">
  459. <el-form-item label="姓名:">
  460. <el-input v-model="form.name" autocomplete="off"></el-input>
  461. </el-form-item>
  462. <el-form-item label="微信号:">
  463. <el-input v-model="form.wxAccount" autocomplete="off"></el-input>
  464. </el-form-item>
  465. <el-form-item label="手机号:">
  466. <el-input v-model="form.phone" autocomplete="off"></el-input>
  467. </el-form-item>
  468. <el-form-item label="地区:">
  469. <el-cascader v-model="cityData" :options="transformedData" @change="handleChangeCity">
  470. </el-cascader>
  471. </el-form-item>
  472. <el-form-item label="详细地址:">
  473. <el-input v-model="form.address" autocomplete="off"></el-input>
  474. </el-form-item>
  475. <el-form-item label="备注:">
  476. <el-input v-model="form.remark" type="textarea" autocomplete="off"></el-input>
  477. </el-form-item>
  478. </el-form>
  479. <div slot="footer" class="dialog-footer">
  480. <el-button type="primary" @click="handleSave">确 定</el-button>
  481. </div>
  482. </el-dialog>
  483. <el-dialog :title="dialogTitle" :visible.sync="showTipDialog" :show-close="false" :close-on-click-modal="false">
  484. <el-form :model="getInfoForm" class="prize_form" label-position="top">
  485. <div v-if="preFormType">
  486. <el-form-item label="手机号:">
  487. <el-input v-model="getInfoForm.phone" autocomplete="off" maxlength="11"
  488. oninput="value=value.replace(/[^\d]/g,'')"
  489. @blur="$event => {getInfoForm.phone = Number($event.target.value) || '';}"></el-input>
  490. </el-form-item>
  491. <el-form-item label="地址:">
  492. <el-cascader v-model="cityData" :options="transformedData" @change="handleInfoCity">
  493. </el-cascader>
  494. </el-form-item>
  495. <el-form-item label="意向车型:">
  496. <el-select v-model="getInfoForm.intenModel" placeholder="请选择">
  497. <el-option v-for="item in allCarList" :key="item" :label="item" :value="item">
  498. </el-option>
  499. </el-select>
  500. </el-form-item>
  501. </div>
  502. <div v-else>
  503. <el-form-item label="确认:">
  504. <el-radio-group v-model="getInfoForm.buyCar">
  505. <el-radio :label="1">是</el-radio>
  506. <el-radio :label="0">否</el-radio>
  507. </el-radio-group>
  508. </el-form-item>
  509. <el-form-item label="已购车型:" v-if="getInfoForm.buyCar">
  510. <el-select v-model="getInfoForm.car" placeholder="请选择">
  511. <el-option v-for="item in allCarList" :key="item" :label="item" :value="item">
  512. </el-option>
  513. </el-select>
  514. </el-form-item>
  515. </div>
  516. </el-form>
  517. <div slot="footer" class="dialog-footer">
  518. <el-button type="primary" @click="handleSaveCar">确 定</el-button>
  519. </div>
  520. </el-dialog>
  521. </div>
  522. <script>
  523. new Vue({
  524. el: '#box',
  525. data () {
  526. return {
  527. env: '',
  528. httpUrl: '',
  529. h5Type: null,
  530. qrCodeData: {
  531. qrCode: '',
  532. msg: '',
  533. },
  534. bId: null,
  535. shareTitle: '',
  536. shareDes: '',
  537. shareCover: '',
  538. prizesList: [],
  539. useNum: null,
  540. remainNum: null,
  541. activeMsg: '',
  542. lotteryRecords: [],
  543. activeName: 'tab1',
  544. showDialog: false,
  545. form: {
  546. name: '',
  547. wxAccount: '',
  548. phone: '',
  549. province: '',
  550. city: '',
  551. address: '',
  552. remark: '',
  553. recordId: null,
  554. },
  555. transformedData: [],
  556. cityData: '',
  557. showTipDialog: false,
  558. allCarList: [],
  559. getInfoForm: {
  560. buyCar: 1,
  561. phone: '',
  562. province: '',
  563. city: '',
  564. intenModel: '',
  565. car: '',
  566. },
  567. prizeData: {
  568. acceptType: null,
  569. name: '',
  570. img: '',
  571. money: '',
  572. id: null
  573. },
  574. showPrizeDialog: false,
  575. lotteryStatus: null,
  576. currentIndex: 0, // 当前活动的格子索引
  577. isSpinning: false,
  578. intervalId: null,
  579. showRuleDialog: false,
  580. preFormType: null,
  581. showError: false,
  582. errorMsg: '',
  583. dialogTitle: ""
  584. }
  585. },
  586. created () {
  587. this.bId = this.getQueryParam('bId')
  588. this.env = this.getQueryParam('env')
  589. this.h5Type = this.getQueryParam('h5Type')
  590. if (!this.env || this.env === 'prod') {
  591. this.httpUrl = 'https://wlapi.wefanbot.com'
  592. } else {
  593. this.httpUrl = 'http://test.wefanbot.com:18993'
  594. }
  595. this.ifH5Type()
  596. },
  597. methods: {
  598. // 公众号授权,获取code
  599. getAuth () {
  600. // 获取url上的code
  601. let code = this.getQueryParam('code')
  602. if (code) {
  603. // 判断业务id是否生产环境业务id
  604. fetch(this.httpUrl + `/p/insuite/p/isProdId?id=${this.bId}`)
  605. .then(res => {
  606. return res.json()
  607. }).then(result => {
  608. let { data, msg } = result
  609. if (typeof data === 'boolean' && data) {
  610. this.httpUrl = 'https://wlapi.wefanbot.com'
  611. } else {
  612. this.httpUrl = 'http://test.wefanbot.com:18993'
  613. }
  614. this.getInfoByh5Code(this.getQueryParam('code'))
  615. })
  616. } else {
  617. let redirect_uri = window.location.href
  618. // code 不存在,走微信网页授权逻辑
  619. let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  620. window.location.replace(url)
  621. }
  622. },
  623. getInfoByh5Code (code) {
  624. fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
  625. .then(res => {
  626. return res.json()
  627. }).then(result => {
  628. let { data, code, msg } = result
  629. if (code === 1) {
  630. this.h5Type = data.h5Type
  631. localStorage.setItem('openId', data.openId)
  632. // this.gerQwAuth(this.bId);
  633. this.ifH5Type();
  634. }
  635. })
  636. },
  637. ifH5Type () {
  638. if (this.h5Type == 19 || this.h5Type == 30) {
  639. if (this.getQueryParam('openId') || localStorage.getItem('openId')) {
  640. if (!this.getQueryParam('externalUserid')) {
  641. this.gerQwAuth(this.bId);
  642. } else {
  643. if (this.getQueryParam('externalUserid') === 'unknown') {
  644. this.gerQwCode(this.bId);
  645. } else {
  646. this.raffleInfo();
  647. this.raffleRecord()
  648. this.getCityLevel()
  649. this.getAllCar()
  650. this.getQyWxSign()
  651. }
  652. }
  653. } else {
  654. // 走授权操作
  655. this.getAuth();
  656. }
  657. } else if (this.h5Type == 20) {
  658. // 宝骏云海送祝福
  659. var currentQueryParams = window.location.search;
  660. window.location.replace('h5Type-20.html' + currentQueryParams)
  661. } else if (this.h5Type == 21) {
  662. // 活码
  663. var currentQueryParams = window.location.search;
  664. window.location.replace('live_code.html' + currentQueryParams)
  665. } else if (this.h5Type == 22) {
  666. // 红包兑换
  667. var currentQueryParams = window.location.search;
  668. window.location.replace('receiveMoney.html' + currentQueryParams)
  669. } else if (this.h5Type == 23) {
  670. // 会话列表
  671. var currentQueryParams = window.location.search;
  672. window.location.replace('sessionList.html' + currentQueryParams)
  673. } else if (this.h5Type == 24) {
  674. // 客户SOP提醒
  675. var currentQueryParams = window.location.search;
  676. window.location.replace('clientSopTip.html' + currentQueryParams)
  677. } else if (this.h5Type == 25) {
  678. // 客户SOP内容
  679. var currentQueryParams = window.location.search;
  680. window.location.replace('clientSop.html' + currentQueryParams)
  681. } else if (this.h5Type == 26) {
  682. // 群SOP提醒
  683. var currentQueryParams = window.location.search;
  684. window.location.replace('groupSopTip.html' + currentQueryParams)
  685. } else if (this.h5Type == 27) {
  686. // 群SOP内容
  687. var currentQueryParams = window.location.search;
  688. window.location.replace('groupSop.html' + currentQueryParams)
  689. } else if (this.h5Type == 28) {
  690. // 点亮五菱
  691. var currentQueryParams = window.location.search;
  692. window.location.replace('lightUpWl.html' + currentQueryParams)
  693. } else if (this.h5Type == 29) {
  694. // 车主筛选,试驾筛选,预约试驾
  695. var currentQueryParams = window.location.search;
  696. window.location.replace('carOwnerScreening.html' + currentQueryParams)
  697. } else if (this.h5Type == 31) {
  698. // 活动报名
  699. var currentQueryParams = window.location.search;
  700. window.location.replace('registrationActivity.html' + currentQueryParams)
  701. } else if (this.h5Type == 32) {
  702. // 核销
  703. var currentQueryParams = window.location.search;
  704. window.location.replace('signUp.html' + currentQueryParams)
  705. } else if (!this.h5Type) {
  706. this.getAuth()
  707. }
  708. },
  709. // 企微授权
  710. gerQwAuth (bId) {
  711. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  712. fetch(this.httpUrl + `/p/insuite/p/getOAUrl?openId=${openId}&bId=${bId}`)
  713. .then(res => {
  714. return res.json()
  715. }).then(result => {
  716. let { data, code, msg } = result
  717. if (code === 1) {
  718. window.location.replace(data)
  719. } else {
  720. this.$message({
  721. message: msg,
  722. type: 'warning'
  723. })
  724. }
  725. })
  726. },
  727. // 获取二维码
  728. gerQwCode (bId) {
  729. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/getUnknown?bId=${bId}`)
  730. .then(res => {
  731. return res.json()
  732. }).then(result => {
  733. let { data, code, msg } = result
  734. if (code === 1) {
  735. this.qrCodeData = data
  736. } else {
  737. this.$message({
  738. message: msg,
  739. type: 'warning'
  740. })
  741. }
  742. })
  743. },
  744. // 内容类型的分享页,获取企业微信的签名
  745. getQyWxSign () {
  746. let shareUrl = `${window.location.origin}?bId=${this.bId}&h5Type=${this.h5Type}`
  747. fetch(this.httpUrl + `/scrm/v1/ct-share/p/getSignature?url=${window.location.href}`)
  748. .then(res => {
  749. return res.json()
  750. }).then(result => {
  751. let { data, code, msg } = result
  752. if (code === 1) {
  753. wx.config({
  754. debug: false,
  755. appId: data.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
  756. timestamp: data.timestamp, // 必填,生成签名的时间戳
  757. nonceStr: data.nonceStr, // 必填,生成签名的随机串
  758. signature: data.signature, // 必填,签名,见附录1
  759. jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'] // 必填,需要使用的JS接口列表
  760. })
  761. // 分享接口仅激活的成员数超过200人且已经认证的企业才可在微信上调用。
  762. wx.ready(() => {
  763. let shareData = {
  764. link: shareUrl,
  765. title: this.shareTitle, // 分享标题
  766. desc: this.shareDes, // 分享描述
  767. imgUrl: this.shareCover,
  768. }
  769. // 分享到朋友圈
  770. wx.updateAppMessageShareData(shareData)
  771. // 分享给朋友
  772. wx.updateTimelineShareData(shareData);
  773. // 配置失败的回调函数
  774. wx.error(function(res) {
  775. // 配置失败
  776. console.log('配置失败', res);
  777. })
  778. })
  779. } else {
  780. // this.$message({
  781. // message: msg,
  782. // type: 'warning'
  783. // })
  784. }
  785. })
  786. },
  787. // 获取抽奖信息
  788. raffleInfo () {
  789. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/raffleInfoByOpenId?openId=${this.getQueryParam('openId') || localStorage.getItem('openId')}&bId=${this.bId}`)
  790. .then(res => {
  791. return res.json()
  792. }).then(result => {
  793. let { data, code, msg } = result
  794. if (code === 1) {
  795. this.lotteryStatus = data.status
  796. this.prizesList = data.prizes
  797. this.useNum = data.useNum
  798. this.remainNum = data.raffleNum - data.useNum
  799. this.activeMsg = data.activityInfo
  800. this.shareTitle = data.name
  801. this.shareDes = data.description
  802. this.shareCover = data.cover
  803. this.preFormType = data.preFormType
  804. if (data.preForm && !data.isSubmit && this.getInfoForm.buyCar !== 0) {
  805. if (this.preFormType) {
  806. this.dialogTitle = '五菱试驾体验报名'
  807. } else {
  808. this.dialogTitle = '请问您是否已购五菱/宝骏车型?'
  809. }
  810. // 此处加上this.getInfoForm.buyCar !== 0的条件是当用户点击过否的时候,不再弹出此框,除非用户重新进入页面,可再次弹出此框
  811. this.showTipDialog = true
  812. }
  813. } else {
  814. this.showError = true
  815. this.errorMsg = msg
  816. }
  817. })
  818. },
  819. // 抽奖记录
  820. raffleRecord () {
  821. fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/raffleRecord', {
  822. method: 'post',
  823. body: JSON.stringify({
  824. openId: this.getQueryParam('openId') || localStorage.getItem('openId'),
  825. bid: this.bId,
  826. page: 1,
  827. pageCount: 1000,
  828. }),
  829. headers: {
  830. 'Content-Type': 'application/json'
  831. }
  832. }).then(res => {
  833. return res.json()
  834. }).then(result => {
  835. let { data, code, msg } = result
  836. if (code === 1) {
  837. this.lotteryRecords = data.records
  838. }
  839. })
  840. },
  841. changeTab (tabName) {
  842. this.activeName = tabName
  843. },
  844. handleOpenForm (id) {
  845. this.form.recordId = id
  846. this.showDialog = true
  847. },
  848. handleSave () {
  849. if (!this.form.name) {
  850. this.$message({
  851. message: '请填写姓名',
  852. type: 'warning'
  853. })
  854. return
  855. }
  856. if (!this.form.phone) {
  857. this.$message({
  858. message: '请输入手机号',
  859. type: 'warning'
  860. })
  861. return
  862. }
  863. if (!this.form.province) {
  864. this.$message({
  865. message: '请选择城市',
  866. type: 'warning'
  867. })
  868. return
  869. }
  870. fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/raffleForm', {
  871. method: 'post',
  872. body: JSON.stringify(this.form),
  873. headers: {
  874. 'Content-Type': 'application/json'
  875. }
  876. }).then(res => {
  877. return res.json()
  878. }).then(result => {
  879. let { data, code, msg } = result
  880. if (code === 1) {
  881. this.$message({
  882. message: '提交成功!',
  883. type: 'success'
  884. })
  885. this.showDialog = false
  886. this.raffleRecord()
  887. }
  888. })
  889. },
  890. handleSaveCar () {
  891. if (this.preFormType) {
  892. if (!this.getInfoForm.phone) {
  893. this.$message({
  894. message: '请输入手机号',
  895. type: 'warning'
  896. })
  897. return
  898. }
  899. if (!this.getInfoForm.city) {
  900. this.$message({
  901. message: '请选择城市',
  902. type: 'warning'
  903. })
  904. return
  905. }
  906. if (!this.getInfoForm.intenModel) {
  907. this.$message({
  908. message: '请选择意向车型',
  909. type: 'warning'
  910. })
  911. return
  912. }
  913. this.getInfoForm.buyCar = null
  914. this.getInfoForm.car = ''
  915. } else {
  916. if (this.getInfoForm.buyCar) {
  917. if (!this.getInfoForm.car) {
  918. this.$message({
  919. message: '请选择已购车型',
  920. type: 'warning'
  921. })
  922. return
  923. }
  924. } else {
  925. this.getInfoForm.car = ''
  926. }
  927. this.getInfoForm.phone = ''
  928. this.getInfoForm.province = ''
  929. this.getInfoForm.city = ''
  930. this.getInfoForm.intenModel = ''
  931. }
  932. fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/submitPreForm', {
  933. method: 'post',
  934. body: JSON.stringify({
  935. bid: this.bId,
  936. buyCar: this.getInfoForm.buyCar,
  937. car: this.getInfoForm.car,
  938. phone: this.getInfoForm.phone,
  939. province: this.getInfoForm.province,
  940. city: this.getInfoForm.city,
  941. intenModel: this.getInfoForm.intenModel,
  942. mpOpenId: this.getQueryParam('openId') || this.localStorage.getItem('openId'),
  943. }),
  944. headers: {
  945. 'Content-Type': 'application/json'
  946. }
  947. }).then(res => {
  948. return res.json()
  949. }).then(result => {
  950. let { data, code, msg } = result
  951. if (code === 1) {
  952. this.$message({
  953. message: '提交成功!',
  954. type: 'success'
  955. })
  956. this.showTipDialog = false
  957. }
  958. })
  959. },
  960. // 获取城市数据
  961. getCityLevel () {
  962. fetch('https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/1000/1720161853377/pc-code.json')
  963. .then(res => {
  964. return res.json()
  965. }).then(result => {
  966. this.transformedData = this.transformData(result)
  967. })
  968. },
  969. // 获取全部车型
  970. getAllCar () {
  971. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/getCarList?bId=${this.bId}`)
  972. .then(res => {
  973. return res.json()
  974. }).then(result => {
  975. let { data, code, msg } = result
  976. if (code === 1) {
  977. this.allCarList = data
  978. }
  979. })
  980. },
  981. handleChangeCity (value) {
  982. this.form.province = value[0]
  983. this.form.city = value[1]
  984. },
  985. handleInfoCity (value) {
  986. this.getInfoForm.province = value[0]
  987. this.getInfoForm.city = value[1]
  988. },
  989. // 点击抽奖
  990. handleLottery () {
  991. if (!this.remainNum) {
  992. this.$message({
  993. message: '暂无抽奖次数',
  994. type: 'warning'
  995. })
  996. return
  997. }
  998. if (this.lotteryStatus === -1) {
  999. this.$message({
  1000. message: '活动已结束',
  1001. type: 'warning'
  1002. })
  1003. } else if (this.lotteryStatus === 0) {
  1004. this.$message({
  1005. message: '活动未开始',
  1006. type: 'warning'
  1007. })
  1008. } else if (this.lotteryStatus === 1) {
  1009. if (this.isSpinning) return
  1010. this.isSpinning = true
  1011. this.currentIndex = 0
  1012. let externalUserid = this.getQueryParam('externalUserid')
  1013. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  1014. const headers = new Headers();
  1015. headers.append('police', 110);
  1016. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/lottery?externalUserid=${externalUserid}&openId=${openId}&bId=${this.bId}`, {
  1017. method: 'GET',
  1018. headers: headers
  1019. })
  1020. .then(res => {
  1021. return res.json()
  1022. }).then(result => {
  1023. let { data, code, msg } = result
  1024. if (code === 1) {
  1025. this.stopLottery()
  1026. this.prizeData = data
  1027. this.showPrizeDialog = true
  1028. this.raffleInfo();
  1029. this.raffleRecord();
  1030. } else {
  1031. this.stopLottery()
  1032. this.$message({
  1033. message: msg,
  1034. })
  1035. }
  1036. })
  1037. // 开始转圈
  1038. this.intervalId = setInterval(() => {
  1039. this.currentIndex = (this.currentIndex + 1) % 9;
  1040. }, 200); // 每 200 毫秒转一次
  1041. }
  1042. },
  1043. // 停止抽奖
  1044. stopLottery () {
  1045. clearInterval(this.intervalId);
  1046. this.isSpinning = false;
  1047. this.currentIndex = null;
  1048. },
  1049. handleRule () {
  1050. this.showRuleDialog = true
  1051. },
  1052. // 省市数据做转换
  1053. transformData (data) {
  1054. return data.map(item => {
  1055. // 创建一个新对象,避免直接修改原始对象
  1056. const newItem = { ...item };
  1057. // 重命名 text 为 label
  1058. if (newItem.text) {
  1059. newItem.label = newItem.text;
  1060. newItem.value = newItem.text;
  1061. delete newItem.text;
  1062. }
  1063. // 如果存在 children 数组,则递归处理每个子项
  1064. if (newItem.children && Array.isArray(newItem.children)) {
  1065. newItem.children = this.transformData(newItem.children);
  1066. }
  1067. return newItem;
  1068. })
  1069. },
  1070. // 截取url中的数据
  1071. getQueryParam (paramName) {
  1072. // 获取当前URL的查询字符串部分
  1073. const queryString = window.location.search;
  1074. // 创建一个URLSearchParams对象
  1075. const urlParams = new URLSearchParams(queryString);
  1076. // 返回指定参数的值,如果不存在则返回null
  1077. return urlParams.get(paramName);
  1078. },
  1079. timeFormat (time, format = 'yyyy-MM-dd hh:mm:ss') {
  1080. if (time === undefined || time === '' || time === null) {
  1081. return '/'
  1082. } else {
  1083. const date = new Date(time)
  1084. const o = {
  1085. 'M+': date.getMonth() + 1,
  1086. 'd+': date.getDate(),
  1087. 'h+': date.getHours(),
  1088. 'm+': date.getMinutes(),
  1089. 's+': date.getSeconds(),
  1090. 'q+': Math.floor((date.getMonth() + 3) / 3),
  1091. 'S': date.getMilliseconds()
  1092. }
  1093. if (/(y+)/.test(format)) {
  1094. format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
  1095. }
  1096. for (let k in o) {
  1097. if (new RegExp('(' + k + ')').test(format)) {
  1098. format = format.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
  1099. }
  1100. }
  1101. return format
  1102. }
  1103. },
  1104. }
  1105. })
  1106. </script>
  1107. </body>
  1108. </html>