- 搜索不到数据?
[图片] //index.js //获取应用实例 const app = getApp() let searchKey = '' let api = require('../../config/api'); const db = wx.cloud.database() const data = require('../../config/data.js') Page({ data: { height:app.globalData.height*2+90, swipers:['swiper1','swiper2','swiper3'], active:0, plist:[], serverPath:api.ApiRootUrl, page:1, result:{}, good:{} }, //事件处理函数 bindViewTap: function() { wx.navigateTo({ url: '../logs/logs' }) }, onLoad: function () { console.log(data.tuijian) this.setData({ plist:data.tuijian }) }, tapName(e){ console.log(e) wx.navigateTo({ url: '/pages/index4/index4', }) }, onChange(event) { // event.detail 的值为当前选中项的索引 console.log(event.detail) //this.setData({ active: event.detail }); switch(event.detail){ case 0: wx.navigateTo({ url: '/pages/index/index', }) break; case 1: wx.navigateTo({ url: '/pages/mine/mine', }) break; } }, getSearch(event) { // event.detail 的值为当前选中项的索引 console.log(event.detail.value) searchKey = event.detail.value // let that=this // const db = wx.cloud.database({ // env:"xiaoshitou-sk1se" // }) // db.collection("mianliao").where({ //collectionName 表示欲模糊查询数据所在collection的名 // name:{ //columnName表示欲模糊查询数据所在列的名 // $regex:'.*' + event.detail + '.*', //queryContent表示欲查询的内容,‘.*’等同于SQL中的‘%’ // $options: 'i' //$options:'1' 代表这个like的条件不区分大小写,详见开发文档 // } // }) // .get({ // success:function(res){ // console.log("qqqqqqqq",res.data) // if(res.data&&res.data.length>0){ // that.setData({ // result:res.data.length>0?res.data[0]:{} // }) // }else{ // that.setData({ // result:{} // }) // wx.showToast({ // icon:"none", // title: '内容为空', // }) // } // }, // fail(res){ // console.log(res) // wx.showToast({ // icon:"none", // title: '内容为空', // }) // } // }) }, goSearch(){ console.log('触发了搜索',searchKey) if(searchKey && searchKey.length > 0){ //搜索触发写在里面 // let that=this const db = wx.cloud.database({ env:"xiaoshitou-sk1se" }) db.collection("mianliao").where({ //collectionName 表示欲模糊查询数据所在collection的名 name:db.RegExp({ //columnName表示欲模糊查询数据所在列的名 $regex:searchKey, //queryContent表示欲查询的内容,‘.*’等同于SQL中的‘%’ $options: 'i' //$options:'1' 代表这个like的条件不区分大小写,详见开发文档 }) }) .get() .then(res => { console.log('搜索成功',res) }) .catch(res => { console.log("搜索失败",res) }) }else{ wx.showToast({ icon:"none", title: '搜索词为空', }) } wx.navigateTo({ // url: '/pages/index5/index5?id='+e.currentTarget.dataset.id, url: '/pages/index5/index5?searchKey=' + searchKey, }) }, reachBottom(){ console.log('到达底部') this.page++; wx.request({ url:"http://localhost:9529/", // url: api.GoodsList, success:(res)=>{ let plist = res.data.productlist; plist.forEach((item,i)=>{ item.imgs = JSON.parse(item.imgs) }) plist = this.data.plist.concat(plist) console.log(plist) this.setData({ plist:plist }) } }) } })
2021-05-06 - 云开发图片加载问题?
[图片]
2021-05-05 - 页面布局?
[图片] 页面不能完全展示 /* 导航栏布局相关 */ .toubu{ height: 130rpx; border-bottom: 1px solid #ccc; position: relative; } .toubu .title{ top:70rpx; position: relative; width: 750rpx; text-align: center; left: 300rpx; bottom: 20rpx; font-size: 30rpx; } .toubu image{ top:70rpx; position: absolute; left: 20rpx; bottom: 20rpx; width: 40rpx; height: 40rpx; z-index: 100; } .navbars { /* padding-top: 120rpx; */ /* margin-top:200rpx; */ width: 100%; height: 90rpx; /* 文本不换行 */ white-space: nowrap; display: flex; box-sizing: border-box; border-bottom: 1rpx solid #eee; background: #fff; align-items: center; /* 固定在顶部 */ position: fixed; left: 0rpx; top: 130rpx ; } .nav-item { padding-left: 25rpx; padding-right: 25rpx; height: 100%; display: inline-block; /* 普通文字大小 */ font-size: 28rpx; } .nav-text { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; letter-spacing: 4rpx; box-sizing: border-box; } .tab-on { color: #000080; /* 选中放大 */ font-size: 38rpx !important; font-weight: 600; border-bottom: 4rpx solid #000080 !important; } /* 正文部分 */ .container { position: fixed; width: 100%; height: 90%; top: 220rpx ; background-color: #FFF; } .nav_left { width: 30%; height: 100%; background: #F2F2F2; text-align: center; position: absolute; top: 0; left: 0; } .nav_left .nav_left_items { height: 100rpx; line-height: 100rpx; font-size: 28rpx; } .nav_left .nav_left_items.active { position: relative; background: #FFF; color: #000080; } .nav_left .nav_left_items.active::before { display: inline-block; width: 6rpx; height: 60rpx; background: #000080; content: ''; position: absolute; top: 20rpx; left: 0; } .nav_right { position:absolute ; top: 0; right: 0; width: 70%; height: 100%; bottom: 100rpx; } .nav_right .nav_right_items { float: left; width: 33.33%; text-align: center; padding: 30rpx 0; } .nav_right .nav_right_items image { width: 120rpx; height: 160rpx; } .nav_right .nav_right_items text { display: block; margin-top: 20rpx; font-size: 28rpx; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } .nocate { padding: 100rpx; text-align: center; } .nocate image { width: 70rpx; height: 70rpx; } .nocate text { font-size: 28rpx; display: block; color: #BBB; } /*隐藏滚动条*/ ::-webkit-scrollbar { width: 0; height: 0; color: transparent; } .topx { width: 90%; /* height: 700rpx; */ margin: 30rpx auto; z-index: 1; border-radius: 10rpx; background-size: cover; }
2021-05-03 - 微信小程序id号获取不到?
[图片] Page({ data:{ good:{} } , onLoad(options) { console.log("列表携带的值",options) var id = options.id // var name = options.name //查询单条数据 wx.cloud.database().collection("demo").doc("id") // .doc("79550af26066c95c0d24ed8556960f24") .get() .then(res => { console.log("商品详情页请求成功",res) this.setData({ good:res.data }) }) .catch(res =>{ console.log("商品详情页请求失败") }) } })
2021-04-06 - 云开发点击图像不能跳转?
[图片] [图片] Page({ data:{ good:{} } , onLoad(options) { console.log("列表携带的值",options) var id = options.id // var name = options.name //查询单条数据 wx.cloud.database().collection("demo") // .doc("79550af26066c95c0d24ed8556960f24") .doc(_id) .get() .then(res => { console.log("商品详情页请求成功",res) this.setData({ good:res.data }) }) .catch(res =>{ console.log("商品详情页请求失败") }) } })
2021-04-05 - 云开发读取数据?
[图片] [图片]
2021-04-04 - 云开发图片不能加载?
[图片]
2021-04-04 - 云开发怎么上传图片?
[图片] 这里面要怎么写?
2021-04-02 - 云开发_id后怎么变成阿拉伯数字?
[图片]
2021-04-02 - 点击事件?
[图片] 怎么点击图标,上方方框展示信息?目前点击事件可以实现 //index.js //获取应用实例 const app = getApp() let api = require('../../config/api'); const data = require('../../config/data.js') Page({ data: { height:app.globalData.height*2+90, swipers:['swiper1','swiper2','swiper3'], active:0, plist:[], serverPath:api.ApiRootUrl, page:1, text: "你好", onOff: false }, btnclick:function(){ console.log('123'); var onOff = this.data.onOff; this.setData({text:"hello",onOff:!onOff}); }, //事件处理函数 bindViewTap: function() { wx.navigateTo({ url: '../logs/logs' }) }, onLoad: function () { // wx.request({ // url: api.GoodsList, // success:(res)=>{ // // console.log(res) // let plist = res.data.productlist; // plist.forEach((item,i)=>{ // item.imgs = JSON.parse(item.imgs) // }) // console.log(plist) // this.setData({ // plist:plist // }) // } // }) console.log(data.tuijian) this.setData({ plist:data.tuijian }) }, tapName(e){ console.log(e) wx.navigateTo({ url: '/pages/gengduo/gengduo', }) }, onChange(event) { // event.detail 的值为当前选中项的索引 console.log(event.detail) //this.setData({ active: event.detail }); switch(event.detail){ case 0: wx.navigateTo({ url: '/pages/index/index', }) break; case 1: wx.navigateTo({ url: '/pages/zixun/zixun', }) break; case 2: wx.navigateTo({ url: '/pages/chuanda/chuanda', }) break; case 3: wx.navigateTo({ url: '/pages/mine/mine', }) break; } }, reachBottom(){ console.log('到达底部') this.page++; wx.request({ url:"http://localhost:9529/", // url: api.GoodsList, success:(res)=>{ let plist = res.data.productlist; plist.forEach((item,i)=>{ item.imgs = JSON.parse(item.imgs) }) plist = this.data.plist.concat(plist) console.log(plist) this.setData({ plist:plist }) } }) }, goBack(){ wx.navigateBack() } }) wxml: [图片]
2020-12-24