|
|
|
@ -1,6 +1,12 @@ |
|
|
|
// pages/order/order-info/index.js
|
|
|
|
import { biddingActivity, getBiddingList, getUserProduct } from "../../api/ztb" |
|
|
|
import { $wuxCountDown } from '../../../components/index' |
|
|
|
import { |
|
|
|
biddingActivity, |
|
|
|
getBiddingList, |
|
|
|
getUserProduct |
|
|
|
} from "../../api/ztb" |
|
|
|
import { |
|
|
|
$wuxCountDown |
|
|
|
} from '../../../components/index' |
|
|
|
const util = require('../../../utils/util') |
|
|
|
const math = require('../../../utils/math') |
|
|
|
const event = require('../../../utils/event.js') |
|
|
|
@ -35,9 +41,15 @@ Page({ |
|
|
|
*/ |
|
|
|
onLoad: function (options) { |
|
|
|
if (getCurrentPages().length == 1) { |
|
|
|
this.setData({ backStr: '首页' }) |
|
|
|
this.setData({ |
|
|
|
backStr: '首页' |
|
|
|
}) |
|
|
|
} |
|
|
|
this.setData({ imageHeight: 750, kg: app.globalData.kg, safeBottom: app.globalData.safeBottom }) |
|
|
|
this.setData({ |
|
|
|
imageHeight: 750, |
|
|
|
kg: app.globalData.kg, |
|
|
|
safeBottom: app.globalData.safeBottom |
|
|
|
}) |
|
|
|
event.on('EventMessage', this, this.onEvent) |
|
|
|
if (options.id) { |
|
|
|
wx.showLoading({ |
|
|
|
@ -81,15 +93,17 @@ Page({ |
|
|
|
text: '确定', |
|
|
|
type: 'primary', |
|
|
|
onTap(e) { |
|
|
|
wx.navigateBack({ delta: 1 }) |
|
|
|
wx.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}) |
|
|
|
} |
|
|
|
}] |
|
|
|
}) |
|
|
|
} else if (result.data.bidType == 2 && (result.data.biddingActivityStatus != 0)) { |
|
|
|
|
|
|
|
|
|
|
|
} else if (result.data.bidType == 2 && result.data.biddingActivityStatus == 0) { |
|
|
|
this.fetchBiddingList(result.data.biddingActivityId) |
|
|
|
if(this.data.frist){ |
|
|
|
if (this.data.frist) { |
|
|
|
this.expiredTime(result.data.biddingActivityExpiredTime, id) |
|
|
|
} |
|
|
|
} |
|
|
|
@ -109,9 +123,13 @@ Page({ |
|
|
|
const min = this.leadingZeros(date.min, 2) + ' 分 ' |
|
|
|
const sec = this.leadingZeros(date.sec, 2) + ' 秒 ' |
|
|
|
if (Number(this.leadingZeros(date.days, 1)) > 0) { |
|
|
|
that.setData({ expiredTime: days + hours + min + sec }) |
|
|
|
that.setData({ |
|
|
|
expiredTime: days + hours + min + sec |
|
|
|
}) |
|
|
|
} else { |
|
|
|
that.setData({ expiredTime: hours + min + sec }) |
|
|
|
that.setData({ |
|
|
|
expiredTime: hours + min + sec |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
onEnd() { |
|
|
|
@ -119,19 +137,24 @@ Page({ |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
onChange: function(e){ |
|
|
|
this.setData({ current: e.detail.current + 1 }) |
|
|
|
onChange: function (e) { |
|
|
|
this.setData({ |
|
|
|
current: e.detail.current + 1 |
|
|
|
}) |
|
|
|
}, |
|
|
|
fetchBiddingList: function (biddingActivityId) { |
|
|
|
getBiddingList(biddingActivityId).then(result => { |
|
|
|
for (let index = 0; index < result.data.records.length; index++) { |
|
|
|
const element = result.data.records[index] |
|
|
|
if(element.isMine && app.globalData.userInfo){ |
|
|
|
if (element.isMine && app.globalData.userInfo) { |
|
|
|
this.data.offered = element.biddingUnitPrice |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
this.setData({ recordList: result.data.records, offered: this.data.offered }) |
|
|
|
this.setData({ |
|
|
|
recordList: result.data.records, |
|
|
|
offered: this.data.offered |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
isVideoUrl: function (url) { |
|
|
|
@ -166,7 +189,9 @@ Page({ |
|
|
|
}, |
|
|
|
bindended: function () { |
|
|
|
this.videoContext.exitFullScreen() |
|
|
|
this.setData({ visible: false }) |
|
|
|
this.setData({ |
|
|
|
visible: false |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 图片查看
|
|
|
|
viewImage: function (e) { |
|
|
|
@ -180,12 +205,17 @@ Page({ |
|
|
|
} |
|
|
|
imgList.push(this.data.imgList[index]) |
|
|
|
} |
|
|
|
wx.previewImage({ urls: imgList, current: e.currentTarget.dataset.url }) |
|
|
|
wx.previewImage({ |
|
|
|
urls: imgList, |
|
|
|
current: e.currentTarget.dataset.url |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 进入支付流程
|
|
|
|
offerProject: function (e) { |
|
|
|
if (!app.globalData.userInfo) { |
|
|
|
wx.navigateTo({ url: '/pages/login/index' }) |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/login/index' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
if (!app.globalData.userInfo.isVIP) { |
|
|
|
@ -197,7 +227,9 @@ Page({ |
|
|
|
text: '确定', |
|
|
|
type: 'primary', |
|
|
|
onTap(e) { |
|
|
|
wx.navigateTo({ url: '/pages/ztbvip/index' }) |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/ztbvip/index' |
|
|
|
}) |
|
|
|
} |
|
|
|
}] |
|
|
|
}) |
|
|
|
@ -215,9 +247,11 @@ Page({ |
|
|
|
}] |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
if (this.data.orderInfo.bidType == 1) { |
|
|
|
wx.navigateTo({ url: '/pages/morder/create/index?productId=' + this.data.orderInfo.productId }) |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/morder/create/index?productId=' + this.data.orderInfo.productId |
|
|
|
}) |
|
|
|
} else { |
|
|
|
var that = this |
|
|
|
// this.biddingDialog.showBidding(this.data.orderInfo)
|
|
|
|
@ -229,7 +263,7 @@ Page({ |
|
|
|
value: that.formatePrice(price, app.globalData.kg), |
|
|
|
step: that.formatePrice(that.data.orderInfo.biddingRange, app.globalData.kg), |
|
|
|
content: '请输入您的报价(元/' + (app.globalData.kg ? 'KG' : '吨') + ')', |
|
|
|
fieldtype: app.globalData.kg ? 'digit' : 'numger', |
|
|
|
fieldtype: app.globalData.kg ? 'digit' : 'numger', |
|
|
|
defaultText: '', |
|
|
|
placeholder: '请输入您的报价', |
|
|
|
maxlength: 8, |
|
|
|
@ -242,7 +276,7 @@ Page({ |
|
|
|
}, |
|
|
|
formatePrice: function (value, kg) { |
|
|
|
if (value || value == 0) { |
|
|
|
if(kg){ |
|
|
|
if (kg) { |
|
|
|
return (parseFloat(value)).toFixed(3) |
|
|
|
} else { |
|
|
|
return (parseFloat(value) * 1000).toFixed(1) |
|
|
|
@ -252,14 +286,37 @@ Page({ |
|
|
|
}, |
|
|
|
onShareAppMessage: function () { |
|
|
|
var title = this.data.orderInfo.locProvinceName + this.data.orderInfo.locCityName |
|
|
|
if(this.data.orderInfo.bidType == 2){ |
|
|
|
if (this.data.orderInfo.bidType == 2) { |
|
|
|
title += this.data.orderInfo.secondCategoryName + '竞价中' |
|
|
|
} else { |
|
|
|
title += '出售' + this.data.orderInfo.secondCategoryName |
|
|
|
} |
|
|
|
var imgUrl = this.data.orderInfo.imgList[0] |
|
|
|
if (this.isVideoUrl(imgUrl)) { |
|
|
|
if (this.data.orderInfo.imgList.length > 1) { |
|
|
|
imgUrl = this.data.orderInfo.imgList[1] |
|
|
|
} else { |
|
|
|
imgUrl = '/assets/image/icon_logo.png' |
|
|
|
} |
|
|
|
} |
|
|
|
return { |
|
|
|
title: title, |
|
|
|
path: 'pages/index/index?url=/pages/mall/detail/index&key=id&value=' + this.data.orderInfo.productId, |
|
|
|
imageUrl: imgUrl, |
|
|
|
success: function (res) {} |
|
|
|
} |
|
|
|
}, |
|
|
|
// 分享至朋友圈
|
|
|
|
onShareTimeline() { |
|
|
|
var title = this.data.orderInfo.locProvinceName + this.data.orderInfo.locCityName |
|
|
|
if (this.data.orderInfo.bidType == 2) { |
|
|
|
title += this.data.orderInfo.secondCategoryName + '竞价中' |
|
|
|
} else { |
|
|
|
title += '出售' + this.data.orderInfo.secondCategoryName |
|
|
|
} |
|
|
|
var imgUrl = this.data.orderInfo.imgList[0] |
|
|
|
if(this.isVideoUrl(imgUrl) ){ |
|
|
|
if(this.data.orderInfo.imgList.length > 1){ |
|
|
|
if (this.isVideoUrl(imgUrl)) { |
|
|
|
if (this.data.orderInfo.imgList.length > 1) { |
|
|
|
imgUrl = this.data.orderInfo.imgList[1] |
|
|
|
} else { |
|
|
|
imgUrl = '/assets/image/icon_logo.png' |
|
|
|
@ -284,23 +341,30 @@ Page({ |
|
|
|
if (!this.data.orderInfo) { |
|
|
|
return |
|
|
|
} |
|
|
|
if(!app.globalData.userInfo){ |
|
|
|
wx.navigateTo({ url: '/pages/login/index'}) |
|
|
|
if (!app.globalData.userInfo) { |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/login/index' |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
util.navigateTo('/pages/shop/detail/index?storeId=' + this.data.orderInfo.storeId) |
|
|
|
}, |
|
|
|
biddingPrice: function (price) { |
|
|
|
if(util.isEmpty(price)){ |
|
|
|
if (util.isEmpty(price)) { |
|
|
|
util.showToast('请输入您的报价') |
|
|
|
return |
|
|
|
} |
|
|
|
if(Number(price) <= 0){ |
|
|
|
if (Number(price) <= 0) { |
|
|
|
util.showToast('请输入合理的报价') |
|
|
|
return |
|
|
|
} |
|
|
|
wx.showLoading({ title: '加载中', mask: true }) |
|
|
|
biddingActivity(this.data.orderInfo.biddingActivityId, { biddingUnitPrice: price }).then(result => { |
|
|
|
wx.showLoading({ |
|
|
|
title: '加载中', |
|
|
|
mask: true |
|
|
|
}) |
|
|
|
biddingActivity(this.data.orderInfo.biddingActivityId, { |
|
|
|
biddingUnitPrice: price |
|
|
|
}).then(result => { |
|
|
|
wx.hideLoading() |
|
|
|
this.fetchBiddingList(this.data.orderInfo.biddingActivityId) |
|
|
|
util.showToast('报价成功') |
|
|
|
|