h5Type-20.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>活动</title>
  6. <meta name="viewport"
  7. content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  8. <link href="css/mui.css" rel="stylesheet" />
  9. <link href="css/mui.picker.css" rel="stylesheet" />
  10. <link href="css/mui.poppicker.css" rel="stylesheet" />
  11. <script src="js/mui.js"></script>
  12. <script src="js/mui.picker.js"></script>
  13. <script src="js/mui.poppicker.js"></script>
  14. <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
  15. <!-- <script src="js/vconsole.min.js"></script>
  16. <script>
  17. var vConsole = new window.VConsole();
  18. </script> -->
  19. <script type="text/javascript">
  20. mui.init()
  21. (function flexible (window, document) {
  22. let docEl = document.documentElement
  23. let dpr = window.devicePixelRatio || 1
  24. // adjust body font size
  25. function setBodyFontSize () {
  26. if (document.body) {
  27. document.body.style.fontSize = (12 * dpr) + 'px'
  28. } else {
  29. document.addEventListener('DOMContentLoaded', setBodyFontSize)
  30. }
  31. }
  32. setBodyFontSize()
  33. // set 1rem = viewWidth / 10
  34. function setRemUnit () {
  35. let rem = docEl.clientWidth / 375
  36. docEl.style.fontSize = rem + 'px'
  37. }
  38. setRemUnit()
  39. // reset rem unit on page resize
  40. window.addEventListener('resize', setRemUnit)
  41. window.addEventListener('pageshow', function(e) {
  42. if (e.persisted) {
  43. setRemUnit()
  44. }
  45. })
  46. // detect 0.5px supports
  47. if (dpr >= 2) {
  48. let fakeBody = document.createElement('body')
  49. let testElement = document.createElement('div')
  50. testElement.style.border = '.5px solid transparent'
  51. fakeBody.appendChild(testElement)
  52. docEl.appendChild(fakeBody)
  53. if (testElement.offsetHeight === 1) {
  54. docEl.classList.add('hairlines')
  55. }
  56. docEl.removeChild(fakeBody)
  57. }
  58. }(window, document));
  59. (function() {
  60. if (typeof WeixinJSBridge === 'object' && typeof WeixinJSBridge.invoke === 'function') {
  61. handleFontSize()
  62. } else {
  63. if (document.addEventListener) {
  64. document.addEventListener('WeixinJSBridgeReady', handleFontSize, false)
  65. } else if (document.attachEvent) {
  66. document.attachEvent('onWeixinJSBridgeReady', handleFontSize)
  67. }
  68. }
  69. function handleFontSize () {
  70. // 设置网页字体为默认大小
  71. WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize': 0 })
  72. // 重写设置网页字体大小的事件
  73. WeixinJSBridge.on('menu:setfont', function() {
  74. WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize': 0 })
  75. })
  76. }
  77. })()
  78. </script>
  79. </head>
  80. <style type="text/css">
  81. body {
  82. margin: 0;
  83. background: #FFFFFF;
  84. }
  85. #collectPage,
  86. #qrcode {
  87. display: none;
  88. }
  89. .mui-input-group {
  90. padding-top: 15px;
  91. }
  92. .mui-input-group:before {
  93. background: none;
  94. }
  95. .mui-input-group:after {
  96. background: none;
  97. }
  98. .mui-input-group .mui-input-row:after {
  99. background: none;
  100. }
  101. .mui-input-group .mui-input-row {
  102. height: 60px;
  103. }
  104. ::-webkit-input-placeholder {
  105. /* Chrome/Opera/Safari */
  106. font-weight: 400;
  107. font-size: 14px;
  108. color: #CCCCCC;
  109. float: right;
  110. }
  111. ::-moz-placeholder {
  112. /* Firefox 19+ */
  113. font-weight: 400;
  114. font-size: 14px;
  115. color: #CCCCCC;
  116. float: right;
  117. }
  118. :-ms-input-placeholder {
  119. /* IE 10+ */
  120. font-weight: 400;
  121. font-size: 14px;
  122. color: #CCCCCC;
  123. float: right;
  124. }
  125. :-moz-placeholder {
  126. /* Firefox 18- */
  127. font-weight: 400;
  128. font-size: 14px;
  129. color: #CCCCCC;
  130. float: right;
  131. }
  132. .mui-input-clear {
  133. font-weight: 500;
  134. font-size: 14px;
  135. color: #222222;
  136. text-align: right;
  137. padding: 10px 0;
  138. padding-right: 30px !important;
  139. }
  140. .mui-input-row label {
  141. font-weight: 500;
  142. font-size: 14px;
  143. color: #666666;
  144. }
  145. .dialog {
  146. position: fixed;
  147. top: 0;
  148. left: 0;
  149. width: 100%;
  150. height: 100%;
  151. background-color: rgba(0, 0, 0, 0.5);
  152. /* 半透明黑色 */
  153. z-index: 1000;
  154. /* 确保遮罩层在顶部 */
  155. transition: opacity 0.5s ease;
  156. /* 可选:添加透明度过渡效果 */
  157. display: none;
  158. }
  159. .mui-poppicker {
  160. z-index: 1002 !important;
  161. }
  162. .bg_content {
  163. height: calc(100vh + 44rem);
  164. width: 100vw;
  165. background: url('./img/blessings.png');
  166. background-size: cover;
  167. margin-top: -44rem;
  168. }
  169. .show_box {
  170. position: absolute;
  171. top: 154rem;
  172. /* background: #FFFFFF; */
  173. left: 15rem;
  174. right: 15rem;
  175. height: 290rem;
  176. }
  177. .show_box .show_item {
  178. width: 20rem;
  179. height: 20rem;
  180. position: relative;
  181. display: none;
  182. opacity: 1;
  183. }
  184. .show_box .show_item.add_animation_item {
  185. display: block;
  186. animation: showItem 0.4s linear forwards, hiddenAvatarItem 0.8s linear 2.7s forwards
  187. }
  188. .show_box .show_item .avatar_box {
  189. width: 20rem;
  190. height: 20rem;
  191. border-radius: 15rem;
  192. overflow: hidden;
  193. position: absolute;
  194. top: 0;
  195. left: 0;
  196. z-index: 2;
  197. transform: scale(1);
  198. display: flex;
  199. align-items: center;
  200. }
  201. .show_box .show_item.add_animation_item .avatar_box {
  202. animation: showAvatarItem 0.3s linear 2.4s forwards;
  203. }
  204. .show_box .show_item .avatar_box .avatar {
  205. width: 20rem;
  206. height: 20rem;
  207. object-fit: cover;
  208. }
  209. .show_box .show_item .info_box {
  210. position: absolute;
  211. top: -15rem;
  212. left: -15rem;
  213. z-index: 1;
  214. background: rgba(255, 255, 255, 0.7);
  215. border-radius: 15rem;
  216. border: 1rem solid #FFFFFF;
  217. width: 240rem;
  218. padding: 15rem;
  219. box-sizing: border-box;
  220. }
  221. .show_box .show_item.add_animation_item .info_box {
  222. animation: hiddenItem 0.3s linear 2.4s forwards;
  223. }
  224. .show_box .show_item.show_img_item .info_box {
  225. top: -175rem;
  226. left: -15rem;
  227. }
  228. .show_box .show_item.show_img_item.add_animation_item .info_box {
  229. animation: hiddenImgItem 0.3s linear 2.4s forwards;
  230. }
  231. @keyframes showItem {
  232. 0% {
  233. opacity: 0;
  234. }
  235. 100% {
  236. opacity: 1;
  237. }
  238. }
  239. @keyframes showAvatarItem {
  240. 0% {
  241. transform: scale(1);
  242. }
  243. 100% {
  244. transform: scale(2);
  245. }
  246. }
  247. @keyframes hiddenAvatarItem {
  248. 0% {
  249. transform: scale(2);
  250. opacity: 1;
  251. }
  252. 100% {
  253. transform: scale(1);
  254. opacity: 0;
  255. top: 135rem;
  256. left: 172rem;
  257. }
  258. }
  259. @keyframes hiddenItem {
  260. 0% {
  261. transform: scale(1);
  262. top: -15rem;
  263. left: -15rem;
  264. }
  265. 100% {
  266. transform: scale(0);
  267. left: -110rem;
  268. top: -30rem;
  269. }
  270. }
  271. @keyframes hiddenImgItem {
  272. 0% {
  273. transform: scale(1);
  274. top: -175rem;
  275. left: -15rem;
  276. }
  277. 100% {
  278. transform: scale(0);
  279. left: -110rem;
  280. top: -115rem;
  281. }
  282. }
  283. .show_box .show_item .info_box .img_box {
  284. width: 210rem;
  285. height: 150rem;
  286. border-radius: 15rem;
  287. overflow: hidden;
  288. margin-bottom: 10rem;
  289. display: none;
  290. }
  291. .show_box .show_item.show_img_item .info_box .img_box {
  292. display: block;
  293. }
  294. .show_box .show_item .info_box .img_box .info_img {
  295. width: 210rem;
  296. height: 150rem;
  297. object-fit: cover;
  298. }
  299. .show_box .show_item .info_box .info_text .info_name {
  300. font-weight: 500;
  301. font-size: 14rem;
  302. color: #222222;
  303. line-height: 20rem;
  304. padding-left: 25rem;
  305. margin-bottom: 5rem;
  306. height: 20rem;
  307. }
  308. .show_box .show_item .info_box .info_text .info_dsc {
  309. font-weight: 400;
  310. font-size: 12rem;
  311. color: #222222;
  312. line-height: 17rem;
  313. word-break: break-all;
  314. text-overflow: ellipsis;
  315. display: -webkit-box;
  316. -webkit-box-orient: vertical;
  317. -webkit-line-clamp: 5;
  318. overflow: hidden;
  319. }
  320. .show_box .show_item.show_img_item .info_box .info_text .info_dsc {
  321. word-break: break-all;
  322. text-overflow: ellipsis;
  323. display: -webkit-box;
  324. -webkit-box-orient: vertical;
  325. -webkit-line-clamp: 2;
  326. overflow: hidden;
  327. }
  328. .send_btn {
  329. width: 345rem;
  330. position: fixed;
  331. bottom: 50rem;
  332. left: 50%;
  333. transform: translateX(-50%);
  334. }
  335. .dialog_text {
  336. position: fixed;
  337. top: 0;
  338. left: 0;
  339. width: 100%;
  340. height: 100%;
  341. background-color: rgba(0, 0, 0, 0.5);
  342. /* 半透明黑色 */
  343. z-index: 1000;
  344. /* 确保遮罩层在顶部 */
  345. transition: opacity 0.5s ease;
  346. /* 可选:添加透明度过渡效果 */
  347. display: none;
  348. }
  349. .dialog-body {
  350. width: 100%;
  351. height: 100vh;
  352. z-index: 1001;
  353. /* 确保遮罩层在顶部 */
  354. display: flex;
  355. flex-direction: column;
  356. align-items: center;
  357. justify-content: center;
  358. }
  359. .text_bg {
  360. background: url('./img/dialog-text.png');
  361. background-size: cover;
  362. width: 100vw;
  363. height: 368rem;
  364. }
  365. .close-text {
  366. width: 24rem;
  367. height: 24rem;
  368. float: right;
  369. margin-right: 25rem;
  370. margin-top: 25rem;
  371. }
  372. .textarea_style {
  373. background-color: rgba(255, 255, 255, 0);
  374. border: unset;
  375. height: 180rem;
  376. padding: 0 35rem;
  377. width: 100%;
  378. margin: 0;
  379. font-size: 14rem;
  380. }
  381. .textarea_placeHolder {
  382. color: #999999;
  383. font-size: 14rem;
  384. padding: 0 35rem;
  385. position: absolute;
  386. top: 0;
  387. }
  388. .photo-btn {
  389. width: 80rem;
  390. height: 80rem;
  391. margin-top: 18rem;
  392. margin-right: 35rem;
  393. }
  394. .send_text {
  395. width: 225rem;
  396. height: 52rem;
  397. background: linear-gradient(48deg, #92E4FC 0%, #D0E7F5 100%);
  398. border-radius: 30rem;
  399. border: 2rem solid #FFFFFF;
  400. font-weight: 800;
  401. font-size: 16px;
  402. color: #222222;
  403. margin-top: 15rem;
  404. }
  405. .img_list {
  406. width: 100%;
  407. overflow-x: auto;
  408. padding: 0 35rem;
  409. }
  410. .imageGallery {
  411. display: flex;
  412. overflow-x: auto;
  413. }
  414. .imageGallery img {
  415. width: 80rem;
  416. height: 80rem;
  417. margin-top: 18rem;
  418. margin-right: 35rem;
  419. }
  420. .upload-class {
  421. min-width: 80rem;
  422. height: 80rem;
  423. line-height: 80rem;
  424. font-size: 14px;
  425. border: 1px solid #c1bfa9;
  426. border-radius: 10rem;
  427. text-align: center;
  428. margin-top: 18rem;
  429. margin-right: 35rem;
  430. color: #999;
  431. }
  432. input {
  433. font-size: 14rem;
  434. }
  435. .qrcode {
  436. padding: 20rem;
  437. }
  438. .qrcode-img {
  439. width: 100%;
  440. height: 100%;
  441. object-fit: cover;
  442. margin-bottom: 20rem;
  443. }
  444. .qrcode-msg {
  445. text-align: center;
  446. font-size: 18rem;
  447. }
  448. </style>
  449. <body>
  450. <div id="collectPage">
  451. <div class="bg_content">
  452. <div class="show_box">
  453. <div id="showItem" class="show_item">
  454. <div class="avatar_box">
  455. <img id="avatar" class="avatar" src="./img/prize-bg.png" />
  456. </div>
  457. <div class="info_box">
  458. <div class="img_box">
  459. <img id="infoImg" class="info_img" src="./img/lottery-bg.png" />
  460. </div>
  461. <div class="info_text">
  462. <div id="infoName" class="info_name"></div>
  463. <div id="infoDsc" class="info_dsc"></div>
  464. </div>
  465. </div>
  466. </div>
  467. </div>
  468. <img class="send_btn" id="sendBtn" src="./img/send-btn.png" mode="widthFix" />
  469. </div>
  470. <div id="dialogText" class="dialog_text">
  471. <div class="dialog-body">
  472. <div class="text_bg">
  473. <img class="close-text" id="closeText" src="./img/close-text.png" mode="widthFix" />
  474. <div style="position: relative;margin-top: 42rem;">
  475. <textarea class="textarea_style" id="textarea"></textarea>
  476. <div class="textarea_placeHolder" id="textareaPlaceHolder">说出您和宝骏汽车的故事,为宝骏云海新车上市送上祝福</div>
  477. </div>
  478. <div class="img_list">
  479. <div id="imageGallery" class="imageGallery">
  480. <img class="photo-btn" id="photoBtn" src="./img/photo-btn.png" mode="widthFix"
  481. onclick="uploadImage()" />
  482. <input type="file" id="uploadfile" style="display: none;" multiple accept='image/*'>
  483. </div>
  484. </div>
  485. </div>
  486. <button class="send_text" onclick="handleSendText()">发送</button>
  487. </div>
  488. </div>
  489. </div>
  490. <!-- 二维码 -->
  491. <div id="qrcode" class="qrcode">
  492. <img id="qrcode-img" class="qrcode-img" src="" />
  493. <div id="qrcode-msg" class="qrcode-msg"></div>
  494. </div>
  495. <script>
  496. let httpUrl = true // 初始化时请求地址为真则是正式环境,否则是测试环境
  497. let h5Type = null
  498. let credentials = {
  499. bucket: '',
  500. Authorization: '',
  501. secretId: '',
  502. serverDomain: ''
  503. }
  504. let imgList = []
  505. var itemList = []
  506. var itemIndex = 0
  507. var itemTimer = null
  508. var shareTitle = null
  509. var shareDes = null
  510. var shareCover = null
  511. function uploadImage () {
  512. let uploaInput = document.getElementById('uploadfile');
  513. document.getElementById('uploadfile').click();
  514. // 当用户上传时触发事件
  515. uploaInput.onchange = function() {
  516. readFile(this);
  517. }
  518. //处理图片并添加都dom中的函数
  519. let readFile = function(obj) {
  520. // 获取input里面的文件组
  521. let fileList = obj.files;
  522. //对文件组进行遍历,可以到控制台打印出fileList去看看
  523. for (let i = 0; i < fileList.length; i++) {
  524. var formData = new FormData();
  525. formData.append('path', fileList[i].name)
  526. formData.append('file', fileList[i])
  527. // 显示上传中状态
  528. const gallery = document.getElementById('imageGallery');
  529. const photoBtn = document.getElementById('photoBtn');
  530. const upload = document.createElement('div');
  531. upload.className = 'upload-class';
  532. upload.innerHTML = '上传中...'
  533. gallery.insertBefore(upload, photoBtn);
  534. let url = credentials.serverDomain + '/open/v1/file/upload'
  535. mui.ajax(url, {
  536. data: formData,
  537. processData: false,
  538. contentType: false,
  539. type: 'post',
  540. headers: {
  541. 'bucket': credentials.bucket,
  542. 'Authorization': credentials.authorization,
  543. 'secretId': credentials.secretId,
  544. },
  545. success: function(res) {
  546. imgList.push(res.data.url)
  547. const img = document.createElement('img');
  548. img.className = 'upload-img';
  549. img.src = res.data.url;
  550. gallery.insertBefore(img, photoBtn);
  551. gallery.removeChild(upload);
  552. },
  553. error: function(error) {
  554. //异常处理;
  555. console.log(error);
  556. }
  557. });
  558. }
  559. }
  560. }
  561. window.onload = function() {
  562. if (httpUrl) {
  563. httpUrl = 'https://wlapi.wefanbot.com'
  564. } else {
  565. httpUrl = 'http://test.wefanbot.com:18993'
  566. }
  567. if (localStorage.getItem('openId') || getQueryParam('openId')) {
  568. if (!getQueryParam('externalUserid')) {
  569. let bId = getQueryParam('bId')
  570. gerQwAuth(bId);
  571. } else {
  572. if (isUnknownType(getQueryParam('externalUserid'))) {
  573. let bId = getQueryParam('bId')
  574. gerQwCode(bId);
  575. } else {
  576. h5Type = getQueryParam('h5Type')
  577. if (h5Type == 20) {
  578. findCollectList()
  579. document.getElementById('collectPage').style.display = "block"
  580. }
  581. getQyWxSign()
  582. }
  583. }
  584. } else {
  585. // 走授权操作
  586. getAuth();
  587. }
  588. };
  589. // 内容类型的分享页,获取企业微信的签名
  590. function getQyWxSign () {
  591. let shareUrl = `${window.location.origin}?bId=${getQueryParam('bId')}&h5Type=${getQueryParam('h5Type')}`
  592. mui.ajax(httpUrl + '/scrm/v1/ct-share/p/getSignature', {
  593. data: {
  594. url: window.location.href
  595. },
  596. dataType: 'json',//服务器返回json格式数据
  597. type: 'get',//HTTP请求类型
  598. success: function(res) {
  599. if (res.code === 1) {
  600. wx.config({
  601. debug: false,
  602. appId: res.data.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
  603. timestamp: res.data.timestamp, // 必填,生成签名的时间戳
  604. nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
  605. signature: res.data.signature, // 必填,签名,见附录1
  606. jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'] // 必填,需要使用的JS接口列表
  607. })
  608. // 分享接口仅激活的成员数超过200人且已经认证的企业才可在微信上调用。
  609. wx.ready(() => {
  610. let shareData = {
  611. link: shareUrl,
  612. title: getQueryParam('h5Type') == 19 ? shareTitle : '寻找可靠的伙伴——宝骏14周年车主故事征集', // 分享标题
  613. desc: getQueryParam('h5Type') == 19 ? shareDes : '暨宝骏云海新车上市500万车主送祝福有奖活动,说出你和宝骏的故事', // 分享描述
  614. imgUrl: getQueryParam('h5Type') == 19 ? shareCover : 'http://wfg-1631.oss.wefanbot.com/imgUrl.jpg',
  615. }
  616. // 分享到朋友圈
  617. wx.updateAppMessageShareData(shareData)
  618. // 分享给朋友
  619. wx.updateTimelineShareData(shareData);
  620. // 配置失败的回调函数
  621. wx.error(function(res) {
  622. // 配置失败
  623. console.log('配置失败', res);
  624. })
  625. })
  626. }
  627. },
  628. error: function(error) {
  629. //异常处理;
  630. console.log(error);
  631. }
  632. })
  633. }
  634. // 公众号授权,获取code
  635. function getAuth () {
  636. // 获取url上的code
  637. let code = getQueryParam('code')
  638. if (code) {
  639. let bId = getQueryParam('bId')
  640. mui.ajax(httpUrl + '/scrm/v1/mp-client/p/getInfoByh5Code', {
  641. data: {
  642. code: code,
  643. bId: bId,
  644. },
  645. dataType: 'json',//服务器返回json格式数据
  646. type: 'get',//HTTP请求类型
  647. success: function(res) {
  648. h5Type = res.data.h5Type
  649. localStorage.setItem('openId', res.data.openId)
  650. if (h5Type == 20) {
  651. document.getElementById('collectPage').style.display = "block"
  652. document.getElementById('lotteryPage').style.display = "none"
  653. // if (!res.data.externalUserid) {
  654. // 进行下一步企微授权
  655. gerQwAuth(bId);
  656. // }
  657. }
  658. },
  659. error: function(error) {
  660. //异常处理;
  661. console.log(error);
  662. }
  663. });
  664. } else {
  665. let redirect_uri = window.location.href
  666. // code 不存在,走微信网页授权逻辑
  667. let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
  668. window.location.replace(url)
  669. }
  670. };
  671. // 企微授权
  672. function gerQwAuth (bId) {
  673. let link = window.location.href
  674. mui.ajax(httpUrl + '/p/insuite/p/getOAUrl', {
  675. data: {
  676. bId: bId,
  677. openId: localStorage.getItem('openId') || getQueryParam('openId'),
  678. },
  679. dataType: 'json',//服务器返回json格式数据
  680. type: 'get',//HTTP请求类型
  681. success: function(res) {
  682. if (res.data) {
  683. window.location.replace(res.data)
  684. } else {
  685. mui.toast(res.msg);
  686. }
  687. },
  688. error: function(error) {
  689. //异常处理;
  690. console.log(error);
  691. }
  692. });
  693. };
  694. // 获取二维码
  695. function gerQwCode (bId) {
  696. mui.ajax(httpUrl + '/scrm/v1/wxcp-raffle/p/getUnknown', {
  697. data: {
  698. bId: bId,
  699. externalUserId: getQueryParam('externalUserid'),
  700. },
  701. dataType: 'json',//服务器返回json格式数据
  702. type: 'get',//HTTP请求类型
  703. success: function(res) {
  704. if (res.data) {
  705. document.getElementById('qrcode').style.display = "block"
  706. document.getElementById("qrcode-img").src = res.data.qrCode
  707. document.getElementById("qrcode-msg").innerHTML = res.data.msg
  708. } else {
  709. mui.toast(res.msg);
  710. }
  711. },
  712. error: function(error) {
  713. //异常处理;
  714. console.log(error);
  715. }
  716. });
  717. }
  718. function getCosObj () {
  719. mui.ajax('https://saasapi.wefango.com/scrm/v1/oss/p/getAuthorization', {
  720. data: {
  721. },
  722. dataType: 'json',//服务器返回json格式数据
  723. type: 'post',//HTTP请求类型
  724. headers: { 'Content-Type': 'application/json' },
  725. success: function(res) {
  726. credentials = res.data.info
  727. // 用正则将this.credentials.serverDomain链接中的协议与当前域名的协议保持一致
  728. credentials.serverDomain = credentials.serverDomain.replace(/https:|http:/g, document.location.protocol)
  729. console.log('credentials2', credentials);
  730. },
  731. error: function(error) {
  732. //异常处理;
  733. console.log(error);
  734. }
  735. });
  736. };
  737. // 发送祝福
  738. function handleSendText () {
  739. let bId = getQueryParam('bId')
  740. let textareaResult = document.getElementById("textarea").value;
  741. mui.ajax(httpUrl + '/scrm/v1/mp-collect/p/add', {
  742. data: {
  743. bId: bId,
  744. openId: localStorage.getItem('openId') || getQueryParam('openId'),
  745. content: textareaResult,
  746. imgList: imgList,
  747. },
  748. dataType: 'json',//服务器返回json格式数据
  749. type: 'post',//HTTP请求类型
  750. headers: { 'Content-Type': 'application/json' },
  751. success: function(res) {
  752. if (res.code == 1) {
  753. mui.toast('发送成功');
  754. document.getElementById('dialogText').style.display = 'none';
  755. imgList = []
  756. document.getElementById("textarea").value = "";
  757. document.getElementById('textareaPlaceHolder').innerHTML = '说出您和宝骏汽车的故事,为宝骏云海新车上市送上祝福';
  758. findCollectList()
  759. const gallery = document.getElementById('imageGallery');
  760. // 遍历gallery的所有子元素
  761. var imgsToRemove = gallery.querySelectorAll('img.upload-img');
  762. // 遍历找到的元素并移除它们
  763. imgsToRemove.forEach(function(img) {
  764. gallery.removeChild(img);
  765. });
  766. } else {
  767. mui.toast(res.msg);
  768. }
  769. },
  770. error: function(error) {
  771. //异常处理;
  772. console.log(error);
  773. }
  774. });
  775. };
  776. // 获取用户故事收集列表
  777. function findCollectList () {
  778. mui.ajax(httpUrl + '/scrm/v1/mp-collect/p/findCollectList', {
  779. data: {
  780. },
  781. dataType: 'json',//服务器返回json格式数据
  782. type: 'get',//HTTP请求类型
  783. success: function(res) {
  784. if (res.code == 1) {
  785. itemList = res.data || []
  786. itemIndex = 0
  787. onShowItem()
  788. } else {
  789. mui.toast(res.msg);
  790. }
  791. },
  792. error: function(error) {
  793. //异常处理;
  794. console.log(error);
  795. }
  796. });
  797. };
  798. function getRandomArbitrary (min, max) {
  799. return Math.floor(Math.random() * (max - min) + min);
  800. }
  801. function showItem (data) {
  802. var showItem = document.getElementById('showItem')
  803. var infoName = document.getElementById('infoName')
  804. var infoDsc = document.getElementById('infoDsc')
  805. var avatar = document.getElementById('avatar')
  806. avatar.src = data.avatar
  807. infoName.innerText = data.clientName
  808. infoDsc.innerText = data.content
  809. var X = getRandomArbitrary(15, 125)
  810. if (data.imgList && data.imgList.length) {//有图片
  811. showItem.classList.add("show_img_item")
  812. var infoImg = document.getElementById('infoImg')
  813. infoImg.src = data.imgList[0]
  814. var Y = getRandomArbitrary(175, 208)
  815. } else {//无图片
  816. showItem.classList.remove("show_img_item")
  817. var Y = getRandomArbitrary(15, 157)
  818. }
  819. showItem.style.cssText = `top: ${Y}rem; left: ${X}rem;`
  820. showItem.classList.add("add_animation_item")
  821. setTimeout(() => {
  822. showItem.classList.remove("add_animation_item")
  823. }, 3500)
  824. }
  825. function onShowItem () {
  826. if (itemTimer) {
  827. clearTimeout(itemTimer)
  828. itemTimer = null
  829. }
  830. if (itemList.length) {
  831. var data = itemList[itemIndex]
  832. showItem(data)
  833. if (itemIndex < itemList.length - 1) {
  834. itemIndex++
  835. } else {
  836. itemIndex = 0
  837. }
  838. itemTimer = setTimeout(() => {
  839. onShowItem()
  840. }, 4000)
  841. }
  842. }
  843. document.getElementById('sendBtn').addEventListener('click', function() {
  844. document.getElementById('dialogText').style.display = 'block';
  845. if (itemTimer) {
  846. clearTimeout(itemTimer)
  847. itemTimer = null
  848. }
  849. // 获取腾讯COS对象存储的实例对象
  850. getCosObj();
  851. });
  852. document.getElementById('closeText').addEventListener('click', function() {
  853. document.getElementById('dialogText').style.display = 'none';
  854. imgList = []
  855. const gallery = document.getElementById('imageGallery');
  856. // 遍历gallery的所有子元素
  857. var imgsToRemove = gallery.querySelectorAll('img.upload-img');
  858. // 遍历找到的元素并移除它们
  859. imgsToRemove.forEach(function(img) {
  860. gallery.removeChild(img);
  861. });
  862. document.getElementById("textarea").value = "";
  863. document.getElementById('textareaPlaceHolder').innerHTML = '说出您和宝骏汽车的故事,为宝骏云海新车上市送上祝福';
  864. onShowItem()
  865. });
  866. document.getElementById('textarea').addEventListener('focus', function() {
  867. document.getElementById('textareaPlaceHolder').innerHTML = '';
  868. });
  869. document.getElementById('textarea').addEventListener('blur', function() {
  870. if (document.getElementById('textarea').value == '') {
  871. document.getElementById('textareaPlaceHolder').innerHTML = '说出您和宝骏汽车的故事,为宝骏云海新车上市送上祝福';
  872. }
  873. });
  874. document.getElementById('textareaPlaceHolder').addEventListener('click', function() {
  875. document.getElementById('textarea').focus();
  876. })
  877. // 截取url中的数据
  878. function getQueryParam (paramName) {
  879. // 获取当前URL的查询字符串部分
  880. const queryString = window.location.search;
  881. // 创建一个URLSearchParams对象
  882. const urlParams = new URLSearchParams(queryString);
  883. // 返回指定参数的值,如果不存在则返回null
  884. return urlParams.get(paramName);
  885. };
  886. function isUnknownType(value) {
  887. // 1. 先检查是否为字符串类型
  888. // 2. 再检查是否以"unknown"开头(区分大小写)
  889. return typeof value === 'string' && value.startsWith('unknown');
  890. };
  891. </script>
  892. </body>
  893. </html>