testSubNvue.nvue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <view class="wrapper">
  3. <view class="container">
  4. <view class="jump">
  5. <text class="textSty" @click="send">{{i18n('CloseAD')}} {{date}}</text>
  6. </view>
  7. <view class="img">
  8. <image @click="toShow" :src="'http://172.16.1.159:9200/api/file/pub/' + url" mode="widthFix" alt="" width="100%"></image>
  9. <!-- <image src="@/static/img/index/guideAD.png" v-else mode="widthFix" alt="" width="100%"></image> -->
  10. </view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. data() {
  17. return {
  18. date:5,
  19. countDown:'',
  20. url:'',
  21. advertisiment:{},
  22. linkTo:'',
  23. lan:getApp().$i18n.locale,
  24. adverId:'',
  25. }
  26. },
  27. onReady() {
  28. // this.getAdver()
  29. this.insdate()
  30. },
  31. async onLoad(option) {
  32. await this.getAdver()
  33. },
  34. watch: {
  35. date(n,o) {
  36. if(n == 0){
  37. clearInterval(this.countDown)
  38. this.date = ''
  39. this.send()
  40. }
  41. }
  42. },
  43. beforeDestroy() {
  44. uni.$off('photo')
  45. },
  46. methods: {
  47. insdate(){
  48. if(this.date){
  49. this.countDown = setInterval(()=>{
  50. this.date -- ;
  51. },1000)
  52. }
  53. },
  54. send(){
  55. //获取当前子窗体的唯一id
  56. const subNVue = uni.getCurrentSubNVue()
  57. subNVue.hide()
  58. },
  59. async getAdver(){
  60. let res = await getApp().$myRequest({
  61. url:'/op/advertisementLocations/getAppAdvert',
  62. data:{
  63. position:'mobile_send',
  64. language:getApp().$i18n.locale
  65. }
  66. })
  67. let addver = res.data[0].list
  68. for(let i = 0;i < addver.length ;i++){
  69. if(getApp().$i18n.locale == addver[i].languageDict){
  70. this.url = addver[i].advPicUrl
  71. this.linkTo = addver[i].advPicLink;
  72. this.adverId = addver[i].id
  73. }
  74. }
  75. console.log(this.url)
  76. },
  77. i18n (data) {
  78. return getApp().$t('common.'+data);
  79. },
  80. toShow(){
  81. this.getClickNumber()
  82. if(this.linkTo){
  83. plus.runtime.openURL(this.linkTo)
  84. }else{
  85. return
  86. }
  87. },
  88. async getClickNumber(){
  89. let res = await getApp().$myRequest({
  90. url:'/op/advertisementLocations/getAppAdvert',
  91. data:{
  92. position:'mobile_send',
  93. advId:this.adverId
  94. }
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style scoped>
  101. .wrapper {
  102. /* width: 100%;
  103. margin: auto; */
  104. left: 0;
  105. right: 0;
  106. /* top: 0; */
  107. bottom: 0;
  108. position: relative;
  109. /* height: 90upx;
  110. padding: 0 28upx; */
  111. padding: 60% 50% 0 50%;
  112. }
  113. .container{
  114. margin-top: 50%;
  115. /* background-color: #ffff7f; */
  116. }
  117. .jump{
  118. width:240upx;
  119. height: 50upx;
  120. border-radius: 30upx;
  121. background-color:rgba(0,0,0,0.3) ;
  122. font-size: 24upx;
  123. text-align: center;
  124. color: #FFFFFF;
  125. position: absolute;
  126. top: 0;
  127. right: 0;
  128. }
  129. .img{
  130. position: relative;
  131. top:50upx;
  132. /* width: 100%; */
  133. /* height: calc(100% - 40upx); */
  134. }
  135. .textSty{
  136. color: #ffffff;
  137. text-align: center;
  138. line-height:50upx;
  139. }
  140. </style>