diy_shopname.js
2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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 => {
if(res.data.code==0 && res.data.data){
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 => {
if(res.data.code==0 && res.data.data)
{
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);
}
}
})