authorization.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="container">
  3. <view class="listBox">
  4. <view class="list">
  5. <view class="flex listItem">
  6. <view class="flex titleBox">
  7. <text class="title">授权手机号</text>
  8. </view>
  9. <view class="right flex">
  10. <input class="input" placeholder="请输入用户手机" type="text" v-model="phone"
  11. placeholder-class="placeholder" />
  12. </view>
  13. </view>
  14. <view class="flex listItem">
  15. <view class="flex titleBox">
  16. <text class="title">授权时长</text>
  17. </view>
  18. <view class="right flex">
  19. <picker class="input" mode="selector" range-key='text' :range="timeList" @change="changeTime">
  20. <view>{{time}}</view>
  21. </picker>
  22. <image class="img" src="../../../static/icon/dom.png" mode="widthFix"></image>
  23. </view>
  24. </view>
  25. <view class="flex listItem">
  26. <view class="flex titleBox">
  27. <text class="title">对其备注</text>
  28. </view>
  29. <view class="right flex">
  30. <input class="input" v-model="mask" type="text" placeholder="请输入备注信息"
  31. placeholder-class="placeholder" />
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="base-buttom" :class="{ 'bg-gray': loding }" @click="loding ? '' : confirm()">授权</view>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. add_auth_car
  42. } from '@/api/user.js';
  43. export default {
  44. data() {
  45. return {
  46. phone: '',
  47. id: '',
  48. time: '授权时长',
  49. mask: '',
  50. timeList: [{
  51. type: 0,
  52. text: '长期'
  53. },
  54. {
  55. type: 1,
  56. text: '1天'
  57. },
  58. {
  59. type: 3,
  60. text: '3天'
  61. },
  62. {
  63. type: 7,
  64. text: '7天'
  65. },
  66. {
  67. type: 30,
  68. text: '30天'
  69. }
  70. ],
  71. indexTime: 0, //选中的时间对象
  72. loding: false
  73. };
  74. },
  75. onLoad: function(option) {
  76. this.id = option.id
  77. },
  78. methods: {
  79. changeTime(e) {
  80. this.time = this.timeList[e.detail.value].text
  81. this.indexTime = e.detail.value;
  82. },
  83. confirm(e) {
  84. let obj = this;
  85. if(!obj.phone){
  86. uni.showToast({
  87. title:'请输入授权用户手机号',
  88. icon:'none'
  89. })
  90. return
  91. }
  92. if(obj.time=='授权时长'){
  93. uni.showToast({
  94. title:'请选择授权时长',
  95. icon:'none'
  96. })
  97. return
  98. }
  99. obj.loding = true;
  100. add_auth_car({
  101. to_phone: obj.phone,
  102. car_number: obj.id,
  103. day: obj.indexTime,
  104. nickname: obj.mask
  105. })
  106. .then(({
  107. data
  108. }) => {
  109. uni.showToast({
  110. title:'授权成功',
  111. icon:'success'
  112. })
  113. setTimeout(function() {
  114. obj.loding = false;
  115. uni.navigateBack();
  116. }, 1000);
  117. })
  118. .catch(err => {
  119. obj.loding = false;
  120. console.log(err);
  121. });
  122. }
  123. },
  124. };
  125. </script>
  126. <style lang="scss">
  127. page,
  128. .content {
  129. background: $page-color-base;
  130. height: 100%;
  131. }
  132. .bg-gray {
  133. background-color: $color-gray;
  134. }
  135. .base-buttom{
  136. position: relative;
  137. bottom: auto;
  138. left: auto;
  139. right: auto;
  140. }
  141. .content {
  142. padding-top: 30rpx;
  143. }
  144. .listBox {
  145. margin: $page-row-spacing;
  146. margin-top: 30rpx;
  147. border-radius: 20rpx;
  148. overflow: hidden;
  149. background-color: #FFFFFF;
  150. }
  151. .list {
  152. .input {
  153. text-align: right;
  154. font-size: $font-base;
  155. color: $color-gray;
  156. min-height: 28rpx;
  157. flex-grow: 1;
  158. }
  159. .listItem {
  160. padding: 35rpx 40rpx;
  161. border-bottom: 1px solid $page-color-light;
  162. }
  163. .listIconImg {
  164. width: 36rpx;
  165. }
  166. .right {
  167. color: $font-color-light;
  168. font-size: $font-base;
  169. flex-grow: 1;
  170. .img {
  171. width: 26rpx;
  172. margin-left: 10rpx;
  173. }
  174. }
  175. .titleBox {
  176. .title {
  177. color: $font-color-base;
  178. font-size: $font-base;
  179. }
  180. }
  181. }
  182. </style>