Browse Source

产品下单接入补贴

产品下单接入补贴
master
xuetaotao 4 years ago
parent
commit
bd2f995e80
  1. 18
      pages/info/postProductInfo/index.js
  2. 6
      pages/info/postProductInfo/index.wxml
  3. 27
      pages/info/postProductInfo/index.wxss
  4. 54
      pages/order/postOrder/index.js
  5. 14
      pages/order/postOrder/index.wxml
  6. 48
      pages/order/postOrder/index.wxss
  7. 10
      utils/https.js

18
pages/info/postProductInfo/index.js

@ -68,15 +68,15 @@ Page({
}) })
// 获取补贴 // 获取补贴
// commonApi.user_post("product/getProductAllowancePrice", { commonApi.user_post("product/getProductAllowancePrice", {
// product_code: res.data.product_code product_code: res.data.product_code
// }).then(resTwo => { }).then(resTwo => {
// if (resTwo) { if (resTwo && resTwo.code == 1) {
// this.setData({ this.setData({
// allowance_data: resTwo.data allowance_data: resTwo.data
// }) })
// } }
// }) })
this.BroswerRecord() this.BroswerRecord()
}) })
// 获取评价列表 // 获取评价列表

6
pages/info/postProductInfo/index.wxml

@ -20,7 +20,7 @@
</swiper> </swiper>
<view class="allowance-box" wx:if="{{allowance_data}}"> <view class="allowance-box" wx:if="{{allowance_data}}">
补贴价 补贴价
<view class="com-price two">{{ allowance_data.mini_price / 100 }}</view> <view class="com-price two">{{ allowance_data.mini_price / 100 }}</view>
<view class="yellow">单品最高补贴{{ allowance_data.max_price / 100 }}元</view> <view class="yellow">单品最高补贴{{ allowance_data.max_price / 100 }}元</view>
</view> </view>
<view class="top-info" wx:if="{{info}}"> <view class="top-info" wx:if="{{info}}">
@ -107,7 +107,9 @@
<view class="sku-info-box"> <view class="sku-info-box">
<image id="skuImg" src="{{info.sku[skuIndex].headimg}}" mode="aspectFill"></image> <image id="skuImg" src="{{info.sku[skuIndex].headimg}}" mode="aspectFill"></image>
<view class="sku-info"> <view class="sku-info">
<view class="sku-price">{{info.sku[skuIndex].price/100}}</view> <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 class="sku-name">已选择:{{info.sku[skuIndex].sku_name}}</view>
</view> </view>
</view> </view>

27
pages/info/postProductInfo/index.wxss

