cuiqian2004
4 天以前 2af5f043b60c1f7ac38ecccc8f5bf44743134325
pages/index/connect.vue
@@ -2,51 +2,51 @@
   <view class="pages-vehicle-connect">
      <view class="content" v-if="connectState == 1">
         <view class="title">连接中</view>
         <view class="title">{{translate('connecting')}}</view>
         <view class="content2">
            <view class="auto-circle"></view>
            <view>连接中...</view>
            <view>{{translate('connecting')}}...</view>
         </view>
      </view>
      <view class="content" v-else-if="connectState == 2">
         <view class="title">连接成功</view>
         <view class="title">{{translate('connection_success')}}</view>
         <view class="content2">
            <image class="img" src="/images/Frame_178.svg" alt=" 图片" />
            <view>【{{connectedDevice}}】连接成功</view>
            <image class="img" src="/images/Frame_178.svg" alt=" picture" />
            <view>【{{connectedDevice}}】{{translate('connection_success')}}</view>
         </view>
      </view>
      <view class="content" v-else-if="connectState == 3">
         <view class="title">连接失败</view>
         <view class="title">{{translate('connection_failed')}}</view>
         <view class="content2">
            <image class="img" src="/images/Frame_179.svg" alt=" 图片" />
            <view class="title">无法连接设备</view>
            <view>请确保车辆开机且未与其他终端配对</view>
            <image class="img" src="/images/Frame_179.svg" alt=" picture" />
            <view class="title">{{translate('unable_connect_device')}}</view>
            <view>{{translate('check_vehicle_not_paired_other_terminals')}}</view>
         </view>
      </view>
      <view class="content" v-else-if="connectState == 4">
         <view class="title">连接准备</view>
         <view class="title">{{translate('connection_preparation')}}</view>
         <view class="content2">
            <view>1、请将手机连接到‘{{ip}}’的Wifi网络</view>
            <view>2、连接后回到本应用</view>
            <image class="img-2" src="/images/Frame_180.svg" alt=" 图片" />
            <view>1、{{translate("connect_phone_to_this_ip_wifi",[ip]) }}</view>
            <view>2、{{translate('after_connect_return_this')}}</view>
            <image class="img-2" src="/images/Frame_180.svg" alt=" picture" />
         </view>
      </view>
      <view class="content" v-else>
         <view class="title">连接准备</view>
         <view class="title">{{translate('connection_preparation')}}</view>
      </view>
      <view v-if="connectState == 3" class="button-group">
         <a-button type="primary" plain="true" class="button" @click="clickTry">
            {{reconnectFlag ? "重新连接WiFi":"重试"}}
            {{reconnectFlag ? translate('reconnect_wifi'):translate('retry')}}
         </a-button>
         <a-button  type="ghost" class="button" @click="clickCancel">取消
         <a-button type="ghost" class="button" @click="clickCancel">{{translate('cancel')}}
         </a-button>
         <view class="link-text"> <a @click="clickStudyMore">学习更多...</a> </view>
         <view class="link-text"> <a @click="clickStudyMore">{{translate('more')}}...</a> </view>
      </view>
      <view v-if="connectState == 4" class="button-group">
         <a-button type="primary" plain="true" class="button" @click="clickLinkWifi">去连接
         <a-button type="primary" plain="true" class="button" @click="clickLinkWifi">{{translate('go_connect')}}
         </a-button>
         <a-button  type="ghost" class="button" @click="clickTry">切换扫码连接
         <a-button type="ghost" class="button" @click="clickTry">{{translate('switch_scan_connection')}}
         </a-button>
      </view>
   </view>
@@ -96,6 +96,7 @@
         this.wifiPassword = option.passwpord || ""
         this.reconnectFlag = option.reconnect ? true : false
         this.unloadFlag = false
         this.loadData()
      },
      onUnload() {
@@ -145,7 +146,7 @@
            } catch (ex) {
               showError(ex)
               showError(ex, this.translate('error'))
            }
         },
         checkConnectStatus() {
@@ -183,11 +184,11 @@
                     const result = res.result || ""
                     const arCode = result.split(";")
                     if (arCode.length != 3) {
                        showInfo("无效的二维码!")
                        showToast(this.translate('invalid_qr_code'))
                        return
                     }
                     if (!arCode[0].trim() || !arCode[0].trim()) {
                  showInfo("无效的二维码!")
                        showToast(this.translate('invalid_qr_code'))
                        return
                     }
                     that.ip = arCode[0]
@@ -236,7 +237,12 @@
            console.log("connectWifi", ssid)
            if (`"${this.wifiSID}"` != ssid && `${this.wifiSID}` != ssid) {
               if (platform == "android" && osVersion < 10) {
                  showModal(`【${app.globalData.deviceModel}】想加入无线局域网【${this.wifiSID}】吗?`, "询问").then((res) => {
                  showModal({
                        content: `${this.translate('ask_join_wlan',[this.this.ip,this.wifiSID])}`,
                        confirmText: this.translate('join'),
                        cancelText: this.translate("cancel"),
                     }
                  ).then((res) => {
                     if (res) {
                        this.connectState = 1
@@ -293,7 +299,7 @@
            } catch (ex) {
               console.log("connectVehicle faile",this.ip,ex)
               this.connectState = 3
               // showError(ex)
               // showError(ex,this.translate('error'))
            }
         },
@@ -344,8 +350,7 @@
            if (this.unloadFlag) {
               return
            }
            if(sec <= 0)
            {
            if (sec <= 0) {
               this.connectState = 3
               return
            }
@@ -361,6 +366,17 @@
                  this.checkConnectVehicle(sec- 7)
               }, 2000)
            })
         },
         translate(t, values) {
            if (typeof this.$t == "function") {
               const message = this.$t(`page.${t}`)
               if (values) {
                  return message.replace(/{(\d+)}/g, (match, index) => {
                     const value = values[index]
                     return value !== undefined ? value : match
                  })
               } else return message
            } else return t;
         },
      }
   }
@@ -438,7 +454,7 @@
         .button {
            margin: 20rpx !important;
            width: 320rpx !important;
            width: 400rpx !important;
            border-radius: 4rpx;
         }
      }