infotp.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. <template>
  2. <view class="">
  3. <view class="" @touchmove.stop.prevent="a = false" @catchtouchmove="a = false" v-show="!loadFlag">
  4. <view class="" style="">
  5. <swiper style="height: 100vh;width: 100vw;" :circular="true" @change="swiperChange" :current="activeCurrent">
  6. <swiper-item v-for="(item,index) in detail.images" :key="index">
  7. <image :src="item" @click="cssClick" style="height: 100vh;width: 100vw;display: flex;" mode="aspectFill"></image>
  8. </swiper-item>
  9. </swiper>
  10. </view>
  11. <view class="bottom" :class="cssTran ? 'closeCss' : 'openCss'" v-if="!loadFlag">
  12. <view class="num">{{indexCurrent}} / {{detail.imageslength}}</view>
  13. <view class="nav-box">
  14. <view class="nav-tab" @click="backClick">
  15. <image style="width: 50upx; height: 50upx;" :src="staticUrl+'back.png'"></image>
  16. <text style="font-size: 24upx;">返回</text>
  17. </view>
  18. <view class="nav-tab" @click="collectClick()">
  19. <image style="width: 50upx; height: 50upx;" :src="isColl?staticUrl+'coll_art.png':staticUrl+'coll.png'"></image>
  20. <text style="font-size: 24upx;">{{isColl?'已收藏':'收藏'}}</text>
  21. </view>
  22. <view class="nav-tab" @click="winClick(detail._id)">
  23. <image style="width: 50upx; height: 50upx;" :src="staticUrl+'duihuan.png'"></image>
  24. <text style="font-size: 24upx;">下载</text>
  25. </view>
  26. <view class="nav-tab" @click="zanClick()">
  27. <image style="width: 50upx; height: 50upx;" :src="isZan?staticUrl+'zan_art.png':staticUrl+'zan.png'"></image>
  28. <text style="font-size: 24upx;">{{isZan?'已点赞':'点赞'}}</text>
  29. </view>
  30. <view class="nav-tab">
  31. <image style="width: 50upx; height: 50upx;" :src="staticUrl+'shares.png'"></image>
  32. <text style="font-size: 24upx;">分享</text>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- <view v-if="tipsShow" style="position: absolute;top: 0;left: 0;width: 100vw;height: 100vh;z-index: 11;" @click="tipsClick">
  37. <image src="../../static/tips.png" style="width: 100%;height: 100%;display: flex;" mode="aspectFill"></image>
  38. </view> -->
  39. </view>
  40. <view class="loading_page" v-show="loadFlag"></view>
  41. <pop
  42. ref="pop"
  43. direction="center"
  44. :is_close="true"
  45. :is_mask="true"
  46. :width="90"
  47. height="fit-content"
  48. :maskFun="true"
  49. @watchOpen="watchOpen"
  50. @watchClose="watchClose"
  51. >
  52. <view>
  53. <text class="ffdfgg" v-if="detail.isplay>0" @click="opdownloadFile()">下载</text>
  54. <text class="ffdfgg" v-else @click="duihss()">¥{{price}} 兑换下载</text>
  55. <!-- #ifdef MP-WEIXIN -->
  56. <text class="ffdfgg" @click="adClick()">看广告获取积分</text>
  57. <!-- #endif -->
  58. </view>
  59. </pop>
  60. </view>
  61. </template>
  62. <script>
  63. import pop from "@/components/ming-pop/ming-pop.vue";
  64. let videoAd = null;
  65. var w = uni.getSystemInfoSync().windowWidth;
  66. var h = uni.getSystemInfoSync().windowHeight;
  67. export default {
  68. components: {
  69. pop
  70. },
  71. data() {
  72. return {
  73. loadFlag: true,
  74. loginShow: false,
  75. detail: {},
  76. staticUrl:'',
  77. adIntegral: 0,
  78. downShow: false,
  79. downIntegral: 0,
  80. downTitle: '',
  81. downBtn: '',
  82. adShow: false,
  83. isColl: false,
  84. isZan: false,
  85. zanStatus: true,
  86. collStatus: true,
  87. cssTran: false,
  88. indexCurrent: 1,
  89. activeCurrent: 0,
  90. id: 0,
  91. mid: 0,
  92. isplaytext:'',
  93. price:0,
  94. signShow: false,
  95. signTitle: '',
  96. w: w,
  97. h: h,
  98. }
  99. },
  100. onLoad(e) {
  101. this.staticUrl=this.configs.staticUrl
  102. var that = this
  103. var index =0
  104. that.indexCurrent = parseInt(index)+1
  105. that.activeCurrent = parseInt(index)
  106. that.loadFlag = false
  107. if(e.id){
  108. this.id=e.id
  109. this.getinfo(this.id)
  110. }
  111. },
  112. onShow() {
  113. // #ifdef APP-PLUS
  114. plus.navigator.setFullscreen(true);
  115. // #endif
  116. },
  117. onHide() {
  118. // #ifdef APP-PLUS
  119. plus.navigator.setFullscreen(false);
  120. // #endif
  121. },
  122. onUnload(){
  123. // #ifdef APP-PLUS
  124. plus.navigator.setFullscreen(false);
  125. // #endif
  126. },
  127. methods: {
  128. getinfo(id) {
  129. uni.showLoading({
  130. title: '加载中'
  131. });
  132. let data = {};
  133. data.id=id
  134. data.mid=this.mid
  135. if(uni.getStorageSync("userinfo").token){
  136. data.token=uni.getStorageSync("userinfo").token
  137. this.isLogin = true
  138. }
  139. uni.request({
  140. url: this.configs.webUrl+'/api/video/infotp',
  141. data: data,
  142. success: data => {
  143. uni.hideLoading();
  144. if(uni.getStorageSync("userinfo").token){
  145. if(data.data.isvip>1){
  146. this.price=data.data.vipprice
  147. }else{
  148. this.price=data.data.price
  149. }
  150. }else{
  151. this.price=data.data.price
  152. }
  153. data.data.pricebuy=this.price
  154. //this.info=[];
  155. //this.info=data.data
  156. this.detail = data.data
  157. this.adLoad()
  158. if(data.data.isvip>1){
  159. if(data.data.vipprice*1==0){
  160. this.isplaytext='VIP免费'
  161. }
  162. }else{
  163. if(data.data.price*1==0){
  164. this.isplaytext='免费视频'
  165. }
  166. }
  167. },
  168. fail: (data, code) => {
  169. uni.hideLoading();
  170. }
  171. });
  172. },
  173. async getIsZan(){
  174. let count = await uniCloud.callFunction({
  175. name: 'query_count',
  176. data: {
  177. dbName: "wx_cover",
  178. filter: {
  179. "_id": this.detail._id,
  180. "zan.user_id": this.vuex_user._id
  181. }
  182. },
  183. })
  184. this.zanStatus = false
  185. if(count.result > 0) this.isZan = true
  186. },
  187. async getIsColl(){
  188. let count = await uniCloud.callFunction({
  189. name: 'query_count',
  190. data: {
  191. dbName: "wx_cover",
  192. filter: {
  193. "_id": this.detail._id,
  194. "coll.user_id": this.vuex_user._id
  195. }
  196. },
  197. })
  198. this.collStatus = false
  199. if(count.result > 0) this.isColl = true
  200. },
  201. opdownloadFile(){
  202. var that=this
  203. uni.showLoading({
  204. title: '正在保存图片'
  205. });
  206. // 获取图片信息
  207. var url = that.detail.images[that.indexCurrent-1]
  208. var extension = url.substring(url.lastIndexOf('.') + 1)
  209. let fileName = new Date().valueOf();
  210. console.log(url)
  211. uni.downloadFile({
  212. url: url,
  213. //filePath: wx.env.USER_DATA_PATH + '/' + fileName + '.' + extension,
  214. success: (res) => {
  215. var benUrl = res.tempFilePath
  216. console.log(res)
  217. //图片保存到本地相册
  218. uni.saveImageToPhotosAlbum({
  219. filePath: benUrl,
  220. //授权成功,保存图片
  221. success: function(data) {
  222. uni.hideLoading()
  223. uni.showModal({
  224. title: '温馨提示',
  225. content: '保存成功',
  226. showCancel: false,
  227. success(res) {
  228. if (res.confirm) {
  229. }
  230. }
  231. });
  232. },
  233. //授权失败
  234. fail: function(err) {
  235. if (err.errMsg) {
  236. console.log(err.errMsg)
  237. //重新授权弹框确认
  238. uni.showModal({
  239. title: '提示',
  240. content: '无权限,请打开下载权限后再试!',
  241. showCancel: false,
  242. success(res) {
  243. if (res.confirm) {
  244. //重新授权弹框用户点击了确定
  245. uni.openSetting({
  246. //进入小程序授权设置页面
  247. success(settingdata) {
  248. if (settingdata.authSetting['scope.writePhotosAlbum']) {
  249. //用户打开了保存图片授权开关
  250. uni.saveImageToPhotosAlbum({
  251. filePath: benUrl,
  252. success: function(data) {
  253. uni.hideLoading()
  254. that.adShow = true
  255. }
  256. });
  257. } else {
  258. //用户未打开保存图片到相册的授权开关
  259. uni.showModal({
  260. title: '温馨提示',
  261. content: '授权失败,请稍后重新获取',
  262. showCancel: false
  263. });
  264. }
  265. }
  266. });
  267. }
  268. }
  269. });
  270. }
  271. uni.hideLoading()
  272. }
  273. });
  274. },
  275. fail: (error) => {
  276. console.log(error)
  277. }
  278. })
  279. },
  280. winClick(){
  281. if(uni.getStorageSync("userinfo").id){
  282. }else{
  283. uni.showModal({
  284. title: '温馨提示',
  285. content: '请先登后下载',
  286. showCancel: true,
  287. confirmText: "确定",
  288. success: function (res) {
  289. if (res.confirm) {
  290. uni.navigateTo({
  291. url:'/pages/login/login'
  292. })
  293. } else if (res.cancel) {
  294. }
  295. }
  296. });
  297. return false;
  298. }
  299. var that = this
  300. var downIntegral=2
  301. if(this.detail.isplay == 0){
  302. this.$refs.pop.show();
  303. }else{
  304. this.opdownloadFile()
  305. }
  306. },
  307. backClick(){
  308. uni.navigateBack()
  309. },
  310. collectClick() {
  311. this.isColl=true
  312. uni.showToast({
  313. icon: 'none',
  314. title: '收藏成功',
  315. mask: true,
  316. duration: 1000
  317. })
  318. },
  319. zanClick(){
  320. this.isZan=true
  321. uni.showToast({
  322. icon: 'none',
  323. title: '点赞成功',
  324. mask: true,
  325. duration: 1000
  326. })
  327. },
  328. cssClick() {
  329. this.cssTran = !this.cssTran
  330. },
  331. swiperChange(e){
  332. this.indexCurrent = e.detail.current + 1
  333. },
  334. adClick(){
  335. var mrcs=3
  336. var mrcsjr=0
  337. if(uni.getStorageSync("config").mrcs && uni.getStorageSync("config").mrcsjr){
  338. mrcs=uni.getStorageSync("config").mrcs
  339. mrcsjr=uni.getStorageSync("config").mrcsjr
  340. }
  341. if(mrcsjr>=mrcs){
  342. uni.showModal({
  343. title: '温馨提示',
  344. content: '每日只能看'+mrcs+'次',
  345. showCancel: false,
  346. confirmText: "确定",
  347. success: function (res) {
  348. if (res.confirm) {
  349. //_this.dyxx()
  350. //uni.navigateBack();
  351. } else if (res.cancel) {
  352. }
  353. }
  354. });
  355. return false;
  356. }
  357. var that = this
  358. if (videoAd) {
  359. videoAd.show().catch(err => {
  360. // 失败重试
  361. // console.log("广告拉去失败")
  362. videoAd.load().then(() => videoAd.show())
  363. })
  364. }
  365. },
  366. adLoad(){
  367. console.log(this.detail.videoids);
  368. var that = this
  369. if (wx.createRewardedVideoAd) {
  370. // 加载激励视频广告
  371. // #ifdef MP-QQ
  372. videoAd = wx.createRewardedVideoAd({
  373. adUnitId: "cbe2baa6cdb9b4f2c75269d000476ee6"
  374. });
  375. // #endif
  376. // #ifdef MP-WEIXIN
  377. videoAd = wx.createRewardedVideoAd({
  378. adUnitId: that.detail.videoids//微信广告ID
  379. });
  380. // #endif
  381. //捕捉错误
  382. videoAd.onError(err => {
  383. // 进行适当的提示
  384. console.log('videoAd onError', err);
  385. });
  386. // 监听关闭
  387. videoAd.onClose(status => {
  388. that.downShow = false
  389. if ((status && status.isEnded) || status === undefined) {
  390. // 正常播放结束,下发奖励
  391. that.admoney()
  392. console.log('看完广告')
  393. } else {
  394. uni.showToast({
  395. icon: 'none',
  396. title: '播放中途退出,获取失败',
  397. mask: true,
  398. duration: 1000
  399. })
  400. // 播放中途退出,进行提示
  401. console.log('中途退出')
  402. }
  403. });
  404. }
  405. },
  406. async userIntegral(){
  407. var that = this
  408. uni.showLoading({
  409. mask: true,
  410. title: '加载中...'
  411. })
  412. let data = await uniCloud.callFunction({
  413. name: 'user_integral',
  414. data: {
  415. userId: that.vuex_user._id
  416. },
  417. })
  418. uni.hideLoading()
  419. if(data.result.success){
  420. that.getUser()
  421. that.signTitle = "<p style='font-weight: 550;font-size: 16px;'>观看成功</p><p style='padding-top: 10px;'>获得<span class='num'>"+data.result.integral+"</span>积分</p>"
  422. that.signShow = true
  423. }
  424. },
  425. watchOpen(){},
  426. watchClose(){},
  427. async admoney(){
  428. var this_=this
  429. let data = {};
  430. if(uni.getStorageSync("userinfo").token){
  431. data.token=uni.getStorageSync("userinfo").token
  432. }
  433. let [err,res] =await this.$httpas.get('/api/user/admoney',data);
  434. if (!this.$httpas.errorCheck(err,res)) return;
  435. if(res.data.code === 1){
  436. uni.setStorage({//缓存配置信息
  437. key: 'config',
  438. data: res.data.data
  439. })
  440. uni.showModal({
  441. title: '温馨提示',
  442. content: '获取成功 是否马上兑换',
  443. showCancel: true,
  444. confirmText: "兑换",
  445. success: function (ress) {
  446. if (ress.confirm) {
  447. this_.duihss()
  448. } else if (ress.cancel) {
  449. }
  450. }
  451. });
  452. }else{
  453. uni.showToast({ title: '获取失败',icon:"none" });
  454. }
  455. },
  456. duihss(){
  457. var this_=this
  458. let data=this.detail;
  459. data.sum=1;
  460. data.buytype='余额';
  461. data.lx=1;//1 全章购买 2单集购买
  462. data.smid=0;
  463. data.namet=data.name
  464. data.pricebuy=data.price
  465. data.token = uni.getStorageSync("userinfo").token;
  466. data.uid = uni.getStorageSync("userinfo").id;
  467. console.log(data);
  468. //return false;
  469. uni.request({
  470. url: this.configs.webUrl+'/api/pay/videopay',
  471. data: data,
  472. success: resa =>{
  473. //console.log(resa.data);
  474. if(data.buytype=='微信'){
  475. if(this.wxlx=='wxxcx' && resa.data.code==1){
  476. //console.log(resa.data.code);
  477. this.wxxcx(resa.data.data);
  478. }else{
  479. // #ifdef APP-PLUS
  480. uni.navigateTo({
  481. url:'/pages/client/webva?url='+resa.data.data
  482. })
  483. //plus.runtime.openURL(res.data.data);
  484. // #endif
  485. // #ifdef H5
  486. window.open(resa.data.data, "_self")
  487. // #endif
  488. }
  489. }else if(data.buytype=='余额'){
  490. if(resa.data.code==1){
  491. //pages/user/task/task
  492. uni.showModal({
  493. title: '提示',
  494. content: '兑换成功',
  495. showCancel: false,
  496. success: res => {
  497. this_.getinfo(this.id)
  498. this_.$refs.pop.close();
  499. this_.opdownloadFile()
  500. }
  501. });
  502. }else{
  503. if(resa.data.msg=='余额不足'){
  504. uni.showModal({
  505. title: '提示',
  506. content: '余额不足,看广告可以获取',
  507. showCancel: true,
  508. confirmText: "看广告",
  509. success: res => {
  510. this_.adClick()
  511. }
  512. });
  513. }else{
  514. uni.showModal({
  515. title: '提示',
  516. content: resa.data.msg,
  517. showCancel: false,
  518. success: res => {
  519. uni.navigateBack();
  520. }
  521. });
  522. }
  523. }
  524. }
  525. //thia.okPay(resa)
  526. },
  527. fail: (data, code) => {
  528. console.log('fail' + JSON.stringify(data));
  529. }
  530. });
  531. },
  532. // 登录
  533. getUserInfo(){
  534. var that = this
  535. wx.getUserProfile({
  536. desc: '更新您的个人信息',
  537. success: (res) => {
  538. that.name = res.userInfo.nickName; //昵称
  539. that.avatar = res.userInfo.avatarUrl; //头像
  540. // 成功后进行登录,获取code
  541. that.wxlogin();
  542. },
  543. fail(err){
  544. uni.showToast({
  545. icon: 'none',
  546. title: '授权失败',
  547. duration: 1500
  548. })
  549. }
  550. })
  551. },
  552. //已经授权,自动登录
  553. async wxlogin() {
  554. let that = this;
  555. uni.showLoading({
  556. title: '登录中...'
  557. });
  558. uni.login({
  559. provider: 'weixin',
  560. success: function(loginRes) {
  561. let code = loginRes.code;
  562. that.wxloginres(code);
  563. },
  564. });
  565. },
  566. //登录后提交服务器获取进一步信息
  567. async wxloginres(wxcode) {
  568. let that = this;
  569. var userId = uni.getStorageSync('userId')
  570. var mptype
  571. // #ifdef MP-WEIXIN
  572. mptype = 'wx'
  573. // #endif
  574. // #ifdef MP-QQ
  575. mptype = 'qq'
  576. // #endif
  577. let authorize = await uniCloud.callFunction({
  578. name: 'user_authorize',
  579. data: {
  580. name: that.name,
  581. avatar: that.avatar,
  582. mptype: mptype,
  583. code: wxcode,
  584. userId: userId,
  585. },
  586. })
  587. if(authorize.result.success){
  588. that.$u.vuex('vuex_user',authorize.result.data)
  589. // 登陆成功 获取收藏点赞
  590. that.getIsZan()
  591. that.getIsColl()
  592. uni.showToast({
  593. icon: 'none',
  594. mask: true,
  595. title: '登录成功',
  596. duration: 1500
  597. })
  598. uni.removeStorageSync('userId')
  599. }else{
  600. uni.showToast({
  601. icon: 'none',
  602. mask: true,
  603. title: authorize.result.msg,
  604. duration: 1500
  605. })
  606. }
  607. that.loginShow = false
  608. },
  609. },
  610. onShareAppMessage(res) {
  611. var that = this
  612. setTimeout(function(){
  613. that.adShow = false
  614. },2000)
  615. return {
  616. title: '送你一张超级好看的壁纸~',
  617. imageUrl: that.detail.images[that.indexCurrent-1],
  618. path: '/pages/index/index?userId='+that.vuex_user._id+'&detailId='+that.detail._id+'&index='+(that.indexCurrent-1)
  619. }
  620. },
  621. onShareTimeline(res) {
  622. return {
  623. title: '我等风也等你,近听水无声~',
  624. imageUrl: '/static/share_bg.jpg',
  625. path: '/pages/index/index'
  626. }
  627. }
  628. }
  629. </script>
  630. <style lang="scss">
  631. .bottom {
  632. position: fixed;
  633. left: 4%;
  634. right: 0;
  635. width: 92%;
  636. height: 52px;
  637. box-shadow: 0 0px 8px rgba(0, 0, 0, 0.06);
  638. background: rgba(0, 0, 0, 0.94);
  639. border-radius: 49px;
  640. z-index: 10;
  641. opacity: 0.8;
  642. .num{
  643. position: absolute;
  644. top: -20rpx;
  645. top: -70rpx;
  646. left: 44%;
  647. background: rgba(0,0,0,0.6);
  648. color: #FFF;
  649. padding: 4rpx 20rpx;
  650. font-size: 12px;
  651. border-radius: 36px;
  652. }
  653. }
  654. .nav-tab {
  655. position: relative;
  656. width: 100%;
  657. height: 52px;
  658. font-size: 12px;
  659. color: #D8D8D8;
  660. font-weight: 400;
  661. display: flex;
  662. flex-direction: column;
  663. justify-content: center;
  664. align-items: center;
  665. }
  666. .nav-box {
  667. /* position: absolute; */
  668. display: flex;
  669. flex-direction: row;
  670. justify-content: space-around;
  671. width: 100%;
  672. box-sizing: border-box;
  673. }
  674. .openCss {
  675. animation-name: openLinear;
  676. animation-duration: 0.8s;
  677. animation-iteration-count: 1;
  678. bottom: 40px;
  679. }
  680. @keyframes openLinear {
  681. 0% {
  682. transform: translateY(92px);
  683. }
  684. 100% {
  685. transform: translateY(0px);
  686. }
  687. }
  688. .closeCss {
  689. animation-name: closeLinear;
  690. animation-duration: 0.8s;
  691. animation-iteration-count: 1;
  692. bottom: -52px;
  693. }
  694. .ffdfgg{
  695. font-size: 28upx;
  696. text-align: center;
  697. height: 100upx;
  698. line-height: 100upx;
  699. display: block;
  700. background: #00C657;
  701. color: #fff;
  702. border-radius: 10upx;
  703. margin-top: 20upx;
  704. }
  705. @keyframes closeLinear {
  706. 0% {
  707. transform: translateY(-92px);
  708. }
  709. 100% {
  710. transform: translateY(0px);
  711. }
  712. }
  713. .u-indicator-item-number {
  714. padding: 6rpx 16rpx;
  715. line-height: 1;
  716. background-color: rgba(0, 0, 0, 0.3);
  717. border-radius: 100rpx;
  718. font-size: 26rpx;
  719. color: rgba(255, 255, 255, 0.8);
  720. }
  721. </style>