|
|
@@ -2,7 +2,7 @@
|
|
|
<view class="content">
|
|
|
<navigation-custom :config="config" :scrollTop="scrollTopNav" @customConduct="customConduct" :scrollMaxHeight="scrollMaxHeight" />
|
|
|
<scroll-view id="scrollview" class='chat-box' :style="{height: style.contentViewHeight + 'px'}" scroll-y="true"
|
|
|
- :scroll-with-animation="true" :scroll-top="scrollTop">
|
|
|
+ :scroll-with-animation="false" :scroll-top="scrollTop" @scrolltoupper="lower()">
|
|
|
<view class="tips-box">
|
|
|
{{nowTime}}
|
|
|
</view>
|
|
|
@@ -12,7 +12,7 @@
|
|
|
|
|
|
<view class="talk-box">
|
|
|
<view class="talk-head-box">
|
|
|
- <image src="../../static/logo.png" mode="" class="talk-head"></image>
|
|
|
+ <image src="../../static/logo.png" mode="" class="talk-head"></image>
|
|
|
</view>
|
|
|
<view class="talk-content">您好,智能顾投很高兴为您服务!</view>
|
|
|
</view>
|
|
|
@@ -45,6 +45,7 @@
|
|
|
<script>
|
|
|
import navigationCustom from "../../components/struggler-navigationCustom/navigation-custom";
|
|
|
var md5 = require("../../common/md5.js");
|
|
|
+ var page = 1;
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -69,6 +70,8 @@
|
|
|
scrollTopNav: 0, // 当linear为true的时候需要通过onpagescroll传递参数
|
|
|
scrollMaxHeight: 200 ,//滑动的高度限制,超过这个高度即背景全部显示
|
|
|
scrollTop:0,
|
|
|
+ scrollRequestEnable: true,
|
|
|
+ pageSize:10,
|
|
|
style: {
|
|
|
pageHeight: 0,
|
|
|
contentViewHeight: 0,
|
|
|
@@ -84,15 +87,48 @@
|
|
|
this.scrollTopNav = e.scrollTop;
|
|
|
},
|
|
|
onLoad() {
|
|
|
+ this.userLogin();
|
|
|
this.getEquipmentHeight();
|
|
|
- setTimeout(()=>{
|
|
|
- this.getHistory();
|
|
|
- },100)
|
|
|
},
|
|
|
onShow() {
|
|
|
this.getNowTime();
|
|
|
},
|
|
|
methods: {
|
|
|
+ userLogin(){
|
|
|
+ uni.login({
|
|
|
+ success: (res) => {
|
|
|
+ this.getCodeRabot(res)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getCodeRabot(res){
|
|
|
+ let that = this;
|
|
|
+ uni.request({
|
|
|
+ url:getApp().globalData.shareUrl, //需要设置为全局
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ method: 'login',
|
|
|
+ timestamp: getApp().globalData.globalTimestamp, //Date.now()
|
|
|
+ code: res.code,
|
|
|
+ sign: md5('login' + getApp().globalData.globalTimestamp),
|
|
|
+ // invited:'invited'
|
|
|
+ },
|
|
|
+ success: res => {
|
|
|
+ // 通过openid发起会员登录
|
|
|
+ getApp().globalData.user_id = res.data.msg.id;
|
|
|
+ getApp().globalData.open_id = res.data.msg.openid;
|
|
|
+ getApp().globalData.isAuth = res.data.msg.isauth === '0';
|
|
|
+ getApp().globalData.user_name = res.data.msg.name;
|
|
|
+ getApp().globalData.user_headUrl = res.data.msg.headimg;
|
|
|
+ getApp().globalData.times = res.data.msg.times;
|
|
|
+ getApp().globalData.total_times = res.data.msg.total_times;
|
|
|
+ that.getHistory();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
getNowTime() {
|
|
|
let time = new Date();
|
|
|
let y = time.getFullYear();
|
|
|
@@ -109,7 +145,6 @@
|
|
|
getApp().globalData.glbalHeight = this.nowHeight;
|
|
|
this.style.pageHeight = height;
|
|
|
this.style.contentViewHeight = height - uni.getSystemInfoSync().screenWidth / 750 * (100) - 70; //像素 因为给出的是像素高度 然后我们用的是upx 所以换算一下
|
|
|
-
|
|
|
},
|
|
|
scrollToBottom() {
|
|
|
let that = this;
|
|
|
@@ -139,18 +174,29 @@
|
|
|
data: {
|
|
|
method: 'question_list',
|
|
|
timestamp: getApp().globalData.globalTimestamp, //Date.now()
|
|
|
- uid: getApp().globalData.user_id || '1',
|
|
|
+ uid: getApp().globalData.user_id,
|
|
|
sign: md5('question_list' + getApp().globalData.globalTimestamp),
|
|
|
- page: 1,
|
|
|
+ page: page || 1,
|
|
|
pageSize: 10,
|
|
|
},
|
|
|
success: res => {
|
|
|
- that.talkList = (res.data.msg).reverse();
|
|
|
that.userHeadUrl = getApp().globalData.user_headUrl;
|
|
|
- setTimeout(()=>{
|
|
|
- that.scrollToBottom()
|
|
|
- },100)
|
|
|
-
|
|
|
+ if(page === 1){
|
|
|
+ that.scrollRequestEnable = true;
|
|
|
+ that.talkList = ((res.data.msg).reverse());
|
|
|
+ console.log(1,that.talkList)
|
|
|
+ setTimeout(()=>{
|
|
|
+ that.scrollToBottom()
|
|
|
+ },100)
|
|
|
+ }else if (page > 1 && res.data.msg.length === that.pageSize) {
|
|
|
+ that.scrollRequestEnable = true;
|
|
|
+ that.talkList.unshift(...((res.data.msg).reverse()));
|
|
|
+ }else if (page > 1 && (res.data.msg.length > 0) && (res.data.msg.length < that.pageSize)){
|
|
|
+ that.scrollRequestEnable = true;
|
|
|
+ that.talkList.unshift(...((res.data.msg).reverse()));
|
|
|
+ }else if (page > 1 && res.data.msg.length == 0){
|
|
|
+ that.scrollRequestEnable = false;
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
@@ -159,7 +205,7 @@
|
|
|
url: '../selfInfo/selfInfo'
|
|
|
})
|
|
|
},
|
|
|
- sendMsgRequest(msg) {
|
|
|
+ sendMsgRequest(msg) {
|
|
|
let that = this;
|
|
|
uni.request({
|
|
|
url: getApp().globalData.shareUrl, //需要设置为全局
|
|
|
@@ -176,7 +222,7 @@
|
|
|
},
|
|
|
success: res => {
|
|
|
this.inputInfo = '';
|
|
|
- that.getHistory()
|
|
|
+ that.getHistory();
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
@@ -187,9 +233,22 @@
|
|
|
icon: 'none'
|
|
|
});
|
|
|
} else {
|
|
|
+ page = 1;
|
|
|
this.sendMsgRequest(this.inputInfo)
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ // 滚动至底部触发的事件
|
|
|
+ lower() {
|
|
|
+ if (this.scrollRequestEnable) {
|
|
|
+ // 允许滚动时,触底page加一,重新请求数据
|
|
|
+ page++;
|
|
|
+ this.getHistory();
|
|
|
+ } else {
|
|
|
+ // 不允许滚动时,只显示"到底了"提示
|
|
|
+ // this.showBottem = true
|
|
|
+ console.log('noData')
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
}
|
|
|
</script>
|