123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- import uniPop from '@/components/uni-popup/uni-popup.vue';
- import { Dialog } from 'vant';
- import LoginDom from '@/components/Login/Login.vue';
- // const app = getApp()
- const app = {};
- import {
- kipGetMemberVehicles,
- kipDeleteMemberVehicles,
- } from '@/utils/api-kip.js';
- import { LICENSE_PLATE_TYPE_ARR } from '@/constants.js';
- import { mapState } from 'vuex';
- // import authorize from '@/components/authorize/authorize.vue';
- import { isCruMarketByKey } from '@/utils/location-util.js';
- import MemberCacheTool from '@/utils/member-cache-tool.js';
- import { REG_SOURCE } from '@/constants.js';
- import uni from '@/utils/uniHooks.js';
- // import { vehicles as vehiclesList } from './list';
- import { wxToLoginCallback } from '@/utils/index';
- import { Toast } from 'vant';
- import { getVehicles, delVehicle } from '@/api/parking/index'
- export default {
- components: {
- uniPop,
- // authorize,
- LoginDom,
- },
- computed: {
- ...mapState({
- custTypeId: (state) => state.custTypeId,
- member: (state) => state.member,
- groupId: (state) => state.groupId,
- openid: (state) => state.openid,
- mallid: (state) => state.mallId,
- mobile: (state) => state.mobile,
- kipUserId: (state) => state.kipUserId,
- }),
- isNoLogin() {
- return JSON.stringify(this.member) === '{}'
- }
- },
- data() {
- return {
- list: [],
- activeId: '',
- activeCarno: '',
- licensePlateList: [],
- isBeijing: false,
- options: null,
- preUrl: '',
- deleteDialogSwitch: false,
- deleteSuccessDialogSwitch: false,
- show: false, // 删除车牌时提示内容
- };
- },
- async created() {
- this.options = this.$route.query;
- },
- async mounted() {
- setTimeout(() => {
- uni.setNavigationBarTitle({
- title: '车辆管理',
- });
- }, 300);
- setTimeout(() => {
- window?.toWXSendMsg({
- type: 'uni_func',
- funcName: 'setNavigationBarColor',
- options: {
- frontColor: '#000000',
- backgroundColor: '#FBFCFF',
- },
- });
- }, 500)
- this.$store.dispatch('clearUnlicensed');
- const member = uni.getStorageSync('member');
- if (member && JSON.stringify(this.member) !== '{}') {
- this.getKipMemberVehicles();
- } else {
- wxToLoginCallback('vehicleManagement', (options) => {
- if (options?.noLoginParkingFeeWebView === 'fail') {
- // 如果是用户明确拒绝登录,执行这段逻辑
- setTimeout(() => {
- Toast({
- message: '您还未登录,请登录',
- icon: 'none',
- onClose: () => {
- this.$router.back();
- return
- },
- });
- }, 300)
- } else {
- this.$router.back();
- }
- });
- }
- },
- onUnload() {
- // #ifdef MP-WEIXIN
- var pages = getCurrentPages();
- var prevPage = pages[pages.length - 2];
- console.log('==> 车牌管理-返回上一页');
- prevPage.setData({
- parkData: 'parkData',
- });
- // #endif
- // #ifdef H5
- uni.setStorage({
- key: 'parkData',
- data: 'parkData',
- success: function () {
- console.log('parkData-success');
- },
- });
- // #endif
- },
- methods: {
- // 添加车牌号
- toAdd() {
- if(this.isNoLogin) return
- this.$router.push({ path: 'vehicleAddOrEdit' });
- },
- // 跳转支付页面
- toPay(carno) {
- if(this.isNoLogin) return
- this.$store.commit('cachedViews/DEL_CACHED_VIEW', {
- name: 'parkingFeeDetail',
- });
- uni.setStorageSync('carList', [...new Set([carno, ...JSON.parse(uni.getStorageSync('carList') || '[]')])].slice(0, 6));
- this.$store.commit('cachedViews/DEL_CACHED_VIEW', {
- name: 'parkingFeeDetail',
- });
- this.$nextTick(() => {
- this.$router.push({
- path: 'parkingFeeDetail',
- query: {
- vehicleNo: carno,
- },
- });
- });
- return
- // 查询车费信息
- uni.showLoading({
- title: '加载中',
- });
- // const openId = MemberCacheTool.getOpenId(app)
- const params = {
- carno,
- mallid: this.mallid,
- openid: this.openid,
- vipcode: this.member?.vipcode,
- mobile: this.mobile,
- groupId: this.groupId,
- createuser: 'sys_miniprogram',
- };
- this.$md(params);
- this.$request({
- url: this.$baseURL + 'api/1.0/park/checkCarIsInPark',
- data: params,
- method: 'POST',
- header: JSON.parse(uni.getStorageSync('handleUser')),
- timeout: 10000,
- })
- .then((res) => {
- // console.log(227, res);
- uni.hideLoading();
- if (res.data.code === 0) {
- this.$router.push({
- path: 'parkingFeeDetail?carno=' + carno,
- });
- } else if (res.data.code === 1) {
- // 当前车辆没有查到账单
- this.$router.push({
- path: 'parkingFeePayment?msg=' + res.data.msg + '&carno=' + carno,
- });
- } else if (res.data.code === 2) {
- // 月租车
- this.$router.push({
- path: './parkingFeeHint/parkingFeeHint?carno=' + carno,
- });
- } else {
- uni.showToast({
- title: res.data.msg,
- duration: 2000,
- icon: 'none',
- });
- }
- })
- .catch((err) => {
- uni.hideLoading();
- uni.showToast({
- title: '网络超时请稍后再试',
- duration: 2000,
- icon: 'none',
- });
- console.log(err);
- });
- },
- // 编辑
- toEdit(item) {
- if(this.isNoLogin) return
- if (!item) {
- return;
- }
- const { id, vehicleNo, licensePlateType } = item;
- const carType = LICENSE_PLATE_TYPE_ARR.findIndex(
- (e) => e.value == licensePlateType
- );
- this.$router.push({
- path: `vehicleAddOrEdit?id=${id}&carno=${vehicleNo}&carType=${carType}`,
- });
- },
- activeCarnoFilter(str){
- return str.replace(/(.{2})/, '$1·')
- },
- async delVehicleInTMP() {
- const res = await delVehicle(this.activeId)
- if (res.langMessage) {
- const message = res.langMessage || '删除失败';
- uni.showToast({
- title: message,
- duration: 2000,
- icon: 'none',
- });
- return
- }
- Toast({
- message: '删除成功',
- type: 'success',
- position: 'top',
- duration: 5000,
- className: 'top300',
- icon: require('../static/images/success.svg')
- });
- setTimeout(() => {
- this.getKipMemberVehicles();
- }, 1000)
- },
- // 删除
- toDelete(item) {
- this.activeId = item.id;
- this.activeCarno = item.vehicleNo;
- this.show = true
- // Dialog.confirm({
- // title: '删除已绑定车牌',
- // message: '是否确认删除已经绑定车牌' + '\n' + this.activeCarno,
- // confirmButtonColor: '#333',
- // })
- // .then(() => {
- // // on confirm
- // this.doDelete();
- // })
- // .catch(() => {
- // // on cancel
- // // this.cancelDelete();
- // });
- // this.deleteDialogSwitch = true;
- },
- doDelete() {
- this.delVehicleInTMP();
- return
- uni.showLoading({
- title: '加载中',
- });
- const _this = this;
- kipDeleteMemberVehicles(this.activeId)
- .then((result) => {
- uni.hideLoading();
- // console.log(resp)
- // const result = resp.data
- if (result && result.code == '000000') {
- if (result.data) {
- // this.deleteDialogSwitch = false;
- // this.deleteSuccessDialogSwitch = true;
-
- Toast({
- message: '删除成功',
- type: 'success',
- position: 'top',
- duration: 5000,
- className: 'top300',
- icon: require('../static/images/success.svg')
- });
- setTimeout(() => {
- this.getKipMemberVehicles();
- }, 1500)
- // _this.$refs.deleteSuccessDialog.open()
- return;
- }
- }
- const message = result.message || '删除失败';
- uni.showToast({
- title: message,
- duration: 2000,
- icon: 'none',
- });
- })
- .catch((err) => {
- uni.hideLoading();
- console.log(err);
- uni.showToast({
- title: '删除失败',
- duration: 2000,
- icon: 'none',
- });
- });
- },
- cancelDelete() {
- this.deleteDialogSwitch = true;
- },
- confirmDialog() {
- // this.$refs.deleteSuccessDialog.close()
- this.deleteSuccessDialogSwitch = false;
- this.getKipMemberVehicles();
- },
- // 获取会员绑定的车牌列表
- async getVehiclesINTMP() {
- const res = await getVehicles(this.kipUserId)
- this.licensePlateList = this.setLicensePlateList(res.content);
- },
- getKipMemberVehicles() {
- this.getVehiclesINTMP();
- return
- // console.log(453);
- uni.showLoading({
- title: '加载中',
- });
- kipGetMemberVehicles()
- .then((result) => {
- uni.hideLoading();
- console.log(result);
- // const result = resp.data
- if (result && result.code == '000000') {
- const data = result.data || [];
- if (data && data.length > 0) {
- // data.forEach((item) => {
- // const curLicensePlateType = LICENSE_PLATE_TYPE_ARR.find(
- // (e) => e.value == item.licensePlateType
- // )
- // if (curLicensePlateType) {
- // item.licensePlateTypeDesc = curLicensePlateType.label
- // }
- // })
- this.licensePlateList = this.setLicensePlateList(data);
- } else {
- this.licensePlateList = [];
- }
- // this.licensePlateList = vehiclesList.data;
- } else {
- const message = result.message || '获取信息失败';
- uni.showToast({
- title: message,
- duration: 2000,
- icon: 'none',
- });
- }
- // console.log(380, this.licensePlateList);
- })
- .catch((err) => {
- uni.hideLoading();
- console.error(err);
- });
- // this.licensePlateList = this.setLicensePlateList(vehiclesList.data);
- },
- setLicensePlateList(data) {
- if (!data.length) return [];
- return data.map((item) => {
- const curLicensePlateType = LICENSE_PLATE_TYPE_ARR.find(
- (e) => e.value == item.licensePlateType
- );
- if (curLicensePlateType) {
- item.licensePlateTypeDesc = curLicensePlateType.label;
- }
- return item;
- });
- },
- },
- };
|