confirm.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. <template>
  2. <!-- v-if="info.id" -->
  3. <view class="page" >
  4. <view class="pro-sec flex-row justify-between section_3">
  5. <view class="flex-row">
  6. <image :src="info.goods_img" class="image_5" mode="aspectFill" />
  7. <view class="flex-col group_7">
  8. <view class="flex-col items-start">
  9. <text class="text_2 clamp">{{info.goods_name}}</text>
  10. <view class="stars align-center"><image src="/static/mang_star.png" class="image_6" v-for="(item, idx) in info.rank" :key="idx" /></view>
  11. </view>
  12. <view class="group_9">
  13. <text class="text_3">¥</text>
  14. <text class="text_4">{{info.shop_price}}</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="flex-col items-end group_10">
  19. <text class="text_7">随机搭配</text>
  20. <!-- <text class="text_8">*1</text> -->
  21. <uni-number-box
  22. class="step"
  23. :min="1"
  24. :max="stock"
  25. :disabled="number >= stock"
  26. :value="number"
  27. :isMax="number >= stock ? true : false"
  28. :isMin="number === 1"
  29. @eventChange="numberChange"
  30. ></uni-number-box>
  31. </view>
  32. </view>
  33. <view class="loc-sec flex-col">
  34. <view class="flex-row section_5">
  35. <view class="flex-col items-start group_11">
  36. <text class="text_9 clamp">{{info.shop_name}}</text>
  37. <text class="text_11 clamp2">{{info.full_address}}</text>
  38. </view>
  39. <view class="align-center group_12" @tap="makePhone">
  40. <view class="section_6"></view>
  41. <image
  42. src="/static/confirm-phone.png"
  43. class="image_7"
  44. />
  45. </view>
  46. </view>
  47. <view class="flex-row justify-between group_13" @tap="navTo('/pages/address/address',{sourcePage:'mang'},{isCheckLogin:true})">
  48. <text class="text_12">您的地址</text>
  49. <view class="flex-row" >
  50. <text class="text_14 clamp" :class="{active: addrInfo.address}">{{addrInfo.address? addrInfo.address : '请选择'}}</text>
  51. <image
  52. src="/static/confirm-rarrow.png"
  53. class="image_8"
  54. />
  55. </view>
  56. </view>
  57. <view class="flex-row justify-between group_13" @tap="openTime">
  58. <text class="text_12">自提时间</text>
  59. <view class="flex-row" >
  60. <text class="text_14" :class="{active: show_time}">{{show_time? show_time : '请选择'}}</text>
  61. <image
  62. src="/static/confirm-rarrow.png"
  63. class="image_8"
  64. />
  65. </view>
  66. </view>
  67. </view>
  68. <view class="price-sec flex-col">
  69. <view class="flex-row justify-between group_15">
  70. <text class="text_16">商品总额</text>
  71. <text class="text_17">¥{{total}}</text>
  72. </view>
  73. <view class="flex-row justify-between group_13" @tap="showCoupons">
  74. <text class="text_12">优惠券</text>
  75. <view class="flex-row group_16" >
  76. <text class="text_14" :class="{active: coupon_price>0}">{{ coupon_price>0 ? `-${coupon_price}`: '请选择'}}</text>
  77. <image
  78. src="/static/confirm-rarrow.png"
  79. class="image_8"
  80. />
  81. </view>
  82. </view>
  83. </view>
  84. <view class="note-sec flex-col">
  85. <text class="text_20">订单备注</text>
  86. <view class="flex-col items-start text-wrapper">
  87. <textarea class="area" placeholder="请输入备注信息" v-model="remark"></textarea>
  88. </view>
  89. </view>
  90. <safeArea height="128rpx">
  91. <template v-slot:btn>
  92. <view class="btn-wrap justify-between">
  93. <view class="align-center group_17">
  94. <text class="text_22">待支付</text>
  95. <view class="group_18 align-center">
  96. <text class="text_23">¥</text>
  97. <text class="text_24 clamp">{{realTotal}}</text>
  98. </view>
  99. </view>
  100. <view class="flex-col items-center text-wrapper_1" :class="{disabled: isSubmitted}" @tap="$tools.throttle(submit)"><text class="text_25">立即支付</text></view>
  101. </view>
  102. </template>
  103. </safeArea>
  104. <datetime @rundata="getTime" ref="timeRef" :end='enddate' :start='startdate' default='start'></datetime>
  105. <popup ref="couponRef" type="bottom">
  106. <view class="coupon-panel">
  107. <view class="cancel-wrap align-center justify-center">
  108. <text class="zicon zicon-quxiao ic" @tap="hideCoupons"></text>
  109. </view>
  110. <view class="title-wrap">
  111. 选择优惠券
  112. </view>
  113. <view class="content-wrap">
  114. <scroll-view scroll-y="true" class="scroll">
  115. <view class="item flex-col justify-center"
  116. v-for="(item,idx) in couponList" :key="idx"
  117. @tap="tapCoupon(idx)"
  118. >
  119. <view class="name clamp">{{item.title}}</view>
  120. <view class="tips">
  121. <text class="stxt">消费金额</text>
  122. <text class="mtxt">{{item.handel_des}}</text>
  123. </view>
  124. </view>
  125. </scroll-view>
  126. </view>
  127. </view>
  128. </popup>
  129. </view>
  130. </template>
  131. <script>
  132. import uniNumberBox from './components/uni-number-box.vue';
  133. import datetime from './components/datetime.vue';
  134. export default {
  135. components: {
  136. uniNumberBox,
  137. datetime
  138. },
  139. data() {
  140. return {
  141. id:'', //盲盒id
  142. shopId:'', //店铺id
  143. info:{},
  144. stock: 1000000,
  145. number: 1,
  146. couponList: [], //优惠券列表
  147. useCouponIndex: -1,
  148. coupon_price: 0.0, //优惠券金额
  149. total: 0.0 ,//总额
  150. realTotal:0.0,//实付金额
  151. startdate: '',
  152. enddate: '2042-05-30 23:59',
  153. show_time:'', //自提时间
  154. address:{},
  155. remark:'',
  156. pay_type: '', //1=余额支付,2微信支付
  157. };
  158. },
  159. async onLoad(e) {
  160. let date = new Date();
  161. this.startdate = this.$tools.handleDateTime(date);
  162. this.id =e.id;
  163. this.shopId = e.shopId;
  164. await this.getInfo();
  165. this.number = 1;
  166. this.stock = this.info.num;
  167. this.calcTotal();
  168. },
  169. methods: {
  170. async getInfo(){
  171. let sendData={
  172. goods_id:this.id,
  173. lng: this.addrInfo.address ? this.addrInfo.address_lng : '',
  174. lat: this.addrInfo.address ? this.addrInfo.address_lat : '',
  175. }
  176. let res = await this.$request('goods.info',sendData);
  177. this.info = res.data.goods_info;
  178. },
  179. //数量
  180. async numberChange(data) {
  181. this.number = data.number;
  182. this.calcTotal();
  183. },
  184. makePhone(){
  185. uni.makePhoneCall({
  186. phoneNumber: this.info.shop_mobile
  187. })
  188. },
  189. // 计算价格
  190. calcTotal() {
  191. let price = parseFloat(this.info.shop_price).toFixed(2);
  192. let number = this.number; // 产品数量
  193. this.total = price * number;
  194. this.realTotal = price * number;
  195. // 检查当前优惠券是否满足使用条件
  196. this.coupon_price = 0.0;
  197. if (this.useCouponIndex != -1 && this.couponList && this.couponList[this.useCouponIndex]) {
  198. this.coupon_price = this.couponList[this.useCouponIndex].money;
  199. if (this.total >= this.couponList[this.useCouponIndex].min_money) {
  200. this.realTotal = this.total - this.coupon_price;
  201. } else {
  202. this.$tools.msg('选中的优惠券不满足使用条件', 2000);
  203. this.useCouponIndex = -1; //取消选中的优惠券
  204. this.coupon_price = 0; //设置优惠金额为0
  205. this.realTotal = this.total - this.coupon_price;
  206. }
  207. }
  208. },
  209. getTime(e){
  210. this.show_time=e;
  211. // var date= new Date(e.replace(/-/g, "/"));
  212. },
  213. openTime(){
  214. this.$refs.timeRef.open();
  215. },
  216. async showCoupons(){
  217. let sendData = {
  218. shop_id: this.shopId,
  219. total_amount: this.total,
  220. }
  221. let res = await this.$request('goods.shopCoupons',sendData);
  222. this.couponList = res.data;
  223. this.$refs.couponRef.show();
  224. },
  225. hideCoupons(){
  226. this.$refs.couponRef.hide();
  227. },
  228. tapCoupon(idx){
  229. this.hideCoupons();
  230. if(idx === this.useCouponIndex){
  231. return;
  232. }
  233. this.useCouponIndex = idx;
  234. this.calcTotal();
  235. },
  236. async submit(){
  237. if(!this.addrInfo.id){
  238. this.$tools.msg('请选择您的地址')
  239. return;
  240. }else if(! this.show_time){
  241. this.$tools.msg('请输入自提时间')
  242. return;
  243. }
  244. let sendData={
  245. id:this.id,
  246. shop_id:this.shopId,
  247. buy_number: this.number,
  248. self_hours:this.show_time,
  249. coupon_id: this.useCouponIndex !== -1 ? this.couponList[this.useCouponIndex].id : '',
  250. address_id: this.addrInfo.id,
  251. remark: this.remark,
  252. }
  253. let res=await this.$request('order.add',sendData);
  254. this.navTo('/pages/public/pay',{orderId:res.data.id})
  255. },
  256. }
  257. };
  258. </script>
  259. <style lang="scss">
  260. page {
  261. background-color: #f8f8f8;
  262. }
  263. .page {
  264. padding: 20rpx 30rpx;
  265. }
  266. .pro-sec {
  267. padding: 22rpx 17rpx 24rpx 20rpx;
  268. background-color: #ffffff;
  269. box-shadow: 0px 6rpx 10rpx #2a2a2a14;
  270. border-radius: 20rpx;
  271. margin-bottom: 20rpx;
  272. position: relative;
  273. .image_5 {
  274. width: 154rpx;
  275. height: 154rpx;
  276. }
  277. .group_7 {
  278. margin-left: 15rpx;
  279. margin-bottom: 10rpx;
  280. }
  281. .text_2 {
  282. color: #333333;
  283. font-size: 30rpx;
  284. font-family: PingFang;
  285. max-width: 370rpx;
  286. }
  287. .image_6 {
  288. margin-top: 10rpx;
  289. width: 28rpx;
  290. height: 28rpx;
  291. margin-right: 4rpx;
  292. }
  293. .group_9 {
  294. margin-top: 51rpx;
  295. align-self: flex-start;
  296. line-height: 28rpx;
  297. }
  298. .text_3 {
  299. color: #fc4d37;
  300. font-size: 30rpx;
  301. font-family: PingFang;
  302. letter-spacing: 1.2rpx;
  303. }
  304. .text_4 {
  305. color: #fc4d37;
  306. font-size: 36rpx;
  307. font-family: PingFang;
  308. letter-spacing: 1.44rpx;
  309. }
  310. .group_10 {
  311. margin: 4rpx 0 5rpx;
  312. }
  313. .text_7 {
  314. color: #999999;
  315. font-size: 24rpx;
  316. font-family: PingFang;
  317. }
  318. .text_8 {
  319. margin-top: 106rpx;
  320. color: #999999;
  321. font-size: 24rpx;
  322. font-family: PingFang;
  323. line-height: 18rpx;
  324. }
  325. .step {
  326. margin-top: 86rpx;
  327. }
  328. }
  329. .loc-sec{
  330. margin-top: 24rpx;
  331. padding: 30rpx 20rpx 0 24rpx;
  332. background-color: #ffffff;
  333. box-shadow: 0px 6rpx 10rpx #2a2a2a14;
  334. border-radius: 20rpx;
  335. .section_5 {
  336. padding: 27rpx 20rpx 24rpx;
  337. background-color: #f7f7f7;
  338. border-radius: 10rpx;
  339. }
  340. .group_11 {
  341. margin-bottom: 6rpx;
  342. flex: 1 1 auto;
  343. }
  344. .text_9 {
  345. color: #333333;
  346. font-size: 30rpx;
  347. font-family: PingFang;
  348. max-width: 500rpx;
  349. }
  350. .text_11 {
  351. margin-top: 20rpx;
  352. color: #666666;
  353. font-size: 24rpx;
  354. font-family: PingFang;
  355. line-height: 36rpx;
  356. max-width: 500rpx;
  357. }
  358. .group_12 {
  359. margin-left: 40rpx;
  360. margin-right: 10rpx;
  361. flex-shrink: 0;
  362. }
  363. .section_6 {
  364. background-color: #0000001a;
  365. width: 1rpx;
  366. height: 80rpx;
  367. }
  368. .image_7 {
  369. margin-left: 30rpx;
  370. align-self: center;
  371. width: 48rpx;
  372. height: 48rpx;
  373. }
  374. .group_13 {
  375. padding: 40rpx 0;
  376. border-bottom: 2rpx solid #eee;
  377. &:last-child{
  378. border: none;
  379. }
  380. }
  381. .text_12 {
  382. color: #333333;
  383. font-size: 30rpx;
  384. font-family: PingFang;
  385. line-height: 28rpx;
  386. letter-spacing: 1.2rpx;
  387. }
  388. .text_14 {
  389. color: #999999;
  390. font-size: 28rpx;
  391. font-family: PingFang;
  392. max-width: 400rpx;
  393. &.active{
  394. color: #333;
  395. }
  396. }
  397. .image_8 {
  398. margin: 4rpx 0 4rpx 11rpx;
  399. flex-shrink: 0;
  400. width: 10rpx;
  401. height: 18rpx;
  402. }
  403. }
  404. .price-sec{
  405. margin-top: 24rpx;
  406. padding-left: 21rpx;
  407. padding-right: 12rpx;
  408. background-color: #ffffff;
  409. box-shadow: 0px 6rpx 10rpx #2a2a2a14;
  410. border-radius: 20rpx;
  411. .group_15 {
  412. padding: 40rpx 0;
  413. border-bottom: solid 2rpx #0000001a;
  414. }
  415. .text_16 {
  416. color: #333333;
  417. font-size: 30rpx;
  418. font-family: PingFang;
  419. letter-spacing: 1.2rpx;
  420. }
  421. .text_17 {
  422. margin-bottom: 3rpx;
  423. color: #333333;
  424. font-size: 30rpx;
  425. font-family: PingFang;
  426. }
  427. .group_13 {
  428. padding: 40rpx 0;
  429. }
  430. .text_12 {
  431. color: #333333;
  432. font-size: 30rpx;
  433. font-family: PingFang;
  434. line-height: 28rpx;
  435. letter-spacing: 1.2rpx;
  436. }
  437. .group_16 {
  438. margin-right: 8rpx;
  439. }
  440. .text_14 {
  441. color: #999999;
  442. font-size: 28rpx;
  443. font-family: PingFang;
  444. line-height: 26rpx;
  445. &.active{
  446. color: #ff342e;
  447. }
  448. }
  449. .image_8 {
  450. margin: 4rpx 0 4rpx 11rpx;
  451. flex-shrink: 0;
  452. width: 10rpx;
  453. height: 18rpx;
  454. }
  455. }
  456. .note-sec{
  457. margin-top: 24rpx;
  458. padding: 40rpx 20rpx 40rpx 21rpx;
  459. background-color: #ffffff;
  460. box-shadow: 0px 6rpx 10rpx #2a2a2a14;
  461. border-radius: 20rpx;
  462. .text_20 {
  463. align-self: flex-start;
  464. color: #333333;
  465. font-size: 30rpx;
  466. font-family: PingFang;
  467. letter-spacing: 1.2rpx;
  468. }
  469. .text-wrapper {
  470. margin-left: 3rpx;
  471. margin-top: 30rpx;
  472. background-color: #f7f7f7;
  473. border-radius: 10rpx;
  474. .area{
  475. padding: 18rpx;
  476. font-size: 24rpx;
  477. color: #333;
  478. line-height: 36rpx;
  479. width: 646rpx;
  480. height: 147rpx;
  481. }
  482. }
  483. }
  484. .btn-wrap{
  485. padding: 32rpx 20rpx 20rpx 29rpx;
  486. background-color: #ffffff;
  487. box-shadow: 0px 0px 14rpx #0000001a;
  488. height: 128rpx;
  489. .group_17 {
  490. align-self: center;
  491. }
  492. .text_22 {
  493. color: #999999;
  494. font-size: 28rpx;
  495. font-family: PingFang;
  496. }
  497. .group_18 {
  498. margin-left: 11rpx;
  499. line-height: 28rpx;
  500. height: 29rpx;
  501. }
  502. .text_23 {
  503. color: #ff342e;
  504. font-size: 28rpx;
  505. font-family: PingFang;
  506. }
  507. .text_24 {
  508. color: #ff342e;
  509. font-size: 36rpx;
  510. font-family: PingFang;
  511. max-width: 320rpx;
  512. }
  513. .text-wrapper_1 {
  514. padding: 24rpx 0 23rpx;
  515. background-color: #92b99c;
  516. border-radius: 38rpx;
  517. width: 228rpx;
  518. height: 76rpx;
  519. &.disabled{
  520. background-color: #eee;
  521. }
  522. }
  523. .text_25 {
  524. color: #ffffff;
  525. font-size: 30rpx;
  526. font-family: PingFang;
  527. }
  528. }
  529. .coupon-panel{
  530. width: 750rpx;
  531. // height: 441rpx;
  532. background: #FFFFFF;
  533. border-radius: 20rpx 20rpx 0rpx 0rpx;
  534. position: relative;
  535. .cancel-wrap{
  536. width: 68rpx;
  537. height: 68rpx;
  538. position: absolute;
  539. right: 0;
  540. top: 0;
  541. z-index: 2;
  542. .ic{
  543. font-size: 24rpx;
  544. color: #999;
  545. }
  546. }
  547. .title-wrap{
  548. height: 92rpx;
  549. line-height: 92rpx;
  550. text-align: center;
  551. font-size: 34rpx;
  552. font-family: PingFang SC;
  553. font-weight: bold;
  554. color: #333333;
  555. }
  556. .content-wrap{
  557. padding: 30rpx;
  558. // padding-bottom: 30rpx + calc( var(--safe-area-inset-bottom) / 2);
  559. .scroll{
  560. min-height: 350rpx;
  561. max-height: 600rpx;
  562. }
  563. .item{
  564. width: 690rpx;
  565. height: 133rpx;
  566. background: #F5F5F5;
  567. border-radius: 10rpx;
  568. margin-bottom: 20rpx;
  569. padding: 0 30rpx;
  570. }
  571. .name{
  572. font-size: 32rpx;
  573. font-family: PingFang SC;
  574. font-weight: bold;
  575. color: #333333;
  576. }
  577. .tips{
  578. margin-top: 24rpx;
  579. font-size: 26rpx;
  580. font-family: PingFang SC;
  581. font-weight: 500;
  582. color: #666666;
  583. .mtxt{
  584. color:$base-color;
  585. }
  586. }
  587. }
  588. }
  589. </style>