Browse Source

upload

master
HolyKnightIX 1 year ago
parent
commit
643e8bf3b1
7 changed files with 41 additions and 22 deletions
  1. +5
    -0
      miniprogram/app.js
  2. +19
    -8
      miniprogram/pages/chat/chat.js
  3. +3
    -2
      miniprogram/pages/chat/chat.wxml
  4. +9
    -1
      miniprogram/pages/index/index.js
  5. +1
    -1
      miniprogram/pages/index/index.less
  6. +2
    -0
      miniprogram/pages/index/index.wxml
  7. +2
    -10
      miniprogram/pages/payOrder/payOrder.js

+ 5
- 0
miniprogram/app.js View File

@@ -1,4 +1,5 @@
const request = require('./utils/request')
import { timestampToTime } from './utils/util'

App({
globalData: {
@@ -58,6 +59,10 @@ App({
url: '/api/user/userinfo'
}).then(res => {
console.log(res, 'userinfo');
res.data.createDate = res.data.createDate ? timestampToTime(res.data.createDate, 'YYYY-MM-DD hh:mm:ss') : ''
res.data.updateDate = res.data.updateDate ? timestampToTime(res.data.updateDate, 'YYYY-MM-DD hh:mm:ss') : ''
res.data.validStartTime = res.data.validStartTime ? timestampToTime(res.data.validStartTime, 'YYYY-MM-DD hh:mm:ss') : ''
res.data.validEndTime = res.data.validEndTime ? timestampToTime(res.data.validEndTime, 'YYYY-MM-DD hh:mm:ss') : ''
const userInfo = res.data
that.globalData.userInfo = userInfo
// 请求完成后的回调,在index.js中调用防止异步


+ 19
- 8
miniprogram/pages/chat/chat.js View File

@@ -10,7 +10,8 @@ Page({
waitingMessage: "",
isResponing: false,
chatOver: false,
messageFlag: true
messageFlag: true,
scrollTop: 0
},

/**
@@ -153,15 +154,12 @@ Page({
that.setData({
isResponing: false
})
setTimeout(() => {
console.log('当前会话已关闭');
// wx.showToast({
// title: '当前会话已关闭',
// icon: 'error'
// })
}, 10000);
// setTimeout(() => {
// console.log('10s');
// }, 10000);
} else {
that.messageIn(msgBack)
that.scrollToBottom('scrollSingel')
that.setData({
isResponing: true
})
@@ -177,6 +175,19 @@ Page({
})
},

scrollToBottom(id) {
const that = this
wx.createSelectorQuery().select('#' + id).boundingClientRect(function (rect) {
wx.pageScrollTo({
scrollTop: rect.height,
duration: 100 // 滑动速度
})
that.setData({
scrollTop: rect.height - that.data.scrollTop
});
}).exec();
},

/**
* 生命周期函数--监听页面初次渲染完成
*/


+ 3
- 2
miniprogram/pages/chat/chat.wxml View File

@@ -1,5 +1,5 @@
<!--pages/chat/chat.wxml-->
<view class="content">
<view class="content" id='scrollSingel'>
<view class="chatItem" wx:for="{{chatList}}" wx:key="index">
<view class="{{item.id == 1 ? 'chatContent right' : 'chatContent left'}}">
<image class="{{isResponing ? 'chatGpt isResponing' : 'chatGpt'}}" wx:if="{{!item.id}}" src="../../asset/icon/tiny-Chat-rotate.png" mode="heightFix" />
@@ -15,4 +15,5 @@
<input class="inputBox" type="text" bindinput="input" value="{{message}}" />
<button class="sendBtn" type="primary" bindtap="send">发送</button>
</view>
</view>
</view>
<view></view>

+ 9
- 1
miniprogram/pages/index/index.js View File

@@ -1,5 +1,6 @@
const app = getApp()
import request from '../../utils/request'
import { timestampToTime } from '../../utils/util'

Page({
data: {
@@ -16,7 +17,10 @@ Page({
url: '../logs/logs',
})
},
onLoad() {
onLoad(option) {
if (option.checkUserInfo) {
this.checkUserInfo()
}
const that = this
app.userInfoCallback = res => {
console.log(res, 'userInfoCallback')
@@ -95,6 +99,10 @@ Page({
url: '/api/user/userinfo'
}).then(res => {
console.log(res, 'userinfo');
res.data.createDate = res.data.createDate ? timestampToTime(res.data.createDate, 'YYYY-MM-DD hh:mm:ss') : ''
res.data.updateDate = res.data.updateDate ? timestampToTime(res.data.updateDate, 'YYYY-MM-DD hh:mm:ss') : ''
res.data.validStartTime = res.data.validStartTime ? timestampToTime(res.data.validStartTime, 'YYYY-MM-DD hh:mm:ss') : ''
res.data.validEndTime = res.data.validEndTime ? timestampToTime(res.data.validEndTime, 'YYYY-MM-DD hh:mm:ss') : ''
this.setData({
userInfo: res.data,
isPhone: this.data.userInfo.phone ? true : false


+ 1
- 1
miniprogram/pages/index/index.less View File

@@ -45,7 +45,7 @@
font-size: 22rpx;
color: #929292;
padding: 0 50rpx;
margin-top: 20rpx;
margin-top: 35rpx;
}
}



+ 2
- 0
miniprogram/pages/index/index.wxml View File

@@ -25,12 +25,14 @@

<block wx:if="{{userInfo.isMember == 1 && userInfo.isValid == 1}}">
<view class="userPhone">当前用户:{{userInfo.phone}}</view>
<view class="userPhone" wx:if="{{userInfo.validEndTime}}">到期时间:{{userInfo.validEndTime}}</view>
<view class="payHistory" bindtap="checkPayHistory">购买历史</view>
<button type="primary" bindtap="goToChat">开始聊天</button>
</block>

<block wx:if="{{userInfo.isMember == 1 && userInfo.isValid == 0}}">
<view class="userPhone">当前用户:{{userInfo.phone}}</view>
<view class="userPhone" wx:if="{{userInfo.validEndTime}}">到期时间:{{userInfo.validEndTime}}</view>
<view class="payHistory" bindtap="checkPayHistory">购买历史</view>
<button type="primary" bindtap="goToBuy">续费会员</button>
</block>


+ 2
- 10
miniprogram/pages/payOrder/payOrder.js View File

@@ -65,17 +65,9 @@ Page({
title: '订单正在处理中...',
})
setTimeout(() => {
wx.showToast({
title: '支付成功',
icon: 'success',
duration: 2000
wx.navigateTo({
url: '/pages/index/index?checkUserInfo="go"'
})
setTimeout(() => {
wx.redirectTo({
url: '/pages/index/index',
})
}, 2000);
wx.hideLoading();
}, 2000);
},
fail: res => {


Loading…
Cancel
Save