Browse Source

组合产品

master
jiazhipeng 8 months ago
parent
commit
3416b87d42
  1. 51
      pages/info/roadInfo/index.js
  2. 36
      pages/info/roadInfo/index.wxml
  3. 152
      pages/info/roadInfo/index.wxss
  4. 74
      utils/util.js

51
pages/info/roadInfo/index.js

@ -23,7 +23,11 @@ Page({
showShareFlag: false, showShareFlag: false,
showQrCode: false, showQrCode: false,
wxqrcode: null, wxqrcode: null,
ZTPoint:'' ZTPoint:'',
skuIndex: 0,
skuFlag: false,
producNum: 1,
}, },
/** /**
@ -159,6 +163,15 @@ Page({
}, },
order: function () { order: function () {
// todo 判断组合产品
// if (this.data.info.is_compose == 1) {
// if (true) {
// // 打开规格弹窗
// this.setData({skuFlag: true})
// return
// }
commonApi.user_post('wx/get_user_keep', { commonApi.user_post('wx/get_user_keep', {
jumpurl: '/pages/info/roadInfo/index?id=' + this.data.id, jumpurl: '/pages/info/roadInfo/index?id=' + this.data.id,
title: this.data.info.title, title: this.data.info.title,
@ -196,6 +209,21 @@ Page({
}, },
// 组合产品获取购买的sku
getComposeSku () {
commonApi.user_post("product/get_sku_compose_list", {
sku_id: "190720"
}).then(res => {
if (res&&Array.isArray(res.data)&&res.data.length>0) {
res.data.forEach(v => {
v.sku.is_compose = 1
});
util.orderByShoppingCart(res.data,app)
}
})
},
pagePoint: function (e) { pagePoint: function (e) {
util.pagePoint(e) util.pagePoint(e)
}, },
@ -467,6 +495,27 @@ Page({
} }
}, },
setSimpleValue: function (e) {
let keyname = e.currentTarget.dataset.keyname
let val = e.currentTarget.dataset.val
let param = {}
param[keyname] = val
this.setData(param)
},
minus: function () {
if (this.data.producNum == 1) return;
this.setData({
producNum: this.data.producNum - 1
})
},
add: function () {
this.setData({
producNum: this.data.producNum + 1
})
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */

36
pages/info/roadInfo/index.wxml

@ -120,4 +120,38 @@
</view> </view>
</view> </view>
<code showModel="{{showQrCode}}" qrcode = "{{wxqrcode}}"> <code showModel="{{showQrCode}}" qrcode = "{{wxqrcode}}">
</code> </code>
<view class="mask" wx:if="{{skuFlag}}">
<view class="mask-bg" bindtap="setSimpleValue" data-keyname="skuFlag" data-value="{{false}}"></view>
<view class="mask-content">
<view class="iconfont icon-close" bindtap="setSimpleValue" data-keyname="skuFlag" data-value="{{false}}"></view>
<view class="sku-info-box">
<image id="skuImg" src="{{info.sku[skuIndex].headimg}}" mode="aspectFill"></image>
<view class="sku-info">
<view class="sku-price">{{info.sku[skuIndex].price/100}}
<!-- <view class="allowance" wx:if="{{allowance_data}}">
补贴价:¥{{ (1 - allowance_data.discount_rate / 100) * info.sku[skuIndex].price / 100 }}</view> -->
</view>
<view class="sku-name">已选择:{{info.sku[skuIndex].sku_name}}</view>
</view>
</view>
<view class="sku-names">
<view bindtap="setSimpleValue" data-keyname="skuIndex" data-value="{{index}}"
class="sku-name-item textOver{{index==skuIndex?' active':''}}"
wx:for="{{info.sku}}">{{item.sku_name}}</view>
</view>
<view class="number-box">
<text>数量</text>
<view class="iconfont icon-sami-select" bindtap="minus"></view>
<view class="number">{{producNum}}</view>
<view class="iconfont icon-add-select" bindtap="add"></view>
</view>
<view style="height:138rpx"></view>
<view class="btn-box">
<view class="mask-btn" bindtap="getComposeSku" wx:if="{{info.sku[skuIndex].flag=='on'}}">立即购买</view>
<view class="mask-btn disable" wx:else>该商品已下架</view>
</view>
</view>
</view>

152
pages/info/roadInfo/index.wxss

