App.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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.indexOf("pages/login/mimi") > 0) || (url.indexOf("pages/login/xieyi") > 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.indexOf("pages/login/mimi") > 0) || (url.indexOf("pages/login/xieyi") > 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.indexOf("pages/login/mimi") > 0) || (url.indexOf("pages/login/xieyi") > 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.getLocation({
  57. type: 'gcj02',
  58. geocode: true,
  59. success: function(res) {
  60. console.log(res);
  61. uni.setStorage({
  62. key: 'location',
  63. data: {
  64. latitude: res.latitude,
  65. longitude: res.longitude,
  66. },
  67. success: function() {
  68. console.log('位置信息保存成功');
  69. }
  70. });
  71. },
  72. fail: function(err) {
  73. console.log(err);
  74. // #ifdef APP-PLUS
  75. uni.showModal({
  76. title: '提示',
  77. content: '请打开定位服务',
  78. success: ({
  79. confirm,
  80. cancel
  81. }) => {
  82. if (confirm) {
  83. // android平台
  84. if (uni.getSystemInfoSync().platform == 'android') {
  85. var Intent = plus.android.importClass(
  86. 'android.content.Intent');
  87. var Settings = plus.android.importClass(
  88. 'android.provider.Settings');
  89. var intent = new Intent(Settings
  90. .ACTION_LOCATION_SOURCE_SETTINGS);
  91. var main = plus.android.runtimeMainActivity();
  92. main.startActivity(intent); // 打开系统设置GPS服务页面
  93. }
  94. }
  95. // 用户取消前往开启定位服务
  96. if (cancel) {
  97. uni.navigateBack({ //uni.navigateTo跳转的返回,默认1为返回上一级
  98. delta: 1
  99. });
  100. }
  101. }
  102. });
  103. // #endif
  104. }
  105. });
  106. },
  107. onHide: function() {},
  108. methods: {
  109. // TODO 开屏广告 后续优化添加
  110. launch() {
  111. try {
  112. var date = new Date();
  113. var year = date.getFullYear();
  114. var month = date.getMonth() + 1;
  115. var strDate = date.getDate();
  116. var currentdate = year + '' + month + '' + strDate + '' + plus.runtime.version;
  117. // 获取本地存储中launchFlag标识(不可动)
  118. const value = uni.getStorageSync("launchFlag");
  119. if (value == currentdate) {} else {
  120. //app启动时打开启动广告页
  121. var w = plus.webview.open(
  122. "/hybrid/html/advertise/advertise.html",
  123. "本地地址", {
  124. top: 0,
  125. bottom: 0,
  126. zindex: 999,
  127. },
  128. "fade-in",
  129. 500
  130. );
  131. //设置定时器,4s后关闭启动
  132. setTimeout(function() {
  133. uni.setStorage({
  134. key: "launchFlag",
  135. data: currentdate
  136. });
  137. plus.webview.close(w);
  138. }, 3000);
  139. }
  140. } catch (e) {
  141. // error
  142. uni.setStorage({
  143. key: "launchFlag",
  144. data: currentdate,
  145. success: function() {
  146. console.log("error时存储launchFlag");
  147. },
  148. });
  149. }
  150. },
  151. }
  152. };
  153. </script>
  154. <style>
  155. /* #ifndef APP-NVUE */
  156. @import "/style/uni.css";
  157. /* 官方ui库 */
  158. /* @import "/style/animate.min.css"; */
  159. /* 第三方动画库 */
  160. @import "/style/icon.css";
  161. /* 自定义图标库 */
  162. /* @import 'https://at.alicdn.com/t/font_1807257_t3nqcuysmns.css'; */
  163. @import "/style/common.css";
  164. /* 公共样式库 */
  165. @import "/style/zcm-main.css";
  166. /* UI基础库 */
  167. /* @import "/style/input.scss"; */
  168. /* 基础表单样式*/
  169. /* #endif */
  170. /* #ifdef H5 */
  171. /* 修复H5底部导航挡住内容bug */
  172. uni-app {
  173. height: auto;
  174. }
  175. /* 修复H5输入框上下不居中bug */
  176. .uni-input-form {
  177. height: 100%;
  178. }
  179. /* 去除地图上高德地图标识符 */
  180. .amap-copyright {
  181. display: none !important;
  182. }
  183. .amap-logo {
  184. display: none !important;
  185. }
  186. .amap-ui-control-zoom {
  187. width: 60upx !important;
  188. }
  189. .amap-ui-control-zoom>* {
  190. width: 60upx !important;
  191. height: 60upx !important;
  192. line-height: 60upx !important;
  193. }
  194. .amap-ui-control-theme-dark {
  195. display: none !important;
  196. }
  197. /* #endif */
  198. </style>