index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="content">
  3. <image class="logo" src="/static/logo.png"></image>
  4. <view class="text-area">
  5. <text class="title">{{title}}</text>
  6. </view>
  7. <view>
  8. <input id="myInput" type="text" v-model="funName" placeholder="请输入方法名" />
  9. <button id="btnCheck" @click="funCheck">验证</button>
  10. </view>
  11. <button @click="btnTestClick">toTest</button>
  12. <view id="iframeView">
  13. <iframe :src="iframeSRC" id="myIframe">该浏览器不支持 iframe 标签</iframe>
  14. </view>
  15. <view id="routerTest">
  16. <view>
  17. <router-link to="../test/test2">test2</router-link>
  18. </view>
  19. <view>
  20. <router-view></router-view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. components: {
  28. },
  29. data() {
  30. return {
  31. title: 'Hello',
  32. funName: '',
  33. myHost: 'http://39.105.166.141:8085',
  34. webviewStyles: {
  35. progress: {
  36. color: '#FF3333'
  37. }
  38. },
  39. iframeSRC: '#pages/test/test2'
  40. }
  41. },
  42. onLoad() {
  43. // uni.redirectTo({
  44. // url:"../test/StartLearning"
  45. // })
  46. },
  47. mounted() {
  48. window.addEventListener('message', event => {
  49. let data = event.data;
  50. console.log(data);
  51. if (data.cmd === 'jump') {
  52. console.log("-----------jump111");
  53. // this.iframeSRC = '#pages/test/test3';
  54. // this.iframeSRC = '#pages/index/index';
  55. this.iframeSRC = 'https://www.baidu.com';
  56. } else if (data.cmd === 'jump2') {
  57. console.log("-----------jump222");
  58. this.iframeSRC = '#pages/test/test2';
  59. // this.iframeSRC = 'https://www.baidu.com';
  60. } else {
  61. console.log("***********notjump");
  62. }
  63. })
  64. },
  65. methods: {
  66. funCheck() {
  67. console.log(this.funName)
  68. this.testPOST();
  69. },
  70. testPOST() {
  71. let url = "http://39.105.166.141:8085/user/loginin";
  72. uni.request({
  73. header: {
  74. // 'Content-Type': 'application/x-www-form-urlencoded'
  75. 'Content-Type': 'application/json'
  76. },
  77. url: url,
  78. method: 'POST',
  79. data: {
  80. "IlabAccount": "teststudent01",
  81. "Password": "qgsTest002"
  82. },
  83. dataType: 'json',
  84. success: (res) => {
  85. // var result = JSON.parse(res);
  86. console.log("success***", res)
  87. },
  88. fail: (res) => {
  89. console.log("fail***", res)
  90. }
  91. });
  92. },
  93. btnTestClick() {
  94. uni.navigateTo({
  95. url: '/pages/test/test',
  96. });
  97. },
  98. }
  99. }
  100. </script>
  101. <style>
  102. .content {
  103. display: flex;
  104. flex-direction: column;
  105. align-items: center;
  106. justify-content: center;
  107. }
  108. .logo {
  109. height: 200rpx;
  110. width: 200rpx;
  111. margin-top: 200rpx;
  112. margin-left: auto;
  113. margin-right: auto;
  114. margin-bottom: 50rpx;
  115. }
  116. .text-area {
  117. display: flex;
  118. justify-content: center;
  119. }
  120. .title {
  121. font-size: 36rpx;
  122. color: #8f8f94;
  123. }
  124. #myInput {
  125. border: #007AFF 1rpx solid;
  126. }
  127. #iframeView {
  128. margin-top: 20rpx;
  129. }
  130. #myIframe {
  131. border: none;
  132. }
  133. #routerTest {
  134. width: 500rpx;
  135. height: 200rpx;
  136. border: #aa00ff 1rpx solid;
  137. flex-direction: row;
  138. }
  139. </style>