lottery.html 35 KB

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