diy_shopname.js 1.94 KB
var t = getApp(),
    o = t.globalData.setting;

Component({
  properties: {
    // 这里定义了innerText属性,属性值可以在组件使用时指定
    object: {
      type: Object,
      value: null,
    },
  },
  data: {
    // 这里是一些组件内部数据
    yc:false,
    imghost: o.imghost,
    stoid:o.stoid,
    sto:null,
    store_name:'',
    someData: {},
    total:0,
    new_total:0,
  },

  ready: function() {
    var th=this;
    this.init();
    //--所有商品--
    getApp().request.promiseGet("/api/weshop/goods/page/",
      {data:{ isonsale: 1, store_id: o.stoid,page:1,pageSize:1}}).then(res => {
         var total=res.data.data.total;
         th.setData({total:total})
    })

    //--所有新品--
    getApp().request.promiseGet("/api/weshop/goods/page/",
      {data:{is_new:1,isonsale: 1, store_id: o.stoid,page:1,pageSize:1}}).then(res => {
       var total=res.data.data.total;
      th.setData({new_total:total})
    })

  },
  methods: {
    // 这里是一个自定义方法
    init:function(){
      var app=getApp();
          app.request.promiseGet("/api/weshop/store/get/"+o.stoid,{
            data:{}
          }).then(res=>{
           var logo=o.imghost+res.data.data.store_logo;
           var name=res.data.data.store_name;
            this.setData({
              sto:logo,store_name:name
            })
          })
    },
    customMethod: function () {},
    go_user:function () {
       var url="/pages/user/index/index";
       getApp().goto(url);
    },
    go_all_wares:function () {
       var url="/pages/goods/goodsList/goodsList";
       getApp().goto(url);
    },
    go_new_wares:function () {
       var url="/pages/goods/goodsList/goodsList?is_new=1";
      getApp().goto(url);
    },
    //主图的图片显示	
	berror:function(e){
		  var err=e.currentTarget.dataset.err;
		  var url=this.data.imghost+'/public/static/images/model/bg.jpg';
		  var ob={};
		  ob[err]=url;
		  this.setData(ob);
	}

  }
})