product.vue
5.1 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<template>
<view class="product_all">
<view class="top">
<image src="../../static/ic-back-false.png" mode="" @click="back"></image>
<view class="search">
<view class="tosear">
<input type="text" value="" placeholder="搜索"
placeholder-style="text-align: center;font-size: 28rpx; color: rgba(194,194,194,1);"
v-model="keyword" @confirm="gosourch" />
<image src="../../static/icon-search.png" mode="" v-if="!keyword"></image>
</view>
</view>
</view>
<u-empty marginTop="200" text="暂无数据" mode="data" v-if="!list.length"></u-empty>
<scroll-view v-if="list.length" scroll-y="true" @scrolltolower="scrolltolower" style="height: 100vh">
<view class="misslist">
<custom-waterfalls-flow :value="list" @wapperClick="godetail" @imageClick="godetail">
<template v-slot:default="item">
<view class="item">
<view class="title">{{item.name}}</view>
<view class="types">
所属分类:{{item.sort.name}}
</view>
<view class="desc">
<text v-if="item.seller_name">{{item.seller_name}}</text>
<view class="money">
<text>¥</text>{{item.price}}
</view>
</view>
</view>
</template>
</custom-waterfalls-flow>
</view>
</scroll-view>
</view>
</template>
<script>
import {
product_list
} from '@/api/index'
export default {
data() {
return {
//瀑布
list: [],
keyword: "",
currentpage: 1,
sort_id: "",
sort_name:"",
}
},
onLoad(options) {
if (options.ktext) {
this.keyword = options.ktext
uni.setNavigationBarTitle({
title: "产品" //这是修改后的导航栏文字
})
let URL=window.location.href
this.$wxH5Share.get_jssdk("产品",URL)
}
if (options.sort_id) {
this.sort_id = options.sort_id
this.sort_name = options.sort_name
let that =this
uni.setNavigationBarTitle({
title: that.sort_name //这是修改后的导航栏文字
})
let URL=window.location.href
this.$wxH5Share.get_jssdk(that.sort_name,URL)
}
this.product_list(true)
},
methods: {
gosourch() {
this.product_list(true)
},
scrolltolower() {
this.currentpage++
this.product_list()
},
back() {
uni.navigateBack({
delta: 1
})
},
//产品列表
async product_list(x) {
let obj = {
keyword: this.keyword,
sort_id: this.sort_id,
page: this.currentpage,
pagenum: 15,
}
try {
const res = await product_list(obj)
console.log('产品列表', res)
this.list = x ? res.list.data : this.list.concat(res.list.data)
this.list.forEach((item, index) => {
item.image = item.images_preview[0]
})
if (res.list.data.length == 0) {
// uni.showToast({
// title: "暂无更多数据",
// icon: 'none'
// })
return
}
console.log('产品列表', this.list)
// 保存数据
} catch (err) {
uni.showToast({
title: err,
icon: 'none'
})
console.log('product_list', err)
}
},
//跳转详情
godetail(item) {
console.log(1)
uni.navigateTo({
url: "/pages/index/detail?id=" + item.id
})
},
}
}
</script>
<style lang="scss">
page {
background: rgba(246, 246, 246, 1);
}
.product_all {
.top {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 99;
height: 96rpx;
opacity: 1;
background: rgba(255, 255, 255, 1);
padding: 16rpx 32rpx;
display: flex;
box-sizing: border-box;
align-items: center;
image {
margin-right: 32rpx;
width: 48rpx;
height: 48rpx;
}
.search {
flex: 1;
display: flex;
align-items: center;
.tosear {
position: relative;
width: 522rpx;
height: 64rpx;
border-radius: 38rpx;
opacity: 1;
border: 0 solid rgba(0.5920000076293945, 0.5920000076293945, 0.5920000076293945, 1);
background: rgba(245, 245, 245, 1);
padding: 0 32rpx;
input {
text-align: center;
width: 100%;
height: 100%;
}
image {
position: absolute;
left: 280rpx;
top: 50%;
left: 36%;
transform: translateY(-50%);
width: 32rpx;
height: 32rpx;
}
}
}
}
.misslist {
margin-top: 104rpx;
.item {
padding: 24rpx;
box-sizing: border-box;
.types {
margin-top: 8rpx;
color: rgba(0, 0, 0, 0.6);
font-size: 24rpx;
font-weight: 400;
font-family: "PingFang SC";
}
.desc {
margin-top: 14rpx;
display: flex;
align-items: center;
justify-content: space-between;
color: rgba(0, 0, 0, 0.6);
font-size: 20rpx;
font-weight: 400;
font-family: "PingFang SC";
.money {
color: rgba(248, 83, 23, 1);
font-size: 32rpx;
font-weight: 700;
font-family: "Montserrat";
text {
font-size: 24rpx;
font-weight: 500;
}
}
}
}
}
}
</style>