123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510 |
- <template>
- <view class="container-view-contril">
- <scroll-view class="scroll-view flex-row" scroll-x="true">
- <view @tap="tapOpen" v-for="(item,index) of contrilList" :key="index" :data-item="item" class="contril-item flex-row">
- <img class="contril-item-img" :src="isOverdueShow?item.disableUrl:(item.isTurnOn==0?item.offUrl:item.iconUrl)" alt="">
- <text >{{item.name}}</text>
- </view>
- <view class="contril-item flex-row" @tap="toMoreFunctionSet">
- <img class="contril-item-img" src="https://qiniu.bms16.com/Ft3pNyStT22LP8Ds1Mru2LoTHadx" alt="">
- <text>{{$t("更多功能")}}</text>
- </view>
- </scroll-view>
- <view class="flex-row power-view">
-
- {{ $t('滑动启动') }}
- <custom-switch @changEnd='changEnd' :width="'400rpx'"
- :height="'96rpx'" :modelValue="switchValue" :fetchData="loadData"></custom-switch>
-
-
-
- <view v-if="authority_list.indexOf(5) == -1" @tap="navToInputPages" class="car-change-battery flex-row">
- <view class="car-change-btn"><image style="width: 80rpx;height: 80rpx;" src="https://qiniu.bms16.com/FgvnT-msLbL5RHjl6fvNlM0kab5N" mode=""></image></view>
- <view class="car-change-text">{{ $t('车辆换电') }}</view>
- </view>
- </view>
- <view v-if="popupControlShow" class="show-modal">
- <view class="modal-info">
- <view class="popup-title">{{($t(popText)==$t('开机'))?$t('开启车辆'):($t(popText)==$t('关机')?$t('关闭车辆'):$t(popText))}}</view>
- <view class="popup-content">{{$t("您确认")+(($t(popText)==$t('开机'))?$t('开启车辆'):($t(popText)==$t('关机')?$t('关闭车辆'):$t(popText)))+$t("吗")}}</view>
- <view class="flex-row modal-footer">
- <view class="show-btn cencel-btn-pop" @tap="closePopup">{{$t("取消")}}</view>
- <view class="show-btn ok-btn-pop" @tap="tapBlueToothCmd">{{$t("确定")}}</view>
- </view>
- </view>
- </view>
-
- {{ $t('开启车辆') }}
- {{ $t('确定打开') }}
- {{ $t('取消') }}
- {{ $t('确定') }}
-
- {{$t("{{ $t('更多功能') }}")}}
- {{$t("{{ $t('胎压') }}")}}
- {{$t("{{ $t('电池信息') }}")}}
- {{$t("{{ $t('导航') }}")}}
- {{$t("{{ $t('解除绑定') }}")}}
- </view>
- </template>
- <script>
- var bluetooth = require('@/common/bluetooth.js');
- var config = require('@/common/config.js');
- var common = require('@/common/common.js');
- var http = require('@/common/http.js');
- import CustomSwitch from '@/component/customSwitch.vue';
-
- import controlMixin from '@/mixin/index';
- import {Language} from '@/utils/util.js'
- import {
- getFunctionTag,
- setFunctionTag
- } from '@/common/storage.js';
- export default {
- mixins: [controlMixin],
- components:{CustomSwitch},
- props:{
- contrilList: {
- type: Array,
- default: () => []
- },
- online: {
- type: Boolean,
- default: false
- },
- isOverdueShow: {
- type: Boolean,
- default: false
- },
- isConnectBlueth: {
- type: Boolean,
- default: false
- }
- },
- data() {
- return {
-
-
-
- switchValue: {state:false,time:0},
- isShowMore:false,
- car_line:false,
- authority_list:[],
- Language,
-
-
-
-
- };
- },
- computed: {
-
- sliderStyle() {
- return {
- transform: `translateX(${this.moveX}px)`
- };
- },
- },
- mounted() {
-
-
- this.authority_list=uni.getStorageSync('car_info').authority_list
- this.switchValue.state=uni.getStorageSync('car_info').acc_state==1
-
-
-
-
-
-
- },
-
-
- methods: {
- changEnd(e){
- this.switchValue = JSON.parse(e)
- if(this.switchValue.type==1){
- this.callApiThreeTimes()
- }
- console.log(this.switchValue)
- },
- callApiThreeTimes() {
- const apiCall = (attempt) => {
- const car_sn= uni.getStorageSync('car_info').car_sn
- this.$emit('loadCarDetail',car_sn)
- };
- apiCall(1);
-
-
- },
- tapOpen(e){
- if(this.isOverdueShow) return
- const item = e.currentTarget.dataset.item;
- this.changClick(item)
- },
- toMoreFunctionSet() {
- uni.navigateTo({
- url: '/pages/carFunctionSet/more?online='+this.online
- })
- },
- trunOn(type){
-
- if (this.carOnline) {
-
- const car_sn= uni.getStorageSync('car_info').car_sn;
- const pData = {
- car_sn,
- switch: switchType
- }
- const me=this
- common.loading();
- http.postApi(config.API_FLK_CAR_SWITCH, pData, (resp) => {
- uni.hideLoading();
- if (resp.data.code === 200) {
- common.simpleToast(me.popText + this.$t('成功'));
- const activeTag = me.contrilList.map(item => {
- if('isLock' in item){
- item.isTurnOn = (item.isTurnOn == 1) ? 0 : 1
- item.name = i18n.t((item.isTurnOn == 1) ? this.$t('关机') : this.$t('开机'))
- }
- return item
- })
- const tag = getFunctionTag().tag
- setFunctionTag({
- activeTag,
- tag
- })
- me.$emit('loadCarDetail',pData,car_sn)
- } else {
- common.simpleToast(resp.data.msg);
- }
- });
- }else{
-
- const car_sn= uni.getStorageSync('car_info').car_sn;
- common.loading();
- if (type==1) {
- bluetooth.turnOnCar(car_sn, () => {
- uni.hideLoading();
- });
- }else{
- bluetooth.turnOffCar(car_sn, () => {
- uni.hideLoading();
- });
- }
- }
- },
- async navToInputPages() {
- const me = this
- const exchange_need_package=uni.getStorageSync('car_info').exchange_need_package;
- if(exchange_need_package==0){
- uni.scanCode({
- scanType:['qrCode'],
- success(res) {
- me.loadGeneralQRData(res.result)
- },
- fail() {
- me.$msg(this.$t('扫码失败,请重新扫码'))
- }
- })
- }else if(exchange_need_package==1){
- uni.showModal({
- title: this.$t('温馨提示'),
- content: this.$t('您还未购买换电套餐,是否前往购买换电套餐?'),
- showCancel: true,
- cancelText: this.$t('取消'),
- confirmText: this.$t('前往购买'),
- success: function(res) {
- if (res.confirm) {
- uni.navigateTo({
- url: `/pages/batteryPackage/batteryPackage`
- })
-
- }
- },
- fail: function(res) {},
- complete: function(res) {},
- })
- }else if(exchange_need_package==-1){
- this.$msg(this.$t('当前车辆暂未绑定电池'))
- }
-
- },
- loadGeneralQRData(options) {
- console.log(options)
- let objOpt = this.$paramsObj(options)
-
- if (objOpt.d) {
- uni.navigateTo({
- url: `/pages/cabinetDetail/cabinetDetail?dev_id=${objOpt.d}`,
- })
- return
- } else {
- this.$msg(this.$t('请扫描机柜二维码'))
- return
- }
- },
-
- async loadData(state) {
-
- return new Promise((resolve,reject) => {
- if (uni.getStorageSync('car_info').online==1) {
-
- const car_sn= uni.getStorageSync('car_info').car_sn;
- const switchType= state?0:1;
- const pData = {
- car_sn,
- switch: switchType
- }
- const me=this
- http.postApi(config.API_FLK_CAR_SWITCH, pData, (resp) => {
- if (resp.data.code === 200) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- setTimeout(() => {
-
- resolve(JSON.stringify({
- state:!state,
- type:1,
- time: Math.floor(Date.now() / 1000)
- }))
- console.log(132);
-
-
-
-
-
- }, 1000)
-
- } else {
- setTimeout(() => {
- resolve(JSON.stringify({
- state:state,
- type:2,
- time:Math.floor(Date.now() / 1000)
- }))
-
-
-
-
-
-
- }, 1000)
-
-
- }
- });
- }else{
-
- const car_sn= uni.getStorageSync('car_info').car_sn;
- const switchType= state;
- common.loading();
- const app=getApp()
-
-
- if (!switchType) {
- bluetooth.turnOnCar(car_sn, () => {
- uni.hideLoading();
- });
- }else{
- bluetooth.turnOffCar(car_sn, () => {
- uni.hideLoading();
- });
- }
- }
-
-
-
- });
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- };
- </script>
- <style>
- @import './control.css';
- </style>
|