index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <script setup>
  2. import { ref, nextTick, onUnmounted, watch, onMounted } from "vue"
  3. const isShow = ref(true)
  4. const helpRef = ref(null)
  5. let videoAutoAd = null
  6. const impressions = ref(0)
  7. const impression_errors = ref(0)
  8. const openId = ref('')
  9. const isStart = ref(false)
  10. let timer1 = null
  11. uni.login({
  12. provider: 'weixin',
  13. success(res){
  14. uni.request({
  15. url: 'https://browse.test.caixiao365.com/userinfo',
  16. method: 'POST',
  17. data: { code: res.code },
  18. header: { 'content-type': 'application/json' },
  19. success(res){
  20. openId.value = res.data.data.openid
  21. }
  22. })
  23. }
  24. })
  25. function update(){
  26. const updateManager = wx.getUpdateManager();
  27. updateManager.onCheckForUpdate(function(res) {
  28. console.log(res, '~~🚀~~')
  29. console.log(res.hasUpdate);
  30. });
  31. updateManager.onUpdateReady(function() {
  32. wx.showModal({
  33. title: "更新提示",
  34. content: "新版本已经准备好,是否重启应用?",
  35. success: function(res) {
  36. if (res.confirm) {
  37. updateManager.applyUpdate();
  38. }
  39. },
  40. });
  41. });
  42. updateManager.onUpdateFailed(function() {
  43. // 新版本下载失败
  44. });
  45. }
  46. function start(){
  47. isStart.value = true
  48. uni.request({
  49. url: 'https://browse.test.caixiao365.com/browse',
  50. method: 'POST',
  51. data: { openId: openId.value, nickname: 'null', clicks: 1, impressions: 0, impression_errors: 0 },
  52. header: { 'content-type': 'application/json' },
  53. fail(err){ console.log('记录失败', err) }
  54. })
  55. helpRef.value.open()
  56. }
  57. let timer = null
  58. function timerStart(){
  59. timer = setInterval(() => {
  60. isShow.value = false
  61. nextTick(() => isShow.value = true)
  62. }, 10000)
  63. }
  64. timerStart()
  65. onUnmounted(() => {
  66. if(timer) window.clearInterval(timer)
  67. })
  68. function adLoad() {
  69. impressions.value = impressions.value + 1
  70. console.log('原生模板广告加载成功')
  71. }
  72. function adError(err) {
  73. impression_errors.value = impression_errors.value + 1
  74. console.error('原生模板广告加载失败', err)
  75. }
  76. function adClose() {
  77. console.log('原生模板广告关闭')
  78. }
  79. function stop(){
  80. isStart.value = false
  81. }
  82. onMounted(() => update())
  83. watch(() => [impression_errors.value, impressions.value], () => {
  84. if(impression_errors.value + impressions.value !== 7) return
  85. uni.request({
  86. url: 'https://browse.test.caixiao365.com/browse',
  87. method: 'POST',
  88. data: { openId: openId.value, nickname: 'null', clicks: 0, impressions: impressions.value, impression_errors: impression_errors.value },
  89. header: { 'content-type': 'application/json' },
  90. fail(err){ console.log('记录失败', err) }
  91. })
  92. impressions.value = 0;
  93. impression_errors.value = 0;
  94. })
  95. </script>
  96. <template>
  97. <view class="container">
  98. <div style="margin-bottom: 8px;min-height: 130px">
  99. <ad-custom v-if="isShow" unit-id="adunit-96241c9c228ed13c" @load="adLoad" @error="adError" @close="adClose"></ad-custom>
  100. </div>
  101. <div style="margin-bottom: 10px;">
  102. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;“喵缘礼堂”是一款专注于为猫咪结婚提供解决方案的应用。它以所有目标角色猫咪的势力总和作为基准,通过筛选备选角色猫咪,为用户匹配出其势力总和最接近目标角色猫咪势力总和的方案。
  103. </div>
  104. <div>
  105. <p style="font-weight: bold;margin-bottom: 10px">使用方法:</p>
  106. <p style="margin-bottom: 10px">1.录入目标猫咪势力数据,总数≤20 只,依次准确填写。</p>
  107. <p style="margin-bottom: 10px">2.输入备选猫咪势力数据,不同性别数均≤20 只,详细填写。</p>
  108. <p>3.点击 “计算最佳匹配方案”,系统将据此算出最适配方案。</p>
  109. </div>
  110. <div class="mask" v-if="isStart">
  111. <div class="help-modal" style="width: 98vw; height:calc(100vh - 180px);" >
  112. <div style="width:100%;display:flex;justify-content: flex-end;">
  113. <uni-icons type="closeempty" size="18" @click="stop"></uni-icons>
  114. </div>
  115. <div style="margin-bottom: 8px;min-height: 130px;width:100%">
  116. <ad-custom v-if="isShow" unit-id="adunit-99db11dec2f49ce6" @load="adLoad" @error="adError" @close="adClose"></ad-custom>
  117. </div>
  118. <div style="margin-bottom: 8px;min-height: 130px;width:100%">
  119. <ad-custom v-if="isShow" unit-id="adunit-cb8a5498725abe55" @load="adLoad" @error="adError" @close="adClose"></ad-custom>
  120. </div>
  121. <div style="margin-bottom: 8px;min-height: 130px;width:100%">
  122. <ad-custom v-if="isShow" unit-id="adunit-5c77f25f137c7abb" @load="adLoad" @error="adError" @close="adClose"></ad-custom>
  123. </div>
  124. <div style="margin-bottom: 8px;min-height: 130px;width:100%">
  125. <ad-custom v-if="isShow" unit-id="adunit-5c77f25f137c7abb" @load="adLoad" @error="adError" @close="adClose"></ad-custom>
  126. </div>
  127. <div style="position: absolute;top:200px;right:0px;z-index:999;opacity: 0.5">
  128. <ad-custom v-if="isShow" unit-id="adunit-c0538d202acf8b82" @load="adLoad" @error="adError" @close="adClose"></ad-custom>
  129. </div>
  130. <div style="position: absolute;top:200px;left:0px;z-index:999;opacity: 0.5">
  131. <ad-custom v-if="isShow" unit-id="adunit-a644feed6de76121" @load="adLoad" @error="adError" @close="adClose"></ad-custom>
  132. </div>
  133. </div>
  134. </div>
  135. <div style="margin-bottom: 10px;position: absolute;bottom: 0px;left:50%;transform:translate(-50%,-50%)">
  136. <button
  137. :plain="true"
  138. class="primary-btn"
  139. style="padding:1px;width:70px;margin:2px;height: 32px;font-size:14px;line-height: 32px;"
  140. @click="start"
  141. >
  142. 显示全部
  143. </button>
  144. </div>
  145. </view>
  146. </template>
  147. <style>
  148. .container {
  149. }
  150. .uni-popup__wrapper {
  151. width: 100%;
  152. }
  153. .help-modal {
  154. line-height: 24px;
  155. color: #2c3e50;
  156. }
  157. .primary-btn {}
  158. uni-button::after {
  159. /* display: none; */
  160. /* border: 0px solid rgb(224.6, 242.8, 215.6) !important; */
  161. /* border: 2px solid transparent !important; */
  162. }
  163. button {
  164. border: none !important;
  165. background: rgb(239.8, 248.9, 235.3) !important;
  166. color: #67c23a !important;
  167. outline: none !important;
  168. }
  169. .container {
  170. display: flex;
  171. justify-content: center;
  172. flex-direction: column;
  173. padding: 10px 20px;
  174. }
  175. .help-modal {
  176. line-height: 24px;
  177. color: #2c3e50;
  178. background: #fff;
  179. position: absolute;
  180. left: 50%;
  181. top: 50%;
  182. transform: translate(-50%, -50%);
  183. }
  184. .mask{
  185. position:fixed;
  186. background:rgba(0, 0, 0, 0.7);
  187. top: 0px;
  188. left: 0px;
  189. width: 100vw;
  190. height: 100vh;
  191. z-index: 10000;
  192. }
  193. </style>