App-Android(使用App+htnl5框架,解决消息推送兼容SignalR问题)
loulijun2021
2022-10-21 0ab4bf8f3982bdee9962076f29c5664185328517
pages/xtsy/index.html
@@ -20,8 +20,19 @@
      <script type="text/javascript" src="../../js/http.js"></script>
      <script type="text/javascript" src="../../js/global.js"></script>
      <script type="text/javascript" src="../../js/global.css"></script>
      <!-- <script src="http://121.196.36.24:8001/Scripts/jquery-3.4.1.min.js"></script>
       <script src="http://121.196.36.24:8001/Scripts/jquery.signalR-2.2.2.min.js"></script>
       <script src="http://121.196.36.24:8001/SignalR/Hubs"></script> -->
      <script src="../../js/jquery-3.4.1.min.js"></script>
      <script src="../../js/jquery.signalR-2.2.2.min.js"></script>
      <script src="../../js/Hubs.js"></script>
      <script type="text/javascript" src="../../js/msg.js"></script>
   </head>
   <body>
@@ -77,34 +88,36 @@
            </van-nav-bar>
            <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
               <van-swipe :autoplay="3000">
                  <van-swipe-item v-for="(image, index) in images" :key="index">
                     <img v-lazy="image" :src='image' style="background-size: 100% 100%;width: 100%;" />
                  </van-swipe-item>
               </van-swipe>
            <van-swipe :autoplay="3000">
               <van-swipe-item v-for="(image, index) in images" :key="index">
                  <img v-lazy="image" :src='image' style="background-size: 100% 100%;width: 100%;" />
               </van-swipe-item>
            </van-swipe>
            <van-grid :gutter="20" :border='false' square :column-num="3" style="margin: 30px auto 0; width: 90%;">
               <van-grid-item v-for="item in firstMenu" @click='vanGridItem(item)' :key="item" :text="item.name">
                  <img :src="item.imgurl" alt=""
                     style="width: 56px;height:56px;margin-top: 10px;border-radius: 10px;">
                  <div style="margin-top: 5px;font-size: 14px;color: #929399;">{{item.name}}</div>
               </van-grid-item>
            </van-grid>
            <van-action-sheet lazy-render :closeable='false' close-on-click-action close-on-click-overlay
               safe-area-inset-bottom v-model="sheetShow" :title="firstMenuName">
               <van-grid :border='false' :gutter="5" square :column-num="3" style="width: 80%; margin: auto;">
                  <van-grid-item v-for="item in secondMenu" @click='vanGridSecondItem(item)' :key="item"
                     icon="photo-o">
               <van-grid :gutter="20" :border='false' square :column-num="3"
                  style="margin: 30px auto 0; width: 90%;">
                  <van-grid-item v-for="item in firstMenu" @click='vanGridItem(item)' :key="item"
                     :text="item.name">
                     <img :src="item.imgurl" alt=""
                        style="width: 48px;height:48px;margin-top: 10px;border-radius: 10px;">
                     <div style="margin-top: 5px;font-size: 12px;color: #929399;">{{item.name}}</div>
                        style="width: 56px;height:56px;margin-top: 10px;border-radius: 10px;">
                     <div style="margin-top: 5px;font-size: 14px;color: #929399;">{{item.name}}</div>
                  </van-grid-item>
               </van-grid>
            </van-action-sheet>
         </div>
               <van-action-sheet lazy-render :closeable='false' close-on-click-action close-on-click-overlay
                  safe-area-inset-bottom v-model="sheetShow" :title="firstMenuName">
                  <van-grid :border='false' :gutter="5" square :column-num="3" style="width: 80%; margin: auto;">
                     <van-grid-item v-for="item in secondMenu" @click='vanGridSecondItem(item)' :key="item"
                        icon="photo-o">
                        <img :src="item.imgurl" alt=""
                           style="width: 48px;height:48px;margin-top: 10px;border-radius: 10px;">
                        <div style="margin-top: 5px;font-size: 12px;color: #929399;">{{item.name}}</div>
                     </van-grid-item>
                  </van-grid>
               </van-action-sheet>
         </div>
         </van-pull-refresh>
         <van-overlay :show="overlayShow" @click="overlayShow=false" />
@@ -116,6 +129,7 @@
         el: '#app',
         data: function() {
            return {
               isLoading: false, //下拉刷新
               images: [
                  '../../static/images/swiper01.png',
                  '../../static/images/swiper02.png',
@@ -149,23 +163,39 @@
         },
         mounted() {
            this.getfirstMenu()
            this.getLoginAppAnDonMessage()
            setInterval(() => {
               this.getLoginAppAnDonMessage()
            }, 1000 * 10)
         },
         methods: {
            onRefresh() {
               setTimeout(() => {
                  vant.Toast('刷新成功');
                  this.getfirstMenu()
                  this.getLoginAppAnDonMessage()
                  // vant.Notify('刷新成功');
                  this.isLoading = false;
               }, 1000);
            },
            // 获取消息接口
         async   getLoginAppAnDonMessage(){
               const data={
                  userid:localStorage.getItem('userid'),
                  usercode:localStorage.getItem('usercode'),
                  username:localStorage.getItem('username'),
                  usertype:localStorage.getItem('usertype'),
            async getLoginAppAnDonMessage() {
               const data = {
                  userid: localStorage.getItem('userid'),
                  usercode: localStorage.getItem('usercode'),
                  username: localStorage.getItem('username'),
                  usertype: localStorage.getItem('usertype'),
               }
               const res=await post('Login/LoginAppAnDonMessage'+formatParams(data))
               this.messageNumber=res.data.length
               const res = await post('Login/LoginAppAnDonMessage' + formatParams(data))
               this.messageNumber = res.data.length
               // this.messageNumber=9
            },
            // 获取一级菜单
            async getfirstMenu() {
               const data = {