modificationOld.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 40px;">
  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" :class="quanxian.namealter?'namebg':''" />
  12. </view>
  13. <view class="mod_id">
  14. <p>设备ID</p>
  15. <input type="text" :value="moddata.imei || moddata.device_id || moddata.id" 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. <view style="width: 90%;">
  23. <p><span style="color: #ff0000;">*</span>设备位置</p>
  24. <input type="text" :value="city" disabled />
  25. </view>
  26. <u-icon name="arrow-right"></u-icon>
  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. quanxian:{
  48. namealter:false,
  49. cityalter:false,
  50. infoalter:false
  51. }
  52. }
  53. },
  54. methods: {
  55. async eqlistcity(lat, lng) { //修改设备定位
  56. const res = await this.$myRequest({
  57. url: '/api/api_gateway?method=forecast.worm_lamp.revise_device',
  58. data: {
  59. device_id: this.moddata.imei || this.moddata.device_id || this.moddata.id,
  60. lat: lat,
  61. lng: lng
  62. }
  63. })
  64. console.log(res)
  65. if (res==false) {
  66. uni.showToast({
  67. title: '修改地址失败!',
  68. icon: "none"
  69. });
  70. }else{
  71. uni.showToast({
  72. title: '修改地址成功!',
  73. icon: "none"
  74. });
  75. }
  76. },
  77. async eqlistname(lat, lng) { //修改设备名称
  78. const res = await this.$myRequest({
  79. url: '/api/api_gateway?method=forecast.worm_lamp.revise_device',
  80. data: {
  81. device_id: this.moddata.imei || this.moddata.device_id || this.moddata.id,
  82. device_name: this.moddata.device_name,
  83. lat: lat,
  84. lng: lng,
  85. }
  86. })
  87. console.log(res)
  88. if (res==false) {
  89. uni.showToast({
  90. title: '修改名称失败!',
  91. icon: "none"
  92. });
  93. }else{
  94. uni.showToast({
  95. title: '修改名称成功!',
  96. icon: "none"
  97. });
  98. uni.removeStorage({
  99. key: "location"
  100. })
  101. this.clickLeft()
  102. }
  103. },
  104. async eqlistuser(id, imei,device_model) { //获取设备信息
  105. const res = await this.$myRequest({
  106. url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
  107. data: {
  108. device_type_id: id,
  109. device_id: imei,
  110. device_model: device_model,
  111. }
  112. })
  113. this.moddata = res.data[0]
  114. this.selectaddress(this.moddata.lng, this.moddata.lat)
  115. },
  116. async xyeqlistuser(imei) { //获取设备信息
  117. const res = await this.$myRequest({
  118. url: '/api/api_gateway?method=sex_lure_nl.sex_lure.nl_device_list',
  119. data: {
  120. device_id: imei,
  121. }
  122. })
  123. this.moddata = res.data[0]
  124. this.selectaddress(this.moddata.lng, this.moddata.lat)
  125. },
  126. btn() {
  127. // this.eqlistcity(this.moddata.lat, this.moddata.lng)
  128. this.eqlistname(this.moddata.lat, this.moddata.lng)
  129. },
  130. clickLeft() {
  131. uni.navigateBack({
  132. delta:1,
  133. success:()=>{
  134. //告知上一页刷新数据
  135. uni.$emit('refreshData')
  136. }
  137. })
  138. },
  139. amendcity() { //修改设备地址
  140. // this.selectcityTF = true
  141. uni.navigateTo({
  142. url: "/pages/fourBase/city"
  143. })
  144. },
  145. selectaddress(lng, lat) { //获取分布位置
  146. uni.request({
  147. type: "GET",
  148. url: "https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=" + lng + "," + lat +
  149. "&key=27273b81090f78759e4057f94474516f&radius=1000&extensions=all",
  150. dataType: "json",
  151. complete: ress => {
  152. // console.log(ress)
  153. if (ress.data.regeocode.formatted_address.length == 0) {
  154. this.city = "--"
  155. } else {
  156. this.city = ress.data.regeocode.formatted_address
  157. }
  158. }
  159. });
  160. },
  161. },
  162. onLoad(option) {
  163. if(option.id==10){
  164. const data = JSON.parse(option.data)
  165. this.xyeqlistuser(data.device_id || data.id)
  166. }else{
  167. const data = JSON.parse(option.data)
  168. this.eqlistuser(data.type_id, data.imei || data.device_id || data.id,data.device_model)
  169. }
  170. uni.getStorage({
  171. key:"jurisdiction",
  172. success:(res)=>{
  173. console.log(res,'resresres')
  174. if(!res?.data){
  175. return;
  176. }
  177. let items = JSON.parse(res.data).filter((item)=>{
  178. return item.purview_name == "设备管理"
  179. })
  180. let items2 = items[0].children.filter((item)=>{
  181. return item.purview_name == "设备列表"
  182. })
  183. this.quanxian.namealter = items2[0].children.some((item)=>{
  184. return item.purview_name == "修改名称"
  185. })
  186. this.quanxian.cityalter = items2[0].children.some((item)=>{
  187. return item.purview_name == "添加位置"
  188. })
  189. this.quanxian.infoalter = items2[0].children.some((item)=>{
  190. return item.purview_name == "修改名称" || item.purview_name == "添加位置"
  191. })
  192. },
  193. })
  194. },
  195. onShow(){
  196. uni.getStorage({
  197. key: "location",
  198. success: (res) => {
  199. // console.log(res);
  200. this.moddata.lat = res.data[1]
  201. this.moddata.lng = res.data[0]
  202. this.selectaddress(this.moddata.lng, this.moddata.lat)
  203. }
  204. })
  205. }
  206. }
  207. </script>
  208. <style lang="scss">
  209. page{
  210. background-color: #FAFAFA;
  211. }
  212. .mod {
  213. width: 100%;
  214. position: absolute;
  215. top: 44px;
  216. .mod_name,
  217. .mod_id,
  218. .mod_user,
  219. .mod_time {
  220. width: 90%;
  221. margin: 30rpx auto;
  222. display: flex;
  223. justify-content: space-between;
  224. background-color: #FFFFFF;
  225. padding: 20rpx 10rpx;
  226. color: #57C77A;
  227. line-height: 50rpx;
  228. .namebg{
  229. background-color: #FAFAFA;
  230. }
  231. input {
  232. text-align: right;
  233. font-size: 28rpx;
  234. padding: 10rpx;
  235. }
  236. }
  237. .mod_city{
  238. width: 90%;
  239. margin: 30rpx auto;
  240. background-color: #FFFFFF;
  241. padding: 20rpx 10rpx;
  242. color: #57C77A;
  243. line-height: 50rpx;
  244. display: flex;
  245. justify-content: space-between;
  246. .namebg{
  247. background-color: #FAFAFA;
  248. }
  249. input {
  250. width: 90%;
  251. font-size: 28rpx;
  252. padding: 10rpx;
  253. }
  254. }
  255. }
  256. .sub {
  257. width: 90%;
  258. margin: 30rpx auto;
  259. text-align: center;
  260. height: 70rpx;
  261. line-height: 70rpx;
  262. background-color: #57C77A;
  263. border-radius: 35rpx;
  264. color: #FFFFFF;
  265. }
  266. </style>