| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- var app = new Vue({
- 'el': '#app',
- 'data': {
- // 列表数据
- dataList: [],
- // 参数
- params: {
- page: 1,
- pageSize: 6,
- type: 1,
- },
- loading: false,
- loaded: false,
- },
- created: function(){
- this.getDataList(0);
- },
- mounted: function(){
- var _this = this;
- $(window).scroll(function(){
- var scrollHeight = $(this).scrollTop();
- var height = $('body')[0].scrollHeight;
- var docHeight = $(this).outerHeight();
- if(docHeight+scrollHeight >= height-1){
- if(_this.loading || _this.loaded){
- return false;
- }
- _this.params.page++;
- _this.getDataList(1);
- }
- })
- },
- methods: {
- // 详情
- goDetail: function(id){
- if(id){
- location.href = '/weixin/goods/detail?id='+id;
- }
- },
- // 编辑商品
- editGoods: function(id){
- if(id){
- location.href = '/weixin/goods/publish?id='+id;
- }
- },
- // 删除商品
- delGoods: function(id){
- if(id>0 && confirm('确定删除该商品?')){
- var _this = this;
- $.showLoading("处理中...");
- $.post('/weixin/goods/doDel', {id:id}, function (res) {
- $.hideLoading();
- if (res.code == 'success') {
- $.toast(res.message, 'text');
- setTimeout(function () {
- _this.params.page = 1;
- _this.getDataList(0);
- }, 500);
- }else if(res.code == 'login'){
- login(res.data.url);
- }else {
- $.toast(res.message, 'text');
- }
- }, "json");
- }
- },
- // 获取列表数据
- getDataList: function(more){
- var _this = this;
- $.showLoading("数据加载中...");
- _this.loading = true;
- $.post('/weixin/goods/goodsList', _this.params, function (res) {
- $.hideLoading();
- _this.loading = false;
- if (res.code == 'success') {
- if(res.data.data.length<=0 && _this.params.page > 1){
- _this.loaded = true;
- $.toast("已加载完全部...",'text');
- return false;
- }
- if(more){
- $.each(res.data.data, function(k,item){
- _this.dataList.push(item);
- });
- }else{
- _this.dataList = res.data.data
- }
- }else if(res.code == 'login'){
- login(res.data.url);
- }
- }, "json");
- },
- }
- })
|