forked from lsl/xzjl-ui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
155 lines
3.7 KiB
155 lines
3.7 KiB
// pages/home/jl/jlai/jlai.js
|
|
const app = getApp();//新建页面时 默认引入
|
|
const req = app.xzjlReq();//初始化一个的request() 实例
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
isAdd:false,
|
|
times:0,//非会员聊天次数
|
|
chatList:[],
|
|
ltinfo:'',
|
|
isBlank:true,//没有聊天
|
|
userInfo:{},
|
|
stxx:false,
|
|
},
|
|
addClick(){
|
|
console.log('点击了加号')
|
|
this.setData({isAdd:true})
|
|
},
|
|
noaddClick(){
|
|
console.log('点击了加号')
|
|
this.setData({isAdd:false})
|
|
},
|
|
dovipTips(){
|
|
wx: wx.showToast({
|
|
title: '请购买会员或聊天次数',
|
|
icon:'none',
|
|
})
|
|
},
|
|
go2Member(){
|
|
console.log('一天啊啊啊')
|
|
wx.navigateTo({
|
|
url: '/pages/home/me/member/member'
|
|
})
|
|
},
|
|
doLt(e){/**点击快捷选项 */
|
|
console.log('到此一游')
|
|
this.setData({ltinfo:e.target.dataset.lt})
|
|
|
|
},
|
|
go2BB(e){/**鼠标回显事件 */
|
|
this.setData({ltinfo:e.detail.value})
|
|
},
|
|
go2Send(e){/**发送消息 */
|
|
this.setData({isBlank:false})
|
|
if(e.target.dataset.lt==''){
|
|
wx: wx.showToast({
|
|
title: '聊天内容不能为空',
|
|
icon:'none',
|
|
})
|
|
}else{
|
|
this.setData({
|
|
chatList:this.data.chatList.concat({'type':1,'value':e.target.dataset.lt})
|
|
})
|
|
let that = this
|
|
req.postRequest('/api/v1/chat-records/completions',{'content':e.target.dataset.lt}).then((res)=>{
|
|
console.log(res)
|
|
console.log(res.data)
|
|
if(res.data.code==500){
|
|
console.log('500状态码')
|
|
wx: wx.showToast({
|
|
title: '获取星座精灵AI聊天消息超时',
|
|
icon:'none',
|
|
})
|
|
}
|
|
if(res.data.code==200){
|
|
this.setData({times:res.data.data.freeChatCount})
|
|
console.log(res)
|
|
this.setData({
|
|
chatList:this.data.chatList.concat({'type':2,'value':res.data.data.content})
|
|
})
|
|
}
|
|
console.log(this.userInfo);
|
|
}).catch((err)=>{
|
|
console.log(err);
|
|
})
|
|
this.setData({ltinfo:''})
|
|
}
|
|
|
|
},
|
|
getUserInfo(){
|
|
req.getRequest('/api/user/curt',{}).then((res)=>{
|
|
if(res.data.code==200){
|
|
this.setData({userInfo:res.data.data})
|
|
if(!res.data.data.isChatVip){
|
|
this.setData({times:res.data.data.freeChatCount})
|
|
}
|
|
console.log(this.data.times)
|
|
}
|
|
console.log(this.userInfo);
|
|
}).catch((err)=>{
|
|
console.log(err);
|
|
})
|
|
},
|
|
go2Reback(){
|
|
wx.navigateBack({ changed: true });
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
this.getUserInfo()
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |