var utils = require('../../utils/util.js');
let app = getApp();
// 获取云数据库引用
const db = wx.cloud.database();
const allbookmsg = db.collection('booklist');
let bookmsg = null;
let password = null;
//index.js
//获取应用实例
var screenNum = 3;
// var app = getApp()
Page({
data: {
cateisShow: false,
activeNum: 1,
loading: true,
bookObj:null,
},
inputBook:function(event){
bookmsg=event.detail.value;
console.log(bookmsg)
},
//事件处理函数
bindViewTap: function () {
wx.navigateTo({
url: '../logs/logs'
})
},
onPullDownRefresh: function () {
//监听页面刷新
this.onLoad()
wx.stopPullDownRefresh()
},
onLoad: function () {
console.log(bookmsg);
var that = this;
utils.getUserData();
//图书列表数据获取
// wx.request({
// url: 'http://' + app.globalData.apiUrl + '/bookshare?m=home&c=Api&a=bookList',
// method: "GET",
// success: function (res) {
// that.setData({
// bookObj: res.data,
// loading:false
// })
// },
// fail: function () {
// wx.showToast({
// title: '获取数据失败,请稍后重试!',
// icon: 'false',
// duration: 2000
// })
// }
// })
},
onShow: function () {
this.onLoad()
console.log(bookmsg)
},
changeTab: function (event) {
//切换筛选tab
var num = event.target.dataset.id;
this.setData({
activeNum: num
})
},
searching:function(){
let that = this;
allbookmsg.get({
success: (res) => {
console.log(res);
}
})
},
screenISBN: function () {
console.log("搜索功能执行");
wx.getSetting({
success(res) {
console.log(res);
if (res.authSetting['scope.userInfo']) {
//已授权 扫描ISBN
wx.scanCode({
success: (res) => {
if (res.errMsg == "scanCode:ok") {
//扫描成功
if (res.scanType == "EAN_13") {
//条形码
var isbnCode = res.result;
wx.navigateTo({
url: '../share/share?isbn=' + isbnCode,
})
} else {
wx.showToast({
title: '条形码有误!',
})
}
} else {
wx.showToast({
title: '获取数据失败,请稍后重试!',
})
}
}
})
}else{
utils.checkSettingStatu();
}
}
})
},
detail: function (event) {
var bookId = event.currentTarget.dataset.bookid;
var canShareId = event.currentTarget.dataset.canshareid;
var book_type = event.currentTarget.dataset.type;//type 为1时自营点 为0时C2C
//打开详情页
wx.navigateTo({
url: '../detail/detail?bookId=' + bookId + "&canShareId=" + canShareId + "&book_type=" + book_type,
})
},
togglePtype: function () {
//显示分类
this.setData({
cateisShow: !this.data.cateisShow
})
},
})
searching:function(){
let that = this;
allbookmsg.get({
success: (res) => {
console.log(res);
}
c此处我请求到的res信息没有任何数组
此处的booklist是我存进去的数据,但是打印出来的res却没有,这是为什么?
数据库权限设置了吗?
所有人可读?
这是我请求到的res信息内容