charge.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <view style="padding: 20rpx;">
  3. <view class="box">
  4. <uni-row :gutter="10">
  5. <uni-col :span="8" v-for="item in items" :key="item">
  6. <view class="charge-item" :class="{ 'active' : current === item }" @click="clickItem(item)">¥{{ item }}</view>
  7. </uni-col>
  8. </uni-row>
  9. <view style="margin-top: 20rpx;">
  10. <button type="primary" style="background-color: #f94b4b;" @click="charge">支 付</button>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. current: 6,
  20. items: [6, 18, 68, 288, 588, 999]
  21. }
  22. },
  23. methods: {
  24. clickItem(item) {
  25. this.current = item
  26. },
  27. charge() {
  28. this.$request.put('/user/charge/' + this.current).then(res => {
  29. if (res.code === '200') {
  30. uni.showToast({
  31. icon: 'success',
  32. title: '操作成功'
  33. })
  34. uni.navigateBack()
  35. } else {
  36. uni.showToast({
  37. icon: 'none',
  38. title: res.msg
  39. })
  40. }
  41. })
  42. }
  43. }
  44. }
  45. </script>
  46. <style>
  47. .charge-item {
  48. border: 1px solid #ccc;
  49. padding: 40rpx 0;
  50. margin-bottom: 10rpx;
  51. text-align: center;
  52. font-size: 36rpx;
  53. color: #888;
  54. border-radius: 5rpx;
  55. cursor: pointer;
  56. }
  57. .active {
  58. background-color: #f94b4b;
  59. color: white;
  60. border-color: #f94b4b;
  61. }
  62. </style>