viewRecords.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <template>
  2. <view class="container">
  3. <view class="header">
  4. <image src="../../static/images/skm_fn_bg.png" mode="aspectFill" class="bg-img"></image>
  5. <view class="info-block flex-row-between">
  6. <view class="info">
  7. <view class="title" :data-type="type">
  8. {{type==7?'游戏':type==6?'视频':type==1?'收款码':type==2?'公众号':type==4?'二维码':'网站'}}{{$test.$test}}</view>
  9. <view class="desc">{{$test.$desc}}</view>
  10. </view>
  11. <view class="btn" @click="setup">修改</view>
  12. </view>
  13. </view>
  14. <view class="main">
  15. <view class="page-title flex-row-between">
  16. <view class="title">推广详情</view>
  17. <view class="btn-block flex-row">
  18. <view class="name">使用</view>
  19. <switch :checked="info.state==2?false:true" @change="onChangeType" style="transform:scale(0.7)" />
  20. </view>
  21. </view>
  22. <view class="cell flex-row-start">
  23. <view class="name">二维码ID</view>
  24. <view class="content">{{info.code}}</view>
  25. </view>
  26. <view class="cell flex-row-start" v-if="info.url">
  27. <view class="name">访问地址</view>
  28. <view class="content">{{info.url}}</view>
  29. </view>
  30. <view class="cell flex-row-start" v-if="info.moshi">
  31. <view class="name">模式设置</view>
  32. <view class="content">{{info.moshi==1?'普通模式':'高级模式'}} <block v-if="info.moshi==2">-{{info.moshi_type==2?'时间方式':'轮询方式'}} </block></view>
  33. </view>
  34. <view class="cell flex-row-start">
  35. <view class="name">分享链接</view>
  36. <view class="content">{{info.qrurl}} <text @click="copy" style="color:#00BFFF;margin-left: 20rpx;">复制</text></view>
  37. </view>
  38. <view class="cell flex-row-start">
  39. <view class="name">{{$test.$test}}次数</view>
  40. <view class="content">{{info.scan_num}}次
  41. | <text style="color:#000;margin-left: 20rpx;" @click="detail(1)">查看明细</text>
  42. </view>
  43. </view>
  44. <block v-if="info.type!=7">
  45. <view class="cell flex-row-start">
  46. <view class="name">换量联盟</view>
  47. <view class="content" style="color:#000;">{{info.is_exchange=='Y'?'已加入':'未加入'}}</view>
  48. </view>
  49. <view class="cell flex-row-start">
  50. <view class="name">换量效益</view>
  51. <view class="content">{{info.exchange_num}}次
  52. | <text style="color:#000;margin-left: 20rpx;" @click="detail(2)">查看明细</text>
  53. </view>
  54. </view>
  55. </block>
  56. <view v-if="info.type==7" class="cell flex-row-start">
  57. <view class="name">游戏名称</view>
  58. <view class="content">{{info.game==1?'大转盘':'砸金蛋'}}
  59. </view>
  60. </view>
  61. <view class="cell flex-row-start">
  62. <view class="name">生成时间</view>
  63. <view class="content">{{info.create_time}}</view>
  64. </view>
  65. <view class="cell flex-row-start" v-if="info.description">
  66. <view class="name">{{$test.$test}}备注</view>
  67. <view class="content">{{info.description}}</view>
  68. </view>
  69. <image :src="info.qrcode" mode="aspectFit" class="code-img"></image>
  70. </view>
  71. <view class="btm-btn-block">
  72. <view class="content flex-row-between">
  73. <!-- #ifdef H5 -->
  74. <block v-if="type==1||type==4">
  75. <view class="btn btn22" @click="upCode">下载二维码</view>
  76. <view class="btn btn11" @click="setup" data-index="index">修改</view>
  77. </block>
  78. <block v-else>
  79. <view class="btn btn22" style="background: #07c160;color: #FFFFFF;" @click="Wechat">分享好友/朋友圈</view>
  80. <view class="btn btn11" @click="setup" data-index="index">修改</view>
  81. </block>
  82. <!-- #endif -->
  83. <!-- #ifdef MP-WEIXIN -->
  84. <block>
  85. <view class="btn btn22" @click="upCode">下载二维码</view>
  86. <view class="btn btn11" @click="setup" data-index="index">修改</view>
  87. </block>
  88. <!-- #endif -->
  89. </view>
  90. </view>
  91. <view class="model" @click="close" v-if="isdown">
  92. <view class="model-home">
  93. <image class="model-img" src="/static/images/jt.png" />
  94. <view>1.请点击右上角
  95. <block>选择分享好友或者朋友圈</block>
  96. </view>
  97. </view>
  98. <view class="model-close">
  99. 2.点击关闭遮盖层
  100. </view>
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. // #ifdef H5
  106. import getWXSign from "@/static/js/config.js";
  107. // #endif
  108. // #ifdef MP-WEIXIN
  109. import saveImgToPhotosAlbum from "@/static/js/saveImgToPhotosAlbum.js";
  110. // #endif
  111. export default {
  112. data() {
  113. return {
  114. $test: this.$test.$test,
  115. useing: false,
  116. info: {
  117. code: "",
  118. url: "",
  119. qrurl: "",
  120. qrurl: "",
  121. scan_num: "",
  122. create_time: "",
  123. description: "",
  124. },
  125. wx_content: {},
  126. type: 1,
  127. isdown: false,
  128. }
  129. },
  130. onLoad(e) {
  131. console.log(e, "e")
  132. this.card_num = e.card_num;
  133. this.type = Number(e.type);
  134. },
  135. onShow(e) {
  136. this.funeng_detail();
  137. },
  138. methods: {
  139. share(e) {
  140. var ua = navigator.userAgent.toLowerCase();
  141. if (ua.match(/MicroMessenger/i) == "micromessenger") {
  142. getWXSign().then(res => {
  143. if (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) {
  144. var imgUrl=this.wx_content.wximg_url?this.wx_content.wximg_url:getApp().globalData.URL + this.wx_content.wx_img;
  145. this.$wx.updateAppMessageShareData({
  146. title: this.wx_content.wx_title?this.wx_content.wx_title:"", // 分享标题
  147. desc: this.wx_content.wx_desc?this.wx_content.wx_desc:"", // 分享描述
  148. link: this.info.qrurl, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  149. imgUrl: imgUrl, // 分享图标
  150. success: (res) => {
  151. // 设置成功
  152. console.log("设置成功", res)
  153. }
  154. })
  155. this.$wx.updateTimelineShareData({
  156. title: this.wx_content.wx_title?this.wx_content.wx_title:"", // 分享标题
  157. link: this.info.qrurl, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  158. imgUrl: imgUrl, // 分享图标
  159. success: (res) => {
  160. // 设置成功
  161. console.log("设置成功", res)
  162. }
  163. })
  164. } else {
  165. this.$wx.onMenuShareTimeline({
  166. title: this.wx_content.wx_title?this.wx_content.wx_title:"", // 分享标题
  167. desc: this.wx_content.wx_desc?this.wx_content.wx_desc:"", // 分享描述
  168. link: this.info.qrurl, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  169. imgUrl:imgUrl, // 分享图标
  170. success: function() {
  171. // 用户点击了分享后执行的回调函数
  172. }
  173. })
  174. this.$wx.onMenuShareAppMessage({
  175. title: this.wx_content.wx_title?this.wx_content.wx_title:"", // 分享标题
  176. desc: this.wx_content.wx_desc?this.wx_content.wx_desc:"", // 分享描述
  177. link: this.info.qrurl, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  178. imgUrl:imgUrl, // 分享图标
  179. success: function() {
  180. // 用户点击了分享后执行的回调函数
  181. }
  182. })
  183. }
  184. })
  185. }
  186. },
  187. Wechat(e) {
  188. this.isdown = true;
  189. },
  190. close() {
  191. this.isdown = false;
  192. },
  193. copy(e) {
  194. // #ifdef MP-WEIXIN
  195. uni.setClipboardData({
  196. data: this.info.qrurl,
  197. success: function() {
  198. console.log('success');
  199. }
  200. });
  201. // #endif
  202. // #ifdef H5
  203. let content = this.info.qrurl;
  204. if (!document.queryCommandSupported('copy')) {
  205. // 不支持
  206. return false
  207. }
  208. let textarea = document.createElement("input")
  209. textarea.value = content
  210. textarea.readOnly = "readOnly"
  211. document.body.appendChild(textarea)
  212. textarea.select() // 选择对象
  213. textarea.setSelectionRange(0, content.length) //核心
  214. let result = document.execCommand("copy") // 执行浏览器复制命令
  215. textarea.remove();
  216. uni.showToast({
  217. title: "复制成功",
  218. icon: 'none'
  219. })
  220. return result
  221. // #endif
  222. },
  223. setup(e) {
  224. console.log("eeee", this.type)
  225. var type = this.type;
  226. let url =type==7 ?'/pages/index/games': type ==6 ?'/pages/index/video': type == 1 ? '/pages/index/enable' : type == 2 ? '/pages/index/public' : type == 4 ?
  227. '/pages/index/standard' : '/pages/index/article'
  228. uni.navigateTo({
  229. url: url + '?card_num=' + this.card_num,
  230. })
  231. },
  232. upCode(e) {
  233. // #ifdef H5
  234. uni.showModal({
  235. title: '提示',
  236. content: '请长按二维码图片进行保存',
  237. showCancel: false,
  238. confirmText: '好的',
  239. });
  240. // #endif
  241. // #ifdef MP-WEIXIN
  242. var url = this.info.qrcode;
  243. saveImgToPhotosAlbum.saveImgToPhotosAlbum(url).then((res) => {
  244. //成功的逻辑
  245. console.log(res, "保存成功")
  246. wx.showToast({
  247. title: '保存成功',
  248. icon: 'none',
  249. mask: true,
  250. })
  251. }).catch((err) => {
  252. console.log(err, "保存失败")
  253. if (err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" ||
  254. err.errMsg === "saveImageToPhotosAlbum:fail auth deny" || err.errMsg ===
  255. "saveImageToPhotosAlbum:fail authorize no response") {
  256. // 这边微信做过调整,必须要在按钮中触发,因此需要在弹框回调中进行调用
  257. uni.showModal({
  258. title: '提示',
  259. content: '需要您授权保存相册',
  260. showCancel: false,
  261. success: modalSuccess => {
  262. uni.openSetting({
  263. success(settingdata) {
  264. console.log("settingdata", settingdata)
  265. if (settingdata.authSetting['scope.writePhotosAlbum']) {
  266. uni.showModal({
  267. title: '提示',
  268. content: '获取权限成功,再次点击图片即可保存',
  269. showCancel: false,
  270. })
  271. } else {
  272. uni.showModal({
  273. title: '提示',
  274. content: '获取权限失败,将无法保存到相册哦~',
  275. showCancel: false,
  276. })
  277. }
  278. },
  279. fail(failData) {
  280. console.log("failData", failData)
  281. },
  282. complete(finishData) {
  283. console.log("finishData", finishData)
  284. }
  285. })
  286. }
  287. })
  288. }
  289. // 失败后的逻辑
  290. })
  291. // #endif
  292. },
  293. funeng_detail() {
  294. this.request({
  295. url:"funeng/funeng_detailnew",
  296. data: {
  297. card_num: this.card_num,
  298. token: uni.getStorageSync("token"),
  299. },
  300. }).then(res => {
  301. console.log(res, "res")
  302. if (res.code === '200') {
  303. this.info = res.data;
  304. this.wx_content = res.data;
  305. if (res.data.type==3&&!res.data.wx_title) {
  306. // #ifdef H5
  307. // this.Crawler(res.data.url);
  308. // #endif
  309. } else {
  310. console.log("res.data")
  311. // this.wx_content = res.data;
  312. if(res.data.type!=1){
  313. // #ifdef H5
  314. this.share();
  315. // #endif
  316. }
  317. }
  318. }
  319. });
  320. },
  321. Crawler(url){
  322. this.request({
  323. url:"Exchange/Crawler",
  324. data: {
  325. url: url,
  326. token: uni.getStorageSync("token"),
  327. },
  328. method:"GET",
  329. }).then(res => {
  330. console.log(res, "res")
  331. if (res.code === '200') {
  332. var wx_content = {
  333. wx_title: res.data.title,
  334. wx_desc: res.data.desc,
  335. wximg_url: res.data.img,
  336. }
  337. this.wx_content = wx_content;
  338. // #ifdef H5
  339. this.share();
  340. // #endif
  341. }
  342. }).catch((err)=>{
  343. console.log(err,"errr")
  344. // #ifdef H5
  345. this.share();
  346. // #endif
  347. });
  348. },
  349. detail(type) {
  350. uni.navigateTo({
  351. url: "../createRecordsDetail/createRecordsDetail?card_num=" + this.info.card_num+'&type='+type
  352. })
  353. },
  354. onChangeType(e) {
  355. console.log(e)
  356. this.request({
  357. url: "funeng/save_state",
  358. data: {
  359. code: this.info.code,
  360. state: e.detail.value ? 1 : 2
  361. },
  362. }).then(res => {
  363. console.log(res, "res")
  364. if (res.code === '200') {
  365. }
  366. });
  367. }
  368. }
  369. }
  370. </script>
  371. <style>
  372. .header {
  373. width: 100%;
  374. height: 198rpx;
  375. position: relative;
  376. }
  377. .header .bg-img {
  378. display: block;
  379. position: absolute;
  380. left: 0;
  381. top: 0;
  382. z-index:1;
  383. width: 100%;
  384. height: 198rpx;
  385. }
  386. .header .info-block {
  387. padding: 0 40rpx 0 48rpx;
  388. height: 198rpx;
  389. position: relative;
  390. z-index: 2;
  391. }
  392. .header .info-block .title {
  393. font-size: 36rpx;
  394. color: #fff;
  395. font-weight: 500;
  396. line-height: 50rpx;
  397. }
  398. .header .info-block .desc {
  399. font-size: 28rpx;
  400. font-weight: 500;
  401. color: #fff;
  402. line-height: 40rpx;
  403. margin-top: 8rpx;
  404. }
  405. .header .info-block .btn {
  406. width: 120rpx;
  407. height: 56rpx;
  408. border: 2rpx solid #fff;
  409. border-radius: 28rpx;
  410. background-color: rgba(255, 255, 255, 0.2);
  411. text-align: center;
  412. line-height: 52rpx;
  413. font-size: 28rpx;
  414. font-weight: 500;
  415. color: #fff;
  416. }
  417. .main {
  418. background-color: #fff;
  419. border-radius: 20rpx 20rpx 0 0;
  420. margin-top: -20rpx;
  421. padding: 20rpx 40rpx 0;
  422. z-index: 3;
  423. position: relative;
  424. }
  425. .main .page-title {
  426. padding: 28rpx 0 40rpx;
  427. }
  428. .main .page-title .title {
  429. font-size: 36rpx;
  430. color: #262626;
  431. line-height: 50rpx;
  432. font-weight: 600;
  433. }
  434. .main .page-title .btn-block .name {
  435. font-size: 28rpx;
  436. color: #7e7e7e;
  437. line-height: 50rpx;
  438. font-weight: 400;
  439. }
  440. .main .page-title .btn-block .switch-btn {
  441. width: 72rpx;
  442. height: 36rpx;
  443. border-radius: 18rpx;
  444. margin-left: 10rpx;
  445. position: relative;
  446. }
  447. .main .page-title .btn-block .switch-btn::before {
  448. content: "";
  449. display: block;
  450. width: 100%;
  451. height: 100%;
  452. background-color: #E8EEFF;
  453. border-radius: 18rpx;
  454. }
  455. .main .page-title .btn-block .switch-btn::after {
  456. content: "";
  457. display: block;
  458. width: 36rpx;
  459. height: 36rpx;
  460. background-color: #fff;
  461. border-radius: 18rpx;
  462. position: absolute;
  463. left: 0;
  464. top: 0;
  465. box-shadow: 0 0 20rpx #ccc;
  466. transition: all 0.3s ease-out;
  467. }
  468. .main .page-title .btn-block .switch-btn.checked::after {
  469. left: 36rpx;
  470. background-color: #3387FF;
  471. box-shadow: 0 0 20rpx #3387FF;
  472. }
  473. .main .cell {
  474. font-size: 30rpx;
  475. line-height: 42rpx;
  476. color: #666;
  477. margin-bottom: 24rpx;
  478. }
  479. .main .cell .name {
  480. flex: none;
  481. width: 176rpx;
  482. }
  483. .main .code-img {
  484. display: block;
  485. width: 400rpx;
  486. height: 400rpx;
  487. margin: 90rpx auto 126rpx;
  488. }
  489. .content {
  490. word-wrap: break-word;
  491. word-break: break-all;
  492. }
  493. .btm-btn-block .content {
  494. padding: 0 40rpx 90rpx;
  495. }
  496. .btm-btn-block .content .btn {
  497. flex: none;
  498. width: 325rpx;
  499. height: 98rpx;
  500. border-radius: 8rpx;
  501. text-align: center;
  502. line-height: 98rpx;
  503. font-size: 32rpx;
  504. font-weight: 500;
  505. }
  506. .btm-btn-block .content .btn11 {
  507. background: linear-gradient(315deg, #3387ff 2%, #569bff 99%);
  508. box-shadow: 0 0 8rpx 0 rgba(51, 135, 255, 0.2);
  509. color: #fff;
  510. }
  511. .btm-btn-block .content .btn22 {
  512. box-shadow: 0px 0px 8px 0px rgba(255, 255, 255, 0.4);
  513. color: #3387FF;
  514. }
  515. .model {
  516. position: fixed;
  517. width: 100%;
  518. height: 100%;
  519. left: 0;
  520. right: 0;
  521. top: 0;
  522. bottom: 0;
  523. margin: auto;
  524. z-index: 9999;
  525. background: rgba(0, 0, 0, 0.5);
  526. font-size: 18px;
  527. }
  528. .model-home {
  529. width: 135px;
  530. height: 100px;
  531. position: fixed;
  532. right: 24px;
  533. top: 32px;
  534. text-align: center;
  535. color: #FFFFFF;
  536. }
  537. .model-close {
  538. width: 100%;
  539. height: 100px;
  540. position: fixed;
  541. right: 24px;
  542. top: 200px;
  543. text-align: right;
  544. color: #FFFFFF;
  545. }
  546. .model-img {
  547. width: 50px;
  548. height: 50px;
  549. }
  550. </style>