| @@ -1,4 +1,5 @@ | |||||
| const request = require('./utils/request') | const request = require('./utils/request') | ||||
| import { timestampToTime } from './utils/util' | |||||
| App({ | App({ | ||||
| globalData: { | globalData: { | ||||
| @@ -58,6 +59,10 @@ App({ | |||||
| url: '/api/user/userinfo' | url: '/api/user/userinfo' | ||||
| }).then(res => { | }).then(res => { | ||||
| console.log(res, 'userinfo'); | 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 | const userInfo = res.data | ||||
| that.globalData.userInfo = userInfo | that.globalData.userInfo = userInfo | ||||
| // 请求完成后的回调,在index.js中调用防止异步 | // 请求完成后的回调,在index.js中调用防止异步 | ||||
| @@ -10,7 +10,8 @@ Page({ | |||||
| waitingMessage: "", | waitingMessage: "", | ||||
| isResponing: false, | isResponing: false, | ||||
| chatOver: false, | chatOver: false, | ||||
| messageFlag: true | |||||
| messageFlag: true, | |||||
| scrollTop: 0 | |||||
| }, | }, | ||||
| /** | /** | ||||
| @@ -153,15 +154,12 @@ Page({ | |||||
| that.setData({ | that.setData({ | ||||
| isResponing: false | isResponing: false | ||||
| }) | }) | ||||
| setTimeout(() => { | |||||
| console.log('当前会话已关闭'); | |||||
| // wx.showToast({ | |||||
| // title: '当前会话已关闭', | |||||
| // icon: 'error' | |||||
| // }) | |||||
| }, 10000); | |||||
| // setTimeout(() => { | |||||
| // console.log('10s'); | |||||
| // }, 10000); | |||||
| } else { | } else { | ||||
| that.messageIn(msgBack) | that.messageIn(msgBack) | ||||
| that.scrollToBottom('scrollSingel') | |||||
| that.setData({ | that.setData({ | ||||
| isResponing: true | 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(); | |||||
| }, | |||||
| /** | /** | ||||
| * 生命周期函数--监听页面初次渲染完成 | * 生命周期函数--监听页面初次渲染完成 | ||||
| */ | */ | ||||
| @@ -1,5 +1,5 @@ | |||||
| <!--pages/chat/chat.wxml--> | <!--pages/chat/chat.wxml--> | ||||
| <view class="content"> | |||||
| <view class="content" id='scrollSingel'> | |||||
| <view class="chatItem" wx:for="{{chatList}}" wx:key="index"> | <view class="chatItem" wx:for="{{chatList}}" wx:key="index"> | ||||
| <view class="{{item.id == 1 ? 'chatContent right' : 'chatContent left'}}"> | <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" /> | <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}}" /> | <input class="inputBox" type="text" bindinput="input" value="{{message}}" /> | ||||
| <button class="sendBtn" type="primary" bindtap="send">发送</button> | <button class="sendBtn" type="primary" bindtap="send">发送</button> | ||||
| </view> | </view> | ||||
| </view> | |||||
| </view> | |||||
| <view></view> | |||||
| @@ -1,5 +1,6 @@ | |||||
| const app = getApp() | const app = getApp() | ||||
| import request from '../../utils/request' | import request from '../../utils/request' | ||||
| import { timestampToTime } from '../../utils/util' | |||||
| Page({ | Page({ | ||||
| data: { | data: { | ||||
| @@ -16,7 +17,10 @@ Page({ | |||||
| url: '../logs/logs', | url: '../logs/logs', | ||||
| }) | }) | ||||
| }, | }, | ||||
| onLoad() { | |||||
| onLoad(option) { | |||||
| if (option.checkUserInfo) { | |||||
| this.checkUserInfo() | |||||
| } | |||||
| const that = this | const that = this | ||||
| app.userInfoCallback = res => { | app.userInfoCallback = res => { | ||||
| console.log(res, 'userInfoCallback') | console.log(res, 'userInfoCallback') | ||||
| @@ -95,6 +99,10 @@ Page({ | |||||
| url: '/api/user/userinfo' | url: '/api/user/userinfo' | ||||
| }).then(res => { | }).then(res => { | ||||
| console.log(res, 'userinfo'); | 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({ | this.setData({ | ||||
| userInfo: res.data, | userInfo: res.data, | ||||
| isPhone: this.data.userInfo.phone ? true : false | isPhone: this.data.userInfo.phone ? true : false | ||||
| @@ -45,7 +45,7 @@ | |||||
| font-size: 22rpx; | font-size: 22rpx; | ||||
| color: #929292; | color: #929292; | ||||
| padding: 0 50rpx; | padding: 0 50rpx; | ||||
| margin-top: 20rpx; | |||||
| margin-top: 35rpx; | |||||
| } | } | ||||
| } | } | ||||
| @@ -25,12 +25,14 @@ | |||||
| <block wx:if="{{userInfo.isMember == 1 && userInfo.isValid == 1}}"> | <block wx:if="{{userInfo.isMember == 1 && userInfo.isValid == 1}}"> | ||||
| <view class="userPhone">当前用户:{{userInfo.phone}}</view> | <view class="userPhone">当前用户:{{userInfo.phone}}</view> | ||||
| <view class="userPhone" wx:if="{{userInfo.validEndTime}}">到期时间:{{userInfo.validEndTime}}</view> | |||||
| <view class="payHistory" bindtap="checkPayHistory">购买历史</view> | <view class="payHistory" bindtap="checkPayHistory">购买历史</view> | ||||
| <button type="primary" bindtap="goToChat">开始聊天</button> | <button type="primary" bindtap="goToChat">开始聊天</button> | ||||
| </block> | </block> | ||||
| <block wx:if="{{userInfo.isMember == 1 && userInfo.isValid == 0}}"> | <block wx:if="{{userInfo.isMember == 1 && userInfo.isValid == 0}}"> | ||||
| <view class="userPhone">当前用户:{{userInfo.phone}}</view> | <view class="userPhone">当前用户:{{userInfo.phone}}</view> | ||||
| <view class="userPhone" wx:if="{{userInfo.validEndTime}}">到期时间:{{userInfo.validEndTime}}</view> | |||||
| <view class="payHistory" bindtap="checkPayHistory">购买历史</view> | <view class="payHistory" bindtap="checkPayHistory">购买历史</view> | ||||
| <button type="primary" bindtap="goToBuy">续费会员</button> | <button type="primary" bindtap="goToBuy">续费会员</button> | ||||
| </block> | </block> | ||||
| @@ -65,17 +65,9 @@ Page({ | |||||
| title: '订单正在处理中...', | title: '订单正在处理中...', | ||||
| }) | }) | ||||
| setTimeout(() => { | 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); | }, 2000); | ||||
| }, | }, | ||||
| fail: res => { | fail: res => { | ||||