App.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <style lang="scss">
  2. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  3. @import "uview-ui/index.scss";
  4. </style>
  5. <script>
  6. import store from "@/store";
  7. import socket from "@/config/socket";
  8. import DB from "@/common/sqlite";
  9. export default {
  10. onLaunch: function(e) {
  11. //取出缓存数据
  12. store.commit("setCacheData");
  13. if (store.state.token) {
  14. socket.init();
  15. } else {
  16. var url = window.location.href;
  17. if ((url.indexOf("pages/carInsure/payVerify") >
  18. 0) || (url
  19. .indexOf("pages/carInsure1/yonganCode") > 0)) {
  20. uni.navigateTo({
  21. url: url
  22. })
  23. } else {}
  24. }
  25. // #ifdef H5
  26. if (store.state.token) {
  27. socket.init();
  28. } else {
  29. var url = window.location.href;
  30. if ((url.indexOf("pages/carInsure/payVerify") >
  31. 0) || (url
  32. .indexOf("pages/carInsure1/yonganCode") > 0)) {
  33. uni.navigateTo({
  34. url: url
  35. })
  36. } else {
  37. }
  38. }
  39. // #endif
  40. // #ifdef APP-PLUS
  41. this.launch()
  42. if (store.state.token) {} else {
  43. var url = window.location.href;
  44. if ((url.indexOf("pages/carInsure/payVerify") >
  45. 0) || (url
  46. .indexOf("pages/carInsure1/yonganCode") > 0)) {
  47. uni.navigateTo({
  48. url: url
  49. })
  50. } else {
  51. }
  52. }
  53. // #endif
  54. },
  55. onShow: function(e) {
  56. // uni.authorize({
  57. // scope: 'scope.userLocation',
  58. // success() {
  59. // uni.getLocation()
  60. // }
  61. // })
  62. // uni.getLocation({
  63. // type: 'gcj02',
  64. // geocode: true,
  65. // success: function(res) {
  66. // console.log(res);
  67. // uni.setStorage({
  68. // key: 'location',
  69. // data: {
  70. // latitude: res.latitude,
  71. // longitude: res.longitude,
  72. // },
  73. // success: function() {
  74. // console.log('位置信息保存成功');
  75. // }
  76. // });
  77. // },
  78. // fail: function(err) {
  79. // console.log(err);
  80. // // #ifdef APP-PLUS
  81. // uni.showModal({
  82. // title: '提示',
  83. // content: '请打开定位服务',
  84. // success: ({
  85. // confirm,
  86. // cancel
  87. // }) => {
  88. // if (confirm) {
  89. // // android平台
  90. // if (uni.getSystemInfoSync().platform == 'android') {
  91. // var Intent = plus.android.importClass(
  92. // 'android.content.Intent');
  93. // var Settings = plus.android.importClass(
  94. // 'android.provider.Settings');
  95. // var intent = new Intent(Settings
  96. // .ACTION_LOCATION_SOURCE_SETTINGS);
  97. // var main = plus.android.runtimeMainActivity();
  98. // main.startActivity(intent); // 打开系统设置GPS服务页面
  99. // }
  100. // }
  101. // 用户取消前往开启定位服务
  102. // if (cancel) {
  103. // uni.navigateBack({ //uni.navigateTo跳转的返回,默认1为返回上一级
  104. // delta: 1
  105. // });
  106. // }
  107. // }
  108. // });
  109. // // #endif
  110. // }
  111. // });
  112. },
  113. onHide: function() {},
  114. methods: {
  115. // TODO 开屏广告 后续优化添加
  116. launch() {
  117. try {
  118. var date = new Date();
  119. var year = date.getFullYear();
  120. var month = date.getMonth() + 1;
  121. var strDate = date.getDate();
  122. var currentdate = year + '' + month + '' + strDate + '' + plus.runtime.version;
  123. // 获取本地存储中launchFlag标识(不可动)
  124. const value = uni.getStorageSync("launchFlag");
  125. if (value == currentdate) {} else {
  126. //app启动时打开启动广告页
  127. var w = plus.webview.open(
  128. "/hybrid/html/advertise/advertise.html",
  129. "本地地址", {
  130. top: 0,
  131. bottom: 0,
  132. zindex: 999,
  133. },
  134. "fade-in",
  135. 500
  136. );
  137. //设置定时器,4s后关闭启动
  138. setTimeout(function() {
  139. uni.setStorage({
  140. key: "launchFlag",
  141. data: currentdate
  142. });
  143. plus.webview.close(w);
  144. }, 3000);
  145. }
  146. } catch (e) {
  147. // error
  148. uni.setStorage({
  149. key: "launchFlag",
  150. data: currentdate,
  151. success: function() {
  152. console.log("error时存储launchFlag");
  153. },
  154. });
  155. }
  156. },
  157. }
  158. };
  159. </script>
  160. <style>
  161. /* #ifndef APP-NVUE */
  162. @import "/style/uni.css";
  163. /* 官方ui库 */
  164. /* @import "/style/animate.min.css"; */
  165. /* 第三方动画库 */
  166. @import "/style/icon.css";
  167. /* 自定义图标库 */
  168. /* @import 'https://at.alicdn.com/t/font_1807257_t3nqcuysmns.css'; */
  169. @import "/style/common.css";
  170. /* 公共样式库 */
  171. @import "/style/zcm-main.css";
  172. /* UI基础库 */
  173. /* @import "/style/input.scss"; */
  174. /* 基础表单样式*/
  175. /* #endif */
  176. /* #ifdef H5 */
  177. /* 修复H5底部导航挡住内容bug */
  178. uni-app {
  179. height: auto;
  180. }
  181. /* 修复H5输入框上下不居中bug */
  182. .uni-input-form {
  183. height: 100%;
  184. }
  185. /* 去除地图上高德地图标识符 */
  186. .amap-copyright {
  187. display: none !important;
  188. }
  189. .amap-logo {
  190. display: none !important;
  191. }
  192. .amap-ui-control-zoom {
  193. width: 60upx !important;
  194. }
  195. .amap-ui-control-zoom>* {
  196. width: 60upx !important;
  197. height: 60upx !important;
  198. line-height: 60upx !important;
  199. }
  200. .amap-ui-control-theme-dark {
  201. display: none !important;
  202. }
  203. /* #endif */
  204. </style>