@ -441,4 +441,154 @@ page {
font-size: 31rpx; font-size: 31rpx;
font-weight: 500; font-weight: 500;
margin-top: 50rpx; margin-top: 50rpx;
} }
.sku-info-box {
margin: 50rpx 40rpx;
display: flex;
justify-content: space-between;
}
.sku-info-box image {
width: 218rpx;
height: 180rpx;
border-radius: 13rpx;
display: block;
margin-right: 40rpx;
flex-shrink: 0;
}
.sku-info {
flex: 1;
}
.sku-price {
font-size: 40rpx;
font-weight: 500;
color: #D62828;
margin: 20rpx 0;
display: flex;
justify-content: flex-start;
align-items: center;
}
.sku-price::before {
content: "¥";
font-weight: 400;
font-size: 27rpx;
vertical-align: baseline;
}
.sku-price view {
font-size: 24rpx;
color: #FFFFFF;
background-color: #D62828;
border-radius: 22rpx;
line-height: 44rpx;
margin-left: 7rpx;
padding: 0 20rpx;
}
.sku-name {
font-size: 27rpx;
color: #666666;
}
.sku-names {
display: flex;
font-size: 29rpx;
color: #333;
margin: 0 40rpx;
text-align: center;
flex-wrap: wrap;
margin-bottom: 20rpx;
justify-content: space-between;
}
.sku-name-item {
background: #EFEFEF;
border: 1rpx solid #EFEFEF;
/* width: 318rpx; */
line-height: 77rpx;
border-radius: 14rpx;
margin-bottom: 25rpx;
margin-right: 30rpx;
max-width: 100%;
padding: 0 15rpx;
min-width: 270rpx;
}
.sku-name-item:nth-child(2n) {
margin-right: 0;
}
.sku-name-item.active {
color: #0B898E;
border-color: #0B898E;
background: rgba(11, 137, 142, 0.1);
}
.number-box {
display: flex;
align-items: center;
border-top: 1rpx solid #ccc;
justify-content: space-between;
margin: 0 40rpx;
padding: 40rpx 0;
}
.number-box text {
flex: 1;
font-size: 29rpx;
color: #333;
}
.number-box view {
border: 1rpx solid #666;
border-radius: 7rpx;
text-align: center;
width: 67rpx;
line-height: 67rpx;
font-size: 33rpx;
color: #000;
}
.number-box view.disable {
border-color: #ccc;
color: #999;
}
.number-box view.number {
width: 94rpx;
margin: 0 15rpx;
}
.btn-box {
height: 138rpx;
background: #FFFFFF;
box-shadow: 0px 0px 16rpx 0px rgba(6, 0, 1, 0.1);
display: flex;
align-items: center;
justify-content: center;
position: fixed;
left: 0;
right: 0;
bottom: 0;
}
.mask-btn {
width: 670rpx;
line-height: 78rpx;
background: #D62828;
border-radius: 39rpx;
color: #fff;
text-align: center;
font-size: 33rpx;
font-weight: 500;
}
.mask-btn.disable {
background: #ccc;
}

74
utils/util.js

@ -561,6 +561,79 @@ const detailPagePoint = function (url, res) {
} }
// app 要传进来 util 获取不到
const orderByShoppingCart = function (listData, app) {
let productType,flag,isCar;
commonApi.user_post('wx/get_user_keep', {
jumpurl: '/pages/user/cartlist/list',
title: '购物车',
type: 'mini'
}).then(res => {
if (res.data.subscribe == 0) {
this.setData({
wxqrcode: res.data.qrcode,
showQrCode: true
})
} else {
app.globalData.couponInfo = null;
let list = listData, product = [], product1 = []
list.map(item => {
// item.product.type="post";
if (item.product.type == 'post') {
product.push({
product: item.product,
sku: item.sku,
productNum: item.num
})
} else {
product1.push(item)
app.globalData.list = product1
}
if (item.product.type.includes('post')) {
productType = 'post'
}
})
if (product.length == 0 && product1.length == 0) {
wx.showToast({
title: '请先选择产品',
icon: 'none'
})
return;
}
if (product.length > 0 && product1.length > 0) {
flag = "mix";
isCar = "multiple"
}
if (product1.length > 1) {
isCar = "multiple"
} else {
isCar = "single"
}
console.log(product1,'product1');
app.globalData.listName = null
if (product1.length>0) {
app.globalData.listName = 'car'
}
app.globalData.postProduct = product;
if (app.globalData.list) {
app.globalData.index = 0
app.globalData.product = app.globalData.list[app.globalData.index]
}
if (productType == 'post') {
wx.navigateTo({
url: '/pages/order/postOrder/index?from=cart&flag=' + flag,
})
} else {
wx.navigateTo({
url: '/subPackages/gwcOrder/index?isCar=' + isCar,
})
}
}
})
}
module.exports = { module.exports = {
formatTime: formatTime, formatTime: formatTime,
@ -586,4 +659,5 @@ module.exports = {
getGlobalPagePoint: getGlobalPagePoint, getGlobalPagePoint: getGlobalPagePoint,
clearGlobalPagePoint: clearGlobalPagePoint, clearGlobalPagePoint: clearGlobalPagePoint,
detailPagePoint: detailPagePoint, detailPagePoint: detailPagePoint,
orderByShoppingCart: orderByShoppingCart,
} }

Loading…
Cancel
Save