index.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982
  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 || !h5Type">
  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 || !this.h5Type) {
  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. }
  591. },
  592. methods: {
  593. // 公众号授权,获取code
  594. getAuth () {
  595. // 获取url上的code
  596. let code = this.getQueryParam('code')
  597. if (code) {
  598. fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
  599. .then(res => {
  600. return res.json()
  601. }).then(result => {
  602. let { data, code, msg } = result
  603. if (code === 1) {
  604. this.h5Type = data.h5Type
  605. localStorage.setItem('openId', data.openId)
  606. this.gerQwAuth(this.bId);
  607. }
  608. })
  609. } else {
  610. let redirect_uri = window.location.href
  611. // code 不存在,走微信网页授权逻辑
  612. let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  613. window.location.replace(url)
  614. }
  615. },
  616. // 企微授权
  617. gerQwAuth (bId) {
  618. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  619. fetch(this.httpUrl + `/p/insuite/p/getOAUrl?openId=${openId}&bId=${bId}`)
  620. .then(res => {
  621. return res.json()
  622. }).then(result => {
  623. let { data, code, msg } = result
  624. if (code === 1) {
  625. window.location.replace(data)
  626. } else {
  627. this.$message({
  628. message: msg,
  629. type: 'warning'
  630. })
  631. }
  632. })
  633. },
  634. // 获取二维码
  635. gerQwCode (bId) {
  636. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/getUnknown?bId=${bId}`)
  637. .then(res => {
  638. return res.json()
  639. }).then(result => {
  640. let { data, code, msg } = result
  641. if (code === 1) {
  642. this.qrCodeData = data
  643. } else {
  644. this.$message({
  645. message: msg,
  646. type: 'warning'
  647. })
  648. }
  649. })
  650. },
  651. // 内容类型的分享页,获取企业微信的签名
  652. getQyWxSign () {
  653. let shareUrl = `${window.location.origin}?bId=${this.bId}&h5Type=${this.h5Type}`
  654. fetch(this.httpUrl + `/scrm/v1/ct-share/p/getSignature?url=${window.location.href}`)
  655. .then(res => {
  656. return res.json()
  657. }).then(result => {
  658. let { data, code, msg } = result
  659. if (code === 1) {
  660. wx.config({
  661. debug: false,
  662. appId: data.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
  663. timestamp: data.timestamp, // 必填,生成签名的时间戳
  664. nonceStr: data.nonceStr, // 必填,生成签名的随机串
  665. signature: data.signature, // 必填,签名,见附录1
  666. jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'] // 必填,需要使用的JS接口列表
  667. })
  668. // 分享接口仅激活的成员数超过200人且已经认证的企业才可在微信上调用。
  669. wx.ready(() => {
  670. let shareData = {
  671. link: shareUrl,
  672. title: this.shareTitle, // 分享标题
  673. desc: this.shareDes, // 分享描述
  674. imgUrl: this.shareCover,
  675. }
  676. // 分享到朋友圈
  677. wx.updateAppMessageShareData(shareData)
  678. // 分享给朋友
  679. wx.updateTimelineShareData(shareData);
  680. // 配置失败的回调函数
  681. wx.error(function(res) {
  682. // 配置失败
  683. console.log('配置失败', res);
  684. })
  685. })
  686. } else {
  687. // this.$message({
  688. // message: msg,
  689. // type: 'warning'
  690. // })
  691. }
  692. })
  693. },
  694. // 获取抽奖信息
  695. raffleInfo () {
  696. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/raffleInfoByOpenId?openId=${this.getQueryParam('openId') || localStorage.getItem('openId')}&raffleId=${this.bId}`)
  697. .then(res => {
  698. return res.json()
  699. }).then(result => {
  700. let { data, code, msg } = result
  701. if (code === 1) {
  702. this.lotteryStatus = data.status
  703. this.prizesList = data.prizes
  704. this.useNum = data.useNum
  705. this.remainNum = data.raffleNum - data.useNum
  706. this.activeMsg = data.activityInfo
  707. this.shareTitle = data.name
  708. this.shareDes = data.description
  709. this.shareCover = data.cover
  710. if (data.preForm) {
  711. this.showTipDialog = true
  712. }
  713. }
  714. })
  715. },
  716. // 抽奖记录
  717. raffleRecord () {
  718. fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/raffleRecord', {
  719. method: 'post',
  720. body: JSON.stringify({
  721. openId: this.getQueryParam('openId') || localStorage.getItem('openId'),
  722. raffleId: this.bId,
  723. page: 1,
  724. pageCount: 1000,
  725. }),
  726. headers: {
  727. 'Content-Type': 'application/json'
  728. }
  729. }).then(res => {
  730. return res.json()
  731. }).then(result => {
  732. let { data, code, msg } = result
  733. if (code === 1) {
  734. this.lotteryRecords = data.records
  735. }
  736. })
  737. },
  738. changeTab (tabName) {
  739. this.activeName = tabName
  740. },
  741. handleOpenForm (id) {
  742. this.form.recordId = id
  743. this.showDialog = true
  744. },
  745. handleSave () {
  746. if (!this.form.name) {
  747. this.$message({
  748. message: '请填写姓名',
  749. type: 'warning'
  750. })
  751. return
  752. }
  753. if (!this.form.phone) {
  754. this.$message({
  755. message: '请输入手机号',
  756. type: 'warning'
  757. })
  758. return
  759. }
  760. if (!this.form.province) {
  761. this.$message({
  762. message: '请选择城市',
  763. type: 'warning'
  764. })
  765. return
  766. }
  767. fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/raffleForm', {
  768. method: 'post',
  769. body: JSON.stringify(this.form),
  770. headers: {
  771. 'Content-Type': 'application/json'
  772. }
  773. }).then(res => {
  774. return res.json()
  775. }).then(result => {
  776. let { data, code, msg } = result
  777. if (code === 1) {
  778. this.$message({
  779. message: '提交成功!',
  780. type: 'success'
  781. })
  782. this.showDialog = false
  783. this.raffleRecord()
  784. }
  785. })
  786. },
  787. handleSaveCar () {
  788. if (this.radioYesNo && !this.carData) {
  789. this.$message({
  790. message: '请选择已购车型',
  791. type: 'warning'
  792. })
  793. return
  794. }
  795. fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/submitPreForm', {
  796. method: 'post',
  797. body: JSON.stringify({
  798. bid: this.bId,
  799. buyCar: this.radioYesNo,
  800. car: this.radioYesNo ? this.carData : '',
  801. mpOpenId: this.getQueryParam('openId') || this.localStorage.getItem('openId'),
  802. }),
  803. headers: {
  804. 'Content-Type': 'application/json'
  805. }
  806. }).then(res => {
  807. return res.json()
  808. }).then(result => {
  809. let { data, code, msg } = result
  810. if (code === 1) {
  811. this.$message({
  812. message: '提交成功!',
  813. type: 'success'
  814. })
  815. this.showTipDialog = false
  816. }
  817. })
  818. },
  819. // 获取城市数据
  820. getCityLevel () {
  821. fetch('https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/1000/1720161853377/pc-code.json')
  822. .then(res => {
  823. return res.json()
  824. }).then(result => {
  825. this.transformedData = this.transformData(result)
  826. })
  827. },
  828. // 获取全部车型
  829. getAllCar () {
  830. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/getCarList`)
  831. .then(res => {
  832. return res.json()
  833. }).then(result => {
  834. let { data, code, msg } = result
  835. if (code === 1) {
  836. this.allCarList = data
  837. }
  838. })
  839. },
  840. handleChangeCity (value) {
  841. this.form.province = value[0]
  842. this.form.city = value[1]
  843. },
  844. // 点击抽奖
  845. handleLottery () {
  846. if (!this.remainNum) {
  847. this.$message({
  848. message: '暂无抽奖次数',
  849. type: 'warning'
  850. })
  851. return
  852. }
  853. if (this.lotteryStatus === -1) {
  854. this.$message({
  855. message: '活动已结束',
  856. type: 'warning'
  857. })
  858. } else if (this.lotteryStatus === 0) {
  859. this.$message({
  860. message: '活动未开始',
  861. type: 'warning'
  862. })
  863. } else if (this.lotteryStatus === 1) {
  864. if (this.isSpinning) return
  865. this.isSpinning = true
  866. this.currentIndex = 0
  867. let externalUserid = this.getQueryParam('externalUserid')
  868. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  869. fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/lottery?externalUserid=${externalUserid}&openId=${openId}&raffleId=${this.bId}`)
  870. .then(res => {
  871. return res.json()
  872. }).then(result => {
  873. let { data, code, msg } = result
  874. if (code === 1) {
  875. this.stopLottery()
  876. this.prizeData = data
  877. this.showPrizeDialog = true
  878. this.raffleInfo();
  879. this.raffleRecord();
  880. } else {
  881. this.stopLottery()
  882. this.$message({
  883. message: msg,
  884. })
  885. }
  886. })
  887. // 开始转圈
  888. this.intervalId = setInterval(() => {
  889. this.currentIndex = (this.currentIndex + 1) % 9;
  890. }, 200); // 每 200 毫秒转一次
  891. }
  892. },
  893. // 停止抽奖
  894. stopLottery() {
  895. clearInterval(this.intervalId);
  896. this.isSpinning = false;
  897. this.currentIndex = null;
  898. },
  899. handleRule () {
  900. this.showRuleDialog = true
  901. },
  902. // 省市数据做转换
  903. transformData(data) {
  904. return data.map(item => {
  905. // 创建一个新对象,避免直接修改原始对象
  906. const newItem = { ...item };
  907. // 重命名 text 为 label
  908. if (newItem.text) {
  909. newItem.label = newItem.text;
  910. newItem.value = newItem.text;
  911. delete newItem.text;
  912. }
  913. // 如果存在 children 数组,则递归处理每个子项
  914. if (newItem.children && Array.isArray(newItem.children)) {
  915. newItem.children = this.transformData(newItem.children);
  916. }
  917. return newItem;
  918. })
  919. },
  920. // 截取url中的数据
  921. getQueryParam (paramName) {
  922. // 获取当前URL的查询字符串部分
  923. const queryString = window.location.search;
  924. // 创建一个URLSearchParams对象
  925. const urlParams = new URLSearchParams(queryString);
  926. // 返回指定参数的值,如果不存在则返回null
  927. return urlParams.get(paramName);
  928. },
  929. timeFormat (time, format = 'yyyy-MM-dd hh:mm:ss') {
  930. if (time === undefined || time === '' || time === null) {
  931. return '/'
  932. } else {
  933. const date = new Date(time)
  934. const o = {
  935. 'M+': date.getMonth() + 1,
  936. 'd+': date.getDate(),
  937. 'h+': date.getHours(),
  938. 'm+': date.getMinutes(),
  939. 's+': date.getSeconds(),
  940. 'q+': Math.floor((date.getMonth() + 3) / 3),
  941. 'S': date.getMilliseconds()
  942. }
  943. if (/(y+)/.test(format)) {
  944. format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
  945. }
  946. for (let k in o) {
  947. if (new RegExp('(' + k + ')').test(format)) {
  948. format = format.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
  949. }
  950. }
  951. return format
  952. }
  953. },
  954. }
  955. })
  956. </script>
  957. </body>
  958. </html>