auth.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view>
  3. <form @submit="formSubmit">
  4. <view class='personal-data' :style="colorStyle">
  5. <view class='list'>
  6. <view class='item acea-row row-between-wrapper'>
  7. <view>{{$t(`手机号`)}}</view>
  8. <view class='input'>
  9. <input type='nickname' placeholder="请输入手机号" name='nickname' :maxlength="16" v-model='phone'></input>
  10. </view>
  11. </view>
  12. <picker mode="selector" range-key='text' :range="timeList" @change="changeTime">
  13. <view class='item acea-row row-between-wrapper'>
  14. <view>{{$t(`授权时长`)}}</view>
  15. <view class='input'>
  16. {{time||'请选择时间'}}
  17. </view>
  18. </view>
  19. </picker>
  20. <view class='item acea-row row-between-wrapper'>
  21. <view>{{$t(`备注`)}}</view>
  22. <view class='input'><input placeholder="备注信息填写" type='nickname' name='nickname' :maxlength="16"
  23. v-model='mask'></input>
  24. </view>
  25. </view>
  26. </view>
  27. <button class='modifyBnt bg-color' formType="submit">{{$t(`保存修改`)}}</button>
  28. </view>
  29. </form>
  30. </view>
  31. </template>
  32. <script>
  33. import {
  34. toLogin
  35. } from '@/libs/login.js';
  36. import {
  37. postCarAuth,
  38. } from '@/api/rent.js';
  39. import {
  40. mapGetters
  41. } from "vuex";
  42. import colors from '@/mixins/color.js';
  43. export default {
  44. mixins: [colors],
  45. data() {
  46. return {
  47. id: '',
  48. phone: '',
  49. indexTime: '',
  50. mask:'',
  51. time:'',
  52. timeList: [{
  53. type: 0,
  54. text: '长期'
  55. },
  56. {
  57. type: 1,
  58. text: '1天'
  59. },
  60. {
  61. type: 3,
  62. text: '3天'
  63. },
  64. {
  65. type: 7,
  66. text: '7天'
  67. },
  68. {
  69. type: 30,
  70. text: '30天'
  71. }
  72. ],
  73. };
  74. },
  75. computed: mapGetters(['isLogin']),
  76. onLoad(options) {
  77. this.id = options.id
  78. if (!this.isLogin) {
  79. toLogin();
  80. }
  81. },
  82. methods: {
  83. // 切换
  84. changeTime(e) {
  85. this.time = this.timeList[e.detail.value].text
  86. this.indexTime = e.detail.value;
  87. },
  88. // 提交
  89. formSubmit(e) {
  90. let obj = this;
  91. if (!obj.phone) {
  92. uni.showToast({
  93. title: '请输入授权用户手机号',
  94. icon: 'none'
  95. })
  96. return
  97. }
  98. if (obj.time == '授权时长') {
  99. uni.showToast({
  100. title: '请选择授权时长',
  101. icon: 'none'
  102. })
  103. return
  104. }
  105. uni.showLoading({
  106. title: '授权申请中',
  107. mask: true
  108. });
  109. postCarAuth({
  110. phone: obj.phone,
  111. car_id: obj.id,
  112. day: obj.indexTime,
  113. nickname: obj.mask
  114. })
  115. .then(({
  116. data
  117. }) => {
  118. uni.hideLoading()
  119. uni.showToast({
  120. title: '授权成功',
  121. icon: 'success'
  122. })
  123. setTimeout(function() {
  124. uni.redirectTo({
  125. url:'./authList?id='+obj.id,
  126. fail(e){
  127. console.log(e)
  128. }
  129. });
  130. }, 1000);
  131. })
  132. .catch(err => {
  133. uni.hideLoading()
  134. uni.showToast({
  135. title: err,
  136. icon:"error"
  137. });
  138. });
  139. },
  140. }
  141. }
  142. </script>
  143. <style scoped lang="scss">
  144. .personal-data .list {
  145. /* #ifndef H5 */
  146. margin-top: 15rpx;
  147. /* #endif */
  148. background-color: #fff;
  149. .item {
  150. padding: 30rpx 30rpx 30rpx 0;
  151. border-bottom: 1rpx solid #f2f2f2;
  152. margin-left: 30rpx;
  153. font-size: 28rpx;
  154. color: #282828;
  155. .input {
  156. flex-grow: 1;
  157. text-align: right;
  158. color: #868686;
  159. font-size: $uni-font-size-lg;
  160. .icon-suozi {
  161. margin-left: 10rpx;
  162. }
  163. .id {
  164. // width: 180rpx;
  165. }
  166. .iconfont {
  167. font-size: 24rpx;
  168. }
  169. }
  170. }
  171. }
  172. .modifyBnt {
  173. font-size: 32rpx;
  174. color: #fff;
  175. width: 690rpx;
  176. height: 90rpx;
  177. border-radius: 50rpx;
  178. text-align: center;
  179. line-height: 90rpx;
  180. margin: 76rpx auto 0 auto;
  181. }
  182. .monthslist {
  183. background-color: #FFF;
  184. border-radius: 10rpx;
  185. margin: 20rpx 20rpx 0rpx 20rpx;
  186. padding: 20rpx;
  187. .time,
  188. .peytype {
  189. font-size: 24rpx;
  190. color: #999;
  191. }
  192. .info {
  193. color: var(--view-theme);
  194. }
  195. .right {
  196. text-align: right;
  197. .money {
  198. color: var(--view-theme);
  199. }
  200. }
  201. }
  202. </style>