Skip to content

Commit f907636

Browse files
committed
优化代码
1 parent b2481ff commit f907636

File tree

10 files changed

+372
-23
lines changed

10 files changed

+372
-23
lines changed

api/goods/goodsApi.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,50 @@ export function toPay(data) {
276276
// #endif
277277
})
278278
}
279+
280+
281+
export function queryGroupGoods(_dataObj){
282+
return new Promise(
283+
(resolve, reject) => {
284+
requestNoAuth({
285+
url: url.listProductGroup,
286+
method: "GET",
287+
data: _dataObj,
288+
//动态数据
289+
success: function(res) {
290+
if (res.data.code == 0) {
291+
let _appraisets = res.data.data;
292+
resolve(_appraisets);
293+
return;
294+
}
295+
reject(res.data.msg);
296+
},
297+
fail: function(e) {
298+
reject();
299+
}
300+
});
301+
})
302+
}
303+
304+
export function queryProductSeckill(_dataObj){
305+
return new Promise(
306+
(resolve, reject) => {
307+
requestNoAuth({
308+
url: url.listProductSeckill,
309+
method: "GET",
310+
data: _dataObj,
311+
//动态数据
312+
success: function(res) {
313+
if (res.data.code == 0) {
314+
let _appraisets = res.data.data;
315+
resolve(_appraisets);
316+
return;
317+
}
318+
reject(res.data.msg);
319+
},
320+
fail: function(e) {
321+
reject();
322+
}
323+
});
324+
})
325+
}

components/index/group-view.vue

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<template>
2+
<view class="bg-white group-view margin-top">
3+
<view class="flex justify-between group-view-top">
4+
<view>
5+
<text class="view-title">超值拼团</text>
6+
<text class="view-sub-title">拼着买更便宜</text>
7+
</view>
8+
<view>
9+
<text @tap="_toGroupGoodsList" class="view-title-more">更多 ></text>
10+
</view>
11+
</view>
12+
<view class="bg-white flex justify-between group-goods">
13+
<view v-for="(item,index) in goods" :key="index" class="group-item" @click="_toGroupGoods(item)">
14+
<view>
15+
<image :src="item.coverPhoto"></image>
16+
</view>
17+
<view>
18+
<text class="group-price">¥{{item.groupPrice}}</text>
19+
</view>
20+
<view>
21+
<text class="normal-price">¥{{item.price}}</text>
22+
</view>
23+
</view>
24+
</view>
25+
</view>
26+
</template>
27+
28+
<script>
29+
import {queryGroupGoods} from '../../api/goods/goodsApi.js';
30+
export default {
31+
name:"groupView",
32+
data() {
33+
return {
34+
goods:[],
35+
shopId:''
36+
};
37+
},
38+
created() {
39+
let _goods = {
40+
coverPhoto:this.imgUrl + '/h5/images/noPic.png',
41+
groupPrice:'1.50',
42+
price:'2.50'
43+
}
44+
this.goods.push(_goods);
45+
this.goods.push(_goods);
46+
this.goods.push(_goods);
47+
this.goods.push(_goods);
48+
this._loadGoods();
49+
},
50+
methods:{
51+
_toGroupGoodsList:function(){
52+
this.vc.navigateToMall({
53+
url:'/pages/goods/groupGoodsList'
54+
},true)
55+
},
56+
_loadGoods:function(){
57+
let _that = this;
58+
queryGroupGoods({
59+
page:1,
60+
row:4,
61+
shopId:this.shopId
62+
}).then(_data=>{
63+
_that.goods = _data
64+
})
65+
},
66+
_toGroupGoods:function(_product){
67+
this.vc.navigateToMall({
68+
url:'/pages/goods/groupGoods?productId='+_product.productId+"&groupId="+_product.groupId+"&shopId="+_product.shopId
69+
},true)
70+
}
71+
}
72+
}
73+
</script>
74+
75+
<style lang="scss">
76+
.group-view{
77+
border-radius: 10upx;
78+
padding:20upx;
79+
.view-title{
80+
font-size: 36upx;
81+
color: #444;
82+
}
83+
.view-sub-title{
84+
font-size: 18upx;
85+
margin-left:20upx;
86+
color:#FA2E1B;
87+
}
88+
.view-title-more{
89+
font-size: 18upx;
90+
color: #777;
91+
line-height: 48upx;
92+
}
93+
.group-goods{
94+
margin-top:20upx;
95+
.group-item{
96+
width: 25%;
97+
text-align: center;
98+
image{
99+
width: 90%;
100+
height: 180upx;
101+
border-radius: 15upx;
102+
}
103+
}
104+
.group-price{
105+
font-size: 24upx;
106+
color: #FA2E1B;
107+
}
108+
.normal-price{
109+
font-size: 16upx;
110+
color: #777;
111+
text-decoration:line-through;
112+
}
113+
}
114+
115+
}
116+
</style>

