index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = {
  4. data() {
  5. return {
  6. title: "jxst",
  7. // url: 'http://139.9.102.170:10012/#/',
  8. url: "http://121.37.194.75:20011/#/",
  9. src: "",
  10. canBack: false
  11. };
  12. },
  13. onBackPress() {
  14. return false;
  15. },
  16. onReady() {
  17. },
  18. onLoad() {
  19. var height = 0;
  20. common_vendor.index.getSystemInfo({
  21. //成功获取的回调函数,返回值为系统信息
  22. success: (sysinfo) => {
  23. console.log(sysinfo);
  24. height = sysinfo.windowHeight;
  25. },
  26. complete: () => {
  27. }
  28. });
  29. let info = common_vendor.index.getSystemInfoSync();
  30. let top = info.statusBarHeight;
  31. console.log(info, 12312312312);
  32. var currentWebview = this.$scope.$getAppWebview();
  33. setTimeout(function() {
  34. var wv = currentWebview.children()[0];
  35. wv.setStyle({
  36. //设置web-view距离顶部的距离以及自己的高度,单位为px
  37. top,
  38. //此处是距离顶部的高度,应该是你页面的头部
  39. // bottom:0,//防止输入框被软键盘遮挡
  40. height: height - top,
  41. //webview的高度
  42. scalable: false
  43. //webview的页面是否可以缩放,双指放大缩小
  44. });
  45. }, 1e3);
  46. common_vendor.index.$on("connectStatusChange", (connectStatus) => {
  47. if (connectStatus) {
  48. var currentWebview2 = this.$scope.$getAppWebview();
  49. var wv = currentWebview2.children()[0];
  50. jpushModule.getRegistrationID((result) => {
  51. console.log(result, "注册ID.....");
  52. wv.evalJS(`getVueMessage(${JSON.stringify(result.registerID)})`);
  53. });
  54. }
  55. });
  56. },
  57. onUnload() {
  58. common_vendor.index.$off("connectStatusChange");
  59. },
  60. methods: {
  61. messageData(e) {
  62. const data = e.detail.data;
  63. var currentWebview = this.$scope.$getAppWebview();
  64. var wv = currentWebview.children()[0];
  65. if (data[0].type == "file") {
  66. let url = data[0].url;
  67. common_vendor.index.downloadFile({
  68. url,
  69. // 文件的下载链接
  70. success: function(res) {
  71. if (res.statusCode === 200) {
  72. common_vendor.index.openDocument({
  73. filePath: res.tempFilePath,
  74. success: function(res2) {
  75. },
  76. fail: function(error) {
  77. }
  78. });
  79. }
  80. },
  81. fail: function(error) {
  82. }
  83. });
  84. } else if (data[0].type == "scanCode") {
  85. common_vendor.index.scanCode({
  86. success: (res) => {
  87. wv.evalJS(`getVueMessage(${JSON.stringify(res.result)})`);
  88. }
  89. });
  90. }
  91. }
  92. }
  93. };
  94. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  95. return {
  96. a: $data.url,
  97. b: common_vendor.o((...args) => $options.messageData && $options.messageData(...args))
  98. };
  99. }
  100. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "D:/uni-fans-mobile/pages/index/index.vue"]]);
  101. wx.createPage(MiniProgramPage);