replace-take.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <template>
  2. <view class="replace-take-box iPhone-bottom flex-common-css box-border-box bgc-f">
  3. <view class="nav-box">
  4. <image class="bg-img" src="@/static/img/takeout/dq-bg.png" mode="scaleToFill"></image>
  5. <Nav :leftShow='false' :customNav='true' bgckgroundBox='transparent'>
  6. <template>
  7. <view slot="custom" class="align-items-center">
  8. <uni-icons type="left" size="20" @click="toBack()"></uni-icons>
  9. <view class="w-390 text-overflow-ellipsis-one fs-36 fw-400">{{schoolData.school_name}}</view>
  10. </view>
  11. </template>
  12. </Nav>
  13. <view :class="addressData.id?'bottom-124':''" class="address-box align-items-center box-border-box plr-24" @click="selectFun()">
  14. <view v-if="!addressData.site_id" class="address-1 flex-justify-space align-items-center">
  15. <view class="align-items-center">
  16. <image class="qu-image" src="@/static/img/takeout/qu-icon.png" mode=""></image>
  17. <view class="fw-600 fs-40">请选择站点</view>
  18. </view>
  19. <image class="address-box-right" src="@/static/img/toRight.png" mode=""></image>
  20. </view>
  21. <view v-else class="address-2 flex-justify-space align-items-center">
  22. <view class="display-flex">
  23. <image class="address-img mr-20" :src="addressData.site_logo" mode="scaleToFill"></image>
  24. <view class="">
  25. <view class="w-474 fs-40 fw-600 mb-4">{{addressData.site_name}}</view>
  26. <view class="w-474 fw-400 fs-26 fc-9">{{addressData.site_address}}</view>
  27. </view>
  28. </view>
  29. <image class="address-box-right" src="@/static/img/toRight.png" mode=""></image>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="scroll-view-css list-box box-border-box plr-24">
  34. <view class="mb-32" :class="addressData.id?'h-120':'h-60'"></view>
  35. <view class="list-box-b mb-48">
  36. <view class="fs-36 fw-600 mb-22">快递类型</view>
  37. <view class="list-item flex-justify-space" v-for="(item,i) in list" :key="i">
  38. <image :src="item.serve_image" mode="scaleToFill"></image>
  39. <view class="flex-1">
  40. <view class="fs-32 fw-600 mb-32 ">{{item.serve_name}}</view>
  41. <view class="fs-24 fw-400 mb-32 fc-9">{{item.serve_desc}}</view>
  42. <!-- <view class="fs-24 fw-400 mb-4 fc-9">销量2801</view> -->
  43. <view class="flex-justify-space">
  44. <view class="">
  45. <span class="fw-4 fc-FB3D03 fs-24">¥</span>
  46. <span class="fw-b fc-FB3D03 fs-40">{{item.price}}</span>
  47. <span class="fw-400 fc-9 fs-24">/份</span>
  48. </view>
  49. <view class="display-flex align-items-center">
  50. <view v-if="item.number > 0" class="right-only-right-red fw-500 text-align-center fs-36 fc-f" @click="redNumber(1,item)">-</view>
  51. <view v-if="item.number > 0" class="right-only-right-2 text-align-center fs-28 fw-400">{{item.number}}</view>
  52. <view class="right-only-right-add fw-500 text-align-center fs-36 fc-f" @click="addNumber(1,item)">+</view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="">
  59. <view class="fs-36 fw-600 mb-22">取件码({{pickup_code.length}})</view>
  60. <view class="mb-20" v-for="(item,i) in pickup_code" :key="i">
  61. <input class="input-num" v-model="item.code" type="text" placeholder="未输入取件码" placeholder-class="input-p">
  62. </view>
  63. </view>
  64. </view>
  65. <view class="shop-buttom-money box-border-box" >
  66. <view class="shop-buttom-money-1 flex-justify-space align-items-center">
  67. <image src="@/static/img/takeout/buy-icon.png" mode="scaleToFill" @click="openBuyCrad()"></image>
  68. <view class="shop-buttom-num fs-24 fc-f text-align-center" @click="openBuyCrad()">{{cardData.total_num}}</view>
  69. <view class="" @click="openBuyCrad()">
  70. <span class="fw-600 fs-24 fc-f">¥</span>
  71. <span class="fw-600 fs-44 fc-f">{{cardData.total_price||0}}</span>
  72. </view>
  73. <view class="shop-buttom-money-2 text-align-center fs-32 fc-f fw-600" @click="createOrder()">去结算</view>
  74. </view>
  75. </view>
  76. <uni-popup ref="popupBuy" type="bottom" style="z-index: 200;">
  77. <view class="buy-card flex-index-css">
  78. <view class="buy-card-top box-border-box plr-32 flex-justify-space align-items-center">
  79. <view class="">
  80. <span class="fs-32 fc-3 mr-12">已选商品</span>
  81. </view>
  82. <view class="fs-28 fw-400 fc-9 align-items-center">
  83. <view class="">
  84. <uni-icons type="trash" size="18" color="#999"></uni-icons>
  85. </view>
  86. <view class="fs-28 fw-400 fc-9" @click="cardAllDel()">清空</view>
  87. </view>
  88. </view>
  89. <view class="scroll-view-css box-border-box p-32">
  90. <view class="buy-card-item display-flex" v-for="(item,i) in cardData.goods_list" :key="i">
  91. <image :src="item.serve_image" mode="aspectFill"></image>
  92. <view class="flex-1">
  93. <view class="w-514 text-overflow-ellipsis-one fs-34 fw-600 mb-12">{{item.serve_name}}</view>
  94. <view class="w-514 text-overflow-ellipsis-one fs-24 fw-400 fc-9 mb-18">{{item.serve_desc}}</view>
  95. <view class="flex-justify-space">
  96. <view class="">
  97. <span class="fs-24 fc-FB3D03 fw-400">¥</span>
  98. <span class="fs-40 fc-FB3D03 fw-b">{{item.price}}</span>
  99. </view>
  100. <view class="display-flex align-items-center">
  101. <view class="right-only-right-red fw-500 text-align-center fs-36 fc-f" @click="redNumber(2,item)">-</view>
  102. <view class="right-only-right-2 text-align-center fs-28 fw-400">{{item.number}}</view>
  103. <view class="right-only-right-add fw-500 text-align-center fs-36 fc-f" @click="addNumber(2,item)">+</view>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. <view class="shop-buttom-money box-border-box" @click="createOrder()">
  110. <view class="shop-buttom-money-1 flex-justify-space align-items-center">
  111. <image src="@/static/img/takeout/buy-icon.png" mode="scaleToFill"></image>
  112. <view class="shop-buttom-num fs-24 fc-f text-align-center">{{cardData.total_num}}</view>
  113. <view class="">
  114. <view class="">
  115. <span class="fw-600 fs-24 fc-f">¥</span>
  116. <span class="fw-600 fs-44 fc-f">{{cardData.total_price||0}}</span>
  117. </view>
  118. </view>
  119. <view class="shop-buttom-money-2 text-align-center fs-32 fc-f fw-600">去结算</view>
  120. </view>
  121. </view>
  122. </view>
  123. </uni-popup>
  124. </view>
  125. </template>
  126. <script>
  127. import tools from "@/service/tools";
  128. import {getExpressServe} from '@/api/express.js';
  129. import {setShopIngAdd,setShopIngNumber,setShopIngDel,getShopIngList} from '@/api/shopping.js'
  130. export default {
  131. data(){
  132. return{
  133. schoolData:{
  134. school_id:'',
  135. school_name:'',
  136. },
  137. addressData:{
  138. site_id:'',
  139. site_name:'',
  140. site_address:'',
  141. site_logo:'',
  142. },
  143. list:[],
  144. isAJAX:false,
  145. pickup_code:[],
  146. cardData:{
  147. goods_list:[],
  148. total_num:0,
  149. total_price:0,
  150. },
  151. }
  152. },
  153. onShow() {
  154. this.list = [];
  155. this.pickup_code = [];
  156. this.cardData = {
  157. goods_list:[],
  158. total_num:0,
  159. total_price:0,
  160. },
  161. this.schoolData.school_id = uni.getStorageSync('school_id');
  162. this.schoolData.school_name = uni.getStorageSync('school_name');
  163. this.addressData.site_id = uni.getStorageSync('site_id');
  164. this.addressData.site_name = uni.getStorageSync('site_name');
  165. this.addressData.site_address = uni.getStorageSync('site_address');
  166. this.addressData.site_logo = uni.getStorageSync('site_logo');
  167. this.getList();
  168. },
  169. methods:{
  170. getList(){
  171. getExpressServe().then((res)=>{
  172. if(res.code === 1){
  173. this.list = res.data;
  174. this.list.forEach((v)=>{
  175. v.number = 0
  176. })
  177. this.getCard();
  178. }
  179. })
  180. },
  181. getCard(){
  182. getShopIngList({type:2}).then((res)=>{
  183. if(res.code === 1){
  184. this.cardData = res.data;
  185. if(this.cardData.total_num > 0){
  186. this.cardData.goods_list.forEach(v=>{
  187. this.list.forEach(t=>{
  188. if(v.goods_id === t.id){
  189. t.number = v.number
  190. }else{
  191. t.number = 0
  192. }
  193. })
  194. })
  195. for (let i = 0; i < this.cardData.total_num; i++) {
  196. let obj = {code:''};
  197. this.pickup_code.push(obj);
  198. }
  199. }else{
  200. this.list.forEach(t=>{
  201. t.number = 0;
  202. })
  203. }
  204. }
  205. })
  206. },
  207. resetCard(){
  208. getShopIngList({type:2}).then((res)=>{
  209. if(res.code === 1){
  210. this.cardData = res.data;
  211. if(this.cardData.total_num > 0){
  212. this.cardData.goods_list.forEach(v=>{
  213. this.list.forEach(t=>{
  214. if(v.goods_id === t.id){
  215. t.number = v.number
  216. }else{
  217. t.number = 0
  218. }
  219. })
  220. })
  221. }else{
  222. this.list.forEach(t=>{
  223. t.number = 0;
  224. })
  225. }
  226. }
  227. })
  228. },
  229. toBack(){
  230. tools.leftClick()
  231. },
  232. selectFun(){
  233. uni.navigateTo({
  234. url:'pages-takeout/replace-mod/select-site?site_id=' + this.addressData.site_id
  235. })
  236. },
  237. openBuyCrad(){
  238. if(!this.addressData.site_id){
  239. tools.error('请选择站点')
  240. }else{
  241. this.$refs.popupBuy.open()
  242. }
  243. },
  244. createOrder(){
  245. let flag = this.pickup_code.every((item)=>{return item.code});
  246. if(flag){
  247. let arr = [];
  248. this.pickup_code.forEach((v)=>{
  249. arr.push(v.code)
  250. })
  251. let pickup_code = arr.join(',')
  252. uni.navigateTo({
  253. url:'pages-takeout/confirm-order?pickup_code=' + pickup_code + '&type=2'
  254. })
  255. }else{
  256. tools.error('请输入取件码')
  257. }
  258. },
  259. addNumber(type,item){
  260. if(this.isAJAX){
  261. return
  262. }
  263. this.isAJAX = true;
  264. let id = type == 1?item.id:item.goods_id;
  265. setShopIngAdd({type:2,goods_id:id}).then((res)=>{
  266. if(res.code === 1){
  267. this.isAJAX = false;
  268. item.number += 1;
  269. let obj = {code:''};
  270. this.pickup_code.push(obj);
  271. this.$forceUpdate();
  272. this.resetCard();
  273. }else{
  274. this.isAJAX = false;
  275. tools.error('添加操作失败')
  276. }
  277. })
  278. },
  279. redNumber(type,item){
  280. if(item.number > 0){
  281. if(this.isAJAX){
  282. return
  283. }
  284. this.isAJAX = true;
  285. let id = type == 1?item.id:item.goods_id;
  286. setShopIngNumber({type:2,goods_id:id,operation:2}).then((res)=>{
  287. if(res.code === 1){
  288. this.isAJAX = false;
  289. item.number -= 1;
  290. this.pickup_code.pop();
  291. this.$forceUpdate();
  292. this.resetCard();
  293. }else{
  294. this.isAJAX = false;
  295. tools.error('减少操作失败')
  296. }
  297. })
  298. }else{
  299. tools.error('已无可减少商品')
  300. }
  301. },
  302. cardAllDel(){
  303. setShopIngDel({type:2}).then((res)=>{
  304. if(res.code === 1){
  305. this.pickup_code = [];
  306. this.getCard();
  307. }else{
  308. tools.error('清空失败')
  309. }
  310. })
  311. },
  312. }
  313. }
  314. </script>
  315. <style scoped lang="scss">
  316. .replace-take-box{
  317. .h-80{
  318. width: 470rpx;
  319. height: 88rpx;
  320. }
  321. .right-only-right-red{
  322. width: 44rpx;
  323. height: 44rpx;
  324. line-height: 40rpx;
  325. border-radius: 12rpx;
  326. border: 1rpx solid #41ABF5;
  327. color: #41ABF5;
  328. }
  329. .right-only-right-add{
  330. width: 44rpx;
  331. height: 44rpx;
  332. line-height: 40rpx;
  333. background: linear-gradient( 117deg, #57CAFF 0%, #41ABF5 100%);
  334. border-radius: 12rpx;
  335. }
  336. .right-only-right-2{
  337. min-width: 50rpx;
  338. }
  339. .w-514{
  340. width: 514rpx;
  341. }
  342. .buy-card{
  343. z-index: 200;
  344. height: 828rpx;
  345. background-color: #fff;
  346. border-radius: 24rpx 24rpx 0rpx 0rpx;
  347. .buy-card-top{
  348. width: 100%;
  349. height: 92rpx;
  350. background: #FCF5DB;
  351. border-radius: 24rpx 24rpx 0rpx 0rpx;
  352. }
  353. .buy-card-item{
  354. width: 100%;
  355. height: 176rpx;
  356. margin-bottom: 32rpx;
  357. image{
  358. width: 152rpx;
  359. height: 152rpx;
  360. border-radius: 12rpx;
  361. margin-right: 20rpx;
  362. }
  363. }
  364. }
  365. .h-120{
  366. height: 120rpx;
  367. }
  368. .h-60{
  369. height: 60rpx;
  370. }
  371. .w-474{
  372. width: 474rpx;
  373. }
  374. .w-390{
  375. width: 390rpx;
  376. margin-left: 38rpx;
  377. }
  378. .nav-box{
  379. height: 490rpx;
  380. position: relative;
  381. .bg-img{
  382. position: absolute;
  383. top: 0;
  384. left: 0;
  385. width: 100%;
  386. height: 490rpx;
  387. // z-index: -1;
  388. }
  389. .bottom-124{
  390. bottom: -124rpx !important;
  391. }
  392. .address-box{
  393. z-index: 100;
  394. position: absolute;
  395. bottom: -64rpx;
  396. left: 24rpx;
  397. box-sizing: border-box;
  398. width: 702rpx;
  399. min-height: 136rpx;
  400. background: linear-gradient( 182deg, #F1F9FF 0%, #FFFFFF 100%);
  401. box-shadow: 0rpx 0rpx 40rpx 0rpx rgba(172,210,235,0.19);
  402. border-radius: 20rpx;
  403. border-image: linear-gradient(167deg, rgba(255, 255, 255, 1), rgba(208, 236, 255, 0.61)) 2 2;
  404. .address-1{
  405. width: 100%;
  406. .qu-image{
  407. width: 40rpx;
  408. height: 49rpx;
  409. margin: 10rpx 10rpx 0 0;
  410. }
  411. }
  412. .address-2{
  413. box-sizing: border-box;
  414. padding:32rpx 0;
  415. }
  416. .address-img{
  417. width: 100rpx;
  418. height: 100rpx;
  419. border-radius: 8rpx;
  420. }
  421. .address-box-right{
  422. width: 32rpx;
  423. height: 32rpx;
  424. }
  425. }
  426. }
  427. .shop-buttom-money{
  428. width: 100%;
  429. height: 140rpx;
  430. background: rgba(255,255,255,0.8);
  431. padding: 20rpx 24rpx;
  432. .shop-buttom-money-1{
  433. width: 100%;
  434. height: 100%;
  435. background: #333333;
  436. border-radius: 200rpx;
  437. box-sizing: border-box;
  438. padding-left: 136rpx;
  439. // padding-right: 32rpx;
  440. position: relative;
  441. image{
  442. position: absolute;
  443. bottom: 0;
  444. left: 8rpx;
  445. width: 128rpx;
  446. height: 128rpx;
  447. }
  448. .shop-buttom-num{
  449. width: 32rpx;
  450. height: 32rpx;
  451. line-height: 32rpx;
  452. background: #FB3D03;
  453. border-radius: 50%;
  454. position: absolute;
  455. top: 36rpx;
  456. left: 82rpx;
  457. }
  458. .shop-buttom-money-2{
  459. width: 200rpx;
  460. height: 100rpx;
  461. line-height: 100rpx;
  462. background: #41ABF5;
  463. border-radius: 0rpx 200rpx 200rpx 0rpx;
  464. }
  465. }
  466. }
  467. .list-box{
  468. .list-box-b{
  469. border-bottom: 1rpx solid #f9f9f9;
  470. }
  471. .list-item{
  472. width: 100%;
  473. min-height: 100rpx;
  474. margin-bottom: 50rpx;
  475. image{
  476. width: 200rpx;
  477. height: 200rpx;
  478. border-radius: 20rpx;
  479. margin-right: 20rpx;
  480. }
  481. }
  482. .input-num{
  483. width: 100%;
  484. height: 92rpx;
  485. box-sizing: border-box;
  486. padding: 0 24rpx;
  487. background: #F6F6F6;
  488. border-radius: 20rpx;
  489. font-size: 32rpx;
  490. }
  491. .input-p{
  492. font-weight: 400;
  493. font-size: 28rpx;
  494. color: #FB3D03;
  495. }
  496. }
  497. }
  498. </style>