Commit 712b33e1 authored by jiangjiantao's avatar jiangjiantao

加减删商品,清空列表,优惠券

parent ca5baf71
App({
globalData: {
TEST_URL: "https://cashier.test.miyahub.net/",
RELEASE_URL: "https://cashier.miyahub.com/",
},
onLaunch(options) {
// 第一次打开
// options.query == {number:1}
......
......@@ -9,6 +9,7 @@
}
/* 带有高斯模糊的效果 */
.pfilter {
display: flex;
flex-direction: column;
......@@ -70,6 +71,7 @@
}
/* 下部分 */
.land-scan-boottom {
height: 100%;
width: 100%;
......@@ -86,7 +88,8 @@
}
/* 顶部空白 */
.shopcart-cart-top-blank{
.shopcart-cart-top-blank {
height: 7rpx;
width: 100%
}
......@@ -116,6 +119,7 @@
}
/* 空购物车 */
.shopcart-list-empty {
height: 100%;
width: 68%;
......@@ -125,7 +129,6 @@
align-items: center;
}
/* 提示文字 */
.empty-remind-text {
......@@ -188,8 +191,6 @@
height: 60rpx;
}
/* 商品条目上半部分 */
.good-top {
......@@ -278,3 +279,100 @@
width: 28rpx;
height: 28rpx;
}
/* 用券page */
.page-coupon {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
position: absolute;
background: white
}
/* 券顶部 */
.coupon-top {
width: 100%;
height: 60rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
background: rgba(255, 255, 255, 1);
box-shadow: 0px 2px 7px 0px rgba(153, 153, 153, 0.16)
}
/* 券底部 */
.coupon-bottom {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around
}
/* 返回 */
.coupon-back-container {
width: 95rpx;
height: 100%;
justify-content: center;
align-items: center;
display: flex;
flex-direction: row
}
/* 返回icon */
.coupon-back-icon{
width: 9rpx;
height: 18rpx;
}
/* 返回text */
.coupon-back-text {
font-size: 19rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(51, 51, 51, 1);
line-height: 22rpx;
margin-left: 5rpx
}
/* 标题 */
.coupon-title {
font-size: 22rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: rgba(51, 51, 51, 1);
line-height: 22rpx;
}
/* 扫券码提示 */
.scan-coupon-text {
font-size: 26rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: rgba(51, 51, 51, 0.85);
line-height: 26rpx;
}
/* 取消用券 */
.cancel-use-coupon {
border-radius: 5px;
width: 252rpx;
height: 60rpx;
}
/* 扫券引导图 */
.scan-coupon-guide{
width: 180rpx;
height: 155rpx;
}
\ No newline at end of file
<!-- 扫商品页面 -->
<view class="{{scene != 0 ? 'pfilter' : 'pageland' }}">
<view class="land-scan-top">
<button class="land-scan-top-member-login" size="default" type="ghost">会员登陆</button>
......@@ -19,19 +19,19 @@
<view class="shopcart-cart-top-blank">
</view>
<block a:for="{{goods}}">
<view class="scan-list-bg">
<view class="scan-list-bg" >
<view class="good-top">
<view class="good-name">
{{item.name}}
</view>
<image class="good-del" mode="aspectFit" src="/images/harf_delete.png"/>
<image id="{{item.barcode}}" class="good-del" mode="aspectFit" src="/images/harf_delete.png" catchTap="deleteGood" />
</view>
<view class="good-bottom">
<view class="good-price">¥{{item.price}}</view>
<view class="good-operat">
<image class="good-decrease" mode="scaleToFill" src="/images/good_decrease.png"/>
<image id="{{item.barcode}}" class="good-decrease" mode="scaleToFill" src="/images/good_decrease.png" catchTap="decreaseGood"/>
<text class="good-num">{{item.quantity}}</text>
<image class="good-increase" mode="scaleToFill" src="/images/good_increase.png"/>
<image id="{{item.barcode}}" class="good-increase" mode="scaleToFill" src="/images/good_increase.png" catchTap="increaseGood"/>
</view>
</view>
</view>
......@@ -40,8 +40,8 @@
<view class="more-operating">
<view class="operating-top">
<image class="operat-icon" mode="aspectFit" src="/images/manual_barcode.png" catchTap="manualBarcode"/>
<image class="operat-icon" mode="aspectFit" src="/images/use_coupon.png"/>
<image class="operat-icon" mode="aspectFit" src="/images/clear_shop_list.png"/>
<image class="operat-icon" mode="aspectFit" src="/images/use_coupon.png" catchTap="useCoupon"/>
<image class="operat-icon" mode="aspectFit" src="/images/clear_shop_list.png" catchTap="clearGood"/>
</view>
<view class="operating-bottom">
<text class="total-num">共{{totalNum}}件商品,合计金额</text>
......@@ -51,7 +51,22 @@
</view>
</view>
</view>
<!-- 扫描优惠券 -->
<view class="page-coupon" a:if="{{couponUseing}}" >
<view class="coupon-top">
<view class="coupon-back-container" onTap="couponBack">
<image class="coupon-back-icon" mode="aspectFit" src="/images/icon_back.png"/>
<text class="coupon-back-text">返回</text>
</view>
<view class="coupon-title">优惠券</view>
<view></view>
</view>
<view class="coupon-bottom">
<text class="scan-coupon-text">等待顾客扫描优惠券码…</text>
<image class="scan-coupon-guide" mode="aspectFit" src="/images/scan_guide.png"/>
<button class="cancel-use-coupon" size="default" type="ghost" onTap="couponBack">取消</button>
</view>
</view>
<!-- 键盘 -->
<land-keybord scene="{{scene}}" onKeyBordFinished="onKeyBordFinished" onKeyBordClose="onKeyBordClose">
</land-keybord>
\ No newline at end of file
var api = require("../../utils/api.js");
import { API_SCAN } from '../../const/apiurl'
Page({
data: {
//是否正在用券
couponUseing:false,
//0代表弹窗关闭 1代表手动输入条码弹窗 2代表会员 3.收款 4.退款
scene: 0,
//总数量
......@@ -7,61 +11,161 @@ Page({
//应付款
payPrice: "0.00",
goods: [
{
name: "Beats Studio3 头戴式耳机-魅影灰",
price: 298.6,
quantity: 20,
}, {
name: "Beats Studio3 头戴式耳机-魅影灰",
price: 298.6,
quantity: 20,
}, {
name: "Beats Studio3 头戴式耳机-魅影灰",
price: 298.6,
quantity: 20,
}, {
name: "Beats Studio3 头戴式耳机-魅影灰",
price: 298.6,
quantity: 20,
}, {
name: "Beats Studio3 头戴式耳机-魅影灰",
price: 298.6,
quantity: 20,
}, {
name: "Beats Studio3 头戴式耳机-魅影灰",
price: 298.6,
quantity: 20,
}, {
name: "Beats Studio3 头戴式耳机-魅影灰",
price: 298.6,
quantity: 20,
}
]
},
onLoad() { },
//键盘完成
onKeyBordFinished(data) {
my.showToast({
type: 'success',
content: data,
duration: 3000,
success: () => {
let mockdata = '{"activityId": "5808753370","activityType": "Skus","activityName": "2020年新活动,中国加油","discnt": 100,"startTime": 1580877000000,"endTime": 1583423999000,"pic": "https://miya-ngm.oss-cn-hangzhou.aliyuncs.com/1560763177031148973127.png?Expires=1876123177&OSSAccessKeyId=LTAItcMpilplOYdV&Signature=9NTSNuDocXKQyr%2FbPlHooey3Vrg%3D","name": "test001","barcode": "09876","price": 100000,"salePrice": 100000,"hasDiscount": true}';
},
});
this.parseGoodInfo(JSON.parse(mockdata))
this.onKeyBordClose();
},
// 键盘关闭
onKeyBordClose() {
this.setData({scene:0})
this.setData({ scene: 0 })
},
// 手动输入码
manualBarcode(e){
this.setData({scene:1})
manualBarcode(e) {
this.setData({ scene: 1 })
},
//清空商品信息
clearGood(e) {
this.setData({ goods: [] })
},
//转化商品信息
parseGoodInfo(goodinfo) {
//价格 分转元
goodinfo.quantity = 1;
goodinfo.price = goodinfo.price / 100
goodinfo.salePrice = goodinfo.salePrice / 100
goodinfo.discnt = goodinfo.discnt / 100
//总数量
let totalQuantityTemp = 0
//总价格
let totalPriceTemp = 0.00
//数量+1
let isHasSame = false;
let lastgoods = this.data.goods;
let goodstemp = []
let goodtemp
lastgoods.forEach(function (item, index, array) {
if (item.barcode == goodinfo.barcode) {
let quantitytemp = item.quantity
item.quantity = quantitytemp + 1
isHasSame = true
goodtemp = item
} else {
totalQuantityTemp = totalQuantityTemp + item.quantity
totalPriceTemp = totalPriceTemp + item.price * item.quantity
goodstemp.push(item)
}
})
if (isHasSame) {
totalQuantityTemp = totalQuantityTemp + goodtemp.quantity
totalPriceTemp = totalPriceTemp + goodtemp.price * goodtemp.quantity
let nowgoods = []
nowgoods.push(goodtemp);
var newgoods = nowgoods.concat(goodstemp)
this.setData({ goods: newgoods })
} else {
totalQuantityTemp = totalQuantityTemp + 1
totalPriceTemp = totalPriceTemp + goodinfo.price
let nowgoods = []
nowgoods.push(goodinfo);
var newgoods = nowgoods.concat(lastgoods)
this.setData({ goods: newgoods })
}
//汇总
this.setData({
totalNum: totalQuantityTemp,
payPrice: totalPriceTemp,
})
},
//删除商品
deleteGood(e) {
let barcode = e.target.id;
let lastgoods = this.data.goods;
let newGoods = []
lastgoods.forEach(function (item, index, array) {
if (barcode != item.barcode) {
newGoods.push(item);
}
})
this.setData({ goods: newGoods })
},
//减少商品
decreaseGood(e) {
let barcode = e.target.id;
let lastgoods = this.data.goods;
let newGoods = []
lastgoods.forEach(function (item, index, array) {
if (barcode == item.barcode) {
if (item.quantity != 1) {
let quantitytemp = item.quantity
item.quantity = quantitytemp - 1
newGoods.push(item);
}
} else {
newGoods.push(item);
}
})
this.setData({ goods: newGoods })
},
//增加商品
increaseGood(e) {
console.log(e);
let barcode = e.target.id;
let lastgoods = this.data.goods;
let newGoods = []
lastgoods.forEach(function (item, index, array) {
if (barcode == item.barcode) {
let quantitytemp = item.quantity
item.quantity = quantitytemp + 1
newGoods.push(item);
} else {
newGoods.push(item);
}
})
this.setData({ goods: newGoods })
},
//用券返回
couponBack(e){
this.setData({ couponUseing: false })
},
//使用券
useCoupon(e){
this.setData({ couponUseing: true })
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment