index.html 33 KB

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