@ -20,7 +20,7 @@ page {
background: white; background: white;
position: relative; position: relative;
z-index: 1; z-index: 1;
margin-top: -20rpx; margin-top: -60rpx;
padding: 20rpx 40rpx; padding: 20rpx 40rpx;
} }
@ -483,12 +483,26 @@ page {
font-weight: 500; font-weight: 500;
color: #D62828; color: #D62828;
margin: 20rpx 0; margin: 20rpx 0;
display: flex;
justify-content: flex-start;
align-items: center;
} }
.sku-price::before { .sku-price::before {
content: "¥"; content: "¥";
font-weight: 400; font-weight: 400;
font-size: 27rpx; 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 { .sku-name {
@ -743,15 +757,18 @@ page {
} }
.allowance-box { .allowance-box {
height: 114rpx; height: 113rpx;
background-image: url("/static/images/detail/allowanceBacTwo.png"); background: url("https://sz-qd.oss-cn-hangzhou.aliyuncs.com/uploads/20220602/7762b9c4be5adac1f3d0ab5228569821.png");
padding: 20rpx 10rpx; background-size: 100% auto;
font-size: 18rpx; background-repeat: no-repeat;
padding: 30rpx 30rpx 10rpx;
font-size: 24rpx;
color: #FFFFFF; color: #FFFFFF;
margin-top: -60rpx; margin-top: -60rpx;
position: relative; position: relative;
display: flex; display: flex;
justify-content: start; justify-content: start;
align-items: baseline;
} }
.allowance-box .com-price { .allowance-box .com-price {

54
pages/order/postOrder/index.js

@ -16,7 +16,10 @@ Page({
sku_id: '', sku_id: '',
kjId: null, kjId: null,
gp_id: null, gp_id: null,
prizeId:null prizeId: null,
select_allowance: false,
allowance_data: null,
allowance_price: 0,
}, },
/** /**
@ -47,7 +50,6 @@ Page({
if (!this.data.kjId && !this.data.gp_id) { if (!this.data.kjId && !this.data.gp_id) {
this.couponCom = this.selectAllComponents("#coupon")[0]; this.couponCom = this.selectAllComponents("#coupon")[0];
} }
}, },
inputRemark: function (e) { inputRemark: function (e) {
let index = e.currentTarget.dataset.index, product = this.data.product; let index = e.currentTarget.dataset.index, product = this.data.product;
@ -89,6 +91,10 @@ Page({
let product = this.data.product, price = 0; let product = this.data.product, price = 0;
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) {
let spread_price = Number(this.data.allowance_data.discount_limit_price - this.data.allowance_data.user_used_price);
price -= this.data.allowance_price * item.productNum < spread_price ? this.data.allowance_price * item.productNum : spread_price
}
}) })
if (this.data.coupon && this.data.showPrice != price) { if (this.data.coupon && this.data.showPrice != price) {
wx.showToast({ wx.showToast({
@ -135,6 +141,7 @@ 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 (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;
} }
@ -214,6 +221,16 @@ Page({
}) })
}, },
/**
* 选择补贴
*/
selectAllowance: function () {
this.setData({
select_allowance: !this.data.select_allowance
})
this.changePrice()
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
@ -228,6 +245,39 @@ Page({
this.setData({ this.setData({
coupon: app.globalData.couponInfo coupon: app.globalData.couponInfo
}) })
// 获取补贴
if (this.data.product.length == 1) {
commonApi.user_post("product/getProductAllowancePrice", {
product_code: this.data.product[0].product.product_code
}).then(resTwo => {
console.log(resTwo)
if (resTwo && resTwo.code == 1) {
this.setData({
allowance_data: resTwo.data
})
let spread_price = Number(this.data.allowance_data.discount_limit_price - this.data.allowance_data.user_used_price)
let sInfo = this.data.product[0].sku
console.log(9999, this.data.allowance_data.discount_rate / 100 * sInfo.price)
console.log(9999, spread_price)
if (spread_price > 0) {
if (spread_price < this.data.allowance_data.discount_rate / 100 * sInfo.price) {
this.setData({
allowance_price: spread_price
})
} else {
this.setData({
allowance_price: this.data.allowance_data.discount_rate / 100 * sInfo.price
})
}
this.changePrice()
} else {
this.setData({
allowance_price: 0
})
}
}
})
}
}, },
/** /**

14
pages/order/postOrder/index.wxml

@ -36,11 +36,23 @@
<view class="all-money-box" wx:if="{{from=='cart'}}"> <view class="all-money-box" wx:if="{{from=='cart'}}">
小计:<text class="unit">¥</text><text class="s-price">{{item.sku.price * item.productNum /100}}</text> 小计:<text class="unit">¥</text><text class="s-price">{{item.sku.price * item.productNum /100}}</text>
</view> </view>
<!-- 补贴 -->
<view class="box-title allowance" wx:if="{{allowance_price}}">
<view>惠民补贴</view>
<view class="com-flex-tao" bindtap="selectAllowance">
-¥{{allowance_price / 100}}
<image src="https://sz-qd.oss-cn-hangzhou.aliyuncs.com/uploads/20220602/6ecdbc41527c0c603608686967d4493b.png"
alt="" wx:if="{{select_allowance}}"></image>
<view class="border" wx:else></view>
</view>
</view>
</view> </view>
<coupon id="coupon" wx:if="{{!kjId && !gp_id}}" money="{{showPrice + postFee}}" sku="{{sku_id}}"></coupon> <coupon id="coupon" wx:if="{{!kjId && !gp_id}}" money="{{showPrice + postFee}}" sku="{{sku_id}}"></coupon>
<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}}"><text>合计:</text><text class="price">¥{{((showPrice + postFee - (coupon?coupon.activity.money:0))>0?(showPrice + postFee - (coupon?coupon.activity.money:0)):0)/100}}</text></view> <view class="fixed-price-box" wx:if="{{!prizeId}}"><text>合计:</text><text
class="price">¥{{((showPrice + postFee - (coupon?coupon.activity.money:0))>0?(showPrice + postFee - (coupon?coupon.activity.money:0)):0)/100}}</text>
</view>
<view class="fixed-price-box" wx:else><text>合计:</text><text class="price">¥{{postFee?(0+postFee)/100:0}}</text></view> <view class="fixed-price-box" wx:else><text>合计:</text><text class="price">¥{{postFee?(0+postFee)/100:0}}</text></view>
<view class="fixed-btn" bindtap="order">提交订单</view> <view class="fixed-btn" bindtap="order">提交订单</view>
</view> </view>

48
pages/order/postOrder/index.wxss

@ -2,11 +2,13 @@
page { page {
background: #f6f6f6; background: #f6f6f6;
} }
.box { .box {
margin: 30rpx 25rpx; margin: 30rpx 25rpx;
background: white; background: white;
border-radius: 9rpx; border-radius: 9rpx;
} }
.box-title { .box-title {
height: 113rpx; height: 113rpx;
margin: 0 20rpx; margin: 0 20rpx;
@ -16,6 +18,30 @@ page {
display: flex; display: flex;
align-items: center; align-items: center;
} }
.allowance {
justify-content: space-between;
}
.allowance>view:nth-child(2) {
display: flex;
align-items: center;
}
.allowance image {
width: 40rpx;
height: 40rpx;
margin-left: 10rpx;
}
.allowance .border {
width: 30rpx;
height: 30rpx;
border-radius: 50%;
border: 4rpx solid #0B98BE;
margin-left: 10rpx;
}
.coupon-btn { .coupon-btn {
width: 138rpx; width: 138rpx;
line-height: 56rpx; line-height: 56rpx;
@ -25,12 +51,14 @@ page {
font-size: 28rpx; font-size: 28rpx;
color: #000; color: #000;
} }
.skuinfo { .skuinfo {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
padding: 30rpx 20rpx; padding: 30rpx 20rpx;
margin-bottom: 30rpx; margin-bottom: 30rpx;
} }
.skuinfo image { .skuinfo image {
flex-shrink: 0; flex-shrink: 0;
width: 174rpx; width: 174rpx;
@ -38,10 +66,12 @@ page {
border-radius: 7rpx; border-radius: 7rpx;
margin-right: 23rpx; margin-right: 23rpx;
} }
.right-info { .right-info {
flex: 1; flex: 1;
width: 400rpx; width: 400rpx;
} }
.sku-name { .sku-name {
font-size: 32rpx; font-size: 32rpx;
line-height: 47rpx; line-height: 47rpx;
@ -51,6 +81,7 @@ page {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
} }
.info-tips { .info-tips {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@ -58,22 +89,27 @@ page {
font-size: 27rpx; font-size: 27rpx;
color: #666; color: #666;
} }
.info-tips .price { .info-tips .price {
font-size: 33rpx; font-size: 33rpx;
color: #000; color: #000;
flex: 1; flex: 1;
margin-left: 10rpx; margin-left: 10rpx;
} }
.info-tips .price text { .info-tips .price text {
font-size: 24rpx; font-size: 24rpx;
} }
.info-tips .iconfont { .info-tips .iconfont {
font-size: 26rpx; font-size: 26rpx;
} }
.box-title .iconfont { .box-title .iconfont {
font-size: 28rpx; font-size: 28rpx;
flex-shrink: 0; flex-shrink: 0;
} }
.number-box { .number-box {
font-size: 29rpx; font-size: 29rpx;
font-weight: 500; font-weight: 500;
@ -86,14 +122,17 @@ page {
text-align: center; text-align: center;
margin: 0 20rpx; margin: 0 20rpx;
} }
.line { .line {
margin: 0 20rpx; margin: 0 20rpx;
background: #ccc; background: #ccc;
height: 1rpx; height: 1rpx;
} }
.topbox .box-title { .topbox .box-title {
border-top: 1rpx solid #ccc; border-top: 1rpx solid #ccc;
} }
.box-title input { .box-title input {
flex: 1; flex: 1;
display: block; display: block;
@ -102,6 +141,7 @@ page {
margin-left: 15rpx; margin-left: 15rpx;
font-weight: 400; font-weight: 400;
} }
.fixed-bottom { .fixed-bottom {
position: fixed; position: fixed;
left: 0; left: 0;
@ -115,6 +155,7 @@ page {
z-index: 2; z-index: 2;
box-shadow: 0px 0px 16rpx 0px rgba(6, 0, 1, 0.1); box-shadow: 0px 0px 16rpx 0px rgba(6, 0, 1, 0.1);
} }
.fixed-btn { .fixed-btn {
width: 320rpx; width: 320rpx;
line-height: 113rpx; line-height: 113rpx;
@ -124,6 +165,7 @@ page {
font-size: 36rpx; font-size: 36rpx;
font-weight: 500; font-weight: 500;
} }
.fixed-price-box { .fixed-price-box {
margin-left: 25rpx; margin-left: 25rpx;
flex-shrink: 0; flex-shrink: 0;
@ -131,11 +173,13 @@ page {
color: #333; color: #333;
font-weight: 500; font-weight: 500;
} }
.fixed-price-box .price { .fixed-price-box .price {
color: #D62828; color: #D62828;
font-size: 36rpx; font-size: 36rpx;
margin-left: 10rpx; margin-left: 10rpx;
} }
.all-money-box { .all-money-box {
margin: 0 20rpx; margin: 0 20rpx;
display: flex; display: flex;
@ -146,15 +190,19 @@ page {
border-top: 1rpx solid #ccc; border-top: 1rpx solid #ccc;
color: #000; color: #000;
} }
.all-money-box text { .all-money-box text {
color: #D62828; color: #D62828;
} }
.all-money-box .unit { .all-money-box .unit {
font-size: 24rpx; font-size: 24rpx;
} }
.all-money-box .s-price { .all-money-box .s-price {
font-size: 33rpx; font-size: 33rpx;
} }
.header-title { .header-title {
font-size: 31rpx; font-size: 31rpx;
font-weight: 500; font-weight: 500;

10
utils/https.js

@ -1,8 +1,8 @@
var app = getApp(); var app = getApp();
import util from "../utils/util" import util from "../utils/util"
// import userApi from "../utils/https/user.js"; // import userApi from "../utils/https/user.js";
const baseUrl = "https://test.api.cloud.sz-trip.com/api/"; // const baseUrl = "https://test.api.cloud.sz-trip.com/api/";
// const baseUrl = "https://api.cloud.sz-trip.com/api/"; const baseUrl = "https://api.cloud.sz-trip.com/api/";
const orders = ['', 'weight', 'distance', 'sale_number', 'sale_price', 'price']; const orders = ['', 'weight', 'distance', 'sale_number', 'sale_price', 'price'];
//封装GET请求 //封装GET请求
function _get(url, data) { function _get(url, data) {
@ -200,7 +200,11 @@ function user_post_new(url,data={},type){
} }
else if (res.data.code != 1 && res.data.msg) { else if (res.data.code != 1 && res.data.msg) {
// 不出现提示语 // 不出现提示语
if(url.indexOf('actonline/video_act/getRaffle')!=-1 || url.indexOf('team_order/apply_post')!=-1 && type=='get'){ const noToast = [
'actonline/video_act/getRaffle',
'getProductAllowancePrice'
]
if (noToast.indexOf(url) || url.indexOf('team_order/apply_post') != -1 && type == 'get') {
} }
else if (url.indexOf('actonline/act_online/vote') != -1 && res.data.code == 0) { else if (url.indexOf('actonline/act_online/vote') != -1 && res.data.code == 0) {

Loading…
Cancel
Save