live_code.html 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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"
  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. }
  32. .page1 {
  33. background: #FAFAFA;
  34. }
  35. .page2 {
  36. background: #FFFFFF;
  37. }
  38. .ready_code_box {
  39. position: relative;
  40. padding-top: 70px;
  41. }
  42. .ready_code {
  43. width: 100%;
  44. }
  45. .code_tip {
  46. position: absolute;
  47. bottom: 7px;
  48. font-weight: bold;
  49. font-size: 24px;
  50. color: #222222;
  51. text-align: center;
  52. width: 100%;
  53. }
  54. .form_title {
  55. font-weight: bold;
  56. font-size: 24px;
  57. color: #222222;
  58. text-align: center;
  59. width: 100%;
  60. padding: 60px 0 7px;
  61. background: #FAFAFA;
  62. }
  63. .main_tip {
  64. color: #2885FF;
  65. }
  66. .page_tip {
  67. font-weight: 500;
  68. font-size: 14px;
  69. color: #222222;
  70. text-align: center;
  71. width: 100%;
  72. padding-top: 8px;
  73. }
  74. .page_tip_page2 {
  75. padding-bottom: 40px;
  76. }
  77. .form_list {
  78. background: #FFFFFF;
  79. }
  80. .page_btn {
  81. width: 305px;
  82. height: 52px;
  83. line-height: 52px;
  84. background: #222222;
  85. border-radius: 20px;
  86. font-weight: 500;
  87. font-size: 16px;
  88. color: #FFFFFF;
  89. text-align: center;
  90. }
  91. .el-form-item__label {
  92. padding-right: 0;
  93. font-weight: 500;
  94. font-size: 14px;
  95. color: #666666;
  96. }
  97. .el-input__inner {
  98. border: none;
  99. font-weight: 500;
  100. font-size: 14px;
  101. color: #222222;
  102. text-align: right;
  103. }
  104. .el-form-item {
  105. margin-bottom: 0;
  106. border-bottom: 1px solid #F9F9F9;
  107. padding: 10px 0;
  108. padding-left: 35px;
  109. }
  110. .live_code_box {
  111. position: relative;
  112. padding-top: 96px;
  113. width: 315px;
  114. height: 329px;
  115. margin: 0 auto;
  116. }
  117. .salesMan_style {
  118. text-align: center;
  119. line-height: 14px;
  120. padding-bottom: 10px;
  121. }
  122. .live_code_bg {
  123. width: 315px;
  124. }
  125. .live_code {
  126. width: 180px;
  127. position: absolute;
  128. top: 195px;
  129. left: 68px;
  130. }
  131. .live_code_tip {
  132. position: absolute;
  133. bottom: 0;
  134. font-weight: 500;
  135. font-size: 14px;
  136. color: #222222;
  137. width: 100%;
  138. text-align: center;
  139. }
  140. .foot_btn {
  141. display: flex;
  142. align-items: center;
  143. position: fixed;
  144. bottom: 40px;
  145. left: 30px;
  146. }
  147. .save_btn {
  148. width: 152px;
  149. height: 52px;
  150. line-height: 52px;
  151. text-align: center;
  152. border-radius: 20px;
  153. border: 1px solid #222222;
  154. box-sizing: border-box;
  155. font-weight: 500;
  156. font-size: 16px;
  157. color: #222222;
  158. margin-right: 11px;
  159. }
  160. .data_btn {
  161. width: 152px;
  162. height: 52px;
  163. line-height: 52px;
  164. text-align: center;
  165. background: #222222;
  166. border-radius: 20px;
  167. font-weight: 500;
  168. font-size: 16px;
  169. color: #FFFFFF;
  170. }
  171. </style>
  172. <body>
  173. <div id="box" class="box" :class="step === 2 ? 'page2' : 'page1'">
  174. <!-- 引导页面 -->
  175. <div v-if="step === 1">
  176. <div class="ready_code_box">
  177. <image class="ready_code" src="./img/ready_code.png"></image>
  178. <div class="code_tip">
  179. <span>生成我的</span>
  180. <span class="main_tip">专属活码</span>
  181. </div>
  182. </div>
  183. <div class="page_tip">引导门店客户添加,领取引流激励!</div>
  184. <div class="page_btn" style="margin: 150px auto 0;" @click="createQrcode">创建活码</div>
  185. </div>
  186. <!-- 创建活码 -->
  187. <div v-if="step === 2">
  188. <div class="form_title">
  189. <span>生成我的</span>
  190. <span class="main_tip">专属活码</span>
  191. </div>
  192. <div class="page_tip page1 page_tip_page2">引导门店客户添加,领取引流激励!</div>
  193. <div class="form_list">
  194. <el-form ref="form" :model="form" label-position="left" label-width="84px">
  195. <el-form-item label="顾问姓名:">
  196. <el-input v-model="form.salesMan" placeholder="请输入"></el-input>
  197. </el-form-item>
  198. <el-form-item label="经销商名称:">
  199. <el-input v-model="form.ownerDealerName" placeholder="请输入"></el-input>
  200. </el-form-item>
  201. <el-form-item label="经销商代码:">
  202. <el-input v-model="form.ownerDealerCode" placeholder="请输入"></el-input>
  203. </el-form-item>
  204. <el-form-item label="联系电话:">
  205. <el-input v-model="form.phone" placeholder="请输入"></el-input>
  206. </el-form-item>
  207. </el-form>
  208. </div>
  209. <div class="page_btn" style="margin: 177px auto 0;" @click="handleQrcode">创建活码</div>
  210. </div>
  211. <!-- 我的活码 -->
  212. <div v-if="step === 3">
  213. <div class="live_code_box">
  214. <div class="salesMan_style">{{salesMan}}</div>
  215. <image class="live_code_bg" src="./img/live_code_bg.png"></image>
  216. <image class="live_code" :src="qrCode"></image>
  217. <div class="live_code_tip">
  218. <div>扫描二维码,添加官方企业微信</div>
  219. <div>获取最新资讯</div>
  220. </div>
  221. </div>
  222. <div class="foot_btn">
  223. <div class="save_btn" @click="saveImage">保存二维码</div>
  224. <div class="data_btn" @click="showData">数据查看</div>
  225. </div>
  226. </div>
  227. </div>
  228. </body>
  229. <script>
  230. new Vue({
  231. el: '#box',
  232. data () {
  233. return {
  234. httpUrl: '',
  235. bId: null,
  236. env: '',
  237. memberId: null,
  238. corpId: null,
  239. step: null,
  240. qrCode: '',
  241. salesMan: '',
  242. form: {
  243. salesMan: '',
  244. ownerDealerName: '',
  245. ownerDealerCode: '',
  246. phone: ''
  247. },
  248. }
  249. },
  250. created () {
  251. this.bId = this.getQueryParam('bId')
  252. this.env = this.getQueryParam('env')
  253. if (!this.env || this.env === 'prod') {
  254. this.httpUrl = 'https://wlapi.wefanbot.com'
  255. } else {
  256. this.httpUrl = 'http://test.wefanbot.com:18993'
  257. }
  258. if (this.getQueryParam('memberId')) {
  259. // 已授权
  260. this.memberId = this.getQueryParam('memberId')
  261. this.corpId = this.getQueryParam('corpId')
  262. this.findQrCode()
  263. } else {
  264. // 授权
  265. this.getAuth()
  266. }
  267. },
  268. methods: {
  269. getAuth () {
  270. fetch(this.httpUrl + `/p/insuite/p/getRedirectUri?env=${this.env}&bId=${this.bId}`)
  271. .then(res => {
  272. return res.json()
  273. }).then(result => {
  274. let { data, code, msg } = result
  275. if (code === 1) {
  276. window.location.replace(data)
  277. } else {
  278. this.$message({
  279. message: msg,
  280. type: 'warning'
  281. })
  282. }
  283. })
  284. },
  285. findQrCode () {
  286. fetch(this.httpUrl + '/scrm/v1/wxcp-live-code-counselor/p/findQrCodeByH5', {
  287. method: 'post',
  288. body: JSON.stringify({
  289. corpId: this.corpId,
  290. memberId: this.memberId,
  291. }),
  292. headers: {
  293. 'Content-Type': 'application/json'
  294. }
  295. }).then(res => {
  296. return res.json()
  297. }).then(result => {
  298. let { data, code, msg } = result
  299. if (data && data.qrCode) {
  300. this.step = 3
  301. this.salesMan = data.salesMan
  302. this.qrCode = data.qrCode
  303. } else {
  304. this.$message.error(msg)
  305. this.step = 1
  306. }
  307. })
  308. },
  309. createQrcode () {
  310. this.step = 2
  311. },
  312. // 创建活码
  313. handleQrcode () {
  314. fetch(this.httpUrl + '/scrm/v1/wxcp-live-code-counselor/p/addByH5', {
  315. method: 'post',
  316. body: JSON.stringify({
  317. corpId: this.corpId,
  318. memberId: this.memberId,
  319. ...this.form
  320. }),
  321. headers: {
  322. 'Content-Type': 'application/json'
  323. }
  324. }).then(res => {
  325. return res.json()
  326. }).then(result => {
  327. let { data, code, msg } = result
  328. if (data && data.qrCode) {
  329. this.step = 3
  330. this.qrCode = data.qrCode
  331. } else {
  332. this.$message.error(msg)
  333. this.step = 1
  334. }
  335. })
  336. },
  337. // 保存二维码
  338. saveImage () {
  339. const link = document.createElement('a')
  340. link.href = this.qrCode
  341. link.download = 'qrCode.jpg'
  342. document.body.appendChild(link);
  343. link.click();
  344. document.body.removeChild(link);
  345. },
  346. // 查看数据
  347. showData () {
  348. window.location.href = `prize.html?httpUrl=${this.httpUrl}&corpId=${this.corpId}&memberId=${this.memberId}`;
  349. },
  350. // 截取url中的数据
  351. getQueryParam (paramName) {
  352. // 获取当前URL的查询字符串部分
  353. const queryString = window.location.search;
  354. // 创建一个URLSearchParams对象
  355. const urlParams = new URLSearchParams(queryString);
  356. // 返回指定参数的值,如果不存在则返回null
  357. return urlParams.get(paramName);
  358. },
  359. }
  360. })
  361. </script>
  362. </html>