|
|
<template> <view> <!-- 占位 --> <view class="place">现订货量=原订货量+加单数量;若要加单5则输入5,减单5则输入-5(新增商品点击页面最下方的新增按钮)</view> <!-- 商品列表 --> <view class="goods-list"> <!-- 空白页 --> <empty v-if="goodsList.length === 0" tip='订单是空的哦'></empty> <view class="row" v-for="(row,index) in goodsList" :key="index"> <!-- 删除按钮 --> <view class="menu" @tap.stop="deleteGoods(row.id)"> <view class="icon shanchu"></view> </view> <!-- 商品 --> <view class="carrier" :class="[theIndex==index?'open':oldIndex==index?'close':'']" @touchstart="touchStart(index,$event)" @touchmove="touchMove(index,$event)" @touchend="touchEnd(index,$event)"> <!-- 商品信息 --> <view class="goods-info"> <view class="img"> <image :src="row.img"></image> </view> <view class="info"> <view class="title">{{row.mc}}{{row.gg}}{{row.dw}}</view> <view class="spbz" style="width: 100%;"> <input style="font-size: 28upx; color: #f06c7a; height: 40upx; line-height: 40upx; min-height: 40upx;" type="text" :value="row.bz" @input="inputchangeBz($event,row.bz,row.id,index)" placeholder="输入备注"> <input style="font-size: 28upx; color: #f06c7a; height: 40upx; line-height: 40upx; min-height: 40upx;" type="text" :value="row.fudw" @input="inputchangeFudw($event,row.fudw,row.id,index)" placeholder="输入副单位"> </view> <view class="kucun">现订货量:{{row.dinghl}} <span style="color: #f06c7a; padding-left: 42px;">原订货量:{{row.onedhl}}</span></view> <view class="price-number" v-if="row.kucun"> <view class="price">¥{{row.price}}</view> <view class="number"> <!-- <view class="sub" @tap.stop="sub(index)"> <view class="icon jian"></view> </view> --> <view class="input" @tap.stop="discard"> <input type="text" v-model="row.inputnum" placeholder="数量" @input="inputchange($event,row.inputnum,row.id,index)" /> </view> <!-- <view class="input" @tap.stop="discard"> <input type="digit" v-model="product.inputnum==0?'':product.inputnum" @input="inputchange($event,product.inputnum,product.id,product.kcnum,2)" /> </view> --> <!-- <view class="add" @tap.stop="add(index)"> <view class="icon jia"></view> </view> --> </view> </view> <view class="price-number" v-if="!row.kucun"> <view class="deltip">左滑可删除</view> </view> </view> </view> </view> </view> </view> <!-- 脚部菜单 --> <view class="footer" :style="{bottom:footerbottom}"> <view class="settlement1"> <view class="btn_gray" @tap="toAddcp">新增产品</view> </view> <view class="settlement"> <!-- <view class="sum">合计:<view class="money">¥{{sumPrice}}</view></view> --> <view class="btn" @tap="toConfirmation">提交编辑({{sumSl}})</view> </view> </view> </view> </template>
<script> import empty from "@/components/empty"; export default { components: { empty }, data() { return { sumSl:0, sumPrice:'0.00', headerPosition:"fixed", headerTop:null, statusTop:null, selectedList:[], isAllselected:false, goodsList:[], //控制滑动效果
theIndex:null, oldIndex:null, isStop:false, dhid:0, cpids:'', cpnums:'', cpbeizs:'', delcpids:'', cpfudws:'', } }, onShow() { }, onPageScroll(e){ //兼容iOS端下拉时顶部漂移
this.headerPosition = e.scrollTop>=0?"fixed":"absolute"; this.headerTop = e.scrollTop>=0?null:0; this.statusTop = e.scrollTop>=0?null:-this.statusHeight+'px'; }, //下拉刷新,需要自己在page.json文件中配置开启页面下拉刷新 "enablePullDownRefresh": true
onPullDownRefresh() { setTimeout(function () { uni.stopPullDownRefresh(); }, 1000); }, filters: { toFixed:function(x) { return parseFloat(x).toFixed(2); } }, onLoad(e) { //兼容H5下结算条位置
// #ifdef H5
this.footerbottom = document.getElementsByTagName('uni-tabbar')[0].offsetHeight+'px'; // #endif
// #ifdef APP-PLUS
this.statusHeight = plus.navigator.getStatusbarHeight(); // #endif
this.dhid=e.dhid; this.init(); }, methods: { //去添加加单产品
toAddcp(){ uni.navigateTo({ url:'../category/categoryjiad?dhid='+this.dhid }) }, async init(){ //本地模拟订单提交UI效果
uni.showLoading({ title:'' }) //提交订单
let userinfo=uni.getStorageSync('userinfo'); let redata=await this.$api.orderdetail({action:'orderdetail',dhid:this.dhid,aid:userinfo.aid}); if(redata.code==1){ this.goodsList = redata.data; } uni.hideLoading(); this.sum(); }, //控制左滑删除效果-begin
touchStart(index,event){ //多点触控不触发
if(event.touches.length>1){ this.isStop = true; return ; } this.oldIndex = this.theIndex; this.theIndex = null; //初始坐标
this.initXY = [event.touches[0].pageX,event.touches[0].pageY]; }, touchMove(index,event){ //多点触控不触发
if(event.touches.length>1){ this.isStop = true; return ; } let moveX = event.touches[0].pageX - this.initXY[0]; let moveY = event.touches[0].pageY - this.initXY[1]; if(this.isStop||Math.abs(moveX)<5){ return ; } if (Math.abs(moveY) > Math.abs(moveX)){ // 竖向滑动-不触发左滑效果
this.isStop = true; return; } if(moveX<0){ this.theIndex = index; this.isStop = true; }else if(moveX>0){ if(this.theIndex!=null&&this.oldIndex==this.theIndex){ this.oldIndex = index; this.theIndex = null; this.isStop = true; setTimeout(()=>{ this.oldIndex = null; },150) } } }, touchEnd(index,$event){ //结束禁止触发效果
this.isStop = false; }, //控制左滑删除效果-end
//提交订单
async toConfirmation(){ let getuserinfo=uni.getStorageSync('userinfo'); let delcps=this.delcpids.substr(1); let reinfo=await this.$api.postorderjiad({action:'postorderjiad',uid:getuserinfo.uid,aid:getuserinfo.aid,name:getuserinfo.name,dhid:this.dhid,sjids:this.cpids,cpnums:this.cpnums,cpbeizs:this.cpbeizs,delcpids:delcps,cpfudws:this.cpfudws}); if(reinfo.code==1){ uni.hideLoading(); uni.showModal({ title: '操作成功', content: reinfo.msg, showCancel: false, success: (res) => { uni.navigateBack({ url: "/pages/orderlist/orderlist" }) } }); }else{ uni.hideLoading(); uni.showToast({title:reinfo.msg,icon:'none',duration: 2000}); } }, //删除商品
deleteGoods(id){ let len = this.goodsList.length; for(let i=0;i<len;i++){ if(id==this.goodsList[i].id){ this.goodsList.splice(i, 1); this.delcpids=this.delcpids+','+id; break; } } this.selectedList.splice(this.selectedList.indexOf(id), 1); this.sum(); this.oldIndex = null; this.theIndex = null; }, inputchange(e,inputnum, id, index) { inputnum=e.detail.value; this.goodsList[index].inputnum=inputnum; this.sum(); }, // 合计
sum(){ this.sumPrice=0; let len = this.goodsList.length; let gids=''; let gnums=''; let gbzs=''; let gfudws=''; for(let i=0;i<len;i++){ gids=gids+','+this.goodsList[i].id; gnums=gnums+','+this.goodsList[i].inputnum; gbzs=gbzs+'^'+this.goodsList[i].bz; gfudws=gfudws+'^'+this.goodsList[i].fudw; } this.cpids=gids.substr(1); this.cpnums=gnums.substr(1); this.cpbeizs=gbzs.substr(1); this.cpfudws=gfudws.substr(1); // this.sumPrice = this.sumPrice.toFixed(2);
this.sumSl=this.goodsList.length; }, inputchangeBz(e,inputnum, id, index) { inputnum=e.detail.value; this.goodsList[index].bz=inputnum; this.sum(); }, inputchangeFudw(e,inputnum, id, index) { inputnum=e.detail.value; this.goodsList[index].fudw=inputnum; this.sum() }, discard() { //丢弃
} } } </script> <style lang="scss"> page{position: relative;} @font-face {font-family:"HMfont-home";src:url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAOEAAsAAAAAB7wAAAM1AAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCDHAqDAIJNATYCJAMQCwoABCAFhG0HPhu1BsiOw7jha84s8T+CgOyq6unevTlAeAkRhAhQBjj8eJfmMg/oB5whSgaFspy7AqbpwE3Py3/j9j+X07uGyFHr21lua9HYi9rUCzDeGtBYmw4o0AJJ0BvGLmiJxyEAC3yIQhSVPL9BF4U5TgBi7ChtQzfjQKFYWEdgrFiqEBsxoGurtMfAhuD74g8JQgcNg8ScWjf8xoPz7/nfD8iFpoV0eQi86XQAWwUSiAIUiJGVhgEaUSAKiYXau0kKoKOjwVRthd8PmExIBRvmWH95INCQIIyYqVYAJKGghO/5Dg4B3wtxaPD9QAoS4IOM1gEzYBbAMkT16iIQGPxsopS5ScAcK23LiaBDpzyk1aGLHtsvhVrL7adDD55016wPXnDfcr7T3lcE2TVcP2fNhZM7WeiEhVp44vx9C5vVD6+eEgaLTZvEot3HL1lawlnXLK3XnISDllbWwmrmGjlRLdxq2bpme1RAeqXtzWh6g0F//wCCnRiN2diwr2+Yse3iEs20g05Q5tT0BikOXwKf79vsoEvb6p6xjVhHP92nwDJmX+9hwsf26dXbPiNvZ/98x67/+5T+ev0aWxbXCwOX41zLxia+O73B6Y57fN1u6GvN+Zmbc8XITigTAcB0Rl6X8QB4hDgEpoXypZz2q37D5FVnVa9t1n/dUgHw8uKMq9BmWqjoJoP3zevM+zG8jmVKE5hKpRShw9WTFZW04D7TscAC+B0RcOD9FHLnzqkg0HFOQMMMb5DoBKGKGgUGLEkCIzq5YEEkpastcWQyDYQyByJYBkBgx2nQsOEaSOx4girqOzDgwj8wYickWNAiHLe0JESMsiicTLaQh84PBm6WKlst/TD9hXQV25wWBLQP4jJw435MXD58RynxFDPKT30golBxluAtOI3iOMOcs5Bc2fFF8sPd2OFVBO24WQJ9CmEIG4HwQAb4ARmFS0aK8qoL/cLnXyA0FTE23FBSZf+AYEqCzpF4YojrgN5J004lt/LKFD7RHDAVQYEMh8lIQErAICImJgOZWD0ohHARdhg5wJdzSKxVaXhX6c7y8uQN1wAWmLOU0IQUShiQo0fZTceadqaMdP2uXwEAAAAA') format('woff2');} .icon { font-family:"HMfont-home" !important; font-size:60upx; font-style:normal; color:#000000; &.jia { &:before{content:"\e641";} } &.jian { &:before{content:"\e643";} } &.shanchu { &:before{content:"\e6a4";} } } .checkbox-box{ display: flex; align-items: center; .sellq{ font-size: 28upx; color: #ffffff; background-color: #C4C4C4; padding: 5upx 20upx; text-align: center; border-radius: 25upx; } .checkbox{ width: 35upx; height: 35upx; border-radius: 100%; border: solid 2upx #f06c7a; display: flex; justify-content: center; align-items: center; .on{ width: 25upx; height: 25upx; border-radius: 100%; background-color: #f06c7a; } } .text{ font-size: 28upx; margin-left: 10upx; } } .status { width: 100%; height: 0; position: fixed; z-index: 10; background-color: #fff; top: 0; /* #ifdef APP-PLUS */ height: var(--status-bar-height);//覆盖样式
/* #endif */ }
.header{ width: 92%; padding: 0 4%; height: 100upx; display: flex; align-items: center; position: fixed; top: 0; z-index: 10; background-color: #fff; /* #ifdef APP-PLUS */ top: var(--status-bar-height); /* #endif */ .title{ font-size: 36upx; } } .place{ background-color: #ffffff; height: auto; /* #ifdef APP-PLUS */ margin-top: var(--status-bar-height); /* #endif */ font-size: 25upx; color: #999; padding: 5px 20px 0 20px; } .goods-list{ width: 100%; padding: 20upx 0 120upx 0; .tis{ width: 100%; height: 60upx; display: flex; justify-content: center; align-items: center; font-size: 32upx; } .row{ width: calc(92%); height: calc(22vw + 40upx); margin: 20upx auto; border-radius: 15upx; box-shadow: 0upx 5upx 20upx rgba(0,0,0,0.1); display: flex; align-items: center; position: relative; overflow: hidden; z-index: 4; border: 0; .menu{ .icon{ color: #fff; // font-size: 25upx;
} position: absolute; width: 30%; height: 100%; right: 0; display: flex; justify-content: center; align-items: center; background-color: red; color: #fff; z-index: 2; } .carrier{ @keyframes showMenu { 0% {transform: translateX(0);}100% {transform: translateX(-30%);} } @keyframes closeMenu { 0% {transform: translateX(-30%);}100% {transform: translateX(0);} } &.open{ animation: showMenu 0.25s linear both; } &.close{ animation: closeMenu 0.15s linear both; } background-color: #fff; .checkbox-box{ padding-left: 20upx; flex-shrink: 0; height: 22vw; margin-right: 20upx; } position: absolute; width: 100%; padding: 0 0; height: 100%; z-index: 3; display: flex; align-items: center;
.goods-info{ width: 100%; display: flex; padding:0 20upx; .img{ width: 22vw; height: 22vw; border-radius: 10upx; overflow: hidden; flex-shrink: 0; margin-right: 10upx; image{ width: 22vw; height: 22vw; } } .info{ width: 100%; height: 22vw; overflow: hidden; display: flex; flex-wrap: wrap; position: relative; .title{ width: 100%; font-size: 28upx; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; // text-align: justify;
overflow: hidden; } .spgg{ font-size: 25upx; background-color: #f3f3f3; color: #a7a7a7; border-radius: 15upx; margin-bottom: 10vw; } // .spec{
// font-size: 25upx;
// background-color: #f3f3f3;
// color: #a7a7a7;
// height: 30upx;
// display: flex;
// align-items: center;
// padding: 0 10upx;
// border-radius: 15upx;
// margin-bottom: 10vw;
// }
.spbz{ font-size: 25upx; color: #a7a7a7; height: 30upx; display: flex; align-items: center; padding: 0 10upx; margin-bottom: 10vw; } .kucun{ font-size: 25upx; position: absolute; width: 100%; top: 88upx; padding: 0 10upx; border-radius: 15upx; margin-bottom: 10vw; } .price-number{ position: absolute; width: 100%; bottom: 0upx; display: flex; justify-content: space-between; align-items: flex-end; font-size: 28upx; height: 60upx; .price{ } .deltip{ position: absolute; right: 0; top: -53rpx; color: #B4B4B4; margin-right: 8rpx; } .number{ display: flex; justify-content: center; align-items: flex-end; .input{ width: 100upx; height: 60upx; margin: 0 10upx; border-bottom: 1upx #ADADAD solid; input{ width: 100upx; height: 60upx; display: flex; justify-content: center; align-items: center; text-align: center; font-size: 26upx; } } .sub ,.add{ width: 45upx; height: 45upx; background-color: #f3f3f3; border-radius: 5upx; .icon{ font-size: 22upx; width: 45upx; height: 45upx; display: flex; justify-content: center; align-items: center; } } } } } } } } } .footer{ width: 100%; padding: 0 4%; background-color: #fbfbfb; height: 100upx; display: flex; justify-content: space-between; align-items: center; font-size: 28upx; position: fixed; bottom: 0upx; z-index: 5; .delBtn{ border: solid 1upx #f06c7a; color: #f06c7a; padding: 0 30upx; height: 50upx; border-radius: 30upx; display: flex; justify-content: center; align-items: center; } .settlement{ width: 50%; display: flex; justify-content: flex-end; align-items: flex-end; .sum{ width: 50%; font-size: 28upx; margin-right: 10upx; display: flex; justify-content: flex-end; .money{ font-weight: 600; } } .btn{ padding: 0 20upx; height: 50upx; background-color: #f06c7a; color: #fff; justify-content: center; align-items: center; display: flex; border-radius: 30upx; } } .settlement1{ width: 50%; display: flex; justify-content: flex-start; align-items: flex-start; .sum{ width: 50%; font-size: 28upx; margin-right: 10upx; display: flex; justify-content: flex-end; .money{ font-weight: 600; } } .btn_gray{ padding: 0 20upx; height: 50upx; background-color: #C4C4C4; color: #fff; display: flex; justify-content: center; align-items: center; // width: 180upx;
border-radius: 30upx; } } } </style>
|