123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- import {
- getBargainDetail,
- postBargainStartUser,
- postBargainStart,
- postBargainHelpPrice,
- postBargainHelpCount,
- postBargainHelp,
- postBargainHelpList,
- postBargainShare
- } from '../../../api/activity.js';
- import { postCartAdd } from '../../../api/store.js';
- import wxh from '../../../utils/wxh.js';
- import WxParse from '../../../wxParse/wxParse.js';
- import util from '../../../utils/util.js';
- const app = getApp();
- Page({
-
- data: {
- countDownDay: '00',
- countDownHour: '00',
- countDownMinute: '00',
- countDownSecond: '00',
- active: false,
- id:0,
- userInfo:{},
- bargainUid: 0,
- bargainUserInfo: {},
- bargainUserId: 0,
- bargainInfo:[],
- offset:0,
- limit:20,
- limitStatus:false,
- bargainUserHelpList:[],
- bargainUserHelpInfo:[],
- bargainUserBargainPrice:0,
- status:'',
- bargainCount:[],
- retunTop:true,
- bargainPartake:0,
- isHelp:false,
- interval:null,
- userBargainStatus:0,
- productStock:0,
- quota:0,
- userBargainStatusHelp:true,
- navH: '',
- statusPay:'',
- },
-
- onLoad: function (options) {
- this.setData({
- navH: app.globalData.navHeight
- });
- var that = this;
- var pages = getCurrentPages();
- if (pages.length <= 1) that.setData({ retunTop:false});
-
- if (options.scene) {
- var value = util.getUrlParams(decodeURIComponent(options.scene));
- if (typeof value === 'object'){
- if (value.id) options.id = value.id;
- if (value.bargain) options.bargain = value.bargain;
-
- if (value.pid) app.globalData.spid = value.pid;
- }else{
- app.globalData.spid = value;
- }
- }
- if (options.hasOwnProperty('id')) {
- this.setData({ id: options.id, bargainUid: options.bargain || 0 });
- }
- },
-
- goProduct:function(){
- return app.Tips('/pages/goods_details/index?id=' + this.data.bargainInfo.product_id);
- },
- goBack: function () {
- wx.navigateBack({ delta: 1 })
- },
- gobargainUserInfo:function(){
- var that = this;
- var data = { bargainId: that.data.id, bargainUserUid: that.data.bargainUid };
- postBargainStartUser(data).then(res=>{
- that.setData({ bargainUserInfo: res.data });
- });
- },
- goPay: function () {
- var that = this;
- var data = {
- productId: that.data.bargainInfo.product_id,
- bargainId: that.data.id,
- cartNum: that.data.bargainInfo.num,
- uniqueId:'',
- combinationId:0,
- secKillId:0,
- 'new':1
- };
- postCartAdd(data).then(res=>{
- wx.navigateTo({ url: '/pages/order_confirm/index?cartId=' + res.data.cartId });
- }).catch(err=>{
- return app.Tips({title:err})
- });
- },
- getBargainDetails:function(){
- var that = this;
- var id = that.data.id;
- getBargainDetail(id).then(function(res){
- that.setData({
- bargainInfo: res.data.bargain,
- bargainPrice:res.data.bargain.price,
- userInfo: res.data.userInfo,
- bargainSumCount: res.data.bargainSumCount,
- userBargainStatus: res.data.userBargainStatus,
- productStock: res.data.bargain.attr.product_stock,
- quota: res.data.bargain.attr.quota
- });
- app.globalData.openPages = '/pages/activity/goods_bargain_details/index?id=' + that.data.id + '&bargain=' + that.data.bargainUid + '&scene=' + that.data.userInfo.uid;
- WxParse.wxParse('description', 'html', that.data.bargainInfo.description || '', that, 0);
- WxParse.wxParse('rule', 'html', that.data.bargainInfo.rule || '', that, 0);
- wxh.time2(that.data.bargainInfo.stop_time, that);
- that.getBargainHelpCount();
- that.setData({ bargainUserHelpList: [] });
- that.getBargainUser();
- that.gobargainUserInfo();
- }).catch(function(err){
- return app.Tips({ title: err }, { tab: 3, url: 1 });
- })
- },
-
- userBargain:function(){
- let that = this;
- if (that.data.userInfo.uid == that.data.bargainUid){
- that.setBargain();
- }
- },
- getBargainHelpCount: function () {
- var that = this;
- var data = { bargainId: that.data.id, bargainUserUid:that.data.bargainUid };
- postBargainHelpCount(data).then(res=>{
- var price = util.$h.Sub(that.data.bargainPrice, res.data.alreadyPrice);
- that.setData({
- bargainUserHelpInfo: res.data,
- 'bargainInfo.price': parseFloat(price) <= 0 ? 0 : price,
- userBargainStatusHelp: res.data.userBargainStatus,
- statusPay: res.data.status
- });
- })
- },
- currentBargainUser:function(){
- this.setData({ bargainUid:this.data.userInfo.uid });
- this.setBargain();
- },
- setBargain:function(){
- var that = this;
- postBargainStart(that.data.id).then(res=>{
- that.setData({ bargainUserId: res.data });
- that.getBargainUserBargainPrice();
- that.setBargainHelp();
- that.getBargainHelpCount();
- that.setData({
- userBargainStatus:1
- })
- })
- },
- setBargainHelp: function () {
- var that = this;
- var data = { bargainId: that.data.id, bargainUserUid: that.data.bargainUid };
- postBargainHelp(data).then(res=>{
- that.setData({ bargainUserHelpList: [],isHelp:true });
- that.getBargainUser();
- that.getBargainUserBargainPrice();
- that.getBargainHelpCount();
- }).catch(err=>{
- that.setData({ bargainUserHelpList: [] });
- that.getBargainUser();
- })
- },
- getBargainUser: function () {
- var that = this;
- var data = {
- bargainId: that.data.id,
- bargainUserUid: that.data.bargainUid,
- offset: that.data.offset,
- limit: that.data.limit,
- };
- postBargainHelpList(data).then(res=>{
- var bargainUserHelpListNew = [];
- var bargainUserHelpList = that.data.bargainUserHelpList;
- var len = res.data.length;
- bargainUserHelpListNew = bargainUserHelpList.concat(res.data);
- that.setData({ bargainUserHelpList: bargainUserHelpListNew, limitStatus: data.limit > len, offest: Number(data.offset) + Number(data.limit) });
- });
- },
- getBargainUserBargainPricePoster:function(){
- var that = this;
- wx.navigateTo({
- url: '/pages/activity/poster-poster/index?type=1&id=' + that.data.id,
- });
- },
- getBargainUserBargainPrice: function () {
- var that = this;
- var data = {bargainId: that.data.id,bargainUserUid: that.data.bargainUid};
- postBargainHelpPrice(data).then(res=>{
- that.setData({ bargainUserBargainPrice: res.data, active: true });
- }).catch(err=>{
- that.setData({ active: false });
- });
- },
- goBargainList:function(){
- wx.navigateTo({
- url: '/pages/activity/goods_bargain/index',
- })
- },
- close:function(){
- this.setData({
- active: false
- })
- },
-
- onReady: function () {
- },
- onLoadFun: function (e) {
- let uid = e.detail.uid;
- if(!this.data.bargainUid && uid){
- this.setData({bargainUid:uid});
- }
- if(!this.data.bargainUid){
- return app.Tips({ title:'参数错误'},{tab:3,url:1})
- }
- this.getBargainDetails();
- this.addShareBargain();
- app.globalData.openPages = '/pages/activity/goods_bargain_details/index?id=' + this.data.id + '&bargain=' + this.data.bargainUid + '&spid=' + e.detail.uid;
- this.setData({ bargainPartake: e.detail.uid});
- },
-
- onShow: function () {
- },
-
- onHide: function () {
- if (this.data.interval !== null) clearInterval(this.data.interval);
- },
-
- onUnload: function () {
- if (this.data.interval !== null) clearInterval(this.data.interval);
- },
-
- onPullDownRefresh: function () {
- },
-
- onReachBottom: function () {
- },
- addShareBargain: function () {
- var that = this;
- postBargainShare(this.data.id).then(res=>{
- that.setData({ bargainCount: res.data })
- });
- },
-
- onShareAppMessage: function () {
- var that = this;
- that.close();
- that.addShareBargain();
- return {
- title: '您的好友' + that.data.userInfo.nickname + '邀请您帮他砍' + that.data.bargainInfo.title+' 快去帮忙吧!',
- path: app.globalData.openPages,
- imageUrl: that.data.bargainInfo.image,
- }
- }
- })
|