1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- // template/carts/index.js
- Page({
- dever: getApp().dever,
- addrObj: null,
- data: {
-
- },
- onLoad: function (options) {
- // 初始化购物车
- //self.dever.carts(self, 'carts.save', 'carts/index');
- //test - begin
- var list = new Array();
- for(var i=1; i<10; i++){
- var item = new Object();
- item.name = i+'盒有机韭菜';
- item.price = i*20;
- item.id = i;
- list.push(item);
- }
- this.dever.setList(this, list);
- //test - end
- },
- /**
- * 删除订单
- */
- delOrder: function(e){
- var that = this;
- wx.showModal({
- content: '确认删除该订单吗?',
- success: function(res){
- if (res.confirm){
- that.dever.alert('订单删除成功!');
- }
- }
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
- /**
- * 使用微信地址
- */
- chooseAddress: function(event){
- var that = this;
- var success = function(){
- wx.chooseAddress({
- success: function (res) {
- that.dever.log('wx.chooseAddress', res);
- that.addrObj = res;
- that.sets(that, res);
- },
- fail: function (res) {
- that.dever.log('wx.chooseAddress', 'fail');
- }
- })
- }
- wx.getSetting({
- success: function(res){
- if (res.authSetting['scope.address']){
- success();
- }else{
- wx.authorize({
- scope: 'scope.address',
- success: function () {
- success();
- }
- })
- }
- }
- })
- }
- })
|