powerSetting.vue 4.9 KB

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