signUp.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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">
  7. <title>活动</title>
  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>
  16. var vConsole = new window.VConsole();
  17. </script>
  18. </head>
  19. <style>
  20. body {
  21. margin: 0;
  22. padding: 0;
  23. }
  24. .box {
  25. width: 100vw;
  26. height: 100vh;
  27. box-sizing: border-box;
  28. background: #FAFAFA;
  29. }
  30. .page6 {
  31. width: 100vw;
  32. height: 100vh;
  33. background: url('./img/signup_bg.png') no-repeat top;
  34. background-size: 100vw 210px;
  35. background-repeat: no-repeat;
  36. display: flex;
  37. justify-content: center;
  38. align-items: center;
  39. }
  40. .page_title {
  41. font-weight: 800;
  42. font-size: 40px;
  43. color: #FFFFFF;
  44. position: fixed;
  45. top: 40px;
  46. left: 20px;
  47. }
  48. .form_content {
  49. width: 100%;
  50. height: calc(100vh - 180px);
  51. margin-top: 180px;
  52. background: #FFFFFF;
  53. border-radius: 20px 20px 0px 0px;
  54. padding: 20px 20px 66px;
  55. overflow-y: auto;
  56. box-sizing: border-box;
  57. }
  58. .foot_btn {
  59. position: fixed;
  60. bottom: 14px;
  61. padding: 0 35px;
  62. width: 100%;
  63. box-sizing: border-box;
  64. }
  65. .signUp_btn {
  66. height: 52px;
  67. line-height: 52px;
  68. background: #1677FF;
  69. border-radius: 20px;
  70. font-weight: 500;
  71. font-size: 16px;
  72. color: #FFFFFF;
  73. text-align: center;
  74. }
  75. .el-form-item__label {
  76. padding-right: 0;
  77. font-weight: 500;
  78. font-size: 14px;
  79. color: #666666;
  80. }
  81. .el-input__inner{
  82. border: none;
  83. font-weight: 500;
  84. font-size: 14px;
  85. color: #222222;
  86. text-align: right;
  87. }
  88. .el-form-item {
  89. margin-bottom: 0;
  90. border-bottom: 1px solid #F9F9F9;
  91. padding: 10px 0;
  92. }
  93. .page6s {
  94. width: 100vw;
  95. height: 100vh;
  96. background: url('./img/signup_success.png') no-repeat center;
  97. background-size: 100vw 100vh;
  98. background-repeat: no-repeat;
  99. }
  100. .succ_tip {
  101. padding-top: 240px;
  102. font-weight: bold;
  103. font-size: 24px;
  104. color: #222222;
  105. line-height: 40px;
  106. text-align: center;
  107. }
  108. .signup_page {
  109. width: 100vw;
  110. height: 100vh;
  111. background: url('./img/sign_up.png') no-repeat center;
  112. background-size: 100vw 100vh;
  113. background-repeat: no-repeat;
  114. }
  115. .signup_title {
  116. font-weight: bold;
  117. font-size: 24px;
  118. color: #FFFFFF;
  119. padding-top: 80px;
  120. text-align: center;
  121. line-height: 41px;
  122. }
  123. .fail_box {
  124. margin: 80px 20px 0;
  125. height: 287px;
  126. background: linear-gradient(#D5E6FF 50%, #FFFFFF 100%);
  127. border-radius: 20px;
  128. box-sizing: border-box;
  129. text-align: center;
  130. }
  131. .fail_img {
  132. width: 246px;
  133. height: 144px;
  134. margin-top: -20px;
  135. }
  136. .fail_title {
  137. font-weight: 500;
  138. font-size: 20px;
  139. color: #222222;
  140. line-height: 30px;
  141. padding: 20px 0;
  142. }
  143. .fail_tip {
  144. font-weight: 400;
  145. font-size: 16px;
  146. color: #666666;
  147. line-height: 30px;
  148. }
  149. </style>
  150. <body>
  151. <div id="box" class="box">
  152. <div class="page6" v-if="step === 1">
  153. <div class="page_title">核销领取礼品</div>
  154. <div class="form_content">
  155. <el-form ref="form" label-position="left" label-width="100px">
  156. <el-form-item label="核销码:" required>
  157. <el-input v-model="verificationCode" placeholder="请输入"></el-input>
  158. </el-form-item>
  159. <el-form-item v-for="(item, index) in toshopData.formProList" :key="index" :label="item.name + ':'"
  160. :required="Boolean(item.isNeed)">
  161. <el-input v-if="item.type === 0" v-model="item.value" placeholder="请输入"></el-input>
  162. <el-input v-if="item.type === 1" type="textarea" autosize v-model="item.value" placeholder="请输入"></el-input>
  163. <el-input v-if="item.type === 2" type="number" v-model="item.value" placeholder="请输入"></el-input>
  164. <el-date-picker v-if="item.type === 5" v-model="item.value" type="date" placeholder="选择日期">
  165. <el-time-picker v-if="item.type === 6" v-model="item.value" placeholder="请选择"></el-time-picker>
  166. <el-date-picker v-if="item.type === 7" v-model="item.value" type="datetime" placeholder="选择日期时间"></el-date-picker>
  167. </el-form-item>
  168. </el-form>
  169. </div>
  170. <div class="foot_btn">
  171. <div class="signUp_btn" @click="toSignUp">核销</div>
  172. </div>
  173. </div>
  174. <div class="page6s" v-else-if="step === 2">
  175. <div class="succ_tip">
  176. <div>感谢参与{{toshopData.name}}活动</div>
  177. <div>请联系门店顾问领取礼品</div>
  178. </div>
  179. </div>
  180. <div class="signup_page" v-else-if="step === 3">
  181. <div class="signup_title">{{toshopData.name}}</div>
  182. <div class="fail_box">
  183. <img class="fail_img" src="./img/fail_img.png" />
  184. <div class="fail_title">很遗憾,您不在此次活动范围内</div>
  185. <div class="fail_tip">
  186. <div>后续有活动我们将第一时间通知您</div>
  187. <div>敬请关注</div>
  188. </div>
  189. </div>
  190. </div>
  191. </div>
  192. </body>
  193. <script>
  194. new Vue({
  195. el: '#box',
  196. data() {
  197. return {
  198. httpUrl: '',
  199. bId: null,
  200. env: '',
  201. openId: '',
  202. toshopData: {
  203. name: '',
  204. formProList: [],
  205. },
  206. step: 1,
  207. verificationCode: '',
  208. }
  209. },
  210. created() {
  211. this.bId = this.getQueryParam('bId')
  212. this.env = this.getQueryParam('env')
  213. if (!this.env || this.env === 'prod') {
  214. this.httpUrl = 'https://wlapi.wefanbot.com'
  215. } else {
  216. this.httpUrl = 'http://test.wefanbot.com:18993'
  217. }
  218. this.ifH5Type()
  219. },
  220. methods: {
  221. ifH5Type() {
  222. if (this.getQueryParam('openId') || localStorage.getItem('openId')) {
  223. if (!this.getQueryParam('externalUserid')) {
  224. this.gerQwAuth(this.bId);
  225. } else {
  226. this.lightenShare()
  227. }
  228. } else {
  229. // 走授权操作
  230. this.getAuth();
  231. }
  232. },
  233. getAuth() {
  234. // 获取url上的code
  235. let code = this.getQueryParam('code')
  236. if (code) {
  237. fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
  238. .then(res => {
  239. return res.json()
  240. }).then(result => {
  241. let { data, code, msg } = result
  242. if (code === 1) {
  243. this.openId = data.openId
  244. localStorage.setItem('openId', data.openId)
  245. this.ifH5Type()
  246. }
  247. })
  248. } else {
  249. let redirect_uri = window.location.href
  250. // code 不存在,走微信网页授权逻辑
  251. let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  252. window.location.replace(url)
  253. }
  254. },
  255. // 企微授权
  256. gerQwAuth(bId) {
  257. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  258. fetch(this.httpUrl + `/p/insuite/p/getOAUrl?openId=${openId}&bId=${bId}`)
  259. .then(res => {
  260. return res.json()
  261. }).then(result => {
  262. let { data, code, msg } = result
  263. if (code === 1) {
  264. window.location.replace(data)
  265. } else {
  266. this.$message({
  267. message: msg,
  268. type: 'warning'
  269. })
  270. }
  271. })
  272. },
  273. lightenShare() {
  274. let externalUserid = this.getQueryParam('externalUserid')
  275. let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
  276. const headers = new Headers();
  277. headers.append('police', 110);
  278. fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-verification/p/lottery?externalUserid=${externalUserid}&openId=${openId}&bId=${this.bId}`, {
  279. method: 'GET',
  280. headers: headers
  281. })
  282. .then(res => {
  283. return res.json()
  284. }).then(result => {
  285. let { data, code, msg } = result
  286. if (code === 1) {
  287. this.toshopData = data
  288. } else {
  289. this.$message({
  290. message: msg,
  291. })
  292. }
  293. })
  294. },
  295. toSignUp() {
  296. let cols = []
  297. cols = this.toshopData.formProList.map(item => {
  298. return {
  299. name: item.name,
  300. type: item.type,
  301. value: [item.value]
  302. }
  303. })
  304. fetch(this.httpUrl + `/scrm/v1/wxcp-toshop-verification/p/formData?openId=${this.openId}`, {
  305. method: 'post',
  306. body: JSON.stringify({
  307. bid: this.bId,
  308. cols: cols,
  309. verificationCode: this.verificationCode
  310. }),
  311. headers: {
  312. 'Content-Type': 'application/json'
  313. }
  314. }).then(res => {
  315. return res.json()
  316. }).then(result => {
  317. let { data, code, msg } = result
  318. if (code === 1) {
  319. if (data.client.state === 3) {
  320. // 已核销(已提交核销表单)
  321. this.step = 2
  322. } else if (data.client.state === -1) {
  323. // 不符合资格
  324. this.step = 3
  325. }
  326. } else if (code === 2) {
  327. this.$message({
  328. message: '核销码无效',
  329. type: 'warning'
  330. })
  331. } else {
  332. this.$message({
  333. message: msg,
  334. type: 'warning'
  335. })
  336. }
  337. })
  338. },
  339. // 截取url中的数据
  340. getQueryParam(paramName) {
  341. // 获取当前URL的查询字符串部分
  342. const queryString = window.location.search;
  343. // 创建一个URLSearchParams对象
  344. const urlParams = new URLSearchParams(queryString);
  345. // 返回指定参数的值,如果不存在则返回null
  346. return urlParams.get(paramName);
  347. },
  348. }
  349. })
  350. </script>
  351. </html>