|
@@ -3,35 +3,24 @@ Page({
|
|
|
data: {
|
|
|
test : 1
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
- * 生命周期函数--监听页面加载
|
|
|
- */
|
|
|
onLoad: function (options) {
|
|
|
-
|
|
|
|
|
|
- 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});*/
|
|
|
-
|
|
|
-
|
|
|
- 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);
|
|
|
+
|
|
|
+ var that = this;
|
|
|
+ var callback = {
|
|
|
+ success: function(data, res){
|
|
|
+ that.dever.setList(that, data.product);
|
|
|
+ that.dever.stopPullDown();
|
|
|
+ }
|
|
|
}
|
|
|
- this.dever.setList(this, list);
|
|
|
- this.dever.stopPullDown();
|
|
|
-
|
|
|
+ that.dever.request('product.api.home', {
|
|
|
+ signature:''
|
|
|
+ },callback);
|
|
|
},
|
|
|
|
|
|
+
|
|
|
+ * 查看商品详情
|
|
|
+ */
|
|
|
view: function (event) {
|
|
|
if (typeof (event) == 'object') {
|
|
|
var id = event.currentTarget.dataset.id
|
|
@@ -41,6 +30,9 @@ Page({
|
|
|
this.dever.location('view/index?id=' + id);
|
|
|
},
|
|
|
|
|
|
+
|
|
|
+ * 添加购物车
|
|
|
+ */
|
|
|
addCarts: function (event){
|
|
|
if (typeof (event) == 'object') {
|
|
|
var id = event.currentTarget.dataset.id
|
|
@@ -50,45 +42,8 @@ Page({
|
|
|
this.dever.location('carts/index?id=' + id);
|
|
|
},
|
|
|
|
|
|
-
|
|
|
- * 生命周期函数--监听页面初次渲染完成
|
|
|
- */
|
|
|
- onReady: function () {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- * 生命周期函数--监听页面显示
|
|
|
- */
|
|
|
- onShow: function () {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- * 生命周期函数--监听页面隐藏
|
|
|
- */
|
|
|
- onHide: function () {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- * 生命周期函数--监听页面卸载
|
|
|
- */
|
|
|
- onUnload: function () {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
- * 页面相关事件处理函数--监听用户下拉动作
|
|
|
- */
|
|
|
onPullDownRefresh: function () {
|
|
|
this.dever.startPullDown(this);
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- * 用户点击右上角分享
|
|
|
- */
|
|
|
- onShareAppMessage: function () {
|
|
|
-
|
|
|
- },
|
|
|
})
|