live_code.html 10 KB

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