powerSetting.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 || defaultHeadImg"></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. defaultHeadImg
  57. } from '@/common/constant'
  58. import {
  59. msg
  60. } from '../../utils/util.js';
  61. export default {
  62. data() {
  63. return {
  64. defaultHeadImg,
  65. isSet:"",
  66. target_user_id:0,
  67. form: {
  68. headimg: "",
  69. nickname: "",
  70. car_sn: "",
  71. email: "",
  72. authority_list: [5]
  73. }
  74. };
  75. }
  76. /**
  77. * 生命周期函数--监听页面加载
  78. */
  79. ,
  80. onLoad: function(options) {
  81. this.isSet = options.isSet
  82. this.form.car_sn = uni.getStorageSync('car_info').car_sn || '';
  83. if(options.id){
  84. this.target_user_id = options.id
  85. this.carInfoFn()
  86. return
  87. }
  88. this.form.email = options.email;
  89. this.form.headimg = options.headimg;
  90. this.form.nickname = options.nickname;
  91. },
  92. methods: {
  93. async carInfoFn(){
  94. let {
  95. data
  96. } = await http.postApi(config.API_FLK_CAR_EDIT_SHARE_INFO, {
  97. car_sn: this.form.car_sn,
  98. target_user_id: this.target_user_id
  99. })
  100. if(data.code == 200){
  101. data.data.authority = data.data.authority.map(item=>{
  102. return Number(item)
  103. })
  104. this.form.authority_list = data.data.authority
  105. this.form.email = data.data.email
  106. this.form.nickname = data.data.nickname
  107. this.form.headimg = data.data.headimg
  108. }
  109. },
  110. async delSubmit() {
  111. let res = await uni.showModal({
  112. content:this.$t('确定删除这个成员吗?')
  113. })
  114. if(!res[1].confirm) return
  115. let {
  116. data
  117. } = await http.postApi(config.API_FLK_CAR_REMOVE_SHARE_USER, {
  118. car_sn: this.form.car_sn,
  119. email: this.form.email
  120. })
  121. uni.showLoading({
  122. mask:true,
  123. title:this.$t('删除中')+'...'
  124. })
  125. msg(data.msg)
  126. if(data.code == 200){
  127. setTimeout(()=>{
  128. uni.navigateBack({
  129. delta: 1
  130. })
  131. },800)
  132. }
  133. },
  134. async submit() {
  135. uni.showLoading({
  136. mask: true,
  137. title: this.$t('提交中')+'...'
  138. })
  139. let {
  140. data
  141. } = await http.postApi(config.API_FLK_CAR_ADD_SHARE_USER, this.form)
  142. uni.hideLoading()
  143. if (data.code == 200) {
  144. msg(this.$t('添加成功!'))
  145. setTimeout(() => {
  146. uni.navigateBack({
  147. delta: 2
  148. })
  149. }, 800)
  150. } else {
  151. msg(data.msg)
  152. }
  153. },
  154. selctFn(type) {
  155. if (this.form.authority_list.indexOf(type) != -1) {
  156. this.form.authority_list = this.form.authority_list.filter(item => item !== type);
  157. } else {
  158. this.form.authority_list.push(type)
  159. }
  160. if(this.target_user_id) this.editFn()
  161. },
  162. async editFn(){
  163. let {
  164. data
  165. } = await http.postApi(config.API_FLK_CAR_EDIT_SHARE_USER,{
  166. ...this.form,
  167. })
  168. }
  169. }
  170. };
  171. </script>
  172. <style>
  173. @import './powerSetting.css';
  174. </style>