index.html 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  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="form" class="prize_form"label-position="top">
  476. <el-form-item label="姓名:">
  477. <el-radio-group v-model="radioYesNo">
  478. <el-radio :label="1">是</el-radio>
  479. <el-radio :label="0">否</el-radio>
  480. </el-radio-group>
  481. </el-form-item>
  482. <el-form-item label="已购车型:" v-if="radioYesNo === 1">
  483. <el-select v-model="carData" placeholder="请选择">
  484. <el-option
  485. v-for="item in allCarList"
  486. :key="item"
  487. :label="item"
  488. :value="item">
  489. </el-option>
  490. </el-select>
  491. </el-form-item>
  492. </el-form>
  493. <div slot="footer" class="dialog-footer">
  494. <el-button type="primary" @click="handleSaveCar">确 定</el-button>
  495. </div>
  496. </el-dialog>
  497. </div>
  498. <script>
  499. new Vue({
  500. el: '#box',
  501. data() {
  502. return {
  503. httpUrl: true,
  504. h5Type: null,
  505. qrCodeData: {
  506. qrCode: '',
  507. msg: '',
  508. },
  509. bId: null,
  510. shareTitle: '',
  511. shareDes: '',
  512. shareCover: '',
  513. prizesList: [],
  514. useNum: null,
  515. remainNum: null,
  516. activeMsg: '',
  517. lotteryRecords: [],
  518. activeName: 'tab1',
  519. showDialog: false,
  520. form: {
  521. name: '',
  522. wxAccount: '',
  523. phone: '',
  524. province: '',
  525. city: '',
  526. address: '',
  527. remark: '',
  528. recordId: null,
  529. },
  530. transformedData: [],
  531. cityData: '',
  532. showTipDialog: false,
  533. allCarList: [],
  534. radioYesNo: 1,
  535. carData: '',
  536. prizeData: {
  537. acceptType: null,
  538. name: '',
  539. img: '',
  540. money: '',
  541. id: null
  542. },
  543. showPrizeDialog: false,
  544. lotteryStatus: null,
  545. currentIndex: 0, // 当前活动的格子索引
  546. isSpinning: false,
  547. intervalId: null,
  548. showRuleDialog: false
  549. }
  550. },
  551. created() {
  552. if (this.httpUrl) {
  553. this.httpUrl = 'https://wlapi.wefanbot.com'
  554. } else {
  555. this.httpUrl = 'http://test.wefanbot.com:18993'
  556. }
  557. this.bId = this.getQueryParam('bId')
  558. this.h5Type = this.getQueryParam('h5Type')
  559. if (this.h5Type == 19) {
  560. if (this.getQueryParam('openId') || localStorage.getItem('openId')) {
  561. if (!this.getQueryParam('externalUserid')) {
  562. this.gerQwAuth(this.bId);
  563. } else {
  564. if (this.getQueryParam('externalUserid') === 'unknown') {
  565. this.gerQwCode(this.bId);
  566. } else {
  567. this.raffleInfo();
  568. this.raffleRecord()
  569. this.getCityLevel()
  570. this.getAllCar()
  571. this.getQyWxSign()
  572. }
  573. }
  574. } else {
  575. // 走授权操作
  576. this.getAuth();
  577. }
  578. } else if (this.h5Type == 20) {
  579. // 宝骏云海送祝福
  580. var currentQueryParams = window.location.search;
  581. window.location.replace('h5Type-20.html' + currentQueryParams)
  582. } else if (this.h5Type == 21) {
  583. // 活码
  584. var currentQueryParams = window.location.search;
  585. window.location.replace('live_code.html' + currentQueryParams)
  586. } else if (this.h5Type == 22) {
  587. // 红包兑换
  588. var currentQueryParams = window.location.search;
  589. window.location.replace('receiveMoney.html' + currentQueryParams)
  590. } else if (this.h5Type == 23) {
  591. // 会话列表
  592. var currentQueryParams = window.location.search;
  593. window.location.replace('sessionList.html' + currentQueryParams)
  594. } else if (this.h5Type == 24) {
  595. // SOP
  596. var currentQueryParams = window.location.search;
  597. window.location.replace('sop.html' + currentQueryParams)
  598. } else if (this.h5Type == 25) {
  599. // 客户SOP
  600. var currentQueryParams = window.location.search;
  601. window.location.replace('clientSop.html' + currentQueryParams)
  602. } else if (!this.h5Type) {
  603. this.getAuth()
  604. }
  605. },
  606. methods: {
  607. // 公众号授权,获取code
  608. getAuth () {
  609. // 获取url上的code
  610. let code = this.getQueryParam('code')
  611. if (code) {
  612. fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
  613. .then(res => {
  614. return res.json()
  615. }).then(result => {
  616. let { data, code, msg } = result
  617. if (code === 1) {
  618. this.h5Type = data.h5Type
  619. localStorage.setItem('openId', data.openId)
  620. this.gerQwAuth(this.bId);
  621. }
  622. })
  623. } else {
  624. let redirect_uri = window.location.href
  625. // code 不存在,走微信网页授权逻辑
  626. let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  627. window.location.replace(url)
  628. }
  629. },
  630. // 企微授权
  631. gerQwAuth (bId) {
  632. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  633. fetch(this.httpUrl + `/p/insuite/p/getOAUrl?openId=${openId}&bId=${bId}`)
  634. .then(res => {
  635. return res.json()
  636. }).then(result => {
  637. let { data, code, msg } = result
  638. if (code === 1) {
  639. window.location.replace(data)
  640. } else {
  641. this.$message({
  642. message: msg,
  643. type: 'warning'
  644. })
  645. }
  646. })
  647. },
  648. // 获取二维码
  649. gerQwCode (bId) {
  650. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/getUnknown?bId=${bId}`)
  651. .then(res => {
  652. return res.json()
  653. }).then(result => {
  654. let { data, code, msg } = result
  655. if (code === 1) {
  656. this.qrCodeData = data
  657. } else {
  658. this.$message({
  659. message: msg,
  660. type: 'warning'
  661. })
  662. }
  663. })
  664. },
  665. // 内容类型的分享页,获取企业微信的签名
  666. getQyWxSign () {
  667. let shareUrl = `${window.location.origin}?bId=${this.bId}&h5Type=${this.h5Type}`
  668. fetch(this.httpUrl + `/scrm/v1/ct-share/p/getSignature?url=${window.location.href}`)
  669. .then(res => {
  670. return res.json()
  671. }).then(result => {
  672. let { data, code, msg } = result
  673. if (code === 1) {
  674. wx.config({
  675. debug: false,
  676. appId: data.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
  677. timestamp: data.timestamp, // 必填,生成签名的时间戳
  678. nonceStr: data.nonceStr, // 必填,生成签名的随机串
  679. signature: data.signature, // 必填,签名,见附录1
  680. jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'] // 必填,需要使用的JS接口列表
  681. })
  682. // 分享接口仅激活的成员数超过200人且已经认证的企业才可在微信上调用。
  683. wx.ready(() => {
  684. let shareData = {
  685. link: shareUrl,
  686. title: this.shareTitle, // 分享标题
  687. desc: this.shareDes, // 分享描述
  688. imgUrl: this.shareCover,
  689. }
  690. // 分享到朋友圈
  691. wx.updateAppMessageShareData(shareData)
  692. // 分享给朋友
  693. wx.updateTimelineShareData(shareData);
  694. // 配置失败的回调函数
  695. wx.error(function(res) {
  696. // 配置失败
  697. console.log('配置失败', res);
  698. })
  699. })
  700. } else {
  701. // this.$message({
  702. // message: msg,
  703. // type: 'warning'
  704. // })
  705. }
  706. })
  707. },
  708. // 获取抽奖信息
  709. raffleInfo () {
  710. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/raffleInfoByOpenId?openId=${this.getQueryParam('openId') || localStorage.getItem('openId')}&raffleId=${this.bId}`)
  711. .then(res => {
  712. return res.json()
  713. }).then(result => {
  714. let { data, code, msg } = result
  715. if (code === 1) {
  716. this.lotteryStatus = data.status
  717. this.prizesList = data.prizes
  718. this.useNum = data.useNum
  719. this.remainNum = data.raffleNum - data.useNum
  720. this.activeMsg = data.activityInfo
  721. this.shareTitle = data.name
  722. this.shareDes = data.description
  723. this.shareCover = data.cover
  724. if (data.preForm) {
  725. this.showTipDialog = true
  726. }
  727. }
  728. })
  729. },
  730. // 抽奖记录
  731. raffleRecord () {
  732. fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/raffleRecord', {
  733. method: 'post',
  734. body: JSON.stringify({
  735. openId: this.getQueryParam('openId') || localStorage.getItem('openId'),
  736. raffleId: this.bId,
  737. page: 1,
  738. pageCount: 1000,
  739. }),
  740. headers: {
  741. 'Content-Type': 'application/json'
  742. }
  743. }).then(res => {
  744. return res.json()
  745. }).then(result => {
  746. let { data, code, msg } = result
  747. if (code === 1) {
  748. this.lotteryRecords = data.records
  749. }
  750. })
  751. },
  752. changeTab (tabName) {
  753. this.activeName = tabName
  754. },
  755. handleOpenForm (id) {
  756. this.form.recordId = id
  757. this.showDialog = true
  758. },
  759. handleSave () {
  760. if (!this.form.name) {
  761. this.$message({
  762. message: '请填写姓名',
  763. type: 'warning'
  764. })
  765. return
  766. }
  767. if (!this.form.phone) {
  768. this.$message({
  769. message: '请输入手机号',
  770. type: 'warning'
  771. })
  772. return
  773. }
  774. if (!this.form.province) {
  775. this.$message({
  776. message: '请选择城市',
  777. type: 'warning'
  778. })
  779. return
  780. }
  781. fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/raffleForm', {
  782. method: 'post',
  783. body: JSON.stringify(this.form),
  784. headers: {
  785. 'Content-Type': 'application/json'
  786. }
  787. }).then(res => {
  788. return res.json()
  789. }).then(result => {
  790. let { data, code, msg } = result
  791. if (code === 1) {
  792. this.$message({
  793. message: '提交成功!',
  794. type: 'success'
  795. })
  796. this.showDialog = false
  797. this.raffleRecord()
  798. }
  799. })
  800. },
  801. handleSaveCar () {
  802. if (this.radioYesNo && !this.carData) {
  803. this.$message({
  804. message: '请选择已购车型',
  805. type: 'warning'
  806. })
  807. return
  808. }
  809. fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/submitPreForm', {
  810. method: 'post',
  811. body: JSON.stringify({
  812. bid: this.bId,
  813. buyCar: this.radioYesNo,
  814. car: this.radioYesNo ? this.carData : '',
  815. mpOpenId: this.getQueryParam('openId') || this.localStorage.getItem('openId'),
  816. }),
  817. headers: {
  818. 'Content-Type': 'application/json'
  819. }
  820. }).then(res => {
  821. return res.json()
  822. }).then(result => {
  823. let { data, code, msg } = result
  824. if (code === 1) {
  825. this.$message({
  826. message: '提交成功!',
  827. type: 'success'
  828. })
  829. this.showTipDialog = false
  830. }
  831. })
  832. },
  833. // 获取城市数据
  834. getCityLevel () {
  835. fetch('https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/1000/1720161853377/pc-code.json')
  836. .then(res => {
  837. return res.json()
  838. }).then(result => {
  839. this.transformedData = this.transformData(result)
  840. })
  841. },
  842. // 获取全部车型
  843. getAllCar () {
  844. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/getCarList`)
  845. .then(res => {
  846. return res.json()
  847. }).then(result => {
  848. let { data, code, msg } = result
  849. if (code === 1) {
  850. this.allCarList = data
  851. }
  852. })
  853. },
  854. handleChangeCity (value) {
  855. this.form.province = value[0]
  856. this.form.city = value[1]
  857. },
  858. // 点击抽奖
  859. handleLottery () {
  860. if (!this.remainNum) {
  861. this.$message({
  862. message: '暂无抽奖次数',
  863. type: 'warning'
  864. })
  865. return
  866. }
  867. if (this.lotteryStatus === -1) {
  868. this.$message({
  869. message: '活动已结束',
  870. type: 'warning'
  871. })
  872. } else if (this.lotteryStatus === 0) {
  873. this.$message({
  874. message: '活动未开始',
  875. type: 'warning'
  876. })
  877. } else if (this.lotteryStatus === 1) {
  878. if (this.isSpinning) return
  879. this.isSpinning = true
  880. this.currentIndex = 0
  881. let externalUserid = this.getQueryParam('externalUserid')
  882. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  883. const headers = new Headers();
  884. headers.append('police', 110);
  885. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/lottery?externalUserid=${externalUserid}&openId=${openId}&raffleId=${this.bId}`, {
  886. method: 'GET',
  887. headers: headers
  888. })
  889. .then(res => {
  890. return res.json()
  891. }).then(result => {
  892. let { data, code, msg } = result
  893. if (code === 1) {
  894. this.stopLottery()
  895. this.prizeData = data
  896. this.showPrizeDialog = true
  897. this.raffleInfo();
  898. this.raffleRecord();
  899. } else {
  900. this.stopLottery()
  901. this.$message({
  902. message: msg,
  903. })
  904. }
  905. })
  906. // 开始转圈
  907. this.intervalId = setInterval(() => {
  908. this.currentIndex = (this.currentIndex + 1) % 9;
  909. }, 200); // 每 200 毫秒转一次
  910. }
  911. },
  912. // 停止抽奖
  913. stopLottery() {
  914. clearInterval(this.intervalId);
  915. this.isSpinning = false;
  916. this.currentIndex = null;
  917. },
  918. handleRule () {
  919. this.showRuleDialog = true
  920. },
  921. // 省市数据做转换
  922. transformData(data) {
  923. return data.map(item => {
  924. // 创建一个新对象,避免直接修改原始对象
  925. const newItem = { ...item };
  926. // 重命名 text 为 label
  927. if (newItem.text) {
  928. newItem.label = newItem.text;
  929. newItem.value = newItem.text;
  930. delete newItem.text;
  931. }
  932. // 如果存在 children 数组,则递归处理每个子项
  933. if (newItem.children && Array.isArray(newItem.children)) {
  934. newItem.children = this.transformData(newItem.children);
  935. }
  936. return newItem;
  937. })
  938. },
  939. // 截取url中的数据
  940. getQueryParam (paramName) {
  941. // 获取当前URL的查询字符串部分
  942. const queryString = window.location.search;
  943. // 创建一个URLSearchParams对象
  944. const urlParams = new URLSearchParams(queryString);
  945. // 返回指定参数的值,如果不存在则返回null
  946. return urlParams.get(paramName);
  947. },
  948. timeFormat (time, format = 'yyyy-MM-dd hh:mm:ss') {
  949. if (time === undefined || time === '' || time === null) {
  950. return '/'
  951. } else {
  952. const date = new Date(time)
  953. const o = {
  954. 'M+': date.getMonth() + 1,
  955. 'd+': date.getDate(),
  956. 'h+': date.getHours(),
  957. 'm+': date.getMinutes(),
  958. 's+': date.getSeconds(),
  959. 'q+': Math.floor((date.getMonth() + 3) / 3),
  960. 'S': date.getMilliseconds()
  961. }
  962. if (/(y+)/.test(format)) {
  963. format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
  964. }
  965. for (let k in o) {
  966. if (new RegExp('(' + k + ')').test(format)) {
  967. format = format.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
  968. }
  969. }
  970. return format
  971. }
  972. },
  973. }
  974. })
  975. </script>
  976. </body>
  977. </html>