diff --git a/components/VNavigationBar.vue b/components/VNavigationBar.vue index 9f4aebc..1cdd4a4 100644 --- a/components/VNavigationBar.vue +++ b/components/VNavigationBar.vue @@ -17,10 +17,13 @@ {{ title }} + + + - + @@ -45,6 +48,10 @@ leftTitle: { type: Boolean, default: false + }, + showClear: { + type: Boolean, + default: false } }, mounted() { @@ -77,7 +84,10 @@ methods: { back() { uni.navigateBack() - } + }, + clearNoReadFun(){ + this.$emit('clearNoRead') + } } } @@ -108,5 +118,13 @@ font-size: 36rpx; font-weight: bold; } + .navigationBarIcon { + display: flex; + } + .clear-icon{ + width: 40rpx; + height: 40rpx; + border-radius: 50%; + } } - \ No newline at end of file + diff --git a/config.js b/config.js index ec892d3..3b4b3dc 100644 --- a/config.js +++ b/config.js @@ -1,8 +1,8 @@ // 应用全局配置 module.exports = { // baseUrl: 'https://www.nuoyunr.com', - // baseUrl: 'http://192.168.1.4:48080', - baseUrl: "http://localhost:48080", + // baseUrl: 'http://192.168.1.17:48080', + baseUrl: "http://192.168.1.4:48080", imagesUrl: 'http://shequ.0315e.com/static/images/pages/', baseImageUrl: 'https://www.nuoyunr.com/minio/', wsUrl: 'wss://www.nuoyunr.com', diff --git a/pages-home/home/active.vue b/pages-home/home/active.vue index edcf612..6601f09 100644 --- a/pages-home/home/active.vue +++ b/pages-home/home/active.vue @@ -18,7 +18,9 @@ - + + + @@ -34,8 +36,7 @@ diff --git a/pages-order/orderList/orderList.vue b/pages-order/orderList/orderList.vue index afea9ac..944b04c 100644 --- a/pages-order/orderList/orderList.vue +++ b/pages-order/orderList/orderList.vue @@ -11,38 +11,43 @@ - - - - 订单编号:{{ item.orderNo }} + + + + + 订单编号:{{ item.orderNo }} + + + {{ getStatus(item.orderStatus,item.mainStatus,item.payType) }} + - - {{ getStatus(item.orderStatus) }} - - - - - {{ item.goodsTitle }} - - - - {{ item.tenantName | 蓝安-中鑫之宝 }} - - - - 共计 - - {{ item.payMoney }} + + + {{ item.goodsTitle }} + + + + {{ item.tenantName || "蓝安-中鑫之宝" }} + + + + 共计 + + {{ item.payMoney }} + + {{ formatTimestamp(item.createTime) }} + + + 支付 + 查看订单 + 评价订单 - {{ formatTimestamp(item.createTime) }} - - 支付 - 查看订单 - 评价订单 + + - - + @@ -66,6 +71,7 @@ import request from '../../utils/request'; import VNavigationBar from '@/components/VNavigationBar.vue' import tabBarVue from '@/components/tabBar/tabBar.vue' import drawQrcode from 'weapp-qrcode'; +import {getToken,getUserInfo} from '@/utils/auth' export default { components: { @@ -76,38 +82,41 @@ export default { return { payShow: false, activeKey: 0, - pageNum: 1, - totalPages: 0, imageUrl: '', - tabList: [{ - id: 0, - title: '全部订单' - }, + tabList: [ + { + id: 0, + title: '维修中' + }, { id: 1, - title: '维修中' + title: '待支付' }, { id: 2, title: '待评价' }, + { + id: 3, + title: '全部订单' + }, ], orderList: [], + pageNo: 1, + pageSize: 10, + total: 0, + //下来刷新状态 + isTriggered:false, changeActive: false } }, - onShow() { - this.orderList = [] - this.getList() - }, - onReachBottom() { - if (this.pageNum >= this.totalPages) { - uni.showToast({ - title: '没有下一页数据', - icon: 'none' + onLoad() { + if(!getToken()){ + uni.reLaunch({ + url: '/pages/login/login' }) - } else { - this.pageNum++ + }else { + this.orderList = [] this.getList() } }, @@ -125,19 +134,47 @@ export default { // 组合成日期时间字符串 return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; }, + /** + * 上滑加载数据 + */ + onReachBottom() { + //判断 如果页码*页容量大于等于总条数,提示该页数据加载完毕 + if (this.pageNo * this.pageSize >= this.total) { + uni.$u.toast('没有更多数据了') + return + } + //页码+1,调用获取数据的方法获取第二页数据 + this.pageNo++ + //此处调用自己获取数据列表的方法 + this.getList() + }, + /** + * 下拉刷新数据 + */ + onRefresherrefresh(){ + this.isTriggered = true + this.pageNo = 1 + this.total = 0 + this.messageList = [] + this.getList() + }, async getList() { let data = { - pageSize: 20, - pageNo: this.pageNum + pageSize: this.pageSize, + pageNo: this.pageNo } switch (this.activeKey) { case 0: + //维修中 + data.selectType = "working" break; case 1: - data.status = "06" + //待支付 + data.selectType = "waitingPay" break; case 2: - data.status = '00' + //待评价 + data.selectType = 'waitingComment' break default: break @@ -147,31 +184,70 @@ export default { } this.changeActive = false await request({ - url: '/userClient/order/page', + url: '/app-api/repair/order-info/page', method: 'get', - params: data + params: data, + tenantIdFlag:false }).then((res) => { if (res.code === 200) { - this.orderList = this.orderList.concat(res.rows) - let total = res.total - this.totalPages = Math.ceil(total / this.pageSize); + //判断 如果获取的数据的页码不是第一页,就让之前赋值获取过的数组数据 concat连接 刚获取的第n页数据 + if (this.pageNo != 1) { + this.orderList = this.orderList.concat(res.data.records) + } else { + this.orderList = res.data.records + } + //将获取的总条数赋值 + this.total = res.data.total + this.isTriggered = false } }) }, changeTabFun(id) { this.activeKey = id this.changeActive = true + this.pageNo = 1 + this.total = 0 this.getList() }, - getStatus(status) { - switch (status) { - case '0': - return '待支付' - case '1': - return '已支付' - default: - break; + /** + * 获取工单的状态 + * @param orderStatus 订单是否支付 0未支付 1已支付 + * @param mainStatus 工单主状态 + * @param payType 支付方式 + * @returns {string} + */ + getStatus(orderStatus,mainStatus,payType) { + let str = ""; + if("0"==orderStatus){ + //未支付的情况下,返回工单的状态 + if("04"==mainStatus){ + //待派工 + str = "待派工" + }else if("05"==mainStatus){ + //维修中 + str = "维修中" + }else if("01"==mainStatus){ + //待结算 + if(!payType){ + str = "待结算" + }else{ + str = "待支付" + } + }else if("06"==mainStatus){ + //挂单/记账 + str = "挂单/记账" + }else if("02"==mainStatus){ + //已结账 + str = "已结账" + }else if("03"==mainStatus){ + //已作废 + str = "已作废" + } + }else{ + //已支付 + str = "已支付" } + return str; }, async goPay(data) { let that = this @@ -226,10 +302,6 @@ export default { uni.navigateTo({ url: '/pages-order/orderDetail/orderDetail?ticketsId=' + row.goodsId }) - }else { - uni.navigateTo({ - url: '/pages-order/orderDetail/orderDetail' - }) } }, gotoEvaluate(row) { @@ -251,8 +323,8 @@ export default { .body { flex: 1; - height: 0; - padding: 24rpx 32rpx; + height: 100%; + padding: 0 32rpx; overflow: auto; } @@ -292,8 +364,10 @@ export default { display: flex; flex-direction: column; row-gap: 20rpx; + height: calc(100% - 65px); .orderItem { + margin-bottom:10rpx; padding: 30rpx; background: #FFFFFF; border-radius: 12rpx 12rpx 12rpx 12rpx; @@ -382,5 +456,8 @@ export default { } } } + .no-data{ + text-align: center; + } } diff --git a/pages-shop/notice/notice.vue b/pages-shop/notice/notice.vue new file mode 100644 index 0000000..7b6337d --- /dev/null +++ b/pages-shop/notice/notice.vue @@ -0,0 +1,195 @@ + + + + + diff --git a/pages-shop/notice/noticeContent.vue b/pages-shop/notice/noticeContent.vue new file mode 100644 index 0000000..a7de3e7 --- /dev/null +++ b/pages-shop/notice/noticeContent.vue @@ -0,0 +1,85 @@ + + + + + + + diff --git a/pages-shop/shopDetail/shopDetail.vue b/pages-shop/shopDetail/shopDetail.vue index d5f81f4..66792d6 100644 --- a/pages-shop/shopDetail/shopDetail.vue +++ b/pages-shop/shopDetail/shopDetail.vue @@ -66,21 +66,37 @@ - 开始预约 + 开始预约 + + + + + + {{info.corpName}}申请获取您的个人信息、车辆信息。 + + + + + + + + @@ -34,13 +42,14 @@ height: 0; margin: 32rpx; padding: 30rpx; - + display: flex; flex-direction: column; row-gap: 20rpx; - + .title { text-align: center; + font-size: 20px; } } } diff --git a/pages/guideList/guideList.vue b/pages/guideList/guideList.vue index 1ddaf40..d39db65 100644 --- a/pages/guideList/guideList.vue +++ b/pages/guideList/guideList.vue @@ -2,27 +2,98 @@ - - 如何在小程序上下单车辆维修 - - + + + {{ item.title }} + + + + + + \ No newline at end of file + diff --git a/pages/login/login.vue b/pages/login/login.vue index 68be44b..d34b442 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -28,7 +28,7 @@ @@ -37,11 +168,12 @@ flex-direction: column; .body { flex: 1; - height: 0; + height: calc(100vh - env(safe-area-inset-top)); overflow: auto; } .messageList { padding: 0 32rpx; + height: 100%; } .messageItem { padding: 30rpx 0; @@ -49,18 +181,30 @@ align-items: center; column-gap: 20rpx; border-bottom: 1rpx solid #EEEEEE; - + .messageIcon { width: 80rpx; height: 80rpx; } - + .noReadTitle { + font-weight: bold; + font-size: 32rpx; + color: #333333; + } + .noReadTitle:after{ + content: "*"; + color: red; + display: block; /* 或者其他的块级显示类型,比如 inline-block, table 等 */ + position: absolute; /* 或者 absolute 或者 fixed,取决于你的布局需求 */ + z-index: 1; /* 确保它在元素的上方 */ + right: 0; + } + .messageContent { flex: 1; width: 0; } .messageTitle { - font-weight: bold; font-size: 32rpx; color: #333333; } @@ -68,11 +212,37 @@ font-weight: 500; font-size: 28rpx; color: #858BA0; - + overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } - } + } + .popup-content { + padding: 15px; + height: auto; + margin: auto; + width: 80%; + background-color: #fff; + } + .popup-content-text { + display: flex; + align-items: center; + justify-content: center; + } + + .text { + color: #333; + } + + .popup-info { + margin-top: 30rpx; + color: #fff; + background-color: #f2f6fc; + } + + .info-text { + color: #909399; + } } diff --git a/pages/my/my.vue b/pages/my/my.vue index 9f8650f..f62e077 100644 --- a/pages/my/my.vue +++ b/pages/my/my.vue @@ -6,22 +6,23 @@ - - {{customInfo.cusName}} + + + {{customInfo.nickname}} - - - - {{customInfo.levelName}} - - - - 查看权益 - - - + + + + + + + + + + + @@ -42,9 +43,6 @@ {{ item.title }} - - {{ '12' }} - @@ -53,6 +51,9 @@ {{ item.title }} + + {{ noReadNum }} + @@ -65,8 +66,8 @@ import VNavigationBar from '@/components/VNavigationBar.vue' import tabBarVue from '@/components/tabBar/tabBar.vue' import request from "@/utils/request"; - import {getUserInfoRequest} from "@/utils/common.js"; - import {getToken,setUserInfo,getUserInfo} from '@/utils/auth.js' + import config from '@/config' + import {getToken,getUserInfo} from '@/utils/auth' export default { components: { tabBarVue, @@ -79,17 +80,17 @@ }) }else{ console.log("已登录") - if(!getUserInfo()){ - this.getServer() - }else{ - this.customInfo = JSON.parse(getUserInfo()) - } + //直接取缓存中的用户信息 + this.customInfo = JSON.parse(getUserInfo()) + //查未读消息数量 + this.getNoReadNum() } }, data() { return { //用户信息 customInfo:{}, + imgUrlPrex:config.baseImageUrl, menuCard1: [ { title: '我的资料', icon: require('@/static/icons/my-menu-icon1.png'), path: '/pages/my/myInfo' }, { title: '我的卡券', icon: require('@/static/icons/my-menu-icon5.png'), path: "/pages/my/cardRoll" }, @@ -97,9 +98,10 @@ ], menuCard2: [ { title: '消息中心', icon: require('@/static/icons/my-menu-icon2.png'), path: '/pages/my/message' }, - { title: '客服中心', icon: require('@/static/icons/my-menu-icon4.png') }, + // { title: '客服中心', icon: require('@/static/icons/my-menu-icon4.png') }, { title: '操作指南', icon: require('@/static/icons/my-menu-icon5.png'), path: "/pages/guideList/guideList" }, - ] + ], + noReadNum:0 } }, methods: { @@ -113,23 +115,17 @@ url: '/pages/my/myEquity' }) }, - //获取当前登录用户信息 - async getServer() { - request({ - url: "/userClient/customer/getUserCustomer", - method: 'get', - params:{} - }).then(res=>{ - if(!res.data){ - uni.reLaunch({ - url: '/pages/my/register' - }) - }else{ - setUserInfo(JSON.stringify(res.data)) - this.customInfo = res.data - } - }) - } + async getNoReadNum(){ + await request({ + url: "/app-api/system/notify-message/get-unread-count", + method: "GET", + tenantIdFlag:false + }).then((res) => { + if(res.code==200){ + this.noReadNum = res.data + } + }) + } } } @@ -171,6 +167,7 @@ .avatar { width: 140rpx; height: 140rpx; + border-radius: 50%; margin-bottom: 30rpx; } diff --git a/pages/my/myInfo.vue b/pages/my/myInfo.vue index 26791d5..14b51a8 100644 --- a/pages/my/myInfo.vue +++ b/pages/my/myInfo.vue @@ -2,45 +2,116 @@ - - - - - - 姓名 - {{ customInfo.cusName }} - - - + + 姓名 + + 手机号 - {{ customInfo.phoneNumber }} - + {{ customInfo.mobile }} - 联系地址 - {{ customInfo.address }} - + 头像 + + + + @@ -48,30 +119,30 @@ .container { height: 100%; background-color: #fff; - + .body { - + } - + .formItem { box-sizing: border-box; width: 686rpx; margin: 0 auto; padding: 40rpx; - + display: flex; align-items: center; justify-content: space-between; column-gap: 20rpx; - + border-bottom: 1rpx solid #DDDDDD; } - + .formLabel { font-size: 32rpx; color: #333333; } - + .formValue { flex: 1; width: 0; @@ -79,15 +150,14 @@ font-size: 32rpx; color: #999999; } - + .formBtn { width: 24rpx; height: 24rpx; } - - .avatar { - width: 108rpx; - height: 108rpx; + + .dl-avatar-box { + text-align: right; } } - \ No newline at end of file + diff --git a/pages/myCar/carDetail.vue b/pages/myCar/carDetail.vue index d7efb0d..10349aa 100644 --- a/pages/myCar/carDetail.vue +++ b/pages/myCar/carDetail.vue @@ -3,9 +3,27 @@ + - 车牌号 - + 是否车主 + + + + + + + + + 车牌号 + + + + 车架号 + + + + 发动机号码 + 品牌 @@ -15,13 +33,7 @@ 型号 - - - - 车辆类别 - - {{ categoryNamesComputed[categoryIndex] }} - + 车辆性质 @@ -29,6 +41,12 @@ {{ natureNamesComputed[natureIndex] }} + + 车辆类别 + + {{ categoryNamesComputed[categoryIndex] }} + + 注册日期 - - + + 行驶证 + - - - - - - - - - - - - - + @@ -70,7 +87,7 @@ 删除 - + 保存 @@ -80,7 +97,10 @@ @@ -345,6 +454,11 @@ export default { &:last-child { border: none; } + + .require { + content: "*"; + color: red; + } } .labelVal { diff --git a/pages/myCar/myCar.vue b/pages/myCar/myCar.vue index c3eee48..2326f8d 100644 --- a/pages/myCar/myCar.vue +++ b/pages/myCar/myCar.vue @@ -9,9 +9,12 @@ {{ item.licenseNumber}} 品牌:{{ item.brandName }} - 型号:{{ item.carModelInput }} + 型号:{{ item.carModel || "" }} + + + @@ -26,8 +29,7 @@ import VNavigationBar from '@/components/VNavigationBar.vue'; import request from "../../utils/request"; import config from "config"; -import {getUserInfoRequest} from "@/utils/common.js"; -import {getToken,setUserInfo} from '@/utils/auth.js' +import {getToken,setJSONData} from '@/utils/auth' export default { computed: { @@ -41,12 +43,12 @@ export default { data() { return { carList: [ - { - carNum: '鲁A 781NB', - name: '魏书豪', - phone: '15726786903', - image: '' - } + // { + // carNum: '鲁A 781NB', + // name: '魏书豪', + // phone: '15726786903', + // image: '' + // } ] }; }, @@ -60,34 +62,27 @@ export default { uni.reLaunch({ url: '/pages/login/login' }) - }else{ - console.log("已登录") - this.getUserInfos() } // 页面显示时执行初始化操作 this.getList(); }, methods: { - //获取当前登录用户信息 - async getUserInfos() { - console.log("获取用户信息") - getUserInfoRequest() - }, getList(){ request({ - url: '/userClient/base/myCar/get', + url: '/app-api/base/user-car/getMyCar', method: 'GET', + tenantIdFlag: false }).then(res => { console.log(res); this.carList = res.data; console.log('图片路径', config.baseImageUrl+this.carList[0].logoImg) }) }, - gotoDetail(item) { if (item){ + setJSONData("carInfo",item) uni.navigateTo({ - url: `/pages/myCar/carDetail?car=${encodeURIComponent(JSON.stringify(item))}` + url: `/pages/myCar/carDetail?id=`+item.id }); } else { @@ -120,6 +115,9 @@ export default { flex-direction: column; } + .no-data{ + text-align: center; + } .carItem { box-sizing: border-box; width: 686rpx; diff --git a/pages/myCar/scan-frame.vue b/pages/myCar/scan-frame.vue new file mode 100644 index 0000000..0a19b4a --- /dev/null +++ b/pages/myCar/scan-frame.vue @@ -0,0 +1,106 @@ + + + + + diff --git a/pages/myReservation/addReservation.vue b/pages/myReservation/addReservation.vue index 03a677a..41f1b6d 100644 --- a/pages/myReservation/addReservation.vue +++ b/pages/myReservation/addReservation.vue @@ -102,8 +102,7 @@ import request from '../../utils/request'; import VNavigationBar from '@/components/VNavigationBar.vue' import config from "@/config"; - import {getUserInfoRequest} from "@/utils/common.js"; - import {getToken,getUserInfo} from '@/utils/auth.js' + import {getToken,getUserInfo,getJSONData} from '@/utils/auth' export default { components: { @@ -139,7 +138,7 @@ // }, ], dateList:[], chooseDate: '06-06', - chooseTime: '11:00', + chooseTime: '09:00', timeList: [{ time: '09:00', disabled: false @@ -183,28 +182,20 @@ }; }, onLoad(data){ - this.info = JSON.parse(decodeURIComponent(data.info)) + this.info = getJSONData("shopInfo") this.formData.corpId = this.info.id this.getServer(this.info.id) + this.initCarList() + this.initDateList() }, onShow() { if(!getToken()){ uni.reLaunch({ url: '/pages/login/login' }) - }else{ - console.log("已登录") - this.getUserInfos() } - this.initCarList() - this.initDateList() }, methods: { - //获取当前登录用户信息 - async getUserInfos() { - console.log("获取用户信息") - getUserInfo() - }, initDateList(){ const daysOfWeek = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']; const currentDate = new Date(); diff --git a/pages/myReservation/myReservation.vue b/pages/myReservation/myReservation.vue index 294f0c2..abf0866 100644 --- a/pages/myReservation/myReservation.vue +++ b/pages/myReservation/myReservation.vue @@ -8,6 +8,9 @@ + + + @@ -18,8 +21,7 @@ import tabBarVue from '@/components/tabBar/tabBar.vue' import reservationOrderVue from '../../components/reservationOrder/reservationOrder.vue' import request from "@/utils/request"; - import {getUserInfoRequest} from "@/utils/common.js"; - import {getToken,setUserInfo} from '@/utils/auth.js' + import {getToken} from '@/utils/auth.js' export default { components: { @@ -54,15 +56,10 @@ }) }else{ console.log("已登录") - this.getUserInfos() } this.getBookingPage() }, methods: { - //获取当前登录用户信息 - async getUserInfos() { - getUserInfoRequest() - }, async getBookingPage(){ const res = await request({ url: "/userClient/repair/booking/page", @@ -119,5 +116,8 @@ flex-direction: column; row-gap: 20rpx; } + .no-data{ + text-align: center; + } } diff --git a/static/icons/bottom.png b/static/icons/bottom.png new file mode 100644 index 0000000..83e78fc Binary files /dev/null and b/static/icons/bottom.png differ diff --git a/static/icons/date.png b/static/icons/date.png new file mode 100644 index 0000000..ce35b6c Binary files /dev/null and b/static/icons/date.png differ diff --git a/static/icons/orderIng.png b/static/icons/orderIng.png new file mode 100644 index 0000000..27330bb Binary files /dev/null and b/static/icons/orderIng.png differ diff --git a/static/images/clear.png b/static/images/clear.png new file mode 100644 index 0000000..2c0f153 Binary files /dev/null and b/static/images/clear.png differ diff --git a/static/images/nothing.png b/static/images/nothing.png new file mode 100644 index 0000000..85907e6 Binary files /dev/null and b/static/images/nothing.png differ diff --git a/static/images/scan-img.png b/static/images/scan-img.png new file mode 100644 index 0000000..8d4f302 Binary files /dev/null and b/static/images/scan-img.png differ diff --git a/utils/auth.js b/utils/auth.js index 0a35c4a..e0372dd 100644 --- a/utils/auth.js +++ b/utils/auth.js @@ -1,6 +1,7 @@ const TokenKey = 'App-Token' const UserInfo = 'customerInfo' const TenantIdKey = 'TENANT_ID' +const InviteIdKey = 'INVITE_ID' export function getToken() { return uni.getStorageSync(TokenKey) } @@ -19,6 +20,15 @@ export function setTenantId(TenantId) { export function getTenantId(){ return uni.getStorageSync(TenantIdKey) } +export function setInviteId(InviteId) { + return uni.setStorageSync(InviteIdKey, InviteId); +} +export function getInviteId(){ + return uni.getStorageSync(InviteIdKey) +} +export function removeInviteId(){ + return uni.removeStorageSync(InviteIdKey) +} export function hasRole(roleCode) { const roleList = uni.getStorageSync('role') @@ -38,3 +48,46 @@ export function getUserInfo() { export function setUserInfo(userInfo) { return uni.setStorageSync(UserInfo, userInfo) } + +export function getJSONData(keyStr) { + if(uni.getStorageSync(keyStr)){ + return JSON.parse(uni.getStorageSync(keyStr)) + }else{ + return ""; + } +} + +export function setJSONData(keyStr,dataObj) { + return uni.setStorageSync(keyStr, JSON.stringify(dataObj)) +} + +// 设置本地存储,并设置一个过期时间(单位为秒) +export function setStorageWithExpiry(key, value, ttl) { + const now = new Date(); + // 计算过期时间 + const item = { + value: value, + expiry: now.getTime() + ttl * 1000, + }; + // 将数据对象转换为字符串存储 + uni.setStorageSync(key, JSON.stringify(item)); +} + +// 获取本地存储的数据,检查是否过期 +export function getStorageWithExpiry(key) { + // 从本地存储获取数据 + const itemStr = uni.getStorageSync(key); + if (!itemStr) { + return null; // 未找到数据 + } + const item = JSON.parse(itemStr); + const now = new Date(); + // 检查项目是否过期 + if (now.getTime() > item.expiry) { + // 如果过期,从存储中移除该项 + uni.removeStorageSync(key); + return null; + } + return item.value; // 数据未过期,返回数据 +} + diff --git a/utils/request.js b/utils/request.js index 810ec77..c63a03a 100644 --- a/utils/request.js +++ b/utils/request.js @@ -23,7 +23,7 @@ const request = config => { // 设置租户 const isTanantId = (config.headers || {}).isTanantId === false config.header = config.header || {} - if(!config.hasOwnProperty("noTenantId")){ + if(!config.hasOwnProperty("tenantIdFlag")){ //请求设置了不需要租户,不拼接,,走进这里的是没设置不需要租户的 if(getTenantId() && !isTanantId){ config.header['tenant-id'] = getTenantId() diff --git a/utils/upload.js b/utils/upload.js index 740387e..e1ee5bf 100644 --- a/utils/upload.js +++ b/utils/upload.js @@ -20,6 +20,7 @@ const upload = config => { url = url.slice(0, -1) config.url = url } + console.log("参数",config) return new Promise((resolve, reject) => { uni.uploadFile({ timeout: config.timeout || timeout, diff --git a/utils/utils.js b/utils/utils.js index 9e3fe91..cebcc6e 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -1,3 +1,9 @@ +import request from '@/utils/request'; +import { + setStorageWithExpiry, + getStorageWithExpiry +} from '@/utils/auth' + function getWXStatusHeight() { // #ifdef MP-WEIXIN // 获取距上 @@ -22,6 +28,135 @@ function getWXStatusHeight() { // #endif } +/** + * 根据订单的状态获取订单的文字展示状态 + * @param ticketsStatus 订单状态 + * @param workStatus 维修工作状态 + */ +function getOrderStatusText(ticketsStatus,workStatus){ + let str = ""; + if("04"==ticketsStatus){ + //待派工 + str = "待派工" + }else if("05"==ticketsStatus){ + //维修中 + str = "维修中" + }else if("01"==ticketsStatus){ + //待结算 + str = "待结算" + }else if("06"==ticketsStatus){ + //挂单/记账 + str = "挂单/记账" + }else if("02"==ticketsStatus){ + //已结账 + str = "已结账" + }else if("03"==ticketsStatus){ + //已作废 + str = "已作废" + } + return str; +} + + +/** + * 查询字典可选值 + * @param dictCode + */ +function getDictByCode(dictCode){ + let dictArray = getStorageWithExpiry(dictCode); + if(null==dictArray || undefined==dictArray){ + request({ + url: '/app-api/system/dict-data/type', + method: 'get', + tenantIdFlag:false, + params:{type:dictCode} + }).then((res) => { + console.log(res) + if (res.code == 200) { + setStorageWithExpiry(dictCode,res.data,3600) + return res.data + } + }) + }else{ + return dictArray + } +} + +/** + * 翻译字典 + * @param dictCode + */ +async function getDictTextByCodeAndValue(dictCode,value){ + return new Promise((resolve, reject) => { + let dictArray = getStorageWithExpiry(dictCode); + console.log(dictCode, 'dictCode') + console.log(value, 'value') + if (null == dictArray || undefined == dictArray) { + request({ + url: '/app-api/system/dict-data/type', + method: 'get', + tenantIdFlag: false, + params: {type: dictCode} + }).then((res) => { + console.log(res, 98) + console.log(res, 98) + if (res.code == 200) { + setStorageWithExpiry(dictCode, res.data, 3600) + dictArray = res.data + let dictObj = dictArray.find(item => item.value == value) + console.log(dictObj, "dictObj") + if (dictObj) { + resolve(dictObj.label); + // return dictObj.label + } else { + resolve("未知数据") + } + } + }) + } else { + let dictObj = dictArray.find(item => item.value == value) + console.log(dictObj, "dictObj") + if (dictObj) { + resolve(dictObj.label); + } else { + resolve("未知数据") + } + } + }); +} + +function formatTimestamp(timestamp) { + // 将时间戳转换为Date对象 + const date = new Date(timestamp); + // 获取年月日时分秒 + const year = date.getFullYear(); + const month = (date.getMonth() + 1).toString().padStart(2, '0'); + const day = date.getDate().toString().padStart(2, '0'); + const hours = date.getHours().toString().padStart(2, '0'); + const minutes = date.getMinutes().toString().padStart(2, '0'); + const seconds = date.getSeconds().toString().padStart(2, '0'); + // 组合成日期时间字符串 + return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; +} + +function formatDate(timestamp) { + // 将时间戳转换为Date对象 + const date = new Date(timestamp); + // 获取年月日时分秒 + const year = date.getFullYear(); + const month = (date.getMonth() + 1).toString().padStart(2, '0'); + const day = date.getDate().toString().padStart(2, '0'); + // 组合成日期时间字符串 + return `${year}-${month}-${day}`; +} + + + export { getWXStatusHeight, + getOrderStatusText, + getDictByCode, + getDictTextByCodeAndValue, + formatTimestamp, + formatDate, } \ No newline at end of file