Prepayment.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <view class="app">
  3. <view class="bg">
  4. </view>
  5. <view class="moneyBox">
  6. <view class="price-box">
  7. <text>提前还款金额</text>
  8. </view>
  9. <view class="moneyNumBox flex">
  10. <text class="fh">¥</text>
  11. <input class="moneyValue" type="text" v-model="money" />
  12. </view>
  13. <view class="day">
  14. 服务天数剩余{{day}}天
  15. </view>
  16. </view>
  17. <view class="moneyBox margin-t-30 padding-t-30">
  18. <view class="yt-list">
  19. <view class="yt-list-cell" @click="payType='yue'">
  20. <view class="cell-tit flex">
  21. <image class="orderIcon" src="../../../static/icon/ye.png" mode="widthFix"></image>
  22. <text class="margin-l-10">余额({{now_money}})</text>
  23. </view>
  24. <image class="checked" v-if="payType=='yue'" src="../../../static/icon/addressIconXz.png"
  25. mode="widthFix">
  26. </image>
  27. <view v-else class="noChecked"></view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="base-buttom" :class="{ clickbg: payLoding }" @click="!payLoding ? confirm() : ''">确认支付</view>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. balance
  37. } from '@/api/wallet.js';
  38. import {
  39. getCarInfo,
  40. prepayment
  41. } from '@/api/user.js';
  42. export default {
  43. data() {
  44. return {
  45. payType: 'yue',
  46. money: 0, //订单金额
  47. allMoney: 0, //总的还款金额
  48. now_money: 0.0, //余额
  49. car_number: '', //保存订单id
  50. payLoding: false, //判断是否支付中
  51. minMoney: 0, //最低还款金额
  52. };
  53. },
  54. onLoad(options) {
  55. this.car_number = options.id;
  56. // 载入余额
  57. balance({}).then(({
  58. data
  59. }) => {
  60. // 获取余额
  61. this.now_money = data.now_money;
  62. });
  63. getCarInfo({
  64. car_number: this.car_number
  65. }).then((e) => {
  66. this.money = e.data.surplus;
  67. this.allMoney = e.data.surplus;
  68. this.minMoney = +e.data.day_deducted
  69. this.day = e.data.day
  70. })
  71. },
  72. methods: {
  73. // 支付成功跳转
  74. paySuccessTo() {
  75. uni.hideLoading();
  76. uni.redirectTo({
  77. url: '/pages/user/money/paySuccess?type=1'
  78. });
  79. },
  80. //确认支付
  81. confirm: async function() {
  82. let obj = this;
  83. // 判断是否余额不足
  84. if (obj.payType == 'yue' && +obj.now_money < obj.money) {
  85. uni.showModal({
  86. title: '提示',
  87. content: '账户余额不足!',
  88. showCancel: false,
  89. });
  90. return;
  91. }
  92. // 判断是否为未支付订单中跳转进入
  93. if (this.money < this.minMoney) {
  94. uni.showModal({
  95. title: '提示',
  96. content: '还款金额不可低于' + this.minMoney + '元',
  97. showCancel: false,
  98. });
  99. return
  100. }
  101. if (this.money % this.minMoney != 0 && this.money < this.allMoney) {
  102. uni.showModal({
  103. title: '提示',
  104. content: '还款金额必须为' + this.minMoney + '的倍数',
  105. showCancel: false,
  106. });
  107. return
  108. }
  109. // 支付中
  110. uni.showLoading({
  111. title: '支付中',
  112. mask: true
  113. })
  114. obj.payLoding = true;
  115. prepayment({
  116. 'car_number': this.car_number,
  117. money: this.money
  118. }).then((e) => {
  119. uni.hideLoading()
  120. uni.showToast({
  121. title: e.msg
  122. });
  123. obj.payLoding = false;
  124. uni.showModal({
  125. title: '提示',
  126. content: e.msg,
  127. showCancel: false,
  128. cancelText: '取消',
  129. confirmText: '返回',
  130. success: res => {
  131. if(res.confirm){
  132. uni.navigateBack()
  133. }
  134. },
  135. fail: () => {},
  136. complete: () => {}
  137. });
  138. }).catch((e) => {
  139. obj.payLoding = false;
  140. uni.hideLoading()
  141. console.log(e);
  142. })
  143. }
  144. }
  145. };
  146. </script>
  147. <style lang="scss">
  148. .app {
  149. width: 100%;
  150. padding-top: 30rpx;
  151. }
  152. .moneyBox {
  153. position: relative;
  154. margin: 0 $page-row-spacing;
  155. border-radius: 20rpx;
  156. overflow: hidden;
  157. background-color: #FFFFFF;
  158. padding: 50rpx 30rpx 30rpx;
  159. .moneyNumBox {
  160. color: $font-color-base;
  161. border-bottom: 1px solid $page-color-light;
  162. .fh {
  163. font-size: $font-base + 2rpx;
  164. }
  165. .moneyValue {
  166. font-size: $font-lg + 16rpx;
  167. }
  168. }
  169. .day {
  170. padding-top: 30RPX;
  171. font-size: $font-sm - 2rpx;
  172. color: $font-color-light;
  173. }
  174. }
  175. .bg {
  176. background-color: $color-green;
  177. width: 950rpx;
  178. position: absolute;
  179. left: -100rpx;
  180. border-bottom-left-radius: 1000rpx;
  181. border-bottom-right-radius: 1000rpx;
  182. top: 0rpx;
  183. height: 300rpx;
  184. }
  185. .price-box {
  186. background-color: #fff;
  187. padding-bottom: 60rpx;
  188. font-size: $font-base;
  189. color: $font-color-base;
  190. font-weight: bold;
  191. .price {
  192. font-size: 50upx;
  193. color: #303133;
  194. margin-top: 12upx;
  195. &:before {
  196. content: '¥';
  197. font-size: 40upx;
  198. }
  199. }
  200. }
  201. .pay-type-list {
  202. margin-top: 20upx;
  203. background-color: #fff;
  204. padding-left: 60upx;
  205. .type-item {
  206. height: 120upx;
  207. padding: 20upx 0;
  208. display: flex;
  209. justify-content: space-between;
  210. align-items: center;
  211. padding-right: 60upx;
  212. font-size: 30upx;
  213. position: relative;
  214. }
  215. .icon {
  216. width: 100upx;
  217. font-size: 52upx;
  218. }
  219. .iconyue {
  220. color: #fe8e2e;
  221. }
  222. .iconweixin {
  223. color: #36cb59;
  224. }
  225. .iconzhifubao {
  226. color: #01aaef;
  227. }
  228. .tit {
  229. font-size: $font-lg;
  230. color: $font-color-dark;
  231. margin-bottom: 4upx;
  232. }
  233. .con {
  234. flex: 1;
  235. display: flex;
  236. flex-direction: column;
  237. font-size: $font-sm;
  238. color: $font-color-light;
  239. }
  240. }
  241. .clickbg {
  242. background-color: $color-gray !important;
  243. }
  244. .yt-list {
  245. background: #fff;
  246. border-radius: 20rpx;
  247. width: 100%;
  248. }
  249. .yt-list-cell {
  250. display: flex;
  251. align-items: center;
  252. justify-content: space-between;
  253. line-height: 70rpx;
  254. position: relative;
  255. .checked,
  256. .noChecked {
  257. width: 36rpx;
  258. height: 36rpx;
  259. }
  260. .noChecked {
  261. border: 1px solid $font-color-light;
  262. border-radius: 100rpx;
  263. }
  264. &.cell-hover {
  265. background: #fafafa;
  266. }
  267. &.b-b:after {
  268. left: 30rpx;
  269. }
  270. .cell-icon {
  271. height: 32rpx;
  272. width: 32rpx;
  273. font-size: 22rpx;
  274. color: #fff;
  275. text-align: center;
  276. line-height: 32rpx;
  277. background: #f85e52;
  278. border-radius: 4rpx;
  279. margin-right: 12rpx;
  280. &.hb {
  281. background: #ffaa0e;
  282. }
  283. &.lpk {
  284. background: #3ab54a;
  285. }
  286. }
  287. .cell-more {
  288. align-self: center;
  289. font-size: 24rpx;
  290. color: $font-color-light;
  291. margin-left: 8rpx;
  292. margin-right: -10rpx;
  293. }
  294. .cell-tit {
  295. font-size: 26rpx;
  296. color: $font-color-light;
  297. margin-right: 10rpx;
  298. .orderIcon {
  299. width: 48rpx;
  300. }
  301. }
  302. .cell-tip {
  303. font-size: 26rpx;
  304. color: $font-color-dark;
  305. &.disabled {
  306. color: $font-color-light;
  307. }
  308. &.active {
  309. color: $base-color;
  310. }
  311. &.red {
  312. color: $base-color;
  313. }
  314. }
  315. &.desc-cell {
  316. .cell-tit {
  317. max-width: 90rpx;
  318. }
  319. }
  320. .desc {
  321. text-align: right;
  322. font-size: $font-base;
  323. color: $font-color-light;
  324. }
  325. }
  326. </style>