You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

637 lines
16 KiB

6 months ago
  1. <template>
  2. <view>
  3. <!-- 占位 -->
  4. <view class="place">现订货量=原订货量+加单数量若要加单5则输入5,减单5则输入-5(新增商品点击页面最下方的新增按钮)</view>
  5. <!-- 商品列表 -->
  6. <view class="goods-list">
  7. <!-- 空白页 -->
  8. <empty v-if="goodsList.length === 0" tip='订单是空的哦'></empty>
  9. <view class="row" v-for="(row,index) in goodsList" :key="index">
  10. <!-- 删除按钮 -->
  11. <view class="menu" @tap.stop="deleteGoods(row.id)">
  12. <view class="icon shanchu"></view>
  13. </view>
  14. <!-- 商品 -->
  15. <view class="carrier" :class="[theIndex==index?'open':oldIndex==index?'close':'']" @touchstart="touchStart(index,$event)" @touchmove="touchMove(index,$event)" @touchend="touchEnd(index,$event)">
  16. <!-- 商品信息 -->
  17. <view class="goods-info">
  18. <view class="img">
  19. <image :src="row.img"></image>
  20. </view>
  21. <view class="info">
  22. <view class="title">{{row.mc}}{{row.gg}}{{row.dw}}</view>
  23. <view class="spbz" style="width: 100%;">
  24. <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="输入备注">
  25. <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="输入副单位">
  26. </view>
  27. <view class="kucun">现订货量{{row.dinghl}} <span style="color: #f06c7a; padding-left: 42px;">原订货量{{row.onedhl}}</span></view>
  28. <view class="price-number" v-if="row.kucun">
  29. <view class="price">{{row.price}}</view>
  30. <view class="number">
  31. <!-- <view class="sub" @tap.stop="sub(index)">
  32. <view class="icon jian"></view>
  33. </view> -->
  34. <view class="input" @tap.stop="discard">
  35. <input type="text" v-model="row.inputnum" placeholder="数量" @input="inputchange($event,row.inputnum,row.id,index)" />
  36. </view>
  37. <!-- <view class="input" @tap.stop="discard">
  38. <input type="digit" v-model="product.inputnum==0?'':product.inputnum" @input="inputchange($event,product.inputnum,product.id,product.kcnum,2)" />
  39. </view> -->
  40. <!-- <view class="add" @tap.stop="add(index)">
  41. <view class="icon jia"></view>
  42. </view> -->
  43. </view>
  44. </view>
  45. <view class="price-number" v-if="!row.kucun">
  46. <view class="deltip">左滑可删除</view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 脚部菜单 -->
  54. <view class="footer" :style="{bottom:footerbottom}">
  55. <view class="settlement1">
  56. <view class="btn_gray" @tap="toAddcp">新增产品</view>
  57. </view>
  58. <view class="settlement">
  59. <!-- <view class="sum">合计:<view class="money">{{sumPrice}}</view></view> -->
  60. <view class="btn" @tap="toConfirmation">提交编辑({{sumSl}})</view>
  61. </view>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import empty from "@/components/empty";
  67. export default {
  68. components: {
  69. empty
  70. },
  71. data() {
  72. return {
  73. sumSl:0,
  74. sumPrice:'0.00',
  75. headerPosition:"fixed",
  76. headerTop:null,
  77. statusTop:null,
  78. selectedList:[],
  79. isAllselected:false,
  80. goodsList:[],
  81. //控制滑动效果
  82. theIndex:null,
  83. oldIndex:null,
  84. isStop:false,
  85. dhid:0,
  86. cpids:'',
  87. cpnums:'',
  88. cpbeizs:'',
  89. delcpids:'',
  90. cpfudws:'',
  91. }
  92. },
  93. onShow() {
  94. },
  95. onPageScroll(e){
  96. //兼容iOS端下拉时顶部漂移
  97. this.headerPosition = e.scrollTop>=0?"fixed":"absolute";
  98. this.headerTop = e.scrollTop>=0?null:0;
  99. this.statusTop = e.scrollTop>=0?null:-this.statusHeight+'px';
  100. },
  101. //下拉刷新,需要自己在page.json文件中配置开启页面下拉刷新 "enablePullDownRefresh": true
  102. onPullDownRefresh() {
  103. setTimeout(function () {
  104. uni.stopPullDownRefresh();
  105. }, 1000);
  106. },
  107. filters: {
  108. toFixed:function(x) {
  109. return parseFloat(x).toFixed(2);
  110. }
  111. },
  112. onLoad(e) {
  113. //兼容H5下结算条位置
  114. // #ifdef H5
  115. this.footerbottom = document.getElementsByTagName('uni-tabbar')[0].offsetHeight+'px';
  116. // #endif
  117. // #ifdef APP-PLUS
  118. this.statusHeight = plus.navigator.getStatusbarHeight();
  119. // #endif
  120. this.dhid=e.dhid;
  121. this.init();
  122. },
  123. methods: {
  124. //去添加加单产品
  125. toAddcp(){
  126. uni.navigateTo({
  127. url:'../category/categoryjiad?dhid='+this.dhid
  128. })
  129. },
  130. async init(){
  131. //本地模拟订单提交UI效果
  132. uni.showLoading({
  133. title:''
  134. })
  135. //提交订单
  136. let userinfo=uni.getStorageSync('userinfo');
  137. let redata=await this.$api.orderdetail({action:'orderdetail',dhid:this.dhid,aid:userinfo.aid});
  138. if(redata.code==1){
  139. this.goodsList = redata.data;
  140. }
  141. uni.hideLoading();
  142. this.sum();
  143. },
  144. //控制左滑删除效果-begin
  145. touchStart(index,event){
  146. //多点触控不触发
  147. if(event.touches.length>1){
  148. this.isStop = true;
  149. return ;
  150. }
  151. this.oldIndex = this.theIndex;
  152. this.theIndex = null;
  153. //初始坐标
  154. this.initXY = [event.touches[0].pageX,event.touches[0].pageY];
  155. },
  156. touchMove(index,event){
  157. //多点触控不触发
  158. if(event.touches.length>1){
  159. this.isStop = true;
  160. return ;
  161. }
  162. let moveX = event.touches[0].pageX - this.initXY[0];
  163. let moveY = event.touches[0].pageY - this.initXY[1];
  164. if(this.isStop||Math.abs(moveX)<5){
  165. return ;
  166. }
  167. if (Math.abs(moveY) > Math.abs(moveX)){
  168. // 竖向滑动-不触发左滑效果
  169. this.isStop = true;
  170. return;
  171. }
  172. if(moveX<0){
  173. this.theIndex = index;
  174. this.isStop = true;
  175. }else if(moveX>0){
  176. if(this.theIndex!=null&&this.oldIndex==this.theIndex){
  177. this.oldIndex = index;
  178. this.theIndex = null;
  179. this.isStop = true;
  180. setTimeout(()=>{
  181. this.oldIndex = null;
  182. },150)
  183. }
  184. }
  185. },
  186. touchEnd(index,$event){
  187. //结束禁止触发效果
  188. this.isStop = false;
  189. },
  190. //控制左滑删除效果-end
  191. //提交订单
  192. async toConfirmation(){
  193. let getuserinfo=uni.getStorageSync('userinfo');
  194. let delcps=this.delcpids.substr(1);
  195. 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});
  196. if(reinfo.code==1){
  197. uni.hideLoading();
  198. uni.showModal({
  199. title: '操作成功',
  200. content: reinfo.msg,
  201. showCancel: false,
  202. success: (res) => {
  203. uni.navigateBack({
  204. url: "/pages/orderlist/orderlist"
  205. })
  206. }
  207. });
  208. }else{
  209. uni.hideLoading();
  210. uni.showToast({title:reinfo.msg,icon:'none',duration: 2000});
  211. }
  212. },
  213. //删除商品
  214. deleteGoods(id){
  215. let len = this.goodsList.length;
  216. for(let i=0;i<len;i++){
  217. if(id==this.goodsList[i].id){
  218. this.goodsList.splice(i, 1);
  219. this.delcpids=this.delcpids+','+id;
  220. break;
  221. }
  222. }
  223. this.selectedList.splice(this.selectedList.indexOf(id), 1);
  224. this.sum();
  225. this.oldIndex = null;
  226. this.theIndex = null;
  227. },
  228. inputchange(e,inputnum, id, index) {
  229. inputnum=e.detail.value;
  230. this.goodsList[index].inputnum=inputnum;
  231. this.sum();
  232. },
  233. // 合计
  234. sum(){
  235. this.sumPrice=0;
  236. let len = this.goodsList.length;
  237. let gids='';
  238. let gnums='';
  239. let gbzs='';
  240. let gfudws='';
  241. for(let i=0;i<len;i++){
  242. gids=gids+','+this.goodsList[i].id;
  243. gnums=gnums+','+this.goodsList[i].inputnum;
  244. gbzs=gbzs+'^'+this.goodsList[i].bz;
  245. gfudws=gfudws+'^'+this.goodsList[i].fudw;
  246. }
  247. this.cpids=gids.substr(1);
  248. this.cpnums=gnums.substr(1);
  249. this.cpbeizs=gbzs.substr(1);
  250. this.cpfudws=gfudws.substr(1);
  251. // this.sumPrice = this.sumPrice.toFixed(2);
  252. this.sumSl=this.goodsList.length;
  253. },
  254. inputchangeBz(e,inputnum, id, index) {
  255. inputnum=e.detail.value;
  256. this.goodsList[index].bz=inputnum;
  257. this.sum();
  258. },
  259. inputchangeFudw(e,inputnum, id, index) {
  260. inputnum=e.detail.value;
  261. this.goodsList[index].fudw=inputnum;
  262. this.sum()
  263. },
  264. discard() {
  265. //丢弃
  266. }
  267. }
  268. }
  269. </script>
  270. <style lang="scss">
  271. page{position: relative;}
  272. @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');}
  273. .icon {
  274. font-family:"HMfont-home" !important;
  275. font-size:60upx;
  276. font-style:normal;
  277. color:#000000;
  278. &.jia {
  279. &:before{content:"\e641";}
  280. }
  281. &.jian {
  282. &:before{content:"\e643";}
  283. }
  284. &.shanchu {
  285. &:before{content:"\e6a4";}
  286. }
  287. }
  288. .checkbox-box{
  289. display: flex;
  290. align-items: center;
  291. .sellq{
  292. font-size: 28upx;
  293. color: #ffffff;
  294. background-color: #C4C4C4;
  295. padding: 5upx 20upx;
  296. text-align: center;
  297. border-radius: 25upx;
  298. }
  299. .checkbox{
  300. width: 35upx;
  301. height: 35upx;
  302. border-radius: 100%;
  303. border: solid 2upx #f06c7a;
  304. display: flex;
  305. justify-content: center;
  306. align-items: center;
  307. .on{
  308. width: 25upx;
  309. height: 25upx;
  310. border-radius: 100%;
  311. background-color: #f06c7a;
  312. }
  313. }
  314. .text{
  315. font-size: 28upx;
  316. margin-left: 10upx;
  317. }
  318. }
  319. .status {
  320. width: 100%;
  321. height: 0;
  322. position: fixed;
  323. z-index: 10;
  324. background-color: #fff;
  325. top: 0;
  326. /* #ifdef APP-PLUS */
  327. height: var(--status-bar-height);//覆盖样式
  328. /* #endif */
  329. }
  330. .header{
  331. width: 92%;
  332. padding: 0 4%;
  333. height: 100upx;
  334. display: flex;
  335. align-items: center;
  336. position: fixed;
  337. top: 0;
  338. z-index: 10;
  339. background-color: #fff;
  340. /* #ifdef APP-PLUS */
  341. top: var(--status-bar-height);
  342. /* #endif */
  343. .title{
  344. font-size: 36upx;
  345. }
  346. }
  347. .place{
  348. background-color: #ffffff;
  349. height: auto;
  350. /* #ifdef APP-PLUS */
  351. margin-top: var(--status-bar-height);
  352. /* #endif */
  353. font-size: 25upx;
  354. color: #999;
  355. padding: 5px 20px 0 20px;
  356. }
  357. .goods-list{
  358. width: 100%;
  359. padding: 20upx 0 120upx 0;
  360. .tis{
  361. width: 100%;
  362. height: 60upx;
  363. display: flex;
  364. justify-content: center;
  365. align-items: center;
  366. font-size: 32upx;
  367. }
  368. .row{
  369. width: calc(92%);
  370. height: calc(22vw + 40upx);
  371. margin: 20upx auto;
  372. border-radius: 15upx;
  373. box-shadow: 0upx 5upx 20upx rgba(0,0,0,0.1);
  374. display: flex;
  375. align-items: center;
  376. position: relative;
  377. overflow: hidden;
  378. z-index: 4;
  379. border: 0;
  380. .menu{
  381. .icon{
  382. color: #fff;
  383. // font-size: 25upx;
  384. }
  385. position: absolute;
  386. width: 30%;
  387. height: 100%;
  388. right: 0;
  389. display: flex;
  390. justify-content: center;
  391. align-items: center;
  392. background-color: red;
  393. color: #fff;
  394. z-index: 2;
  395. }
  396. .carrier{
  397. @keyframes showMenu {
  398. 0% {transform: translateX(0);}100% {transform: translateX(-30%);}
  399. }
  400. @keyframes closeMenu {
  401. 0% {transform: translateX(-30%);}100% {transform: translateX(0);}
  402. }
  403. &.open{
  404. animation: showMenu 0.25s linear both;
  405. }
  406. &.close{
  407. animation: closeMenu 0.15s linear both;
  408. }
  409. background-color: #fff;
  410. .checkbox-box{
  411. padding-left: 20upx;
  412. flex-shrink: 0;
  413. height: 22vw;
  414. margin-right: 20upx;
  415. }
  416. position: absolute;
  417. width: 100%;
  418. padding: 0 0;
  419. height: 100%;
  420. z-index: 3;
  421. display: flex;
  422. align-items: center;
  423. .goods-info{
  424. width: 100%;
  425. display: flex;
  426. padding:0 20upx;
  427. .img{
  428. width: 22vw;
  429. height: 22vw;
  430. border-radius: 10upx;
  431. overflow: hidden;
  432. flex-shrink: 0;
  433. margin-right: 10upx;
  434. image{
  435. width: 22vw;
  436. height: 22vw;
  437. }
  438. }
  439. .info{
  440. width: 100%;
  441. height: 22vw;
  442. overflow: hidden;
  443. display: flex;
  444. flex-wrap: wrap;
  445. position: relative;
  446. .title{
  447. width: 100%;
  448. font-size: 28upx;
  449. display: -webkit-box;
  450. -webkit-box-orient: vertical;
  451. -webkit-line-clamp: 1;
  452. // text-align: justify;
  453. overflow: hidden;
  454. }
  455. .spgg{
  456. font-size: 25upx;
  457. background-color: #f3f3f3;
  458. color: #a7a7a7;
  459. border-radius: 15upx;
  460. margin-bottom: 10vw;
  461. }
  462. // .spec{
  463. // font-size: 25upx;
  464. // background-color: #f3f3f3;
  465. // color: #a7a7a7;
  466. // height: 30upx;
  467. // display: flex;
  468. // align-items: center;
  469. // padding: 0 10upx;
  470. // border-radius: 15upx;
  471. // margin-bottom: 10vw;
  472. // }
  473. .spbz{
  474. font-size: 25upx;
  475. color: #a7a7a7;
  476. height: 30upx;
  477. display: flex;
  478. align-items: center;
  479. padding: 0 10upx;
  480. margin-bottom: 10vw;
  481. }
  482. .kucun{
  483. font-size: 25upx;
  484. position: absolute;
  485. width: 100%;
  486. top: 88upx;
  487. padding: 0 10upx;
  488. border-radius: 15upx;
  489. margin-bottom: 10vw;
  490. }
  491. .price-number{
  492. position: absolute;
  493. width: 100%;
  494. bottom: 0upx;
  495. display: flex;
  496. justify-content: space-between;
  497. align-items: flex-end;
  498. font-size: 28upx;
  499. height: 60upx;
  500. .price{
  501. }
  502. .deltip{
  503. position: absolute;
  504. right: 0;
  505. top: -53rpx;
  506. color: #B4B4B4;
  507. margin-right: 8rpx;
  508. }
  509. .number{
  510. display: flex;
  511. justify-content: center;
  512. align-items: flex-end;
  513. .input{
  514. width: 100upx;
  515. height: 60upx;
  516. margin: 0 10upx;
  517. border-bottom: 1upx #ADADAD solid;
  518. input{
  519. width: 100upx;
  520. height: 60upx;
  521. display: flex;
  522. justify-content: center;
  523. align-items: center;
  524. text-align: center;
  525. font-size: 26upx;
  526. }
  527. }
  528. .sub ,.add{
  529. width: 45upx;
  530. height: 45upx;
  531. background-color: #f3f3f3;
  532. border-radius: 5upx;
  533. .icon{
  534. font-size: 22upx;
  535. width: 45upx;
  536. height: 45upx;
  537. display: flex;
  538. justify-content: center;
  539. align-items: center;
  540. }
  541. }
  542. }
  543. }
  544. }
  545. }
  546. }
  547. }
  548. }
  549. .footer{
  550. width: 100%;
  551. padding: 0 4%;
  552. background-color: #fbfbfb;
  553. height: 100upx;
  554. display: flex;
  555. justify-content: space-between;
  556. align-items: center;
  557. font-size: 28upx;
  558. position: fixed;
  559. bottom: 0upx;
  560. z-index: 5;
  561. .delBtn{
  562. border: solid 1upx #f06c7a;
  563. color: #f06c7a;
  564. padding: 0 30upx;
  565. height: 50upx;
  566. border-radius: 30upx;
  567. display: flex;
  568. justify-content: center;
  569. align-items: center;
  570. }
  571. .settlement{
  572. width: 50%;
  573. display: flex;
  574. justify-content: flex-end;
  575. align-items: flex-end;
  576. .sum{
  577. width: 50%;
  578. font-size: 28upx;
  579. margin-right: 10upx;
  580. display: flex;
  581. justify-content: flex-end;
  582. .money{
  583. font-weight: 600;
  584. }
  585. }
  586. .btn{
  587. padding: 0 20upx;
  588. height: 50upx;
  589. background-color: #f06c7a;
  590. color: #fff;
  591. justify-content: center;
  592. align-items: center;
  593. display: flex;
  594. border-radius: 30upx;
  595. }
  596. }
  597. .settlement1{
  598. width: 50%;
  599. display: flex;
  600. justify-content: flex-start;
  601. align-items: flex-start;
  602. .sum{
  603. width: 50%;
  604. font-size: 28upx;
  605. margin-right: 10upx;
  606. display: flex;
  607. justify-content: flex-end;
  608. .money{
  609. font-weight: 600;
  610. }
  611. }
  612. .btn_gray{
  613. padding: 0 20upx;
  614. height: 50upx;
  615. background-color: #C4C4C4;
  616. color: #fff;
  617. display: flex;
  618. justify-content: center;
  619. align-items: center;
  620. // width: 180upx;
  621. border-radius: 30upx;
  622. }
  623. }
  624. }
  625. </style>