home.html
<view class="home-banner">
<swiper indicator-dots="ture" indicator-color="#ff0000" autoplay="true" interval="3500" circular="true">
<block wx:for="{{bannerList}}" wx:key="_id">
<swiper-item>
<image src="{{item.imgUrl}}" class="home-banner_img" ></image>
</swiper-item>
</block>
</swiper>
</view>
home.js
// 获取轮播的数据
getBanner: function() {
// orderBy排序,desc以降序方式,limit限制请求多少个
db.collection('emall').orderBy('count','desc').limit(4).get({
success: res => {
this.setData({
bannerList: res.data
})
}
})
},
onLoad: function (options) {
this.getBanner()
}
当点击详情页时,进行访问量加一 detail.js
*/
onLoad: function (options) {
this.setData({
ig: options,
goodList: []
})
// 获取当前某个商品的数据
const ins = db.collection('emall').doc(options.id)
// 记录访问量 db.command.inc()每次自增多少,自己定义
ins.update({
data: {
count: db.command.inc(1)
}
})
ins.get({
success: res => {
console.log(res)
this.setData({
goodList: res.data
})
}
})
},