integralOrderPay.vue 13 KB

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