control.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <view class="container-view-contril">
  3. <scroll-view class="scroll-view flex-row" scroll-x="true">
  4. <view @tap="tapOpen" v-for="(item,index) of contrilList" :key="index" :data-item="item" class="contril-item flex-row">
  5. <img class="contril-item-img" :src="item.isTurnOn==0?item.offUrl:item.iconUrl" alt="">
  6. <text >{{item.name}}</text>
  7. </view>
  8. <view class="contril-item flex-row" @tap="toMoreFunctionSet">
  9. <img class="contril-item-img" src="https://qiniu.bms16.com/Ft3pNyStT22LP8Ds1Mru2LoTHadx" alt="">
  10. <text>{{$t("更多功能")}}</text>
  11. </view>
  12. </scroll-view>
  13. <view class="flex-row power-view">
  14. <view class="power-on-off flex-row" >
  15. <view :style="sliderStyle" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd" class="power-on-btn"><image style="width: 52rpx;height: 52rpx;" src="https://qiniu.bms16.com/Fkovrpq1bexe-Unal_VJREbLUhdu" mode=""></image></view>
  16. <view class="power-on-text" >滑动启动</view>
  17. </view>
  18. <view @tap="navToInputPages" class="car-change-battery flex-row">
  19. <view class="car-change-btn"><image style="width: 80rpx;height: 80rpx;" src="https://qiniu.bms16.com/FgvnT-msLbL5RHjl6fvNlM0kab5N" mode=""></image></view>
  20. <view class="car-change-text">车辆换电</view>
  21. </view>
  22. </view>
  23. <view v-if="popupControlShow" class="show-modal">
  24. <view class="modal-info">
  25. <view class="popup-title">{{($t(popText)==$t('开机'))?$t('开启车辆'):($t(popText)==$t('关机')?$t('关闭车辆'):$t(popText))}}</view>
  26. <view class="popup-content">{{$t("您确认")+(($t(popText)==$t('开机'))?$t('开启车辆'):($t(popText)==$t('关机')?$t('关闭车辆'):$t(popText)))+$t("吗")}}</view>
  27. <view class="flex-row modal-footer">
  28. <view class="show-btn cencel-btn-pop" @tap="closePopup">{{$t("取消")}}</view>
  29. <view class="show-btn ok-btn-pop" @tap="tapBlueToothCmd">{{$t("确定")}}</view>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- <u-popup v-model="popupControlShow" mode="center" border-radius="30" height="30%" length="60%">
  34. <view class="popup-title">开启车辆</view>
  35. <view class="popup-content">确定打开</view>
  36. <view class="flex-row">
  37. <view class="sure-btn cencel-btn" @tap="closePopup">取消</view>
  38. <view class="sure-btn ok-btn" >确定</view>
  39. </view>
  40. </u-popup> -->
  41. <!-- <view v-if="isShowMore" class="show-more">
  42. <view class="more-info">
  43. <view class="flex-row flex-between model-title">
  44. <view>{{$t("更多功能")}}</view>
  45. <view>
  46. <image style="width: 32rpx;height: 32rpx;" @tap="isShowMore = false"
  47. src="https://qiniu.bms16.com/FtoTEHOJiUf_gjPCJGGHMsAtHI5M" />
  48. </view>
  49. </view>
  50. <view style="height: 300rpx;">
  51. <view data-url="test" @tap="navUrl" class="more-item flex-row">
  52. <img class="more-img" src="https://qiniu.bms16.com/FgxiD-W96FGvgyLI_kXUfWVDYLQ9" alt="">
  53. <text>{{$t("胎压")}}</text>
  54. </view>
  55. <view class="more-item flex-row">
  56. <img class="more-img" src="https://qiniu.bms16.com/FgxiD-W96FGvgyLI_kXUfWVDYLQ9" alt="">
  57. <text>{{$t("电池信息")}}</text>
  58. </view>
  59. <view @tap="navCarLocation" class="more-item flex-row">
  60. <img class="more-img" src="https://qiniu.bms16.com/FgxiD-W96FGvgyLI_kXUfWVDYLQ9" alt="">
  61. <text>{{$t("导航")}}</text>
  62. </view>
  63. </view>
  64. <view class="lift-btn-view">
  65. <view class="lift-btn">{{$t("解除绑定")}}</view>
  66. </view>
  67. </view>
  68. </view>
  69. -->
  70. <Confirm v-model="comboDialoginfo.showConfirm" :dialog-info="comboDialoginfo" @confirm="dialogConfirm" />
  71. </view>
  72. </template>
  73. <script>
  74. var bluetooth = require('@/common/bluetooth.js');
  75. var config = require('@/common/config.js');
  76. var common = require('@/common/common.js');
  77. var http = require('@/common/http.js');
  78. import Confirm from '@/component/comPopup/Confirm'
  79. import controlMixin from '@/mixin/index';
  80. import i18n from '@/locale/index.js'
  81. import {
  82. getFunctionTag,
  83. setFunctionTag
  84. } from '@/common/storage.js';
  85. export default {
  86. mixins: [controlMixin],
  87. props:{
  88. contrilList: {
  89. type: Array,
  90. default: () => []
  91. },
  92. online: {
  93. type: Boolean,
  94. default: false
  95. },
  96. },
  97. components: {
  98. Confirm,
  99. },
  100. data() {
  101. return {
  102. // popText:'',
  103. // popupControlShow:false,
  104. // controlType:null,//选择的车辆控制
  105. isShowMore:false,
  106. car_line:false,
  107. startX: 0, // 滑块开始滑动的初始位置
  108. moveX: 0, // 滑块滑动的距离
  109. unlocked: false, // 是否解锁成功的标志
  110. };
  111. },
  112. computed: {
  113. // 计算滑块的样式
  114. sliderStyle() {
  115. return {
  116. transform: `translateX(${this.moveX}px)`
  117. };
  118. }
  119. },
  120. mounted() {
  121. // this.contrilList = getFunctionTag().activeTag
  122. },
  123. /**
  124. * 组件的方法列表
  125. */
  126. methods: {
  127. tapOpen(e){
  128. const item = e.currentTarget.dataset.item;
  129. this.changClick(item)
  130. },
  131. toMoreFunctionSet() {
  132. uni.navigateTo({
  133. url: '/pages/carFunctionSet/more?online='+this.online
  134. })
  135. },
  136. touchStart(event) {
  137. console.log(event,'test');
  138. this.startX = this.unlocked?this.moveX:event.touches[0].clientX;
  139. },
  140. touchMove(event) {
  141. this.moveX = event.touches[0].clientX - this.startX;
  142. console.log( event.touches[0].clientX,this.startX,'this.moveX');
  143. if (this.moveX < 0) this.moveX = 0;
  144. if (this.moveX > 70 &&!this.unlocked) this.moveX = 135; // 假设滑块最大滑动距离为135px
  145. },
  146. touchEnd() {
  147. console.log(this.moveX,'this.moveX1111');
  148. if (this.moveX >= 135) {
  149. this.unlocked = true;
  150. console.log('解锁成功');
  151. } else {
  152. // this.moveX = 0;
  153. }
  154. }
  155. // tapOpen(e){
  156. // this.carOnline=this.online
  157. // console.log( getFunctionTag().activeTag, getFunctionTag());
  158. // const {name,type} = e.currentTarget.dataset.item;
  159. // this.setData({
  160. // popText:name,
  161. // cmdType:type,
  162. // popupControlShow:true
  163. // })
  164. // },
  165. // tapBlueToothCmd(){
  166. // const car_info= uni.getStorageSync('car_info');
  167. // const me=this
  168. // // 判断车辆是否在线状态 true 在线调用接口 不在线提示连接蓝牙
  169. // if (this.online) {
  170. // if(this.cmdType=='batteryInfo'){
  171. // uni.navigateTo({
  172. // url:`/pages/batteryDetail/batteryDetail`
  173. // })
  174. // }else if(this.cmdType=='navigation'){
  175. // const {
  176. // address,
  177. // latitude,
  178. // longitude,
  179. // car_name
  180. // } =car_info
  181. // uni.openLocation({
  182. // latitude: latitude - 0,
  183. // longitude: longitude - 0,
  184. // scale: 15,
  185. // name: car_name,
  186. // address: address,
  187. // success: function (res) {},
  188. // })
  189. // }else if(this.cmdType=='turnOnOrOff'){
  190. // const switchType=this.contrilList.find(item => item.isTurnOn)
  191. // const pData={
  192. // car_sn:car_info.car_sn,
  193. // switch:switchType
  194. // }
  195. // const me=this
  196. // common.loading();
  197. // http.postApi(config.API_FLK_CAR_SWITCH, pData, (resp) => {
  198. // uni.hideLoading();
  199. // if (resp.data.code === 200) {
  200. // common.simpleToast(me.popText + '成功');
  201. // const activeTag=me.contrilList.map(item=>{
  202. // item.isTurnOn=(item.isTurnOn==1)?0:1
  203. // item.name=i18n.t((item.isTurnOn==1)?'关机':'开机')
  204. // return item
  205. // })
  206. // const tag=getFunctionTag().tag
  207. // setFunctionTag({activeTag,tag})
  208. // } else {
  209. // common.simpleToast(resp.data.msg);
  210. // }
  211. // });
  212. // }else{
  213. // const testArr=[
  214. // {type:'findCar',opt_type:1},
  215. // {type:'openSeatBag',opt_type:0},
  216. // {type:'openTailBox',opt_type:2},
  217. // ]
  218. // const pData = testArr.find(i=>i.type===this.cmdType)
  219. // const me=this
  220. // common.loading();
  221. // http.postApi(config.API_FLK_CAR_REMOTE_CONTROL, pData, (resp) => {
  222. // uni.hideLoading();
  223. // if (resp.data.code === 200) {
  224. // common.simpleToast(me.popText + '成功');
  225. // } else {
  226. // common.simpleToast(resp.data.msg);
  227. // }
  228. // });
  229. // }
  230. // } else {
  231. // //蓝牙是否已经连接 未连接提示去连接 已连接下发对应指令
  232. // const isBluetoothConnect = app.globalData.connectionStateChangeFunc[car_info.car_sn]
  233. // if(isBluetoothConnect){
  234. // const isTurnOn=this.contrilList.find(item => item.isTurnOn).isTurnOn==1
  235. // console.log(isTurnOn,this.cmdType,this.contrilList);
  236. // const bluetoothCommands = {
  237. // 'turnOnOrOff': isTurnOn?bluetooth.turnOnCar:bluetooth.turnOffCar,
  238. // 'findCar': bluetooth.findCarCmd,
  239. // 'openSeatBag': bluetooth.openCarSeat,
  240. // 'openTailBox': bluetooth.openCarTrunk,
  241. // 'tirePressure': bluetooth.getCarPressure
  242. // };
  243. // common.loading();
  244. // const command = bluetoothCommands[this.cmdType];
  245. // if (command) {
  246. // command('900000997', () => {
  247. // uni.hideLoading();
  248. // if(this.cmdType=='openSeatBag'||this.cmdType=='openTailBox'){
  249. // common.simpleToast('操作成功');
  250. // }
  251. // console.log(`发送${this.popText}指令结束`);
  252. // });
  253. // }
  254. // }else{
  255. // uni.showModal({
  256. // title: '提示',
  257. // content: '当前车辆处于离线,是否前往开启蓝牙配对操作车辆?',
  258. // showCancel: true,
  259. // cancelText: '取消',
  260. // confirmText: '确定',
  261. // success: function(res) {
  262. // if (res.confirm) {
  263. // me.$emit('toBluetooth')
  264. // }
  265. // },
  266. // fail: function(res) {},
  267. // complete: function(res) {},
  268. // })
  269. // }
  270. // }
  271. // this.popupControlShow=false
  272. // },
  273. // // closePopup(){
  274. // this.popupControlShow=false
  275. // },
  276. // tapOpenMore(){
  277. // // this.isShowMore=true
  278. // },
  279. // closeMore(){
  280. // this.isShowMore=false
  281. // },
  282. // navUrl(url){
  283. // // ifconsole.log(url,'sj');
  284. // },
  285. // navCarLocation(){
  286. // //前往配置更多功能
  287. // uni.navigateTo({
  288. // url:'/pages/carLocation/carLocation'
  289. // })
  290. // },
  291. }
  292. };
  293. </script>
  294. <style>
  295. @import './control.css';
  296. </style>