| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- var app = new Vue({
- 'el': '#app',
- 'data': {
- // 列表数据
- dataList: [],
- // 参数
- params: {
- page: 1,
- status: 0,
- pageSize: 10,
- },
- loading: false,
- loaded: false,
- },
- created: function(){
- this.getDataList(0);
- },
- mounted: function(){
- var _this = this;
- $(".weui-navbar__item").click(function(){
- _this.params.page = 1;
- _this.loaded = false;
- _this.params.status = $(this).index();
- $(this).addClass('on').siblings().removeClass('on');
- _this.dataList = [];
- _this.getDataList(0);
- });
- $(window).scroll(function(){
- var scrollHeight = $(this).scrollTop();
- var height = $('body')[0].scrollHeight;
- var docHeight = $(this).outerHeight();
- if(docHeight+scrollHeight >= height){
- if(_this.loading || _this.loaded){
- return false;
- }
- _this.params.page++;
- _this.getDataList(1);
- }
- })
- },
- methods: {
- // 获取列表数据
- getDataList: function(more){
- var _this = this;
- _this.loading = true;
- if(_this.params.page == 1){
- _this.dataList = [];
- }
- $.showLoading("数据加载中...");
- $.post('/weixin/order/getList', _this.params, function (res) {
- _this.loading = false;
- $.hideLoading();
- if (res.code == 'success') {
- if(res.data.length<=0 && _this.params.page > 1){
- _this.loaded = true;
- $.toast("已加载完全部...",'text');
- return false;
- }
- if(more){
- $.each(res.data, function(k,item){
- console.log(item);
- _this.dataList.push(item);
- });
- }else{
- _this.dataList = res.data
- }
- }else if(res.code == 'login'){
- login(res.data.url);
- }
- }, "json");
- },
- // 商品详情
- showGoods:function(id){
- if(id>0){
- location.href = '/weixin/goods/detail?id='+id;
- }
- },
- // 确认收货
- delivery: function(data){
- var _this = this;
- $.modal({
- title: "确认收货",
- text: "发货信息:"+(data.confirm_remark? data.confirm_remark : '无'),
- buttons: [
- { text: "取消", onClick: function(){ return false; }},
- { text: "确认", className: "default", onClick: function(){
- $.showLoading("提交处理中...");
- $.post('/weixin/order/delivery', {id: data.id}, function (res) {
- $.hideLoading();
- if (res.code == 'success') {
- $.toast(res.message, 'text');
- setTimeout(function(){
- _this.getDataList(0);
- }, 500)
- }else if(res.code == 'login'){
- login(res.data.url);
- }else {
- $.toast(res.message, 'text');
- }
- },"json");
- return false;
- } },
- ]
- });
- },
- }
- })
|