Browse Source

提交

master
chenkainan 3 months ago
parent
commit
22a5b96510
  1. 74
      pages/order/WineSceneOrder/index.js
  2. 3
      pages/order/WineSceneOrder/index.json
  3. 13
      pages/order/WineSceneOrder/index.wxml
  4. 1
      pages/order/WineSceneOrder/index.wxss
  5. 5
      pages/order/components/address/index.js
  6. 2
      pages/order/components/address/index.wxml
  7. 29
      pages/order/components/coupon/index.js
  8. 8
      pages/order/components/coupon/index.wxml
  9. 18
      pages/order/components/coupon/index.wxss
  10. 291
      pages/order/components/smoothlyOrder/index.js
  11. 6
      pages/order/components/smoothlyOrder/index.json
  12. 78
      pages/order/components/smoothlyOrder/index.wxml
  13. 201
      pages/order/components/smoothlyOrder/index.wxss
  14. 64
      pages/order/food/index.js
  15. 3
      pages/order/food/index.json
  16. 12
      pages/order/food/index.wxml
  17. 66
      pages/order/showOrderNew/index.js
  18. 3
      pages/order/showOrderNew/index.json
  19. 11
      pages/order/showOrderNew/index.wxml
  20. 1
      pages/order/showOrderNew/index.wxss
  21. 27
      project.private.config.json

74
pages/order/WineSceneOrder/index.js

