|
@@ -8,14 +8,28 @@ Page({
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
- var self = this;
|
|
|
+
|
|
|
|
|
|
self.dever.carts(self, 'carts.save', 'carts/index');
|
|
|
var success = function(data, res)
|
|
|
{
|
|
|
self.dever.setList(self, data.product);
|
|
|
};
|
|
|
- self.dever.request('main.api.home', {}, {success: success});
|
|
|
+ self.dever.request('main.api.home', {}, {success: success});*/
|
|
|
+
|
|
|
+
|
|
|
+ var list = new Array();
|
|
|
+ for(var i=1; i<4; i++){
|
|
|
+ var item = new Object();
|
|
|
+ item.id = i;
|
|
|
+ item.pic = '/static/img/item-'+(1+Math.round(Math.random()*1))+'.png';
|
|
|
+ item.name = i+'盒有机韭菜';
|
|
|
+ item.price = i*20;
|
|
|
+ list.push(item);
|
|
|
+ }
|
|
|
+ this.dever.setList(this, list);
|
|
|
+ this.dever.stopPullDown();
|
|
|
+
|
|
|
},
|
|
|
|
|
|
view: function (event) {
|
|
@@ -27,6 +41,15 @@ Page({
|
|
|
this.dever.location('view/index?id=' + id);
|
|
|
},
|
|
|
|
|
|
+ addCarts: function (event){
|
|
|
+ if (typeof (event) == 'object') {
|
|
|
+ var id = event.currentTarget.dataset.id
|
|
|
+ } else {
|
|
|
+ var id = event
|
|
|
+ }
|
|
|
+ this.dever.location('carts/index?id=' + id);
|
|
|
+ },
|
|
|
+
|
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|