fireflysg-wxapp/pages/shopList/shopDetail.js

120 lines
1.9 KiB
JavaScript

// pages/shopList/shopDetail.js
import request from '../../utils/request'
Page({
/**
* 页面的初始数据
*/
data: {
cur:false,
goodShow: false,
collectShow:false,
shopItem:''
},
goodEvent(){
this.setData({
cur: !this.data.cur
})
},
tapEvent1(){
this.setData({
goodShow: !this.data.goodShow
})
},
tapEvent2(){
this.setData({
collectShow: !this.data.collectShow
})
},
buyEvent(){
request._post('/firefly/cart/mycart/empty/all',{},
res=>{
if(res.retCode == 0){
this.buysubmit()
}
})
},
buysubmit(){
let id = this.data.shopItem.id
const param = {
"goodsId": id,
"count": 1
}
request._post('/firefly/cart/mycart/add/goods',param,
res=>{
if(res.retCode == 0){
wx.navigateTo({
url: '/pages/buy/index?id='+id
})
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getData(options.id)
},
getData(id){
const param = {
"goodsId": id
}
request._post('/firefly/goods/detail',param,
res=>{
if(res.retCode == 0){
this.setData({
shopItem:res.body
})
}
}
)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})