notice-center.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>消息中心-创业帮</title>
  6. <meta name="keywords" content="消息中心-创业帮">
  7. <meta name="description" content="消息中心-创业帮">
  8. <meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,shrink-to-fit=no,user-scalable=no" name="viewport" viewport="cover">
  9. <meta name="apple-mobile-web-app-capable" content="yes">
  10. <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  11. <meta content="telephone=no" name="format-detection">
  12. <meta content="email=no" name="format-detection">
  13. <meta name="apple-mobile-web-app-title" content="消息中心-创业帮">
  14. <meta http-equiv="Cache-Control" content="no-siteapp">
  15. <link rel="stylesheet" href="./static/css/main.css">
  16. </head>
  17. <body class="bgcf7f7f7 pt0" style="padding-top:0;">
  18. <div id="app">
  19. <van-nav-bar class="mall_title bottom_line" title="消息中心" v-if="tabsisshow"></van-nav-bar>
  20. <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
  21. <div style="height:80vh;">
  22. <van-cell-group class="notice-center">
  23. <van-cell class="cm" is-link @click="systemnotice">
  24. <template #title><img class="notice-center-img vm" src="./static/images/notice-btn1@2x.png" alt=""><span class="f14 c333 pl6">系统消息</span></template>
  25. <template #right-icon>
  26. <van-tag class="cm" type="warning" round v-if="unreadnoticenum.PlacardCount &gt; 0">{{unreadnoticenum.PlacardCount}}</van-tag>
  27. <van-icon name="arrow"></van-icon>
  28. </template>
  29. </van-cell>
  30. <van-cell class="cm" is-link @click="personalnotice">
  31. <template #title><img class="notice-center-img vm" src="./static/images/notice-btn2@2x.png" alt=""><span class="f14 c333 pl6">个人消息</span></template>
  32. <template #right-icon>
  33. <van-tag class="cm" type="warning" round v-if="unreadnoticenum.PersonalCount &gt; 0">{{unreadnoticenum.PersonalCount}}</van-tag>
  34. <van-icon name="arrow"></van-icon>
  35. </template>
  36. </van-cell>
  37. </van-cell-group>
  38. </div>
  39. </van-pull-refresh>
  40. <van-tabbar v-model="active" active-color="#333" inactive-color="#999" v-cloak v-if="tabsisshow">
  41. <van-tabbar-item icon="home-o" @click="index">首页
  42. <template #icon="props"><img :src="props.active ? icon1.active : icon1.inactive"></template>
  43. </van-tabbar-item>
  44. <van-tabbar-item icon="search" @click="mall">商城
  45. <template #icon="props"><img :src="props.active ? icon2.active : icon2.inactive"></template>
  46. </van-tabbar-item>
  47. <van-tabbar-item icon="friends-o" :dot="isnotice">消息
  48. <template #icon="props"><img :src="props.active ? icon3.active : icon3.inactive"></template>
  49. </van-tabbar-item>
  50. <van-tabbar-item icon="setting-o" @click="user">我的
  51. <template #icon="props"><img :src="props.active ? icon4.active : icon4.inactive"></template>
  52. </van-tabbar-item>
  53. </van-tabbar>
  54. </div>
  55. <script src="./static/js/klm-vv.min.js"></script>
  56. <script src="./static/js/appfunc.min.js"></script>
  57. <script src="./static/js/klm-axios-config.js"></script>
  58. <script src="./static/js/publicfn.js"></script>
  59. <script>
  60. function OnStart(){
  61. app.getnoticecount();
  62. };
  63. // 通过 CDN 引入时不会自动注册 Lazyload 组件
  64. // 可以通过下面的方式手动注册
  65. Vue.use(vant.Lazyload);
  66. //- PublicLib.SetStatusBarBgColor({bgcolor:'ffffff'});
  67. // 在 #app 标签下渲染一个按钮组件
  68. let app = new Vue({
  69. el: '#app',
  70. data() {
  71. return {
  72. active: 2,
  73. unreadnoticenum:{
  74. PersonalCount:0,
  75. PlacardCount:0,
  76. },
  77. icon1: {
  78. active: './static/images/tab-icon1-active1@3x.png',
  79. inactive: './static/images/tab-icon1-no@3x.png',
  80. },
  81. icon2: {
  82. active: './static/images/tab-icon2-active1@3x.png',
  83. inactive: './static/images/tab-icon2-no@3x.png',
  84. },
  85. icon3: {
  86. active: './static/images/tab-icon3-active1@3x.png',
  87. inactive: './static/images/tab-icon3-no@3x.png',
  88. },
  89. icon4: {
  90. active: './static/images/tab-icon4-active1@3x.png',
  91. inactive: './static/images/tab-icon4-no@3x.png',
  92. },
  93. tabsisshow:false,
  94. isLoading:false,
  95. };
  96. },
  97. created() {
  98. this.tabsisshow = bottomtabisshow;
  99. this.getnoticecount();
  100. },
  101. computed:{
  102. isnotice:function(){
  103. if(this.unreadnoticenum.PersonalCount !== 0 || this.unreadnoticenum.PlacardCount !== 0){
  104. PublicLib.putCookieInfo('noticeiscount', true);
  105. } else {
  106. PublicLib.putCookieInfo('noticeiscount', "");
  107. };
  108. return PublicLib.getCookieInfo('noticeiscount') !== "";
  109. }
  110. },
  111. methods: {
  112. SetBadgeValue(num){
  113. const type = browsertype.versions.ios ? 'ios' : 'android';
  114. if (type !== 'ios') {
  115. Func.SetBadgeValue('2',String(num));
  116. } else {
  117. window.webkit.messageHandlers.SetBadgeValue.postMessage({Index:2,BadgeNum:Number(num)});
  118. }
  119. },
  120. ClearBadgeValue(){
  121. const type = browsertype.versions.ios ? 'ios' : 'android';
  122. if (type !== 'ios') {
  123. Func.ClearBadgeValue('2');
  124. } else{
  125. window.webkit.messageHandlers.ClearBadgeValue.postMessage({Index:2});
  126. }
  127. },
  128. async onRefresh(){
  129. await this.getnoticecount();
  130. this.isLoading = false;
  131. },
  132. //- 跳转商城
  133. mall(){
  134. PublicLib.Goto({Url:'mall'});
  135. },
  136. //- 跳转主页
  137. index(){
  138. PublicLib.Goto({Url:'index'});
  139. },
  140. //- 跳转我的
  141. user(){
  142. PublicLib.Goto({Url:'user-center'});
  143. },
  144. //- 跳转系统消息
  145. systemnotice(){
  146. PublicLib.putCookieInfo('noticeType', '系统消息');
  147. PublicLib.Goto({Url:'notice-list'});
  148. },
  149. //- 跳转个人消息
  150. personalnotice(){
  151. PublicLib.putCookieInfo('noticeType', '个人消息');
  152. PublicLib.Goto({Url:'notice-list'});
  153. },
  154. //- 活动页面
  155. goactive(){
  156. PublicLib.Goto({Url:'market-active'});
  157. },
  158. //- 获取消息数量
  159. async getnoticecount(){
  160. //- PublicLib.ShowLoading({Message:''});
  161. const UserId = PublicLib.getCookieInfo('userId');
  162. const res = await getRequest('api/v1/msgplacard/notread?t='+Math.random(6),JSON.stringify({UserId}));
  163. if(res.status === '1'){
  164. //- PublicLib.HideLoading();
  165. this.unreadnoticenum = res.data;
  166. if(PublicLib.getCookieInfo('userId') === '14'){
  167. const count = res.data.PersonalCount + res.data.PlacardCount;
  168. if(count > 0){
  169. this.SetBadgeValue(count);
  170. }else{
  171. this.ClearBadgeValue();
  172. };
  173. };
  174. };
  175. }
  176. }
  177. });
  178. </script>
  179. </body>
  180. </html>