@@ -3,7 +3,8 @@ | |||||
"pages/index/index", | "pages/index/index", | ||||
"pages/logs/logs", | "pages/logs/logs", | ||||
"pages/payOrder/payOrder", | "pages/payOrder/payOrder", | ||||
"pages/payHistory/payHistory" | |||||
"pages/payHistory/payHistory", | |||||
"pages/chat/chat" | |||||
], | ], | ||||
"window": { | "window": { | ||||
"backgroundTextStyle": "light", | "backgroundTextStyle": "light", | ||||
@@ -0,0 +1,100 @@ | |||||
// pages/chat/chat.ts | |||||
Page({ | |||||
/** | |||||
* 页面的初始数据 | |||||
*/ | |||||
data: { | |||||
chatList: [], | |||||
message: "" | |||||
}, | |||||
/** | |||||
* 生命周期函数--监听页面加载 | |||||
*/ | |||||
onLoad() { | |||||
this.socketLink() | |||||
}, | |||||
input(e) { | |||||
this.setData({ | |||||
message: e.detail.value | |||||
}) | |||||
}, | |||||
send() { | |||||
const data = { | |||||
message: this.data.message | |||||
} | |||||
const arr = this.data.chatList | |||||
arr.push(data) | |||||
this.setData({ | |||||
chatList: arr, | |||||
message: '' | |||||
}) | |||||
}, | |||||
socketLink() { | |||||
wx.connectSocket({ | |||||
url: 'wss://gptsockettest.malls.iformall.com:8010', | |||||
header: { | |||||
'content-type': 'application/json' | |||||
}, | |||||
success: function (res) { | |||||
console.log(res) | |||||
}, | |||||
fail: function (err) { | |||||
console.log(err) | |||||
} | |||||
}) | |||||
}, | |||||
/** | |||||
* 生命周期函数--监听页面初次渲染完成 | |||||
*/ | |||||
onReady() { | |||||
}, | |||||
/** | |||||
* 生命周期函数--监听页面显示 | |||||
*/ | |||||
onShow() { | |||||
}, | |||||
/** | |||||
* 生命周期函数--监听页面隐藏 | |||||
*/ | |||||
onHide() { | |||||
}, | |||||
/** | |||||
* 生命周期函数--监听页面卸载 | |||||
*/ | |||||
onUnload() { | |||||
}, | |||||
/** | |||||
* 页面相关事件处理函数--监听用户下拉动作 | |||||
*/ | |||||
onPullDownRefresh() { | |||||
}, | |||||
/** | |||||
* 页面上拉触底事件的处理函数 | |||||
*/ | |||||
onReachBottom() { | |||||
}, | |||||
/** | |||||
* 用户点击右上角分享 | |||||
*/ | |||||
onShareAppMessage() { | |||||
} | |||||
}) |
@@ -0,0 +1,4 @@ | |||||
{ | |||||
"navigationBarTitleText": "聊天", | |||||
"usingComponents": {} | |||||
} |
@@ -0,0 +1,29 @@ | |||||
/* pages/chat/chat.wxss */ | |||||
.content { | |||||
padding: 0 50rpx; | |||||
.chatItem { | |||||
margin-bottom: 20rpx; | |||||
} | |||||
} | |||||
.chatBox { | |||||
position: fixed; | |||||
bottom: 100rpx; | |||||
padding-left: 40rpx; | |||||
.inputBox { | |||||
display: inline-block; | |||||
width: 500rpx; | |||||
border: 1px solid #000; | |||||
border-radius: 10rpx; | |||||
margin-right: 15rpx; | |||||
padding-left: 10rpx; | |||||
} | |||||
.sendBtn { | |||||
display: inline-block; | |||||
width: 150rpx; | |||||
padding: 5rpx 0; | |||||
} | |||||
} |
@@ -0,0 +1,11 @@ | |||||
<!--pages/chat/chat.wxml--> | |||||
<view class="content"> | |||||
<view class="chatItem" wx:for="{{chatList}}" wx:key="index"> | |||||
我: {{item.message}} | |||||
</view> | |||||
</view> | |||||
<view class="chatBox"> | |||||
<input class="inputBox" type="text" bindinput="input" value="{{message}}" /> | |||||
<button class="sendBtn" type="primary" bindtap="send">发送</button> | |||||
</view> |
@@ -77,6 +77,12 @@ Page({ | |||||
}) | }) | ||||
}, | }, | ||||
goToChat() { | |||||
wx.navigateTo({ | |||||
url: '/pages/chat/chat', | |||||
}) | |||||
}, | |||||
/** | /** | ||||
* @description 检查用户信息 | * @description 检查用户信息 | ||||
* @returns userInfo | * @returns userInfo | ||||
@@ -11,7 +11,16 @@ | |||||
<block wx:if="{{!userInfo.phone}}"> | <block wx:if="{{!userInfo.phone}}"> | ||||
<button type="primary" open-type="getPhoneNumber" bindgetphonenumber="getUserPhone">申请使用</button> | <button type="primary" open-type="getPhoneNumber" bindgetphonenumber="getUserPhone">申请使用</button> | ||||
</block> | </block> | ||||
<block wx:else> | |||||
<block wx:if="{{userInfo.isMember == 1 && userInfo.isValid == 1}}"> | |||||
<button type="primary" bindtap="goToChat">开始聊天</button> | |||||
</block> | |||||
<block wx:if="{{userInfo.isMember == 1 && userInfo.isValid == 0}}"> | |||||
<button type="primary" bindtap="goToBuy">续费会员</button> | |||||
</block> | |||||
<block wx:if="{{userInfo.phone && userInfo.isMember == 0 && userInfo.isValid == 0}}"> | |||||
<view class="userPhone">当前用户:{{userInfo.phone}}</view> | <view class="userPhone">当前用户:{{userInfo.phone}}</view> | ||||
<button type="primary" bindtap="goToBuy">购买会员</button> | <button type="primary" bindtap="goToBuy">购买会员</button> | ||||
</block> | </block> | ||||
@@ -6,5 +6,17 @@ | |||||
"urlCheck": false | "urlCheck": false | ||||
}, | }, | ||||
"libVersion": "2.31.0", | "libVersion": "2.31.0", | ||||
"condition": {} | |||||
"condition": { | |||||
"miniprogram": { | |||||
"list": [ | |||||
{ | |||||
"name": "", | |||||
"pathName": "pages/chat/chat", | |||||
"query": "", | |||||
"launchMode": "default", | |||||
"scene": null | |||||
} | |||||
] | |||||
} | |||||
} | |||||
} | } |
@@ -32,6 +32,7 @@ | |||||
"miniprogram/pages/index/index.js", | "miniprogram/pages/index/index.js", | ||||
"miniprogram/pages/payOrder/payOrder.js", | "miniprogram/pages/payOrder/payOrder.js", | ||||
"miniprogram/pages/payHistory/payHistory.js", | "miniprogram/pages/payHistory/payHistory.js", | ||||
"miniprogram/pages/chat/chat.js", | |||||
], | ], | ||||
"exclude": [ | "exclude": [ | ||||
"node_modules" | "node_modules" | ||||