Browse Source

uploaf

master
HolyKnightIX 1 year ago
parent
commit
a2c58d92ef
9 changed files with 176 additions and 3 deletions
  1. +2
    -1
      miniprogram/app.json
  2. +100
    -0
      miniprogram/pages/chat/chat.js
  3. +4
    -0
      miniprogram/pages/chat/chat.json
  4. +29
    -0
      miniprogram/pages/chat/chat.less
  5. +11
    -0
      miniprogram/pages/chat/chat.wxml
  6. +6
    -0
      miniprogram/pages/index/index.js
  7. +10
    -1
      miniprogram/pages/index/index.wxml
  8. +13
    -1
      project.private.config.json
  9. +1
    -0
      tsconfig.json

+ 2
- 1
miniprogram/app.json View File

@@ -3,7 +3,8 @@
"pages/index/index",
"pages/logs/logs",
"pages/payOrder/payOrder",
"pages/payHistory/payHistory"
"pages/payHistory/payHistory",
"pages/chat/chat"
],
"window": {
"backgroundTextStyle": "light",


+ 100
- 0
miniprogram/pages/chat/chat.js View File

@@ -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() {

}
})

+ 4
- 0
miniprogram/pages/chat/chat.json View File

@@ -0,0 +1,4 @@
{
"navigationBarTitleText": "聊天",
"usingComponents": {}
}

+ 29
- 0
miniprogram/pages/chat/chat.less View File

@@ -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;
}
}

+ 11
- 0
miniprogram/pages/chat/chat.wxml View File

@@ -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>

+ 6
- 0
miniprogram/pages/index/index.js View File

@@ -77,6 +77,12 @@ Page({
})
},

goToChat() {
wx.navigateTo({
url: '/pages/chat/chat',
})
},

/**
* @description 检查用户信息
* @returns userInfo


+ 10
- 1
miniprogram/pages/index/index.wxml View File

@@ -11,7 +11,16 @@
<block wx:if="{{!userInfo.phone}}">
<button type="primary" open-type="getPhoneNumber" bindgetphonenumber="getUserPhone">申请使用</button>
</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>
<button type="primary" bindtap="goToBuy">购买会员</button>
</block>


+ 13
- 1
project.private.config.json View File

@@ -6,5 +6,17 @@
"urlCheck": false
},
"libVersion": "2.31.0",
"condition": {}
"condition": {
"miniprogram": {
"list": [
{
"name": "",
"pathName": "pages/chat/chat",
"query": "",
"launchMode": "default",
"scene": null
}
]
}
}
}

+ 1
- 0
tsconfig.json View File

@@ -32,6 +32,7 @@
"miniprogram/pages/index/index.js",
"miniprogram/pages/payOrder/payOrder.js",
"miniprogram/pages/payHistory/payHistory.js",
"miniprogram/pages/chat/chat.js",
],
"exclude": [
"node_modules"


Loading…
Cancel
Save