lu_quan_dev
han 11 months ago
parent e01e006a12
commit b06a49f812
  1. 10
      common/config.js
  2. 125
      subPageC/Ai/index.vue
  3. 44
      subPageC/weather/index.vue

@ -51,9 +51,13 @@ module.exports = {
userCancelUpdateOrder: REAUEST_ROOTPATH + "/admin-api/homestay/HotelOrder/userCancelUpdateOrder",//民宿订单取消 userCancelUpdateOrder: REAUEST_ROOTPATH + "/admin-api/homestay/HotelOrder/userCancelUpdateOrder",//民宿订单取消
getDictDataList: REAUEST_ROOTPATH + "/admin-api/homestay/HotelOrder/getDictDataList",//民宿订单原因 getDictDataList: REAUEST_ROOTPATH + "/admin-api/homestay/HotelOrder/getDictDataList",//民宿订单原因
getWeatherForecast: 'http://192.168.130.157:48080/app-api' + "/wechatshop/weather/getWeatherForecast",//工具-天气预报
aiSendMsg: REAUEST_ROOTPATH + "/app-api/wechatshop/ai/sendMsg",//Ai发送
getWeatherForecast: REAUEST_ROOTPATH + "/app-api/wechatshop/weather/getWeatherForecast",//天气预报
getRealTimeWeather: REAUEST_ROOTPATH + "/app-api/wechatshop/weather/getRealTimeWeather",//Ai发送
// getMethodList: REAUEST_ROOTPATH + "/mobile/method/getMethodList", //原攻略列表 // getMethodList: REAUEST_ROOTPATH + "/mobile/method/getMethodList", //原攻略列表
getMethodList: REAUEST_ROOTPATH + "/mobile/WalkthroughType/selectWalkthroughType",//攻略列表 getMethodList: REAUEST_ROOTPATH + "/mobile/WalkthroughType/selectWalkthroughType",//攻略列表
getMethodRecommendList: REAUEST_ROOTPATH + "/mobile/WalkthroughType/selectMessageRecommend",//攻略推荐列表 getMethodRecommendList: REAUEST_ROOTPATH + "/mobile/WalkthroughType/selectMessageRecommend",//攻略推荐列表

@ -27,7 +27,7 @@
<image src="@/static/test/icon-voice.png" mode="widthFix" class="left-icon" <image src="@/static/test/icon-voice.png" mode="widthFix" class="left-icon"
@click="messageType='voice'"> @click="messageType='voice'">
</image> </image>
<input type="text" v-model="content" class="input" @confirm="send" /> <input type="text" v-model="content" class="input" @confirm="sendMsg" />
</block> </block>
<block v-if="messageType === 'voice'"> <block v-if="messageType === 'voice'">
<image src="@/static/test/icon-text.png" mode="widthFix" class="left-icon" @click="messageType='text'"> <image src="@/static/test/icon-text.png" mode="widthFix" class="left-icon" @click="messageType='text'">
@ -60,8 +60,9 @@
// //
messageType: 'voice', // text voice messageType: 'voice', // text voice
recordStart: false, recordStart: false,
identity: "",
//websocket //websocket
headers: {}, Token:null ,
userInfo: {}, userInfo: {},
wsInfo: { wsInfo: {
ws: null, // ws ws: null, // ws
@ -78,21 +79,16 @@
} }
} }
}, },
onReady() {
const userInfo = uni.getStorageSync("userInfo"); onShow() {
const userInfo = uni.getStorageSync("userInfo");
this.userInfo = { this.userInfo = {
"message": "", "message": "",
"dialogId": "", "dialogId": "",
"identity": userInfo.openid, "identity": "",
"userId": userInfo.userId "userId": userInfo.userId
}; };
const tok = userInfo.accessToken; this.Token = userInfo.accessToken;
this.headers = {
"content-type": 'application/json',
'Authorization': 'Bearer ' + '3e803f812b5c4bba8a0d6864d011cf28'
};
},
onShow() {
this.connectWs() this.connectWs()
}, },
methods: { methods: {
@ -101,7 +97,7 @@
const $this = this const $this = this
this.wsInfo.ws = null; this.wsInfo.ws = null;
this.wsInfo.ws = uni.connectSocket({ this.wsInfo.ws = uni.connectSocket({
url: 'wss://192.168.130.157:48080/infra/ws?token=3e803f812b5c4bba8a0d6864d011cf28', url: 'wss://eluyou.ailuquan.cn/prod-api/infra/ws?token='+this.Token,
success() { success() {
$this.wsInfo.alive = true; $this.wsInfo.alive = true;
console.log("ws连接成功!"); console.log("ws连接成功!");
@ -111,51 +107,36 @@
console.log("ws连接失败!"); console.log("ws连接失败!");
}, },
}); });
console.log("ws信息:", this.wsInfo.ws); console.log("ws信息:", this.wsInfo.ws);
// ws
this.wsInfo.ws.onOpen((res) => { this.wsInfo.ws.onOpen((res) => {
$this.wsInfo.alive = true; $this.wsInfo.alive = true;
// //
$this.heartBeat(); $this.heartBeat();
console.log("ws开启成功!"); console.log("ws开启成功!",$this.wsInfo.alive);
}); });
// ws // ws
this.wsInfo.ws.onMessage((res) => { this.wsInfo.ws.onMessage((res) => {
console.log("===", res) console.log("ws接收消息:", res);
$this.heartBeat();
//
let data = JSON.parse(res.data); let data = JSON.parse(res.data);
$this.handlerMessage($this.userInfo); $this.handlerMessage(data);
console.log("ws接收消息:", data); console.log("ws接收消息:", data);
}); });
// ws
this.wsInfo.ws.onClose((res) => {
$this.wsInfo.alive = false;
// console.log("ws", this.wsInfo.ws); $this.reConnect();
// // ws console.log("ws连接关闭:", res);
// this.wsInfo.ws.onOpen((res) => { });
// this.wsInfo.alive = true; // ws
// // this.wsInfo.ws.onError((err) => {
// this.heartBeat(); $this.wsInfo.alive = false;
// console.log("ws!"); $this.reConnect();
// }); console.log("ws连接错误:", res);
// // ws });
// this.wsInfo.ws.onMessage((res) => {
// this.heartBeat();
// //
// let data = JSON.parse(res.data);
// this.handlerMessage(data);
// console.log("ws", data);
// });
// // ws
// this.wsInfo.ws.onClose((res) => {
// this.wsInfo.alive = false;
// this.reConnect();
// console.log("ws", res);
// });
// // ws
// this.wsInfo.ws.onError((err) => {
// this.wsInfo.alive = false;
// this.reConnect();
// console.log("ws", res);
// });
}, },
// //
heartBeat() { heartBeat() {
@ -163,11 +144,11 @@
clearTimeout(this.wsInfo.clientTimer); clearTimeout(this.wsInfo.clientTimer);
clearTimeout(this.wsInfo.serverTimer); clearTimeout(this.wsInfo.serverTimer);
this.wsInfo.clientTimer = setTimeout(() => { this.wsInfo.clientTimer = setTimeout(() => {
if (this.wsInfo.ws) { if ($this.wsInfo.ws) {
let pong = { let pong = {
type: "ping", type: "ping",
}; };
this.wsInfo.ws.send({ $this.wsInfo.ws.send({
data: JSON.stringify(pong), data: JSON.stringify(pong),
fail() { fail() {
$this.wsInfo.serverTimer = setTimeout(() => { $this.wsInfo.serverTimer = setTimeout(() => {
@ -176,7 +157,7 @@
}, },
}); });
} }
}, this.wsInfo.clientTime); }, $this.wsInfo.clientTime);
}, },
// //
handlerMessage(data) { handlerMessage(data) {
@ -204,23 +185,34 @@
this.wsInfo.ws.close(); this.wsInfo.ws.close();
}, },
// //
send() { sendMsg() {
const $this = this
this.list.push({ this.list.push({
content: this.content, content: this.content,
userType: 'self', userType: 'self',
}) })
if (this.userInfo.identity == "") {
this.userInfo.identity = this.generateRandomString(8);
}
this.userInfo.message = this.content
this.$Request.post(this.$config.aiSendMsg, $this.userInfo, "json", null, false, true)
.then(res => {
console.log("---", res)
});
this.content = '' this.content = ''
this.scrollToBottom() this.scrollToBottom()
// // //
setTimeout(() => { // setTimeout(() => {
this.list.push({ // this.list.push({
content: '好的', // content: '',
userType: 'friend', // userType: 'friend',
}) // })
this.scrollToBottom() // this.scrollToBottom()
}, 1500) // }, 1500)
}, },
// //
scrollToBottom() { scrollToBottom() {
@ -361,7 +353,18 @@
} }
}); });
}) })
} },
// key
generateRandomString(length) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * characters.length);
result += characters.charAt(randomIndex);
}
return result;
},
} }
} }
</script> </script>

