Browse Source

无库存

master
caichunsheng 4 years ago
parent
commit
c569d881ff
  1. 126
      pages/info/postProductInfo/index.js
  2. 38
      pages/info/sceneProductInfo/index.js
  3. 4
      pages/info/sceneProductInfo/index.wxml
  4. 6
      pages/info/sceneProductInfo/index.wxss
  5. 8
      pages/order/postOrder/index.js
  6. 1
      pages/order/scene/index.js
  7. 2
      pages/user/cartlist/list.wxml
  8. 12
      pages/user/coupon/index.js
  9. 6
      pages/user/coupon/index.wxml
  10. 5
      pages/user/coupon/index.wxss
  11. 127
      pages/user/user.js
  12. 16
      pages/user/user.wxml
  13. 59
      pages/user/user.wxss

126
pages/info/postProductInfo/index.js

@ -257,72 +257,72 @@ Page({
order: function () { order: function () {
app.globalData.postProduct = null app.globalData.postProduct = null
app.globalData.list = [] app.globalData.list = []
// commonApi.user_post("/product/checkStock", { commonApi.user_post("/product/checkStock", {
// sku_id: this.data.info.sku[this.data.skuIndex].id, sku_id: this.data.info.sku[this.data.skuIndex].id,
// }).then(res => { }).then(res => {
// if (res && res.code != 1) { if (res && res.code != 1) {
// return; return;
// } else { } else {
if (this.data.skuFlag == 'order') { if (this.data.skuFlag == 'order') {
util.pagePoint({ util.pagePoint({
event: 'product_order', event: 'product_order',
param: { param: {
id: this.data.info.id, id: this.data.info.id,
type: this.data.info.type type: this.data.info.type
} }
}, 1) }, 1)
wx.setStorageSync('login_from', 'product_order_login') wx.setStorageSync('login_from', 'product_order_login')
wx.setStorageSync('order_from', 'product_order_submit') wx.setStorageSync('order_from', 'product_order_submit')
app.globalData.couponInfo = null; app.globalData.couponInfo = null;
// 购买 // 购买
let product = [{ let product = [{
product: this.data.info, product: this.data.info,
sku: this.data.info.sku[this.data.skuIndex], sku: this.data.info.sku[this.data.skuIndex],
productNum: this.data.producNum productNum: this.data.producNum
}]; }];
app.globalData.postProduct = product; app.globalData.postProduct = product;
app.globalData.retailId = this.data.retailId; app.globalData.retailId = this.data.retailId;
wx.navigateTo({ wx.navigateTo({
url: '/pages/order/postOrder/index', url: '/pages/order/postOrder/index',
})
} else {
commonApi.user_post("cart/add_sku", {
sku_id: this.data.info.sku[this.data.skuIndex].id,
num: this.data.producNum
}).then(res => {
if (res.code == 1) {
commonApi.user_post('cart/get_list', {}).then(res => {
this.setData({
cartCount: res.data.length
})
}) })
} else { // 加动效
commonApi.user_post("cart/add_sku", { this.setData({
sku_id: this.data.info.sku[this.data.skuIndex].id, skuFlag: null,
num: this.data.producNum aniSkuIndex: this.data.skuIndex,
}).then(res => { cartImgInfo: null
if (res.code == 1) {
commonApi.user_post('cart/get_list', {}).then(res => {
this.setData({
cartCount: res.data.length
})
})
// 加动效
this.setData({
skuFlag: null,
aniSkuIndex: this.data.skuIndex,
cartImgInfo: null
})
setTimeout(() => {
this.setData({
aniSkuIndex: -1
})
wx.showModal({
title: "提示",
content: "去购物车结算?",
success: function (res) {
if (res.confirm) {
wx.navigateTo({
url: '/pages/user/cartlist/list',
})
}
}
})
}, 650)
}
}) })
setTimeout(() => {
this.setData({
aniSkuIndex: -1
})
wx.showModal({
title: "提示",
content: "去购物车结算?",
success: function (res) {
if (res.confirm) {
wx.navigateTo({
url: '/pages/user/cartlist/list',
})
}
}
})
}, 650)
} }
// } })
// }) }
}
})
}, },
// 分享 // 分享

38
pages/info/sceneProductInfo/index.js

@ -249,27 +249,37 @@ Page({
// }) // })
// }, // },
selectSku: function (e) { selectSku: function (e) {
console.log(e.currentTarget.dataset.item);
if (e.currentTarget.dataset.item.stock == 0) {
wx.showToast({
title: "该商品暂无库存",
icon: 'none'
})
return
}
let index = e.currentTarget.dataset.index; let index = e.currentTarget.dataset.index;
this.setData({ this.setData({
skuIndex: index skuIndex: index
}) })
}, },
order: function (e) { order: function (e) {
// commonApi.user_post("/product/checkStock", { commonApi.user_post("/product/checkStock", {
// sku_id: this.data.skuList[this.data.skuIndex].id, sku_id: this.data.skuList[this.data.skuIndex].id,
// }).then(res => { }).then(res => {
// if (res && res.code != 1) { if (res && res.code != 1) {
// wx.showModal({ wx.showModal({
// title: "温馨提示", title: "温馨提示",
// content: '商品已经被抢光啦~要不要瞧瞧别的~', content: '商品已经被抢光啦~要不要瞧瞧别的~',
// showCancel: false showCancel: false
// }) })
// return; return;
// } else { } else {
app.globalData.postProduct = [] app.globalData.postProduct = []
app.globalData.list = [] app.globalData.list = []
if (this.data.skuFlag == 'order') { if (this.data.skuFlag == 'order') {
if (e.currentTarget.dataset.disable == 1) return; if (e.currentTarget.dataset.disable === 1) return;
util.pagePoint({ util.pagePoint({
event: 'scene_order', event: 'scene_order',
param: { param: {
@ -332,8 +342,8 @@ Page({
} }
}) })
} }
// } }
// }) })
}, },
pagePoint: function (e) { pagePoint: function (e) {
util.pagePoint({ util.pagePoint({

4
pages/info/sceneProductInfo/index.wxml

@ -125,7 +125,7 @@
</view> </view>
</view> </view>
<view class="sku-names"> <view class="sku-names">
<view bindtap="selectSku" data-index="{{index}}" class="sku-name-item textOver{{index==skuIndex?' active':''}}" wx:for="{{skuList}}">{{item.sku_name}}</view> <view bindtap="selectSku" data-index="{{index}}" data-item="{{item}}" class="sku-name-item textOver{{index==skuIndex?' active':''}}" wx:for="{{skuList}}">{{item.sku_name}}</view>
</view> </view>
<view class="number-box"> <view class="number-box">
<text>数量</text> <text>数量</text>
@ -135,7 +135,7 @@
</view> </view>
<view style="height:138rpx"></view> <view style="height:138rpx"></view>
<view class="btn-box"> <view class="btn-box">
<view class="mask-btn" bindtap="order" data-sku="{{sku}}" data-product="{{item}}" wx:if="{{info && info.flag==1}}" data-disable="{{item.flag==0 || sku.flag=='off'?1:0}}" data-disable="{{item.flag==0 || sku.flag=='off'?1:0}}">{{skuFlag=='cart'?'确认':'立即购买'}} <view class="mask-btn" bindtap="order" data-product="{{item}}" wx:if="{{info && info.flag==1}}">{{skuFlag=='cart'?'确认':'立即购买'}}
</view> </view>
<view class="mask-btn disable" wx:else>该商品已下架</view> <view class="mask-btn disable" wx:else>该商品已下架</view>
</view> </view>

6
pages/info/sceneProductInfo/index.wxss

@ -717,6 +717,12 @@ page {
color: #999; color: #999;
} }
.sku-name-item.disable {
border-color: transparent;
color: #fff;
background: #d7d7d7;
}
.number-box view.number { .number-box view.number {
width: 94rpx; width: 94rpx;
margin: 0 15rpx; margin: 0 15rpx;

8
pages/order/postOrder/index.js

@ -28,6 +28,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.setData({ this.setData({
from: options.from, from: options.from,
kjId: app.globalData.kjId, kjId: app.globalData.kjId,
@ -186,8 +187,11 @@ Page({
}else{ }else{
app.globalData.productPrice = (this.data.showPrice + this.data.postFee - (this.data.coupon?this.data.coupon.activity.money:0))/100; app.globalData.productPrice = (this.data.showPrice + this.data.postFee - (this.data.coupon?this.data.coupon.activity.money:0))/100;
app.globalData.createDate = data app.globalData.createDate = data
console.log(app.globalData.createDate) console.log(app.globalData.product)
wx.navigateTo({ if (!app.globalData.product) {
app.globalData.product = app.globalData.list[0]
}
wx.redirectTo({
url: '/pages/order/scene/index?flag='+this.data.flag, url: '/pages/order/scene/index?flag='+this.data.flag,
}) })
} }

1
pages/order/scene/index.js

@ -361,6 +361,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
if(app.globalData.list && app.globalData.list.length != 0){ if(app.globalData.list && app.globalData.list.length != 0){
app.globalData.product = app.globalData.list[app.globalData.index] app.globalData.product = app.globalData.list[app.globalData.index]
} }

2
pages/user/cartlist/list.wxml

@ -33,6 +33,6 @@
<view class="tip">合计:</view> <view class="tip">合计:</view>
<view class="bottom-price">¥{{allPrice/100}} </view> <view class="bottom-price">¥{{allPrice/100}} </view>
<view style="margin-right: 10rpx; font-size: 29rpx;color: #000;">起</view> <view style="margin-right: 10rpx; font-size: 29rpx;color: #000;">起</view>
<view style="flex:1">不含运费</view> <view style="flex:1"></view>
<view class="btn" bindtap="order">去下单</view> <view class="btn" bindtap="order">去下单</view>
</view> </view>

12
pages/user/coupon/index.js

@ -8,7 +8,8 @@ Page({
data: { data: {
list:[], list:[],
moreFlag:true, moreFlag:true,
index:0 index:0,
showR:false
}, },
/** /**
@ -43,6 +44,15 @@ Page({
}) })
this.getList() this.getList()
}, },
showRule(e){
wx.showModal({
cancelColor: 'cancelColor',
showCancel:false,
title:"使用规则",
content:e.currentTarget.dataset.item.activity.use_rule_text
})
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成

6
pages/user/coupon/index.wxml

@ -11,10 +11,12 @@
<view class="title textOver">{{item.activity.name}}</view> <view class="title textOver">{{item.activity.name}}</view>
<view class="coupon-money">¥<text>{{item.activity.money/100}}</text></view> <view class="coupon-money">¥<text>{{item.activity.money/100}}</text></view>
</view> </view>
<view class="coupon-tip"><text>使用条件:</text>全场可用</view> <view class="coupon-tip"><text>使用条件:</text>满{{item.activity.mini_money/100}}元</view>
<view class="coupon-tip"><text>有效期:</text>{{item.activity.end_time}}</view> <view class="coupon-tip"><text>有效期:</text>{{item.activity.end_time}}</view>
<view class="coupon-tip"><text>优惠码:</text>{{item.key}}</view> <view class="coupon-tip"><text>优惠码:</text>{{item.key}}</view>
<view class="coupon-rule">使用规则 <text class="iconfont icon-xia"></text></view> <view class="coupon-rule">
<view bindtap="showRule" data-item="{{item}}">使用规则 <text class="iconfont icon-xia"></text></view>
</view>
</view> </view>
<!-- <view class="coupon-item"> <!-- <view class="coupon-item">
<view class="title-box"> <view class="title-box">

5
pages/user/coupon/index.wxss

@ -83,10 +83,9 @@ page {
color: #999999; color: #999999;
} }
.coupon-rule { .coupon-rule {
line-height: 79rpx; line-height: 100rpx;
font-size: 26rpx; font-size: 26rpx;
position: absolute;
bottom: 0;
} }
.coupon-rule .iconfont { .coupon-rule .iconfont {
font-size: 28rpx; font-size: 28rpx;

127
pages/user/user.js

@ -2,6 +2,7 @@ import common from "../../utils/https/common";
// pages/user/user.js // pages/user/user.js
import userApi from "../../utils/https/user" import userApi from "../../utils/https/user"
import util from '../../utils/util' import util from '../../utils/util'
import commonApi from "../../utils/https/common"
let app = getApp() let app = getApp()
Page({ Page({
@ -10,7 +11,12 @@ Page({
*/ */
data: { data: {
height: 0, height: 0,
info: null info: null,
list: [], //待付款列表
orderList: [],//订单列表
timeList: [],//倒计时
timerOut: null,//定时器
formatTime:[]
}, },
/** /**
@ -73,6 +79,7 @@ Page({
util.pagePoint({ util.pagePoint({
event:'mine_view' event:'mine_view'
},1) },1)
this.getList()
}, },
pagePoint: function(e){ pagePoint: function(e){
util.pagePoint(e) util.pagePoint(e)
@ -92,12 +99,126 @@ Page({
} }
}) })
}, },
getList:function(){
commonApi.user_post("order/list",{
state:'WAIT_PAYMENT',
offset:0,
limit:10,
keywords:''
}).then(res=>{
console.log(res);
let arr = []
let trr = []
let yrr = []
let reslist = res.data.list
this.setData({})
let nowDateTime = parseInt(new Date().getTime() / 1000)
for (let i = 0; i < reslist.length; i++) {
let del = nowDateTime - this.strtotime(reslist[i].create_time)
if (del < reslist[i].auto_close_time) {
trr.push(reslist[i].auto_close_time - del)
yrr.push(this.formatSeconds(reslist[i].auto_close_time - del))
arr.push(reslist[i].order_product_list[0])
}
}
this.setData({
list: arr,
orderList: reslist,
timeList: trr,
formatTime:yrr
})
this.timer(this.data.timeList)
})
},
strtotime(str) {
var _arr = str.split(' ');
var _day = _arr[0].split('-');
_arr[1] = (_arr[1] == null) ? '0:0:0' : _arr[1];
var _time = _arr[1].split(':');
for (let i = _day.length - 1; i >= 0; i--) {
_day[i] = isNaN(parseInt(_day[i])) ? 0 : parseInt(_day[i]);
}
for (let i = _time.length - 1; i >= 0; i--) {
_time[i] = isNaN(parseInt(_time[i])) ? 0 : parseInt(_time[i]);
}
let _temp = new Date(_day[0], _day[1] - 1, _day[2], _time[0], _time[1], _time[2]);
return _temp.getTime() / 1000;
},
formatSeconds(value) {
let secondTime = parseInt(value);
let minuteTime = 0;
let hourTime = 0;
if (secondTime >= 60) {
minuteTime = parseInt(secondTime / 60);
secondTime = parseInt(secondTime % 60);
if (minuteTime >= 60) {
hourTime = parseInt(minuteTime / 60);
minuteTime = parseInt(minuteTime % 60);
}
}
// 补0
hourTime = hourTime < 10 ? "0" + hourTime : hourTime;
minuteTime = minuteTime < 10 ? "0" + minuteTime : minuteTime;
secondTime = secondTime < 10 ? "0" + secondTime : secondTime;
let res = hourTime + ":" + minuteTime + ":" + secondTime;
return res;
},
timer(arr) {
let trr = []
let list = this.data.list
this.data.timerOut = setInterval(() => {
for (let i = 0; i < arr.length; i++) {
arr[i]--
trr[i] = this.formatSeconds(arr[i])
if (arr[i] == 0) {
arr.splice(i, 1)
list.splice(i, 1)
trr.splice(i, 1)
}
}
this.setData({
timeList: arr,
formatTime:trr,
list:list
})
}, 1000)
},
gotoDetail:function(e){
let item = e.currentTarget.dataset.item;
console.log(item);
item = this.getChild(item)
util.gotoOrder(item)
},
getChild(list){
console.log(list);
let arr = {order_product_list:[]}
for (let i = 0; i < list.order_product_list.length; i++) {
if (list.order_product_list[i].product_model=="ticket") {
arr.order_product_list.push(list.order_product_list[i])
break
}
}
if (arr.order_product_list.length>0) {
list.order_product_list = []
list.order_product_list.push(arr.order_product_list[0])
console.log(list);
return list
}else{
return list
}
},
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { onHide: function () {
let that = this
clearInterval(that.data.timerOut);
this.setData({
list: [], //待付款列表
orderList: [],//订单列表
timeList: [],//倒计时
formatTime:[]
})
}, },
/** /**

16
pages/user/user.wxml

@ -12,7 +12,7 @@
<view>id:{{info.id}}</view> <view>id:{{info.id}}</view>
</view> </view>
</navigator> </navigator>
<view class="user-box" style="padding-bottom:0"> <view class="user-box" style="padding-bottom:20rpx">
<navigator url="order/list" catchtap="pagePoint" data-event="mine_order" class="user-box-top"> <navigator url="order/list" catchtap="pagePoint" data-event="mine_order" class="user-box-top">
<text>我的订单</text> <text>我的订单</text>
<view class="all-text">全部订单 <text class="iconfont icon-you"></text></view> <view class="all-text">全部订单 <text class="iconfont icon-you"></text></view>
@ -43,6 +43,20 @@
<view>退货/退款</view> <view>退货/退款</view>
</navigator> </navigator>
</view> </view>
<view class="pay" wx:if="{{list[0]}}" >
<swiper autoplay interval="{{3500}}" circular="true" class="swiper">
<swiper-item wx:for="{{list}}">
<view class="s-box" bindtap="gotoDetail" data-item="{{orderList[index]}}">
<image style="width:248rpx;height:168rpx" mode="aspectFill" src="{{item.product_img}}"></image>
<view class="box-r">
<view class="wpay">等待付款</view>
<view class="time">剩余时间: <text>{{formatTime[index]}}</text></view>
<navigator class="btn" url="/pages/order/pay/index?id={{orderList[index].order_id}}">去支付</navigator>
</view>
</view>
</swiper-item>
</swiper>
</view>
</view> </view>
<view class="user-box"> <view class="user-box">
<navigator url="cartlist/list" class="user-box-line" catchtap="pagePoint" data-event="mine_cart"> <navigator url="cartlist/list" class="user-box-line" catchtap="pagePoint" data-event="mine_cart">

59
pages/user/user.wxss

@ -43,9 +43,10 @@ page {
margin-bottom: 20rpx; margin-bottom: 20rpx;
background: white; background: white;
border-radius: 20rpx; border-radius: 20rpx;
padding: 0 20rpx; padding: 0rpx 20rpx;
font-size: 29rpx; font-size: 29rpx;
color: #333; color: #333;
} }
.user-box-top { .user-box-top {
display: flex; display: flex;
@ -87,4 +88,60 @@ page {
} }
.user-box .user-box-line:last-child { .user-box .user-box-line:last-child {
border-bottom: none; border-bottom: none;
}
.pay {
width: 648rpx;
height: 204rpx;
margin: 0 auto;
background: #F6F6F6;
padding: 18rpx;
box-sizing: border-box;
}
.s-box {
display: flex;
align-items: center;
width: 100%;
height: 100%;
overflow: hidden;
}
.btn {
width: 162rpx;
height: 56rpx;
background: #FB6E4D;
border-radius: 28rpx;
font-size: 32rpx;
font-family: PingFang SC;
font-weight: 400;
color: #FFFFFF;
line-height: 56rpx;
text-align: center;
margin-top: 10rpx;
float:right;
}
.swiper{
height: 100% !important;
}
.box-r{
margin-left: 30rpx;
width: 388rpx;
}
.wpay{
font-size: 32rpx;
font-family: PingFang SC;
font-weight: 400;
color: #333333;
}
.time{
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 400;
color: #666666;
margin-top: 10rpx;
} }
Loading…
Cancel
Save