App.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <div style="width:100%; height: 100%; position: relative;">
  3. <vc-keep-alive :ignorePaths="ignorePaths" :ignoreParams="ignoreParams">
  4. <router-view style="width:100%;height:100%"></router-view>
  5. </vc-keep-alive>
  6. </div>
  7. </template>
  8. <script>
  9. import Vue from 'vue';
  10. import FastClick from 'fastclick'
  11. import VcKeepAlive from 'vc-keep-alive';
  12. Vue.use(VcKeepAlive);
  13. export default {
  14. name: 'App',
  15. data() {
  16. return {
  17. ignorePaths:['/help_detail'],
  18. ignoreParams:[]
  19. };
  20. },
  21. methods: {
  22. IsPC() {
  23. var userAgentInfo = navigator.userAgent;
  24. var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
  25. var flag = true;
  26. for (var v = 0; v < Agents.length; v++) {
  27. if (userAgentInfo.indexOf(Agents[v]) > 0) {
  28. flag = false;
  29. break;
  30. }
  31. }
  32. return flag;
  33. },
  34. // 检查更新
  35. get_ver() {
  36. let self = this
  37. if (!window.plus) {
  38. return false
  39. }
  40. plus.runtime.getProperty(plus.runtime.appid, function(inf) {
  41. wgtVer = inf.version
  42. if (!localStorage.getItem('a-token-temp')) {
  43. return false
  44. }
  45. if (plus.webview.currentWebview().id != plus.runtime.appid) {
  46. return false
  47. }
  48. self.$axios('post', '/api/version/check', {
  49. version: wgtVer.toString()
  50. }).then((res) => {
  51. self.info = res.data.data
  52. if (res.data.code == 1) {
  53. if (res.data.data.status) {} else {
  54. self.downWgt(res.data.data.new_version.app_path)
  55. }
  56. }
  57. })
  58. })
  59. },
  60. downWgt(wgtUrl) {
  61. let self = this;
  62. plus.downloader.createDownload(wgtUrl, {
  63. filename: '_doc/update/'
  64. }, function(d, status) {
  65. if (status == 200) {
  66. self.$removeCache('user_info');
  67. self.installWgt(d.filename);
  68. }
  69. }).start();
  70. },
  71. installWgt(path) {
  72. plus.runtime.install(path, {
  73. force: true
  74. },
  75. function() {
  76. plus.runtime.restart()
  77. },
  78. function(e) {
  79. plus.runtime.restart()
  80. }
  81. )
  82. },
  83. // 缓存选择周数据
  84. getColumns() {
  85. let columns = [];
  86. for (let i = 2020; i < 2051; i++) {
  87. let obj = {
  88. value: i,
  89. text: i.toString() + '年',
  90. children: this.cycleTypeArr(i)
  91. }
  92. columns.push(obj)
  93. }
  94. this.$setCache('weekArr', columns);
  95. },
  96. cycleTypeArr(year) {
  97. let options = [{
  98. text: '1月'
  99. },
  100. {
  101. text: '2月'
  102. },
  103. {
  104. text: '3月'
  105. },
  106. {
  107. text: '4月'
  108. },
  109. {
  110. text: '5月'
  111. },
  112. {
  113. text: '6月'
  114. },
  115. {
  116. text: '7月'
  117. },
  118. {
  119. text: '8月'
  120. },
  121. {
  122. text: '9月'
  123. },
  124. {
  125. text: '10月'
  126. },
  127. {
  128. text: '11月'
  129. },
  130. {
  131. text: '12月'
  132. },
  133. ];
  134. options.forEach((e, index) => {
  135. let week_count = this.getWeeks(year, index + 1);
  136. e.children = this.returnWeekArr(week_count)
  137. })
  138. return options;
  139. },
  140. returnWeekArr(count) {
  141. if (count == 4) {
  142. return [{
  143. text: '第一周'
  144. }, {
  145. text: '第二周'
  146. }, {
  147. text: '第三周'
  148. }, {
  149. text: '第四周'
  150. }]
  151. } else {
  152. return [{
  153. text: '第一周'
  154. }, {
  155. text: '第二周'
  156. }, {
  157. text: '第三周'
  158. }, {
  159. text: '第四周'
  160. }, {
  161. text: '第五周'
  162. }]
  163. }
  164. },
  165. getWeeks(year, month) {
  166. var d = new Date();
  167. // 该月第一天
  168. d.setFullYear(year, month - 1, 1);
  169. var w1 = d.getDay();
  170. if (w1 == 0) w1 = 7;
  171. // 该月天数
  172. d.setFullYear(year, month, 0);
  173. var dd = d.getDate();
  174. // 第一个周一
  175. let d1;
  176. if (w1 != 1) d1 = 7 - w1 + 2;
  177. else d1 = 1;
  178. let week_count = Math.ceil((dd - d1 + 1) / 7);
  179. return week_count;
  180. },
  181. init() {
  182. if (!this.$getCache('weekArr')) { //缓存周信息
  183. this.getColumns();
  184. }
  185. // 是否是安卓
  186. if (navigator.userAgent.indexOf('Android') > 0) {
  187. this.$setCache('isAndroid', true)
  188. } else {
  189. this.$setCache('isAndroid', false)
  190. }
  191. // 是否是需要兼容IOS特殊机型 // 下边横杠兼容
  192. if (window.plus) {
  193. plus.navigator.setStatusBarStyle('light');
  194. plus.runtime.setBadgeNumber(0); //清除角标
  195. var str = window.plus.device.model;
  196. // console.log("iPhone",str)
  197. if (str.indexOf('iPhone') >= 0) {
  198. if (
  199. str === 'iPhone4' ||
  200. str === 'iPhone4s' ||
  201. str === 'iPhone5' ||
  202. str === 'iPhone5c' ||
  203. str === 'iPhone5s' ||
  204. str === 'iPhone6' ||
  205. str === 'iPhone6 Plus' ||
  206. str === 'iPhone6s' ||
  207. str === 'iPhone6s Plus' ||
  208. str === 'iPhone SE' ||
  209. str === 'iPhone7' ||
  210. str === 'iPhone7 Plus' ||
  211. str === 'iPhone8' ||
  212. str === 'iPhone8 Plus'
  213. ) {
  214. this.$setCache('iPhone', false);
  215. } else {
  216. this.$setCache('iPhone', true);
  217. }
  218. }
  219. }
  220. },
  221. },
  222. mounted() {
  223. if (process.env.NODE_ENV == 'production') {
  224. // if (this.IsPC()) {
  225. // this.$router.replace({name: 'error'}); // 提示去APP端
  226. // return false
  227. // } else {
  228. this.get_ver(); //热更新
  229. // }
  230. }
  231. },
  232. created() {
  233. document.documentElement.style.backgroundColor = '#26A2FF';
  234. FastClick.attach(document.body); //300毫秒点击问题
  235. window.sessionStorage.setItem('__VCKEEPALIVE__', JSON.stringify(['/','/home']))
  236. window.sessionStorage.setItem('routers', '/');
  237. this.init()
  238. }
  239. };
  240. </script>
  241. <style>
  242. html,
  243. body {
  244. height: 100%;
  245. margin: 0;
  246. padding: 0;
  247. }
  248. #app {
  249. width: 100%;
  250. margin: 0 auto;
  251. height: 100%;
  252. }
  253. .suspendButton {
  254. height: 1.3rem;
  255. width: 1.3rem;
  256. /*1.3 如果碰到滑动问题,请检查 z-index。z-index需比web大一级*/
  257. z-index: 999;
  258. position: fixed;
  259. bottom: 1.3rem;
  260. right: 0.1rem;
  261. border-radius: 50%;
  262. background-color: rgb(38 161 255);
  263. color: #fff;
  264. touch-action: none;
  265. }
  266. .yuanqiu {
  267. font-size: 0.2rem;
  268. text-align: center;
  269. position: relative;
  270. top: 50%;
  271. transform: translate(0, -50%);
  272. }
  273. </style>