index.html 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  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. </style>
  357. <body>
  358. <div id="box">
  359. <!-- 二维码 -->
  360. <div class="qrcode" v-if="qrCodeData.qrCode">
  361. <img class="qrcode-img" :src="qrCodeData.qrCode" />
  362. <div class="qrcode-msg">{{qrCodeData.msg}}</div>
  363. </div>
  364. <div v-if="h5Type == 19">
  365. <div class="lotteryPage">
  366. <div class="event_notice" @click="handleRule">
  367. <span>活动须知</span>
  368. </div>
  369. <div class="prize_content">
  370. <div :class="['prize_item', { actives: isSpinning && index === currentIndex }]" v-for="(item, index) in prizesList" :key="index">
  371. <img class="prize_img" :src="item.img"></img>
  372. <div>{{item.name}}</div>
  373. </div>
  374. </div>
  375. <div class="lottery_btn">
  376. <img class="btn_img" src="./img/btn.png" @click="handleLottery"></img>
  377. <div class="lottery_tip">已抽奖{{useNum}}次,还剩{{remainNum}}次机会</div>
  378. </div>
  379. </div>
  380. <div class="rule">
  381. <div class="rule_body">
  382. <div class="tabs">
  383. <Button class="tab_link" :class="{ 'active': activeName === 'tab1' }" @click="changeTab('tab1')">活动信息</Button>
  384. <Button class="tab_link" :class="{ 'active': activeName === 'tab2' }" @click="changeTab('tab2')">抽奖记录</Button>
  385. </div>
  386. <div v-if="activeName === 'tab1'" class="tab_content record_list" v-html="activeMsg"></div>
  387. <div v-if="activeName === 'tab2'" class="record_list">
  388. <div class="record_item" v-for="(item, index) in lotteryRecords" :key="index">
  389. <img class="record_img" :src="item.img" mode="widthFix" />
  390. <div>
  391. <div class="prize_name">{{item.name}}</div>
  392. <div class="prize_time">{{timeFormat(item.raffleTime)}}</div>
  393. </div>
  394. <el-button :disabled="item.status == -1 || item.status == 1" class="get_btn" onclick="handleOpenForm(item.id)">{{item.status == 1 ? '已领取' : (item.status == -1 ? '审核中' : '领取')}}</el-button>
  395. </div>
  396. </div>
  397. </div>
  398. </div>
  399. </div>
  400. <!-- 奖励弹窗 -->
  401. <div class="prize_dialog" v-if="showPrizeDialog">
  402. <div class="dialog-body">
  403. <img class="dialog-tip" src="./img/dialog-tip.png" />
  404. <img class="dialog-bg" src="./img/dialog-bg.png" />
  405. <div class="prize-msg" v-if="prizeData.acceptType === 2">
  406. <div class="money-title">微信红包</div>
  407. <div class="money-content">
  408. <span class="prize-money">{{prizeData.money}}</span>
  409. <span class="prize-unit">元</span>
  410. </div>
  411. <img class="dialog-btn" src="./img/dialog-btn.png" @click="showPrizeDialog = false"/>
  412. <div class="money-tip">红包到账会有延迟情况,请以实际为准</div>
  413. </div>
  414. <div class="prize-msg" v-if="prizeData.acceptType === 0 || prizeData.acceptType === 1">
  415. <img class="goods-img" :src="prizeData.img" />
  416. <div class="goods-name">{{prizeData.name}}</div>
  417. <img class="dialog-btn" src="./img/dialog-btn.png" @click="showPrizeDialog = false" />
  418. </div>
  419. <img class="dialog-close" src="./img/dialog-close.png" @click="showPrizeDialog = false" />
  420. </div>
  421. </div>
  422. <!-- 活动须知弹框 -->
  423. <el-dialog
  424. title="活动须知"
  425. :visible.sync="showRuleDialog">
  426. <div>以下隐私协议是本产品对用户隐私保护的许诺,请您务必仔细阅读本协议,以了解我们关于管理您个人信息的情况。本隐私协议的全部条款属于本产品用户服务协议的重要部份之一。<br />
  427. 为了给您提供更准确、更有针对性的服务,本产品可能会以如下方式,使用您授权的个人信息。但本产品会以高度的勤勉义务对待这些信息,在未征得您许可的情况下,不会将这些信息对外公开或向第三方提供。<br />
  428. 请务必遵守《微信开放平台协议》、《微信公众平台协议》、《企业微信服务协议》、《企业微信隐私保护协议》、《微信商户号服务协议》、《微信外部链接内容管理规范》等微信相关管理规范,我们不承担因违反上述管理规范所导致的任何责任。<br />
  429. 一、您已经认真阅读参与的活动信息,自愿参加相关活动。您自愿并乐意将活动链接、海报、文案等信息转发分享到微信朋友圈、微信群、微信聊天等渠道,并不是因为诱导的情况下参与相关活动、分享相关活动。<br />
  430. 二、您自愿选择服务或提供信息的情况下收集您的个人信息(包括但不限于,微信昵称,微信头像,微信地址,微信关联手机号等),并将这些信息进行整合,以便向您提供更好的用户服务。<br />
  431. 三、保有您的使用记录在如下情况下,本产品会遵照您的意愿或法律的规定披露您的个人信息(包括但不限于,微信昵称,微信头像,微信地址,微信关联手机号等),由此引发的问题将由您个人承担: <br />
  432. 1)事先获得您的授权<br />
  433. 2)只有获取您的个人资料,才能提供您所要求的服务 <br />
  434. 3)根据有关的法律法规要求<br />
  435. 4)按照相关政府主管部门的要求 <br />
  436. 5)为维护本产品的合法权益<br />
  437. 6)您同意让第三方共享资料<br />
  438. 7)我们发现您违反了本产品的服务条款或使用规定 <br />
  439. 8)我们需要向代表我们提供产品或服务的公司提供资料 (除非我们另行通知您,否则这些公司无权使用您的身份识别资料)<br />
  440. 四、本《隐私协议》不适用于以下情况: <br />
  441. 1)通过我们的服务而接入的第三方服务(包括任何第三方网站)收集的信息。本政策仅适用于我们所收集的信息,并不适用于任何第三方提供的服务或第三方的信息使用规则,我们对任何第三方使用由您提供的信息不承担任何责任。<br />
  442. 2)通过在我们服务中进行广告服务的其他公司或机构所收集的信息。<br />
  443. </div>
  444. </el-dialog>
  445. <el-dialog title="收货地址" :visible.sync="showDialog">
  446. <el-form :model="form" class="prize_form">
  447. <el-form-item label="姓名:">
  448. <el-input v-model="form.name" autocomplete="off"></el-input>
  449. </el-form-item>
  450. <el-form-item label="微信号:">
  451. <el-input v-model="form.wxAccount" autocomplete="off"></el-input>
  452. </el-form-item>
  453. <el-form-item label="手机号:">
  454. <el-input v-model="form.phone" autocomplete="off"></el-input>
  455. </el-form-item>
  456. <el-form-item label="地区:">
  457. <el-cascader
  458. v-model="cityData"
  459. :options="transformedData"
  460. @change="handleChangeCity">
  461. </el-cascader>
  462. </el-form-item>
  463. <el-form-item label="详细地址:">
  464. <el-input v-model="form.address" autocomplete="off"></el-input>
  465. </el-form-item>
  466. <el-form-item label="备注:">
  467. <el-input v-model="form.remark" type="textarea" autocomplete="off"></el-input>
  468. </el-form-item>
  469. </el-form>
  470. <div slot="footer" class="dialog-footer">
  471. <el-button type="primary" @click="handleSave">确 定</el-button>
  472. </div>
  473. </el-dialog>
  474. <el-dialog title="请问您是否已购五菱/宝骏车型?" :visible.sync="showTipDialog" :show-close="false" :close-on-click-modal="false">
  475. <el-form :model="getInfoForm" class="prize_form"label-position="top">
  476. <div v-if="preFormType">
  477. <el-form-item label="手机号:">
  478. <el-input type="number" v-model="getInfoForm.phone" autocomplete="off"
  479. maxlength="11"
  480. oninput="value=value.replace(/[^\d]/g,'')"
  481. @blur="$event => {getInfoForm.phone = Number($event.target.value) || '';}"
  482. ></el-input>
  483. </el-form-item>
  484. <el-form-item label="地址:">
  485. <el-cascader v-model="cityData" :options="transformedData" @change="handleInfoCity">
  486. </el-cascader>
  487. </el-form-item>
  488. <el-form-item label="意向车型:">
  489. <el-select v-model="getInfoForm.intenModel" placeholder="请选择">
  490. <el-option
  491. v-for="item in allCarList"
  492. :key="item"
  493. :label="item"
  494. :value="item">
  495. </el-option>
  496. </el-select>
  497. </el-form-item>
  498. </div>
  499. <div v-else>
  500. <el-form-item label="确认:">
  501. <el-radio-group v-model="getInfoForm.buyCar">
  502. <el-radio :label="1">是</el-radio>
  503. <el-radio :label="0">否</el-radio>
  504. </el-radio-group>
  505. </el-form-item>
  506. <el-form-item label="已购车型:" v-if="getInfoForm.buyCar">
  507. <el-select v-model="getInfoForm.car" placeholder="请选择">
  508. <el-option v-for="item in allCarList" :key="item" :label="item" :value="item">
  509. </el-option>
  510. </el-select>
  511. </el-form-item>
  512. </div>
  513. </el-form>
  514. <div slot="footer" class="dialog-footer">
  515. <el-button type="primary" @click="handleSaveCar">确 定</el-button>
  516. </div>
  517. </el-dialog>
  518. </div>
  519. <script>
  520. new Vue({
  521. el: '#box',
  522. data() {
  523. return {
  524. env: '',
  525. httpUrl: '',
  526. h5Type: null,
  527. qrCodeData: {
  528. qrCode: '',
  529. msg: '',
  530. },
  531. bId: null,
  532. shareTitle: '',
  533. shareDes: '',
  534. shareCover: '',
  535. prizesList: [],
  536. useNum: null,
  537. remainNum: null,
  538. activeMsg: '',
  539. lotteryRecords: [],
  540. activeName: 'tab1',
  541. showDialog: false,
  542. form: {
  543. name: '',
  544. wxAccount: '',
  545. phone: '',
  546. province: '',
  547. city: '',
  548. address: '',
  549. remark: '',
  550. recordId: null,
  551. },
  552. transformedData: [],
  553. cityData: '',
  554. showTipDialog: false,
  555. allCarList: [],
  556. getInfoForm: {
  557. buyCar: 1,
  558. phone: '',
  559. province: '',
  560. city: '',
  561. intenModel: '',
  562. car: '',
  563. },
  564. prizeData: {
  565. acceptType: null,
  566. name: '',
  567. img: '',
  568. money: '',
  569. id: null
  570. },
  571. showPrizeDialog: false,
  572. lotteryStatus: null,
  573. currentIndex: 0, // 当前活动的格子索引
  574. isSpinning: false,
  575. intervalId: null,
  576. showRuleDialog: false,
  577. preFormType: null,
  578. }
  579. },
  580. created() {
  581. this.bId = this.getQueryParam('bId')
  582. this.env = this.getQueryParam('env')
  583. this.h5Type = this.getQueryParam('h5Type')
  584. if (!this.env || this.env === 'prod') {
  585. this.httpUrl = 'https://wlapi.wefanbot.com'
  586. } else {
  587. this.httpUrl = 'http://test.wefanbot.com:18993'
  588. }
  589. if (this.h5Type == 19) {
  590. if (this.getQueryParam('openId') || localStorage.getItem('openId')) {
  591. if (!this.getQueryParam('externalUserid')) {
  592. this.gerQwAuth(this.bId);
  593. } else {
  594. if (this.getQueryParam('externalUserid') === 'unknown') {
  595. this.gerQwCode(this.bId);
  596. } else {
  597. this.raffleInfo();
  598. this.raffleRecord()
  599. this.getCityLevel()
  600. this.getAllCar()
  601. this.getQyWxSign()
  602. }
  603. }
  604. } else {
  605. // 走授权操作
  606. this.getAuth();
  607. }
  608. } else if (this.h5Type == 20) {
  609. // 宝骏云海送祝福
  610. var currentQueryParams = window.location.search;
  611. window.location.replace('h5Type-20.html' + currentQueryParams)
  612. } else if (this.h5Type == 21) {
  613. // 活码
  614. var currentQueryParams = window.location.search;
  615. window.location.replace('live_code.html' + currentQueryParams)
  616. } else if (this.h5Type == 22) {
  617. // 红包兑换
  618. var currentQueryParams = window.location.search;
  619. window.location.replace('receiveMoney.html' + currentQueryParams)
  620. } else if (this.h5Type == 23) {
  621. // 会话列表
  622. var currentQueryParams = window.location.search;
  623. window.location.replace('sessionList.html' + currentQueryParams)
  624. } else if (this.h5Type == 24) {
  625. // 客户SOP提醒
  626. var currentQueryParams = window.location.search;
  627. window.location.replace('clientSopTip.html' + currentQueryParams)
  628. } else if (this.h5Type == 25) {
  629. // 客户SOP内容
  630. var currentQueryParams = window.location.search;
  631. window.location.replace('clientSop.html' + currentQueryParams)
  632. } else if (this.h5Type == 26) {
  633. // 群SOP提醒
  634. var currentQueryParams = window.location.search;
  635. window.location.replace('groupSopTip.html' + currentQueryParams)
  636. } else if (this.h5Type == 27) {
  637. // 群SOP内容
  638. var currentQueryParams = window.location.search;
  639. window.location.replace('groupSop.html' + currentQueryParams)
  640. } else if (!this.h5Type) {
  641. this.getAuth()
  642. }
  643. },
  644. methods: {
  645. // 公众号授权,获取code
  646. getAuth () {
  647. // 获取url上的code
  648. let code = this.getQueryParam('code')
  649. if (code) {
  650. fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
  651. .then(res => {
  652. return res.json()
  653. }).then(result => {
  654. let { data, code, msg } = result
  655. if (code === 1) {
  656. this.h5Type = data.h5Type
  657. localStorage.setItem('openId', data.openId)
  658. this.gerQwAuth(this.bId);
  659. }
  660. })
  661. } else {
  662. let redirect_uri = window.location.href
  663. // code 不存在,走微信网页授权逻辑
  664. let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  665. window.location.replace(url)
  666. }
  667. },
  668. // 企微授权
  669. gerQwAuth (bId) {
  670. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  671. fetch(this.httpUrl + `/p/insuite/p/getOAUrl?openId=${openId}&bId=${bId}`)
  672. .then(res => {
  673. return res.json()
  674. }).then(result => {
  675. let { data, code, msg } = result
  676. if (code === 1) {
  677. window.location.replace(data)
  678. } else {
  679. this.$message({
  680. message: msg,
  681. type: 'warning'
  682. })
  683. }
  684. })
  685. },
  686. // 获取二维码
  687. gerQwCode (bId) {
  688. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/getUnknown?bId=${bId}`)
  689. .then(res => {
  690. return res.json()
  691. }).then(result => {
  692. let { data, code, msg } = result
  693. if (code === 1) {
  694. this.qrCodeData = data
  695. } else {
  696. this.$message({
  697. message: msg,
  698. type: 'warning'
  699. })
  700. }
  701. })
  702. },
  703. // 内容类型的分享页,获取企业微信的签名
  704. getQyWxSign () {
  705. let shareUrl = `${window.location.origin}?bId=${this.bId}&h5Type=${this.h5Type}`
  706. fetch(this.httpUrl + `/scrm/v1/ct-share/p/getSignature?url=${window.location.href}`)
  707. .then(res => {
  708. return res.json()
  709. }).then(result => {
  710. let { data, code, msg } = result
  711. if (code === 1) {
  712. wx.config({
  713. debug: false,
  714. appId: data.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
  715. timestamp: data.timestamp, // 必填,生成签名的时间戳
  716. nonceStr: data.nonceStr, // 必填,生成签名的随机串
  717. signature: data.signature, // 必填,签名,见附录1
  718. jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'] // 必填,需要使用的JS接口列表
  719. })
  720. // 分享接口仅激活的成员数超过200人且已经认证的企业才可在微信上调用。
  721. wx.ready(() => {
  722. let shareData = {
  723. link: shareUrl,
  724. title: this.shareTitle, // 分享标题
  725. desc: this.shareDes, // 分享描述
  726. imgUrl: this.shareCover,
  727. }
  728. // 分享到朋友圈
  729. wx.updateAppMessageShareData(shareData)
  730. // 分享给朋友
  731. wx.updateTimelineShareData(shareData);
  732. // 配置失败的回调函数
  733. wx.error(function(res) {
  734. // 配置失败
  735. console.log('配置失败', res);
  736. })
  737. })
  738. } else {
  739. // this.$message({
  740. // message: msg,
  741. // type: 'warning'
  742. // })
  743. }
  744. })
  745. },
  746. // 获取抽奖信息
  747. raffleInfo () {
  748. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/raffleInfoByOpenId?openId=${this.getQueryParam('openId') || localStorage.getItem('openId')}&bId=${this.bId}`)
  749. .then(res => {
  750. return res.json()
  751. }).then(result => {
  752. let { data, code, msg } = result
  753. if (code === 1) {
  754. this.lotteryStatus = data.status
  755. this.prizesList = data.prizes
  756. this.useNum = data.useNum
  757. this.remainNum = data.raffleNum - data.useNum
  758. this.activeMsg = data.activityInfo
  759. this.shareTitle = data.name
  760. this.shareDes = data.description
  761. this.shareCover = data.cover
  762. this.preFormType = data.preFormType
  763. if (data.preForm && !data.isSubmit) {
  764. this.showTipDialog = true
  765. }
  766. }
  767. })
  768. },
  769. // 抽奖记录
  770. raffleRecord () {
  771. fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/raffleRecord', {
  772. method: 'post',
  773. body: JSON.stringify({
  774. openId: this.getQueryParam('openId') || localStorage.getItem('openId'),
  775. bid: this.bId,
  776. page: 1,
  777. pageCount: 1000,
  778. }),
  779. headers: {
  780. 'Content-Type': 'application/json'
  781. }
  782. }).then(res => {
  783. return res.json()
  784. }).then(result => {
  785. let { data, code, msg } = result
  786. if (code === 1) {
  787. this.lotteryRecords = data.records
  788. }
  789. })
  790. },
  791. changeTab (tabName) {
  792. this.activeName = tabName
  793. },
  794. handleOpenForm (id) {
  795. this.form.recordId = id
  796. this.showDialog = true
  797. },
  798. handleSave () {
  799. if (!this.form.name) {
  800. this.$message({
  801. message: '请填写姓名',
  802. type: 'warning'
  803. })
  804. return
  805. }
  806. if (!this.form.phone) {
  807. this.$message({
  808. message: '请输入手机号',
  809. type: 'warning'
  810. })
  811. return
  812. }
  813. if (!this.form.province) {
  814. this.$message({
  815. message: '请选择城市',
  816. type: 'warning'
  817. })
  818. return
  819. }
  820. fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/raffleForm', {
  821. method: 'post',
  822. body: JSON.stringify(this.form),
  823. headers: {
  824. 'Content-Type': 'application/json'
  825. }
  826. }).then(res => {
  827. return res.json()
  828. }).then(result => {
  829. let { data, code, msg } = result
  830. if (code === 1) {
  831. this.$message({
  832. message: '提交成功!',
  833. type: 'success'
  834. })
  835. this.showDialog = false
  836. this.raffleRecord()
  837. }
  838. })
  839. },
  840. handleSaveCar () {
  841. if (this.preFormType) {
  842. if (!this.getInfoForm.phone) {
  843. this.$message({
  844. message: '请输入手机号',
  845. type: 'warning'
  846. })
  847. return
  848. }
  849. if (!this.getInfoForm.city) {
  850. this.$message({
  851. message: '请选择城市',
  852. type: 'warning'
  853. })
  854. return
  855. }
  856. if (!this.getInfoForm.intenModel) {
  857. this.$message({
  858. message: '请选择意向车型',
  859. type: 'warning'
  860. })
  861. return
  862. }
  863. this.getInfoForm.buyCar = null
  864. this.getInfoForm.car = ''
  865. } else {
  866. if (this.getInfoForm.buyCar) {
  867. if (!this.getInfoForm.car) {
  868. this.$message({
  869. message: '请选择已购车型',
  870. type: 'warning'
  871. })
  872. return
  873. }
  874. } else {
  875. this.getInfoForm.car = ''
  876. }
  877. this.getInfoForm.phone = ''
  878. this.getInfoForm.province = ''
  879. this.getInfoForm.city = ''
  880. this.getInfoForm.intenModel = ''
  881. }
  882. fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/submitPreForm', {
  883. method: 'post',
  884. body: JSON.stringify({
  885. bid: this.bId,
  886. buyCar: this.getInfoForm.buyCar,
  887. car: this.getInfoForm.car,
  888. phone: this.getInfoForm.phone,
  889. province: this.getInfoForm.province,
  890. city: this.getInfoForm.city,
  891. intenModel: this.getInfoForm.intenModel,
  892. mpOpenId: this.getQueryParam('openId') || this.localStorage.getItem('openId'),
  893. }),
  894. headers: {
  895. 'Content-Type': 'application/json'
  896. }
  897. }).then(res => {
  898. return res.json()
  899. }).then(result => {
  900. let { data, code, msg } = result
  901. if (code === 1) {
  902. this.$message({
  903. message: '提交成功!',
  904. type: 'success'
  905. })
  906. this.showTipDialog = false
  907. }
  908. })
  909. },
  910. // 获取城市数据
  911. getCityLevel () {
  912. fetch('https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/1000/1720161853377/pc-code.json')
  913. .then(res => {
  914. return res.json()
  915. }).then(result => {
  916. this.transformedData = this.transformData(result)
  917. })
  918. },
  919. // 获取全部车型
  920. getAllCar () {
  921. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/getCarList?bId=${this.bId}`)
  922. .then(res => {
  923. return res.json()
  924. }).then(result => {
  925. let { data, code, msg } = result
  926. if (code === 1) {
  927. this.allCarList = data
  928. }
  929. })
  930. },
  931. handleChangeCity (value) {
  932. this.form.province = value[0]
  933. this.form.city = value[1]
  934. },
  935. handleInfoCity (value) {
  936. this.getInfoForm.province = value[0]
  937. this.getInfoForm.city = value[1]
  938. },
  939. // 点击抽奖
  940. handleLottery () {
  941. if (!this.remainNum) {
  942. this.$message({
  943. message: '暂无抽奖次数',
  944. type: 'warning'
  945. })
  946. return
  947. }
  948. if (this.lotteryStatus === -1) {
  949. this.$message({
  950. message: '活动已结束',
  951. type: 'warning'
  952. })
  953. } else if (this.lotteryStatus === 0) {
  954. this.$message({
  955. message: '活动未开始',
  956. type: 'warning'
  957. })
  958. } else if (this.lotteryStatus === 1) {
  959. if (this.isSpinning) return
  960. this.isSpinning = true
  961. this.currentIndex = 0
  962. let externalUserid = this.getQueryParam('externalUserid')
  963. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  964. const headers = new Headers();
  965. headers.append('police', 110);
  966. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/lottery?externalUserid=${externalUserid}&openId=${openId}&bId=${this.bId}`, {
  967. method: 'GET',
  968. headers: headers
  969. })
  970. .then(res => {
  971. return res.json()
  972. }).then(result => {
  973. let { data, code, msg } = result
  974. if (code === 1) {
  975. this.stopLottery()
  976. this.prizeData = data
  977. this.showPrizeDialog = true
  978. this.raffleInfo();
  979. this.raffleRecord();
  980. } else {
  981. this.stopLottery()
  982. this.$message({
  983. message: msg,
  984. })
  985. }
  986. })
  987. // 开始转圈
  988. this.intervalId = setInterval(() => {
  989. this.currentIndex = (this.currentIndex + 1) % 9;
  990. }, 200); // 每 200 毫秒转一次
  991. }
  992. },
  993. // 停止抽奖
  994. stopLottery() {
  995. clearInterval(this.intervalId);
  996. this.isSpinning = false;
  997. this.currentIndex = null;
  998. },
  999. handleRule () {
  1000. this.showRuleDialog = true
  1001. },
  1002. // 省市数据做转换
  1003. transformData(data) {
  1004. return data.map(item => {
  1005. // 创建一个新对象,避免直接修改原始对象
  1006. const newItem = { ...item };
  1007. // 重命名 text 为 label
  1008. if (newItem.text) {
  1009. newItem.label = newItem.text;
  1010. newItem.value = newItem.text;
  1011. delete newItem.text;
  1012. }
  1013. // 如果存在 children 数组,则递归处理每个子项
  1014. if (newItem.children && Array.isArray(newItem.children)) {
  1015. newItem.children = this.transformData(newItem.children);
  1016. }
  1017. return newItem;
  1018. })
  1019. },
  1020. // 截取url中的数据
  1021. getQueryParam (paramName) {
  1022. // 获取当前URL的查询字符串部分
  1023. const queryString = window.location.search;
  1024. // 创建一个URLSearchParams对象
  1025. const urlParams = new URLSearchParams(queryString);
  1026. // 返回指定参数的值,如果不存在则返回null
  1027. return urlParams.get(paramName);
  1028. },
  1029. timeFormat (time, format = 'yyyy-MM-dd hh:mm:ss') {
  1030. if (time === undefined || time === '' || time === null) {
  1031. return '/'
  1032. } else {
  1033. const date = new Date(time)
  1034. const o = {
  1035. 'M+': date.getMonth() + 1,
  1036. 'd+': date.getDate(),
  1037. 'h+': date.getHours(),
  1038. 'm+': date.getMinutes(),
  1039. 's+': date.getSeconds(),
  1040. 'q+': Math.floor((date.getMonth() + 3) / 3),
  1041. 'S': date.getMilliseconds()
  1042. }
  1043. if (/(y+)/.test(format)) {
  1044. format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
  1045. }
  1046. for (let k in o) {
  1047. if (new RegExp('(' + k + ')').test(format)) {
  1048. format = format.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
  1049. }
  1050. }
  1051. return format
  1052. }
  1053. },
  1054. }
  1055. })
  1056. </script>
  1057. </body>
  1058. </html>