@ -42,7 +42,10 @@ Page({
showDate:false,
showDate2:false,
showYhq:null,
couponFlag:false
couponFlag:false,
smoothlyTotal: 0,
maxCouponObject: null
},
/**
@ -77,7 +80,8 @@ Page({
}
this.setData({singlePrice: this.data.product.sku.price})
this.showAllPrice()
// this.showAllPrice()
this.totalPrice(this.data.singlePrice)
console.log(this.data);
console.log(this.data.product.product.ZTPoint)
@ -86,7 +90,18 @@ Page({
},
// 子组件发生改变时更新价格
handleUpdateTotalPrice(e) {
this.setData({
smoothlyTotal: e.detail.total
});
// 重新计算总价
this.totalPrice(this.data.singlePrice)
},
// 调用子组件清除优惠券方法
callOtherCompMethod: function(e) {
this.couponCom.setNullCoupon()
},
showBookingInfo: function (e) {
this.setData({
bookingInfo: this.data.product.sku.sku_model,
@ -230,15 +245,21 @@ Page({
this.totalPrice(this.data.singlePrice)
},
totalPrice(price) {
let allPrice
let allPrice = this.data.singlePrice * this.data.productNum
let prices = 0
console.log(this.data.smoothlyTotal,111111)
// 顺手购价格
allPrice += this.data.smoothlyTotal || 0;
prices = allPrice
if (this.data.coupon) {
if (this.data.coupon.activity.discount_type == 'pricebreak') {
allPrice = this.data.singlePrice * this.data.productNum - this.data.coupon.activity.money
allPrice = allPrice - this.data.coupon.activity.money
} else {
allPrice =(this.data.singlePrice * this.data.productNum * this.data.coupon.activity.fold)/ 10
allPrice =(allPrice * this.data.coupon.activity.fold)/ 10
}
} else {
allPrice = this.data.singlePrice * this.data.productNum
allPrice = allPrice
}
// allPrice = price * this.data.productNum - (this.data.coupon?this.data.coupon.activity.money:0)
@ -254,10 +275,40 @@ Page({
})
}
console.log('singlePrice',this.data.singlePrice);
const smoothlyComp = this.selectComponent("#smoothlyOrderComp");
const skuIds = []
skuIds.push(this.data.product.sku.id)
if(smoothlyComp) {
// 检查是否有选中的顺手购商品
const hasSkuIds = smoothlyComp.hasSelectedGoods();
if(hasSkuIds) {
skuIds.push(...smoothlyComp.emitSkuIds())
}
}
this.setData({
maxCouponObject: {
price: prices,
skuIds: skuIds.toString()
}
})
},
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 linkmanList = this.data.linkmanList, productNum = this.data.productNum, date = this.data.date, time = this.data.time, remark = this.data.remark, product = this.data.product;
let linkmanIds = [];
@ -282,6 +333,12 @@ Page({
team_id: app.globalData.team_id,
}
// 顺手购下单参数
if(smoothlyComp && smoothlyComp.emitOrder() && smoothlyComp.emitOrder().length) {
data.product_list.push(...smoothlyComp.emitOrder())
}
if (app.globalData.from) {
data.system_name = app.globalData.from;
}
@ -383,7 +440,8 @@ Page({
this.setData({
coupon:e.detail
})
this.showAllPrice()
// this.showAllPrice()
this.totalPrice(this.data.singlePrice)
},
/**

3
pages/order/WineSceneOrder/index.json

@ -3,6 +3,7 @@
"title":"/pages/component/TitleHeader",
"contact":"../components/contact/index",
"coupon":"../components/coupon/index",
"notice":"/pages/component/notice/notice"
"notice":"/pages/component/notice/notice",
"smoothly-order": "/pages/order/components/smoothlyOrder/index"
}
}

13
pages/order/WineSceneOrder/index.wxml

@ -38,9 +38,16 @@
<coupon bind:getNewCoupon = 'getNewCoupon' wx:if="{{!kjId && !gp_id && type!='activity' && product && product.isGroup!=1 && isCar=='single' && type!='museum' && showYhq}}" id="coupon"
money="{{singlePrice * productNum}}" sku="{{product.sku.id}}" couponFlag="{{couponFlag}}"></coupon>
money="{{singlePrice * productNum}}" sku="{{product.sku.id}}" couponFlag="{{couponFlag}}" maxCouponObject="{{maxCouponObject}}"></coupon>
<!-- 顺手购组件 -->
<smoothly-order
wx:if="{{product.product.id}}"
id="smoothlyOrderComp"
productId="{{product.product.id}}"
bind:callOtherComp="callOtherCompMethod"
bind:updateTotalPrice="handleUpdateTotalPrice"
></smoothly-order>
<view class="fixed-bottom" >
<view class="fixed-price-box" ><text>合计:</text>

1
pages/order/WineSceneOrder/index.wxss

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

5
pages/order/components/address/index.js

@ -11,7 +11,10 @@ Component({
addGlobalClass: true
},
properties: {
showSelect: {
type: Boolean,
value: true
},
},
/**

2
pages/order/components/address/index.wxml

@ -1,4 +1,4 @@
<view class="address-box">
<view class="address-box" wx:if="{{showSelect}}">
<view class="box-title">
<view style="flex:1">收货地址</view>
<view class="contact-add" bindtap="showLinkman" wx:if="{{selectLinkman}}"><text class="iconfont icon-add-select"></text>选择</view>

29
pages/order/components/coupon/index.js

@ -26,6 +26,14 @@ Component({
})
}
}
},
maxCouponObject: {
type: Object,
value: null,
observer(nv, ov) {
console.log(111, nv, ov)
this.getMaxPrice()
}
}
},
@ -33,7 +41,8 @@ Component({
* 组件的初始数据
*/
data: {
coupon:null
coupon: null,
maxCouponPrice: 0
},
pageLifetimes: {
show: function() {
@ -41,14 +50,14 @@ Component({
}
},
lifetimes: {
attached(){
},
attached() {},
},
/**
* 组件的方法列表
*/
methods: {
setNullCoupon: function() {
console.log(44154)
app.globalData.couponInfo = null
this.setData({
coupon: null
@ -67,7 +76,8 @@ Component({
money: this.data.money,
sku_ids: this.data.sku
}).then(res => {
if (app.globalData.couponInfo&&app.globalData.couponInfo.hasOwnProperty('SubCoupon')) {
if (app.globalData.couponInfo && app.globalData.couponInfo.hasOwnProperty(
'SubCoupon')) {
this.setData({
coupon: app.globalData.couponInfo
})
@ -87,7 +97,16 @@ Component({
}
})
}
},
getMaxPrice() {
commonApi.user_post('coupon/use_max_coupon_list', {
money: this.data.maxCouponObject.price,
sku_ids: this.data.maxCouponObject.skuIds
}).then(res => {
this.setData({
maxCouponPrice: res.data.activity.money
})
})
}
},

8
pages/order/components/coupon/index.wxml

@ -2,14 +2,18 @@
<navigator url="/pages/order/coupon/index?money={{money}}&sku={{sku}}&sourceFrom={{sourceFrom}}" class="box">
<view class="box-title">
<view style="flex:1">优惠券</view>
<view class="coupon-left" wx:if="{{maxCouponPrice > 0 && maxCouponPrice != coupon.activity.money}}">
¥{{maxCouponPrice / 100}}优惠券可用
</view>
<view wx:if="{{coupon}}">
<view wx:if="{{coupon.activity.discount_type == 'pricebreak'}}">
-{{coupon.activity.money/100}}
-{{coupon.activity.money/100}}
</view>
<view wx:else>
{{coupon.activity.fold}}折
</view>
</view>
<view class="coupon-btn" wx:else>请选择</view>
<!-- <view class="coupon-btn" wx:else>请选择</view> -->
<view class="coupon-btn">></view>
</view>
</navigator>

18
pages/order/components/coupon/index.wxss

@ -8,17 +8,27 @@
height: 113rpx;
margin: 0 20rpx;
font-size: 31rpx;
color: #000;
color: #E30000;
font-weight: 500;
display: flex;
align-items: center;
}
.coupon-btn {
width: 138rpx;
width: 50rpx;
line-height: 56rpx;
border: 1px solid #333333;
/* border: 1px solid #333333; */
border-radius: 29rpx;
text-align: center;
font-size: 28rpx;
color: #000;
color: #333333;
}
.coupon-left {
line-height: 40rpx;
background: #FFDEDE;
border-radius: 13rpx;
padding: 0 18rpx;
font-weight: 500;
font-size: 24rpx;
color: #E30000;
margin-right: 20rpx;
}

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

@ -0,0 +1,291 @@
import commonApi from "../../../../utils/https/common"
let app = getApp()
Component({
properties: {
productId: {
type: [String, Number],
value: ''
},
postId: {
type: [String, Number],
value: ''
},
type: {
type: String,
value: ''
}
},
data: {
addressList: [],
addressIndex: -1,
address: null,
smoothlyList: [],
sommthlyIndex: 0,
showAddressPopup: false,
showItem: null,
showSkuPopup: false
},
lifetimes: {
attached() {
this.setData({
sommthlyIndex: 0
})
this.getList()
}
},
observers: {
'type': function(newVal, oldVal) {
// 当从邮寄切换到自提时
if (oldVal === 'post' && newVal !== 'post') {
// 重置所有商品邮费
const smoothlyList = this.data.smoothlyList.map(item => ({
...item,
postMoney: 0
}))
this.setData({
smoothlyList,
addressIndex: -1
})
// 重新计算总价
this.calculateTotalPrice()
} else if (newVal === 'post') {
// 切换到邮寄时重新计算邮费
this.showPostMoney()
}
},
'postId': function(newVal, oldVal) {
// 只有当当前是邮寄类型时,才重新计算邮费
if (this.data.type === 'post' && newVal !== oldVal) {
this.showPostMoney()
}
}
},
onload() {
this.couponCom = this.selectAllComponents("#coupon")[0];
},
methods: {
// 是否有选中商品
hasSelectedGoods() {
return this.data.smoothlyList.some(item => (item.buyNum || 0) > 0);
},
// 规格id
emitSkuIds() {
let skuIds = []
this.data.smoothlyList.forEach(item => {
if (item.buyNum > 0) {
skuIds.push(item.sku_id)
}
});
return skuIds;
},
// 下单参数
emitOrder() {
let orderList = []
this.data.smoothlyList.forEach(item => {
if (item.buyNum > 0) {
orderList.push({
type: item.type,
product_id: item.id,
sku_id: item.sku_id,
post: this.data.type == 'post' ? this.data.postId : (this.data.address ?
this.data
.address.id : ''),
product_num: item.buyNum,
use_type: 0,
is_batch_shipment: 0,
})
}
})
return orderList
},
switchSmoothlyList() {
const {
smoothlyList,
sommthlyIndex
} = this.data
// 重置当前商品数量
smoothlyList[sommthlyIndex].buyNum = 0
// 更新索引
const newIndex = sommthlyIndex < smoothlyList.length - 1 ? sommthlyIndex + 1 : 0
this.setData({
smoothlyList,
sommthlyIndex: newIndex
})
this.showPostMoney().then(() => {
this.calculateTotalPrice()
})
},
setNullCoupons() {
if (app.globalData.couponInfo != null) {
wx.showToast({
title: '订单价格发生变化,请重新选择优惠券',
icon: 'none'
})
this.triggerEvent('callOtherComp', {
methodName: 'setNullCoupon', // 要调用的子组件B的方法名
});
}
},
setAddress(e) {
console.log(e.detail);
this.setData({
address: e.detail
})
this.showPostMoney().then(() => {
this.calculateTotalPrice()
})
},
showAddress() {
const childComp = this.selectComponent('#addressComp');
if (!childComp) {
wx.showToast({
title: '组件未加载完成',
icon: 'none'
});
return;
}
childComp.showLinkman()
},
showImg(img) {
if (!img) {
return img
}
if (img.indexOf('https://') != -1 || img.indexOf('http://') != -1) {
return img;
} else {
// return "https://test.api.cloud.sz-trip.com"+img
return "https://static.ticket.sz-trip.com" + img;
}
},
getList() {
commonApi.user_post('product/get_convenient_purchase', {
page: 1,
limit: 100,
product_id: this.data.productId
}).then(res => {
if (res.data) {
const smoothlyList = res.data.map(i => ({
...i,
headimg: this.showImg(i.headimg),
buyNum: 0,
postMoney: 0
}));
this.setData({
smoothlyList
});
}
})
},
showPostMoney() {
const {
type,
postId,
addressList,
addressIndex,
smoothlyList
} = this.data
if (type == 'post') {
if (!postId) return Promise.resolve()
} else {
if (!this.data.address) return Promise.resolve()
}
const promises = smoothlyList.map(item => {
if (item.buyNum > 0) {
return commonApi.user_post("order/get_post_price", {
sku_id: item.sku_id,
num: item.buyNum,
consignee_id: type == 'post' ? postId : (this.data.address ? this.data
.address.id : '')
}).then(res => {
if (res) {
// 更新对应商品的邮费
const newList = [...smoothlyList]
const idx = newList.findIndex(i => i.sku_id === item.sku_id)
if (idx > -1) {
newList[idx].postMoney = res.data.price
this.setData({
smoothlyList: newList
})
}
}
})
}
return Promise.resolve()
})
return Promise.all(promises)
},
decreaseSkuNum(e) {
const item = e.currentTarget.dataset.item
const {
smoothlyList
} = this.data
if (item.buyNum > 0) {
// 找到对应商品并更新数量
const newList = smoothlyList.map(i => {
if (i.sku_id === item.sku_id) {
return {
...i,
buyNum: i.buyNum - 1
}
}
return i
})
this.setData({
smoothlyList: newList
})
this.setNullCoupons()
this.showPostMoney().then(() => {
this.calculateTotalPrice()
})
}
},
increaseSkuNum(e) {
const item = e.currentTarget.dataset.item
const {
smoothlyList
} = this.data
// 找到对应商品并更新数量
const newList = smoothlyList.map(i => {
if (i.sku_id === item.sku_id) {
return {
...i,
buyNum: i.buyNum + 1
}
}
return i
})
this.setData({
smoothlyList: newList
})
this.showPostMoney().then(() => {
this.calculateTotalPrice()
})
},
// 计算总价
calculateTotalPrice() {
let total = 0;
this.data.smoothlyList.forEach(item => {
if (item.buyNum > 0) {
const itemPrice = parseFloat(item.price) * item.buyNum;
total += itemPrice + item.postMoney;
}
});
this.triggerEvent('updateTotalPrice', {
total
});
return total;
},
}
})

6
pages/order/components/smoothlyOrder/index.json

@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"address":"../../components/address/index"
}
}

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

@ -0,0 +1,78 @@
<view class="container">
<view class="box">
<view class="top-title flex-between">
顺手带一件
<view bindtap="switchSmoothlyList" class="refresh-btn">
<image src="https://static.ticket.sz-trip.com/jundaosuzhou/images/smoothlyOrder/refresh.png" mode="widthFix"></image>
换一换
</view>
</view>
<!-- 邮寄不显示收货地址 -->
<view wx:if="{{type !== 'post'}}">
<view class="address-box flex-between" wx:if="{{!address}}" bindtap="showAddress">
<view style="display: flex;align-items: center;">
<image src="https://static.ticket.sz-trip.com/jundaosuzhou/images/smoothlyOrder/location.png"
class="location" mode="widthFix"></image>
收货地址 点击填写收货地址
</view>
<image src="https://static.ticket.sz-trip.com/jundaosuzhou/images/smoothlyOrder/rightIcon.png"
class="rightIcon" mode="widthFix"></image>
</view>
<view class="address-boxs flex-between" bindtap="showAddress" wx:else>
<image src="https://static.ticket.sz-trip.com/jundaosuzhou/images/smoothlyOrder/location.png"
class="location" mode="widthFix"></image>
<view class="content">
<view class="left">收货地址</view>
<view class="right">
<view class="top">
{{address.name}}<text>{{address.tel}}</text>
</view>
<view class="bottom text-overflowRows">
{{address.address}}
</view>
</view>
</view>
<image src="https://static.ticket.sz-trip.com/jundaosuzhou/images/smoothlyOrder/rightIcon.png"
class="rightIcon" mode="widthFix"></image>
</view>
</view>
<view class="product-item" wx:for="{{smoothlyList}}" wx:key="index"
bindtap="showSkuInfo" data-item="{{item}}" wx:if="{{sommthlyIndex == index}}">
<image src="{{item.headimg}}" class="product-img" mode="aspectFill"></image>
<view class="product-content">
<view class="title-boxs flex-between">
<view class="title">{{item.title}}</view>
<image src="https://static.ticket.sz-trip.com/jundaosuzhou/images/smoothlyOrder/right.png" mode="widthFix"></image>
</view>
<view class="subtitle" wx:if="{{item.sku_name}}">{{item.sku_name}}</view>
<view class="flex-between">
<view class="price">{{item.price / 100}}<text
wx:if="{{item.postMoney > 0}}">(另需运费¥{{item.postMoney / 100}})</text></view>
<view class="product-btn flex-between">
<image src="https://static.ticket.sz-trip.com/jundaosuzhou/images/combinedLine/del.png"
bindtap="decreaseSkuNum" data-item="{{item}}" wx:if="{{item.buyNum > 0}}" mode="widthFix" />
<view wx:else></view>
<view style="width: 100%;text-align: center;" wx:if="{{item.buyNum > 0}}">{{item.buyNum}}
</view>
<view wx:else></view>
<image src="https://static.ticket.sz-trip.com/jundaosuzhou/images/combinedLine/add.png"
bindtap="increaseSkuNum" data-item="{{item}}" mode="widthFix" />
</view>
</view>
</view>
</view>
</view>
<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 class="sku-popup" wx:if="{{showItem}}">
<view class="sku-name">产品详情</view>
<view class="sku-content" bindtap="onSkuContentTap">
<rich-text nodes="{{formateRichText(showItem.content)}}"></rich-text>
</view>
</view>
</van-popup> -->
</view>

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

@ -0,0 +1,201 @@
.flex-between {
display: flex;
justify-content: space-between;
align-items: center;
}
.container {
width: 750rpx;
}
.box {
width: 700rpx;
background: #FFFFFF;
border-radius: 9.33rpx;
padding: 0 21.33rpx 46.67rpx;
margin: 0 auto;
box-sizing: border-box;
}
.top-title {
height: 110rpx;
font-weight: bold;
font-size: 30.67rpx;
color: #000000;
display: flex;
justify-content: space-between;
align-items: center;
}
.refresh-btn {
font-weight: bold;
font-size: 28rpx;
color: #0B898E;
display: flex;
align-items: center;
}
.refresh-btn image {
width: 32rpx;
margin-right: 13.33rpx;
}
.address-box {
width: 655.33rpx;
height: 80rpx;
background: rgba(11, 137, 142, .06);
border-radius: 13.33rpx;
padding: 0 21.33rpx;
font-weight: 500;
font-size: 26.67rpx;
color: #0B898E;
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
}
.address-box .location {
width: 42.67rpx;
margin-right: 26.67rpx;
}
.address-box .rightIcon {
width: 20rpx;
}
.address-boxs {
width: 655.33rpx;
height: 133.33rpx;
background: #F7F7F7;
border-radius: 13.33rpx;
padding: 13.33rpx 21.33rpx;
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
}
.address-boxs .location {
width: 42.67rpx;
margin-right: 26.67rpx;
}
.address-boxs .content {
display: flex;
align-items: center;
margin-right: 33.33rpx;
}
.address-boxs .content .left {
font-weight: 500;
font-size: 26.67rpx;
color: #000000;
}
.address-boxs .content .right {
width: 333.33rpx;
margin-left: 16.67rpx;
}
.address-boxs .content .right .top {
font-weight: 400;
font-size: 30.67rpx;
color: #000000;
}
.address-boxs .content .right .top text {
font-weight: 500;
font-size: 24rpx;
color: #666666;
margin-left: 33.33rpx;
}
.address-boxs .content .right .bottom {
margin-top: 6.67rpx
font-weight: 500;
font-size: 24rpx;
color: #666666;
}
.address-boxs .rightIcon {
width: 33.33rpx;
}
.product-item {
height: 153.33rpx;
display: flex;
width: 100%;
margin-top: 40rpx;
}
.product-item .product-img {
width: 153.33rpx;
height: 153.33rpx;
border-radius: 13.33rpx;
margin-right: 20rpx;
}
.product-item .product-content {
flex: 1;
height: 153.33rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.product-item .product-content .title-boxs {
display: flex;
justify-content: space-between;
align-items: center;
}
.product-item .product-content .title-boxs .title {
width: 445.33rpx;
font-weight: 500;
font-size: 28rpx;
color: #000000;
}
.product-item .product-content .title-boxs image {
width: 20rpx;
}
.product-item .product-content .subtitle {
font-weight: 500;
font-size: 24rpx;
color: #999999;
}
.product-item .product-content .price {
font-weight: 500;
font-size: 33.33rpx;
color: #E30000;
}
.product-item .product-content .price::before {
content: '¥';
font-size: 24rpx;
}
.product-item .product-content .price text {
font-weight: 500;
font-size: 24rpx;
color: #E30000;
margin-left: 6.67rpx;
}
.product-item .product-content .product-btn {
width: 160rpx;
font-weight: bold;
font-size: 28rpx;
color: #111111;
display: flex;
justify-content: space-between;
align-items: center;
}
.product-item .product-content .product-btn image {
width: 46.67rpx;
flex-shrink: 0;
}

64
pages/order/food/index.js

@ -16,6 +16,8 @@ Page({
showNoticeFlag:false,
coupon:null,
price: 0,
smoothlyTotal: 0,
maxCouponObject: null
},
/**
@ -37,6 +39,18 @@ Page({
console.log(app.globalData.product)
this.showAllPrice()
},
// 子组件发生改变时更新价格
handleUpdateTotalPrice(e) {
this.setData({
smoothlyTotal: e.detail.total
});
// 重新计算总价
this.showAllPrice();
},
// 调用子组件清除优惠券方法
callOtherCompMethod: function(e) {
this.couponCom.setNullCoupon()
},
showNotice:function(){
this.setData({
showNoticeFlag:true
@ -58,15 +72,21 @@ Page({
showAllPrice () {
console.log('couponInfo',app.globalData.couponInfo);
let price
let price = this.data.product.sku.price * this.data.productNum
let allPrice = 0
// 顺手购价格
price += this.data.smoothlyTotal || 0;
allPrice = price
if (this.data.coupon) {
if (this.data.coupon.activity.discount_type == 'pricebreak') {
price = this.data.product.sku.price * this.data.productNum - this.data.coupon.activity.money
price = price - this.data.coupon.activity.money
} else {
price =(this.data.product.sku.price * this.data.productNum * this.data.coupon.activity.fold)/ 10
price =(price * this.data.coupon.activity.fold)/ 10
}
} else {
price = this.data.product.sku.price * this.data.productNum
price = price
}
if (price >0) {
this.setData({ price:price/100})
@ -74,6 +94,22 @@ Page({
this.setData({ price:0 })
}
const smoothlyComp = this.selectComponent("#smoothlyOrderComp");
const skuIds = []
skuIds.push(this.data.product.sku.id)
if(smoothlyComp) {
// 检查是否有选中的顺手购商品
const hasSkuIds = smoothlyComp.hasSelectedGoods();
if(hasSkuIds) {
skuIds.push(...smoothlyComp.emitSkuIds())
}
}
this.setData({
maxCouponObject: {
price: allPrice,
skuIds: skuIds.toString()
}
})
},
/**
@ -116,6 +152,20 @@ Page({
})
},
order:function(){
const smoothlyComp = this.selectComponent("#smoothlyOrderComp");
console.log(smoothlyComp,smoothlyComp.emitOrder())
if(smoothlyComp) {
// 检查是否有选中的顺手购商品
const hasSelected = smoothlyComp.hasSelectedGoods();
if(hasSelected && !smoothlyComp.data.address) {
wx.showToast({
title: '请选择收货地址',
icon: 'none'
})
return;
}
}
// if(!this.data.user){
// wx.showToast({
// title: '请输入联系人',
@ -143,6 +193,12 @@ Page({
source:"WECHATXCX",
coupon_id:this.data.coupon?this.data.coupon.id:null
};
// 顺手购下单参数
if(smoothlyComp && smoothlyComp.emitOrder() && smoothlyComp.emitOrder().length) {
product_list.push(...smoothlyComp.emitOrder())
}
if(app.globalData.from){
data.system_name = app.globalData.from;
}

3
pages/order/food/index.json

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

12
pages/order/food/index.wxml

@ -28,7 +28,17 @@
<input type="number" value="{{tel}}" bindinput="telInput" placeholder="请输入手机号"></input>
</view>
</view>
<coupon id="coupon" bind:getNewCoupon = 'getNewCoupon' money="{{product.sku.price * productNum}}" sku="{{product.sku.id}}"></coupon>
<coupon id="coupon" bind:getNewCoupon = 'getNewCoupon' money="{{product.sku.price * productNum}}" sku="{{product.sku.id}}" maxCouponObject="{{maxCouponObject}}"></coupon>
<!-- 顺手购组件 -->
<smoothly-order
wx:if="{{product.product.id}}"
id="smoothlyOrderComp"
productId="{{product.product.id}}"
bind:callOtherComp="callOtherCompMethod"
bind:updateTotalPrice="handleUpdateTotalPrice"
></smoothly-order>
<view style="height:113rpx"></view>
<view class="fixed-bottom" wx:if="{{product}}">
<!-- <view class="fixed-price-box"><text>订单金额:</text><text class="price">¥{{((product.sku.price * productNum - (coupon?coupon.activity.money:0))>0?(product.sku.price * productNum - (coupon?coupon.activity.money:0)):0) / 100}}</text></view> -->

66
pages/order/showOrderNew/index.js

@ -46,6 +46,8 @@ Page({
showDate2:false,
showYhq:null,
couponFlag:false,
smoothlyTotal: 0,
maxCouponObject: null
},
/**
@ -115,6 +117,18 @@ Page({
// showDate: true,
// })
// },
// 子组件发生改变时更新价格
handleUpdateTotalPrice(e) {
this.setData({
smoothlyTotal: e.detail.total
});
// 重新计算总价
this.totalPrice(this.data.singlePrice)
},
// 调用子组件清除优惠券方法
callOtherCompMethod: function(e) {
this.couponCom.setNullCoupon()
},
hideDate: function () {
this.setData({
showDate: false
@ -281,15 +295,20 @@ Page({
this.totalPrice(this.data.singlePrice)
},
totalPrice(price) {
let allPrice
let allPrice = this.data.singlePrice * this.data.productNum
let prices = 0
console.log(this.data.smoothlyTotal,111111)
// 顺手购价格
allPrice += this.data.smoothlyTotal || 0;
prices = allPrice
if (this.data.coupon) {
if (this.data.coupon.activity.discount_type == 'pricebreak') {
allPrice = this.data.singlePrice * this.data.productNum - this.data.coupon.activity.money
allPrice = allPrice - this.data.coupon.activity.money
} else {
allPrice =(this.data.singlePrice * this.data.productNum * this.data.coupon.activity.fold)/ 10
allPrice =(allPrice * this.data.coupon.activity.fold)/ 10
}
} else {
allPrice = this.data.singlePrice * this.data.productNum
allPrice = allPrice
}
// allPrice = price * this.data.productNum - (this.data.coupon?this.data.coupon.activity.money:0)
@ -305,6 +324,23 @@ Page({
})
}
console.log('singlePrice',this.data.singlePrice);
const smoothlyComp = this.selectComponent("#smoothlyOrderComp");
const skuIds = []
skuIds.push(this.data.product.sku.id)
if(smoothlyComp) {
// 检查是否有选中的顺手购商品
const hasSkuIds = smoothlyComp.hasSelectedGoods();
if(hasSkuIds) {
skuIds.push(...smoothlyComp.emitSkuIds())
}
}
this.setData({
maxCouponObject: {
price: prices,
skuIds: skuIds.toString()
}
})
},
changeDate: function (e) {
console.log('打印',e);
@ -372,6 +408,19 @@ Page({
this.hideDate()
},
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 linkmanList = this.data.linkmanList, productNum = this.data.productNum, date = this.data.date, time = this.data.time, remark = this.data.remark, product = this.data.product;
let linkmanIds = [];
if (linkmanList.length==0 && this.data.is_authentication == 1) {
@ -432,6 +481,12 @@ Page({
team_id: app.globalData.team_id,
linkmanList:this.data.is_authentication == 1?this.data.linkmanList:[]
}
// 顺手购下单参数
if(smoothlyComp && smoothlyComp.emitOrder() && smoothlyComp.emitOrder().length) {
data.product_list.push(...smoothlyComp.emitOrder())
}
if (app.globalData.from) {
data.system_name = app.globalData.from;
}
@ -609,7 +664,8 @@ Page({
coupon:e.detail
})
this.showAllPrice()
// this.showAllPrice()
this.totalPrice(this.data.singlePrice)
},
/**

3
pages/order/showOrderNew/index.json

@ -4,6 +4,7 @@
"contact":"../components/contact/index",
"coupon":"../components/coupon/index",
"notice":"/pages/component/notice/notice",
"date":"/pages/order/components/date"
"date":"/pages/order/components/date",
"smoothly-order": "/pages/order/components/smoothlyOrder/index"
}
}

11
pages/order/showOrderNew/index.wxml

@ -46,7 +46,16 @@
</view> -->
<coupon bind:getNewCoupon = 'getNewCoupon' wx:if="{{!kjId && !gp_id && type!='activity' && product && product.isGroup!=1 && isCar=='single' && type!='museum' && showYhq}}" id="coupon"
money="{{singlePrice * productNum}}" sku="{{product.sku.id}}" couponFlag="{{couponFlag}}"></coupon>
money="{{singlePrice * productNum}}" sku="{{product.sku.id}}" couponFlag="{{couponFlag}}" maxCouponObject="{{maxCouponObject}}"></coupon>
<!-- 顺手购组件 -->
<smoothly-order
wx:if="{{product.product.id}}"
id="smoothlyOrderComp"
productId="{{product.product.id}}"
bind:callOtherComp="callOtherCompMethod"
bind:updateTotalPrice="handleUpdateTotalPrice"
></smoothly-order>

1
pages/order/showOrderNew/index.wxss

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

27
project.private.config.json

@ -6,12 +6,33 @@
"condition": {
"miniprogram": {
"list": [
{
"name": "pages/info/showInfo/index",
"pathName": "pages/info/showInfo/index",
"query": "id=465394",
"scene": null,
"launchMode": "default"
},
{
"name": "pages/info/postProductInfo/index",
"pathName": "pages/info/postProductInfo/index",
"query": "id=460201&ZTPoint=%E7%94%84%E9%80%89%E6%99%AF%E9%85%92%E5%A5%97%E9%A4%90",
"launchMode": "default",
"scene": null
},
{
"name": "subPackages/foodNew/index",
"pathName": "subPackages/foodNew/index",
"query": "id=914667",
"launchMode": "default",
"scene": null
},
{
"name": "pages/info/roadInfo/index",
"pathName": "pages/info/roadInfo/index",
"query": "id=457033",
"scene": null,
"launchMode": "default"
"launchMode": "default",
"scene": null
},
{
"name": "pages/info/roadInfo/index",
@ -109,5 +130,5 @@
},
"projectname": "%E8%8B%8F%E5%B7%9E%E6%96%87%E6%97%85",
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"libVersion": "3.9.3"
"libVersion": "3.7.12"
}
Loading…
Cancel
Save