Skip to content

Commit 6c9fa56

Browse files
committed
增加砍价
1 parent 0a91aaa commit 6c9fa56

File tree

4 files changed

+237
-28
lines changed

4 files changed

+237
-28
lines changed

App.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
// APP 自动更新
9797
// #endif
9898
},
99-
async autoLogin() {
99+
async autoLogin(force) {
100100
// 自动登陆
101101
// #ifdef MP-WEIXIN
102102
const isLogined = await WXAUTH.checkHasLogined()
@@ -128,6 +128,9 @@
128128
uni.$emit('loginOK', {})
129129
}, 500)
130130
// #endif
131+
if (!force) {
132+
return
133+
}
131134
// #ifdef H5
132135
const isLogined = await this.checkHasLoginedH5()
133136
if (!isLogined) {
@@ -149,9 +152,9 @@
149152
}
150153
} else {
151154
// 其他浏览器打开的, 按需登陆,不能直接跳转到登陆界面
152-
// uni.navigateTo({
153-
// url: "/pages/login/login"
154-
// })
155+
uni.navigateTo({
156+
url: "/pages/login/login"
157+
})
155158
}
156159
}
157160
// #endif

components/goods-pop/goods-pop.vue

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@
3636
</view>
3737
</view>
3838
<u-line v-if="goodsAddition || properties" dashed margin="32rpx"></u-line>
39-
<view class="buy-number">
40-
<text>购买数量</text>
41-
<u-number-box v-model="buyNumber" :min="min" :max="max" integer></u-number-box>
39+
<block v-if="!kjid">
40+
<view class="buy-number">
41+
<text>购买数量</text>
42+
<u-number-box v-model="buyNumber" :min="min" :max="max" integer></u-number-box>
43+
</view>
44+
<u-line dashed margin="32rpx"></u-line>
45+
</block>
46+
<view v-if="kjid">
47+
<view class="btn">
48+
<u-button text="立即购买" shape="circle" color="linear-gradient(90deg, #ff6034, #ee0a24, #ff6034)" @click="tobuy"></u-button>
49+
</view>
4250
</view>
43-
<u-line dashed margin="32rpx"></u-line>
44-
<view class="btns">
51+
<view v-else class="btns">
4552
<!-- #ifdef MP-WEIXIN || MP-BAIDU -->
4653
<view class="icon-btn">
4754
<u-icon name="chat" size="48rpx"></u-icon>
@@ -95,6 +102,7 @@
95102
type: Array,
96103
default: null
97104
},
105+
kjid: undefined
98106
},
99107
data() {
100108
return {
@@ -532,7 +540,8 @@
532540
score: this.goodsDetail.basicInfo.minScore,
533541
sku, // optionId optionName optionValueId optionValueName
534542
additions: goodsAddition, // id name pid pname price
535-
goodsType
543+
goodsType,
544+
kjid: this.kjid ? this.kjid : ''
536545
}]
537546
uni.setStorageSync('goodsList', goodsList)
538547
uni.navigateTo({

pages/goods/detail.vue

Lines changed: 208 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@
1010
<u-swiper v-else :list="goodsDetail.pics" keyName="pic" indicator circular height="750rpx">
1111
</u-swiper>
1212
<view class="price-share">
13-
<view class="price-score">
13+
<view v-if="curKanjiaprogress" class="price-score price-score2">
14+
<view class="item">
15+
<text>¥</text>{{ curKanjiaprogress.kanjiaInfo.curPrice }}
16+
</view>
17+
<view class="item original">
18+
<text>¥</text>{{ curGoodsKanjia.originalPrice }}
19+
</view>
20+
</view>
21+
<view v-else class="price-score price-score2">
1422
<view v-if="goodsDetail.basicInfo.minPrice" class="item">
1523
<text>¥</text>{{goodsDetail.basicInfo.minPrice}}
1624
</view>
@@ -51,21 +59,61 @@
5159
{{goodsDetail.basicInfo.commission}}元 现金奖励
5260
</view>
5361
</view>
54-
<u-cell-group v-if="curGoodsKanjia" title="砍价设置">
55-
<u-cell title="数量" :value="curGoodsKanjia.number + '份'"></u-cell>
56-
<u-cell title="已售" :value="curGoodsKanjia.numberBuy + '份'"></u-cell>
57-
<u-cell title="原价" :value="curGoodsKanjia.originalPrice"></u-cell>
58-
<u-cell title="底价" :value="curGoodsKanjia.minPrice"></u-cell>
59-
<u-cell title="截止" :value="curGoodsKanjia.dateEnd"></u-cell>
60-
</u-cell-group>
62+
63+
<block v-if="curGoodsKanjia">
64+
<u-gap height="20rpx" bgColor="#eee"></u-gap>
65+
<view class="label-title">
66+
<view class="icon"></view>商品砍价设置
67+
</view>
68+
<u-cell-group>
69+
<u-cell title="数量" :value="curGoodsKanjia.number + '份'"></u-cell>
70+
<u-cell title="已售" :value="curGoodsKanjia.numberBuy + '份'"></u-cell>
71+
<u-cell title="原价" :value="curGoodsKanjia.originalPrice"></u-cell>
72+
<u-cell title="底价" :value="curGoodsKanjia.minPrice"></u-cell>
73+
<u-cell title="截止" :value="curGoodsKanjia.dateEnd"></u-cell>
74+
</u-cell-group>
75+
</block>
76+
<block v-if="curKanjiaprogress">
77+
<u-gap height="20rpx" bgColor="#eee"></u-gap>
78+
<view class="label-title">
79+
<view class="icon"></view>当前砍价状态
80+
</view>
81+
<u-cell-group>
82+
<u-cell title="帮砍人数" :value="curKanjiaprogress.kanjiaInfo.helpNumber"></u-cell>
83+
<u-cell title="状态" :value="curKanjiaprogress.kanjiaInfo.statusStr"></u-cell>
84+
<u-cell title="参与时间" :value="curKanjiaprogress.kanjiaInfo.dateAdd"></u-cell>
85+
</u-cell-group>
86+
</block>
6187
<view v-if="curKanjiaprogress && curKanjiaprogress.kanjiaInfo.uid != uid" class="curKanjiaJoin">
6288
帮<text>{{curKanjiaprogress.joiner.nick}}</text> 砍价吧!
6389
</view>
6490
<view v-if="curGoodsKanjia && curKanjiaprogress" class="curKanjiaprogress">
65-
<u-line-progress :percentage="100 * (curGoodsKanjia.originalPrice - curKanjiaprogress.kanjiaInfo.curPrice) / (curGoodsKanjia.originalPrice - curGoodsKanjia.minPrice)" activeColor="#ff0000"></u-line-progress>
91+
<u-line-progress
92+
:percentage="100 * (curGoodsKanjia.originalPrice - curKanjiaprogress.kanjiaInfo.curPrice) / (curGoodsKanjia.originalPrice - curGoodsKanjia.minPrice)"
93+
activeColor="#ff0000"></u-line-progress>
94+
<view class="curKanjiaprogress-bar">// 砍价完成进度 //</view>
95+
</view>
96+
97+
<block v-if="curKanjiaprogress && curKanjiaprogress.helps && curKanjiaprogress.helps.length>0">
98+
<u-gap height="20rpx" bgColor="#eee"></u-gap>
99+
<view class="label-title">
100+
<view class="icon"></view>好友助力明细
101+
</view>
102+
<view class="kjlj" v-for="(item,index) in curKanjiaprogress.helps" :key="index">
103+
<image class="kjlj-l" :src="item.avatarUrl" mode="aspectFill" />
104+
<u-cell class="kjlj-r" :label="item.nick + ' ' + item.dateAdd + '帮砍'" size="large">
105+
<view slot="title" class="price-score">
106+
<view class="item"><text>¥</text>{{ item.cutPrice }}</view>
107+
</view>
108+
</u-cell>
109+
</view>
110+
</block>
111+
112+
<u-gap height="20rpx" bgColor="#eee"></u-gap>
113+
<view class="label-title">
114+
<view class="icon"></view>详细介绍
66115
</view>
67116
<view id="content">
68-
<u-divider text="详细介绍"></u-divider>
69117
<view class="content">
70118
<view v-if="wxintroduction">
71119
<u-image v-for="(item,index) in wxintroduction" :src="item" mode="widthFix" width="750rpx"
@@ -109,11 +157,76 @@
109157
</view>
110158
</view>
111159
</scroll-view>
112-
<view v-if="curGoodsKanjia && (!curKanjiaprogress || curKanjiaprogress.kanjiaInfo.uid != uid)"
113-
class="bottom-btns">
114-
<view class="btn">
115-
<u-button text="我要砍价" shape="circle" color="linear-gradient(90deg, #ff6034, #ee0a24, #ff6034)"
116-
@click="joinKanjia"></u-button>
160+
<view v-if="curGoodsKanjia">
161+
<view v-if="curKanjiaprogress && curKanjiaprogress.kanjiaInfo.uid == uid" class="bottom-btns">
162+
<!-- #ifdef MP-WEIXIN || MP-BAIDU -->
163+
<view class="icon-btn">
164+
<u-icon name="chat" size="48rpx"></u-icon>
165+
<text>客服</text>
166+
<button open-type='contact' :send-message-title="goodsDetail.basicInfo.name"
167+
:send-message-img="goodsDetail.basicInfo.pic"
168+
:send-message-path="'/pages/goods/detail?id='+goodsDetail.basicInfo.id"
169+
show-message-card></button>
170+
</view>
171+
<!-- #endif -->
172+
<view class="icon-btn" @click="addFav">
173+
<u-icon :name="faved ? 'heart-fill' : 'heart'" size="48rpx"></u-icon>
174+
<text>收藏</text>
175+
</view>
176+
<view class="btn">
177+
<u-button class="half-l" text="邀请好友助力" shape="circle"
178+
color="linear-gradient(90deg,#ffd01e, #ff8917)" open-type='share'>
179+
</u-button>
180+
</view>
181+
<view class="btn">
182+
<u-button class="half-r" text="用现价购买" shape="circle"
183+
color="linear-gradient(90deg, #ff6034, #ee0a24)" @click="kanjiabuy">
184+
</u-button>
185+
</view>
186+
</view>
187+
<view v-else-if="curKanjiaprogress && curKanjiaprogress.kanjiaInfo.uid != uid" class="bottom-btns">
188+
<view class="icon-btn">
189+
<u-icon name="share" size="48rpx"></u-icon>
190+
<text>邀请</text>
191+
<button open-type='share'></button>
192+
</view>
193+
<view class="btn">
194+
<u-button class="half-l" :text="myHelpDetail ? '您已助力' : '帮忙砍一刀'" shape="circle"
195+
:disabled="myHelpDetail ? true : false" color="linear-gradient(90deg,#ffd01e, #ff8917)"
196+
@click="helpKanjia">
197+
</u-button>
198+
</view>
199+
<view class="btn">
200+
<u-button class="half-r" text="我也要参与" shape="circle"
201+
color="linear-gradient(90deg, #ff6034, #ee0a24)" @click="joinKanjia">
202+
</u-button>
203+
</view>
204+
</view>
205+
<view v-else class="bottom-btns">
206+
<!-- #ifdef MP-WEIXIN || MP-BAIDU -->
207+
<view class="icon-btn">
208+
<u-icon name="chat" size="48rpx"></u-icon>
209+
<text>客服</text>
210+
<button open-type='contact' :send-message-title="goodsDetail.basicInfo.name"
211+
:send-message-img="goodsDetail.basicInfo.pic"
212+
:send-message-path="'/pages/goods/detail?id='+goodsDetail.basicInfo.id"
213+
show-message-card></button>
214+
</view>
215+
<!-- #endif -->
216+
<view class="icon-btn" @click="addFav">
217+
<u-icon :name="faved ? 'heart-fill' : 'heart'" size="48rpx"></u-icon>
218+
<text>收藏</text>
219+
</view>
220+
<view class="btn">
221+
<u-button class="half-l" text="发起砍价" shape="circle"
222+
color="linear-gradient(90deg,#ffd01e, #ff8917)" @click="joinKanjia">
223+
</u-button>
224+
</view>
225+
<view class="btn">
226+
<u-button class="half-r" text="原价购买" shape="circle"
227+
color="linear-gradient(90deg, #ff6034, #ee0a24)" @click="_showGoodsPop">
228+
</u-button>
229+
</view>
117230
</view>
118231
</view>
119232
<view v-else class="bottom-btns">
@@ -154,7 +267,7 @@
154267
</view>
155268
</view>
156269
</view>
157-
<goods-pop :show="showGoodsPop" :goodsDetail="goodsDetail" @close="showGoodsPop = false"></goods-pop>
270+
<goods-pop :show="showGoodsPop" :goodsDetail="goodsDetail" :kjid="kjid" @close="showGoodsPop = false"></goods-pop>
158271
<!-- <u-modal :show="showhaibao" :title="title" >
159272
<view class="slot-content">
160273
<hch-poster v-if="showhaibao" ref="hchPoster" @cancel="handleCancel" :posterData.sync="posterData" @previewImage='previewImage' />
@@ -205,6 +318,7 @@
205318
curGoodsKanjia: undefined,
206319
curKanjiaprogress: undefined,
207320
myHelpDetail: undefined,
321+
kjid: undefined
208322
}
209323
},
210324
onLoad(e) {
@@ -425,6 +539,13 @@
425539
// 弹出商品购买弹窗
426540
async _showGoodsPop() {
427541
this.showGoodsPop = true
542+
this.kjid = null
543+
},
544+
kanjiabuy() {
545+
// 砍价用现在的价格购买
546+
this.goodsDetail.basicInfo.minPrice = this.curKanjiaprogress.kanjiaInfo.curPrice
547+
this.kjid = this.curGoodsKanjia.id
548+
this.showGoodsPop = true
428549
},
429550
scrolltolower() {
430551
this.page += 1
@@ -581,6 +702,7 @@
581702
const res = await this.$wxapi.kanjiaDetail(this.curGoodsKanjia.id, kjJoinUid)
582703
if (res.code == 0) {
583704
this.curKanjiaprogress = res.data
705+
this.kanjiaHelpDetail()
584706
}
585707
},
586708
async joinKanjia() {
@@ -593,6 +715,10 @@
593715
})
594716
const res = await this.$wxapi.kanjiaJoin(this.token, this.curGoodsKanjia.id)
595717
uni.hideLoading()
718+
if (res.code == 2000) {
719+
getApp().autoLogin(true)
720+
return
721+
}
596722
if (res.code == 0) {
597723
this.$u.vuex('kjJoinUid', this.uid)
598724
this.myHelpDetail = null
@@ -604,6 +730,36 @@
604730
})
605731
}
606732
},
733+
async helpKanjia() {
734+
console.log(this.curGoodsKanjia);
735+
console.log(this.token);
736+
const res = await this.$wxapi.kanjiaHelp(this.token, this.curGoodsKanjia.id, this.curKanjiaprogress
737+
.kanjiaInfo.uid, '')
738+
if (res.code != 0) {
739+
uni.showToast({
740+
title: res.msg,
741+
icon: 'none'
742+
})
743+
return;
744+
}
745+
this.myHelpDetail = res.data
746+
uni.showModal({
747+
title: '成功',
748+
content: '成功帮TA砍掉 ' + res.data.cutPrice + '',
749+
showCancel: false,
750+
confirmText: '知道了'
751+
})
752+
this.kanjiaSet()
753+
},
754+
async kanjiaHelpDetail() {
755+
console.log(this.curGoodsKanjia);
756+
console.log(this.token);
757+
const res = await this.$wxapi.kanjiaHelpDetail(this.token, this.curGoodsKanjia.id, this
758+
.curKanjiaprogress.kanjiaInfo.uid)
759+
if (res.code == 0) {
760+
this.myHelpDetail = res.data
761+
}
762+
},
607763
}
608764
}
609765
</script>
@@ -775,18 +931,54 @@
775931
776932
.goods-title {
777933
padding: 0 32rpx;
934+
935+
text {
936+
font-weight: bold;
937+
font-size: 34rpx;
938+
}
778939
}
940+
779941
.curKanjiaJoin {
780942
padding: 32rpx;
781943
font-size: 28rpx;
944+
782945
text {
783946
color: #e64340;
784947
font-weight: bold;
785948
padding: 0 8rpx;
786949
font-size: 32rpx;
787950
}
788951
}
952+
789953
.curKanjiaprogress {
790954
padding: 32rpx;
791955
}
956+
957+
.price-score2 {
958+
.item {
959+
font-size: 64rpx;
960+
}
961+
}
962+
963+
.curKanjiaprogress-bar {
964+
text-align: center;
965+
font-size: 20rpx;
966+
color: #999;
967+
margin-top: 20rpx;
968+
}
969+
.kjlj {
970+
display: flex;
971+
background-color: #ffffff;
972+
padding: 0 32rpx;
973+
align-items: center;
974+
.kjlj-l {
975+
width: 88rpx;
976+
height: 88rpx;
977+
border-radius: 50%;
978+
flex-shrink: 0;
979+
}
980+
.kjlj-r {
981+
flex: 1;
982+
}
983+
}
792984
</style>

0 commit comments

Comments
 (0)