Jelajahi Sumber

调整了检测蓝牙的步骤

yerong 4 tahun lalu
induk
melakukan
daa4f8c911
3 mengubah file dengan 68 tambahan dan 27 penghapusan
  1. 36 11
      src/components/banner.vue
  2. 29 16
      src/pages/competition/index.vue
  3. 3 0
      src/pages/start/index.vue

+ 36 - 11
src/components/banner.vue

@@ -1,38 +1,63 @@
 <template>
   <div id="banner_container">
-    <img src="https://img.shuimuai.com/web/banner1.png" class="full_img main_banner" alt="">
-    <button class="cu-btn bg-yellow text-white join_button" @click="to_none">关于水母星球</button>
+    <!--    <img src="https://img.shuimuai.com/mp/banners/banner1%402x.png" class="full_img main_banner" alt="">-->
+    <swiper class="screen-swiper round-dot full_img main_banner" :indicator-dots="true" :circular="true"
+            :autoplay="true" interval="5000" duration="500">
+      <swiper-item v-for="(item,index) in banners" :key="index" class="full_img main_banner">
+        <img :src="item.src" mode="aspectFill" class="full_img main_banner">
+        <button class="cu-btn bg-yellow text-white join_button" @click="to_none(item.url)">{{
+            item.button_text
+          }}
+        </button>
+      </swiper-item>
+    </swiper>
   </div>
 </template>
 
 <script>
-  import {getBannerList} from "../requests/user";
+import {getBannerList} from "../requests/user";
 
-  var $this;
+var $this;
 export default {
   name: "banner",
-  data(){
+  data() {
     return {
-      banners:[]
+      banners: [
+        {
+          id: 1,
+          src: "https://img.shuimuai.com/mp/banners/banner1%402x.png",
+          url: '/pages/none/main',
+          button_text: '关于水母星球'
+        },
+        {
+          id: 2,
+          src: "https://img.shuimuai.com/mp/banners/banner3%402x.png",
+          url: '/pages/competition/main',
+          button_text: '比赛详情'
+        }
+      ]
     }
   },
   methods: {
-    to_none() {
+    to_none($url) {
       mpvue.navigateTo({
-        url: "/pages/none/main"
+        url: $url
       })
     },
     getBanners() {
       getBannerList().then((res) => {
         let $res = res.data
-        console.log($res.data)
+        let $activities = $res.data
+        let $new_act = $activities.pop()
+        console.log($new_act)
+        $this.banners[1].url = '/pages/competition/main?activity_id=' + $new_act['activity_id']
       })
     }
   },
-  mounted(){
+  mounted() {
     $this.getBanners()
   },
-  created(){
+  created() {
     $this = this;
   }
 }

+ 29 - 16
src/pages/competition/index.vue

@@ -1,6 +1,7 @@
 <template>
   <!-- 图片前缀 https://img.shuimuai.com/ -->
-  <scroll-view id="index_container" @scroll="onListenScroll" scroll-y style="height: 100%;">
+  <scroll-view id="index_container" @scroll="onListenScroll" scroll-y style="height: 100%;"
+               :scroll-into-view="scroll_id" scroll-y>
     <!--    死底部分-->
     <div class="index_container">
 
@@ -8,7 +9,7 @@
       <van-row>
         <van-col :span="12">
 
-          <div class="userinfo " :class="{not_show:userinfo.user_id == false}">
+          <div class="userinfo " :class="{not_show:!userinfo.user_id}">
             <van-row>
               <van-col :span="5">
                 <van-image :src="userinfo.portrait" width="32px" height="32px"></van-image>
@@ -288,7 +289,7 @@
 
                 <!--      特等奖        -->
                 <view class="gold_award_container last_sort" v-if="item.prize==0">
-                  <van-row >
+                  <van-row>
                     <van-col span="2" offset="9" class="">
                       <van-image :src="item.portrait" alt="" class="avatar" width="25px" height="25px"></van-image>
                     </van-col>
@@ -420,7 +421,8 @@ export default {
       },
       icon_show: false,
       // 是否悬浮
-      is_fixed: false
+      is_fixed: false,
+      scroll_id: ''
     }
   },
   watch: {
@@ -455,10 +457,10 @@ export default {
     to_info() {
       if (!$this.userinfo.user_id) {
         Toast.fail({
-          message:'请登录水母智脑小程序后进行参与比赛',
-          onClose(){
+          message: '请登录水母智脑小程序后进行参与比赛',
+          onClose() {
             wx.navigateTo({
-              url:"/pages/index/main"
+              url: "/pages/index/main"
             })
           }
         })
@@ -487,14 +489,14 @@ export default {
 
     //跳转比赛信息位置
     to_rank() {
-      window.location.href = '#rank_container'
+      $this.scroll_id = 'rank_container'
     },
     //时间产生变化时
     onTimeChange($e) {
-      $this.timeData = $e.mp.detail
-      for (let $key in $e) {
-        if ($e[$key].toString().length == 1) {
-          $e[$key] = "0" + $e[$key]
+      let $datetime =  $this.timeData = $e.mp.detail
+      for (let $key in $datetime) {
+        if ($datetime[$key].toString().length == 1) {
+          $datetime[$key] = "0" + $datetime[$key]
         }
       }
     },
@@ -586,20 +588,29 @@ export default {
       //计算倒计时
       // 获取比赛结束日
       let $time_result = cal_down_time($time)
+      console.log($time_result)
       $this.complete_time = $time_result.differ
     },
     //监听滚动
     onListenScroll(event) {
       let $scrollTop = event.mp.detail.scrollTop
       $this.is_fixed = $scrollTop > 400
+      $this.scroll_id = ''
     }
   },
   mounted() {
+    reload_userinfo($this)
+    let $userinfo = wx.getStorageSync('userinfo')
+    //检查用户是否参与比赛了
+    checkJoined($this.activity_id, $userinfo.user_id).then((res) => {
+      let $res = res.data;
+      let $data = $res.data;
+      $this.joined = $data['match_status'] == 1
+    })
   },
   created() {
     $this = this;
     //获取浏览器信息
-    reload_userinfo($this)
   },
   onLoad($options) {
     $this.activity_id = $options.activity_id
@@ -807,7 +818,7 @@ page {
 }
 
 .diy_container .rank_container .rank_main .rank_main_list .my_score .rank_item {
-  display: flex;
+  /*display: flex;*/
 }
 
 .diy_container .rank_container .rank_main .rank_main_list .my_score .rank_item .rank_num {
@@ -1069,12 +1080,14 @@ page {
 .rank_header {
   padding: 0px 25px;
 }
-.last_sort{
+
+.last_sort {
   padding: 10px 0px;
 }
 
-.last_sort_ext{
+.last_sort_ext {
   padding: 10px;
 }
+
 /*# sourceMappingURL=diy.css.map */
 </style>

+ 3 - 0
src/pages/start/index.vue

@@ -220,6 +220,9 @@ export default {
       })
     },
     start_game() {
+      wx.setKeepScreenOn({
+        keepScreenOn: true
+      })
       bluetooth.watchingDevice($this)
       bluetooth.sendControl($this._deviceId, $this._serviceId, $this._characteristicId)
     },