app-service.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. if (typeof Promise !== "undefined" && !Promise.prototype.finally) {
  2. Promise.prototype.finally = function(callback) {
  3. const promise = this.constructor;
  4. return this.then(
  5. (value) => promise.resolve(callback()).then(() => value),
  6. (reason) => promise.resolve(callback()).then(() => {
  7. throw reason;
  8. })
  9. );
  10. };
  11. }
  12. ;
  13. if (typeof uni !== "undefined" && uni && uni.requireGlobal) {
  14. const global = uni.requireGlobal();
  15. ArrayBuffer = global.ArrayBuffer;
  16. Int8Array = global.Int8Array;
  17. Uint8Array = global.Uint8Array;
  18. Uint8ClampedArray = global.Uint8ClampedArray;
  19. Int16Array = global.Int16Array;
  20. Uint16Array = global.Uint16Array;
  21. Int32Array = global.Int32Array;
  22. Uint32Array = global.Uint32Array;
  23. Float32Array = global.Float32Array;
  24. Float64Array = global.Float64Array;
  25. BigInt64Array = global.BigInt64Array;
  26. BigUint64Array = global.BigUint64Array;
  27. }
  28. ;
  29. if (uni.restoreGlobal) {
  30. uni.restoreGlobal(Vue, weex, plus, setTimeout, clearTimeout, setInterval, clearInterval);
  31. }
  32. (function(vue) {
  33. "use strict";
  34. function requireNativePlugin(name) {
  35. return weex.requireModule(name);
  36. }
  37. function formatAppLog(type, filename, ...args) {
  38. if (uni.__log__) {
  39. uni.__log__(type, filename, ...args);
  40. } else {
  41. console[type].apply(console, [...args, filename]);
  42. }
  43. }
  44. const _export_sfc = (sfc, props) => {
  45. const target = sfc.__vccOpts || sfc;
  46. for (const [key, val] of props) {
  47. target[key] = val;
  48. }
  49. return target;
  50. };
  51. const jpushModule$1 = requireNativePlugin("JG-JPush");
  52. var wv;
  53. const _sfc_main$1 = {
  54. data() {
  55. return {
  56. title: "jxst",
  57. // url: 'http://139.9.102.170:10012/#/',
  58. url: "http://139.9.102.170:10022/#/",
  59. src: "",
  60. canBack: false
  61. };
  62. },
  63. onBackPress() {
  64. if (wv && this.canBack) {
  65. wv.back();
  66. return true;
  67. }
  68. return false;
  69. },
  70. onReady() {
  71. var self = this;
  72. var currentWebview = this.$scope.$getAppWebview();
  73. setTimeout(function() {
  74. wv = currentWebview.children()[0];
  75. wv.addEventListener(
  76. "progressChanged",
  77. function(e) {
  78. wv.canBack(function(e2) {
  79. self.canBack = e2.canBack;
  80. });
  81. },
  82. false
  83. );
  84. }, 500);
  85. },
  86. onLoad() {
  87. var height = 0;
  88. uni.getSystemInfo({
  89. //成功获取的回调函数,返回值为系统信息
  90. success: (sysinfo) => {
  91. formatAppLog("log", "at pages/index/index.vue:55", sysinfo);
  92. height = sysinfo.windowHeight;
  93. },
  94. complete: () => {
  95. }
  96. });
  97. let info = uni.getSystemInfoSync();
  98. let top = info.statusBarHeight;
  99. formatAppLog("log", "at pages/index/index.vue:62", info, 12312312312);
  100. var currentWebview = this.$scope.$getAppWebview();
  101. setTimeout(function() {
  102. var wv2 = currentWebview.children()[0];
  103. wv2.setStyle({
  104. //设置web-view距离顶部的距离以及自己的高度,单位为px
  105. top,
  106. //此处是距离顶部的高度,应该是你页面的头部
  107. // bottom:0,//防止输入框被软键盘遮挡
  108. height: height - top,
  109. //webview的高度
  110. scalable: false
  111. //webview的页面是否可以缩放,双指放大缩小
  112. });
  113. }, 1e3);
  114. uni.$on("connectStatusChange", (connectStatus) => {
  115. if (connectStatus) {
  116. var currentWebview2 = this.$scope.$getAppWebview();
  117. var wv2 = currentWebview2.children()[0];
  118. jpushModule$1.getRegistrationID((result) => {
  119. formatAppLog("log", "at pages/index/index.vue:86", result, "注册ID.....");
  120. wv2.evalJS(`getVueMessage(${JSON.stringify(result.registerID)})`);
  121. });
  122. }
  123. });
  124. },
  125. onUnload() {
  126. uni.$off("connectStatusChange");
  127. },
  128. methods: {
  129. messageData(e) {
  130. const data = e.detail.data;
  131. var currentWebview = this.$scope.$getAppWebview();
  132. var wv2 = currentWebview.children()[0];
  133. if (data[0].type == "file") {
  134. let url = data[0].url;
  135. uni.downloadFile({
  136. url,
  137. // 文件的下载链接
  138. success: function(res) {
  139. if (res.statusCode === 200) {
  140. uni.openDocument({
  141. filePath: res.tempFilePath,
  142. success: function(res2) {
  143. },
  144. fail: function(error) {
  145. }
  146. });
  147. }
  148. },
  149. fail: function(error) {
  150. }
  151. });
  152. } else if (data[0].type == "scanCode") {
  153. uni.scanCode({
  154. success: (res) => {
  155. wv2.evalJS(`getVueMessage(${JSON.stringify(res.result)})`);
  156. }
  157. });
  158. }
  159. }
  160. }
  161. };
  162. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  163. return vue.openBlock(), vue.createElementBlock("view", { class: "content" }, [
  164. vue.createElementVNode("view", { class: "status_bar" }, [
  165. vue.createCommentVNode(" 这里是状态栏 ")
  166. ]),
  167. vue.createElementVNode("web-view", {
  168. src: $data.url,
  169. fullscreen: false,
  170. onMessage: _cache[0] || (_cache[0] = (...args) => $options.messageData && $options.messageData(...args))
  171. }, null, 40, ["src"])
  172. ]);
  173. }
  174. const PagesIndexIndex = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__file", "D:/uni-jxst-mobile/pages/index/index.vue"]]);
  175. __definePage("pages/index/index", PagesIndexIndex);
  176. const jpushModule = requireNativePlugin("JG-JPush");
  177. const _sfc_main = {
  178. onLaunch: function() {
  179. formatAppLog("log", "at App.vue:5", "App Launch");
  180. if (uni.getSystemInfoSync().platform == "ios") {
  181. let locationServicesEnabled = jpushModule.locationServicesEnabled();
  182. let locationAuthorizationStatus = jpushModule.getLocationAuthorizationStatus();
  183. formatAppLog("log", "at App.vue:10", "locationAuthorizationStatus", locationAuthorizationStatus);
  184. if (locationServicesEnabled == true && locationAuthorizationStatus < 3) {
  185. jpushModule.requestLocationAuthorization((result) => {
  186. formatAppLog("log", "at App.vue:13", "定位权限", result.status);
  187. });
  188. }
  189. jpushModule.requestNotificationAuthorization((result) => {
  190. let status = result.status;
  191. if (status < 2) {
  192. uni.showToast({
  193. icon: "none",
  194. title: "您还没有打开通知权限",
  195. duration: 3e3
  196. });
  197. }
  198. });
  199. }
  200. jpushModule.initJPushService();
  201. jpushModule.setLoggerEnable(true);
  202. jpushModule.addConnectEventListener((result) => {
  203. formatAppLog("log", "at App.vue:38", result);
  204. let connectEnable = result.connectEnable;
  205. uni.$emit("connectStatusChange", connectEnable);
  206. });
  207. jpushModule.addNotificationListener((result) => {
  208. formatAppLog("log", "at App.vue:59", result);
  209. if (result.notificationEventType == "notificationOpened") {
  210. uni.navigateTo({
  211. url: "/pages/home/warningCenter/warningCenter",
  212. complete(res) {
  213. formatAppLog("log", "at App.vue:65", res);
  214. }
  215. });
  216. }
  217. });
  218. jpushModule.addCustomMessageListener((result) => {
  219. result.type;
  220. result.messageType;
  221. result.content;
  222. uni.showToast({
  223. icon: "none",
  224. title: JSON.stringify(result),
  225. duration: 3e3
  226. });
  227. });
  228. jpushModule.addLocalNotificationListener((result) => {
  229. result.messageID;
  230. result.title;
  231. result.content;
  232. result.extras;
  233. uni.showToast({
  234. icon: "none",
  235. title: JSON.stringify(result),
  236. duration: 3e3
  237. });
  238. });
  239. jpushModule.addGeofenceListener((result) => {
  240. result.code;
  241. result.type;
  242. result.geofenceId;
  243. result.userInfo;
  244. uni.showToast({
  245. icon: "none",
  246. title: "触发地理围栏",
  247. duration: 3e3
  248. });
  249. });
  250. jpushModule.setIsAllowedInMessagePop(true);
  251. jpushModule.pullInMessage((result) => {
  252. let code = result.code;
  253. formatAppLog("log", "at App.vue:110", code);
  254. });
  255. jpushModule.addInMessageListener((result) => {
  256. let eventType = result.eventType;
  257. let messageType = result.messageType;
  258. let content = result.content;
  259. formatAppLog("log", "at App.vue:117", "inMessageListener", eventType, messageType, content);
  260. uni.showToast({
  261. icon: "none",
  262. title: JSON.stringify(result),
  263. duration: 3e3
  264. });
  265. });
  266. },
  267. onShow: function() {
  268. formatAppLog("log", "at App.vue:127", "App Show");
  269. },
  270. onHide: function() {
  271. formatAppLog("log", "at App.vue:130", "App Hide");
  272. }
  273. };
  274. const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "D:/uni-jxst-mobile/App.vue"]]);
  275. function createApp() {
  276. const app = vue.createVueApp(App);
  277. return {
  278. app
  279. };
  280. }
  281. const { app: __app__, Vuex: __Vuex__, Pinia: __Pinia__ } = createApp();
  282. uni.Vuex = __Vuex__;
  283. uni.Pinia = __Pinia__;
  284. __app__.provide("__globalStyles", __uniConfig.styles);
  285. __app__._component.mpType = "app";
  286. __app__._component.render = () => {
  287. };
  288. __app__.mount("#app");
  289. })(Vue);