Commit 34c2de92 by 胡悦

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

2 parents 20f64848 177a53bf
import http from '../request/http'
module.exports = {}
...@@ -46,7 +46,7 @@ module.exports = { ...@@ -46,7 +46,7 @@ module.exports = {
/** /**
* 订单详情 * 订单详情
*/ */
getOrderDetail(data) { getOrderDetail (data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.order.detail', method: 'dj.api.smartcarlife.order.detail',
projectName: 'boutique', projectName: 'boutique',
...@@ -54,16 +54,27 @@ module.exports = { ...@@ -54,16 +54,27 @@ module.exports = {
}) })
}, },
/**pos支付 */ /**pos支付 */
getPosQr(data) { getPosQr (data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.payOrder.create', method: 'dj.api.smartcarlife.payOrder.create',
projectName: 'boutique', projectName: 'boutique',
...data ...data
}) })
}, },
/**
* 查询门店录单设置
},
*/
orderSettingList (data) {
return http.post({
method: 'dj.api.smartcarlife.order.field.setting.list',
projectName: 'boutique',
...data
})
},
/** 报价单分页列表 */ /** 报价单分页列表 */
quotationPage(data) { quotationPage (data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.page', method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.page',
projectName: 'boutique', projectName: 'boutique',
...@@ -71,7 +82,7 @@ module.exports = { ...@@ -71,7 +82,7 @@ module.exports = {
}) })
}, },
/** 根据id查询报价单数据 */ /** 根据id查询报价单数据 */
getQuotationInfo(data) { getQuotationInfo (data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.generate', method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.generate',
projectName: 'boutique', projectName: 'boutique',
...@@ -79,7 +90,7 @@ module.exports = { ...@@ -79,7 +90,7 @@ module.exports = {
}) })
}, },
/** 修改车损报价单客户基本信息信息 */ /** 修改车损报价单客户基本信息信息 */
updateCustomerInfo(data) { updateCustomerInfo (data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.customer.base.info.update', method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.customer.base.info.update',
projectName: 'boutique', projectName: 'boutique',
...@@ -88,7 +99,7 @@ module.exports = { ...@@ -88,7 +99,7 @@ module.exports = {
}, },
/** 报价单订单分状态统计信息 */ /** 报价单订单分状态统计信息 */
orderStatistics(data) { orderStatistics (data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.order.status.statistics', method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.order.status.statistics',
projectName: 'boutique', projectName: 'boutique',
...@@ -96,7 +107,7 @@ module.exports = { ...@@ -96,7 +107,7 @@ module.exports = {
}) })
}, },
// 查询订单是否支持状态变更 // 查询订单是否支持状态变更
getOrderRefundStep(data) { getOrderRefundStep (data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.refundApplyRecord.isExist', method: 'dj.api.smartcarlife.refundApplyRecord.isExist',
projectName: 'boutique', projectName: 'boutique',
...@@ -104,11 +115,27 @@ module.exports = { ...@@ -104,11 +115,27 @@ module.exports = {
}) })
}, },
/**报价单-撤销工单 */ /**报价单-撤销工单 */
cancelOrderById(data) { cancelOrderById (data) {
return http.post({ return http.post({
method: 'dj.api.smartcarlife.quotation.cancel', method: 'dj.api.smartcarlife.quotation.cancel',
projectName: 'boutique', projectName: 'boutique',
...data ...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
})
} }
} }
import sign from './sign.js' import sign from './sign.js'
import { secretKey, pathEnum, domain, djDomain, merchantDomain, djSecretKey } from '../../env' import { secretKey, pathEnum, domain, djDomain, merchantDomain, djSecretKey } from '../../env'
const HOST = { const HOST = {
scrm: domain, scrm: domain,
dj: djDomain, dj: djDomain,
......

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
...@@ -38,8 +38,13 @@ export default { ...@@ -38,8 +38,13 @@ export default {
] ]
this.updateParams(params, data) this.updateParams(params, data)
}, },
initData (data) { initData (list) {
this.list = data const { params:{idKey}, data } = this
if(data[idKey]) {
this.currentId = data[idKey]
this.$emit('choose', data[idKey])
}
this.list = list
this.$emit('onComplete') this.$emit('onComplete')
}, },
handleSearch (searchValue) { handleSearch (searchValue) {
......
...@@ -88,7 +88,7 @@ export default { ...@@ -88,7 +88,7 @@ export default {
this.updateParams(params, data || []) this.updateParams(params, data || [])
}, },
initData (carData) { initData (carData) {
let { params: { idKey }, data: { customer } } = this, let { params: { idKey }, data: { customer, carInfo }, sceneType } = this,
letterList = Array.from(new Set([...carData.map((e) => e.letter)])), letterList = Array.from(new Set([...carData.map((e) => e.letter)])),
carModelList = letterList.map(e => { carModelList = letterList.map(e => {
let list = [] let list = []
...@@ -100,10 +100,21 @@ export default { ...@@ -100,10 +100,21 @@ export default {
c.childs.map((s) => { c.childs.map((s) => {
s.carChildsBrandId = c.id; s.carChildsBrandId = c.id;
s.carChildsBrandName = c.name; s.carChildsBrandName = c.name;
if (sceneType == 1) {
if (customer && customer[idKey]) { if (customer && customer[idKey]) {
if (s.id == customer[idKey]) { if (s.id == customer[idKey]) {
s.active = true; s.active = true;
this.letter = i.letter; this.letter = i.letter;
this.choose(s, c)
}
}
} else {
if (carInfo && carInfo[idKey]) {
if (s.id == carInfo[idKey]) {
s.active = true;
this.letter = i.letter;
this.choose(s, c)
}
} }
} }
}); });
......
...@@ -153,11 +153,15 @@ export default { ...@@ -153,11 +153,15 @@ export default {
this.updateParams(params, province) this.updateParams(params, province)
}, },
initData (listData) { initData (listData) {
let {data, params:{idKeys}} = this, let { data, params: { idKeys } } = this,
[provinceKey, cityKey] = idKeys [provinceKey, cityKey] = idKeys
if(data[cityKey]){ if (data[cityKey]) {
this.currentIds = [data[provinceKey], data[cityKey]] this.currentIds = [data[provinceKey], data[cityKey]]
this.currentStep = 2 this.currentStep = 2
this.$emit('choose', {
province: data[provinceKey],
city: data[cityKey]
})
} }
this.list = listData this.list = listData
this.$emit('onComplete') this.$emit('onComplete')
......
...@@ -90,12 +90,12 @@ export default { ...@@ -90,12 +90,12 @@ export default {
}) })
this.updateParams(params, data || []) this.updateParams(params, data || [])
}, },
initData (data) { initData (dataList) {
let couponTypeList = Array.from(new Set([...data.map((e) => e.couponInfo.couponType)])), let couponTypeList = Array.from(new Set([...dataList.map((e) => e.couponInfo.couponType)])),
couponList = couponTypeList.map((e, index) => { couponList = couponTypeList.map((e, index) => {
let list = []; let list = [];
let title = ""; let title = "";
data.map((i) => { dataList.map((i) => {
i.merchantCouponCode = i.merchantCouponCode.split("-")[0]; i.merchantCouponCode = i.merchantCouponCode.split("-")[0];
if (i.couponInfo.couponType == e) { if (i.couponInfo.couponType == e) {
list.push(i); list.push(i);
...@@ -107,12 +107,30 @@ export default { ...@@ -107,12 +107,30 @@ export default {
list, list,
}; };
}) })
const { params: { idKey }, data, customerCouponList } = this
this.$emit('onComplete') this.$emit('onComplete')
this.list = couponList this.list = couponList
if (data[idKey]) {
this.currentId = data[idKey]
let item = null,
isCustomer = false
couponList.map(e => {
e.list.map(i => {
if (i.merchantCouponCode == data[idKey]) item = i
})
})
customerCouponList.map(i => {
if (i.customerCouponCode == data[idKey]) {
item = i
isCustomer = true
}
})
if (item) this.choose(item, isCustomer)
}
}, },
async getCustomerCouponList (customerPhone) { async getCustomerCouponList (customerPhone) {
const phoneRex = /^[1]([3-9])[0-9]{9}$/, const phoneRex = /^[1]([3-9])[0-9]{9}$/,
{ data: orderObj } = this, { data: orderObj, params: { idKey } } = this,
params = { params = {
customerPhone, customerPhone,
statusList: [0, 1], statusList: [0, 1],
...@@ -126,7 +144,7 @@ export default { ...@@ -126,7 +144,7 @@ export default {
(item.status == 1 && item.id == orderObj.customerCouponId) (item.status == 1 && item.id == orderObj.customerCouponId)
); );
}) })
if(this.customerCouponList.length) this.choose(this.customerCouponList[0],true) if (this.customerCouponList.length && !orderObj[idKey]) this.choose(this.customerCouponList[0], true, true)
} }
}, },
handleSearch (searchValue) { handleSearch (searchValue) {
...@@ -155,7 +173,7 @@ export default { ...@@ -155,7 +173,7 @@ export default {
this.searchStatus = true this.searchStatus = true
} }
}, },
choose (item, isCustomer = false) { choose (item, isCustomer = false, autoSelect = false) {
if (item.disabled) return if (item.disabled) return
let customerCouponCode = isCustomer ? item.customerCouponCode : item.merchantCouponCode, let customerCouponCode = isCustomer ? item.customerCouponCode : item.merchantCouponCode,
key = isCustomer ? 'customerCouponId' : 'merchantCouponId', key = isCustomer ? 'customerCouponId' : 'merchantCouponId',
...@@ -167,6 +185,7 @@ export default { ...@@ -167,6 +185,7 @@ export default {
} }
this.currentId = customerCouponCode this.currentId = customerCouponCode
this.$emit('choose', chooseItem) this.$emit('choose', chooseItem)
if (autoSelect) this.$emit('confirm', true)
}, },
checkDisabled (item) { checkDisabled (item) {
let disabled = false, let disabled = false,
......
...@@ -53,8 +53,14 @@ export default { ...@@ -53,8 +53,14 @@ export default {
const { list } = await uni.$api.popupApi.getQuotationCustomerList(apiParams) const { list } = await uni.$api.popupApi.getQuotationCustomerList(apiParams)
this.updateParams(params, list || []) this.updateParams(params, list || [])
}, },
initData (data) { initData (list) {
this.list = data const { params: { idKey }, data } = this
if (data[idKey]) {
this.currentId = data[idKey]
let item = list.find(i => i.customerPhone == this.currentId)
this.$emit('choose', item)
}
this.list = list
this.$emit('onComplete') this.$emit('onComplete')
}, },
handleSearch (searchValue) { handleSearch (searchValue) {
......
...@@ -38,8 +38,14 @@ export default { ...@@ -38,8 +38,14 @@ export default {
}) })
this.updateParams(params, data || []) this.updateParams(params, data || [])
}, },
initData (data) { initData (list) {
this.list = data const { params: { idKey }, data } = this
if (data[idKey]) {
this.currentId = data[idKey]
let item = list.find(i => i.subMerchantId == this.currentId)
this.$emit('choose', item)
}
this.list = list
this.$emit('onComplete') this.$emit('onComplete')
}, },
choose (i) { choose (i) {
......
...@@ -26,14 +26,14 @@ export default { ...@@ -26,14 +26,14 @@ export default {
computed: { computed: {
idKey () { idKey () {
let { params: { idKey }, sceneType } = this let { params: { idKey }, sceneType } = this
return idKey[sceneType] || idKey
return Array.isArray(idKey) ? idKey[sceneType] : idKey
} }
}, },
mounted () { mounted () {
}, },
methods: { methods: {
async getList (searchValue, search) { async getList (searchValue, search) {
const { userInfo, params } = this, const { userInfo, params } = this,
{ cacheData } = params { cacheData } = params
this.currentId = '' this.currentId = ''
...@@ -52,8 +52,15 @@ export default { ...@@ -52,8 +52,15 @@ export default {
const data = await uni.$api.popupApi[apiTargetName](apiParams) const data = await uni.$api.popupApi[apiTargetName](apiParams)
this.updateParams(params, data || []) this.updateParams(params, data || [])
}, },
initData (data) { initData (list) {
this.list = data const { idKey, data } = this
console.log(idKey)
if (data[idKey]) {
this.currentId = data[idKey]
let item = list.find(i => i.uuid == this.currentId)
this.$emit('choose', item)
}
this.list = list
this.$emit('onComplete') this.$emit('onComplete')
}, },
handleSearch (searchValue) { handleSearch (searchValue) {
......
...@@ -121,8 +121,8 @@ export default { ...@@ -121,8 +121,8 @@ export default {
} }
}, },
initData (goodsData) { initData (goodsData) {
let { data, dataKey, isDefeatOrder, baseConfigData, positionTypeList } = this, let { data, dataKey, isDefeatOrder, baseConfigData, positionTypeList, params } = this,
{ goodsType } = this.params, { goodsType } = params,
arr = [] arr = []
if (isDefeatOrder) { if (isDefeatOrder) {
let arrData = [] let arrData = []
...@@ -168,18 +168,31 @@ export default { ...@@ -168,18 +168,31 @@ export default {
if (goodsType.includes(subVal.merchantGoodsPosition)) arr.push(val) if (goodsType.includes(subVal.merchantGoodsPosition)) arr.push(val)
} }
}) })
}
let paramsData = dataKey ? data[dataKey] : data let paramsData = dataKey ? data[dataKey] : data
if (paramsData && paramsData.length) paramsData.map(e => { if (paramsData && paramsData.length) {
this.currentIds.push(e.goods.goodsId) // let idName = isDefeatOrder ? 'id' : 'goodsId'
this.chooseList.push(e) // paramsData.map(e => {
// this.currentIds.push(e.goods[idName])
// this.chooseList.push(e)
// })
arr.map(i => {
console.log(i)
if (isDefeatOrder) i.upgradeGoodsList.map(e => {
paramsData.map(c => {
if (c.goods.id == e.id) this.choose(e)
})
})
else paramsData.map(c => {
if (i.goods.goodsId == c.goods.goodsId) this.choose(i)
})
}) })
} }
this.$emit('choose', this.chooseList)
this.$emit('onComplete') this.$emit('onComplete')
this.list = arr this.list = arr
}, },
choose (i) { choose (i) {
let { currentIds, isDefeatOrder } = this, let { currentIds, isDefeatOrder } = this,
id = '' id = ''
if (isDefeatOrder) id = i.id if (isDefeatOrder) id = i.id
......
...@@ -108,6 +108,7 @@ export default { ...@@ -108,6 +108,7 @@ export default {
this.currentIds.push(e.packageGoods.packageCode) this.currentIds.push(e.packageGoods.packageCode)
this.chooseList.push(e) this.chooseList.push(e)
}) })
this.$emit('choose', this.chooseList)
this.$emit('onComplete') this.$emit('onComplete')
this.list = arr this.list = arr
}, },
......
...@@ -40,8 +40,13 @@ export default { ...@@ -40,8 +40,13 @@ export default {
] ]
this.updateParams(params, data) this.updateParams(params, data)
}, },
initData (data) { initData (list) {
this.list = data const { params:{idKey}, data } = this
if(data[idKey]) {
this.currentId = data[idKey]
this.$emit('choose', data[idKey])
}
this.list = list
this.$emit('onComplete') this.$emit('onComplete')
}, },
handleSearch (searchValue) { handleSearch (searchValue) {
......
...@@ -317,6 +317,7 @@ export default { ...@@ -317,6 +317,7 @@ export default {
this.currentIds.push(id) this.currentIds.push(id)
this.chooseList.push(e) this.chooseList.push(e)
} }
this.$emit('choose', this.chooseList)
}) })
this.list = arr this.list = arr
this.$emit('onComplete') this.$emit('onComplete')
......
...@@ -184,12 +184,14 @@ const componentConfig = { ...@@ -184,12 +184,14 @@ const componentConfig = {
15: { 15: {
name: 'GoodsCategory', name: 'GoodsCategory',
title: '选择商品类目', title: '选择商品类目',
hideSearch: true, hideSearch: true,
loadComplete: false loadComplete: false
}, },
16: { 16: {
name: 'AgeRange', name: 'AgeRange',
title: '年龄区间', title: '年龄区间',
nullTips: '请选择年龄区间',
idKey: 'ageRange', idKey: 'ageRange',
hideSearch: true, hideSearch: true,
loadComplete: false loadComplete: false
...@@ -207,15 +209,17 @@ const componentConfig = { ...@@ -207,15 +209,17 @@ const componentConfig = {
18: { 18: {
name: 'Seat', name: 'Seat',
title: '座位数', title: '座位数',
nullTips: '请选择座位数',
idKey: 'seat', idKey: 'seat',
hideSearch: true, hideSearch: true,
loadComplete: false, loadComplete: false
}, },
19: { 19: {
name: 'Customer', name: 'Customer',
title: '客户档案', title: '客户档案',
loadComplete: false, loadComplete: false,
placeholder: '查找', placeholder: '查找',
nullTips: '请选择客户',
idKey: 'phone', idKey: 'phone',
cacheData: [], cacheData: [],
loadComplete: false, loadComplete: false,
......
<template> <template>
<view class="order-popup"> <view class="order-popup">
<popup :position="position" :animation="animation" ref="popup" @onConfirm="confirm" @onCancel="cancel" @onReset="reset" :showReset="popupType === 15"> <popup
:position="position"
:animation="animation"
ref="popup"
@onConfirm="confirm"
@onCancel="cancel"
@onReset="reset"
:showReset="popupType === 15"
>
<view class="popup-title flex"> <view class="popup-title flex">
{{ title }} {{ title }}
<view class="popup-close flex" @click="close"> <view
<uni-icons type="closeempty" size="16"></uni-icons> class="popup-close flex"
@click="close"
>
<uni-icons
type="closeempty"
size="16"
></uni-icons>
</view> </view>
</view> </view>
<template v-if="!componentObject[popupType].hideSearch"> <template v-if="!componentObject[popupType].hideSearch">
<view class="popup-search"> <view class="popup-search">
<input class="input" type="text" :placeholder="componentObject[popupType].placeholder || '请输入'" placeholder-class="placeholder" v-model="componentObject[popupType].searchValue" confirm-type="search" @confirm="handleSearch" /> <input
<view class="clear flex" @click="clear"> class="input"
<uni-icons type="closeempty" size="16" v-if="componentObject[popupType].searchValue"></uni-icons> type="text"
:placeholder="componentObject[popupType].placeholder || '请输入'"
placeholder-class="placeholder"
v-model="componentObject[popupType].searchValue"
confirm-type="search"
@confirm="handleSearch"
/>
<view
class="clear flex"
@click="clear"
>
<uni-icons
type="closeempty"
size="16"
v-if="componentObject[popupType].searchValue"
></uni-icons>
</view> </view>
</view> </view>
</template> </template>
<view :class="['popup-body', { 'hide-search': componentObject[popupType].hideSearch }]"> <view :class="['popup-body', { 'hide-search': componentObject[popupType].hideSearch }]">
<scroll-view scroll-y :class="['popup-scroll-view', { show: componentObject[popupType].loadComplete }]"> <scroll-view
<component :is="componentObject[popupType].name" :params.sync="componentObject[popupType]" :data="data" :dataKey="dataKey" :isDefeatOrder="isDefeatOrder" :defaultTime="defaultTime" :positionTypeList="positionTypeList" ref="componentRef" @choose="chooseContent = $event" @openSkuPopup="openSkuPopup" @onComplete="componentObject[popupType].loadComplete = true"></component> scroll-y
:class="['popup-scroll-view', { show: componentObject[popupType].loadComplete }]"
>
<component
:is="componentObject[popupType].name"
:params.sync="componentObject[popupType]"
:data="data"
:dataKey="dataKey"
:isDefeatOrder="isDefeatOrder"
:defaultTime="defaultTime"
:positionTypeList="positionTypeList"
ref="componentRef"
@choose="chooseContent = $event"
@openSkuPopup="openSkuPopup"
@onComplete="componentObject[popupType].loadComplete = true"
@confirm="confirm"
></component>
<template v-if="componentObject[popupType].noData"> <template v-if="componentObject[popupType].noData">
<view class="nothing flex">暂无数据</view> <view class="nothing flex">暂无数据</view>
</template> </template>
</scroll-view> </scroll-view>
<image v-if="!componentObject[popupType].loadComplete" class="loading" src="../../assets/images/common/loadding.gif" /> <image
v-if="!componentObject[popupType].loadComplete"
class="loading"
src="../../assets/images/common/loadding.gif"
/>
</view> </view>
</popup> </popup>
<sku-popup ref="skuPopupRef" @onConfirm="skuConfirm"></sku-popup> <sku-popup
ref="skuPopupRef"
@onConfirm="skuConfirm"
></sku-popup>
</view> </view>
</template> </template>
...@@ -66,7 +118,7 @@ export default { ...@@ -66,7 +118,7 @@ export default {
AgeRange, AgeRange,
City, City,
Seat, Seat,
Customer Customer,
}, },
name: '', name: '',
props: { props: {
...@@ -147,7 +199,7 @@ export default { ...@@ -147,7 +199,7 @@ export default {
baseConfigData () { baseConfigData () {
return this.$store.state.boutique.baseConfigData return this.$store.state.boutique.baseConfigData
}, },
sceneType(){ sceneType () {
const { sceneType } = uni.$storage.get('userInfo') const { sceneType } = uni.$storage.get('userInfo')
return sceneType return sceneType
} }
...@@ -171,6 +223,7 @@ export default { ...@@ -171,6 +223,7 @@ export default {
this.$emit('close') this.$emit('close')
}, },
initPopupData () { initPopupData () {
this.chooseContent = null
let componentRef = this.componentRef() let componentRef = this.componentRef()
if (!componentRef) setTimeout(this.initPopupData, .1e3) if (!componentRef) setTimeout(this.initPopupData, .1e3)
else componentRef.getList && componentRef.getList(this.componentObject[this.popupType].searchValue) else componentRef.getList && componentRef.getList(this.componentObject[this.popupType].searchValue)
...@@ -183,18 +236,18 @@ export default { ...@@ -183,18 +236,18 @@ export default {
}) })
else componentRef.handleSearch(this.componentObject[this.popupType].searchValue) else componentRef.handleSearch(this.componentObject[this.popupType].searchValue)
}, },
confirm () { confirm (autoClose) {
try { try {
let { chooseContent, popupType, componentObject } = this let { chooseContent, popupType, componentObject } = this
if (popupType == 13 ) { if (popupType == 13) {
chooseContent = this.componentRef().getResult() chooseContent = this.componentRef().getResult()
} }
if(popupType == 15 ) { if (popupType == 15) {
this.$emit('onConfirm', { this.$emit('onConfirm', {
chooseContent, chooseContent,
popupType popupType
}) })
this.$refs.popup.close() if (!autoClose) this.$refs.popup.close()
return return
} }
if (chooseContent) { if (chooseContent) {
...@@ -203,7 +256,7 @@ export default { ...@@ -203,7 +256,7 @@ export default {
chooseContent, chooseContent,
popupType popupType
}) })
this.$refs.popup.close() if (!autoClose) this.$refs.popup.close()
} else { } else {
if (componentObject[popupType].nullTips) throw componentObject[popupType].nullTips if (componentObject[popupType].nullTips) throw componentObject[popupType].nullTips
} }
...@@ -324,7 +377,7 @@ export default { ...@@ -324,7 +377,7 @@ export default {
} }
.hide-search { .hide-search {
height: calc(100% - #{toRpx(280)}); height: calc(100% - #{toRpx(280)});
.popup-scroll-view{ .popup-scroll-view {
padding-top: 0; padding-top: 0;
} }
} }
......
...@@ -62,7 +62,7 @@ export default { ...@@ -62,7 +62,7 @@ export default {
}, },
styleV2: { styleV2: {
type: Boolean, type: Boolean,
default: true default: false
} }
}, },
name: '', name: '',
......
...@@ -286,6 +286,13 @@ ...@@ -286,6 +286,13 @@
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
},
{
"path": "pages/common/filePreview",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": ""
}
} }
], ],
"globalStyle": { "globalStyle": {
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<view class="upload-box flex flex-wrap"> <view class="upload-box flex flex-wrap">
<view class="upload-item" @click.stop="selectImg"></view> <view class="upload-item" @click.stop="selectImg"></view>
<view v-for="(item, index) in payVoucherList" :key="index" class="previewImageList"> <view v-for="(item, index) in payVoucherList" :key="index" class="previewImageList">
<image :src="item"></image> <image :src="item" mode="aspectFill" @click="previewMedia(index)"></image>
<view class="close-box" @click="deleteImg(index)"> <view class="close-box" @click="deleteImg(index)">
<uni-icons class="icon-close" type="closeempty" color="#ffffff"></uni-icons> <uni-icons class="icon-close" type="closeempty" color="#ffffff"></uni-icons>
</view> </view>
...@@ -111,6 +111,13 @@ export default { ...@@ -111,6 +111,13 @@ export default {
uni.showToast({ title: '提交成功', icon: 'success' }) uni.showToast({ title: '提交成功', icon: 'success' })
this.$emit('jump', 'OrderDetail', data) this.$emit('jump', 'OrderDetail', data)
}) })
},
previewMedia(current){
const {payVoucherList} = this
uni.previewImage({
current,
urls: payVoucherList
})
} }
} }
} }
...@@ -119,6 +126,9 @@ export default { ...@@ -119,6 +126,9 @@ export default {
.px-48 { .px-48 {
padding: 0 toRpx(48); padding: 0 toRpx(48);
} }
.back {
height: 40rpx;
}
.upload-proof-of-payment { .upload-proof-of-payment {
width: 100%; width: 100%;
height: 100%; height: 100%;
...@@ -143,6 +153,7 @@ export default { ...@@ -143,6 +153,7 @@ export default {
} }
.uni-input { .uni-input {
text-align: right; text-align: right;
width: 80%;
.uni-input-placeholder { .uni-input-placeholder {
font-size: toRpx(28); font-size: toRpx(28);
font-weight: 400; font-weight: 400;
...@@ -162,9 +173,11 @@ export default { ...@@ -162,9 +173,11 @@ export default {
} }
} }
.upload-box { .upload-box {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: toRpx(20); gap: toRpx(20);
.upload-item { .upload-item {
width: toRpx(320) !important; width: 100%;
height: toRpx(240) !important; height: toRpx(240) !important;
border-radius: toRpx(12); border-radius: toRpx(12);
background: url('@/assets/images/boutique/uploadImage.png') no-repeat; background: url('@/assets/images/boutique/uploadImage.png') no-repeat;
...@@ -172,9 +185,10 @@ export default { ...@@ -172,9 +185,10 @@ export default {
} }
.previewImageList { .previewImageList {
position: relative; position: relative;
image {
width: toRpx(320) !important;
height: toRpx(240) !important; height: toRpx(240) !important;
image {
width: 100% !important;
height: 100% !important;
border-radius: toRpx(12); border-radius: toRpx(12);
} }
.close-box { .close-box {
......
<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>
...@@ -175,7 +175,8 @@ export default { ...@@ -175,7 +175,8 @@ export default {
seat: '5',//座位数 seat: '5',//座位数
ownerGender: '男', ownerGender: '男',
salesType: '0', salesType: '0',
carInfo: {} carInfo: {},
price: ''
}, // 弹窗传入的数据}, }, // 弹窗传入的数据},
popupType: 0, popupType: 0,
popupTypeEnum, popupTypeEnum,
...@@ -210,6 +211,7 @@ export default { ...@@ -210,6 +211,7 @@ export default {
mounted () { mounted () {
this.baseConfigData = uni.$storage.get('mock_data') || {} this.baseConfigData = uni.$storage.get('mock_data') || {}
this.initData() this.initData()
}, },
methods: { methods: {
initData () { initData () {
...@@ -220,6 +222,33 @@ export default { ...@@ -220,6 +222,33 @@ export default {
this.getConfig() this.getConfig()
this.getSelectOrderGoodsList() this.getSelectOrderGoodsList()
this.getShopMerchantPointConfig() this.getShopMerchantPointConfig()
this.orderSettingList()
},
async orderSettingList () {
const { shopMerchantId } = this.userInfo,
params = {
scene: 0,
isRequired: 1,
merchantId: shopMerchantId
},
data = await uni.$api.equityApi.orderSettingList(params)
if (data) {
let required = data.reduce((pre, item) => {
if (item.isRequired) {
pre.push(item.fieldKey)
}
return pre
}, [])
if (required.includes('carBrand')) this.formList[2].map(e => {
if (e.value == 'carBrandText') e.required = true
})
if (required.includes('carNo')) this.formList[2].map(e => {
if (e.value == 'carVin') e.required = true
})
if (required.includes('idNumber')) this.formList[1].map(e => {
if (e.value == 'certificateNo') e.required = true
})
}
}, },
async getShopMerchantPointConfig () { async getShopMerchantPointConfig () {
const { shopMerchantId: merchantId } = this.userInfo, const { shopMerchantId: merchantId } = this.userInfo,
...@@ -325,6 +354,10 @@ export default { ...@@ -325,6 +354,10 @@ export default {
// 输入框失去焦点事件 // 输入框失去焦点事件
inputBlur (e, val) { inputBlur (e, val) {
console.log(e, val) console.log(e, val)
if (val.value == 'price') {
this.orderObj[val.value] = parseFloat(this.orderObj[val.value]) > 2000000 ? 2000000 : this.orderObj[val.value]
return
}
this.orderObj[val.value] = this.orderObj[val.value] this.orderObj[val.value] = this.orderObj[val.value]
}, },
// 校验必填等规则 // 校验必填等规则
...@@ -817,7 +850,7 @@ export default { ...@@ -817,7 +850,7 @@ export default {
} }
orderObj.city = city orderObj.city = city
} }
if (orderObj.carPrice) owner.price = NP.times(customerInfo.carPrice, 0.01) if (customerInfo.carPrice) orderObj.price = customerInfo.carPrice
if (customerInfo.salesUuid) { if (customerInfo.salesUuid) {
orderObj.referrerId = customerInfo.salesUuid orderObj.referrerId = customerInfo.salesUuid
orderObj.referrer = customerInfo.salesName orderObj.referrer = customerInfo.salesName
......
...@@ -117,6 +117,7 @@ ...@@ -117,6 +117,7 @@
</view> </view>
</view> </view>
<NoticePopup ref="notice" title="提示" text="是否撤销该笔客户工单,撤销后客户工单为「已撤销」状态,不再统计订单数和订单金额。" type="warning"></NoticePopup> <NoticePopup ref="notice" title="提示" text="是否撤销该笔客户工单,撤销后客户工单为「已撤销」状态,不再统计订单数和订单金额。" type="warning"></NoticePopup>
<ContractPopup ref="contractPopupRef" @onConfirm="onConfirm"></ContractPopup>
</view> </view>
</template> </template>
<script> <script>
...@@ -126,6 +127,7 @@ import utils from '@/utils/utils' ...@@ -126,6 +127,7 @@ import utils from '@/utils/utils'
import { checkDailyReport, showNextModal } from '@/utils/modalUtils' import { checkDailyReport, showNextModal } from '@/utils/modalUtils'
import PublishPopup from '@/components/PublishPopup.vue' import PublishPopup from '@/components/PublishPopup.vue'
import NoticePopup from '@/components/NoticePopup.vue' import NoticePopup from '@/components/NoticePopup.vue'
import ContractPopup from './ContractPopup.vue'
export default { export default {
mixins: [interceptionMixin], mixins: [interceptionMixin],
name: 'OrderCard', name: 'OrderCard',
...@@ -137,7 +139,8 @@ export default { ...@@ -137,7 +139,8 @@ export default {
}, },
components: { components: {
PublishPopup, PublishPopup,
NoticePopup NoticePopup,
ContractPopup
}, },
computed: { computed: {
payType() { payType() {
...@@ -384,7 +387,7 @@ export default { ...@@ -384,7 +387,7 @@ export default {
this.localUserInfo = uni.$storage.get('userInfo') this.localUserInfo = uni.$storage.get('userInfo')
this.isOrder = !(this.localUserInfo?.isSuper || this.localUserInfo?.loginRole == 3 || this.localUserInfo.loginRole == 5 || this.localUserInfo?.loginRole == 6) this.isOrder = !(this.localUserInfo?.isSuper || this.localUserInfo?.loginRole == 3 || this.localUserInfo.loginRole == 5 || this.localUserInfo?.loginRole == 6)
}, },
methods: { _methods: {
copyText(e) { copyText(e) {
console.log(e) console.log(e)
uni.setClipboardData({ uni.setClipboardData({
...@@ -402,6 +405,7 @@ export default { ...@@ -402,6 +405,7 @@ export default {
switch (type) { switch (type) {
case 'upload': case 'upload':
// 处理上传协议 // 处理上传协议
this.uploadContract()
break break
case 'handle': case 'handle':
// 处理去处理 // 处理去处理
...@@ -462,6 +466,10 @@ export default { ...@@ -462,6 +466,10 @@ export default {
createorder() { createorder() {
this.$emit('jump', 'CreateOrder', { paramsData: this.orderCardDetail, type: 'CreateOrder' }) this.$emit('jump', 'CreateOrder', { paramsData: this.orderCardDetail, type: 'CreateOrder' })
}, },
//上传协议
uploadContract() {
this.$refs.contractPopupRef.open({})
},
showRefundAlert(type) { showRefundAlert(type) {
const text = type == 'error' ? '订单已发起退款,禁止标记为错误工单!如需标记错误请联系总部运营。' : '订单已发起退款,禁止撤销!如需撤销请联系总部运营。' const text = type == 'error' ? '订单已发起退款,禁止标记为错误工单!如需标记错误请联系总部运营。' : '订单已发起退款,禁止撤销!如需撤销请联系总部运营。'
uni.showModal({ uni.showModal({
...@@ -499,7 +507,62 @@ export default { ...@@ -499,7 +507,62 @@ export default {
uni.hideLoading() uni.hideLoading()
} }
}) })
},
onConfirm(val) {
console.log(val)
let urls = []
if (val && val.contractFiles && Array.isArray(val.contractFiles)) {
urls = val.contractFiles.map(file => file.url).filter(url => url)
}
console.log(urls)
uni.$api.equityApi
.getQuotationInfoById({
id: this.orderCardDetail?.id
})
.then(res => {
console.log(res, 'res')
let orderInfo = {}
let { default4SStoreInfo } = this.userInfo
orderInfo.check = true
orderInfo.id = res.id
orderInfo.orderId = res.orderId
orderInfo.merchantId4s = default4SStoreInfo?.merchantId
orderInfo.merchantName4s = default4SStoreInfo?.merchantName
orderInfo.referrer = res.referrer
orderInfo.referrerId = res.referrerId
console.log(orderInfo, 'orderInfo')
uni.showLoading({
mask: true
})
uni.$api.equityApi
.updateCustomerInfo({
...orderInfo,
zyPayUrl: urls.join(',')
})
.then(result => {
console.log(result, 'resultresult')
this.$refs.contractPopupRef.close()
uni.hideLoading()
setTimeout(() => {
this.$emit('refresh')
// _this.getList();
}, 500)
})
.catch(err => {
console.log(err)
uni.hideLoading()
})
})
.catch(err => {
uni.hideLoading()
})
} }
},
get methods() {
return this._methods
},
set methods(value) {
this._methods = value
} }
} }
</script> </script>
...@@ -843,7 +906,7 @@ export default { ...@@ -843,7 +906,7 @@ export default {
font-size: toRpx(24); font-size: toRpx(24);
width: 100%; width: 100%;
height: toRpx(56); height: toRpx(56);
border-radius: 12px; border-radius: toRpx(8);
opacity: 1; opacity: 1;
background: #fef5ea; background: #fef5ea;
margin: toRpx(16) 0; margin: toRpx(16) 0;
......
...@@ -71,7 +71,12 @@ export default { ...@@ -71,7 +71,12 @@ export default {
async getQuotationInfoById (id) { async getQuotationInfoById (id) {
const data = await uni.$api.equityApi.getQuotationInfoById({ id }) const data = await uni.$api.equityApi.getQuotationInfoById({ id })
this.orderInfo = data this.orderInfo = data
this.zyVoucherStatus = data.zyVoucherStatus const params = {
goodsIds: data?.vdQuotationGoodsList?.map(v => v.goodsId),
merchantId: data.merchantId4s
}
const res = await uni.$api.equityApi.checkZyPayFlag(params)
this.zyVoucherStatus = res ? 1 : 0
if (data.payType == 1) this.createWxQrcode() if (data.payType == 1) this.createWxQrcode()
if (data.payType == 3) this.createQrCodeImg() if (data.payType == 3) this.createQrCodeImg()
this.getOrderDetail() this.getOrderDetail()
...@@ -80,12 +85,15 @@ export default { ...@@ -80,12 +85,15 @@ export default {
async getOrderDetail () { async getOrderDetail () {
uni.hideLoading() uni.hideLoading()
if (!this.show) return if (!this.show) return
const { payId, id } = this.orderInfo, const { payId } = this.orderInfo
data = await uni.$api.equityApi.getOrderDetail({ orderCode: payId }) if (payId) {
const data = await uni.$api.equityApi.getOrderDetail({ orderCode: payId })
console.log(data,'----')
this.orderInfo.total_price = data.totalPrice this.orderInfo.total_price = data.totalPrice
let { payOrder, status } = data let { payOrder, status } = data
if (payOrder?.payStatus == 2 || status == 4) { if (payOrder?.payStatus == 2 || status == 4) {
uni.showToas({ this.closePopup()
uni.showToast({
title: '支付成功', title: '支付成功',
icon: 'none', icon: 'none',
mask: true mask: true
...@@ -94,12 +102,9 @@ export default { ...@@ -94,12 +102,9 @@ export default {
this.$emit('jumpSuccess', { payId }) this.$emit('jumpSuccess', { payId })
}, 1.5e3) }, 1.5e3)
} }
}
setTimeout(() => this.getOrderDetail(), 5e3) setTimeout(() => this.getOrderDetail(), 5e3)
}, },
clearTimer () {
if (this.time) clearInterval(this.time)
this.time = null
},
// 生成小程序码 // 生成小程序码
createWxQrcode () { createWxQrcode () {
let { zyVoucherStatus, orderInfo } = this, let { zyVoucherStatus, orderInfo } = this,
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
:key="index" :key="index"
class="previewImageList" class="previewImageList"
> >
<image :src="item"></image> <image :src="item" mode="aspectFill" @click="previewMedia(index)"></image>
<view <view
class="close-box" class="close-box"
@click="deleteImg(index)" @click="deleteImg(index)"
...@@ -132,6 +132,13 @@ export default { ...@@ -132,6 +132,13 @@ export default {
deleteImg (index) { deleteImg (index) {
this.payVoucherList.splice(index, 1) this.payVoucherList.splice(index, 1)
}, },
previewMedia(current){
const {payVoucherList} = this
uni.previewImage({
current,
urls: payVoucherList
})
}
} }
} }
</script> </script>
...@@ -187,10 +194,10 @@ export default { ...@@ -187,10 +194,10 @@ export default {
} }
.upload-box { .upload-box {
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(4, 1fr);
gap: toRpx(20); gap: toRpx(20);
.upload-item { .upload-item {
width: toRpx(320) !important; width: 100%;
height: toRpx(240) !important; height: toRpx(240) !important;
border-radius: toRpx(12); border-radius: toRpx(12);
background: url('@/assets/images/boutique/uploadImage.png') no-repeat; background: url('@/assets/images/boutique/uploadImage.png') no-repeat;
......
...@@ -80,7 +80,8 @@ const FORM_LIST = [ ...@@ -80,7 +80,8 @@ const FORM_LIST = [
label: '证件号码', label: '证件号码',
value: 'certificateNo', value: 'certificateNo',
maxlength: '18', maxlength: '18',
type: 'input' type: 'input',
required: false
}, },
{ {
label: '兴趣爱好', label: '兴趣爱好',
...@@ -101,7 +102,7 @@ const FORM_LIST = [ ...@@ -101,7 +102,7 @@ const FORM_LIST = [
value: 'carBrandText', value: 'carBrandText',
type: 'select', type: 'select',
key: 'carBrand', key: 'carBrand',
required: true required:false
}, },
{ {
label: '车辆颜色', label: '车辆颜色',
...@@ -114,7 +115,7 @@ const FORM_LIST = [ ...@@ -114,7 +115,7 @@ const FORM_LIST = [
value: 'carVin', value: 'carVin',
maxlength: '17', maxlength: '17',
type: 'input', type: 'input',
required: true required:false
}, },
{ {
label: '座位数', label: '座位数',
...@@ -216,7 +217,7 @@ const DEFEAT_FORM_LIST = [ ...@@ -216,7 +217,7 @@ const DEFEAT_FORM_LIST = [
label: '推荐人员', label: '推荐人员',
value: 'employeeName', value: 'employeeName',
type: 'select', type: 'select',
// key: 'staffName', key: 'employeeName',
required: true, required: true,
showText: 'shopMerchantName' showText: 'shopMerchantName'
} }
...@@ -255,8 +256,8 @@ const DEFEAT_FORM_LIST = [ ...@@ -255,8 +256,8 @@ const DEFEAT_FORM_LIST = [
required: true required: true
}, },
{ {
label: '车主拒升理由', label: '战败理由',
value: 'refusalReason', value: 'deafeatReason',
maxlength: '30', maxlength: '30',
type: 'textarea', type: 'textarea',
placeholder: '请输入 (30字以内)', placeholder: '请输入 (30字以内)',
...@@ -268,6 +269,8 @@ const DEFEAT_FORM_LIST = [ ...@@ -268,6 +269,8 @@ const DEFEAT_FORM_LIST = [
] ]
] ]
const defeat_titleList = [null, { addHtml: 'customer' }]
const payTypeList = [ const payTypeList = [
{ {
value: '1', value: '1',
...@@ -442,4 +445,4 @@ const UpdateOrderInfo = [ ...@@ -442,4 +445,4 @@ const UpdateOrderInfo = [
} }
] ]
] ]
export { FORM_LIST, popupTypeEnum, payTypeList, DEFEAT_FORM_LIST, titleList, UpdateOrderInfo } export { FORM_LIST, popupTypeEnum, payTypeList, DEFEAT_FORM_LIST, titleList, UpdateOrderInfo, defeat_titleList }
## 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 \ 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);
});
});
};
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!