signUp.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  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.0, maximum-scale=1.0, user-scalable=no">
  7. <title>活动</title>
  8. <!--引入 element-ui 的样式,-->
  9. <link rel="stylesheet"
  10. href="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742018383195/element-ui.css">
  11. <!-- 必须先引入vue, 后使用element-ui -->
  12. <script
  13. src="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742017957144/vue.js"></script>
  14. <!-- 引入element 的组件库-->
  15. <script
  16. src="https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742017747738/element-ui.js"></script>
  17. <!-- <script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
  18. <script>
  19. var vConsole = new window.VConsole();
  20. </script> -->
  21. </head>
  22. <style>
  23. body {
  24. margin: 0;
  25. padding: 0;
  26. }
  27. .box {
  28. width: 100vw;
  29. height: 100vh;
  30. box-sizing: border-box;
  31. background: #FAFAFA;
  32. }
  33. .page6 {
  34. width: 100vw;
  35. height: 100vh;
  36. background: url('./img/signup_bg.png') no-repeat top;
  37. background-size: 100vw 210px;
  38. background-repeat: no-repeat;
  39. display: flex;
  40. justify-content: center;
  41. align-items: center;
  42. }
  43. .page_title {
  44. font-weight: 800;
  45. font-size: 40px;
  46. color: #FFFFFF;
  47. position: fixed;
  48. top: 40px;
  49. left: 20px;
  50. }
  51. .form_content {
  52. width: 100%;
  53. height: calc(100vh - 180px);
  54. margin-top: 180px;
  55. background: #FFFFFF;
  56. border-radius: 20px 20px 0px 0px;
  57. padding: 20px 20px 66px;
  58. overflow-y: auto;
  59. box-sizing: border-box;
  60. }
  61. .foot_btn {
  62. position: fixed;
  63. bottom: 14px;
  64. padding: 0 35px;
  65. width: 100%;
  66. box-sizing: border-box;
  67. }
  68. .signUp_btn {
  69. height: 52px;
  70. width: 100%;
  71. background: #1677FF;
  72. border-radius: 20px;
  73. font-weight: 500;
  74. font-size: 16px;
  75. color: #FFFFFF;
  76. text-align: center;
  77. }
  78. .el-form-item__label {
  79. padding-right: 0;
  80. font-weight: 500;
  81. font-size: 14px;
  82. color: #666666;
  83. }
  84. .el-input__inner {
  85. border: none;
  86. font-weight: 500;
  87. font-size: 14px;
  88. color: #222222;
  89. text-align: right;
  90. }
  91. .el-form-item {
  92. margin-bottom: 0;
  93. border-bottom: 1px solid #F9F9F9;
  94. padding: 10px 0;
  95. }
  96. .el-form-item__content .el-select {
  97. margin-left: 55px;
  98. }
  99. .el-form-item__content .el-cascader {
  100. margin-left: 55px;
  101. }
  102. .el-select-dropdown__item {
  103. white-space: normal;
  104. overflow: unset;
  105. height: auto;
  106. }
  107. .page6s {
  108. width: 100vw;
  109. height: 100vh;
  110. background: url('./img/signup_success.png') no-repeat center;
  111. background-size: 100vw 100vh;
  112. background-repeat: no-repeat;
  113. }
  114. .succ_tip {
  115. padding-top: 240px;
  116. font-weight: bold;
  117. font-size: 24px;
  118. color: #222222;
  119. line-height: 40px;
  120. text-align: center;
  121. width: 100%;
  122. word-break: keep-all;
  123. }
  124. .signup_page {
  125. width: 100vw;
  126. height: 100vh;
  127. background: url('./img/sign_up.png') no-repeat center;
  128. background-size: 100vw 100vh;
  129. background-repeat: no-repeat;
  130. }
  131. .signup_title {
  132. font-weight: bold;
  133. font-size: 24px;
  134. color: #FFFFFF;
  135. padding-top: 80px;
  136. text-align: center;
  137. line-height: 41px;
  138. }
  139. .fail_box {
  140. margin: 80px 20px 0;
  141. height: 287px;
  142. background: linear-gradient(#D5E6FF 50%, #FFFFFF 100%);
  143. border-radius: 20px;
  144. box-sizing: border-box;
  145. text-align: center;
  146. }
  147. .fail_img {
  148. width: 246px;
  149. height: 144px;
  150. margin-top: -20px;
  151. }
  152. .fail_title {
  153. font-weight: 500;
  154. font-size: 20px;
  155. color: #222222;
  156. line-height: 30px;
  157. padding: 20px 0;
  158. }
  159. .fail_tip {
  160. font-weight: 400;
  161. font-size: 16px;
  162. color: #666666;
  163. line-height: 30px;
  164. }
  165. </style>
  166. <body>
  167. <div id="box" class="box">
  168. <div class="page6" v-if="step === 1">
  169. <div class="page_title">核销领取礼品</div>
  170. <div class="form_content">
  171. <el-form ref="form" label-position="left" label-width="120px">
  172. <el-form-item label="核销码" required>
  173. <el-input v-model="verificationCode" placeholder="请输入"></el-input>
  174. </el-form-item>
  175. <el-form-item v-for="(item, index) in toshopData.formProList" :key="index" :label="item.name "
  176. :required="Boolean(item.isNeed)">
  177. <el-cascader v-if="item.type === 10" v-model="item.value" :options="transformedData"
  178. @change="handleInfoCity">
  179. </el-cascader>
  180. <el-select v-if="item.type === 11" v-model="item.value" placeholder="请选择" @change="handlechange">
  181. <el-option v-for="(sto, sindex) in storeList" :key="sindex" :label="sto.name" :value="sto.name">
  182. </el-option>
  183. </el-select>
  184. <el-input v-if="item.type === 0" v-model="item.value" placeholder="请输入"></el-input>
  185. <el-input v-if="item.type === 1" type="textarea" autosize v-model="item.value" placeholder="请输入"></el-input>
  186. <el-input v-if="item.type === 2" type="number" v-model="item.value" placeholder="请输入"></el-input>
  187. <el-select v-if="item.type === 3" v-model="item.value" placeholder="请选择">
  188. <el-option v-for="sto in item.formProTagReqs" :key="sto.proValue" :label="sto.proValue"
  189. :value="sto.proValue">
  190. </el-option>
  191. </el-select>
  192. <el-col :span="22" v-if="item.type === 5">
  193. <el-date-picker v-model="item.value" type="date" placeholder="选择日期" style="width: 100%;">
  194. </el-col>
  195. <el-col :span="22" v-if="item.type === 6">
  196. <el-time-picker v-model="item.value" placeholder="请选择"></el-time-picker>
  197. </el-col>
  198. <el-col :span="22" v-if="item.type === 7">
  199. <el-date-picker v-if="item.type === 7" v-model="item.value" type="datetime"
  200. placeholder="选择日期时间"></el-date-picker>
  201. </el-col>
  202. </el-form-item>
  203. </el-form>
  204. </div>
  205. <div class="foot_btn">
  206. <el-button class="signUp_btn" :loading="loading" @click="toSignUp">核销</el-button>
  207. </div>
  208. </div>
  209. <div class="page6s" v-else-if="step === 2">
  210. <div class="succ_tip">
  211. {{toshopData.verificationGuide}}
  212. </div>
  213. </div>
  214. <div class="signup_page" v-else-if="step === 3">
  215. <div class="signup_title">{{toshopData.name}}</div>
  216. <div class="fail_box">
  217. <img class="fail_img" src="./img/fail_img.png" />
  218. <div class="fail_title">{{toshopData.verificationFailGuide}}</div>
  219. <div class="fail_tip">{{toshopData.verificationFailGuide2}}</div>
  220. </div>
  221. </div>
  222. </div>
  223. </body>
  224. <script>
  225. new Vue({
  226. el: '#box',
  227. data () {
  228. return {
  229. httpUrl: '',
  230. bId: null,
  231. env: '',
  232. toshopData: {
  233. name: '',
  234. verificationGuide: '',
  235. verificationFailGuide: '',
  236. verificationFailGuide2: '',
  237. formProList: [],
  238. },
  239. step: 1,
  240. verificationCode: '',
  241. transformedData: [],
  242. storeList: [],
  243. province: '',
  244. city: '',
  245. loading: false,
  246. }
  247. },
  248. created () {
  249. this.bId = this.getQueryParam('bId')
  250. this.env = this.getQueryParam('env')
  251. if (!this.env || this.env === 'prod') {
  252. this.httpUrl = 'https://wlapi.wefanbot.com'
  253. } else {
  254. this.httpUrl = 'http://test.wefanbot.com:18993'
  255. }
  256. this.ifH5Type()
  257. },
  258. methods: {
  259. ifH5Type () {
  260. if (this.getQueryParam('openId') || localStorage.getItem('openId')) {
  261. if (!this.getQueryParam('externalUserid')) {
  262. this.gerQwAuth(this.bId);
  263. } else {
  264. this.getCityLevel()
  265. this.lightenShare()
  266. }
  267. } else {
  268. // 走授权操作
  269. this.getAuth();
  270. }
  271. },
  272. getAuth () {
  273. // 获取url上的code
  274. let code = this.getQueryParam('code')
  275. if (code) {
  276. // 判断业务id是否生产环境业务id
  277. fetch(this.httpUrl + `/p/insuite/p/isProdId?id=${this.bId}`)
  278. .then(res => {
  279. return res.json()
  280. }).then(result => {
  281. let { data, msg } = result
  282. if (typeof data === 'boolean' && data) {
  283. this.httpUrl = 'https://wlapi.wefanbot.com'
  284. } else {
  285. this.httpUrl = 'http://test.wefanbot.com:18993'
  286. }
  287. this.getInfoByh5Code(this.getQueryParam('code'))
  288. })
  289. } else {
  290. let redirect_uri = window.location.href
  291. // code 不存在,走微信网页授权逻辑
  292. let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  293. window.location.replace(url)
  294. }
  295. },
  296. getInfoByh5Code (code) {
  297. fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
  298. .then(res => {
  299. return res.json()
  300. }).then(result => {
  301. let { data, code, msg } = result
  302. if (code === 1) {
  303. localStorage.setItem('openId', data.openId)
  304. this.ifH5Type()
  305. }
  306. })
  307. },
  308. // 企微授权
  309. gerQwAuth (bId) {
  310. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  311. fetch(this.httpUrl + `/p/insuite/p/getOAUrl?openId=${openId}&bId=${bId}`)
  312. .then(res => {
  313. return res.json()
  314. }).then(result => {
  315. let { data, code, msg } = result
  316. if (code === 1) {
  317. window.location.replace(data)
  318. } else {
  319. this.$message({
  320. message: msg,
  321. type: 'warning'
  322. })
  323. }
  324. })
  325. },
  326. // 获取城市数据
  327. getCityLevel () {
  328. fetch('https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/103548289110001/1742009720857/four-province.json')
  329. .then(res => {
  330. return res.json()
  331. }).then(result => {
  332. this.transformedData = this.transformData(result)
  333. })
  334. },
  335. // 省市数据做转换
  336. transformData (data) {
  337. return data.map(item => {
  338. // 创建一个新对象,避免直接修改原始对象
  339. const newItem = { ...item };
  340. // 重命名 text 为 label
  341. if (newItem.text) {
  342. newItem.label = newItem.text;
  343. newItem.value = newItem.text;
  344. delete newItem.text;
  345. }
  346. // 如果存在 children 数组,则递归处理每个子项
  347. if (newItem.children && Array.isArray(newItem.children)) {
  348. newItem.children = this.transformData(newItem.children);
  349. }
  350. return newItem;
  351. })
  352. },
  353. handleInfoCity (value) {
  354. this.province = value[0]
  355. this.city = value[1]
  356. // 清空经销商类型的数据
  357. this.toshopData.formProList.forEach(item => {
  358. if (item.type === 11) {
  359. item.value = ''
  360. }
  361. })
  362. this.storeList = []
  363. this.getStoreList()
  364. },
  365. handlechange (value) {
  366. this.toshopData.formProList.forEach(item => {
  367. if (item.type === 11) {
  368. item.value = value
  369. }
  370. })
  371. this.$forceUpdate()
  372. },
  373. getStoreList () {
  374. fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-store/p/findListByPage?city=${this.city}&province=${this.province}`, {
  375. method: 'post',
  376. body: JSON.stringify({
  377. page: 1,
  378. pageCount: 10000,
  379. }),
  380. headers: {
  381. 'Content-Type': 'application/json'
  382. }
  383. }).then(res => {
  384. return res.json()
  385. }).then(result => {
  386. let { data, code, msg } = result
  387. if (code === 1) {
  388. this.storeList = data.records
  389. } else {
  390. this.$message({
  391. message: msg,
  392. type: 'warning'
  393. })
  394. }
  395. })
  396. },
  397. lightenShare () {
  398. let externalUserid = this.getQueryParam('externalUserid')
  399. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  400. const headers = new Headers();
  401. headers.append('police', 110);
  402. fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-verification/p/lottery?externalUserid=${externalUserid}&openId=${openId}&bId=${this.bId}`, {
  403. method: 'GET',
  404. headers: headers
  405. })
  406. .then(res => {
  407. return res.json()
  408. }).then(result => {
  409. let { data, code, msg } = result
  410. if (code === 1) {
  411. this.toshopData = data
  412. } else {
  413. this.$message({
  414. message: msg,
  415. })
  416. }
  417. })
  418. },
  419. toSignUp () {
  420. if (!this.verificationCode) {
  421. this.$message({
  422. message: '核销码不能为空',
  423. type: 'warning'
  424. })
  425. return
  426. }
  427. const isValid = this.toshopData.formProList.some(item => {
  428. if (item.isNeed && !item.value) {
  429. this.$message({
  430. message: '必填项不能为空',
  431. type: 'warning'
  432. })
  433. return true
  434. }
  435. return false
  436. })
  437. if (isValid) return
  438. let cols = []
  439. cols = this.toshopData.formProList.map(item => {
  440. return {
  441. name: item.name,
  442. type: item.type,
  443. value: item.type === 10 ? [item.value.join('')] : [item.value],
  444. }
  445. })
  446. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  447. this.loading = true
  448. fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-verification/p/formData?openId=${openId}`, {
  449. method: 'post',
  450. body: JSON.stringify({
  451. bid: this.bId,
  452. cols: cols,
  453. verificationCode: this.verificationCode
  454. }),
  455. headers: {
  456. 'Content-Type': 'application/json'
  457. }
  458. }).then(res => {
  459. return res.json()
  460. }).then(result => {
  461. let { data, code, msg } = result
  462. if (code === 1) {
  463. if (data.client.state === 3) {
  464. // 已核销(已提交核销表单)
  465. this.step = 2
  466. } else if (data.client.state === -1) {
  467. // 不符合资格
  468. this.step = 3
  469. }
  470. } else if (code === 2) {
  471. this.$message({
  472. message: '核销码无效',
  473. type: 'warning'
  474. })
  475. } else if (code === 3) {
  476. this.$message({
  477. message: msg,
  478. type: 'warning'
  479. })
  480. } else {
  481. this.$message({
  482. message: msg,
  483. type: 'warning'
  484. })
  485. }
  486. }).finally(() => {
  487. this.loading = false
  488. })
  489. },
  490. // 截取url中的数据
  491. getQueryParam (paramName) {
  492. // 获取当前URL的查询字符串部分
  493. const queryString = window.location.search;
  494. // 创建一个URLSearchParams对象
  495. const urlParams = new URLSearchParams(queryString);
  496. // 返回指定参数的值,如果不存在则返回null
  497. return urlParams.get(paramName);
  498. },
  499. }
  500. })
  501. </script>
  502. </html>