|
@@ -0,0 +1,96 @@
|
|
|
+<template>
|
|
|
+ <view>
|
|
|
+ <web-view src="http://localhost:3200"></web-view>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onReady() {
|
|
|
+ // let token=uni.getStorageSync("token")
|
|
|
+ // let userId=uni.getStorageSync("userId")
|
|
|
+ // if(userId || token){
|
|
|
+ // window.addEventListener("message", function (e) {
|
|
|
+ // console.log('client 2 获取到数据啦:', e)
|
|
|
+ // uni.setStorageSync("token",e.data.token)
|
|
|
+ // uni.setStorageSync("userId",e.data.userId)
|
|
|
+ // })
|
|
|
+
|
|
|
+ // window.addEventListener("unload", function () {
|
|
|
+ // window.removeEventListener("message", function (e) {
|
|
|
+ // console.log('client 2 获取到数据啦:', e)
|
|
|
+ // uni.setStorageSync("token",e.data.token)
|
|
|
+ // uni.setStorageSync("userId",e.data.userId)
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ onLoad() {
|
|
|
+ window.addEventListener("message", function (e) {
|
|
|
+ console.log('client 2 获取到数据啦:', e)
|
|
|
+ uni.setStorageSync("token",e.data.token)
|
|
|
+ uni.setStorageSync("userId",e.data.userId)
|
|
|
+ })
|
|
|
+ let token=uni.getStorageSync("token")
|
|
|
+ let userId=uni.getStorageSync("userId")
|
|
|
+ let url= "ws://192.168.0.205:9000/common/websocket/test/"+ userId +""
|
|
|
+ console.log("url",url)
|
|
|
+ uni.connectSocket({
|
|
|
+ url: "ws://192.168.0.205:9000/common/websocket/test/"+ userId +"/"+ token +"",
|
|
|
+ // header: {
|
|
|
+ // 'content-type': 'application/json'
|
|
|
+ // },
|
|
|
+ // protocols: ['protocol1'],
|
|
|
+ // method: 'GET'
|
|
|
+ });
|
|
|
+ uni.onSocketMessage(function (res) {
|
|
|
+ console.log('收到服务器内容:' + res);
|
|
|
+ });
|
|
|
+ // uni.createPushMessage({
|
|
|
+ // content: '这是一条推送消息', // 推送内容
|
|
|
+ // title: '新消息', // 推送标题
|
|
|
+ // icon: '', // 推送图标(可选)
|
|
|
+ // badge: '', // 应用角标数(可选)
|
|
|
+ // duration:0, // 推送持续时间(可选)
|
|
|
+ // success: function (res) {
|
|
|
+ // console.log('推送成功', res);
|
|
|
+ // },
|
|
|
+ // fail: function (err) {
|
|
|
+ // console.log('推送失败', err);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // let item=uni.getStorageSync("_token");
|
|
|
+ // console.log("item",item)
|
|
|
+ },
|
|
|
+ // onLoad: function () {
|
|
|
+ // uni.createPushMessage({
|
|
|
+ // content: '这是一条推送消息', // 推送内容
|
|
|
+ // title: '新消息', // 推送标题
|
|
|
+ // icon: '', // 推送图标(可选)
|
|
|
+ // badge: '', // 应用角标数(可选)
|
|
|
+ // duration:0, // 推送持续时间(可选)
|
|
|
+ // success: function (res) {
|
|
|
+ // console.log('推送成功', res);
|
|
|
+ // },
|
|
|
+ // fail: function (err) {
|
|
|
+ // console.log('推送失败', err);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // },
|
|
|
+ methods: {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+
|
|
|
+</style>
|