修改小程序砍价逻辑
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
// export const VUE_APP_API_URL = 'http://natapp.xinxintuan.co/api';
|
// export const VUE_APP_API_URL = 'http://natapp.xinxintuan.co/api';
|
||||||
// export const VUE_APP_API_URL = 'https://wxapi.yixiang.co/api';
|
export const VUE_APP_API_URL = 'https://wxapi.yixiang.co/api';
|
||||||
// export const VUE_APP_API_URL = 'http://192.168.31.223:8008/api';
|
// export const VUE_APP_API_URL = 'http://192.168.31.223:8008/api';
|
||||||
export const VUE_APP_API_URL = 'https://h5api.xinxintuan.co/api';
|
// export const VUE_APP_API_URL = 'https://h5api.xinxintuan.co/api';
|
||||||
// export const VUE_APP_API_URL = 'https://h5api.xinxintuan.co/api';
|
// export const VUE_APP_API_URL = 'https://h5api.xinxintuan.co/api';
|
||||||
export const VUE_APP_RESOURCES_URL = 'https://wx.yixiang.co/static';
|
export const VUE_APP_RESOURCES_URL = 'https://wx.yixiang.co/static';
|
||||||
|
|
||||||
|
|||||||
@ -153,6 +153,8 @@ export async function auth(code) {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let loginType = cookie.get(LOGINTYPE);
|
let loginType = cookie.get(LOGINTYPE);
|
||||||
let spread = cookie.get('spread');
|
let spread = cookie.get('spread');
|
||||||
|
alert(spread)
|
||||||
|
debugger
|
||||||
wechatAuth(code, spread, loginType)
|
wechatAuth(code, spread, loginType)
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
console.log(data)
|
console.log(data)
|
||||||
|
|||||||
5
main.js
5
main.js
@ -125,7 +125,10 @@ if (!cookie.has(CACHE_KEY)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var urlSpread = parseQuery()["spread"];
|
var urlSpread = parseQuery()["spread"];
|
||||||
cookie.set("spread", urlSpread || 0);
|
if (urlSpread) {
|
||||||
|
cookie.set("spread", urlSpread);
|
||||||
|
}
|
||||||
|
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,9 @@
|
|||||||
// 判断是否是分销
|
// 判断是否是分销
|
||||||
if (url) {
|
if (url) {
|
||||||
let urlSpread = parseInt(url.spread);
|
let urlSpread = parseInt(url.spread);
|
||||||
cookie.set("spread", urlSpread || 0);
|
if (urlSpread) {
|
||||||
|
cookie.set("spread", urlSpread);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// if (this.$deviceType == "app" || this.$deviceType == "weixinh5") {
|
// if (this.$deviceType == "app" || this.$deviceType == "weixinh5") {
|
||||||
// this.$yrouter.switchTab({
|
// this.$yrouter.switchTab({
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="bargain on">
|
<view class="bargain on">
|
||||||
<!-- 在header上加 on 为请求支援 -->
|
<!-- 在header上加 on 为请求支援 -->
|
||||||
<view :class="[bargainPartake != userInfo.uid ? 'wrapper bargain-box on user' : 'wrapper bargain-box user']"
|
<!-- 当前登录的用户和url上携带的用户id不一致视为被邀请砍价 -->
|
||||||
v-if="bargainUserInfo && bargainPartake != userInfo.uid">
|
<view class="wrapper bargain-box on user" v-if="bargainUserInfo && bargainUid != userInfo.uid">
|
||||||
<!-- <view class="people">{{ lookCount }}人查看 丨 {{ shareCount }}人分享 丨 {{ userCount }}人参与</view> -->
|
<!-- <view class="people">
|
||||||
|
{{ bargainShare.lookCount }}人查看 丨 {{ bargainShare.shareCount }}人分享 丨 {{ bargainShare.userCount }}人参与
|
||||||
|
</view> -->
|
||||||
<!-- 帮助砍价、帮砍成功:-->
|
<!-- 帮助砍价、帮砍成功:-->
|
||||||
<view class="pictxt acea-row row-center-wrapper ">
|
<view class="pictxt acea-row row-center-wrapper ">
|
||||||
<div class="bargain-header">
|
<div class="bargain-header">
|
||||||
@ -20,79 +22,70 @@
|
|||||||
<view class="wrapper bargain-box time on">
|
<view class="wrapper bargain-box time on">
|
||||||
<div class="pictxt ">
|
<div class="pictxt ">
|
||||||
<count-down :isDay="true" :tipText="'倒计时 '" :dayText="' 天 '" :hourText="' 时 '" :minuteText="' 分 '"
|
<count-down :isDay="true" :tipText="'倒计时 '" :dayText="' 天 '" :hourText="' 时 '" :minuteText="' 分 '"
|
||||||
:secondText="' 秒'" :datatime="datatime"></count-down>
|
:secondText="' 秒'" :datatime="goodsDetail.stopTime"></count-down>
|
||||||
</div>
|
</div>
|
||||||
</view>
|
</view>
|
||||||
<view class="wrapper bargain-box bargain-product">
|
<view class="wrapper bargain-box bargain-product">
|
||||||
<view class="pictxt acea-row row-between-wrapper" @click="openAlone">
|
<view class="pictxt acea-row row-between-wrapper" @click="openAlone">
|
||||||
<view class="pictrue">
|
<view class="pictrue">
|
||||||
<image :src="bargain.image" />
|
<image :src="goodsDetail.image" />
|
||||||
<view class="bargain_view">
|
<view class="bargain_view">
|
||||||
查看商品
|
查看商品
|
||||||
<view class="iconfont icon-jiantou iconfonts"></view>
|
<view class="iconfont icon-jiantou iconfonts"></view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="text acea-row row-column-around">
|
<view class="text acea-row row-column-around">
|
||||||
<view class="line2" v-text="bargain.title"></view>
|
<view class="line2" v-text="goodsDetail.title"></view>
|
||||||
<view class="money font-color-red">
|
<view class="money font-color-red">
|
||||||
已砍至: ¥
|
已砍至: ¥
|
||||||
<text class="num" v-text="price"></text>
|
<text class="num" v-text="bargainHelpCount.remainingPrice"></text>
|
||||||
</view>
|
</view>
|
||||||
<view class="acea-row row-middle">
|
<view class="acea-row row-middle">
|
||||||
<view class="successNum" v-text="'原价' + bargain.price"></view>
|
<view class="successNum" v-text="'原价' + goodsDetail.price"></view>
|
||||||
<view class="successNum" v-text="'已有' + bargainSumCount + '人砍价成功'"></view>
|
<view class="successNum" v-text="'已有' + bargainSumCount + '人砍价成功'"></view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 砍价进度条 -->
|
||||||
<view class="cu-progress acea-row row-middle round margin-top">
|
<view class="cu-progress acea-row row-middle round margin-top">
|
||||||
<view class="acea-row row-middle bg-red" :style="{ width: loading ? pricePercent + '%' : '' }"></view>
|
<view class="acea-row row-middle bg-red" :style="{ width: bargainHelpCount.pricePercent + '%' }"></view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 砍价进度条下的金额 -->
|
||||||
<view class="balance acea-row row-between-wrapper">
|
<view class="balance acea-row row-between-wrapper">
|
||||||
<view v-text="'已砍' + alreadyPrice + '元'"></view>
|
<view v-text="'已砍' + bargainHelpCount.alreadyPrice + '元'"></view>
|
||||||
<view v-if="surplusPrice === 0">砍价成功</view>
|
<view v-if="bargainHelpCount.remainingPrice === 0">砍价成功</view>
|
||||||
<view v-else v-text="'还剩' + surplusPrice + '元'"></view>
|
<view v-else v-text="'还剩' + bargainHelpCount.remainingPrice + '元'"></view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 帮助砍价、帮砍成功:-->
|
|
||||||
<!-- <view class="bargainSuccess" v-if="bargainPartake != userInfo.uid && !statusUser && !helpListLoading">
|
|
||||||
<span class="iconfont icon-xiaolian"></span>已成功帮助好友砍价
|
|
||||||
</view> -->
|
|
||||||
<!-- 砍价成功:-->
|
<!-- 砍价成功:-->
|
||||||
<view class="bargainSuccess" v-if="
|
<!--
|
||||||
surplusPrice === 0 &&
|
surplusPrice 砍价剩余金额为0
|
||||||
bargainPartake === userInfo.uid &&
|
bargainUid 砍价人为发起砍价用户
|
||||||
userBargainStatus === 1 &&
|
userBargainStatus 砍价状态为
|
||||||
!helpListLoading
|
-->
|
||||||
">
|
<view class="bargainSuccess" v-if="pay">
|
||||||
<span class="iconfont icon-xiaolian"></span>恭喜您砍价成功,快去支付吧~
|
<span class="iconfont icon-xiaolian"></span>恭喜您砍价成功,快去支付吧~
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-if="userBargainStatus == 0 && bargainPartake === userInfo.uid" class="bargainBnt" @click="goParticipate">
|
<!-- 参与砍价按钮 同一人-->
|
||||||
立即参与砍价</view>
|
<view v-if="participate" class="bargainBnt" @click="goParticipate">立即参与砍价</view>
|
||||||
<view class="bargainBnt" @click="goPoster" v-if="
|
|
||||||
surplusPrice > 0 &&
|
<!-- 邀请好友按钮 -->
|
||||||
bargainPartake === userInfo.uid &&
|
<view v-if="inviteFriends" class="bargainBnt" @click="goPoster">邀请好友帮砍价</view>
|
||||||
userBargainStatus === 1 &&
|
|
||||||
!helpListLoading
|
<!-- 帮砍好友砍按钮 -->
|
||||||
">邀请好友帮砍价</view>
|
<view v-if="helpFriendsBargain" class="bargainBnt" @click="getBargainHelp">帮好友砍一刀</view>
|
||||||
<view class="bargainBnt" @click="getBargainHelp" v-else-if="
|
|
||||||
bargainPartake != userInfo.uid &&
|
<!-- 发起砍价按钮 非同一人-->
|
||||||
userBargainStatus == 1 &&
|
<view v-if="bargain" class="bargainBnt" @click="getBargainStart">我也要参与</view>
|
||||||
statusUser &&
|
|
||||||
!helpListLoading
|
<!-- 支付按钮 -->
|
||||||
">帮好友砍一刀</view>
|
<view class="bargainBnt" @click="goPay" v-if="pay">立即支付</view>
|
||||||
<view class="bargainBnt" @click="getBargainStart"
|
|
||||||
v-if="bargainPartake != userInfo.uid && !statusUser && !helpListLoading">我也要参与</view>
|
|
||||||
<view class="bargainBnt" @click="goPay" v-if="
|
|
||||||
surplusPrice === 0 &&
|
|
||||||
bargainPartake === userInfo.uid &&
|
|
||||||
userBargainStatus === 1
|
|
||||||
">立即支付</view>
|
|
||||||
<view class="bargainBnt on" @click="goList">抢更多商品</view>
|
<view class="bargainBnt on" @click="goList">抢更多商品</view>
|
||||||
<view class="tip">
|
<view class="tip">已有<span class="font-color-red" v-text="bargainHelpCount.count"></span>位好友成功帮您砍价</view>
|
||||||
已有
|
|
||||||
<span class="font-color-red" v-text="helpCount"></span>
|
|
||||||
位好友成功帮您砍价
|
|
||||||
</view>
|
|
||||||
<view class="lock"></view>
|
<view class="lock"></view>
|
||||||
</view>
|
</view>
|
||||||
<view class="bargainGang bargain-box">
|
<view class="bargainGang bargain-box">
|
||||||
@ -123,7 +116,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="load font-color-red" v-if="!helpListStatus && !helpListLoading" @click="getBargainHelpList">点击加载更多
|
<view class="load font-color-red" v-if="!helpListStatus " @click="getBargainHelpList">点击加载更多
|
||||||
</view>
|
</view>
|
||||||
<view class="lock"></view>
|
<view class="lock"></view>
|
||||||
</view>
|
</view>
|
||||||
@ -137,7 +130,7 @@
|
|||||||
<image src="@/static/images/left.png" />
|
<image src="@/static/images/left.png" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="conter" v-html="bargain.description"></view>
|
<view class="conter" v-html="goodsDetail.description"></view>
|
||||||
<view class="lock"></view>
|
<view class="lock"></view>
|
||||||
</view>
|
</view>
|
||||||
<view class="goodsDetails bargain-box">
|
<view class="goodsDetails bargain-box">
|
||||||
@ -150,21 +143,17 @@
|
|||||||
<image src="@/static/images/left.png" />
|
<image src="@/static/images/left.png" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="conter" v-html="bargain.rule"></view>
|
<view class="conter" v-html="goodsDetail.rule"></view>
|
||||||
</view>
|
</view>
|
||||||
<view class="bargainTip" :class="active === true ? 'on' : ''">
|
<view class="bargainTip" :class="active === true ? 'on' : ''">
|
||||||
<!-- <view class="pictrue">
|
<view class="cutOff" v-if="bargainUid === userInfo.uid">
|
||||||
<image src="@/static/images/bargainBg.jpg" />
|
|
||||||
<view class="iconfont icon-guanbi" @click="close"></view>
|
|
||||||
</view>-->
|
|
||||||
<view class="cutOff" v-if="bargainPartake === userInfo.uid">
|
|
||||||
您已砍掉
|
您已砍掉
|
||||||
<text class="font-color-red" v-text="bargainHelpPrice"></text>元,听说分享次数越多砍价成功的机会越大哦!
|
<text class="font-color-red" v-text="bargainHelpPrice"></text>元,听说分享次数越多砍价成功的机会越大哦!
|
||||||
</view>
|
</view>
|
||||||
<view class="cutOff on" v-else>
|
<view class="cutOff on" v-else>
|
||||||
<view class="help font-color-red" v-text="'成功帮砍' + bargainHelpPrice + '元'"></view>,您也可以砍价低价拿哦,快去挑选心仪的商品吧~
|
<view class="help font-color-red" v-text="'成功帮砍' + bargainHelpPrice + '元'"></view>,您也可以砍价低价拿哦,快去挑选心仪的商品吧~
|
||||||
</view>
|
</view>
|
||||||
<view class="tipBnt" @click="goPoster" v-if="bargainPartake === userInfo.uid">邀请好友帮砍价</view>
|
<view class="tipBnt" @click="goPoster" v-if="bargainUid === userInfo.uid">邀请好友帮砍价</view>
|
||||||
<view class="tipBnt" @click="getBargainStart" v-else>我也要参与</view>
|
<view class="tipBnt" @click="getBargainStart" v-else>我也要参与</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="mask" @touchmove.prevent :hidden="active === false" @click="close"></view>
|
<view class="mask" @touchmove.prevent :hidden="active === false" @click="close"></view>
|
||||||
@ -207,88 +196,50 @@
|
|||||||
return {
|
return {
|
||||||
price: 0,
|
price: 0,
|
||||||
bargainId: 0, //砍价编号
|
bargainId: 0, //砍价编号
|
||||||
bargainPartake: 0, //参与砍价
|
|
||||||
bargain: [], //砍价产品信息
|
bargain: [], //砍价产品信息
|
||||||
partake: null,
|
partake: null,
|
||||||
bargainSumCount: 0, //砍价成功人数
|
bargainSumCount: 0, //砍价成功人数
|
||||||
activeMsg: "",
|
activeMsg: "",
|
||||||
// ssssss
|
|
||||||
active: false,
|
active: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
datatime: 0,
|
|
||||||
lookCount: 0, //查看人数
|
lookCount: 0, //查看人数
|
||||||
shareCount: 0, //分享人数
|
shareCount: 0, //分享人数
|
||||||
userCount: 0, //参与人数
|
userCount: 0, //参与人数
|
||||||
bargainHelpPrice: 0, //砍掉金额
|
bargainHelpPrice: 0, //砍掉金额
|
||||||
bargainHelpList: [],
|
bargainHelpList: [],
|
||||||
helpListStatus: false, //砍价列表是否获取完成 false 未完成 true 完成
|
helpListStatus: false, //砍价列表是否获取完成 false 未完成 true 完成
|
||||||
helpListLoading: false, //当前接口是否请求完成 false 完成 true 未完成
|
|
||||||
page: 1, //页码
|
page: 1, //页码
|
||||||
limit: 2, //数量
|
limit: 2, //数量
|
||||||
helpCount: 0, //砍价帮总人数
|
|
||||||
surplusPrice: 0, //剩余金额
|
|
||||||
alreadyPrice: 0, //已砍掉价格
|
|
||||||
pricePercent: 0, //砍价进度条
|
pricePercent: 0, //砍价进度条
|
||||||
bargainUserInfo: [], //砍价 开启砍价用户信息
|
|
||||||
userBargainStatus: 2, //砍价状态
|
|
||||||
statusUser: false // 是否帮别人砍,没砍是true,砍了false
|
bargainShare: {}, // 砍价分享的消息
|
||||||
|
bargainHelpCount: {}, // 砍价的信息数据
|
||||||
|
goodsDetail: {}, // 商品的详情
|
||||||
|
bargainUserInfo: [], // 开启砍价用户信息
|
||||||
|
bargainUid: 0, // 参与砍价的用户
|
||||||
|
pay: false, // 支付
|
||||||
|
bargain: false, // 发起砍价
|
||||||
|
participate: false, // 参与砍价
|
||||||
|
inviteFriends: false, // 邀请好友
|
||||||
|
helpFriendsBargain: false, // 帮好友砍
|
||||||
|
bargainSuccess: false, // 帮好友砍价成功
|
||||||
|
mainBargainSuccess: false, // 砍价成功
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: mapGetters(["userInfo", "isLogin"]),
|
computed: mapGetters(["userInfo", "isLogin"]),
|
||||||
// watch: {
|
|
||||||
// $yroute: function(n) {
|
|
||||||
// var that = this;
|
|
||||||
// if (n.name === NAME) {
|
|
||||||
// that.mountedStart();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
var that = this;
|
this.mountedStart();
|
||||||
that.mountedStart();
|
|
||||||
setTimeout(function () {
|
|
||||||
that.loading = true;
|
|
||||||
}, 500);
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onShareAppMessage: function () {
|
// 开始处理砍价逻辑
|
||||||
return {
|
|
||||||
title: this.storeInfo.title,
|
|
||||||
imageUrl: this.storeInfo.image,
|
|
||||||
path: "pages/activity/DargainDetails/index?id=" + this.storeInfo.id + "&spread=" + uni.getStorageSync(
|
|
||||||
"uid"),
|
|
||||||
success(res) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '分享成功'
|
|
||||||
})
|
|
||||||
},
|
|
||||||
fail(res) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '分享失败',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//参与砍价
|
|
||||||
goParticipate() {
|
|
||||||
if (this.bargainPartake === this.userInfo.uid) this.getBargainStart();
|
|
||||||
else this.getBargainStartUser();
|
|
||||||
this.getBargainHelpCount();
|
|
||||||
},
|
|
||||||
openAlone: function () {
|
|
||||||
this.$yrouter.push({
|
|
||||||
path: "/detail/" + this.bargain.productId
|
|
||||||
});
|
|
||||||
},
|
|
||||||
mountedStart: function () {
|
mountedStart: function () {
|
||||||
var that = this;
|
var that = this;
|
||||||
console.log(this)
|
|
||||||
let url = handleQrCode();
|
let url = handleQrCode();
|
||||||
console.log(url)
|
|
||||||
if (url) {
|
if (url) {
|
||||||
|
// 通过二维码进来
|
||||||
that.bargainId = url.bargainId;
|
that.bargainId = url.bargainId;
|
||||||
that.partake = url.uid;
|
that.partake = url.partake;
|
||||||
} else {
|
} else {
|
||||||
that.bargainId = that.$yroute.query.id;
|
that.bargainId = that.$yroute.query.id;
|
||||||
that.partake = parseInt(that.$yroute.query.partake);
|
that.partake = parseInt(that.$yroute.query.partake);
|
||||||
@ -298,25 +249,43 @@
|
|||||||
this.partake <= 0 ||
|
this.partake <= 0 ||
|
||||||
isNaN(this.partake)
|
isNaN(this.partake)
|
||||||
) {
|
) {
|
||||||
that.bargainPartake = that.userInfo.uid;
|
// url未携带用户uid,填上登录用户uid,跳转
|
||||||
// that.$yrouter.push({
|
that.bargainUid = that.userInfo.uid;
|
||||||
// path: "/pages/activity/DargainDetails/index",
|
that.$yrouter.push({
|
||||||
// query: { id: that.bargainId, partake: that.bargainPartake }
|
path: "/pages/activity/DargainDetails/index",
|
||||||
// });
|
query: {
|
||||||
|
id: that.bargainId,
|
||||||
|
partake: that.bargainUid
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return
|
||||||
} else {
|
} else {
|
||||||
that.bargainPartake = parseInt(this.partake);
|
that.bargainUid = this.partake;
|
||||||
}
|
}
|
||||||
|
// 获取商品详情
|
||||||
that.getBargainHelpCountStart();
|
|
||||||
that.getBargainDetail();
|
that.getBargainDetail();
|
||||||
|
// 砍价数据统计
|
||||||
that.getBargainShare(0);
|
that.getBargainShare(0);
|
||||||
// if (that.bargainPartake !== that.userInfo.uid) that.getBargainStartUser();
|
if (that.bargainUid !== that.userInfo.uid) {
|
||||||
if (that.bargainPartake === that.userInfo.uid) {
|
|
||||||
// that.getBargainStart();
|
|
||||||
} else {
|
|
||||||
that.getBargainStartUser();
|
that.getBargainStartUser();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
//参与砍价
|
||||||
|
goParticipate() {
|
||||||
|
if (this.bargainUid === this.userInfo.uid) {
|
||||||
|
this.getBargainStart()
|
||||||
|
} else {
|
||||||
|
this.getBargainStartUser();
|
||||||
|
}
|
||||||
|
this.getBargainHelpCount();
|
||||||
|
},
|
||||||
|
// 查看商品
|
||||||
|
openAlone: function () {
|
||||||
|
this.$yrouter.push({
|
||||||
|
path: "/detail/" + this.bargain.productId
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 砍价完成,去支付
|
||||||
goPay: function () {
|
goPay: function () {
|
||||||
var data = {};
|
var data = {};
|
||||||
var that = this;
|
var that = this;
|
||||||
@ -342,6 +311,7 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// 生成海报
|
||||||
goPoster: function () {
|
goPoster: function () {
|
||||||
var that = this;
|
var that = this;
|
||||||
that.getBargainShare(that.bargainId);
|
that.getBargainShare(that.bargainId);
|
||||||
@ -353,6 +323,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// 跳转砍价商品列表
|
||||||
goList: function () {
|
goList: function () {
|
||||||
this.$yrouter.push({
|
this.$yrouter.push({
|
||||||
path: "/pages/activity/GoodsBargain/index"
|
path: "/pages/activity/GoodsBargain/index"
|
||||||
@ -366,9 +337,7 @@
|
|||||||
getBargainShare({
|
getBargainShare({
|
||||||
bargainId: bargainId
|
bargainId: bargainId
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
that.lookCount = res.data.lookCount;
|
that.bargainShare = res.data
|
||||||
that.shareCount = res.data.shareCount;
|
|
||||||
that.userCount = res.data.userCount;
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 获取产品详情
|
// 获取产品详情
|
||||||
@ -376,19 +345,17 @@
|
|||||||
var that = this;
|
var that = this;
|
||||||
getBargainDetail(that.bargainId)
|
getBargainDetail(that.bargainId)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
that.bargain = res.data.bargain;
|
that.goodsDetail = res.data.bargain;
|
||||||
that.bargain.description = that.bargain.description.replace(
|
that.goodsDetail.description = that.goodsDetail.description.replace(
|
||||||
/\<img/gi,
|
/\<img/gi,
|
||||||
'<img style="max-width:100%;height:auto;"'
|
'<img style="max-width:100%;height:auto;"'
|
||||||
);
|
);
|
||||||
that.bargain.rule = that.bargain.rule.replace(
|
that.goodsDetail.rule = that.goodsDetail.rule.replace(
|
||||||
/\<img/gi,
|
/\<img/gi,
|
||||||
'<img style="max-width:100%;height:auto;"'
|
'<img style="max-width:100%;height:auto;"'
|
||||||
);
|
);
|
||||||
that.datatime = that.bargain.stopTime / 1000;
|
that.goodsDetail.stopTime = that.goodsDetail.stopTime / 1000
|
||||||
that.getBargainHelpCount();
|
that.getBargainHelpCount();
|
||||||
// that.setOpenShare();
|
|
||||||
that.getBargainHelpList();
|
|
||||||
})
|
})
|
||||||
.catch(res => {
|
.catch(res => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@ -398,14 +365,14 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//开启砍价
|
// 开启砍价
|
||||||
getBargainStart: function () {
|
getBargainStart: function () {
|
||||||
var that = this;
|
var that = this;
|
||||||
getBargainStart({
|
getBargainStart({
|
||||||
bargainId: that.bargainId
|
bargainId: that.bargainId
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
that.bargainPartake = that.userInfo.uid;
|
that.bargainUid = that.userInfo.uid;
|
||||||
that.getBargainHelp();
|
that.getBargainHelp();
|
||||||
})
|
})
|
||||||
.catch(res => {
|
.catch(res => {
|
||||||
@ -416,12 +383,12 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//参与砍价
|
// 参与砍价
|
||||||
getBargainHelp: function () {
|
getBargainHelp: function () {
|
||||||
var that = this;
|
var that = this;
|
||||||
if (
|
if (
|
||||||
that.surplusPrice === 0 &&
|
this.bargainHelpCount.remainingPrice === 0 &&
|
||||||
that.bargainPartake !== that.userInfo.uid
|
that.bargainUid !== that.userInfo.uid
|
||||||
) {
|
) {
|
||||||
return uni.showToast({
|
return uni.showToast({
|
||||||
title: "好友已经砍价成功",
|
title: "好友已经砍价成功",
|
||||||
@ -431,15 +398,12 @@
|
|||||||
}
|
}
|
||||||
var data = {
|
var data = {
|
||||||
bargainId: that.bargainId,
|
bargainId: that.bargainId,
|
||||||
bargainUserUid: that.bargainPartake
|
bargainUserUid: that.bargainUid
|
||||||
};
|
};
|
||||||
getBargainHelp(data)
|
getBargainHelp(data)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
that.activeMsg = res.data.status;
|
that.activeMsg = res.data.status;
|
||||||
if (
|
if (res.data.status === "SUCCESSFUL" && that.bargainUid !== that.userInfo.uid) {
|
||||||
res.data.status === "SUCCESSFUL" &&
|
|
||||||
that.bargainPartake !== that.userInfo.uid
|
|
||||||
) {
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "您已经砍过了",
|
title: "您已经砍过了",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
@ -463,15 +427,12 @@
|
|||||||
//获取砍掉的金额
|
//获取砍掉的金额
|
||||||
getBargainHelpPrice: function () {
|
getBargainHelpPrice: function () {
|
||||||
var that = this;
|
var that = this;
|
||||||
that.helpListLoading = true;
|
|
||||||
|
|
||||||
getBargainHelpPrice({
|
getBargainHelpPrice({
|
||||||
bargainId: that.bargainId,
|
bargainId: that.bargainId,
|
||||||
bargainUserUid: that.bargainPartake
|
bargainUserUid: that.bargainUid
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
that.bargainHelpPrice = res.data.price;
|
that.bargainHelpPrice = res.data.price;
|
||||||
that.helpListLoading = false;
|
|
||||||
that.getBargainHelpCount();
|
that.getBargainHelpCount();
|
||||||
that.getBargainHelpList();
|
that.getBargainHelpList();
|
||||||
switch (that.activeMsg) {
|
switch (that.activeMsg) {
|
||||||
@ -490,29 +451,25 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//砍价帮
|
// 砍价帮助列表
|
||||||
getBargainHelpList: function () {
|
getBargainHelpList: function () {
|
||||||
var that = this;
|
var that = this;
|
||||||
if (that.helpListLoading === true) return;
|
|
||||||
if (that.helpListStatus === true) return;
|
if (that.helpListStatus === true) return;
|
||||||
that.helpListLoading = true;
|
|
||||||
getBargainHelpList({
|
getBargainHelpList({
|
||||||
bargainId: that.bargainId,
|
bargainId: that.bargainId,
|
||||||
bargainUserUid: that.bargainPartake,
|
bargainUserUid: that.bargainUid,
|
||||||
page: that.page,
|
page: that.page,
|
||||||
limit: that.limit
|
limit: that.limit
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
that.helpListStatus = res.data.length < that.limit;
|
that.helpListStatus = res.data.length < that.limit;
|
||||||
that.helpListLoading = false;
|
|
||||||
that.page++;
|
that.page++;
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
that.bargainHelpList.push.apply(that.bargainHelpList, res.data);
|
that.bargainHelpList.push.apply(that.bargainHelpList, res.data);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log(err)
|
if (!err.msg) {
|
||||||
if(!err.msg){
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@ -522,53 +479,100 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getBargainHelpCountStart: function () {
|
// 砍价 砍价帮总人数、剩余金额、进度条、已经砍掉的价格
|
||||||
var that = this;
|
|
||||||
getBargainHelpCount({
|
|
||||||
bargainId: that.bargainId,
|
|
||||||
bargainUserUid: that.bargainPartake
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
// this.$yrouter.push({
|
|
||||||
// path: "/pages/activity/DargainDetails/index",
|
|
||||||
// query: {
|
|
||||||
// id: that.bargainId,
|
|
||||||
// partake: that.userInfo.uid
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
});
|
|
||||||
},
|
|
||||||
getBargainHelpCount: function () {
|
getBargainHelpCount: function () {
|
||||||
var that = this;
|
|
||||||
getBargainHelpCount({
|
getBargainHelpCount({
|
||||||
bargainId: that.bargainId,
|
bargainId: this.bargainId,
|
||||||
bargainUserUid: that.bargainPartake
|
bargainUserUid: this.bargainUid
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
that.userBargainStatus = res.data.status;
|
// 剩余砍价金额 = 商品价格 - 已经砍掉的金额
|
||||||
that.helpCount = res.data.count;
|
let remainingPrice = (this.goodsDetail.price - res.data.alreadyPrice).toFixed(2)
|
||||||
that.surplusPrice = res.data.price;
|
this.bargainHelpCount = {
|
||||||
that.alreadyPrice = res.data.alreadyPrice;
|
...res.data,
|
||||||
that.pricePercent = res.data.pricePercent;
|
remainingPrice
|
||||||
that.price = (that.bargain.price - that.alreadyPrice).toFixed(2);
|
}
|
||||||
console.log(that);
|
this.handleButtonStatus()
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(err => {
|
||||||
that.bargainPartake = that.userInfo.uid;
|
if (!err.msg) {
|
||||||
// that.$yrouter.push({
|
return
|
||||||
// path: "/pages/activity/DargainDetails/index",
|
}
|
||||||
// query: { id: that.bargainId, partake: that.userInfo.uid }
|
uni.showToast({
|
||||||
// });
|
title: err.msg || err.response.data.msg || err.response.data.message,
|
||||||
|
icon: "none",
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// 判断是否可以支付
|
||||||
|
handleButtonStatus() {
|
||||||
|
// 砍价按钮分为
|
||||||
|
// 1.参与砍价 ==> 发起用户和砍价用户为同一人 && 未参与
|
||||||
|
if (
|
||||||
|
this.bargainUid === this.userInfo.uid &&
|
||||||
|
this.bargainHelpCount.status == 0
|
||||||
|
) {
|
||||||
|
this.participate = true
|
||||||
|
} else {
|
||||||
|
this.participate = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2.邀请好友 ==> 发起用户和砍价用户同一人 && 已参与未过期 && 剩余金额>0
|
||||||
|
if (
|
||||||
|
this.bargainUid === this.userInfo.uid &&
|
||||||
|
this.bargainHelpCount.status == 1 &&
|
||||||
|
this.bargainHelpCount.remainingPrice > 0
|
||||||
|
) {
|
||||||
|
this.inviteFriends = true
|
||||||
|
} else {
|
||||||
|
this.inviteFriends = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3.帮好友砍价 ==> 发起用户和砍价用户非一人 && 未参与未过期 && 剩余金额>0 && 为砍价
|
||||||
|
if (
|
||||||
|
this.bargainUid != this.userInfo.uid &&
|
||||||
|
this.bargainHelpCount.status == 1 &&
|
||||||
|
// this.bargainHelpCount.userBargainStatus &&
|
||||||
|
this.bargainHelpCount.remainingPrice > 0
|
||||||
|
) {
|
||||||
|
this.helpFriendsBargain = true
|
||||||
|
} else {
|
||||||
|
this.helpFriendsBargain = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4.支付 ==> 发起用户和砍价用户用户同一人 && 已参与未过期 && 剩余金额<=0
|
||||||
|
if (
|
||||||
|
this.bargainUid === this.userInfo.uid &&
|
||||||
|
this.bargainHelpCount.status == 1 &&
|
||||||
|
this.bargainHelpCount.remainingPrice <= 0
|
||||||
|
) {
|
||||||
|
this.pay = true
|
||||||
|
} else {
|
||||||
|
this.pay = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5.砍价人发起新的砍价 ==> 发起用户和砍价用户非一人 && 未参与
|
||||||
|
if (
|
||||||
|
this.bargainUid != this.userInfo.uid
|
||||||
|
) {
|
||||||
|
this.bargain = true
|
||||||
|
}else{
|
||||||
|
this.bargain = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 砍价弹窗
|
||||||
|
// 1.发起人砍价成功 ==> 发起用户和砍价用户用户同一人 && 已参与未过期
|
||||||
|
// 2.砍价人砍价成功 ==> 发起用户和砍价用户非一人 && 已参与未过期
|
||||||
|
// 3.已砍价 ==> 已参与 && 砍价状态为 true
|
||||||
|
|
||||||
|
},
|
||||||
|
// 获取开启砍价用户信息
|
||||||
getBargainStartUser: function () {
|
getBargainStartUser: function () {
|
||||||
var that = this;
|
var that = this;
|
||||||
getBargainStartUser({
|
getBargainStartUser({
|
||||||
bargainId: that.bargainId,
|
bargainId: that.bargainId,
|
||||||
bargainUserUid: that.bargainPartake
|
bargainUserUid: that.bargainUid
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
that.bargainUserInfo = res.data;
|
that.bargainUserInfo = res.data;
|
||||||
@ -582,9 +586,30 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// 关闭弹窗
|
||||||
close: function () {
|
close: function () {
|
||||||
this.active = false;
|
this.active = false;
|
||||||
}
|
},
|
||||||
|
// 设置微信分享
|
||||||
|
onShareAppMessage: function () {
|
||||||
|
return {
|
||||||
|
title: this.storeInfo.title,
|
||||||
|
imageUrl: this.storeInfo.image,
|
||||||
|
path: "pages/activity/DargainDetails/index?id=" + this.storeInfo.id + "&spread=" + uni.getStorageSync(
|
||||||
|
"uid"),
|
||||||
|
success(res) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '分享成功'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fail(res) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '分享失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
onShareAppMessage() {
|
onShareAppMessage() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -311,7 +311,9 @@
|
|||||||
if (url && url.id) {
|
if (url && url.id) {
|
||||||
this.id = url.id;
|
this.id = url.id;
|
||||||
let urlSpread = parseInt(url.spread);
|
let urlSpread = parseInt(url.spread);
|
||||||
cookie.set("spread", urlSpread || 0);
|
if (urlSpread) {
|
||||||
|
cookie.set("spread", urlSpread);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.id = this._route.query.id;
|
this.id = this._route.query.id;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -889,7 +889,9 @@ export const handleLoginFailure = () => {
|
|||||||
id: qrCode.pinkId,
|
id: qrCode.pinkId,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
cookie.set("spread", qrCode.spread || 0);
|
if (qrCode.spread) {
|
||||||
|
cookie.set("spread", qrCode.spread || 0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('————————')
|
console.log('————————')
|
||||||
console.log('是拼团进来的,但是没有获取到参数')
|
console.log('是拼团进来的,但是没有获取到参数')
|
||||||
@ -912,7 +914,9 @@ export const handleLoginFailure = () => {
|
|||||||
partake: qrCode.uid
|
partake: qrCode.uid
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
cookie.set("spread", qrCode.spread || 0);
|
if (qrCode.spread) {
|
||||||
|
cookie.set("spread", qrCode.spread || 0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
handleNoParameters()
|
handleNoParameters()
|
||||||
console.log('————————')
|
console.log('————————')
|
||||||
@ -933,7 +937,9 @@ export const handleLoginFailure = () => {
|
|||||||
id: qrCode.productId,
|
id: qrCode.productId,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
cookie.set("spread", qrCode.spread || 0);
|
if (qrCode.spread) {
|
||||||
|
cookie.set("spread", qrCode.spread || 0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
handleNoParameters()
|
handleNoParameters()
|
||||||
console.log('————————')
|
console.log('————————')
|
||||||
|
|||||||
Reference in New Issue
Block a user