index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <template>
  2. <view class="tabbar-wrap">
  3. <view class="tabbar">
  4. <view
  5. v-for="(item, index) in tabs"
  6. :key="index"
  7. class="tab-item"
  8. @tap="routerPush(item.url)"
  9. >
  10. <img :src="curtTab === item.name ? item.activeIcon : item.icon" class="tab-icon"/>
  11. <text :class="['base-text', curtTab === item.name && 'checked']">{{ item.label }}</text>
  12. </view>
  13. <view v-if="!isScanCondeRentalCar" class="center-entrance" @tap="navToInputPage">
  14. <img src="https://qiniu.bms16.com/Fm_kDVr1TIeIbbBW6-5bz0r-cECO" style="width: 122rpx; height: 122rpx;"/>
  15. <!-- <img src="https://qiniu.bms16.com/FhCHLz8rQJ5mpJ6nUA4RbKiVkUOo" style="width: 120rpx; height: 24rpx;"/> -->
  16. </view>
  17. <view v-else class="center-entrance" @tap="navToInputPage">
  18. <img src="https://qiniu.bms16.com/FqcCjRjhzHFUkZj76SMHNXCZHwb3" style="width: 122rpx; height: 122rpx;margin-bottom: 14rpx;"/>
  19. <view class="scan-text">扫一扫</view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. var app = getApp();
  26. const storage = require('@/common/storage.js');
  27. const http = require('@/common/http.js');
  28. const config = require('../../common/config.js');
  29. const common = require('../../common/common.js');
  30. const appWhiteListFilter = require('../../common/appWhiteListFilter.js');
  31. import homeIcon from '@/static/resource/images/home-w.png';
  32. import homeIconChecked from '@/static/resource/images/home_b.png';
  33. import myIcon from '@/static/resource/images/my_w.png';
  34. import myIconChecked from '@/static/resource/images/my-b.png';
  35. export default {
  36. props: {
  37. curtTab: {
  38. type: String,
  39. default: 'home'
  40. }
  41. },
  42. data() {
  43. return {
  44. tabs: [
  45. { label: '设备', name: 'home', url: '/pages/index/index',
  46. icon: '/static/resource/images/home-w.png',
  47. activeIcon: '/static/resource/images/home_b.png' ,
  48. },
  49. { label: '服务', name: 'service', url: '/pages/index/index',
  50. icon: '/static/resource/images/service_w.png',
  51. activeIcon: '/static/resource/images/home_b.png' ,
  52. },
  53. { label: '活动', name: 'active', url: '/pages/my/my',
  54. icon: '/static/resource/images/active_w.png',
  55. activeIcon: '/static/resource/images/home_b.png' ,
  56. },
  57. { label: '我的', name: 'my', url: '/pages/my/my',
  58. icon: '/static/resource/images/my_w.png',
  59. activeIcon: '/static/resource/images/home_b.png' ,
  60. },
  61. ],
  62. userInfo: {
  63. is_auth: 0,
  64. status: 0
  65. },
  66. accountInfo: uni.getAccountInfoSync(),
  67. plate_number: '',
  68. isScanCondeRentalCar: false,
  69. };
  70. },
  71. created: function () {
  72. if (appWhiteListFilter.isScanCondeRentalCar()) {
  73. this.setData({
  74. isScanCondeRentalCar: true
  75. })
  76. }
  77. },
  78. methods: {
  79. routerPush(url) {
  80. uni.switchTab({ url });
  81. },
  82. loadFaceToken() {
  83. const me = this
  84. http.postApi(config.API_USER_FACE_TOKEN, {}, (resp) => {
  85. if (resp.data.code === 200) {
  86. me.face_token = resp.data.data.token
  87. me.face_key = resp.data.data.key
  88. uni.navigateTo({
  89. url: '/pages/livenessView/livenessView?face_token=' + me.face_token +
  90. '&face_key=' + this.face_key,
  91. success: function(res) {},
  92. fail: function(res) {},
  93. complete: function(res) {},
  94. })
  95. } else {
  96. common.simpleToast(resp.data.msg)
  97. }
  98. })
  99. },
  100. _getParams() {
  101. return new Promise((reslove ,reject) => {
  102. http.postApi(config.API_DAYHIRE_CAR_CAR_LIST, {}, res => {
  103. const { data = [], wait_active_predetermine = null } = res.data.data
  104. const obj = {
  105. carList: data,
  106. wait_active_predetermine,
  107. order_status: data.length ? data[0].order_status : 0
  108. }
  109. reslove(obj)
  110. })
  111. })
  112. },
  113. loadScanCode(location,battery_sn) {
  114. const pData = {
  115. longitude: location.longitude,
  116. latitude: location.latitude,
  117. battery_sn: battery_sn
  118. }
  119. const me = this
  120. http.postApi(config.API_DAYHIRE_CAR_CAR_INFO, pData, (resp) => {
  121. uni.hideLoading()
  122. if (resp.data.code === 200) {
  123. const timestamp = Date.now(); // 获取当前时间戳(毫秒)
  124. const isOffline = (Math.floor(timestamp / 1000) - resp.data.data.last_comm_time) > 1800
  125. me.plate_number = resp.data.data.license_plate_number
  126. if (resp.data.data.last_comm_time === 0 || isOffline) {
  127. common.simpleToast('此车辆已离线,请选择其他车辆')
  128. } else {
  129. let carInfo = JSON.stringify(resp.data.data)
  130. const car_model = resp.data.data.model_info.car_model
  131. const model_images = resp.data.data.model_info.model_images.split(',')
  132. const return_imgs = resp.data.data.return_imgs
  133. var model_id = resp.data.data.model_info.model_id
  134. if (resp.data.data.has_owner) { //车辆正在被使用
  135. if (resp.data.data.is_mine) { //是本人在使用
  136. uni.showModal({
  137. title: '提示',
  138. content: '已有正在使用的车辆,是否跳转至车辆详情页?',
  139. cancelText: '取消',
  140. confirmText: '确定',
  141. success: function(res) {
  142. this.isReturnHome = false
  143. uni.navigateTo({
  144. url: '/pages/battery/battery?plate_number=' +
  145. this.plate_number
  146. });
  147. },
  148. fail: function(res) {},
  149. complete: function(res) {},
  150. })
  151. } else {
  152. common.simpleToast('此车辆正在被使用')
  153. }
  154. } else {
  155. if (me.order_sn&&me.order_sn != '') {
  156. if (this.order_model_id != model_id) { // 预租车型与之前预约车型不一致
  157. common.simpleToast('与预约车型不符')
  158. } else {
  159. this.isReturnHome = false
  160. uni.navigateTo({
  161. url: '/pages/activation/activation?plate_number=' +
  162. this.plate_number + '&order_sn=' + this.order_sn +
  163. '&car_model=' + car_model + '&model_image=' +
  164. model_images[0] + '&return_imgs=' + JSON.stringify(
  165. return_imgs),
  166. fail() {}
  167. })
  168. }
  169. } else {
  170. this.setData({
  171. flashValue: 'off',
  172. isReturnHome: false
  173. })
  174. // this.isReturnHome = false
  175. uni.redirectTo({
  176. url: '/pages/carIntroduce/carIntroduce?carInfo=' +
  177. encodeURIComponent(carInfo) + '&plate_number=' + this
  178. .plate_number,
  179. fail() {}
  180. })
  181. }
  182. }
  183. }
  184. } else {
  185. common.simpleToast(resp.data.msg)
  186. }
  187. })
  188. },
  189. async navToInputPage() {
  190. const me = this
  191. const { userInfo = '' } = storage.getUserInfoData()
  192. if (userInfo.is_auth - 0 == 1 && userInfo.status - 0 == 2) {
  193. const params = await this._getParams()
  194. var plate_number = params.carList.length!=0&&params.carList[0].license_plate_number?params.carList[0].license_plate_number:me.plate_number
  195. if (params.wait_active_predetermine != null) { //预约车辆为待激活状态
  196. if (params.wait_active_predetermine.order_status == 2) {
  197. uni.showModal({
  198. title: '提示',
  199. content: '您有等待激活的车辆,是否跳转至订单详情页?',
  200. cancelText: '取消',
  201. confirmText: '确定',
  202. success: function(res) {
  203. if (res.confirm) {
  204. uni.navigateTo({
  205. url: '/pages/orderStatus/orderStatus?order_sn=' + params
  206. .wait_active_predetermine.order_sn
  207. });
  208. }
  209. }
  210. })
  211. }
  212. return
  213. }
  214. if (params.carList.length == 0) {
  215. if(me.isScanCondeRentalCar) {
  216. uni.scanCode({
  217. onlyFromCamera: true,
  218. success: function (res) {
  219. var location = uni.getStorageSync('user_current_location')
  220. me.loadScanCode(location,res.result)
  221. },
  222. fail: function (res) { },
  223. complete: function (res) { },
  224. })
  225. } else {
  226. uni.navigateTo({
  227. url: '/pages/scanCar/scanCar'
  228. });
  229. }
  230. } else {
  231. if (params.order_status == 3 || params.order_status == 4) { // 车辆状态为未激活
  232. uni.showModal({
  233. title: '提示',
  234. content: '已有正在使用的车辆,是否跳转至车辆详情页?',
  235. cancelText: '取消',
  236. confirmText: '确定',
  237. success: function(res) {
  238. if (res.confirm) {
  239. const isReturnIndex = false
  240. uni.navigateTo({
  241. url: '/pages/battery/battery?plate_number=' + plate_number +'&isReturnIndex=' + isReturnIndex
  242. });
  243. }
  244. }
  245. })
  246. } else if (params.order_status == 5) {
  247. uni.showModal({
  248. title: '提示',
  249. content: '请等待商家确认还车,是否跳转至订单详情页?',
  250. cancelText: '取消',
  251. confirmText: '确定',
  252. success: function(res) {
  253. if (res.confirm) {
  254. uni.navigateTo({
  255. url: '/pages/orderStatus/orderStatus?order_sn=' + params
  256. .carList[0].order_sn
  257. });
  258. }
  259. }
  260. })
  261. } else {
  262. uni.showModal({
  263. title: '提示',
  264. content: '已有正在进行的订单,是否跳转至订单详情页?',
  265. cancelText: '取消',
  266. confirmText: '确定',
  267. success: function(res) {
  268. if (res.confirm) {
  269. uni.navigateTo({
  270. url: '/pages/orderStatus/orderStatus?order_sn=' + params
  271. .carList[0].order_sn
  272. });
  273. }
  274. }
  275. })
  276. }
  277. }
  278. } else if (userInfo.is_auth == 1 && userInfo.status != 2) {
  279. uni.showModal({
  280. title: '身份认证提示',
  281. content: '尚未完成身份认证,是否进行身份认证?',
  282. cancelText: '取消',
  283. confirmText: '确定',
  284. success: function(res) {
  285. if (res.confirm) {
  286. me.loadFaceToken()
  287. }
  288. }
  289. })
  290. } else {
  291. uni.showModal({
  292. title: '提示',
  293. content: '您还未登录,请先登录',
  294. showCancel: false,
  295. confirmText: '确定',
  296. success: function(res) {
  297. if (res.confirm) {
  298. //#ifdef MP-ALIPAY
  299. uni.navigateTo({
  300. url: '/pages/phoneLogin/phoneLogin',
  301. })
  302. //#endif
  303. //#ifdef MP-WEIXIN
  304. uni.navigateTo({
  305. url: '/pages/login/login',
  306. })
  307. //#endif
  308. }
  309. }
  310. })
  311. }
  312. }
  313. }
  314. };
  315. </script>
  316. <style scoped>
  317. .tabbar-wrap {
  318. position: fixed;
  319. bottom: 0;
  320. left: 0;
  321. right: 0;
  322. border-bottom: env(safe-area-inset-bottom) solid #fff;
  323. }
  324. .tabbar {
  325. height: 188rpx;
  326. width: 100%;
  327. /* background: url('https://qiniu.bms16.com/FiYy2ZOV_hGSJx32YAQSLZSbAOFq') no-repeat; */
  328. background: url('https://qiniu.bms16.com/Fk8jEU5-RbARagKDYZy0tKWErKNF') no-repeat;
  329. background-size: 100%;
  330. display: flex;
  331. justify-content: space-between;
  332. padding-top: 60rpx;
  333. position: relative;
  334. bottom: -5rpx;
  335. }
  336. .tab-item {
  337. display: flex;
  338. flex-direction: column;
  339. align-items: center;
  340. justify-content: center;
  341. flex: 1;
  342. }
  343. .tab-item:nth-child(2) {
  344. margin-right: 20%;
  345. }
  346. .tab-icon {
  347. width: 24px;
  348. height: 24px;
  349. margin-bottom: 4px;
  350. }
  351. .center-entrance {
  352. position: absolute;
  353. left: 50%;
  354. transform: translateX(-50%);
  355. bottom: 28rpx;
  356. display: flex;
  357. flex-direction: column;
  358. }
  359. .scan-text {
  360. font-size: 10px;
  361. text-align: center;
  362. color: #828DA2;
  363. font-weight: 600;
  364. }
  365. .base-text {
  366. font-family: PingFangSC, PingFang SC;
  367. font-weight: 500;
  368. font-size: 22rpx;
  369. color: #9EA9BB;
  370. line-height: 20rpx;
  371. text-align: center;
  372. font-style: normal;
  373. }
  374. .checked {
  375. color: #060809;
  376. }
  377. </style>