Commit 177a53bf by 李伟康

Merge branch 'SAAS+V5.5.0' of http://192.168.3.233:8090/glsx/gl_tape into SAAS+V5.5.0

2 parents b6915151 f1450b49
Showing 41 changed files with 1767 additions and 508 deletions
......@@ -458,4 +458,52 @@ module.exports = {
...data
})
},
// 新 学习中心 - 开始测评
startExam(data) {
return http.post({
method: 'dj.pad.api.staff.study.exam.start',
projectName: 'pad',
...data
})
},
// 新 学习中心 - 员工学习时长统计
getStudyCenterTimeStatistics(data) {
return http.post({
method: 'dj.pad.api.course.staff.statistics',
projectName: 'pad',
...data
})
},
// 新 学习中心 - 我的课程 ,带状态的分页接口
getMyCourseList(data) {
return http.post({
method: 'dj.api.pad.learning.center.myself.course',
projectName: 'pad',
...data
})
},
// 新 学习中心 - 查询考试分页接口
getExamPage(data) {
return http.post({
method: 'dj.pad.api.recommended.staff.examination.page',
projectName: 'pad',
...data
})
},
// 新 学习中心 - 考试统计
getExamStatistics(data) {
return http.post({
method: 'dj.pad.api.recommended.staff.examination.count',
projectName: 'pad',
...data
})
},
// 新 学习中心 - 排行榜
getStudyDurationRank(data) {
return http.post({
method: 'dj.pad.api.recommended.staff.study.duration.rank',
projectName: 'pad',
...data
})
},
}
import http from '../request/http'
module.exports = {
/** 报价单分页列表 */
quotationPage(data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.page',
projectName: 'boutique',
...data
})
},
/** 根据id查询报价单数据 */
getQuotationInfo(data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.generate',
projectName: 'boutique',
...data
})
},
/** 查询报价单信息 */
getQuotationInfoById(data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.find.by.id',
projectName: 'boutique',
...data
})
},
/** 修改车损报价单客户基本信息信息 */
updateCustomerInfo(data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.customer.base.info.update',
projectName: 'boutique',
...data
})
},
/** 报价单订单分状态统计信息 */
orderStatistics(data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.order.status.statistics',
projectName: 'boutique',
...data
})
}
}
import http from '../request/http'
module.exports = {
/**新建车损报价单 */
quotationAdd (data) {
quotationAdd(data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.add',
projectName: 'boutique',
......@@ -12,7 +10,7 @@ module.exports = {
})
},
/** 报价单支付订单生成(带上签名)返回订单号(商户地址) */
quotationUpgrade (data) {
quotationUpgrade(data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.pay.order.generate',
projectName: 'boutique',
......@@ -20,7 +18,7 @@ module.exports = {
})
},
// 校验订单是否需要上传合同协议
checkZyPayFlag (data) {
checkZyPayFlag(data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.zyPayUrl.check',
projectName: 'boutique',
......@@ -28,9 +26,8 @@ module.exports = {
})
},
// 查询店铺配置
getShopMerchantPointConfig (data) {
getShopMerchantPointConfig(data) {
return http.post({
method: 'dj.api.smartcarlife.shopMerchantPointConfig.get',
projectName: 'boutique',
......@@ -39,7 +36,7 @@ module.exports = {
},
/** 查询报价单信息 */
getQuotationInfoById (data) {
getQuotationInfoById(data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.find.by.id',
projectName: 'boutique',
......@@ -49,7 +46,7 @@ module.exports = {
/**
* 订单详情
*/
getOrderDetail(data) {
getOrderDetail (data) {
return http.post({
method: 'dj.api.smartcarlife.order.detail',
projectName: 'boutique',
......@@ -57,7 +54,7 @@ module.exports = {
})
},
/**pos支付 */
getPosQr(data) {
getPosQr (data) {
return http.post({
method: 'dj.api.smartcarlife.payOrder.create',
projectName: 'boutique',
......@@ -68,11 +65,77 @@ module.exports = {
* 查询门店录单设置
},
*/
orderSettingList(data) {
orderSettingList (data) {
return http.post({
method: 'dj.api.smartcarlife.order.field.setting.list',
projectName: 'boutique',
...data
})
},
/** 报价单分页列表 */
quotationPage (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.page',
projectName: 'boutique',
...data
})
},
/** 根据id查询报价单数据 */
getQuotationInfo (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.generate',
projectName: 'boutique',
...data
})
},
/** 修改车损报价单客户基本信息信息 */
updateCustomerInfo (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.customer.base.info.update',
projectName: 'boutique',
...data
})
},
/** 报价单订单分状态统计信息 */
orderStatistics (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.order.status.statistics',
projectName: 'boutique',
...data
})
},
// 查询订单是否支持状态变更
getOrderRefundStep (data) {
return http.post({
method: 'dj.api.smartcarlife.refundApplyRecord.isExist',
projectName: 'boutique',
...data
})
},
/**报价单-撤销工单 */
cancelOrderById (data) {
return http.post({
method: 'dj.api.smartcarlife.quotation.cancel',
projectName: 'boutique',
...data
})
},
// 车损报价单战败订单创建
defeatOrderCreate (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.add.defeat.order',
projectName: 'boutique',
...data
})
},
// 更新合同协议内容
updateZyInfo (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.zyPayUrl.update',
projectName: 'boutique',
...data
})
}
}
......@@ -12,7 +12,6 @@ import interceptionApi from './interceptionApi'
import popupApi from './popupApi'
import usedCarApi from './usedCar'
import equityApi from './equity'
import equitApi from './equit'
module.exports = {
commonApi,
......@@ -28,6 +27,5 @@ module.exports = {
evaluationApi,
usedCarApi,
activityApi,
equityApi,
equitApi
equityApi
}
......@@ -162,5 +162,4 @@ class Request {
})
}
}
export default new Request()
export default new Request()
\ No newline at end of file
......@@ -213,6 +213,9 @@
.px-20 {
padding: 0 toRpx(20);
}
.px-24 {
padding: 0 toRpx(20);
}
.px-32 {
padding: 0 toRpx(32);
}
......

2.91 MB | W: | H:

2.92 MB | W: | H:

assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -122,7 +122,7 @@ export default {
},
startStudy(item, index) {
let { pageNum, total, nothing = 'nothing', pageSize } = this;
uni.$track.add({ eventCode: 'app_completed_course', businessId: item.id, pagePath: '/pages/boutique/myCourse' })
uni.$track.add({ eventCode: 'app_completed_course', businessId: item.id, pagePath: '/pages/common/studyCenter/myCourse' })
uni.navigateTo({
url: `/pages/common/studyDetail/detail?type=completed&index=${index}&completedCourseList=${encodeURIComponent(JSON.stringify(this.completedCourseList))}&pageNum=${pageNum}&pageSize=${pageSize}&total=${total}`
})
......
......@@ -464,22 +464,11 @@ export default {
// 切换到学习中心时显示弹窗
if (item.name === 'StudyCenter') {
this.showStudyPopup = true
const res = await uni.$api.commonApi.startExam()
if (res) {
this.showStudyPopup = true
}
}
// this.showBeisen = false
// if (item.isTrack) {
// // this.jumpUrl = jumpUrl
// // if (!this.jumpUrl) {
// // uni.showToast({
// // title: '培训账号未创建',
// // icon: 'none'
// // })
// // return
// // }
// } else {
// this.jumpUrl = ''
// }
},
handleFooter (val) {
this.footerBox = val
......
......@@ -212,7 +212,7 @@ const componentConfig = {
nullTips: '请选择座位数',
idKey: 'seat',
hideSearch: true,
loadComplete: false,
loadComplete: false
},
19: {
name: 'Customer',
......
......@@ -118,7 +118,7 @@ export default {
AgeRange,
City,
Seat,
Customer
Customer,
},
name: '',
props: {
......
const target = ['ip', 'dev', 'uat', 'prod', 'beta']
const index = 2
const index = 1
/**
*
0本地
......
......@@ -124,34 +124,7 @@
"h5" : {
"devServer" : {
"port" : 8080,
"https" : false,
"host" : "0.0.0.0",
"disableHostCheck" : true,
"proxy" : {
"^/rop-scrm-" : {
"target" : "https://scrm.test.glsx.com.cn",
"changeOrigin" : true,
"secure" : false
},
"^/rop-dj-" : {
"target" : "https://183.62.222.180",
"changeOrigin" : true,
"secure" : false,
"headers" : {
"Host" : "dj.test.glsx.com.cn"
}
},
"^/gsc-vcp-" : {
"target" : "http://gsc.test.glsx.com.cn",
"changeOrigin" : true,
"secure" : false
},
"^/rop-merchants/" : {
"target" : "https://rop-merchant.test.glsx.com.cn",
"changeOrigin" : true,
"secure" : false
}
}
"https" : false
}
}
}
}
\ No newline at end of file
......@@ -116,25 +116,25 @@
}
},
{
"path": "pages/boutique/myTask",
"path": "pages/common/studyCenter/myTask",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/boutique/myCourse",
"path": "pages/common/studyCenter/myCourse",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/boutique/myExam",
"path": "pages/common/studyCenter/myExam",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/boutique/leaderboard",
"path": "pages/common/studyCenter/leaderboard",
"style": {
"navigationStyle": "custom"
}
......@@ -275,7 +275,7 @@
"navigationStyle": "custom"
}
},
{
{
"path": "pages/usedCar/deliveryManagement/detail",
"style": {
"navigationStyle": "custom"
......@@ -286,6 +286,13 @@
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/common/filePreview",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": ""
}
}
],
"globalStyle": {
......@@ -301,4 +308,4 @@
"rpxCalcBaseDeviceWidth": 375,
"rpxCalcIncludeWidth": 750
}
}
\ No newline at end of file
}
<template>
<view class="file-preview-page">
<!-- 顶部导航栏 -->
<view class="nav-bar">
<view class="nav-back" @click="goBack" @tap="goBack">
<uni-icons type="arrow-left" size="20" color="#fff"></uni-icons>
</view>
<view class="nav-title">{{ fileName || getDefaultTitle() }}</view>
<view class="nav-placeholder"></view>
</view>
<!-- 预览内容区域 -->
<view class="preview-container">
<!-- 图片预览 -->
<view v-if="fileType === 1" class="image-preview">
<image :src="fileUrl" mode="aspectFit" class="preview-image" @load="onImageLoad" @error="onImageError" />
</view>
<!-- 视频预览 -->
<view v-else-if="fileType === 2" class="video-preview">
<video :src="fileUrl" controls autoplay class="preview-video" object-fit="contain" style="width: 100%; height: 100%"></video>
</view>
<!-- PDF预览 -->
<view v-else-if="fileType === 3" class="pdf-preview">
<!-- <web-view :src="fileUrl" class="pdf-webview"></web-view> -->
<lk-preview-office :url="fileUrl" fileType="pdf"></lk-preview-office>
</view>
<!-- 加载中状态 -->
<view v-else class="loading-container">
<view class="spinner"></view>
<text class="loading-text">加载中...</text>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'FilePreview',
data() {
return {
fileUrl: '',
fileType: 1, // 1: 图片, 2: 视频, 3: PDF
fileName: '',
loading: true,
error: false
}
},
onLoad(options) {
// 从路由参数获取文件信息
if (options.fileUrl) {
this.fileUrl = decodeURIComponent(options.fileUrl)
}
if (options.fileType) {
this.fileType = parseInt(options.fileType)
}
if (options.fileName) {
this.fileName = decodeURIComponent(options.fileName)
}
console.log('预览文件信息:', {
url: this.fileUrl,
type: this.fileType,
name: this.fileName
})
},
methods: {
goBack() {
console.log('返回按钮被点击')
// 使用 setTimeout 确保事件处理完成
setTimeout(() => {
uni.navigateBack({
delta: 1,
success: () => {
console.log('navigateBack 成功')
},
fail: err => {
console.log('navigateBack失败:', err)
// 如果没有上一级页面,跳转到首页
this.goToHomePage()
}
})
}, 100)
},
goToHomePage() {
console.log('跳转到首页')
// 请根据你的实际首页路径修改
const homePage = '/pages/index/index'
// 使用 redirectTo 而不是 reLaunch 避免页面栈问题
uni.redirectTo({
url: homePage,
fail: () => {
// 如果 redirectTo 失败,尝试 switchTab
uni.switchTab({
url: homePage,
fail: () => {
console.log('所有跳转方式都失败了')
// 最后尝试 reLaunch
uni.reLaunch({
url: homePage
})
}
})
}
})
},
getDefaultTitle() {
const titles = {
1: '图片预览',
2: '视频预览',
3: '文档预览'
}
return titles[this.fileType] || '文件预览'
},
onImageLoad() {
this.loading = false
console.log('图片加载成功')
},
onImageError(e) {
this.loading = false
this.error = true
console.error('图片加载失败:', e)
uni.showToast({
title: '图片加载失败',
icon: 'none'
})
}
}
}
</script>
<style scoped lang="scss">
.file-preview-page {
width: 100vw;
height: 100vh;
background: #000;
display: flex;
flex-direction: column;
position: relative;
}
.nav-bar {
height: toRpx(88);
display: flex;
align-items: center;
justify-content: space-between;
background: rgba(0, 0, 0, 0.8);
padding: 0 toRpx(32);
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 9999;
/* 移除 backdrop-filter 避免可能的渲染问题 */
.nav-back {
width: toRpx(60);
height: toRpx(60);
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
background: rgba(255, 255, 255, 0.2);
z-index: 10000;
position: relative;
/* 添加 pointer-events 确保可点击 */
pointer-events: auto;
}
.nav-title {
color: #fff;
font-size: toRpx(32);
font-weight: 500;
flex: 1;
text-align: center;
margin: 0 toRpx(60);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.nav-placeholder {
width: toRpx(60);
}
}
.preview-container {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
position: relative;
margin-top: toRpx(88); /* 为固定导航栏留出空间 */
z-index: 1;
/* 确保内容不会阻挡导航栏 */
pointer-events: auto;
}
.image-preview {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
.preview-image {
max-width: 100%;
max-height: 100%;
display: block;
}
}
.video-preview {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
.preview-video {
width: 100%;
height: 100%;
}
}
.pdf-preview {
width: 100%;
height: 100%;
.pdf-webview {
width: 100%;
height: 100%;
}
}
.loading-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #fff;
.spinner {
width: toRpx(80);
height: toRpx(80);
border: toRpx(4) solid rgba(255, 255, 255, 0.3);
border-top: toRpx(4) solid #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: toRpx(20);
}
.loading-text {
font-size: toRpx(28);
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
/* 响应式优化 */
@media screen and (max-width: 768px) {
.nav-bar {
height: toRpx(80);
padding: 0 toRpx(24);
}
.nav-title {
font-size: toRpx(28);
}
.nav-back,
.nav-placeholder {
width: toRpx(50);
height: toRpx(50);
}
.preview-container {
margin-top: toRpx(80);
}
}
</style>
<template>
<view class="leaderboard-container">
<view class="detail-box">
<!-- 顶部导航 -->
<view class="header">
<view class="nav-bar">
<view class="back" @click="back">
<uni-icons type="left" :size="20" color="#000000"></uni-icons>
</view>
<view class="title">排行榜</view>
<view class="nav-bar">
<view class="back" @click="back">
<uni-icons type="left" :size="20" color="#000000"></uni-icons>
</view>
<view class="title">排行榜</view>
</view>
<!-- 左右布局 -->
......@@ -15,52 +13,56 @@
<!-- 左侧排行榜 -->
<view class="left-panel">
<view class="top-image-wrapper">
<image class="panel-image" :src="require('@/assets/images/studyCenter/Leaderboard-bg.png')" mode="scaleToFill" />
<image class="panel-image" :src="require('@/assets/images/studyCenter/Leaderboard-bg.png')"
mode="scaleToFill" />
</view>
<view class="tab-header">
<view class="tab-list">
<view
v-for="(tab, index) in tabList"
:key="index"
:class="['tab-item', { 'active': currentTab === index }]"
@click="switchTab(index)"
>
<view v-for="(tab, index) in tabList" :key="index" :class="['tab-item', { 'active': currentTab === index }]"
@click="switchTab(index)">
<text class="tab-text">{{ tab.label }}</text>
</view>
</view>
<view class="median-text">学习时长中位数:{{ medianTime }}小时</view>
<view class="median-text">学习时长中位数:{{ rank.median }}小时</view>
</view>
<view class="rank-list">
<view
v-for="(item, index) in leaderboardList"
:key="index"
:class="['rank-item', { 'current-user': item.isCurrentUser }]"
>
<view v-if="rank.currentUserRank" class="rank-item current-user">
<view class="rank-left">
<view v-if="item.rank <= 3 && !item.isCurrentUser" class="rank-badge medal">
<image class="medal-icon" :src="getMedalIcon(item.rank - 1)" mode="aspectFit" />
</view>
<view v-else :class="['rank-badge', 'number', { 'has-bg': item.isCurrentUser }, { 'gray-number': item.rank >= 4 && !item.isCurrentUser }]">
<text class="rank-number">{{ item.rank >= 100 ? '99+' : item.rank }}</text>
<view class="rank-badge number has-bg">
<template v-if="rank.currentUserRank.rank">
<text class="rank-number">{{ rank.currentUserRank.rank >= 100 ? '99+' : rank.currentUserRank.rank }}</text>
</template>
<text v-else class="rank-number">-</text>
</view>
<text class="user-name">{{ item.name }}</text>
<text class="user-name">{{ rank.currentUserRank.userName }}</text>
</view>
<text class="study-time">{{ item.hours }}小时</text>
<text class="study-time">{{ rank.currentUserRank.duration == null ? '-' : rank.currentUserRank.duration }}小时</text>
</view>
<scroll-view class="rank-scroll" scroll-y="true">
<view v-for="(item, index) in rank.rankList" :key="index"
:class="['rank-item']">
<view class="rank-left">
<view v-if="item.rank <= 3" class="rank-badge medal">
<image class="medal-icon" :src="getMedalIcon(item.rank - 1)" mode="aspectFit" />
</view>
<view v-else
:class="['rank-badge', 'number', { 'gray-number': item.rank >= 4 }]">
<text class="rank-number">{{ item.rank >= 100 ? '99+' : item.rank }}</text>
</view>
<text class="user-name">{{ item.userName }}</text>
</view>
<text class="study-time">{{ item.duration == null ? '-' : item.duration }}小时</text>
</view>
</scroll-view>
</view>
</view>
<!-- 右侧面板 -->
<view class="right-panel">
<view class="developing flex">
<image
class="developing-icon"
src="../../assets/images/common/developing.webp"
/>
<image class="developing-icon" src="../../../assets/images/common/developing.webp" />
功能开发中
</view>
</view>
......@@ -80,17 +82,16 @@ export default {
{ label: '周榜' },
{ label: '月榜' }
],
medianTime: 180,
leaderboardList: [],
currentUser: {
name: '李洪扬',
hours: 112
},
currentUserRank: 25
rank: {
median: 0,
currentUserRank: {},
rankList: []
}
}
},
mounted() {
this.generateMockData()
// this.generateMockData()
this.getStudyDurationRank()
},
methods: {
back() {
......@@ -98,7 +99,7 @@ export default {
},
switchTab(index) {
this.currentTab = index
this.generateMockData()
this.getStudyDurationRank()
},
getMedalIcon(index) {
const medals = [
......@@ -108,28 +109,20 @@ export default {
]
return medals[index]
},
generateMockData() {
const names = ['孟伟', '任小宣', '谭亦云', '李晓夏', '李文歆', '袁佳', '刘轩华', '高强', '张明', '王芳', '李娜', '赵伟', '陈静', '周杰', '吴磊', '郑丽', '黄涛', '徐敏', '孙鹏', '马超']
this.leaderboardList = []
this.leaderboardList.push({
rank: this.currentUserRank,
name: this.currentUser.name,
hours: this.currentUser.hours,
isCurrentUser: true
// 获取排行榜
async getStudyDurationRank() {
uni.showLoading({
title: '加载中'
})
let baseHours = 250
for (let i = 0; i < 100; i++) {
if ((i + 1) === this.currentUserRank) {
continue
}
this.leaderboardList.push({
rank: i + 1,
name: names[i % names.length] + (i > 19 ? i - 19 : ''),
hours: Math.max(10, baseHours - i * 2 - Math.floor(Math.random() * 5)),
isCurrentUser: false
try {
const res = await uni.$api.commonApi.getStudyDurationRank({
periodType: this.currentTab,
staffPhone: uni.$storage.get('userInfo').phone
})
console.log(res, 'res')
this.rank = res
} finally {
uni.hideLoading()
}
}
}
......@@ -137,53 +130,42 @@ export default {
</script>
<style lang="scss" scoped>
.leaderboard-container {
width: 100%;
height: 100vh;
.detail-box {
position: relative;
overflow: hidden;
width: 100vw;
height: 100vh;
background-image: url('@/assets/images/common/page-bg.webp');
background-size: 100%;
box-sizing: border-box;
padding: toRpx(160) toRpx(64) 0;
&::after {
content: '';
background-image: url('@/assets/images/common/home-bg-1.webp');
background-size: 100% 100%;
background-repeat: no-repeat;
.nav-bar {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.header {
position: relative;
z-index: 10;
background: transparent;
margin-bottom: toRpx(44);
height: toRpx(96);
left: 0;
top: toRpx(48);
z-index: 999;
pointer-events: none;
.nav-bar {
.back {
height: 100%;
aspect-ratio: 1/1;
display: flex;
align-items: center;
justify-content: center;
height: toRpx(88);
position: relative;
.back {
position: absolute;
left: toRpx(32);
display: flex;
align-items: center;
justify-content: center;
width: toRpx(60);
height: toRpx(60);
}
pointer-events: auto;
}
.title {
font-size: toRpx(36);
font-weight: 500;
color: #000000;
}
.title {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-weight: 700;
font-size: toRpx(32);
color: #1a1a1a;
}
}
......@@ -191,7 +173,7 @@ export default {
display: flex;
gap: toRpx(32);
padding: 0 toRpx(40);
height: calc(100vh - var(--status-bar-height) - toRpx(88) - toRpx(44));
// height: calc(100vh - var(--status-bar-height) - toRpx(88) - toRpx(44));
.left-panel {
width: toRpx(1084);
......@@ -272,12 +254,13 @@ export default {
.rank-list {
margin-top: toRpx(24);
padding: 0 toRpx(48) toRpx(48);
max-height: toRpx(1050);
overflow-y: auto;
.rank-item {
width: toRpx(988);
box-sizing: border-box;
margin: 0 toRpx(48);
// width: toRpx(988);
width: calc(100% - toRpx(96));
height: toRpx(128);
border-radius: toRpx(24);
background: transparent;
......@@ -304,6 +287,7 @@ export default {
align-items: center;
justify-content: center;
margin-right: toRpx(20);
background-color: #ffffff;
&.medal {
background: transparent;
......@@ -316,7 +300,6 @@ export default {
}
&.number {
background: transparent;
border: none;
&.has-bg {
......@@ -362,6 +345,10 @@ export default {
}
}
.rank-scroll {
max-height: toRpx(960);
}
}
}
......@@ -395,5 +382,3 @@ export default {
}
}
</style>
......@@ -123,7 +123,7 @@
},
goToMyTask() {
uni.navigateTo({
url: '/pages/boutique/myTask'
url: '/pages/common/studyCenter/myTask'
})
},
changeType(index, tagIndex) {
......
<template>
<view class="order">
<view :class="['order-box', { hide: showUpload }]" :key="formKey">
<view class="common-title">修改客户信息</view>
<view class="box">
<scroll-view class="scroll-view" scroll-y="true">
<view class="box-content">
<GlCell :formList="formList" :formData="orderObj" @radioChange="radioChange" @inputBlur="inputBlur" @handleCell="handleCell" :titleList="titleList"></GlCell>
</view>
<view class="btns flex">
<view class="btn save" @click="back">放弃</view>
<view @click="submit" class="btn">提交修改</view>
</view>
</scroll-view>
</view>
</view>
<!-- 弹窗 -->
<order-popup ref="orderPopup" :data="orderObj" :dataKey="valueKey" @onConfirm="onConfirm" :externalData="externalData" :popupType="popupType" :popupTitle="popupTitle" />
<template v-if="showUpload">
<view class="upload-box">
<upload-proof-of-payment @back="showUpload = false" @confirm="uploadConfirm" />
</view>
</template>
<!-- 支付弹框 -->
<OrderPay ref="OrderPay" @jumpSuccess="jumpSuccess" />
<NoticePopup ref="notice" title="重要提示" text="当前页面暂未保存,是否确认退出" type="warning"></NoticePopup>
</view>
</template>
<script>
import utils from '@/utils/utils'
import OrderPopup from '@/components/OrderPopup/index.vue'
import GlCell from '../../../../components/Form/GlCell.vue'
import { UpdateOrderInfo, popupTypeEnum, payTypeList, titleList } from '../contant'
import { interceptionMixin } from '@/mixin/index'
import UploadProofOfPayment from './UploadProofOfPayment.vue'
import NoticePopup from '@/components/NoticePopup.vue'
import dayjs from 'dayjs'
import OrderPay from './OrderPay.vue'
import NP from 'number-precision'
export default {
name: 'CreateOrder',
mixins: [interceptionMixin],
components: {
GlCell,
OrderPopup,
UploadProofOfPayment,
OrderPay,
NoticePopup
},
props: {
transmissionOfData: {
type: Object,
default: () => null
}
},
data() {
return {
showUpload: false,
titleList,
formList: utils.deepClone(UpdateOrderInfo),
baseConfigData: {},
requiredList: [], // 录单设置的必填项
orderObj: {
owner: '',
phone: '',
salesType: 0,
carVin: '',
certificateNo: '',
notes: ''
}
}
},
computed: {
showPayTips() {
return this.orderObj.payee == 0 && this.orderObj.payType == 7
},
userInfo() {
return uni.$storage.get('userInfo') || {}
}
},
watch: {
transmissionOfData: {
handler(newVal, oldVal) {
if (newVal) {
console.log(newVal, 'newVal')
} else {
console.log(oldVal, 'oldVal')
}
}
}
},
mounted() {
this.baseConfigData = uni.$storage.get('mock_data') || {}
this.initData()
},
methods: {
initData() {
console.log('initData', this.transmissionOfData)
const { paramsData } = this.transmissionOfData
this.getQuotationInfoById(paramsData.id)
// 埋点
// uni.$track.add({ eventCode: 'app_create_order' })
},
async getQuotationInfoById(id) {
const data = await uni.$api.equityApi.getQuotationInfoById({ id })
console.log(data, 'data')
// this.orderInfo = data
this.orderObj.id = id
this.orderObj.ownerId = data.owner.id
this.orderObj.carVin = data.owner.carVin
this.orderObj.owner = data.owner.owner
this.orderObj.phone = data.owner.phone
this.orderObj.salesType = data.owner.salesType
this.orderObj.certificateNo = data.owner.certificateNo
this.orderObj.notes = data.notes
},
// 输入框失去焦点事件
inputBlur(e, val) {
console.log(e, val)
this.orderObj[val.value] = this.orderObj[val.value]
},
// 校验必填等规则
checkRequired() {
try {
const phoneRex = /^[1]([3-9])[0-9]{9}$/,
requiredArr = [],
onlyLabelItem = [],
{ orderObj } = this
this.formList.forEach(group => {
group.forEach(item => {
if (item.required === true && item.hidden !== true) {
if (item.isArray) onlyLabelItem.push(item)
else requiredArr.push(item)
}
})
})
// 遍历requiredArr,检查orderObj中是否有对应的值
for (let i = 0; i < requiredArr.length; i++) {
const item = requiredArr[i]
// 兼容嵌套customer对象的情况
let value = orderObj[item.value]
if (value === undefined || value === null || value === '') throw `${item.label}不能为空`
// 如果是customerPhone,添加phoneRex校验
if (item.value === 'phone' && !phoneRex.test(value)) throw `请输入正确的${item.label}`
}
if (orderObj.carVin) {
const vinRex = /^(?=.*[A-Za-z])[A-Za-z0-9]{17}$/
if (!vinRex.test(orderObj.carVin)) throw '请输入正确的车架号'
}
if (orderObj.certificateNo && orderObj.certificateNo.length != 18) throw '请输入正确的18位证件号'
return true
} catch (error) {
if (error)
uni.showToast({
title: error,
icon: 'none'
})
return false
}
},
// 提交
async submit() {
if (!this.checkRequired() || (await this.checkDailyReport())) return
let params = {
id: this.orderObj.id,
notes: this.orderObj.notes || '',
owner: {
id: this.orderObj.ownerId,
owner: this.orderObj.owner,
phone: this.orderObj.phone,
carVin: this.orderObj.carVin || '',
certificateNo: this.orderObj.certificateNo || '',
salesType: this.orderObj.salesType || 0
}
}
console.log(params, 'params')
uni.showLoading({
title: '提交中...',
mask: true
})
uni.$api.equityApi
.updateCustomerInfo(params)
.then(result => {
uni.hideLoading()
console.log(result)
this.$emit('jump', 'OrderManagement', {})
})
.catch(err => {
uni.hideLoading()
})
},
back() {
// 配置弹窗按钮
this.$refs.notice.buttonsList = [
{
text: '确认退出',
type: 'default',
callback: () => {
this.transmissionOfData = null
this.$refs.notice.close()
this.$emit('jump', 'OrderManagement', {})
}
},
{
text: '继续编辑',
type: 'primary',
callback: () => {
this.$refs.notice.close()
}
}
]
// 打开弹窗
this.$refs.notice.open()
}
}
}
</script>
<style scoped lang="scss">
.order {
height: 100%;
position: relative;
&-box {
visibility: visible;
height: 100%;
}
.hide {
opacity: 0;
visibility: hidden;
}
.upload-box {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
}
.box {
height: calc(100% - #{toRpx(120)});
padding-bottom: toRpx(24);
.scroll-view {
height: 100%;
}
}
.box-content {
padding: 0 toRpx(48);
}
.total {
display: flex;
justify-content: space-between;
align-items: center;
padding: toRpx(24) toRpx(32) toRpx(24) 0;
font-size: toRpx(28);
border-bottom: toRpx(2) solid #f7f7f6;
&-left {
color: #333;
font-weight: 500;
}
&-right {
color: #f24724;
font-weight: 500;
}
}
.pay-tips {
padding: toRpx(24) toRpx(24) toRpx(24) 0;
font-size: toRpx(24);
color: #999;
}
.btns {
position: absolute;
width: 100%;
bottom: 0;
padding: 24rpx 128rpx;
gap: 32rpx;
.save {
background: #3b73ff1a;
color: #4673ff;
font-size: 28rpx;
font-weight: 500;
}
}
.btn {
display: flex;
align-items: center;
justify-content: center;
width: toRpx(1130);
height: toRpx(80);
color: #fff;
border-radius: toRpx(48);
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
}
.customer-title {
.customer-file {
margin-left: 20rpx;
color: #347bff;
font-size: 24rpx;
.sprite-icon {
margin-right: 4rpx;
}
}
}
</style>
......@@ -5,15 +5,15 @@ const FORM_LIST = [
value: 'referrer',
type: 'select',
key: 'employeeName',
required: true,
required: true
},
{
label: '交付专员',
value: 'deliveryName',
type: 'select',
required: true,
key: 'deliveryEmployeeName',
},
key: 'deliveryEmployeeName'
}
],
[
{
......@@ -94,7 +94,7 @@ const FORM_LIST = [
value: 'companion',
maxlength: '200',
type: 'input'
},
}
],
[
{
......@@ -129,8 +129,8 @@ const FORM_LIST = [
value: 'price',
maxlength: '8',
type: 'input',
required: true,
},
required: true
}
],
[
{
......@@ -141,7 +141,7 @@ const FORM_LIST = [
addHtml: 'skuGoods',
required: true,
isArray: true
},
}
],
[
{
......@@ -214,37 +214,12 @@ const DEFEAT_FORM_LIST = [
required: true
},
{
label: '销售顾问/录单员',
label: '推荐人员',
value: 'employeeName',
type: 'select',
// key: 'staffName',
required: true,
showText: 'shopMerchantName'
},
{
label: '交付专员',
value: 'deliveryEmployeeName',
type: 'select',
key: 'employeeName',
required: true,
// key: 'staffName',
hidden: true,
showText: 'shopMerchantName'
},
{
label: '二级流量方',
value: 'subShopMerchantName',
type: 'select',
required: true,
// key: 'subMerchantName',
hidden: true
},
{
label: '转化人员',
value: 'sellerName',
type: 'select',
// key: 'staffName',
required: true,
showText: 'merchantName'
}
],
[
......@@ -256,40 +231,6 @@ const DEFEAT_FORM_LIST = [
required: true
},
{
label: '客户来源',
value: 'salesType',
type: 'radio',
current: '0',
radioList: [
{
value: '0',
name: '售前'
},
{
value: '1',
name: '售后'
}
],
required: true,
hidden: true
},
{
label: '性别',
value: 'customerSex',
type: 'radio',
current: '1',
radioList: [
{
value: '1',
name: '男'
},
{
value: '2',
name: '女'
}
]
},
{
label: '手机号',
value: 'customerPhone',
maxlength: '11',
......@@ -298,165 +239,25 @@ const DEFEAT_FORM_LIST = [
inputType: 'number'
},
{
label: '选择车型',
value: 'carBrand',
type: 'select',
key: 'carInfo'
},
{
label: '车架号(VIN)',
value: 'standNo',
maxlength: '17',
type: 'input'
},
{
label: '车牌号',
value: 'plateNumber',
maxlength: '8',
type: 'input'
},
{
label: '是否体验',
value: 'experienceFlag',
type: 'radio',
current: 'Y',
required: true,
radioList: [
{
value: 'Y',
name: '是'
},
{
value: 'N',
name: '否'
}
]
}
],
[
{
label: '精品礼券',
value: 'couponInfo',
type: 'select',
key: 'name',
required: true,
hidden: true
},
{
label: '请选择产品',
onlyLabel: true,
required: true,
noBorder: true
},
{
label: '前挡',
value: 'frontGear',
type: 'select',
key: 'name',
labellIcon: 'front-gear',
addHtml: 'frontGear',
hidden: true
},
{
label: '前侧窗玻璃',
value: 'frontWindow',
type: 'select',
key: 'name',
labellIcon: 'front-window',
addHtml: 'frontWindow',
hidden: true
},
{
label: '后侧窗玻璃',
value: 'rearGear',
type: 'select',
key: 'name',
labellIcon: 'rear-gear',
addHtml: 'rearGear',
hidden: true
},
{
label: '后档',
value: 'rearWindow',
type: 'select',
key: 'name',
labellIcon: 'rear-window',
addHtml: 'rearWindow',
hidden: true
},
{
label: '天窗',
value: 'sunRoof',
type: 'select',
key: 'name',
labellIcon: 'sun-roof',
addHtml: 'sunRoof',
hidden: true
},
{
label: '套餐',
value: 'package',
type: 'select',
key: 'name',
addHtml: 'package',
hidden: true
},
{
label: '其他精品',
value: 'skuGoods',
type: 'select',
key: 'name',
addHtml: 'skuGoods',
hidden: true
},
{
label: '收款方式',
value: 'payee',
label: '客户来源',
value: 'salesType',
type: 'radio',
key: 'name',
current: '1',
current: '0',
radioList: [
{
value: '0',
name: '嘀加收款',
disabled: false
name: '售前'
},
{
value: '1',
name: '4s店收款',
disabled: false
name: '售后'
}
],
hidden: true
required: true
},
{
label: '支付方式',
value: 'payType',
type: 'radio',
key: 'name',
current: '0',
radioList: [
// {
// value: '3',
// name: 'POS机'
// },
// {
// value: '6',
// name: '对公转账'
// },
// {
// value: '7',
// name: '其他收款'
// }
],
addHtml: 'otherPay',
hidden: true
}
],
[
{
label: '车主拒升理由',
value: 'refusalReason',
label: '战败理由',
value: 'deafeatReason',
maxlength: '30',
type: 'textarea',
placeholder: '请输入 (30字以内)',
......@@ -468,6 +269,8 @@ const DEFEAT_FORM_LIST = [
]
]
const defeat_titleList = [null, { addHtml: 'customer' }]
const payTypeList = [
{
value: '1',
......@@ -585,11 +388,61 @@ const popupTypeEnum = {
key: 'customer'
}
}
const titleList = [
null,
{ addHtml: 'customer' },
{ name: '车辆信息' },
{ name: '增值车损险' },
{ name: '其他信息' },
const titleList = [null, { addHtml: 'customer' }, { name: '车辆信息' }, { name: '增值车损险' }, { name: '其他信息' }]
const UpdateOrderInfo = [
[
{
label: '车主姓名',
value: 'owner',
maxlength: '10',
type: 'input',
required: true
},
{
label: '手机号',
value: 'phone',
maxlength: '11',
inputType: 'number',
type: 'input',
required: true
},
{
label: '客户类型',
value: 'salesType',
type: 'radio',
current: 0,
radioList: [
{
value: 0,
name: '售前'
},
{
value: 1,
name: '售后'
}
]
},
{
label: '车架号(VIN码)',
value: 'carVin',
maxlength: '17',
type: 'input'
},
{
label: '身份证号',
value: 'certificateNo',
maxlength: '18',
type: 'input'
},
{
label: '订单备注',
value: 'notes',
maxlength: '100',
type: 'textarea',
placeholder: '请输入 (100字以内)',
class: 'cell-break'
}
]
]
export { FORM_LIST, popupTypeEnum, payTypeList, DEFEAT_FORM_LIST, titleList }
export { FORM_LIST, popupTypeEnum, payTypeList, DEFEAT_FORM_LIST, titleList, UpdateOrderInfo, defeat_titleList }
<template>
<view class="detail-box">
<view class="nav-bar">
<view
class="back"
@click="backPage"
>
<uni-icons
type="left"
:size="20"
color="#000"
></uni-icons>
<view class="back" @click="backPage">
<uni-icons type="left" :size="20" color="#000"></uni-icons>
</view>
<view class="title">展业工具</view>
</view>
......@@ -17,46 +10,20 @@
<view class="detail-left">
<view class="common-title">展业</view>
<view class="content">
<image
class="banner"
src="../../../assets/images/common/tool_banner.png"
mode="scaleToFill"
/>
<image class="banner" src="../../../assets/images/common/tool_banner.png" mode="scaleToFill" />
<template v-if="toolComponentName !== 'DailyReport'">
<Entrance @entranceClick="entranceClick"></Entrance>
</template>
<template v-else>
<uni-calendar
ref="calendar"
:clearDate="false"
:endDate="endDate"
:showMonth="false"
@monthSwitch="currentMonth = `${$event.year}-${$event.month}`"
@change="currentDate = $event.fulldate"
backgroundColor="transparent"
:selected="selectedDays"
:date="currentDate"
/>
<uni-calendar ref="calendar" :clearDate="false" :endDate="endDate" :showMonth="false" @monthSwitch="currentMonth = `${$event.year}-${$event.month}`" @change="currentDate = $event.fulldate" backgroundColor="transparent" :selected="selectedDays" :date="currentDate" />
</template>
</view>
</view>
<view class="detail-right">
<component
:is="toolComponentName"
@jump="jump"
:transmission-of-data="transmissionOfData"
:currentDate="currentDate"
:currentMonth="currentMonth"
@setCalendarSelected="selectedDays = $event"
/>
<component :is="toolComponentName" @jump="jump" :transmission-of-data="transmissionOfData" :currentDate="currentDate" :currentMonth="currentMonth" @setCalendarSelected="selectedDays = $event" />
</view>
</view>
<NoticePopup
ref="notice"
title="重要提示"
text="当前页面暂未保存,是否确认退出"
type="warning"
></NoticePopup>
<NoticePopup ref="notice" title="重要提示" text="当前页面暂未保存,是否确认退出" type="warning"></NoticePopup>
</view>
</template>
......@@ -71,6 +38,7 @@ import UploadProofOfPayment from './components/UploadProofOfPayment.vue'
import NoticePopup from '@/components/NoticePopup.vue'
import dayjs from 'dayjs'
import { interceptionMixin } from '@/mixin/index'
import UpdateOrderInfo from './components/UpdateOrderInfo.vue'
export default {
mixins: [interceptionMixin],
......@@ -82,9 +50,10 @@ export default {
OrderManagement,
NoticePopup,
UploadProofOfPayment,
OrderDetail
OrderDetail,
UpdateOrderInfo
},
data () {
data() {
return {
toolComponentName: '',
transmissionOfData: null,
......@@ -94,8 +63,7 @@ export default {
selectedDays: []
}
},
onLoad (options) {
console.log( uni.getWindowInfo())
onLoad(options) {
if (options.componentName) this.toolComponentName = options.componentName
if (options.currentDate) this.setCurrentDate(options.currentDate)
uni.$on('jumpToDailyReport', currentDate => {
......@@ -104,11 +72,11 @@ export default {
})
},
methods: {
setCurrentDate (currentDate) {
setCurrentDate(currentDate) {
this.currentDate = currentDate
this.currentMonth = dayjs(currentDate).format('YYYY-MM')
},
async entranceClick (item) {
async entranceClick(item) {
const noInterceptPage = ['DailyReport']
if (!noInterceptPage.includes(item.name) && ((await this.checkDailyReport()) || (await this.inspectionOfProhibitionBill()))) return
// 保存当前选择的组件信息,但不立即切换
......@@ -116,7 +84,7 @@ export default {
if (this.toolComponentName === selectedItem.name && (!this.transmissionOfData || this.transmissionOfData.type !== 'supplementOrder')) return
// 如果当前组件是OrderManagement,直接切换组件,不显示弹窗
// 只有从CreateOrder、DefeatOrder切换其他组件时需要二次确认
if (this.toolComponentName !== 'CreateOrder' && this.toolComponentName !== 'DefeatOrder') {
if (this.toolComponentName !== 'CreateOrder' && this.toolComponentName !== 'DefeatOrder' && this.toolComponentName !== 'UpdateOrderInfo') {
this.toolComponentName = selectedItem.name
this.transmissionOfData = null
return
......@@ -152,11 +120,11 @@ export default {
// 打开弹窗
this.$refs.notice.open()
},
backPage () {
backPage() {
uni.navigateBack()
},
// name:跳转组件名,val:跳转参数
jump (name, val) {
jump(name, val) {
this.toolComponentName = name
if (val) {
this.transmissionOfData = val
......
## 1.0.2(2023-11-01)
更换App端转换本地链接的方法;
添加App端文件拓展名过滤;
## 1.0.1(2023-09-04)
优化部分逻辑
## 1.0.0(2023-09-03)
支持图片、视频选择上传;H5、微信小程序,App支持文件选择上传
<!-- eslint-disable -->
<template>
<view>
<!-- #ifdef APP-PLUS -->
<view class="xe-upload" v-html="renderInput" :props="mergeProps" :change:props="XeUpload.renderProps"></view>
<!-- #endif -->
</view>
</template>
<script>
import {
chooseMedia,
chooseFile,
chooseMessageFile,
uploadFile,
} from '../../tools/apis';
import {
deepMerge,
awaitWrap,
base64ToPath,
isArray,
} from '../../tools/tools';
export default {
name: 'XeUpload',
props: {
options: {
default: () => ({}),
type: Object,
},
},
data() {
return {
id: 0, // APP上传框ID
renderInput: '', // APP上传框
};
},
computed: {
mergeOptions({ options = {} }) {
const tmpOptions = {
name: 'file',
};
return deepMerge(tmpOptions, options);
},
mergeProps({ id, renderInput, mergeOptions }) {
return {
id,
renderInput,
upload: mergeOptions,
};
},
},
methods: {
// 上传事件
async upload(type, config = {}) {
let tmpResult = [];
if (['image', 'video'].includes(type)) {
const [err, res] = await chooseMedia(type, config);
if (err) return this.handleError(err);
tmpResult = res?.tempFiles || [];
}
// H5 || APP-PLUS || MP-WEIXIN
if (['file'].includes(type)) {
let tmpFiles = {};
let tmpErr = null;
// #ifdef H5
[tmpErr, tmpFiles] = await chooseFile(config);
// #endif
// #ifdef MP-WEIXIN
[tmpErr, tmpFiles] = await chooseMessageFile(config);
// #endif
// #ifdef APP-PLUS
this.id = Math.floor(Math.random() * 100000000 + 1);
this.initInput(config.extension);
// #endif
if (tmpErr) return this.handleError(tmpErr);
tmpResult = tmpFiles?.tempFiles || [];
}
this.handleUpload(tmpResult);
},
// 初始化上传框
initInput(extension) {
const { id } = this;
let accept = extension;
if (isArray(extension)) {
accept = extension.join(',');
}
this.renderInput = `<input type="file" id="xe-upload-${id}" name="xe-upload" ${accept ? 'accept="' + accept + '"' : ''} />`;
},
// 文件上传(没有传入上传url时返回本地链接)
async handleUpload(files = []) {
if (files.filter((e) => Boolean(e)).length === 0) return;
const { mergeOptions } = this;
if (!mergeOptions.url) {
return this.handleEmits({
type: 'choose',
data: files,
});
}
const tmpUploads = files.map((e) =>
uploadFile(
{
...mergeOptions,
filePath: e.tempFilePath,
},
e,
)
);
const [err, res] = await awaitWrap(Promise.all(tmpUploads));
if (err) return this.handleError(err);
this.handleEmits({
type: 'success',
data: res,
});
},
// 处理失败事件
handleError(error) {
this.handleEmits({
type: 'warning',
data: error,
});
},
// 处理响应事件
async handleEmits(e) {
// #ifdef APP-PLUS
if (e.type === 'choose') {
// 将base64转为本地链接
for (let i = 0; i < e.data.length; i += 1) {
const item = e.data[i];
if (!item.base64Url) {
continue;
}
const [parseError, parseUrl] = await awaitWrap(base64ToPath(item.base64Url, item.name));
if (!parseError) {
e.data[i].tempFilePath = parseUrl;
} else {
e.data[i].tempFilePath = item.base64Url;
}
delete e.data[i].base64Url;
}
}
// #endif
this.$emit('callback', e);
},
},
};
</script>
<!-- #ifdef APP-PLUS -->
<script module="XeUpload" lang="renderjs">
import {
appUploadFile,
} from '../../tools/apis';
import {
awaitWrap,
fileToBase64,
} from '../../tools/tools';
export default {
data() {
return {
id: 0, // 上传框ID
uploadOptions: {}, // 上传配置
};
},
methods: {
// 处理 XeUpload 传入 renderjs 数据,以及调起上传框
renderProps(info) {
const { id, renderInput, upload } = info;
if (!renderInput) return;
this.id = id;
this.uploadOptions = upload;
this.$nextTick(() => {
const dom = document.getElementById(`xe-upload-${id}`);
dom.addEventListener('change', () => {
this.handleUpload();
});
dom?.click?.();
});
},
// 处理文件上传(没有传入url时返回本地链接)
async handleUpload() {
const {
url,
name,
header = {},
formData = {},
} = this.uploadOptions || {};
const dom = document.getElementById(`xe-upload-${this.id}`);
if (!dom.files[0]) return;
const tmpFileList = Array.from(dom.files);
const tmpUploads = [];
for (let i = 0; i < tmpFileList.length; i += 1) {
const e = tmpFileList[i];
let tmpType = 'file';
if (e.type.includes('image')) {
tmpType = 'image';
}
if (e.type.includes('video')) {
tmpType = 'video';
}
const tmpExts = {
size: e.size,
name: e.name,
type: e.type,
fileType: tmpType,
tempFilePath: '',
base64Url: '',
};
// 没有传入上传url时,直接返回本地链接
if (!url) {
const [parseError, parseUrl] = await awaitWrap(fileToBase64(dom.files[i]));
if (!parseError) {
tmpExts.base64Url = parseUrl;
}
tmpUploads.push(tmpExts);
continue;
};
const tmpData = new FormData();
tmpData.append(name, dom.files[i], e.name);
for (let key in formData) {
tmpData.append(key, formData[key]);
}
// 上传进度
const onprogress = (ev) => {
if(ev.lengthComputable) {
var result = (ev.loaded / ev.total) * 100;
this.handleRenderEmits({
type: 'onprogress',
data: {
progress: Math.floor(result),
current: i + 1,
total: tmpFileList.length,
},
});
};
}
tmpUploads.push(appUploadFile({
url,
header,
formData: tmpData
}, tmpExts, onprogress ));
}
// 没有传入上传url时,直接返回本地链接列表
if (!url) {
return this.handleRenderEmits({
type: 'choose',
data: tmpUploads,
});
}
this.handleRenderEmits({
type: 'onprogress',
data: {
progress: 0,
current: 1,
total: tmpFileList.length,
},
});
// 处理上传文件
const [err, res] = await awaitWrap(Promise.all(tmpUploads));
if (err) {
return this.handleRenderEmits({
type: 'warning',
data: err,
});
}
this.handleRenderEmits({
type: 'success',
data: res,
});
},
// 数据传输到XeUpload组件
handleRenderEmits(data) {
this.$ownerInstance.callMethod('handleEmits', data);
},
},
};
</script>
<!-- #endif -->
<style scoped>
.xe-upload {
display: none;
}
</style>
{
"id": "xe-upload",
"displayName": "文件选择、文件上传组件(图片,视频,文件等)",
"version": "1.0.2",
"description": "H5、微信小程序、App端支持图片,视频,文件选择上传;其他端暂不支持文件选择上传",
"keywords": [
"App、H5、微信小程序、图片,视频,文件上传"
],
"repository": "",
"engines": {
},
"dcloudext": {
"type": "component-vue",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "u"
},
"App": {
"app-vue": "y",
"app-nvue": "u"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "u",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y",
"钉钉": "y",
"快手": "y",
"飞书": "y",
"京东": "y"
},
"快应用": {
"华为": "y",
"联盟": "y"
}
}
}
}
}
\ No newline at end of file
# xe-upload
## 说明
不占用页面位置的上传组件;
H5、APP、微信小程序中可上传图片,视频和文件;其他端暂时只能上传图片和视频
> 上传图片通过[chooseMedia](https://uniapp.dcloud.net.cn/api/media/video.html#choosemedia)及[chooseImage](https://uniapp.dcloud.net.cn/api/media/image.html#chooseimage)实现
> 上传视频通过[chooseMedia](https://uniapp.dcloud.net.cn/api/media/video.html#choosemedia)及[chooseVideo](https://uniapp.dcloud.net.cn/api/media/video.html#choosevideo)实现
> H5端上传文件通过[chooseFile](https://uniapp.dcloud.net.cn/api/media/file.html#wx-choosemessagefile)实现
> APP上传文件通过[renderjs](https://uniapp.dcloud.net.cn/tutorial/renderjs.html#renderjs)实现
> 微信小程序上传文件通过[chooseMessageFile](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseMessageFile.html)实现
## 使用
Attributes
| 参数 | 说明 | 类型 | 默认值 |
| ----------- | ----------- | ----------- | ----------- |
| options | 请求配置(参数与uni.uploadFile的参数一致) | object | { name: 'file' } |
Events
| 事件名 | 说明 | 参数 |
| ----------- | ----------- | ----------- |
| callback | 接收数据 | { type, data } |
callback type
| 参数 | 说明 |
| ----------- | ----------- |
| warning | 提示信息(下文称warning回调) |
| success | 上传成功(下文称success回调) |
| choose | 选择文件(下文称choose回调) |
callback data
```
'callback.type === success' : [
{
"size": 176579, // 选择的文件的大小
"name": "Kafka.pdf", // 选择的文件的名称(小程序端可能会没有)
"type": "application/pdf",
"tempFilePath": "blob:http://192.168.137.1:8080/2585769b-3195-4f3d-b9f8-d9e99f55deec", // 临时路路径
"fileType": "file", // 文件类型[image, video, file]
"response": {
"result": {
"fileName": "Kafka.pdf",
"filePath": `http://localhost:3000/upload/e51d814b649122fc64892d0bc6383d07.pdf`,
},
"success": true,
}, // 上传返回的信息
}
]
'callback.type === choose' : [
{
"size": 176579, // 选择的文件的大小
"name": "Kafka.pdf", // 选择的文件的名称(小程序端可能会没有)
"type": "application/pdf",
"tempFilePath": "blob:http://192.168.137.1:8080/4204e460-f185-4fc9-9f4d-1bc50ab06981", // 文件临时路径
"fileType": "file", // 文件类型[image, video, file]
}
]
```
## 注意事项
#### 1、options入参中如果url为空,则choose回调的data列表中只有选择文件能得到的信息和临时路径,临时路径可用于自定义上传方法(APP除外);传入url选择文件后会自动上传到服务器,此时choose回调不会触发,而是执行success回调,success回调的data列表会包括选择文件能得到的信息
#### 2、APP端文件建议直接上传到服务器,拿到文件上传后的地址再进行其他操作(目前测试APP端file转换后的Blob Url无法用于uni.uploadFile,所以建议APP文件直接上传)
#### 3、APP端文件暂时支持单个上传
#### 4、当uni.chooseMedia可用时,会优先使用uni.chooseMedia
#### 5、具体使用可下载示例项目运行查看完整示例
// eslint-disable
import { awaitWrap } from './tools';
/**
* 从本地相册选择图片或使用相机拍照
* @param {object} config 参数详情 => https://uniapp.dcloud.net.cn/api/media/image.html#chooseimage
* @returns
*/
export const chooseImage = (config) => {
return awaitWrap(
new Promise((r, j) => {
uni.chooseImage({
...config,
success: (res) => {
const tmpFiles = res?.tempFiles.map((e) => ({
tempFilePath: e.path,
tempFile: e,
size: e.size,
name: e.name,
type: e.type,
fileType: 'image',
}));
return r({ type: 'image', ...res, tempFiles: tmpFiles });
},
fail: (err) => j({ mode: 'chooseImage', data: err }),
});
})
);
};
/**
* 拍摄视频或从手机相册中选视频,返回视频的临时文件路径
* @param {object} config 参数详情 => https://uniapp.dcloud.net.cn/api/media/video.html#choosevideo
* @returns
*/
export const chooseVideo = (config) => {
return awaitWrap(
new Promise((r, j) => {
uni.chooseVideo({
...config,
success: (res) => {
const tmpFiles = [{
...res,
tempFilePath: res.tempFilePath,
tempFile: res.tempFile ?? {},
size: res.size,
name: res.name,
type: res.tempFile?.type,
fileType: 'video',
}];
return r({ type: 'video', tempFiles: tmpFiles });
},
fail: (err) => j({ mode: 'chooseVideo', data: err }),
});
})
);
};
/**
* 拍摄或从手机相册中选择图片或视频
* @param {object} config 参数详情 => https://uniapp.dcloud.net.cn/api/media/video.html#choosemedia
* @returns
*/
export const chooseMedia = (type, config) => {
if (!type) return console.error('chooseMedia type cannot be empty');
if (!uni.chooseMedia && type === 'image') return chooseImage(config);
if (!uni.chooseMedia && type === 'video') return chooseVideo(config);
return awaitWrap(
new Promise((r, j) => {
uni.chooseMedia({
...config,
mediaType: [type],
success: (res) => r(res),
fail: (err) => j({ mode: 'chooseMedia', data: err }),
});
})
);
};
/**
* 从本地选择文件(h5)
* @param {object} config 参数详情 => https://uniapp.dcloud.net.cn/api/media/file.html#wx-choosemessagefile
* @returns
*/
export const chooseFile = (config) => {
return awaitWrap(
new Promise((r, j) => {
uni.chooseFile({
...config,
success: (res) => {
const tmpFiles = res?.tempFiles.map((e) => {
let tmpType = 'file';
if (e.type.includes('image')) {
tmpType = 'image';
}
if (e.type.includes('video')) {
tmpType = 'video';
}
return {
tempFilePath: e.path,
tempFile: e,
size: e.size,
name: e.name,
type: e.type,
fileType: tmpType,
};
});
return r({ type: 'file', ...res, tempFiles: tmpFiles });
},
fail: (err) => j({ mode: 'chooseFile', data: err }),
});
})
);
};
/**
* 从本地选择文件(微信小程序)
* @param {object} config 参数详情 => https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseMessageFile.html
* @returns
*/
export const chooseMessageFile = (config) => {
return awaitWrap(
new Promise((r, j) => {
wx.chooseMessageFile({
...config,
success: (res) => {
const tmpFiles = res?.tempFiles.map((e) => ({
...e,
tempFilePath: e.path,
fileType: e.type ?? 'file',
}));
return r({ type: 'file', ...res, tempFiles: tmpFiles });
},
fail: (err) => j({ mode: 'chooseMessageFile', data: err }),
});
})
);
};
/**
* 上传
* @param {object} config 参数详情 => https://uniapp.dcloud.net.cn/api/request/network-file.html#uploadfile
* @param {object} exts 选择的文件的数据
* @returns {object} exts + response
*/
export const uploadFile = (config, exts = {}) => {
return new Promise((r, j) => {
uni.uploadFile({
...config,
success: (res) => r({ ...exts, response: JSON.parse(res.data) }),
fail: (err) => j({ mode: 'uploadFile', data: err }),
});
});
};
export const appUploadFile = (config, exts = {}, onprogress) => {
const { url, header, formData } = config;
return new Promise((r, j) => {
const xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
for (let key in header) {
xhr.setRequestHeader(key, header[key]);
}
if (onprogress) {
xhr.upload.onprogress = onprogress;
}
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
r({ ...exts, response: JSON.parse(xhr.responseText) });
} else {
j({ mode: 'uploadFile', data: { data: xhr.responseText, errMsg: 'uploadFile fail.' } });
}
}
}
xhr.send(formData);
});
};
// eslint-disable
export const isObject = (obj) => {
return obj
? Object.prototype.toString.call(obj) === "[object Object]"
: false;
};
export const isArray = (arr) => {
return arr ? Array.isArray(arr) : false;
};
/**
* handle async await
* @param {*} promise promise
*/
export const awaitWrap = (promise) =>
promise.then((res) => [null, res]).catch((err) => [err, {}]);
/**
* 深拷贝
* @param {*} source
*/
export const deepClone = (source) => {
if (!isObject(source) && !isArray(source)) return source;
const targetObj = isArray(source) ? [] : {}; // 判断复制的目标是数组还是对象
for (let keys in source) {
// 遍历目标
if (source.hasOwnProperty(keys)) {
if (source[keys] && typeof source[keys] === "object") {
// 如果值是对象,就递归一下
targetObj[keys] = isArray(source[keys]) ? [] : {};
targetObj[keys] = deepClone(source[keys]);
} else {
// 如果不是,就直接赋值
targetObj[keys] = source[keys];
}
}
}
return targetObj;
};
/**
* @description JS对象深度合并
* @param {object} target 需要拷贝的对象
* @param {object} source 拷贝的来源对象
* @returns {object|boolean} 深度合并后的对象或者false(入参有不是对象)
*/
export const deepMerge = (target = {}, source = {}) => {
target = deepClone(target);
if (typeof target !== "object" || typeof source !== "object") return false;
for (const prop in source) {
if (!source.hasOwnProperty(prop)) continue;
if (prop in target) {
if (typeof target[prop] !== "object") {
target[prop] = source[prop];
} else if (typeof source[prop] !== "object") {
target[prop] = source[prop];
} else if (target[prop].concat && source[prop].concat) {
target[prop] = target[prop].concat(source[prop]);
} else {
target[prop] = deepMerge(target[prop], source[prop]);
}
} else {
target[prop] = source[prop];
}
}
return target;
};
/**
* 将File对象转为 Blob Url
* @param {File} File对象
* @returns Blob Url
*/
export const fileToBlob = (file) => {
if (!file) return;
const fileType = file.type;
const blob = new Blob([file], { type: fileType || 'application/*' });
const blobUrl = window.URL.createObjectURL(blob);
return blobUrl;
};
/**
* 将File对象转为 base64
* @param {File} File对象
* @returns base64
*/
export const fileToBase64 = (file) => {
if (!file) return;
return new Promise((r, j) => {
const reader = new FileReader();
reader.onloadend = () => {
const base64String = reader.result;
r(base64String);
};
reader.onerror = () => {
j({ mode: 'fileToBase64', data: { errMsg: 'File to base64 fail.' } });
};
reader.readAsDataURL(file);
});
};
/**
* base64转临时路径(改自https://github.com/zhetengbiji/image-tools/blob/master/index.js)
* @param base64
* @returns
*/
function dataUrlToBase64(str) {
var array = str.split(',');
return array[array.length - 1];
};
function biggerThan(v1, v2) {
var v1Array = v1.split('.');
var v2Array = v2.split('.');
var update = false;
for (var index = 0; index < v2Array.length; index++) {
var diff = v1Array[index] - v2Array[index];
if (diff !== 0) {
update = diff > 0;
break;
}
}
return update;
};
var index = 0;
function getNewFileId() {
return Date.now() + String(index++);
};
export const base64ToPath = (base64, name = '') => {
return new Promise((r, j) => {
if (typeof plus !== 'object') {
return j(new Error('not support'));
}
var fileName = '';
if (name) {
const names = name.split('.');
const extName = names.splice(-1);
fileName = `${names.join('.')}-${getNewFileId()}.${extName}`;
} else {
const names = base64.split(',')[0].match(/data\:\S+\/(\S+);/);
if (!names) {
j(new Error('base64 error'));
}
const extName = names[1];
fileName = `${getNewFileId()}.${extName}`;
}
var basePath = '_doc';
var dirPath = 'uniapp_temp';
var filePath = `${basePath}/${dirPath}/${fileName}`;
if (!biggerThan(plus.os.name === 'Android' ? '1.9.9.80627' : '1.9.9.80472', plus.runtime.innerVersion)) {
plus.io.resolveLocalFileSystemURL(basePath, function (entry) {
entry.getDirectory(dirPath, {
create: true,
exclusive: false,
}, function (entry) {
entry.getFile(fileName, {
create: true,
exclusive: false,
}, function (entry) {
entry.createWriter(function (writer) {
writer.onwrite = function () {
r(filePath);
}
writer.onerror = j;
writer.seek(0);
writer.writeAsBinary(dataUrlToBase64(base64));
}, j)
}, j)
}, j)
}, j)
return;
}
var bitmap = new plus.nativeObj.Bitmap(fileName);
bitmap.loadBase64Data(base64, function () {
bitmap.save(filePath, {}, function () {
bitmap.clear();
r(filePath);
}, function (error) {
bitmap.clear();
j(error);
});
}, function (error) {
bitmap.clear();
j(error);
});
});
};
......@@ -3,7 +3,7 @@
## 一、页面路径
### 1. 我的课程页面
**路径**: `pages/boutique/myCourse.vue`
**路径**: `pages/common/studyCenter/myCourse.vue`
**使用的组件**:
- `components/HomeFrame/components/Study/RecommendCourse.vue` - 待学习 Tab
......@@ -13,7 +13,7 @@
---
### 2. 我的考试页面
**路径**: `pages/boutique/myExam.vue`
**路径**: `pages/common/studyCenter/myExam.vue`
**使用的组件**:
- `components/HomeFrame/components/Study/PassedExam.vue` - 已通过 Tab
......@@ -22,7 +22,7 @@
---
### 3. 我的任务页面
**路径**: `pages/boutique/myTask.vue`
**路径**: `pages/common/studyCenter/myTask.vue`
**使用的组件**:
- `components/HomeFrame/components/Study/LearnStatistics.vue` - 累计学习统计
......@@ -34,7 +34,7 @@
---
### 4. 排行榜页面
**路径**: `pages/boutique/leaderboard.vue`
**路径**: `pages/common/studyCenter/leaderboard.vue`
**使用的图片资源**:
- `assets/images/studyCenter/Leaderboard-bg.png` - 顶部占位图
......@@ -163,19 +163,19 @@
### pages.json
```json
{
"path": "pages/boutique/myTask",
"path": "pages/common/studyCenter/myTask",
"style": { "navigationStyle": "custom" }
},
{
"path": "pages/boutique/myCourse",
"path": "pages/common/studyCenter/myCourse",
"style": { "navigationStyle": "custom" }
},
{
"path": "pages/boutique/myExam",
"path": "pages/common/studyCenter/myExam",
"style": { "navigationStyle": "custom" }
},
{
"path": "pages/boutique/leaderboard",
"path": "pages/common/studyCenter/leaderboard",
"style": { "navigationStyle": "custom" }
}
```
......@@ -186,10 +186,10 @@
| 功能 | 跳转方法 | 页面路径 | 所在文件 |
|-----|---------|---------|---------|
| 我的课程 | `goToMyCourse()` | `/pages/boutique/myCourse` | StudyCenter.vue |
| 我的任务 | `goToMyTask()` | `/pages/boutique/myTask` | StudyCenter.vue |
| 我的考试 | `goToMyExam()` | `/pages/boutique/myExam` | StudyCenter.vue |
| 排行榜 | `goToLeaderboard()` | `/pages/boutique/leaderboard` | StudyCenter.vue |
| 我的课程 | `goToMyCourse()` | `/pages/common/studyCenter/myCourse` | StudyCenter.vue |
| 我的任务 | `goToMyTask()` | `/pages/common/studyCenter/myTask` | StudyCenter.vue |
| 我的考试 | `goToMyExam()` | `/pages/common/studyCenter/myExam` | StudyCenter.vue |
| 排行榜 | `goToLeaderboard()` | `/pages/common/studyCenter/leaderboard` | StudyCenter.vue |
---
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!