@ -60,15 +60,15 @@
tempTotal: undefined, tempTotal: undefined,
}; };
}, },
computed: { computed: {
TodayClass() { TodayClass() {
switch (true) { switch (true) {
case this.today_data.text.includes("晴"): case this.today_data.text.includes("晴"):
return "sunny" return "sunny"
break; break;
case this.today_data.text.includes("阴"): case this.today_data.text.includes("阴"):
return "rainy" return "rainy"
break; break;
case this.today_data.text.includes("雨"): case this.today_data.text.includes("雨"):
return "rainy" return "rainy"
break; break;
@ -92,39 +92,33 @@
}, },
methods: { methods: {
initPages() { initPages() {
uni.request({ this.$Request.get(this.$config.getWeatherForecast, null, null, null, false, true)
url: 'http://192.168.130.157:48080/app-api/wechatshop/weather/getWeatherForecast', .then(res => {
success: (res) => {
let data = res.data let data = res.data
this.tempMax = Math.max.apply(Math, data.data.map(item => { this.tempMax = Math.max.apply(Math, data.map(item => {
return item.tempMax return item.tempMax
})) }))
this.tempMin = Math.min.apply(Math, data.data.map(item => { this.tempMin = Math.min.apply(Math, data.map(item => {
return item.tempMin return item.tempMin
})) }))
this.tempTotal = this.tempMax - this.tempMin this.tempTotal = this.tempMax - this.tempMin
data.data.forEach((item, index, arr) => { data.forEach((item, index, arr) => {
let data = { let data = {
week: this.getWeekday(item.fxDate[0] + '-' + item.fxDate[1] + week: this.getWeekday(item.fxDate[0] + '-' + item.fxDate[1] +
'-' + '-' +
item.fxDate[2]), item.fxDate[2]),
iconDay: item.iconDay, iconDay: item.iconDay,
tempMin:item.tempMin, tempMin: item.tempMin,
tempMax:item.tempMax, tempMax: item.tempMax,
} }
this.days_data.push(data); this.days_data.push(data);
}) })
console.log("asdf",this.days_data) });
this.$Request.get(this.$config.getRealTimeWeather, null, null, null, false, true)
} .then(res => {
});
uni.request({
url: 'http://192.168.130.157:48080/app-api/wechatshop/weather/getRealTimeWeather',
success: (res) => {
let data = res.data let data = res.data
this.today_data = data.data this.today_data = data
} });
});
}, },
getTempBar(Min, Max) { getTempBar(Min, Max) {
let left = ((Min - this.tempMin) / this.tempTotal) * 100 let left = ((Min - this.tempMin) / this.tempTotal) * 100
@ -150,7 +144,7 @@
return weekdays[weekday]; return weekdays[weekday];
} }
}, },
} }
} }
</script> </script>
@ -160,7 +154,7 @@
.v-weather-bar { .v-weather-bar {
position: relative; position: relative;
top:88rpx; top: 88rpx;
z-index: 9; z-index: 9;
height: 88rpx; height: 88rpx;
line-height: 88rpx; line-height: 88rpx;

Loading…
Cancel
Save