You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.1 KiB

8 years ago
const app = getApp()
8 years ago
const product = require('../../utils/product.js')
8 years ago
Page({
data: {
title: '',
8 years ago
id: 0,
address: '',
quantity: 1,
8 years ago
product: {}
},
onShow () {
this.setData({'address': Date.now()})
8 years ago
},
onLoad (params) {
8 years ago
var that = this
8 years ago
this.data.id = params.id
that.data.product = wx.getStorageSync('products').find(function(i){
return i.id === that.data.id
8 years ago
})
8 years ago
},
onReady () {
wx.setNavigationBarTitle({ title: this.data.title })
},
bindTapAddress () {
wx.navigateTo({
url: '../address/address'
})
8 years ago
},
bindAddToCart (e) {
//var existItem = wx.getStorageSync('cartItems')
// TODO
wx.setStorage({
key: `cart-${this.data.id}`,
data: {quantity: this.data.quantity}
})
},
bindQuantityInput (e) {
this.setData({'quantity': e.detail.value})
},
8 years ago
formSubmit: function(e) {
8 years ago
e.detail.value['sku'] = e.target.dataset['sku']
8 years ago
// address.postBuyProduct(e.detail.value)
console.log('form发生了submit事件,携带数据为:', e.detail.value)
},
8 years ago
})