registrationActivity.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <!--引入 element-ui 的样式,-->
  8. <link rel="stylesheet"
  9. href="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742018383195/element-ui.css">
  10. <!-- 必须先引入vue, 后使用element-ui -->
  11. <script
  12. src="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742017957144/vue.js"></script>
  13. <!-- 引入element 的组件库-->
  14. <script
  15. src="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742017747738/element-ui.js"></script>
  16. <!-- <script src="js/vconsole.min.js"></script>
  17. <script>
  18. var vConsole = new window.VConsole();
  19. </script> -->
  20. </head>
  21. <style>
  22. body {
  23. margin: 0;
  24. padding: 0;
  25. }
  26. .box {
  27. width: 100vw;
  28. height: 100%;
  29. box-sizing: border-box;
  30. background: #FAFAFA;
  31. }
  32. .page6 {
  33. width: 100vw;
  34. height: 100%;
  35. background-size: 100vw 300px;
  36. background-repeat: no-repeat;
  37. position: relative;
  38. overflow-y: auto;
  39. }
  40. .enrollment {
  41. width: 100%;
  42. height: 25px;
  43. background: #C30011;
  44. opacity: 0.8;
  45. font-weight: 400;
  46. font-size: 12px;
  47. color: #FFFFFF;
  48. line-height: 25px;
  49. text-align: center;
  50. position: fixed;
  51. top: 0;
  52. left: 0;
  53. }
  54. .activity_content {
  55. width: 100%;
  56. margin-top: 250px;
  57. background: #FFFFFF;
  58. border-radius: 20px 20px 0px 0px;
  59. padding: 30px 20px 66px;
  60. box-sizing: border-box;
  61. }
  62. .activity_item {
  63. display: flex;
  64. align-items: flex-start;
  65. margin-bottom: 30px;
  66. }
  67. .item_title {
  68. font-weight: 500;
  69. font-size: 14px;
  70. color: #222222;
  71. min-width: 100px;
  72. }
  73. .item_content {
  74. font-weight: 400;
  75. font-size: 14px;
  76. color: #222222;
  77. }
  78. .item_content p {
  79. margin: 0;
  80. }
  81. .foot_btn {
  82. position: fixed;
  83. bottom: 14px;
  84. padding: 0 35px;
  85. width: 100%;
  86. box-sizing: border-box;
  87. }
  88. .signUp_btn {
  89. height: 52px;
  90. width: 100%;
  91. background: #1677FF;
  92. border-radius: 20px;
  93. font-weight: 500;
  94. font-size: 16px;
  95. color: #FFFFFF;
  96. text-align: center;
  97. padding: 0;
  98. line-height: 22px;
  99. }
  100. .signUp_btn_tip {
  101. font-weight: bold;
  102. font-size: 12px;
  103. line-height: 17px;
  104. }
  105. .form_content {
  106. width: 100%;
  107. margin-top: 250px;
  108. background: #FFFFFF;
  109. border-radius: 20px 20px 0px 0px;
  110. padding: 20px 20px 66px;
  111. box-sizing: border-box;
  112. }
  113. .form_title {
  114. font-weight: 500;
  115. font-size: 16px;
  116. color: #222222;
  117. text-align: center;
  118. line-height: 24px;
  119. }
  120. .form_title_tip {
  121. font-weight: bold;
  122. font-size: 12px;
  123. color: #FF4E4E;
  124. text-align: center;
  125. line-height: 17px;
  126. }
  127. .el-form-item__label {
  128. padding-right: 0;
  129. font-weight: 500;
  130. font-size: 14px;
  131. color: #666666;
  132. }
  133. .el-input__inner {
  134. border: none;
  135. font-weight: 500;
  136. font-size: 14px;
  137. color: #222222;
  138. text-align: right;
  139. }
  140. .el-input--prefix .el-input__inner {
  141. padding-left: 0;
  142. padding-right: 0;
  143. }
  144. .el-form-item {
  145. margin-bottom: 0;
  146. border-bottom: 1px solid #F9F9F9;
  147. padding: 10px 0;
  148. }
  149. .el-textarea__inner {
  150. border: none;
  151. font-weight: 500;
  152. font-size: 14px;
  153. color: #222222;
  154. text-align: right;
  155. }
  156. .el-form-item__content .el-select {
  157. margin-left: 55px;
  158. }
  159. .el-form-item__content .el-cascader {
  160. margin-left: 55px;
  161. }
  162. .el-select-dropdown__item {
  163. white-space: normal;
  164. overflow: unset;
  165. height: auto;
  166. }
  167. .signup_page {
  168. width: 100vw;
  169. min-height: 100vh;
  170. background: url('./img/sign_up.png') no-repeat center;
  171. /* background-size: 100vw 100%; */
  172. background-size: cover;
  173. }
  174. .signupSucc_page {
  175. width: 100vw;
  176. height: 100vh;
  177. background: url('./img/signup_success.png') no-repeat center;
  178. background-size: 100vw 100vh;
  179. background-repeat: no-repeat;
  180. }
  181. .succ_tip {
  182. padding-top: 240px;
  183. font-weight: bold;
  184. font-size: 24px;
  185. color: #222222;
  186. line-height: 40px;
  187. text-align: center;
  188. width: 100%;
  189. word-break: keep-all;
  190. }
  191. .signup_title {
  192. padding-top: 80px;
  193. }
  194. .form_guide {
  195. font-weight: bold;
  196. font-size: 24px;
  197. color: #FFFFFF;
  198. line-height: 41px;
  199. text-align: center;
  200. white-space: pre-line;
  201. }
  202. .signup_box {
  203. margin: 30px 20px 0;
  204. height: auto;
  205. background: linear-gradient(#D5E6FF 50%, #FFFFFF 100%);
  206. border-radius: 20px;
  207. box-sizing: border-box;
  208. border: 1px solid #FFFFFF;
  209. }
  210. .signup_tip {
  211. font-weight: 400;
  212. font-size: 16px;
  213. color: #222222;
  214. padding: 40px 31px 10px 32px;
  215. text-align: center;
  216. line-height: 27px;
  217. white-space: pre-line;
  218. box-sizing: border-box;
  219. }
  220. .store_msg {
  221. display: flex;
  222. align-items: center;
  223. justify-content: center;
  224. font-weight: 400;
  225. font-size: 12px;
  226. color: #1677FF;
  227. margin-bottom: 15px;
  228. padding-left: 30px;
  229. padding-right: 36px;
  230. }
  231. .store_icon {
  232. width: 24px;
  233. height: 24px;
  234. margin-right: 5px;
  235. }
  236. .signup_code_box {
  237. padding: 0 20px;
  238. box-sizing: border-box;
  239. }
  240. .signup_code {
  241. font-weight: 500;
  242. font-size: 26px;
  243. color: #222222;
  244. padding: 15px 0;
  245. background: #D3E0F5;
  246. border-radius: 20px;
  247. text-align: center;
  248. }
  249. .copy_text {
  250. display: flex;
  251. align-items: center;
  252. justify-content: center;
  253. padding-top: 10px;
  254. font-weight: 400;
  255. font-size: 12px;
  256. color: #9FB3C7;
  257. }
  258. .copy_icon {
  259. width: 11px;
  260. height: 11px;
  261. margin-right: 3px;
  262. }
  263. .attention {
  264. font-weight: 400;
  265. font-size: 12px;
  266. color: #999999;
  267. line-height: 24px;
  268. text-align: start;
  269. padding-top: 20px;
  270. padding-left: 20px;
  271. padding-bottom: 20px;
  272. }
  273. .qrcode_info {
  274. display: flex;
  275. align-items: center;
  276. padding: 20px 0 20px 35px;
  277. border-top: 1px dashed #AEBFCE;
  278. font-weight: 400;
  279. font-size: 14px;
  280. color: #222222;
  281. }
  282. .qrcode_info2 {
  283. display: flex;
  284. align-items: center;
  285. flex-direction: column;
  286. padding: 20px 35px;
  287. font-weight: 400;
  288. font-size: 14px;
  289. color: #222222;
  290. }
  291. .bm_qrcode {
  292. width: 70px;
  293. height: 70px;
  294. margin-right: 25px;
  295. }
  296. .bm_qrcode2 {
  297. width: 120px;
  298. height: 120px;
  299. margin-bottom: 25px;
  300. }
  301. .bm_title {
  302. padding-bottom: 10px;
  303. white-space: pre-line;
  304. box-sizing: border-box;
  305. text-align: center;
  306. }
  307. .fail_box {
  308. margin: 80px 20px 0;
  309. height: 287px;
  310. background: linear-gradient(#D5E6FF 50%, #FFFFFF 100%);
  311. border-radius: 20px;
  312. box-sizing: border-box;
  313. text-align: center;
  314. }
  315. .fail_img {
  316. width: 246px;
  317. height: 144px;
  318. margin-top: -20px;
  319. }
  320. .fail_title {
  321. font-weight: 500;
  322. font-size: 20px;
  323. color: #222222;
  324. line-height: 30px;
  325. padding: 20px 0;
  326. }
  327. .fail_tip {
  328. font-weight: 400;
  329. font-size: 16px;
  330. color: #666666;
  331. line-height: 30px;
  332. }
  333. </style>
  334. <body>
  335. <div id="box" class="box">
  336. <div class="signup_page" v-if="step === 3">
  337. <div class="signup_title">
  338. <div class="form_guide">{{toshopData.formGuide1}}</div>
  339. </div>
  340. <div class="signup_box" v-if="toshopData.formGuide2 || toshopData.verificationShowSwitch || toshopData.sucImgShowSwitch">
  341. <div class="signup_tip">{{toshopData.formGuide2}}</div>
  342. <div v-if="toshopData.verificationShowSwitch">
  343. <div class="store_msg">
  344. <img class="store_icon" src="./img/store.png" />
  345. <span>{{storeName}}</span>
  346. </div>
  347. <div class="signup_code_box">
  348. <div class="signup_code">{{verificationCode}}</div>
  349. </div>
  350. <div class="copy_text" @click="handleCopy(verificationCode)">
  351. <img class="copy_icon" src="./img/copy_icon.png" />
  352. <span>点击复制核销码</span>
  353. </div>
  354. <div class="attention">
  355. <div>注意:</div>
  356. <div>1.凭证码仅可核销一次,请注意保管</div>
  357. <div>2.不记名,不挂失</div>
  358. </div>
  359. </div>
  360. <div v-if="toshopData.sucImgShowSwitch">
  361. <div class="qrcode_info" v-if="toshopData.verificationShowSwitch">
  362. <img class="bm_qrcode" :src="toshopData.sucImg" />
  363. <div>
  364. <div class="bm_title">{{toshopData.sucImgGuide}}</div>
  365. </div>
  366. </div>
  367. <div class="qrcode_info2" v-else>
  368. <img class="bm_qrcode2" :src="toshopData.sucImg" />
  369. <div class="bm_title">{{toshopData.sucImgGuide}}</div>
  370. </div>
  371. </div>
  372. </div>
  373. </div>
  374. <div class="signupSucc_page" v-else-if="step === 4">
  375. <div class="succ_tip">
  376. {{toshopData.verificationGuide}}
  377. </div>
  378. </div>
  379. <div class="signup_page" v-else-if="step === 5">
  380. <div class="signup_title">
  381. <div class="form_guide">{{toshopData.name}}</div>
  382. </div>
  383. <div class="fail_box">
  384. <img class="fail_img" src="./img/fail_img.png" />
  385. <div class="fail_title">{{toshopData.verificationFailGuide}}</div>
  386. <div class="fail_tip">{{toshopData.verificationFailGuide2}}</div>
  387. </div>
  388. </div>
  389. <div class="page6" :style="{'background-image': 'url('+toshopData.banner+')'}" v-else-if="step === 1 || step === 2">
  390. <div class="enrollment">已有23333人参与活动</div>
  391. <!-- <div class="activity_content" v-if="step === 1">
  392. <div class="activity_item">
  393. <div class="item_title">活动主题:</div>
  394. <div class="item_content">{{toshopData.name}}</div>
  395. </div>
  396. <div class="activity_item">
  397. <div class="item_title">活动对象:</div>
  398. <div class="item_content">{{toshopData.target}}</div>
  399. </div>
  400. <div class="activity_item">
  401. <div class="item_title">活动时间:</div>
  402. <div class="item_content">{{toshopData.startTime.slice(0, 10) + '~' + toshopData.endTime.slice(0, 10)}}</div>
  403. </div>
  404. <div class="activity_item">
  405. <div class="item_title">活动规则:</div>
  406. <div class="item_content" v-html="toshopData.activityInfo"></div>
  407. </div>
  408. </div> -->
  409. <div class="form_content" v-if="step === 2">
  410. <div class="form_title">报名表单</div>
  411. <div class="form_title_tip" v-if="
  412. Number(toshopData.id) !== 116262865210171
  413. && Number(toshopData.id) !== 116568649610001
  414. && Number(toshopData.id) !== 116816531710011
  415. && Number(toshopData.id) !== 117422198310041
  416. && Number(toshopData.id) !== 117472990410101
  417. && Number(toshopData.id) !== 117536128510031">【 报名成功还能抽华为手机! 】</div>
  418. <el-form ref="form" label-position="left" label-width="120px">
  419. <el-form-item v-for="(item, index) in toshopData.formProList" :key="index" :label="item.name"
  420. :required="Boolean(item.isNeed)">
  421. <el-cascader v-if="item.type === 10" v-model="item.value" :options="transformedData"
  422. @change="handleInfoCity">
  423. </el-cascader>
  424. <el-select v-if="item.type === 11" v-model="item.value" placeholder="请选择" @change="handlechange">
  425. <el-option v-for="(sto, sindex) in storeList" :key="sindex" :label="sto.name" :value="sto.name">
  426. </el-option>
  427. </el-select>
  428. <el-input v-if="item.type === 0" v-model="item.value" placeholder="请输入"></el-input>
  429. <el-input v-if="item.type === 1" type="textarea" autosize v-model="item.value" placeholder="请输入"></el-input>
  430. <el-input v-if="item.type === 2" type="number" v-model="item.value" placeholder="请输入"></el-input>
  431. <el-select v-if="item.type === 3" v-model="item.value" placeholder="请选择">
  432. <el-option v-for="sto in item.formProTagReqs" :key="sto.proValue" :label="sto.proValue"
  433. :value="sto.proValue">
  434. </el-option>
  435. </el-select>
  436. <el-col :span="22" v-if="item.type === 5">
  437. <el-date-picker v-model="item.value" type="date" placeholder="选择日期" style="width: 100%;">
  438. </el-col>
  439. <el-col :span="22" v-if="item.type === 6">
  440. <el-time-picker v-model="item.value" placeholder="请选择"></el-time-picker>
  441. </el-col>
  442. <el-col :span="22" v-if="item.type === 7">
  443. <el-date-picker v-if="item.type === 7" v-model="item.value" type="datetime"
  444. placeholder="选择日期时间"></el-date-picker>
  445. </el-col>
  446. </el-form-item>
  447. </el-form>
  448. </div>
  449. <div class="foot_btn">
  450. <el-button class="signUp_btn" :loading="loading" @click="toSignUp" v-if="step === 1">
  451. <div>去报名</div>
  452. <div class="signUp_btn_tip" v-if="
  453. Number(toshopData.id) !== 116262865210171
  454. && Number(toshopData.id) !== 116568649610001
  455. && Number(toshopData.id) !== 116816531710011
  456. && Number(toshopData.id) !== 117422198310041
  457. && Number(toshopData.id) !== 117472990410101
  458. && Number(toshopData.id) !== 117536128510031">【 报名成功还能抽华为手机 】</div>
  459. </el-button>
  460. <el-button class="signUp_btn" :loading="loading" @click="toSignUp" v-else>确定</el-button>
  461. </div>
  462. </div>
  463. </div>
  464. </body>
  465. <script>
  466. new Vue({
  467. el: '#box',
  468. data () {
  469. return {
  470. httpUrl: '',
  471. bId: null,
  472. env: '',
  473. toshopData: {
  474. id: null,
  475. banner: '',
  476. name: '',
  477. target: '',
  478. startTime: '',
  479. endTime: '',
  480. activityInfo: '',
  481. formProList: [],
  482. verificationGuide: '',
  483. formGuide1: '',
  484. formGuide2: '',
  485. verificationFailGuide: '',
  486. verificationFailGuide2: '',
  487. browseId: null,
  488. verificationShowSwitch: 0,
  489. sucImgShowSwitch: 0,
  490. sucImg: '',
  491. sucImgGuide: '',
  492. },
  493. step: 2,
  494. verificationCode: '',
  495. storeName: '',
  496. transformedData: [],
  497. storeList: [],
  498. province: '',
  499. city: '',
  500. loading: false,
  501. intervalId: null, // 定时任务的ID
  502. loadTime: null, // 页面加载的时间戳
  503. }
  504. },
  505. created () {
  506. var hrt = document.documentElement.clientHeight; //获取当前可视区域的高度存到hrt变量
  507. document.getElementById('box').style.height = hrt + 'px'//把获取到的高度赋值给根div
  508. this.bId = this.getQueryParam('bId')
  509. this.env = this.getQueryParam('env')
  510. if (!this.env || this.env === 'prod') {
  511. this.httpUrl = 'https://wlapi.wefanbot.com'
  512. } else {
  513. this.httpUrl = 'https://test.wefanbot.com:28993'
  514. // this.httpUrl = 'http://192.168.1.147:18993'
  515. }
  516. localStorage.removeItem('openId')
  517. if (this.isWeChatBrowser()) {
  518. // 微信浏览器
  519. this.ifH5Type()
  520. } else {
  521. // 不是微信浏览器
  522. this.lightenShare()
  523. }
  524. },
  525. beforeDestroy() {
  526. this.clearIntervalTask() // 在组件销毁前清除定时任务
  527. },
  528. methods: {
  529. ifH5Type () {
  530. if (this.getQueryParam('openId') || localStorage.getItem('openId')) {
  531. if (!this.getQueryParam('externalUserid')) {
  532. this.gerQwAuth(this.bId);
  533. } else {
  534. this.lightenShare()
  535. }
  536. } else {
  537. // 走授权操作
  538. this.getAuth();
  539. }
  540. },
  541. getAuth () {
  542. // 获取url上的code
  543. let code = this.getQueryParam('code')
  544. if (code) {
  545. // 判断业务id是否生产环境业务id
  546. fetch(this.httpUrl + `/p/insuite/p/isProdId?id=${this.bId}`)
  547. .then(res => {
  548. return res.json()
  549. }).then(result => {
  550. let { data, msg } = result
  551. if (typeof data === 'boolean' && data) {
  552. this.httpUrl = 'https://wlapi.wefanbot.com'
  553. } else {
  554. this.httpUrl = 'http://test.wefanbot.com:18993'
  555. }
  556. this.getInfoByh5Code(this.getQueryParam('code'))
  557. })
  558. } else {
  559. let redirect_uri = window.location.href
  560. // code 不存在,走微信网页授权逻辑
  561. let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  562. window.location.replace(url)
  563. }
  564. },
  565. getInfoByh5Code (code) {
  566. fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
  567. .then(res => {
  568. return res.json()
  569. }).then(result => {
  570. let { data, code, msg } = result
  571. if (code === 1) {
  572. localStorage.setItem('openId', data.openId)
  573. this.ifH5Type()
  574. }
  575. })
  576. },
  577. // 企微授权
  578. gerQwAuth (bId) {
  579. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  580. fetch(this.httpUrl + `/p/insuite/p/getOAUrl?openId=${openId}&bId=${bId}`)
  581. .then(res => {
  582. return res.json()
  583. }).then(result => {
  584. let { data, code, msg } = result
  585. if (code === 1) {
  586. window.location.replace(data)
  587. } else {
  588. this.$message({
  589. message: msg,
  590. type: 'warning'
  591. })
  592. }
  593. })
  594. },
  595. // 获取城市数据
  596. getCityLevel () {
  597. let url = ''
  598. if (this.toshopData.id == 115399319210021) {
  599. url = 'https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1744104152989/five-province.json'
  600. } else {
  601. url = 'https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742009720857/four-province.json'
  602. }
  603. fetch(url)
  604. .then(res => {
  605. return res.json()
  606. }).then(result => {
  607. this.transformedData = this.transformData(result)
  608. })
  609. },
  610. // 省市数据做转换
  611. transformData (data) {
  612. return data.map(item => {
  613. // 创建一个新对象,避免直接修改原始对象
  614. const newItem = { ...item };
  615. // 重命名 text 为 label
  616. if (newItem.text) {
  617. newItem.label = newItem.text;
  618. newItem.value = newItem.text;
  619. delete newItem.text;
  620. }
  621. // 如果存在 children 数组,则递归处理每个子项
  622. if (newItem.children && Array.isArray(newItem.children)) {
  623. newItem.children = this.transformData(newItem.children);
  624. }
  625. return newItem;
  626. })
  627. },
  628. handleInfoCity (value) {
  629. this.province = value[0]
  630. this.city = value[1]
  631. // 清空经销商类型的数据
  632. this.toshopData.formProList.forEach(item => {
  633. if (item.type === 11) {
  634. item.value = ''
  635. }
  636. })
  637. this.storeList = []
  638. this.getStoreList()
  639. },
  640. handlechange (value) {
  641. this.toshopData.formProList.forEach(item => {
  642. if (item.type === 11) {
  643. item.value = value
  644. }
  645. })
  646. this.$forceUpdate()
  647. },
  648. getStoreList () {
  649. fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-store/p/findListByPage?city=${this.city}&province=${this.province}`, {
  650. method: 'post',
  651. body: JSON.stringify({
  652. page: 1,
  653. pageCount: 10000,
  654. }),
  655. headers: {
  656. 'Content-Type': 'application/json'
  657. }
  658. }).then(res => {
  659. return res.json()
  660. }).then(result => {
  661. let { data, code, msg } = result
  662. if (code === 1) {
  663. this.storeList = data.records
  664. } else {
  665. this.$message({
  666. message: msg,
  667. type: 'warning'
  668. })
  669. }
  670. })
  671. },
  672. lightenShare () {
  673. let externalUserid = this.getQueryParam('externalUserid') || ''
  674. let openId = this.getQueryParam('openId') || localStorage.getItem('openId') || ''
  675. const headers = new Headers();
  676. headers.append('police', 110);
  677. fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-share/p/lottery?clientId=${localStorage.getItem('bkClientId') || ''}&externalUserid=${externalUserid}&openId=${openId}&bId=${this.bId}`, {
  678. method: 'GET',
  679. headers: headers
  680. })
  681. .then(res => {
  682. return res.json()
  683. }).then(result => {
  684. let { data, code, msg } = result
  685. if (code === 1) {
  686. this.toshopData = data
  687. if (!this.isWeChatBrowser()) {
  688. localStorage.setItem('bkClientId', data.client.id)
  689. }
  690. this.getCityLevel()
  691. if (data.client.state === 1) {
  692. // 未提交表单
  693. this.step = 2
  694. } else if (data.client.state === 2) {
  695. // 已提交表单
  696. this.verificationCode = data.client.verificationCode
  697. if (data.client.formData) {
  698. let arr = JSON.parse(data.client.formData)
  699. const filteredItems = arr.filter(item => item.name.includes("门店"))
  700. if (filteredItems.length) {
  701. const names = filteredItems.map(item => item.value[0])
  702. this.storeName = names[0]
  703. }
  704. }
  705. this.step = 3
  706. } else if (data.client.state === 3) {
  707. // 已核销
  708. this.step = 4
  709. } else if (data.client.state === -1) {
  710. // 不符合资格
  711. this.step = 5
  712. }
  713. this.loadTime = Date.now() // 记录页面加载时间
  714. this.startInterval() // 启动定时任务
  715. } else {
  716. this.$message({
  717. message: msg,
  718. })
  719. }
  720. })
  721. },
  722. startInterval() {
  723. if (this.intervalId !== null) {
  724. clearInterval(this.intervalId); // 如果定时任务已经存在,先清除它
  725. }
  726. this.intervalId = setInterval(() => {
  727. const elapsedTime = Math.floor((Date.now() - this.loadTime) / 1000); // 计算停留时长(秒)
  728. this.sendDataToServer(this.toshopData.browseId, elapsedTime);
  729. }, 10000); // 每10秒调用一次
  730. },
  731. sendDataToServer(browseId, elapsedTime) {
  732. let openId = this.getQueryParam('openId') || localStorage.getItem('openId') || ''
  733. fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-client-browse-history/p/updateBrowseDuration?openId=${openId}`, {
  734. method: 'post',
  735. body: JSON.stringify({
  736. id: browseId,
  737. duration: elapsedTime,
  738. }),
  739. headers: {
  740. 'Content-Type': 'application/json'
  741. }
  742. }).then(res => {
  743. return res.json()
  744. }).then(result => {
  745. let { data, code, msg } = result
  746. if (data) {
  747. } else {
  748. }
  749. })
  750. },
  751. clearIntervalTask() {
  752. if (this.intervalId !== null) {
  753. clearInterval(this.intervalId)
  754. this.intervalId = null // 清空定时任务的ID
  755. }
  756. },
  757. toSignUp () {
  758. if (this.step === 1) {
  759. this.step = 2
  760. } else {
  761. if (!this.toshopData.formProList || !this.toshopData.formProList.length) {
  762. this.$message({
  763. message: '请完善表单信息',
  764. type: 'warning'
  765. })
  766. return false
  767. }
  768. const isValid = this.toshopData.formProList.some(item => {
  769. if (item.isNeed && !item.value) {
  770. this.$message({
  771. message: '必填项不能为空',
  772. type: 'warning'
  773. })
  774. return true
  775. }
  776. if (this.containsAllChineseCharacters(item.name, '手机') && item.value.length !== 11) {
  777. this.$message({
  778. message: '请输入正确的手机号',
  779. type: 'warning'
  780. })
  781. return true
  782. }
  783. return false
  784. })
  785. if (isValid) return
  786. let cols = []
  787. cols = this.toshopData.formProList.map(item => {
  788. return {
  789. name: item.name,
  790. type: item.type,
  791. value: item.type === 10 ? [JSON.stringify({
  792. province: item.value[0],
  793. city: item.value[1]
  794. })] : [item.value],
  795. }
  796. })
  797. let openId = this.getQueryParam('openId') || localStorage.getItem('openId') || ''
  798. this.loading = true
  799. fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-share/p/formData?clientId=${localStorage.getItem('bkClientId') || ''}&openId=${openId}`, {
  800. method: 'post',
  801. body: JSON.stringify({
  802. bid: this.bId,
  803. cols: cols,
  804. }),
  805. headers: {
  806. 'Content-Type': 'application/json'
  807. }
  808. }).then(res => {
  809. return res.json()
  810. }).then(result => {
  811. let { data, code, msg } = result
  812. if (data) {
  813. this.verificationCode = data.client.verificationCode
  814. if (data.client.state === 2) {
  815. // 已提交表单
  816. this.step = 3
  817. if (data.client.formData) {
  818. let arr = JSON.parse(data.client.formData)
  819. const filteredItems = arr.filter(item => item.name.includes("门店"))
  820. if (filteredItems.length) {
  821. const names = filteredItems.map(item => item.value[0])
  822. this.storeName = names[0]
  823. }
  824. }
  825. } else if (data.client.state === 3) {
  826. // 已核销
  827. this.step = 4
  828. } else if (data.client.state === -1) {
  829. // 不符合资格
  830. this.step = 5
  831. }
  832. } else {
  833. this.$message({
  834. message: msg,
  835. type: 'warning'
  836. })
  837. }
  838. }).finally(() => {
  839. this.loading = false
  840. })
  841. }
  842. },
  843. // 检查字符串中是否包含所有指定的中文字符
  844. containsAllChineseCharacters (str, chineseChars) {
  845. // 将要检查的字符拆分为数组
  846. const charsArray = chineseChars.split('')
  847. // 遍历每个字符并检查是否存在
  848. for (const char of charsArray) {
  849. if (!str.includes(char)) {
  850. return false
  851. }
  852. }
  853. return true
  854. },
  855. // 检测是否iOS端
  856. iosAgent () {
  857. return navigator.userAgent.match(/(iPhone|iPod|iPad);?/i);
  858. },
  859. // 复制文本函数,微信端,需要在用户触发 Click 事件里面才能执行成功
  860. handleCopy (message) {
  861. if (this.iosAgent()) {
  862. let inputObj = document.createElement("input");
  863. inputObj.value = message;
  864. document.body.appendChild(inputObj);
  865. inputObj.select();
  866. inputObj.setSelectionRange(0, inputObj.value.length);
  867. this.execCommand('Copy');
  868. document.body.removeChild(inputObj);
  869. } else {
  870. let domObj = document.createElement("span");
  871. domObj.innerHTML = message;
  872. document.body.appendChild(domObj);
  873. let selection = window.getSelection();
  874. let range = document.createRange();
  875. range.selectNodeContents(domObj);
  876. selection.removeAllRanges();
  877. selection.addRange(range);
  878. this.execCommand('Copy');
  879. document.body.removeChild(domObj);
  880. }
  881. },
  882. // 执行浏览器命令 Copy 顺便输出一下日志,如果在移动端推荐写个方法展示日志或者用alert(msg)也行。
  883. execCommand (action) {
  884. let is = document.execCommand(action);
  885. if (is) {
  886. this.$message({
  887. message: '复制成功',
  888. type: 'success'
  889. })
  890. } else {
  891. this.$message({
  892. message: '复制失败',
  893. type: 'error'
  894. })
  895. }
  896. },
  897. // 截取url中的数据
  898. getQueryParam (paramName) {
  899. // 获取当前URL的查询字符串部分
  900. const queryString = window.location.search;
  901. // 创建一个URLSearchParams对象
  902. const urlParams = new URLSearchParams(queryString);
  903. // 返回指定参数的值,如果不存在则返回null
  904. return urlParams.get(paramName);
  905. },
  906. // 判断当前是否为微信浏览器
  907. isWeChatBrowser() {
  908. const ua = navigator.userAgent.toLowerCase();
  909. return ua.includes('micromessenger');
  910. },
  911. }
  912. })
  913. </script>
  914. </html>