modification.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 44px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" title="修改名称"></uni-nav-bar>
  7. </view>
  8. <view class="mod">
  9. <view class="mod_name">
  10. <p><span style="color: #ff0000;">*</span>设备名称</p>
  11. <input type="text" v-model="moddata.device_name" style="background-color: #FAFAFA;" />
  12. </view>
  13. <view class="mod_id">
  14. <p>设备ID</p>
  15. <input type="text" :value="moddata.imei" disabled />
  16. </view>
  17. <view class="mod_user">
  18. <p>适配用户</p>
  19. <input type="text" :value="moddata.real_name==''?'无':moddata.real_name" disabled />
  20. </view>
  21. <view class="mod_city" @click="amendcity">
  22. <p><span style="color: #ff0000;">*</span>设备位置</p>
  23. <view style="display: flex;">
  24. <input type="text" :value="city" disabled style="width: 400rpx;" />
  25. <u-icon name="arrow-right"></u-icon>
  26. </view>
  27. </view>
  28. <view class="mod_time">
  29. <p>设备添加时间</p>
  30. <input type="text" :value="moddata.addtime|timeFormat()" disabled />
  31. </view>
  32. <p style="width: 90%;margin: 0 auto;text-align: right;color: #06B535;"><span style="color: #ff0000;">*</span>为可修改</p>
  33. <view class="sub" @click="btn">
  34. 提 交
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. moddata: [],
  45. city: "",
  46. selectcityTF: false
  47. }
  48. },
  49. methods: {
  50. async eqlistcity(lat, lng) { //修改设备定位
  51. const res = await this.$myRequest({
  52. url: '/api/api_gateway?method=forecast.worm_lamp.revise_device',
  53. data: {
  54. device_id: this.moddata.imei,
  55. lat: lat,
  56. lng: lng
  57. }
  58. })
  59. console.log(res)
  60. if (res==false) {
  61. uni.showModal({
  62. title: "修改地址失败",
  63. icon: "none"
  64. })
  65. }
  66. },
  67. async eqlistname() { //修改设备名称
  68. const res = await this.$myRequest({
  69. url: '/api/api_gateway?method=forecast.worm_lamp.revise_device',
  70. data: {
  71. device_id: this.moddata.imei,
  72. device_name: this.moddata.device_name,
  73. }
  74. })
  75. console.log(res)
  76. if (res==false) {
  77. uni.showModal({
  78. title: "修改名称失败",
  79. icon: "none"
  80. })
  81. }
  82. },
  83. async eqlistuser(id, imei) { //获取设备信息
  84. const res = await this.$myRequest({
  85. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  86. data: {
  87. device_type_id: id,
  88. device_id: imei,
  89. }
  90. })
  91. this.moddata = res.data[0]
  92. this.selectaddress(this.moddata.lng, this.moddata.lat)
  93. },
  94. btn() {
  95. this.eqlistcity(this.moddata.lat, this.moddata.lng)
  96. this.eqlistname()
  97. uni.removeStorage({
  98. key: "location"
  99. })
  100. this.clickLeft()
  101. },
  102. clickLeft() {
  103. uni.navigateBack({
  104. delta:1
  105. })
  106. },
  107. amendcity() { //修改设备地址
  108. this.selectcityTF = true
  109. uni.navigateTo({
  110. url: "../fourBase/city"
  111. })
  112. },
  113. selectaddress(lng, lat) { //获取分布位置
  114. uni.request({
  115. type: "GET",
  116. url: "https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=" + lng + "," + lat +
  117. "&key=27273b81090f78759e4057f94474516f&radius=1000&extensions=all",
  118. dataType: "json",
  119. complete: ress => {
  120. // console.log(ress)
  121. if (ress.data.regeocode.formatted_address.length == 0) {
  122. this.city = "--"
  123. } else {
  124. this.city = ress.data.regeocode.formatted_address
  125. }
  126. }
  127. });
  128. },
  129. },
  130. onLoad(option) {
  131. this.eqlistuser(option.id, JSON.parse(option.data).imei)
  132. },
  133. onShow(){
  134. uni.getStorage({
  135. key: "location",
  136. success: (res) => {
  137. // console.log(res);
  138. this.moddata.lat = res.data[1]
  139. this.moddata.lng = res.data[0]
  140. this.selectaddress(this.moddata.lng, this.moddata.lat)
  141. }
  142. })
  143. }
  144. }
  145. </script>
  146. <style lang="scss">
  147. .mod {
  148. width: 100%;
  149. position: absolute;
  150. top: 44px;
  151. height: 92vh;
  152. background-color: #FAFAFA;
  153. .mod_name,
  154. .mod_id,
  155. .mod_user,
  156. .mod_time,
  157. .mod_city {
  158. width: 90%;
  159. margin: 30rpx auto;
  160. display: flex;
  161. justify-content: space-between;
  162. background-color: #FFFFFF;
  163. padding: 20rpx 10rpx;
  164. color: #57C77A;
  165. line-height: 50rpx;
  166. input {
  167. text-align: right;
  168. font-size: 28rpx;
  169. padding: 10rpx;
  170. }
  171. }
  172. }
  173. .sub {
  174. width: 90%;
  175. margin: 30rpx auto;
  176. text-align: center;
  177. height: 70rpx;
  178. line-height: 70rpx;
  179. background-color: #57C77A;
  180. border-radius: 35rpx;
  181. color: #FFFFFF;
  182. }
  183. </style>