powerSetting.vue 4.9 KB

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