Browse Source

顺手购

master
chenkainan 3 months ago
parent
commit
8c539c15af
  1. 20
      pages/order/components/smoothlyOrder/index.js
  2. 16
      pages/order/components/smoothlyOrder/index.wxml
  3. 55
      pages/order/components/smoothlyOrder/index.wxss
  4. 65
      pages/order/postOrder/index.js
  5. 3
      pages/order/postOrder/index.json
  6. 14
      pages/order/postOrder/index.wxml
  7. 1
      pages/order/postOrder/index.wxss
  8. 81
      pages/order/roadOrder/index.js
  9. 3
      pages/order/roadOrder/index.json
  10. 13
      pages/order/roadOrder/index.wxml
  11. 1
      pages/order/roadOrder/index.wxss
  12. 18
      project.private.config.json

20
pages/order/components/smoothlyOrder/index.js

@ -23,7 +23,8 @@ Component({
sommthlyIndex: 0, sommthlyIndex: 0,
showAddressPopup: false, showAddressPopup: false,
showItem: null, showItem: null,
showSkuPopup: false showSkuPopup: false,
content: ''
}, },
lifetimes: { lifetimes: {
attached() { attached() {
@ -64,6 +65,20 @@ Component({
this.couponCom = this.selectAllComponents("#coupon")[0]; this.couponCom = this.selectAllComponents("#coupon")[0];
}, },
methods: { methods: {
// 查看规格信息
showSkuInfo(e) {
this.setData({
showItem: e.currentTarget.dataset.item,
showSkuPopup: true,
content: '<img src="https://static.ticket.sz-trip.com/uploads/20241115/19e939ccf37d7301d82eea2545887218.jpg" style="width: 100%;" /><img src="https://static.ticket.sz-trip.com/uploads/20241115/1d3674e6bdfd5474c7b275b80e9cf56e.jpg" alt="" /><img src="https://static.ticket.sz-trip.com/uploads/20241115/02ff69565931d68464c4f25e30cd78ca.jpg" alt="" /><img src="https://static.ticket.sz-trip.com/uploads/20241115/3c66960d9a403be441dc03afd6346cc1.jpg" alt="" /><img src="https://static.ticket.sz-trip.com/uploads/20241115/420a6830644e16d03e6523e468019579.jpg" alt="" /><img src="https://static.ticket.sz-trip.com/uploads/20241115/b92b9d61f47905292c780faf7cb78762.jpg" alt="" />'
})
console.log(this.data.showItem)
},
closePopup() {
this.setData({
showSkuPopup: false
})
},
// 是否有选中商品 // 是否有选中商品
hasSelectedGoods() { hasSelectedGoods() {
return this.data.smoothlyList.some(item => (item.buyNum || 0) > 0); return this.data.smoothlyList.some(item => (item.buyNum || 0) > 0);
@ -202,10 +217,11 @@ Component({
consignee_id: type == 'post' ? postId : (this.data.address ? this.data consignee_id: type == 'post' ? postId : (this.data.address ? this.data
.address.id : '') .address.id : '')
}).then(res => { }).then(res => {
if (res) { if (res.code == 1) {
// 更新对应商品的邮费 // 更新对应商品的邮费
const newList = [...smoothlyList] const newList = [...smoothlyList]
const idx = newList.findIndex(i => i.sku_id === item.sku_id) const idx = newList.findIndex(i => i.sku_id === item.sku_id)
console.log(res.data.price)
if (idx > -1) { if (idx > -1) {
newList[idx].postMoney = res.data.price newList[idx].postMoney = res.data.price
this.setData({ this.setData({

16
pages/order/components/smoothlyOrder/index.wxml

@ -1,4 +1,5 @@
<view class="container"> <wxs src="/utils/filter.wxs" module="tool" />
<view class="container" wx:if="{{smoothlyList.length > 0}}">
<view class="box"> <view class="box">
<view class="top-title flex-between"> <view class="top-title flex-between">
顺手带一件 顺手带一件
@ -38,7 +39,7 @@
</view> </view>
</view> </view>
<view class="product-item" wx:for="{{smoothlyList}}" wx:key="index" <view class="product-item" wx:for="{{smoothlyList}}" wx:key="index"
bindtap="showSkuInfo" data-item="{{item}}" wx:if="{{sommthlyIndex == index}}"> bindtap="showSkuInfo" data-item="{{item}}" wx:if="{{sommthlyIndex == index}}">
<image src="{{item.headimg}}" class="product-img" mode="aspectFill"></image> <image src="{{item.headimg}}" class="product-img" mode="aspectFill"></image>
<view class="product-content"> <view class="product-content">
@ -67,12 +68,13 @@
<address bind:setAddress="setAddress" showSelect="{{false}}" id="addressComp"></address> <address bind:setAddress="setAddress" showSelect="{{false}}" id="addressComp"></address>
<!-- <van-popup show="{{showSkuPopup}}" position="bottom" round closeable style="width: 100%;height: 80%;" bind:close="onSkuPopupClose"> <view wx:if="{{showSkuPopup}}" class="sku-box">
<view class="sku-popup" wx:if="{{showItem}}"> <view class="sku-popup" wx:if="{{showItem}}">
<view class="sku-name">产品详情</view> <view class="sku-name"><span></span> 产品详情 <span bindtap="closePopup">X</span></view>
<view class="sku-content" bindtap="onSkuContentTap"> <view class="sku-content">
<rich-text nodes="{{formateRichText(showItem.content)}}"></rich-text> <rich-text nodes="{{tool.formateRichText(content)}}"></rich-text>
<!-- tool.formateRichText(showItem.content) -->
</view> </view>
</view> </view>
</van-popup> --> </view>
</view> </view>

55
pages/order/components/smoothlyOrder/index.wxss

@ -112,7 +112,7 @@
} }
.address-boxs .content .right .bottom { .address-boxs .content .right .bottom {
margin-top: 6.67rpx margin-top: 6.67rpx;
font-weight: 500; font-weight: 500;
font-size: 24rpx; font-size: 24rpx;
color: #666666; color: #666666;
@ -198,4 +198,57 @@
.product-item .product-content .product-btn image { .product-item .product-content .product-btn image {
width: 46.67rpx; width: 46.67rpx;
flex-shrink: 0; flex-shrink: 0;
}
.sku-box {
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.3);
position: fixed;
z-index: 99;
left: 0;
bottom: 0;
}
.sku-popup {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
height: 60vh;
background-color: #fff;
padding: 20rpx;
box-sizing: border-box;
overflow-x: hidden;
}
.sku-name {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 35rpx;
font-weight: bold;
height: 80rpx;
padding: 0 20rpx;
box-sizing: border-box;
}
.sku-name span {
font-weight: 400;
}
.sku-content {
width: 100%;
height: 50vh;
overflow-y: auto;
overflow-x: hidden;
max-width: 100%;
}
.sz-xcx-fwb-img {
width: 100% !important;
height: auto !important;
display: block !important;
margin: 0 auto !important;
object-fit: contain !important;
max-width: 100% !important;
} }

65
pages/order/postOrder/index.js

@ -29,12 +29,16 @@ Page({
showYhq:null, showYhq:null,
pickupIndex: null, pickupIndex: null,
smoothlyTotal: 0,
maxCouponObject: null
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
console.log(this.data.product)
this.setData({ this.setData({
from: options.from, from: options.from,
kjId: app.globalData.kjId, kjId: app.globalData.kjId,
@ -45,8 +49,21 @@ Page({
showYhq:app.globalData.listName?false:true showYhq:app.globalData.listName?false:true
}) })
this.handleProduct() this.handleProduct()
console.log(this.data.product)
},
// 子组件发生改变时更新价格
handleUpdateTotalPrice(e) {
this.setData({
smoothlyTotal: e.detail.total
});
// 重新计算总价
this.changePrice();
},
// 调用子组件清除优惠券方法
callOtherCompMethod: function(e) {
this.couponCom.setNullCoupon()
}, },
handleProduct () { handleProduct () {
app.globalData.postProduct.forEach((item,index) => { app.globalData.postProduct.forEach((item,index) => {
item.keyIndex = index item.keyIndex = index
@ -218,7 +235,12 @@ Page({
this.changePrice() this.changePrice()
}, },
changePrice: function () { changePrice: function () {
let product = this.data.product, price = 0; let product = this.data.product, price = 0, allPrice = 0;
// 顺手购价格
price += this.data.smoothlyTotal || 0;
allPrice = price
product.map(item => { product.map(item => {
price = price + item.sku.price * item.productNum; price = price + item.sku.price * item.productNum;
if (this.data.allowance_data && this.data.select_allowance && this.data.allowance_price) { if (this.data.allowance_data && this.data.select_allowance && this.data.allowance_price) {
@ -242,8 +264,38 @@ Page({
this.setData({ this.setData({
showPrice: app.globalData.kjId ? 0 : price showPrice: app.globalData.kjId ? 0 : price
}) })
const smoothlyComp = this.selectComponent("#smoothlyOrderComp");
const skuIds = []
skuIds.push(this.data.sku_id)
if(smoothlyComp) {
// 检查是否有选中的顺手购商品
const hasSkuIds = smoothlyComp.hasSelectedGoods();
if(hasSkuIds) {
skuIds.push(...smoothlyComp.emitSkuIds())
}
}
this.setData({
maxCouponObject: {
price: allPrice,
skuIds: skuIds.toString()
}
})
}, },
order: function () { order: function () {
// 顺手带一件是否选择收货地址
const smoothlyComp = this.selectComponent("#smoothlyOrderComp");
if(smoothlyComp && this.data.product[0].user_select_type == 1) {
// 检查是否有选中的顺手购商品
const hasSelected = smoothlyComp.hasSelectedGoods();
if(hasSelected && !smoothlyComp.data.address) {
wx.showToast({
title: '请选择收货地址',
icon: 'none'
})
return;
}
}
for(let info of this.data.product) { for(let info of this.data.product) {
if (info.user_select_type == 0) { if (info.user_select_type == 0) {
@ -327,6 +379,12 @@ Page({
gp_id: app.globalData.gp_id, gp_id: app.globalData.gp_id,
team_id: app.globalData.team_id team_id: app.globalData.team_id
}; };
// 顺手购下单参数
if(smoothlyComp && smoothlyComp.emitOrder() && smoothlyComp.emitOrder().length) {
product_list.push(...smoothlyComp.emitOrder())
}
if (this.data.select_allowance) data.is_allowance = 1 if (this.data.select_allowance) data.is_allowance = 1
if (app.globalData.from) { if (app.globalData.from) {
data.system_name = app.globalData.from; data.system_name = app.globalData.from;
@ -348,10 +406,11 @@ Page({
data.channel = ZTPointProduct.product.ZTPoint data.channel = ZTPointProduct.product.ZTPoint
} }
console.log(app.globalData.list,this.data.flag) console.log(app.globalData.list,this.data.flag)
if(!app.globalData.list || app.globalData.list.length == 0){ if(!app.globalData.list || app.globalData.list.length == 0){
// 判断混合下单 // 判断混合下单
let use_type = product_list[0].use_type let use_type = product_list[0].use_type
if (product_list.some(x=>x.use_type!=use_type)) { if (product_list.some(x=>x.use_type!=use_type) && !(smoothlyComp && smoothlyComp.emitOrder() && smoothlyComp.emitOrder().length)) {
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
wx.redirectTo({ wx.redirectTo({

3
pages/order/postOrder/index.json

@ -2,6 +2,7 @@
"usingComponents": { "usingComponents": {
"title":"/pages/component/TitleHeader", "title":"/pages/component/TitleHeader",
"address":"../components/address/index", "address":"../components/address/index",
"coupon":"../components/coupon/index" "coupon":"../components/coupon/index",
"smoothly-order": "/pages/order/components/smoothlyOrder/index"
} }
} }

14
pages/order/postOrder/index.wxml

@ -114,7 +114,19 @@
</view> </view>
</view> </view>
</view> </view>
<coupon bind:getNewCoupon = 'getNewCoupon' id="coupon" wx:if="{{!kjId && !gp_id && flag!='mix' && showYhq}}" money="{{showPrice + postFee}}" sku="{{sku_id}}"></coupon> <coupon bind:getNewCoupon = 'getNewCoupon' id="coupon" wx:if="{{!kjId && !gp_id && flag!='mix' && showYhq}}" money="{{showPrice + postFee}}" sku="{{sku_id}}" maxCouponObject="{{maxCouponObject}}"></coupon>
<!-- 顺手购组件 -->
<smoothly-order
wx:if="{{product.length > 0 && flag!='mix' && showYhq}}"
id="smoothlyOrderComp"
productId="{{product[0].product.id}}"
bind:callOtherComp="callOtherCompMethod"
bind:updateTotalPrice="handleUpdateTotalPrice"
type="{{product[0].user_select_type == 0 ? 'post' : ''}}"
postId="{{address.id}}"
></smoothly-order>
<view style="height:113rpx"></view> <view style="height:113rpx"></view>
<view class="fixed-bottom" wx:if="{{product}}"> <view class="fixed-bottom" wx:if="{{product}}">
<view class="fixed-price-box" wx:if="{{!prizeId}}"> <view class="fixed-price-box" wx:if="{{!prizeId}}">

1
pages/order/postOrder/index.wxss

@ -1,6 +1,7 @@
/* pages/order/post/index.wxss */ /* pages/order/post/index.wxss */
page { page {
background: #f6f6f6; background: #f6f6f6;
padding-bottom: 150rpx;
} }
.sendwayArea{ .sendwayArea{

81
pages/order/roadOrder/index.js

@ -22,13 +22,16 @@ Page({
price:0, price:0,
coupon:app.globalData.couponInfo, coupon:app.globalData.couponInfo,
sku_ids:"", sku_ids:"",
prizeId:null prizeId:null,
smoothlyTotal: 0,
maxCouponObject: null
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.couponCom = this.selectAllComponents("#coupon")[0];
this.setData({ this.setData({
prizeId:wx.getStorageSync('prizeId') prizeId:wx.getStorageSync('prizeId')
}) })
@ -54,8 +57,62 @@ Page({
console.log(this.data) console.log(this.data)
// 获取默认联系人 // 获取默认联系人
this.getLinkmanList() this.getLinkmanList()
// this.showAllPrice()
},
// 子组件发生改变时更新价格
handleUpdateTotalPrice(e) {
this.setData({
smoothlyTotal: e.detail.total
});
// 重新计算总价
this.showAllPrice();
},
// 调用子组件清除优惠券方法
callOtherCompMethod: function(e) {
this.couponCom.setNullCoupon()
},
showAllPrice() {
let price = app.globalData.product.price
let allPrice = 0
// 顺手购价格
price += this.data.smoothlyTotal || 0;
allPrice = price
if (this.data.coupon) {
if (this.data.coupon.activity.discount_type == 'pricebreak') {
price = price - this.data.coupon.activity.money
} else {
price =(price * this.data.coupon.activity.fold)/ 10
}
} else {
price = price
}
if (price >0) {
this.setData({ price:price/100})
}else {
this.setData({ price:0 })
}
const smoothlyComp = this.selectComponent("#smoothlyOrderComp");
const skuIds = []
skuIds.push(this.data.sku_ids)
console.log(skuIds)
if(smoothlyComp) {
// 检查是否有选中的顺手购商品
const hasSkuIds = smoothlyComp.hasSelectedGoods();
if(hasSkuIds) {
skuIds.push(...smoothlyComp.emitSkuIds())
}
}
this.setData({
maxCouponObject: {
price: allPrice,
skuIds: skuIds.toString()
}
})
console.log(this.data.maxCouponObject)
}, },
showLinkman:function(e){ showLinkman:function(e){
if(!this.data.linkmanFlag) { if(!this.data.linkmanFlag) {
let skuIndex = e.currentTarget.dataset.index,linkmans = this.data.linkmans[skuIndex],linkmanList = this.data.linkmanList; let skuIndex = e.currentTarget.dataset.index,linkmans = this.data.linkmans[skuIndex],linkmanList = this.data.linkmanList;
@ -200,6 +257,19 @@ Page({
}) })
}, },
order:function(){ order:function(){
const smoothlyComp = this.selectComponent("#smoothlyOrderComp");
if(smoothlyComp) {
// 检查是否有选中的顺手购商品
const hasSelected = smoothlyComp.hasSelectedGoods();
if(hasSelected && !smoothlyComp.data.address) {
wx.showToast({
title: '请选择收货地址',
icon: 'none'
})
return;
}
}
let sku = this.data.sku,product = this.data.product,linkmans = this.data.linkmans,product_list = [],reserve_mobile = this.data.reserve_mobile; let sku = this.data.sku,product = this.data.product,linkmans = this.data.linkmans,product_list = [],reserve_mobile = this.data.reserve_mobile;
if(!reserve_mobile) { if(!reserve_mobile) {
wx.showToast({ wx.showToast({
@ -246,6 +316,12 @@ Page({
if(orderFlag==false){ if(orderFlag==false){
return; return;
} }
// 顺手购下单参数
if(smoothlyComp && smoothlyComp.emitOrder() && smoothlyComp.emitOrder().length) {
product_list.push(...smoothlyComp.emitOrder())
}
let data = { let data = {
product_list:product_list, product_list:product_list,
coupon_id:this.data.coupon?this.data.coupon.id:null, coupon_id:this.data.coupon?this.data.coupon.id:null,
@ -281,6 +357,7 @@ Page({
this.setData({ this.setData({
coupon:e.detail coupon:e.detail
}) })
this.showAllPrice()
}, },
// 一日游合同确认签字 // 一日游合同确认签字
// ondayConfirm:function(){ // ondayConfirm:function(){

3
pages/order/roadOrder/index.json

@ -1,6 +1,7 @@
{ {
"usingComponents": { "usingComponents": {
"title":"/pages/component/TitleHeader", "title":"/pages/component/TitleHeader",
"coupon":"/pages/order/components/coupon/index" "coupon":"/pages/order/components/coupon/index",
"smoothly-order": "/pages/order/components/smoothlyOrder/index"
} }
} }

13
pages/order/roadOrder/index.wxml

@ -29,7 +29,16 @@
<input type="text" bindinput="inputRemark" placeholder="选填"></input> <input type="text" bindinput="inputRemark" placeholder="选填"></input>
</view> </view>
</view> </view>
<coupon bind:getNewCoupon = 'getNewCoupon' money="{{price}}" sku="{{sku_ids}}"></coupon> <coupon id="coupon" bind:getNewCoupon = 'getNewCoupon' money="{{price}}" sku="{{sku_ids}}" maxCouponObject="{{maxCouponObject}}"></coupon>
<!-- 顺手购组件 -->
<smoothly-order
wx:if="{{product.id}}"
id="smoothlyOrderComp"
productId="{{product.id}}"
bind:callOtherComp="callOtherCompMethod"
bind:updateTotalPrice="handleUpdateTotalPrice"
></smoothly-order>
<!-- <view class="user-box"> <!-- <view class="user-box">
<view class="user-item" style="border:none"> <view class="user-item" style="border:none">
<image lazy-load style="width:32rpx" src="https://static.ticket.sz-trip.com/xcxImages/other/hetong.png" mode="widthFix"></image> <image lazy-load style="width:32rpx" src="https://static.ticket.sz-trip.com/xcxImages/other/hetong.png" mode="widthFix"></image>
@ -40,7 +49,7 @@
<view style="height:113rpx"></view> <view style="height:113rpx"></view>
<view class="fixed-bottom"> <view class="fixed-bottom">
<view class="order-all-price" wx:if="{{prizeId}}">订单金额:<text>¥0</text></view> <view class="order-all-price" wx:if="{{prizeId}}">订单金额:<text>¥0</text></view>
<view class="order-all-price" wx:else>订单金额:<text>¥{{((price - (coupon?coupon.activity.money:0))>0?(price - (coupon?coupon.activity.money:0)):0)/100}}</text></view> <view class="order-all-price" wx:else>订单金额:<text>¥{{price}}</text></view>
<view class="order-btn" bindtap="order">去支付</view> <view class="order-btn" bindtap="order">去支付</view>
</view> </view>
<view class="mask" style="align-items:flex-end" wx:if="{{linkmanFlag}}"> <view class="mask" style="align-items:flex-end" wx:if="{{linkmanFlag}}">

1
pages/order/roadOrder/index.wxss

@ -1,6 +1,7 @@
/* pages/order/roadOrder/index.wxss */ /* pages/order/roadOrder/index.wxss */
page { page {
background: #f6f6f6; background: #f6f6f6;
padding-bottom: 150rpx;
} }
.top-box { .top-box {
padding: 30rpx 47rpx; padding: 30rpx 47rpx;

18
project.private.config.json

@ -6,12 +6,26 @@
"condition": { "condition": {
"miniprogram": { "miniprogram": {
"list": [ "list": [
{
"name": "pages/info/postProductInfo/index",
"pathName": "pages/info/postProductInfo/index",
"query": "id=464888",
"scene": null,
"launchMode": "default"
},
{
"name": "pages/info/roadInfo/index",
"pathName": "pages/info/roadInfo/index",
"query": "id=463608",
"launchMode": "default",
"scene": null
},
{ {
"name": "pages/info/showInfo/index", "name": "pages/info/showInfo/index",
"pathName": "pages/info/showInfo/index", "pathName": "pages/info/showInfo/index",
"query": "id=465394", "query": "id=465394",
"scene": null, "launchMode": "default",
"launchMode": "default" "scene": null
}, },
{ {
"name": "pages/info/postProductInfo/index", "name": "pages/info/postProductInfo/index",

Loading…
Cancel
Save