App.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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 DB from "@/common/sqlite";
  8. export default {
  9. data() {
  10. return {
  11. locationInterval: null, // 用于存储定时器ID
  12. errorNotified: false // 用于跟踪错误通知是否已经发送
  13. };
  14. },
  15. onLaunch: function(e) {
  16. //取出缓存数据
  17. store.commit("setCacheData");
  18. if (store.state.token) {} else {
  19. var url = window.location.href;
  20. if ((url.indexOf("pages/carInsure/payVerify") >
  21. 0) || (url
  22. .indexOf("pages/carInsure1/yonganCode") > 0)) {
  23. uni.navigateTo({
  24. url: url
  25. })
  26. } else {}
  27. }
  28. // #ifdef H5
  29. if (store.state.token) {} else {
  30. var url = window.location.href;
  31. if ((url.indexOf("pages/carInsure/payVerify") >
  32. 0) || (url
  33. .indexOf("pages/carInsure1/yonganCode") > 0)) {
  34. uni.navigateTo({
  35. url: url
  36. })
  37. } else {
  38. }
  39. }
  40. // #endif
  41. // #ifdef APP-PLUS
  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. // #ifdef APP-PLUS
  57. // this.launch()
  58. // #endif
  59. },
  60. onHide: function() {},
  61. methods: {
  62. // getLocation() {
  63. // uni.getLocation({
  64. // type: 'gcj02', // 根据需要选择坐标类型
  65. // geocode: true,
  66. // success: (res) => {
  67. // this.saveLocation(res);
  68. // if (this.locationInterval) {
  69. // clearInterval(this.locationInterval);
  70. // }
  71. // // 设置每小时重新获取坐标
  72. // this.locationInterval = setInterval(() => {
  73. // this.updateLocation();
  74. // }, 3600000); // 3600000毫秒 = 1小时
  75. // // 重置错误通知状态
  76. // this.errorNotified = false;
  77. // },
  78. // fail: (err) => {
  79. // if (!this.errorNotified) {
  80. // this.handleLocationError(err);
  81. // this.errorNotified = true;
  82. // }
  83. // }
  84. // });
  85. // },
  86. // updateLocation() {
  87. // uni.getLocation({
  88. // type: 'gcj02',
  89. // geocode: true,
  90. // success: (res) => {
  91. // this.saveLocation(res);
  92. // },
  93. // fail: (err) => {
  94. // if (!this.errorNotified) {
  95. // this.handleLocationError(err);
  96. // this.errorNotified = true;
  97. // }
  98. // }
  99. // });
  100. // },
  101. // saveLocation(res) {
  102. // uni.setStorage({
  103. // key: 'location',
  104. // data: {
  105. // latitude: res.latitude,
  106. // longitude: res.longitude,
  107. // province: res.address.province,
  108. // city: res.address.city,
  109. // district: res.address.district,
  110. // street: res.address.street,
  111. // streetNum: res.address.streetNum,
  112. // poiName: res.address.poiName,
  113. // cityCode: res.address.cityCode
  114. // },
  115. // success: () => {}
  116. // });
  117. // },
  118. // handleLocationError(err) {
  119. // uni.showModal({
  120. // title: '获取权限',
  121. // content: '晋掌柜有道路救援服务,需要获取位置信息',
  122. // success: ({
  123. // confirm,
  124. // cancel
  125. // }) => {
  126. // setTimeout(() => {
  127. // if (confirm) {
  128. // this.openLocationSettings();
  129. // }
  130. // if (cancel) {
  131. // this.exitApp();
  132. // }
  133. // }, 0);
  134. // }
  135. // });
  136. // },
  137. // openLocationSettings() {
  138. // if (uni.getSystemInfoSync().platform == 'android') {
  139. // var Intent = plus.android.importClass('android.content.Intent');
  140. // var Settings = plus.android.importClass('android.provider.Settings');
  141. // var intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
  142. // var main = plus.android.runtimeMainActivity();
  143. // main.startActivity(intent);
  144. // }
  145. // },
  146. // exitApp() {
  147. // if (plus.os.name === "Android") {
  148. // plus.runtime.quit();
  149. // } else {
  150. // plus.ios.import("UIApplication").sharedApplication().performSelector("exit");
  151. // }
  152. // },
  153. // TODO 开屏广告 后续优化添加
  154. launch() {
  155. try {
  156. var date = new Date();
  157. var year = date.getFullYear();
  158. var month = date.getMonth() + 1;
  159. var strDate = date.getDate();
  160. var currentdate = year + '' + month + '' + strDate + '' + plus.runtime.version;
  161. // 获取本地存储中launchFlag标识(不可动)
  162. const value = uni.getStorageSync("launchFlag");
  163. // if (value == currentdate) {} else {
  164. //app启动时打开启动广告页
  165. var w = plus.webview.open(
  166. "/hybrid/html/advertise/advertise.html",
  167. "本地地址", {
  168. top: 0,
  169. bottom: 0,
  170. zindex: 999,
  171. },
  172. "fade-in",
  173. 500
  174. );
  175. //设置定时器,4s后关闭启动
  176. setTimeout(function() {
  177. uni.setStorage({
  178. key: "launchFlag",
  179. data: currentdate
  180. });
  181. plus.webview.close(w);
  182. }, 4000);
  183. // }
  184. } catch (e) {
  185. // error
  186. uni.setStorage({
  187. key: "launchFlag",
  188. data: currentdate,
  189. success: function() {},
  190. });
  191. }
  192. },
  193. }
  194. };
  195. </script>
  196. <style>
  197. /* #ifndef APP-NVUE */
  198. @import "/style/uni.css";
  199. /* 官方ui库 */
  200. /* @import "/style/animate.min.css"; */
  201. /* 第三方动画库 */
  202. @import "/style/icon.css";
  203. /* 自定义图标库 */
  204. /* @import 'https://at.alicdn.com/t/font_1807257_t3nqcuysmns.css'; */
  205. @import "/style/common.css";
  206. /* 公共样式库 */
  207. @import "/style/zcm-main.css";
  208. /* UI基础库 */
  209. /* @import "/style/input.scss"; */
  210. /* 基础表单样式*/
  211. /* #endif */
  212. /* #ifdef H5 */
  213. /* 修复H5底部导航挡住内容bug */
  214. uni-app {
  215. height: auto;
  216. }
  217. /* 修复H5输入框上下不居中bug */
  218. .uni-input-form {
  219. height: 100%;
  220. }
  221. /* 去除地图上高德地图标识符 */
  222. .amap-copyright {
  223. display: none !important;
  224. }
  225. .amap-logo {
  226. display: none !important;
  227. }
  228. .amap-ui-control-zoom {
  229. width: 60upx !important;
  230. }
  231. .amap-ui-control-zoom>* {
  232. width: 60upx !important;
  233. height: 60upx !important;
  234. line-height: 60upx !important;
  235. }
  236. .amap-ui-control-theme-dark {
  237. display: none !important;
  238. }
  239. .uni-tabbar-bottom {
  240. .uni-tabbar {
  241. box-shadow: 0px -2px 5px 0px rgba(218, 227, 244, 0.2);
  242. }
  243. }
  244. /* #endif */
  245. </style>