eww
This commit is contained in:
parent
04f5606d22
commit
86b605b574
@ -1,5 +1,5 @@
|
|||||||
const baseUrl = 'https://mini-chat.1024tool.vip/';
|
// const baseUrl = 'https://mini-chat.1024tool.vip/api/';
|
||||||
|
const baseUrl = 'https://dsjhd9s.tbmw.cn/api/'
|
||||||
function request(url, method = 'GET', data = {}) {
|
function request(url, method = 'GET', data = {}) {
|
||||||
|
|
||||||
const header = {
|
const header = {
|
||||||
|
|||||||
@ -64,25 +64,26 @@ Page({
|
|||||||
|
|
||||||
getMessages() {
|
getMessages() {
|
||||||
const userInfo = wx.getStorageSync('user_info');
|
const userInfo = wx.getStorageSync('user_info');
|
||||||
|
const that = this;
|
||||||
request('app/messages', 'get', {
|
request('app/messages', 'get', {
|
||||||
app_id: this.data.appid,
|
app_id: that.data.appid,
|
||||||
user_id: userInfo.openid,
|
user_id: userInfo.openid,
|
||||||
page: this.data.page,
|
page: that.data.page,
|
||||||
page_size: this.data.page_size,
|
page_size: that.data.page_size,
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
console.log('res', res);
|
console.log('res', res);
|
||||||
// generate stable ids across pages so we can prepend without collisions
|
// generate stable ids across pages so we can prepend without collisions
|
||||||
const base = (this.data.page - 1) * this.data.page_size;
|
const base = (that.data.page - 1) * that.data.page_size;
|
||||||
const list = res.list.map((item, index) => {
|
const list = res.list.map((item, index) => {
|
||||||
item.id = 'm' + (base + index);
|
item.id = 'm' + (base + index);
|
||||||
item.content = JSON.parse(item.content);
|
item.content = JSON.parse(item.content);
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
this.setData({
|
that.setData({
|
||||||
messages: list,
|
messages: list,
|
||||||
total: res.total,
|
total: res.total,
|
||||||
// only auto-scroll if user is at bottom
|
// only auto-scroll if user is at bottom
|
||||||
scrollToId: this.data.isAtBottom ? (list[list.length - 1] ? list[list.length - 1].id : '') : this.data.scrollToId
|
scrollToId: that.data.isAtBottom ? (list[list.length - 1] ? list[list.length - 1].id : '') : that.data.scrollToId
|
||||||
});
|
});
|
||||||
console.log('messages', list);
|
console.log('messages', list);
|
||||||
})
|
})
|
||||||
@ -146,7 +147,7 @@ Page({
|
|||||||
const accountInfo = wx.getAccountInfoSync();
|
const accountInfo = wx.getAccountInfoSync();
|
||||||
wx.login({
|
wx.login({
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
request('api/wechat/miniprogram/login', 'post', {
|
request('wechat/miniprogram/login', 'post', {
|
||||||
"app_id": accountInfo.miniProgram.appId,
|
"app_id": accountInfo.miniProgram.appId,
|
||||||
"js_code": res.code,
|
"js_code": res.code,
|
||||||
"encrypted_data": user.encryptedData,
|
"encrypted_data": user.encryptedData,
|
||||||
@ -156,7 +157,7 @@ Page({
|
|||||||
}).then(resp => {
|
}).then(resp => {
|
||||||
wx.setStorageSync('user_info', resp);
|
wx.setStorageSync('user_info', resp);
|
||||||
// wx.setStorageSync('open_id', resp.openid);
|
// wx.setStorageSync('open_id', resp.openid);
|
||||||
this.setData({
|
that.setData({
|
||||||
showGetUser: false,
|
showGetUser: false,
|
||||||
userInfo: resp
|
userInfo: resp
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user