deguodaigou/pages/product/product.js

110 lines
2.1 KiB
JavaScript
Raw Normal View History

2019-12-19 14:29:24 +08:00
// pages/product/product.js'
import { request } from "../../utils/bin"
2019-12-14 00:31:41 +08:00
Page({
2019-12-16 18:26:28 +08:00
/**
* 页面的初始数据
*/
data: {
2019-12-19 14:57:46 +08:00
array: ['20粒', '30粒', '50粒', '100粒'],
userid:0
2019-12-16 18:26:28 +08:00
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
2019-12-19 14:29:24 +08:00
console.log(options)
request({
url: "Goods/goodsInfo",
data: {
id: options.shopid
}
}).then((res) => {
// console.log(res)
this.setData({
info: res.data.result,
shopid:options.shopid,
})
// console.log(this.data.type, 150)
})
2019-12-19 14:57:46 +08:00
request({
url:"User/validateOpenid"
}).then((res)=>{
console.log(res)
this.setData({
userid:res.data.data.user_id
})
})
2019-12-16 18:26:28 +08:00
},
// goshop() {
// },
bindPickerChange(e) {
2019-12-19 14:29:24 +08:00
console.log(e.detail.value)
request({
url: "Cart/addCart",
data: {
goods_id: this.data.shopid,
goods_num: 1,
2019-12-19 14:57:46 +08:00
goods_spec:"",
user_id:this.data.userid
},
name:"session_id"
2019-12-19 14:29:24 +08:00
}).then((res)=>{
console.log(res)
wx.switchTab({
url: '/pages/shopping/shopping'
})
})
2019-12-16 18:26:28 +08:00
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
2019-12-14 00:31:41 +08:00
})