integralOrderPay.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <template>
  2. <view>
  3. <view class="inner-box">
  4. <!-- 收货人 -->
  5. <view class="address-box" v-if="address==null" @click="openAddress()">
  6. <view class="left">
  7. <view class="name-box">
  8. <text class="text name">添加收货地址</text>
  9. </view>
  10. </view>
  11. <view class="arrow-box">
  12. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/arrow_gray.png" mode=""></image>
  13. </view>
  14. </view>
  15. <view class="address-box" v-if="address!=null" @click="openAddress()">
  16. <view class="left">
  17. <view class="name-box">
  18. <text class="text name">{{address.realName}}</text>
  19. <text class="text" v-if="address.phone!=null">{{address.phone}}</text>
  20. </view>
  21. <view class="address">
  22. {{address.address}}
  23. </view>
  24. </view>
  25. <view class="arrow-box">
  26. <image src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/arrow_gray.png" mode=""></image>
  27. </view>
  28. </view>
  29. <!-- 药品列表 -->
  30. <view class="goods-list">
  31. <view class="item">
  32. <view class="img-box">
  33. <image :src="item.imgUrl==''?'https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/drug.svg':item.imgUrl" mode="aspectFill"></image>
  34. </view>
  35. <view class="info-box">
  36. <view>
  37. <view class="name-box ellipsis2">
  38. {{item.goodsName}}
  39. </view>
  40. </view>
  41. <view class="price-num">
  42. <view class="price">
  43. <text class="unit">积分</text>
  44. <text class="num">{{item.integral}}</text>
  45. </view>
  46. <view class="num" >x1</view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="other-info">
  52. <view class="item">
  53. <view class="left">
  54. <text class="label">所需积分:</text>
  55. </view>
  56. <view class="right">
  57. <text class="text">{{item.integral}}</text>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="other-info">
  62. <view class="item">
  63. <view class="left">
  64. <text class="label">我的积分:</text>
  65. </view>
  66. <view class="right">
  67. <text class="text">{{integral}}</text>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <!-- 底部按钮 -->
  73. <view class="btn-box">
  74. <view class="btn" v-if="item!=null" @click="payOrder()">立即兑换</view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. import {getIntegralGoodsById,createOrder} from '@/api/integral.js'
  80. import {getUserInfo} from '@/api/user'
  81. export default {
  82. data() {
  83. return {
  84. addressId:null,
  85. address:null,
  86. orderId:null,
  87. order:null,
  88. item:null,
  89. integral: 0,
  90. }
  91. },
  92. onLoad(option) {
  93. this.goodsId=option.goodsId;
  94. var that=this;
  95. uni.$on('updateAddress', (e) => {
  96. that.addressId=e.addressId;
  97. that.address=e;
  98. that.address.address=e.province+e.city+e.district+e.detail
  99. })
  100. this.getIntegralGoodsById();
  101. this.getUserInfo();
  102. },
  103. onUnload() {
  104. uni.$off('updateAddress')
  105. },
  106. methods: {
  107. getUserInfo(){
  108. getUserInfo().then(
  109. res => {
  110. if(res.code==200){
  111. if(res.user!=null){
  112. this.integral=res.user.integral;
  113. }
  114. }
  115. },
  116. rej => {}
  117. );
  118. },
  119. getIntegralGoodsById(){
  120. var data={goodsId:this.goodsId};
  121. console.log(data)
  122. getIntegralGoodsById(data).then(
  123. res => {
  124. if(res.code==200){
  125. this.item=res.data;
  126. }else{
  127. }
  128. },
  129. rej => {}
  130. );
  131. },
  132. openAddress(){
  133. uni.navigateTo({
  134. url: '/pages_user/address'
  135. })
  136. },
  137. payOrder(){
  138. if(this.addressId==null){
  139. uni.showToast({
  140. icon:'none',
  141. title: "请选择收货地址",
  142. });
  143. return;
  144. }
  145. var data = {
  146. goodsId:this.goodsId,
  147. addressId:this.addressId,
  148. };
  149. var that=this;
  150. uni.showLoading();
  151. createOrder(data).then(
  152. res => {
  153. if(res.code==200){
  154. var temps=['wqKEklE_w5N19w9VAGY74TltPE6Ne3BaFObDD47uDEo']
  155. uni.requestSubscribeMessage({
  156. tmplIds: temps,
  157. success(e) {
  158. setTimeout(function(){
  159. uni.redirectTo({
  160. url:"./integralOrderPaySuccess?orderId="+res.order.orderId
  161. })
  162. },200);
  163. },
  164. fail(e) {
  165. setTimeout(function(){
  166. uni.redirectTo({
  167. url:"./integralOrderPaySuccess?orderId="+res.order.orderId
  168. })
  169. },200);
  170. }
  171. })
  172. }else{
  173. uni.showToast({
  174. icon:'none',
  175. title: res.msg,
  176. });
  177. }
  178. },
  179. rej => {}
  180. );
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang="scss">
  186. .inner-box{
  187. padding: 20upx 20upx 140upx;
  188. .address-box{
  189. box-sizing: border-box;
  190. min-height: 171upx;
  191. background: #FFFFFF;
  192. border-radius: 16upx;
  193. background-image: url(https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/address_bg.png);
  194. background-repeat: no-repeat;
  195. background-size: 100% 30upx;
  196. background-position: left bottom;
  197. padding: 38upx 30upx 36upx;
  198. display: flex;
  199. align-items: center;
  200. justify-content: space-between;
  201. .left{
  202. width: 92%;
  203. .name-box{
  204. display: flex;
  205. align-items: center;
  206. .text{
  207. font-size: 32upx;
  208. font-family: PingFang SC;
  209. font-weight: bold;
  210. color: #111111;
  211. line-height: 1;
  212. &.name{
  213. margin-right: 30upx;
  214. }
  215. }
  216. }
  217. .address{
  218. font-size: 28upx;
  219. font-family: PingFang SC;
  220. font-weight: 500;
  221. color: #666666;
  222. line-height: 42upx;
  223. text-align:left;
  224. margin-top: 23upx;
  225. }
  226. }
  227. .arrow-box{
  228. width: 12upx;
  229. height: 23upx;
  230. display: flex;
  231. align-items: cenetr;
  232. justify-content: cenetr;
  233. image{
  234. width: 100%;
  235. height: 100%;
  236. }
  237. }
  238. }
  239. .goods-list{
  240. margin-top: 20upx;
  241. padding: 0 30upx;
  242. background-color: #FFFFFF;
  243. border-radius: 16upx;
  244. .item{
  245. padding: 30upx 0;
  246. border-bottom: 1px solid #EDEEEF;
  247. display: flex;
  248. align-items: center;
  249. .img-box{
  250. width: 160upx;
  251. height: 160upx;
  252. margin-right: 30upx;
  253. image{
  254. width: 100%;
  255. height: 100%;
  256. }
  257. }
  258. .info-box{
  259. width: calc(100% - 190upx);
  260. height: 160upx;
  261. display: flex;
  262. flex-direction: column;
  263. justify-content: space-between;
  264. .name-box{
  265. font-size: 28upx;
  266. font-family: PingFang SC;
  267. font-weight: 500;
  268. color: #111111;
  269. line-height: 40upx;
  270. .tag{
  271. display: inline-block;
  272. padding: 0 6upx;
  273. height: 30upx;
  274. background: linear-gradient(90deg, #2583EB 0%, #2EDAD4 100%);
  275. border-radius: 4upx;
  276. margin-right: 10upx;
  277. font-size: 22upx;
  278. font-family: PingFang SC;
  279. font-weight: bold;
  280. color: #FFFFFF;
  281. line-height: 30upx;
  282. float: left;
  283. margin-top: 7upx;
  284. }
  285. }
  286. .spec{
  287. margin-top: 10upx;
  288. font-size: 24upx;
  289. font-family: PingFang SC;
  290. font-weight: 500;
  291. color: #999999;
  292. line-height: 1;
  293. }
  294. .price-num{
  295. display: flex;
  296. align-items: center;
  297. justify-content: space-between;
  298. .price{
  299. display: flex;
  300. align-items: flex-end;
  301. .unit{
  302. font-size: 24upx;
  303. font-family: PingFang SC;
  304. font-weight: 500;
  305. color: #111111;
  306. line-height: 1.2;
  307. margin-right: 4upx;
  308. }
  309. .num{
  310. font-size: 32upx;
  311. font-family: PingFang SC;
  312. font-weight: 500;
  313. color: #111111;
  314. line-height: 1;
  315. }
  316. }
  317. .num{
  318. font-size: 24upx;
  319. font-family: PingFang SC;
  320. font-weight: 500;
  321. color: #999999;
  322. line-height: 1;
  323. }
  324. }
  325. }
  326. }
  327. .sub-total{
  328. height: 88upx;
  329. display: flex;
  330. align-items: center;
  331. justify-content: flex-end;
  332. .label{
  333. font-size: 24upx;
  334. font-family: PingFang SC;
  335. font-weight: 500;
  336. color: #999999;
  337. }
  338. .price{
  339. display: flex;
  340. align-items: flex-end;
  341. .unit{
  342. font-size: 24upx;
  343. font-family: PingFang SC;
  344. font-weight: 500;
  345. color: #FF6633;
  346. line-height: 1.2;
  347. margin-right: 4upx;
  348. }
  349. .num{
  350. font-size: 32upx;
  351. font-family: PingFang SC;
  352. font-weight: bold;
  353. color: #FF6633;
  354. line-height: 1;
  355. }
  356. }
  357. }
  358. }
  359. .other-info{
  360. margin-top: 20upx;
  361. background-color: #fff;
  362. border-radius: 20upx;
  363. overflow: hidden;
  364. padding: 0 30upx;
  365. .title{
  366. height: 80upx;
  367. line-height: 80upx;
  368. font-size: 30upx;
  369. color: #000;
  370. font-weight: bold;
  371. border-bottom: 2upx solid #eeeeee;
  372. }
  373. .item{
  374. height: 80upx;
  375. display: flex;
  376. align-items: center;
  377. justify-content: space-between;
  378. &:last-child{
  379. border-bottom: none;
  380. }
  381. .left{
  382. flex: 1;
  383. display: flex;
  384. align-items: center;
  385. .label{
  386. min-width: 140rpx;
  387. font-size: 28upx;
  388. color: #000;
  389. }
  390. .text{
  391. font-size: 28upx;
  392. color: #1b1b1b;
  393. }
  394. }
  395. .right{
  396. display: flex;
  397. align-items: center;
  398. justify-content: flex-end;
  399. .text{
  400. font-size: 28upx;
  401. color: #1b1b1b;
  402. }
  403. .ic-close{
  404. margin-left: 10rpx;
  405. width: 30rpx;
  406. height:30rpx;
  407. }
  408. .ic-back{
  409. margin-left: 10rpx;
  410. width: 15rpx;
  411. height:30rpx;
  412. }
  413. }
  414. .item-btn{
  415. max-width: 200rpx;
  416. padding: 0rpx 15rpx;
  417. height: 48upx;
  418. border-radius: 24upx;
  419. line-height: 48upx;
  420. font-size: 24upx;
  421. color: #000;
  422. border: 1upx solid #d8d8d8;
  423. display: flex;
  424. align-items: center;
  425. justify-content: center;
  426. }
  427. }
  428. }
  429. .remarks{
  430. height: 88upx;
  431. padding: 0 30upx;
  432. background: #FFFFFF;
  433. border-radius: 16upx;
  434. margin-top: 20upx;
  435. display: flex;
  436. align-items: center;
  437. input{
  438. width: 100%;
  439. font-size: 28upx;
  440. font-family: PingFang SC;
  441. font-weight: 500;
  442. color: #000000;
  443. }
  444. .input{
  445. font-size: 28upx;
  446. font-family: PingFang SC;
  447. font-weight: 500;
  448. color: #999999;
  449. }
  450. }
  451. }
  452. .btn-box{
  453. height: 140upx;
  454. z-index: 9999;
  455. width: 100%;
  456. padding: 0rpx 30upx;
  457. position: fixed;
  458. bottom: 0;
  459. left: 0;
  460. box-sizing: border-box;
  461. background-color: #ffffff;
  462. display: flex;
  463. align-items: center;
  464. justify-content: center;
  465. .btn{
  466. width: 100%;
  467. height: 88upx;
  468. line-height: 88upx;
  469. text-align: center;
  470. font-size: 34upx;
  471. font-family: PingFang SC;
  472. font-weight: 400;
  473. color: #FFFFFF;
  474. background: #2583EB;
  475. border-radius: 10upx;
  476. }
  477. }
  478. .pay-type{
  479. box-sizing: border-box;
  480. height: 192upx;
  481. background: #FFFFFF;
  482. border-radius: 16upx;
  483. margin-top: 20upx;
  484. padding: 40upx 30upx;
  485. display: flex;
  486. flex-direction: column;
  487. justify-content: space-between;
  488. .title{
  489. font-size: 28upx;
  490. font-family: PingFang SC;
  491. font-weight: 500;
  492. color: #999999;
  493. line-height: 1;
  494. }
  495. .item{
  496. display: flex;
  497. align-items: center;
  498. justify-content: space-between;
  499. .left{
  500. display: flex;
  501. align-items: center;
  502. image{
  503. width: 44upx;
  504. height: 44upx;
  505. margin-right: 20upx;
  506. }
  507. .text{
  508. font-size: 30upx;
  509. font-family: PingFang SC;
  510. font-weight: bold;
  511. color: #222222;
  512. line-height: 1;
  513. }
  514. }
  515. }
  516. }
  517. .coupon{
  518. height: 100%;
  519. .empty{
  520. display: flex;
  521. align-items: center;
  522. justify-content: center;
  523. height: 650rpx;
  524. width: 100%;
  525. image{
  526. width: 280rpx;
  527. height: 200rpx;
  528. }
  529. }
  530. }
  531. .coupon-box{
  532. overflow-y: auto;
  533. padding: 80rpx 20rpx 80rpx;
  534. height: 650rpx;
  535. width: 100%;
  536. display: flex;
  537. flex-direction: column;
  538. align-items: flex-start;
  539. justify-content: flex-start;
  540. box-sizing: border-box;
  541. .coupon-item{
  542. width: 100%;
  543. display: flex;
  544. align-items: center;
  545. justify-content: flex-start;
  546. margin-bottom: 16rpx;
  547. height:170rpx;
  548. &:last-child{
  549. margin-bottom: 0rpx;
  550. }
  551. .left{
  552. color: #fff;
  553. font-size: 36rpx;
  554. font-weight: bold;
  555. text-align: center;
  556. display: flex;
  557. flex-direction: column;
  558. align-items: center;
  559. justify-content: center;
  560. position: relative;
  561. width: 230rpx;
  562. image{
  563. position: absolute;
  564. width: 230rpx;
  565. height:170rpx;
  566. color: #fff;
  567. }
  568. .num{
  569. font-size: 40rpx;
  570. }
  571. .pic-num{
  572. font-size: 20rpx;
  573. z-index: 99;
  574. }
  575. }
  576. .right{
  577. display: flex;
  578. flex-direction: column;
  579. align-items: flex-start;
  580. justify-content: flex-start;
  581. height:170rpx;
  582. width: calc(100% - 230rpx);
  583. padding: 0 17rpx 0 24rpx;
  584. background-color: #fff;
  585. box-sizing: border-box;
  586. .title{
  587. width: 100%;
  588. font-size: 0.3 * 100rpx;
  589. color: #282828;
  590. height: 0.93 * 100rpx;
  591. line-height: 0.93 * 100rpx;
  592. border-bottom: 1px solid #f0f0f0;
  593. }
  594. .btns{
  595. display: flex;
  596. align-items: center;
  597. justify-content: space-between;
  598. width: 100%;
  599. font-size: 0.2 * 100rpx;
  600. color: #999;
  601. height: 0.76 * 100rpx;
  602. .btn{
  603. width: 1.36 * 100rpx;
  604. height: 0.44 * 100rpx;
  605. border-radius: 0.22 * 100rpx;
  606. font-size: 0.22 * 100rpx;
  607. color: #fff;
  608. text-align: center;
  609. line-height: 0.44 * 100rpx;
  610. background-color: #2583EB;
  611. .gray{
  612. background-color: #ccc;
  613. }
  614. }
  615. }
  616. }
  617. }
  618. }
  619. </style>