powerSetting.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="power-setting-main">
  3. <navBar :name="$t('权限设置')" bgColor="transparent"></navBar>
  4. <view class="flex-row power-setting-head">
  5. <image class="head-img" :src="form.headimg"></image>
  6. <view class="head-name">{{form.nickname}}</view>
  7. <text class="head-email">{{form.email}}</text>
  8. </view>
  9. <view class="setting-card" style="margin-bottom: 20rpx;">
  10. <view class="setting-card-name">{{ $t('权限设置') }}</view>
  11. <view @click="selctFn(4)" class="setting-card-list flex-row">
  12. <img src="https://qiniu.bms16.com/FgFEr3CUA43kd7yVCDcK4F7v9_zx" alt="">
  13. <view class="setting-list-text flex-row flex-between">
  14. <text>{{ $t('查看实时位置') }}</text>
  15. <img v-if="form.authority_list.indexOf(4) == -1" class="setting-list-arrow"
  16. src="https://qiniu.bms16.com/FrA97op1dwM9XWH1ocqnF5FFlqoY" alt="">
  17. <img v-else class="setting-list-arrow" src="https://qiniu.bms16.com/FuA5w59wrvsisg3bGhe3hQ2dR3Bk"
  18. alt="">
  19. </view>
  20. </view>
  21. <view @click="selctFn(5)" class="setting-card-list flex-row">
  22. <img src="https://qiniu.bms16.com/FmcZqGTnt64_v2xpgNbqS9Fa-fwy" alt="">
  23. <view class="setting-list-text flex-row flex-between">
  24. <text>{{ $t('使用换电') }}</text>
  25. <!-- <img class="setting-list-arrow" src="https://qiniu.bms16.com/FuA5w59wrvsisg3bGhe3hQ2dR3Bk" alt=""> -->
  26. <img v-if="form.authority_list.indexOf(5) == -1" class="setting-list-arrow"
  27. src="https://qiniu.bms16.com/FrA97op1dwM9XWH1ocqnF5FFlqoY" alt="">
  28. <img v-else class="setting-list-arrow" src="https://qiniu.bms16.com/FuA5w59wrvsisg3bGhe3hQ2dR3Bk"
  29. alt="">
  30. </view>
  31. </view>
  32. </view>
  33. <view class="setting-card" style="margin-bottom: 32rpx;">
  34. <view class="setting-card-name">{{ $t('默认设置') }}</view>
  35. <view class="setting-card-list flex-row">
  36. <img src="https://qiniu.bms16.com/FsUxQz3DwHIj_vt3fY25Twmjfpek" alt="">
  37. <view class="setting-list-text flex-row">{{ $t('远程开关锁') }}</view>
  38. </view>
  39. <view class="setting-card-list flex-row">
  40. <img src="https://qiniu.bms16.com/FuCNZSqsoMxn2ha-njRW3zC2ORTz" alt="">
  41. <view class="setting-list-text flex-row">{{ $t('座桶锁') }}</view>
  42. </view>
  43. <view class="setting-card-list flex-row">
  44. <img src="https://qiniu.bms16.com/Fs7i3i_LBM7Zpxyj7Ad7_Kc_8z-J" alt="">
  45. <view class="setting-list-text flex-row">{{ $t('感应解锁') }}</view>
  46. </view>
  47. </view>
  48. <view v-if="isSet" @tap="submit" class="check-btn add-btn">{{ $t('确认添加') }}</view>
  49. <view v-else @tap="delSubmit" class="check-btn del-btn">{{ $t('删除成员') }}</view>
  50. </view>
  51. </template>
  52. <script>
  53. var config = require('../../common/config_gyq.js');
  54. var http = require('../../common/request.js');
  55. import {
  56. msg
  57. } from '../../utils/util.js';
  58. export default {
  59. data() {
  60. return {
  61. isSet:"",
  62. target_user_id:0,
  63. form: {
  64. headimg: "",
  65. nickname: "",
  66. car_sn: "",
  67. email: "",
  68. authority_list: [5]
  69. }
  70. };
  71. }
  72. /**
  73. * 生命周期函数--监听页面加载
  74. */
  75. ,
  76. onLoad: function(options) {
  77. this.isSet = options.isSet
  78. this.form.car_sn = uni.getStorageSync('car_info').car_sn || '';
  79. if(options.id){
  80. this.target_user_id = options.id
  81. this.carInfoFn()
  82. return
  83. }
  84. this.form.email = options.email;
  85. this.form.headimg = options.headimg;
  86. this.form.nickname = options.nickname;
  87. },
  88. methods: {
  89. async carInfoFn(){
  90. let {
  91. data
  92. } = await http.postApi(config.API_FLK_CAR_EDIT_SHARE_INFO, {
  93. car_sn: this.form.car_sn,
  94. target_user_id: this.target_user_id
  95. })
  96. if(data.code == 200){
  97. data.data.authority = data.data.authority.map(item=>{
  98. return Number(item)
  99. })
  100. this.form.authority_list = data.data.authority
  101. this.form.email = data.data.email
  102. this.form.nickname = data.data.nickname
  103. this.form.headimg = data.data.headimg
  104. }
  105. },
  106. async delSubmit() {
  107. let res = await uni.showModal({
  108. content:this.$t('确定删除这个成员吗?')
  109. })
  110. if(!res[1].confirm) return
  111. let {
  112. data
  113. } = await http.postApi(config.API_FLK_CAR_REMOVE_SHARE_USER, {
  114. car_sn: this.form.car_sn,
  115. email: this.form.email
  116. })
  117. uni.showLoading({
  118. mask:true,
  119. title:'删除中...'
  120. })
  121. msg(data.msg)
  122. if(data.code == 200){
  123. setTimeout(()=>{
  124. uni.navigateBack({
  125. delta: 1
  126. })
  127. },800)
  128. }
  129. },
  130. async submit() {
  131. uni.showLoading({
  132. mask: true,
  133. title: '提交中...'
  134. })
  135. let {
  136. data
  137. } = await http.postApi(config.API_FLK_CAR_ADD_SHARE_USER, this.form)
  138. if (data.code == 200) {
  139. msg(this.$t('添加成功!'))
  140. setTimeout(() => {
  141. uni.navigateBack({
  142. delta: 2
  143. })
  144. }, 800)
  145. } else {
  146. msg(data.msg)
  147. }
  148. },
  149. selctFn(type) {
  150. if (this.form.authority_list.indexOf(type) != -1) {
  151. this.form.authority_list = this.form.authority_list.filter(item => item !== type);
  152. } else {
  153. this.form.authority_list.push(type)
  154. }
  155. if(this.target_user_id) this.editFn()
  156. },
  157. async editFn(){
  158. let {
  159. data
  160. } = await http.postApi(config.API_FLK_CAR_EDIT_SHARE_USER,{
  161. ...this.form,
  162. })
  163. }
  164. }
  165. };
  166. </script>
  167. <style>
  168. @import './powerSetting.css';
  169. </style>