components/index/seckill-view.vue

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
<template>
2+
<view class="bg-white seckill-view margin-top">
3+
<view class="flex justify-between seckill-view-top">
4+
<view>
5+
6+
<text class="view-title">限时秒杀</text>
7+
<text class="view-sub-title">{{curSecHours.name}}专场</text>
8+
</view>
9+
<view>
10+
<text @tap="_toSeckillGoodsList" class="view-title-more">更多 ></text>
11+
</view>
12+
</view>
13+
<view class="bg-white flex justify-between seckill-goods">
14+
<view v-for="(item,index) in goods" :key="index" class="seckill-item" @click="_toSeckillGoods(item)">
15+
<view>
16+
<image :src="item.coverPhoto"></image>
17+
</view>
18+
<view>
19+
<text class="seckill-price">¥{{item.killPrice}}</text>
20+
</view>
21+
<view>
22+
<text class="normal-price">¥{{item.price}}</text>
23+
</view>
24+
</view>
25+
</view>
26+
</view>
27+
</template>
28+
29+
<script>
30+
import {queryProductSeckill} from '@/api/goods/goodsApi.js'
31+
export default {
32+
name:"seckillView",
33+
data() {
34+
return {
35+
goods:[],
36+
shopId:'',
37+
curSecHours:{},
38+
secHours: [{
39+
name: '08:00',
40+
hours: 8,
41+
},{
42+
name: '10:00',
43+
hours: 10,
44+
}, {
45+
name: '12:00',
46+
hours: 12,
47+
}, {
48+
name: '14:00',
49+
hours: 14,
50+
}, {
51+
name: '15:00',
52+
hours: 15,
53+
}, {
54+
name: '16:00',
55+
hours: 16,
56+
}, {
57+
name: '20:00',
58+
hours: 20,
59+
}, {
60+
name: '22:00',
61+
hours: 22,
62+
}],
63+
};
64+
},
65+
created() {
66+
let _goods = {
67+
coverPhoto:this.imgUrl + '/h5/images/noPic.png',
68+
killPrice:'1.50',
69+
price:'2.50'
70+
}
71+
this.goods.push(_goods);
72+
this.goods.push(_goods);
73+
this.goods.push(_goods);
74+
this.goods.push(_goods);
75+
this.computeCurHours();
76+
this._loadGoods();
77+
78+
},
79+
methods:{
80+
_toSeckillGoodsList:function(){
81+
this.vc.navigateToMall({
82+
url:'/pages/goods/seckillList'
83+
},true)
84+
},
85+
_loadGoods:function(){
86+
let _that = this;
87+
queryProductSeckill({
88+
page:1,
89+
row:4,
90+
killHours:this.curSecHours.hours,
91+
shopId:this.shopId,
92+
validData:'Y'
93+
}).then(_data=>{
94+
_that.goods = _data;
95+
})
96+
},
97+
computeCurHours:function(){
98+
let _that = this;
99+
let _date = new Date();
100+
let _curHours = _date.getHours();
101+
_that.curSecHours = this.secHours[0];
102+
this.secHours.forEach(_hours=>{
103+
if(_hours.hours >= _curHours){
104+
_that.curSecHours = _hours;
105+
return ;
106+
}
107+
})
108+
109+
},
110+
_toSeckillGoods:function(_goods){
111+
this.vc.navigateToMall({
112+
url:'/pages/goods/seckillGoods?productId='+_goods.productId+"&shopId="+_goods.shopId+"&killId="+_goods.killId
113+
},true);
114+
}
115+
}
116+
}
117+
</script>
118+
119+
<style lang="scss">
120+
.seckill-view{
121+
border-radius: 10upx;
122+
padding:20upx;
123+
.view-title{
124+
font-size: 36upx;
125+
color: #444;
126+
}
127+
.view-sub-title{
128+
font-size: 18upx;
129+
margin-left:20upx;
130+
color:#FA2E1B;
131+
}
132+
.view-title-more{
133+
font-size: 18upx;
134+
color: #777;
135+
line-height: 48upx;
136+
}
137+
.seckill-goods{
138+
margin-top:20upx;
139+
.seckill-item{
140+
width: 25%;
141+
text-align: center;
142+
image{
143+
width: 90%;
144+
height: 180upx;
145+
border-radius: 15upx;
146+
}
147+
}
148+
.seckill-price{
149+
font-size: 24upx;
150+
color: #FA2E1B;
151+
}
152+
.normal-price{
153+
font-size: 16upx;
154+
color: #777;
155+
text-decoration:line-through;
156+
}
157+
}
158+
159+
}
160+
</style>

components/reserve/reserve-goods.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,27 @@
1313
<view>预约数量</view>
1414
<view style="width: 60%;">
1515
<radio-group class="flex justify-end" @change="_changeReserveQuantity">
16-
<view v-for="item in goods.hoursMaxQuantity" :key="item">
17-
<radio class="" v-model="goods.quantity" :value="item"></radio>
16+
<!-- #ifdef MP-WEIXIN -->
17+
<view class="margin-right-sm" v-for="item in goods.hoursMaxQuantity" :key="item">
18+
<radio class="" :value="item+1"></radio>
19+
<view>{{item+1}}个</view>
20+
</view>
21+
<!-- #endif -->
22+
<!-- #ifndef MP-WEIXIN -->
23+
<view class="margin-right-sm" v-for="item in goods.hoursMaxQuantity" :key="item">
24+
<radio class="" :value="item"></radio>
1825
<view>{{item}}个</view>
1926
</view>
27+
<!-- #endif -->
2028
</radio-group>
2129
<!-- <checkbox class='round checked' checked="true" value="B"></checkbox> -->
2230
</view>
2331
</view>
2432
<view class="flex justify-between margin-top">
2533
<view>预约时间</view>
2634
<view style="width: 60%;">
27-
<checkbox-group class="flex justify-end" @change="_changeReserveTime">
28-
<view class="margin-right-sm" v-if="item.isOpen == 'Y'"
35+
<checkbox-group class="text-right" @change="_changeReserveTime">
36+
<view class="margin-right-sm" style="display: inline-block;" v-if="item.isOpen == 'Y'"
2937
v-for="(item,index) in openTimes" :key="index">
3038
<checkbox class=' ' :value="item.hours"></checkbox>
3139
<view>{{item.hours}}时</view>

0 commit comments

Comments
 (0)