App.vue 6.2 KB

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