changeBindCar.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <view :style="colorStyle">
  3. <form @submit="formSubmit">
  4. <view class='personal-data'>
  5. <view class='list'>
  6. <view class='item acea-row row-between-wrapper'>
  7. <view>{{$t(`车辆名称`)}}</view>
  8. <view class='input'>
  9. <input type='text' name='phone' v-model='carDateil.name' placeholder="请输入车辆名称"
  10. class='id'></input>
  11. </view>
  12. </view>
  13. <view class='item acea-row row-between-wrapper'>
  14. <view>{{$t(`车牌号`)}}</view>
  15. <view class='input'>
  16. <input type='text' name='phone' v-model='carDateil.code' placeholder="请输入车牌号"
  17. class='id'></input>
  18. </view>
  19. </view>
  20. <view class='item acea-row row-between-wrapper'>
  21. <view>车辆编号</view>
  22. <view class='input acea-row row-between-wrapper'>
  23. <input type='text' v-model='carDateil.machine_no' placeholder="请输入车辆编号" class='id'></input>
  24. <!-- #ifndef H5 -->
  25. <text @click='openQr' class=' iconfont icon-saoma'></text>
  26. <!-- #endif -->
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <button class='modifyBnt bg-color' formType="submit">{{$t(`提交保存`)}}</button>
  32. </form>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. toLogin
  38. } from '@/libs/login.js';
  39. import {
  40. postSetCarCode,
  41. } from '@/api/rent.js';
  42. import {
  43. mapGetters
  44. } from "vuex";
  45. import colors from '@/mixins/color.js';
  46. export default {
  47. mixins: [colors],
  48. data() {
  49. return {
  50. id: '',
  51. carDateil: {
  52. machine_no: '',
  53. name: '',
  54. code: '',
  55. }
  56. };
  57. },
  58. computed: mapGetters(['isLogin']),
  59. onLoad(options) {
  60. this.id = options.id
  61. if (!this.isLogin) {
  62. toLogin();
  63. }
  64. },
  65. methods: {
  66. // #ifndef H5
  67. // 打开二维码
  68. openQr() {
  69. const that = this;
  70. uni.scanCode({
  71. onlyFromCamera: true,
  72. scanType: ['barCode', 'qrCode', 'datamatrix', 'pdf417'],
  73. success(res) {
  74. that.carDateil.machine_no = res.result;
  75. }
  76. })
  77. },
  78. // #endif
  79. // 提交绑定
  80. formSubmit() {
  81. uni.showLoading({
  82. title: '绑定中',
  83. mask: true
  84. });
  85. postSetCarCode({
  86. machine_no: this.carDateil.machine_no,
  87. machine_name: this.carDateil.name,
  88. plate_number: this.carDateil.code,
  89. }).then((res) => {
  90. uni.hideLoading()
  91. uni.showToast({
  92. title: '绑定成功'
  93. });
  94. setTimeout(() => {
  95. uni.switchTab({
  96. url: '/pages/user/index'
  97. })
  98. }, 1000);
  99. }).catch((res) => {
  100. uni.hideLoading()
  101. uni.showToast({
  102. title: res,
  103. icon: 'error'
  104. });
  105. })
  106. },
  107. }
  108. }
  109. </script>
  110. <style scoped lang="scss">
  111. .personal-data .list {
  112. /* #ifndef H5 */
  113. margin-top: 15rpx;
  114. /* #endif */
  115. background-color: #fff;
  116. .item {
  117. padding: 30rpx 30rpx 30rpx 0;
  118. border-bottom: 1rpx solid #f2f2f2;
  119. margin-left: 30rpx;
  120. font-size: 28rpx;
  121. color: #282828;
  122. .input {
  123. text-align: right;
  124. color: #868686;
  125. .icon-suozi {
  126. margin-left: 10rpx;
  127. }
  128. .id {
  129. // width: 180rpx;
  130. }
  131. .iconfont {
  132. font-size: 36rpx;
  133. padding-left: 10rpx;
  134. }
  135. }
  136. }
  137. }
  138. .modifyBnt {
  139. font-size: 32rpx;
  140. color: #fff;
  141. width: 690rpx;
  142. height: 90rpx;
  143. border-radius: 50rpx;
  144. text-align: center;
  145. line-height: 90rpx;
  146. margin: 76rpx auto 0 auto;
  147. }
  148. </style>