| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <template>
- <view>
- <view class="status_bar"></view>
- <view class="" style="position: relative;top: 44px;">
- <view style="position: fixed;z-index: 100;">
- <uni-nav-bar @clickLeft="clickLeft" left-icon="back" title="修改名称"></uni-nav-bar>
- </view>
- <view class="mod">
- <view class="mod_name">
- <p><span style="color: #ff0000;">*</span>设备名称</p>
- <input type="text" v-model="moddata.device_name" style="background-color: #FAFAFA;" />
- </view>
- <view class="mod_id">
- <p>设备ID</p>
- <input type="text" :value="moddata.imei" disabled />
- </view>
- <view class="mod_user">
- <p>适配用户</p>
- <input type="text" :value="moddata.real_name==''?'无':moddata.real_name" disabled />
- </view>
- <view class="mod_city" @click="amendcity">
- <p><span style="color: #ff0000;">*</span>设备位置</p>
- <view style="display: flex;">
- <input type="text" :value="city" disabled style="width: 400rpx;" />
- <u-icon name="arrow-right"></u-icon>
- </view>
- </view>
- <view class="mod_time">
- <p>设备添加时间</p>
- <input type="text" :value="moddata.addtime|timeFormat()" disabled />
- </view>
- <p style="width: 90%;margin: 0 auto;text-align: right;color: #06B535;"><span style="color: #ff0000;">*</span>为可修改</p>
- <view class="sub" @click="btn">
- 提 交
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- moddata: [],
- city: "",
- selectcityTF: false
- }
- },
- methods: {
- async eqlistcity(lat, lng) { //修改设备定位
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=forecast.worm_lamp.revise_device',
- data: {
- device_id: this.moddata.imei,
- lat: lat,
- lng: lng
- }
- })
- console.log(res)
- if (res==false) {
- uni.showModal({
- title: "修改地址失败",
- icon: "none"
- })
- }
- },
- async eqlistname() { //修改设备名称
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=forecast.worm_lamp.revise_device',
- data: {
- device_id: this.moddata.imei,
- device_name: this.moddata.device_name,
- }
- })
- console.log(res)
- if (res==false) {
- uni.showModal({
- title: "修改名称失败",
- icon: "none"
- })
- }
- },
- async eqlistuser(id, imei) { //获取设备信息
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=forecast.worm_lamp.lamp_list',
- data: {
- device_type_id: id,
- device_id: imei,
- }
- })
- this.moddata = res.data[0]
- this.selectaddress(this.moddata.lng, this.moddata.lat)
- },
- btn() {
- this.eqlistcity(this.moddata.lat, this.moddata.lng)
- this.eqlistname()
- uni.removeStorage({
- key: "location"
- })
- this.clickLeft()
- },
- clickLeft() {
- uni.navigateBack({
- delta:1
- })
- },
- amendcity() { //修改设备地址
- this.selectcityTF = true
- uni.navigateTo({
- url: "../fourBase/city"
- })
- },
- selectaddress(lng, lat) { //获取分布位置
- uni.request({
- type: "GET",
- url: "https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=" + lng + "," + lat +
- "&key=27273b81090f78759e4057f94474516f&radius=1000&extensions=all",
- dataType: "json",
- complete: ress => {
- // console.log(ress)
- if (ress.data.regeocode.formatted_address.length == 0) {
- this.city = "--"
- } else {
- this.city = ress.data.regeocode.formatted_address
- }
- }
- });
- },
- },
- onLoad(option) {
- this.eqlistuser(option.id, JSON.parse(option.data).imei)
- },
- onShow(){
- uni.getStorage({
- key: "location",
- success: (res) => {
- // console.log(res);
- this.moddata.lat = res.data[1]
- this.moddata.lng = res.data[0]
- this.selectaddress(this.moddata.lng, this.moddata.lat)
- }
- })
-
- }
- }
- </script>
- <style lang="scss">
- .mod {
- width: 100%;
- position: absolute;
- top: 44px;
- height: 92vh;
- background-color: #FAFAFA;
- .mod_name,
- .mod_id,
- .mod_user,
- .mod_time,
- .mod_city {
- width: 90%;
- margin: 30rpx auto;
- display: flex;
- justify-content: space-between;
- background-color: #FFFFFF;
- padding: 20rpx 10rpx;
- color: #57C77A;
- line-height: 50rpx;
- input {
- text-align: right;
- font-size: 28rpx;
- padding: 10rpx;
- }
- }
- }
- .sub {
- width: 90%;
- margin: 30rpx auto;
- text-align: center;
- height: 70rpx;
- line-height: 70rpx;
- background-color: #57C77A;
- border-radius: 35rpx;
- color: #FFFFFF;
- }
- </style>
|