Commit 4e2c201a by 胡悦

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

2 parents 12a71291 c05a3e90
Showing 59 changed files with 7517 additions and 782 deletions
......@@ -2,7 +2,7 @@ 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',
......@@ -10,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',
......@@ -18,7 +18,7 @@ module.exports = {
})
},
// 校验订单是否需要上传合同协议
checkZyPayFlag(data) {
checkZyPayFlag (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.zyPayUrl.check',
projectName: 'boutique',
......@@ -27,7 +27,7 @@ module.exports = {
},
// 查询店铺配置
getShopMerchantPointConfig(data) {
getShopMerchantPointConfig (data) {
return http.post({
method: 'dj.api.smartcarlife.shopMerchantPointConfig.get',
projectName: 'boutique',
......@@ -36,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',
......@@ -46,7 +46,7 @@ module.exports = {
/**
* 订单详情
*/
getOrderDetail(data) {
getOrderDetail (data) {
return http.post({
method: 'dj.api.smartcarlife.order.detail',
projectName: 'boutique',
......@@ -54,7 +54,7 @@ module.exports = {
})
},
/**pos支付 */
getPosQr(data) {
getPosQr (data) {
return http.post({
method: 'dj.api.smartcarlife.payOrder.create',
projectName: 'boutique',
......@@ -65,7 +65,7 @@ module.exports = {
* 查询门店录单设置
},
*/
orderSettingList(data) {
orderSettingList (data) {
return http.post({
method: 'dj.api.smartcarlife.order.field.setting.list',
projectName: 'boutique',
......@@ -74,7 +74,7 @@ module.exports = {
},
/** 报价单分页列表 */
quotationPage(data) {
quotationPage (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.page',
projectName: 'boutique',
......@@ -82,7 +82,7 @@ module.exports = {
})
},
/** 根据id查询报价单数据 */
getQuotationInfo(data) {
getQuotationInfo (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.generate',
projectName: 'boutique',
......@@ -90,7 +90,7 @@ module.exports = {
})
},
/** 修改车损报价单客户基本信息信息 */
updateCustomerInfo(data) {
updateCustomerInfo (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.customer.base.info.update',
projectName: 'boutique',
......@@ -99,7 +99,7 @@ module.exports = {
},
/** 报价单订单分状态统计信息 */
orderStatistics(data) {
orderStatistics (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.order.status.statistics',
projectName: 'boutique',
......@@ -107,7 +107,7 @@ module.exports = {
})
},
// 查询订单是否支持状态变更
getOrderRefundStep(data) {
getOrderRefundStep (data) {
return http.post({
method: 'dj.api.smartcarlife.refundApplyRecord.isExist',
projectName: 'boutique',
......@@ -115,7 +115,7 @@ module.exports = {
})
},
/**报价单-撤销工单 */
cancelOrderById(data) {
cancelOrderById (data) {
return http.post({
method: 'dj.api.smartcarlife.quotation.cancel',
projectName: 'boutique',
......@@ -123,7 +123,7 @@ module.exports = {
})
},
// 车损报价单战败订单创建
defeatOrderCreate(data) {
defeatOrderCreate (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.add.defeat.order',
projectName: 'boutique',
......@@ -131,7 +131,7 @@ module.exports = {
})
},
// 更新合同协议内容
updateZyInfo(data) {
updateZyInfo (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.zyPayUrl.update',
projectName: 'boutique',
......@@ -139,7 +139,7 @@ module.exports = {
})
},
/** 根据商户号商品id获取可选升级商品列表 */
quotationGoodsList(data) {
quotationGoodsList (data) {
return http.post({
method: 'dj.api.smartcarlife.quotationGoods.list',
projectName: 'boutique',
......@@ -148,14 +148,14 @@ module.exports = {
},
/**
* /** 修改车损报价单信息 */
updateQuotation(data) {
updateQuotation (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.update',
projectName: 'boutique',
...data
})
},
getCheckEmployeeList(data) {
getCheckEmployeeList (data) {
// 0->2.0 1->1.1 2->1.2 3->1.3 场景对应
// data.sceneList = [1]
return http.post({
......@@ -166,7 +166,7 @@ module.exports = {
// return api.post("dj.api.smartcarlife.employee.getByMerchantId", data);
},
/** 更新报价单状态 */
updateOrderStatus(data) {
updateOrderStatus (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.status.update',
projectName: 'boutique',
......@@ -178,7 +178,7 @@ module.exports = {
* 服务信息详情
*
*/
getServiceInfoDetail(data) {
getServiceInfoDetail (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.equityOrder.detail',
projectName: 'boutique',
......@@ -186,7 +186,7 @@ module.exports = {
})
},
/** 权益单分页列表 */
equityPage(data) {
equityPage (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.equityOrder.page',
projectName: 'boutique',
......@@ -194,11 +194,55 @@ module.exports = {
})
},
/** 权益单统计信息 */
equityStatistics(data) {
equityStatistics (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.equityOrder.statics',
projectName: 'boutique',
...data
})
}
},
// 更新客户签名
updateCustomerNameUrlAPI (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.equityOrder.updateCustomerNameUrl',
projectName: 'boutique',
...data
})
},
/** 查询合同*/
equityOrderList (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.equityOrder.listContracts',
projectName: 'boutique',
...data
})
},
/** 打印合同*/
printContract (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.equityOrder.print',
projectName: 'boutique',
...data
})
},
/**
* 提交前检查车架号是否已购买
*/
checkVinBuyEquityOrder (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.equityOrder.vin.check',
projectName: 'boutique',
...data
}, true)
},
/**提交权益单
*
*/
addEquityOrder (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.equityOrder.add',
projectName: 'boutique',
...data
}, true)
},
}
......@@ -2,7 +2,7 @@ import http from '../request/http'
module.exports = {
/** 销售顾问/录单员 & 交付专员 */
getEmployeeList(data) {
getEmployeeList (data) {
return http.post({
method: 'dj.api.smartcarlife.employee.onTheJob.getByMerchantId',
projectName: 'boutique',
......@@ -13,7 +13,7 @@ module.exports = {
* 二级流量方
*/
getDiversionMerchantRef(data) {
getDiversionMerchantRef (data) {
return http.post({
method: 'dj.api.smartcarlife.diversionMerchant.getDiversionMerchantRef',
projectName: 'boutique',
......@@ -24,7 +24,7 @@ module.exports = {
* 获取门店品牌车型
*/
getMerchantCarBrandList(data) {
getMerchantCarBrandList (data) {
return http.post({
method: 'dj.api.get.car.brandList',
projectName: 'boutique',
......@@ -36,7 +36,7 @@ module.exports = {
/***
* 获取门店礼券列表
*/
getMerchantCouponList(data) {
getMerchantCouponList (data) {
return http.post({
method: 'dj.api.smartCarLife.merchant.coupon.list',
projectName: 'boutique',
......@@ -46,7 +46,7 @@ module.exports = {
/**
* 获取客户礼券列表
*/
getCustomerCouponList(data) {
getCustomerCouponList (data) {
return http.post({
method: 'dj.api.customer.coupon.list',
projectName: 'boutique',
......@@ -56,7 +56,7 @@ module.exports = {
/**
* 获取商品列表
*/
getGoodsList(data) {
getGoodsList (data) {
return http.post({
method: 'dj.api.smartcarlife.selectOrderGoods.list',
projectName: 'boutique',
......@@ -65,7 +65,7 @@ module.exports = {
},
/**获取订单列表筛选转化人员&销售顾问 */
getOrderScreenEmployeeList(data) {
getOrderScreenEmployeeList (data) {
return http.post({
method: 'dj.api.smartcarlife.employee.getByMerchantId',
projectName: 'boutique',
......@@ -75,7 +75,7 @@ module.exports = {
/**
* 获取园区店配置
*/
getYqStoreConfig(data) {
getYqStoreConfig (data) {
return http.get({
method: 'dj.api.smarcarlife.yqMerchantConfig.detail',
projectName: 'boutique',
......@@ -86,7 +86,7 @@ module.exports = {
* 战败下单商品列表
*
*/
getOrderUpgradeGoodsList(data) {
getOrderUpgradeGoodsList (data) {
return http.post({
method: 'dj.api.smartcarlife.orderUpgradeGoods.listByMerchantId',
projectName: 'boutique',
......@@ -96,7 +96,7 @@ module.exports = {
/**
* 获取精品升级场景 太阳膜类商品部位数据
*/
getPositionList(data) {
getPositionList (data) {
return http.post({
method: 'dj.api.smartcarlife.goodsPosition.list',
projectName: 'boutique',
......@@ -107,7 +107,7 @@ module.exports = {
* 获取提单客户档案列表
*
*/
getQuotationCustomerList(data) {
getQuotationCustomerList (data) {
return http.post({
method: 'dj.api.smartcarlife.vehicle.damage.upgrade.quotation.customer.page',
projectName: 'boutique',
......@@ -115,7 +115,7 @@ module.exports = {
})
},
/**搜索订单(含套餐) */
getWorkPackageGoodsList(data) {
getWorkPackageGoodsList (data) {
let params = data || {}
params.sceneType = 1
return http.post(
......@@ -131,5 +131,31 @@ module.exports = {
'dj',
1000000
)
}
},
/**
* 获取车品牌
*/
getCarBrandList (data = {}) {
return http.post({
method: 'scrm.api.carlife.common.getOnlyCarBrandList',
projectName: 'carlife',
...data
}, false, 'scrm')
},
/** 获取车系列表 */
getCarSeriesList (data = {}) {
return http.post({
method: 'scrm.api.carlife.common.getCarSeriesList',
projectName: 'carlife',
...data
}, false, 'scrm')
},
/** 获取车型 */
getCarTypeList (data = {}) {
return http.post({
method: 'scrm.api.carlife.common.getCarTypeList',
projectName: 'carlife',
...data
}, false, 'scrm')
},
}
No preview for this file type
......@@ -140,6 +140,9 @@
.ml-32 {
margin-left: toRpx(32);
}
.ml-36 {
margin-left: toRpx(36);
}
.ml-48 {
margin-left: toRpx(48);
}
......
......@@ -48,9 +48,9 @@
.icon-change-account { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.34654731457800514) calc(100vmin * (1173 / 768) * -0.3052003410059676);}
.icon-clone { width: calc(100vmin * (1173 / 768) * 0.010230179028132993); height: calc(100vmin * (1173 / 768) * 0.010230179028132993);
background-position: calc(100vmin * (1173 / 768) * -0.36615515771526) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.4462915601023018) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-collapse-all { width: calc(100vmin * (1173 / 768) * 0.010230179028132993); height: calc(100vmin * (1173 / 768) * 0.010230179028132993);
background-position: calc(100vmin * (1173 / 768) * -0.38277919863597615) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.4629156010230179) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-coupon-arrow { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.34654731457800514) calc(100vmin * (1173 / 768) * -0.32608695652173914);}
.icon-coupon { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.015345268542199489);
......@@ -108,7 +108,7 @@
.icon-equity-order { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
background-position: calc(100vmin * (1173 / 768) * 0) calc(100vmin * (1173 / 768) * -0.5907928388746803);}
.icon-equityClose { width: calc(100vmin * (1173 / 768) * 0.010230179028132993); height: calc(100vmin * (1173 / 768) * 0.010230179028132993);
background-position: calc(100vmin * (1173 / 768) * -0.39940323955669227) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.479539641943734) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-equityTip { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.4752770673486786) calc(100vmin * (1173 / 768) * -0.4113384484228474);}
.icon-evaluation-management { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
......@@ -134,7 +134,7 @@
.icon-feedback { width: calc(100vmin * (1173 / 768) * 0.027280477408354646); height: calc(100vmin * (1173 / 768) * 0.027280477408354646);
background-position: calc(100vmin * (1173 / 768) * -0.3537936913895993) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-feedbackIcon { width: calc(100vmin * (1173 / 768) * 0.011082693947144074); height: calc(100vmin * (1173 / 768) * 0.011082693947144074);
background-position: calc(100vmin * (1173 / 768) * -0.33034953111679455) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.41048593350383633) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-ffdyj-icon { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.6300085251491901);}
.icon-filter { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
......@@ -151,6 +151,8 @@
background-position: calc(100vmin * (1173 / 768) * -0.5421994884910486) calc(100vmin * (1173 / 768) * -0.45865302642796246);}
.icon-front-window { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.6325660699062233) calc(100vmin * (1173 / 768) * -0.4825234441602728);}
.icon-fullScreen { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.6325660699062233) calc(100vmin * (1173 / 768) * -0.5025575447570333);}
.icon-green-arrow { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.011935208866155157);
background-position: calc(100vmin * (1173 / 768) * -0.7156862745098039) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-home-active { width: calc(100vmin * (1173 / 768) * 0.0443307757885763); height: calc(100vmin * (1173 / 768) * 0.0443307757885763);
......@@ -158,33 +160,33 @@
.icon-home { width: calc(100vmin * (1173 / 768) * 0.04774083546462063); height: calc(100vmin * (1173 / 768) * 0.04774083546462063);
background-position: calc(100vmin * (1173 / 768) * -0.11167945439045183) calc(100vmin * (1173 / 768) * -0.4825234441602728);}
.icon-icon-arrow { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.6325660699062233) calc(100vmin * (1173 / 768) * -0.5025575447570333);}
background-position: calc(100vmin * (1173 / 768) * -0.3751065643648764) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-icon-circle-error { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.340153452685422) calc(100vmin * (1173 / 768) * -0.15601023017902813);}
.icon-icon-close { width: calc(100vmin * (1173 / 768) * 0.030690537084398978); height: calc(100vmin * (1173 / 768) * 0.030690537084398978);
background-position: calc(100vmin * (1173 / 768) * -0.0370843989769821) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-icon-copy { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.3751065643648764) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
background-position: calc(100vmin * (1173 / 768) * -0.39514066496163686) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-icon-gold { width: calc(100vmin * (1173 / 768) * 0.030690537084398978); height: calc(100vmin * (1173 / 768) * 0.030690537084398978);
background-position: calc(100vmin * (1173 / 768) * -0.0741687979539642) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-icon-instructions { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.39514066496163686) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-icon-navigation { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.4151747655583973) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-icon-notice { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
.icon-icon-navigation { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.4352088661551577) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-icon-scanning { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
.icon-icon-notice { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.45524296675191817) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-icon-select { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
.icon-icon-scanning { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.4752770673486786) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-icon-shop { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
.icon-icon-select { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.49531116794543906) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-icon-store { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
.icon-icon-shop { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.5153452685421995) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-icon-store { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.5353793691389599) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-icon-upload { width: calc(100vmin * (1173 / 768) * 0.05456095481670929); height: calc(100vmin * (1173 / 768) * 0.05456095481670929);
background-position: calc(100vmin * (1173 / 768) * -0.4151747655583973) calc(100vmin * (1173 / 768) * -0.35038363171355497);}
.icon-icon-weixin { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.5353793691389599) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
background-position: calc(100vmin * (1173 / 768) * -0.5554134697357204) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-income-card { width: calc(100vmin * (1173 / 768) * 0.015345268542199489); height: calc(100vmin * (1173 / 768) * 0.015345268542199489);
background-position: calc(100vmin * (1173 / 768) * -0.4352088661551577) calc(100vmin * (1173 / 768) * -0.45865302642796246);}
.icon-income-count { width: calc(100vmin * (1173 / 768) * 0.03410059676044331); height: calc(100vmin * (1173 / 768) * 0.03410059676044331);
......@@ -212,7 +214,7 @@
.icon-logo { width: calc(100vmin * (1173 / 768) * 0.06820119352088662); height: calc(100vmin * (1173 / 768) * 0.06820119352088662);
background-position: calc(100vmin * (1173 / 768) * -0.5647911338448423) calc(100vmin * (1173 / 768) * -0.10017050298380221);}
.icon-lssl-icon { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.011935208866155157);
background-position: calc(100vmin * (1173 / 768) * -0.22037510656436488) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.30051150895140666) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-mask-del { width: calc(100vmin * (1173 / 768) * 0.03410059676044331); height: calc(100vmin * (1173 / 768) * 0.03410059676044331);
background-position: calc(100vmin * (1173 / 768) * -0.6547314578005116) calc(100vmin * (1173 / 768) * -0.3614663256606991);}
.icon-mask-edit { width: calc(100vmin * (1173 / 768) * 0.03410059676044331); height: calc(100vmin * (1173 / 768) * 0.03410059676044331);
......@@ -230,13 +232,13 @@
.icon-no-picture { width: calc(100vmin * (1173 / 768) * 0.021312872975277068); height: calc(100vmin * (1173 / 768) * 0.021312872975277068);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.14791133844842286);}
.icon-normal { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.011935208866155157);
background-position: calc(100vmin * (1173 / 768) * -0.23870417732310314) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.3188405797101449) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-notice-script { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
background-position: calc(100vmin * (1173 / 768) * -0.3312020460358056) calc(100vmin * (1173 / 768) * -0.5907928388746803);}
.icon-notice-study { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
background-position: calc(100vmin * (1173 / 768) * -0.37851662404092073) calc(100vmin * (1173 / 768) * -0.5907928388746803);}
.icon-notice-success { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.5554134697357204) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
background-position: calc(100vmin * (1173 / 768) * -0.5754475703324808) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-notice-system { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
background-position: calc(100vmin * (1173 / 768) * -0.4258312020460358) calc(100vmin * (1173 / 768) * -0.5907928388746803);}
.icon-notice-violate { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
......@@ -273,6 +275,10 @@
background-position: calc(100vmin * (1173 / 768) * -0.21994884910485935) calc(100vmin * (1173 / 768) * -0.4825234441602728);}
.icon-points { width: calc(100vmin * (1173 / 768) * 0.027280477408354646); height: calc(100vmin * (1173 / 768) * 0.027280477408354646);
background-position: calc(100vmin * (1173 / 768) * -0.4884910485933504) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-preview { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.5954816709292413) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-previewDownLoad { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.6155157715260017) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-promotion { width: calc(100vmin * (1173 / 768) * 0.020460358056265986); height: calc(100vmin * (1173 / 768) * 0.020460358056265986);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.252770673486786);}
.icon-prompt { width: calc(100vmin * (1173 / 768) * 0.10230179028132992); height: calc(100vmin * (1173 / 768) * 0.10230179028132992);
......@@ -296,9 +302,9 @@
.icon-rbkk-icon { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.1875532821824382) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-rear-gear { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.5754475703324808) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
background-position: calc(100vmin * (1173 / 768) * -0.6355498721227621) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-rear-window { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.5954816709292413) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
background-position: calc(100vmin * (1173 / 768) * -0.6555839727195226) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-reception-1 { width: calc(100vmin * (1173 / 768) * 0.020460358056265986); height: calc(100vmin * (1173 / 768) * 0.020460358056265986);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.30647911338448425);}
.icon-reception-2 { width: calc(100vmin * (1173 / 768) * 0.020460358056265986); height: calc(100vmin * (1173 / 768) * 0.020460358056265986);
......@@ -318,17 +324,17 @@
.icon-revokeOrder { width: calc(100vmin * (1173 / 768) * 0.027280477408354646); height: calc(100vmin * (1173 / 768) * 0.027280477408354646);
background-position: calc(100vmin * (1173 / 768) * -0.5558397271952259) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-right-arrow { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.6155157715260017) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
background-position: calc(100vmin * (1173 / 768) * -0.675618073316283) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-role-1 { width: calc(100vmin * (1173 / 768) * 0.028985507246376812); height: calc(100vmin * (1173 / 768) * 0.028985507246376812);
background-position: calc(100vmin * (1173 / 768) * -0.1483375959079284) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-role-2 { width: calc(100vmin * (1173 / 768) * 0.028985507246376812); height: calc(100vmin * (1173 / 768) * 0.028985507246376812);
background-position: calc(100vmin * (1173 / 768) * -0.1837169650468883) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-rule { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.011935208866155157);
background-position: calc(100vmin * (1173 / 768) * -0.2570332480818414) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.3371696504688832) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-scan { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.6355498721227621) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
background-position: calc(100vmin * (1173 / 768) * -0.6956521739130435) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-scanIcon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.6555839727195226) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
background-position: calc(100vmin * (1173 / 768) * 0) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-scanIconX { width: calc(100vmin * (1173 / 768) * 0.02557544757033248); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.17561807331628304);}
.icon-scene-0 { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
......@@ -340,7 +346,7 @@
.icon-scene-active { width: calc(100vmin * (1173 / 768) * 0.0443307757885763); height: calc(100vmin * (1173 / 768) * 0.0443307757885763);
background-position: calc(100vmin * (1173 / 768) * -0.10144927536231885) calc(100vmin * (1173 / 768) * -0.5400682011935208);}
.icon-scene-change { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.675618073316283) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
background-position: calc(100vmin * (1173 / 768) * -0.020034100596760442) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-scene { width: calc(100vmin * (1173 / 768) * 0.0443307757885763); height: calc(100vmin * (1173 / 768) * 0.0443307757885763);
background-position: calc(100vmin * (1173 / 768) * -0.15217391304347827) calc(100vmin * (1173 / 768) * -0.5400682011935208);}
.icon-search { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
......@@ -352,7 +358,7 @@
.icon-second-right { width: calc(100vmin * (1173 / 768) * 0.05456095481670929); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
background-position: calc(100vmin * (1173 / 768) * -0.48934356351236147) calc(100vmin * (1173 / 768) * -0.30008525149190113);}
.icon-seeIcon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.6956521739130435) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
background-position: calc(100vmin * (1173 / 768) * -0.040068201193520885) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-setting { width: calc(100vmin * (1173 / 768) * 0.027280477408354646); height: calc(100vmin * (1173 / 768) * 0.027280477408354646);
background-position: calc(100vmin * (1173 / 768) * -0.5895140664961637) calc(100vmin * (1173 / 768) * -0.6381074168797954);}
.icon-short-first-nav { width: calc(100vmin * (1173 / 768) * 0.1773231031543052); height: calc(100vmin * (1173 / 768) * 0.0443307757885763);
......@@ -361,20 +367,22 @@
background-position: calc(100vmin * (1173 / 768) * 0) calc(100vmin * (1173 / 768) * -0.4317988064791134);}
.icon-short-task-title { width: calc(100vmin * (1173 / 768) * 0.020460358056265986); height: calc(100vmin * (1173 / 768) * 0.020460358056265986);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.36018755328218244);}
.icon-sign_del { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.06010230179028133) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-start-text { width: calc(100vmin * (1173 / 768) * 0.0733162830349531); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.4761295822676897) calc(100vmin * (1173 / 768) * -0.2659846547314578);}
.icon-stick-top-blue { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * 0) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.08013640238704177) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-stick-top { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.020034100596760442) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.10017050298380221) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-store-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.040068201193520885) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.12020460358056266) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-store { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
background-position: calc(100vmin * (1173 / 768) * -0.6547314578005116) calc(100vmin * (1173 / 768) * -0.18925831202046037);}
.icon-study-active { width: calc(100vmin * (1173 / 768) * 0.0443307757885763); height: calc(100vmin * (1173 / 768) * 0.0443307757885763);
background-position: calc(100vmin * (1173 / 768) * -0.2028985507246377) calc(100vmin * (1173 / 768) * -0.5400682011935208);}
.icon-study-tips { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.011935208866155157);
background-position: calc(100vmin * (1173 / 768) * -0.2753623188405797) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.3554987212276215) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-study { width: calc(100vmin * (1173 / 768) * 0.0443307757885763); height: calc(100vmin * (1173 / 768) * 0.0443307757885763);
background-position: calc(100vmin * (1173 / 768) * -0.2536231884057971) calc(100vmin * (1173 / 768) * -0.5400682011935208);}
.icon-submit { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
......@@ -384,21 +392,21 @@
.icon-suggestions-arrow { width: calc(100vmin * (1173 / 768) * 0.015345268542199489); height: calc(100vmin * (1173 / 768) * 0.015345268542199489);
background-position: calc(100vmin * (1173 / 768) * -0.47868712702472294) calc(100vmin * (1173 / 768) * -0.45865302642796246);}
.icon-suggestions-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.06010230179028133) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.1402387041773231) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-sun-roof { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.08013640238704177) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.16027280477408354) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-tag-checked { width: calc(100vmin * (1173 / 768) * 0.02557544757033248); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.44075021312872975);}
.icon-task-pass { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.011935208866155157);
background-position: calc(100vmin * (1173 / 768) * -0.293691389599318) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.37382779198635974) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-tdcj-icon { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.25788576300085253) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-time-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.10017050298380221) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.18030690537084398) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-time { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.2813299232736573) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-tips-b { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.12020460358056266) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.20034100596760443) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-tips-g { width: calc(100vmin * (1173 / 768) * 0.020460358056265986); height: calc(100vmin * (1173 / 768) * 0.020460358056265986);
background-position: calc(100vmin * (1173 / 768) * -0.7020460358056266) calc(100vmin * (1173 / 768) * -0.38704177323103156);}
.icon-tips { width: calc(100vmin * (1173 / 768) * 0.03410059676044331); height: calc(100vmin * (1173 / 768) * 0.03410059676044331);
......@@ -412,11 +420,11 @@
.icon-topTipsRightIcon { width: calc(100vmin * (1173 / 768) * 0.06990622335890878); height: calc(100vmin * (1173 / 768) * 0.05115089514066496);
background-position: calc(100vmin * (1173 / 768) * -0.2855924978687127) calc(100vmin * (1173 / 768) * -0.20758738277919864);}
.icon-total { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.1402387041773231) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.22037510656436488) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-two-arrow { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.010230179028132993);
background-position: calc(100vmin * (1173 / 768) * -0.34782608695652173) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.4279624893435635) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-up-arrow { width: calc(100vmin * (1173 / 768) * 0.011935208866155157); height: calc(100vmin * (1173 / 768) * 0.011935208866155157);
background-position: calc(100vmin * (1173 / 768) * -0.31202046035805625) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.39215686274509803) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-upload-play { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.30477408354646207) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-uploadAdd { width: calc(100vmin * (1173 / 768) * 0.020460358056265986); height: calc(100vmin * (1173 / 768) * 0.020460358056265986);
......@@ -424,12 +432,12 @@
.icon-visible { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.32821824381926684) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-warning-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.16027280477408354) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.24040920716112532) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-work-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.18030690537084398) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
background-position: calc(100vmin * (1173 / 768) * -0.26044330775788577) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
.icon-ybtc_icon { width: calc(100vmin * (1173 / 768) * 0.017050298380221655); height: calc(100vmin * (1173 / 768) * 0.017050298380221655);
background-position: calc(100vmin * (1173 / 768) * -0.3516624040920716) calc(100vmin * (1173 / 768) * -0.6751918158567775);}
.icon-yw-icon { width: calc(100vmin * (1173 / 768) * 0.015345268542199489); height: calc(100vmin * (1173 / 768) * 0.015345268542199489);
background-position: calc(100vmin * (1173 / 768) * -0.5004262574595055) calc(100vmin * (1173 / 768) * -0.45865302642796246);}
.icon-zj-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
background-position: calc(100vmin * (1173 / 768) * -0.20034100596760443) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
\ No newline at end of file
background-position: calc(100vmin * (1173 / 768) * -0.2804774083546462) calc(100vmin * (1173 / 768) * -0.6986359761295823);}
\ No newline at end of file

2.93 MB | W: | H:

2.94 MB | W: | H:

assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
  • 2-up
  • Swipe
  • Onion skin
<template>
<view
class="gl-cell"
v-if="formList.length"
>
<view class="gl-cell">
<view
v-for="(items, boxIdx) in formList"
:key="boxIdx"
class="cell-box-block"
>
<view class="cell-box">
<view
class="cell-box"
v-if="items.length"
:style="cellBoxStyle"
>
<template v-if="titleList.length">
<view
class="cell-title flex"
......@@ -52,6 +53,12 @@
v-if="item.required"
class="required"
>*</view>
<template v-if="item.labelTips">
<view
class="label-tips"
@click.stop="onLabelTipsClick(item)"
>{{ item.labelTips }}</view>
</template>
</view>
<view class="cell-value">
<!-- 输入框 -->
......@@ -66,6 +73,7 @@
:maxlength="item.maxlength ? item.maxlength : -1"
placeholder-class="input-placeholder"
@input="item.inputType === 'number' && item.maxlength ? (formData[item.value] = String($event.target.value).slice(0, item.maxlength)) : null"
:readonly="item.readonly || false"
/>
<view
v-if="item.valueIcon"
......@@ -123,6 +131,63 @@
:maxlength="item.maxlength"
></textarea>
</template>
<template v-else-if="item.type === 'single-calendar'">
<view
class="value"
@click="openCalendar(boxIdx,idx)"
>
<template v-if="!item.addHtml && formData[item.value]">
{{ formData[item.value] }}
</template>
<template v-else>
<span class="placeholder">请选择</span>
</template>
<view class="sprite-icon icon-icon-select"></view>
</view>
<uni-calendar
:ref="`calendar-${boxIdx}-${idx}`"
:insert="false"
:clearDate="false"
:startDate="item.startDate || ''"
:endDate="item.endDate || ''"
:date="formData[item.value] || item.endDate"
showBottomBtn
@confirm="confirmCalendar($event,item.value )"
/>
</template>
<template v-else-if="item.type === 'range-calendar'">
<view
class="value"
@click="openCalendar(boxIdx,idx)"
>
<template v-if="!item.addHtml && formData[item.value]">
{{ formData[item.value] }}
</template>
<template v-else>
<span class="placeholder">请选择</span>
</template>
<view class="sprite-icon icon-icon-select"></view>
</view>
<uni-calendar
:ref="`calendar-${boxIdx}-${idx}`"
range
:insert="false"
:clearDate="false"
:startDate="item.startDate || ''"
:endDate="item.endDate || ''"
:rangeValue="formData[item.value]"
showBottomBtn
@confirm="confirmCalendar($event,item.value)"
/>
</template>
<slot
v-else-if="item.cellHtml"
:name="item.cellHtml"
></slot>
<template v-if="item.suffix">
<view class="suffix">{{item.suffix}}</view>
</template>
</view>
</view>
<slot
......@@ -140,6 +205,7 @@
</template>
</view>
</view>
</view>
</template>
......@@ -171,7 +237,9 @@ export default {
type: Array,
default: () => []
},
collapseControl: Boolean
collapseControl: Boolean,
cellBoxStyle: String,
index: Number
},
data () {
return {
......@@ -184,7 +252,7 @@ export default {
methods: {
onCellClick (item) {
if (item.type === 'select') {
this.$emit('handleCell', item)
this.$emit('handleCell', item, this.index)
}
},
onRadioChange (e, item) {
......@@ -194,10 +262,20 @@ export default {
this.$emit('handleValue', item)
},
handleBlur (e, item) {
this.$emit('inputBlur', e, item)
this.$emit('inputBlur', e, item, this.index)
},
collapseAll (index) {
this.$emit('collapseAll', index)
},
confirmCalendar (e, key) {
this.$emit('confirmCalendar', e, key, this.index)
},
openCalendar (index, ind) {
let [calendar] = this.$refs[`calendar-${index}-${ind}`]
if (calendar) calendar.open()
},
onLabelTipsClick (item) {
this.$emit('handleLabelTips', item)
}
}
}
......@@ -270,7 +348,12 @@ export default {
font-size: toRpx(28);
display: flex;
align-items: center;
.label-tips {
margin-left: 8rpx;
color: #4673ff;
font-size: 24rpx;
font-weight: 400;
}
.sprite-icon {
margin-right: toRpx(8);
}
......@@ -304,7 +387,12 @@ export default {
margin-left: toRpx(20);
overflow: hidden;
font-size: toRpx(28);
display: flex;
align-items: center;
.suffix {
flex-shrink: 0;
margin-left: 16rpx;
}
uni-input {
font-size: toRpx(28);
}
......@@ -318,6 +406,8 @@ export default {
justify-content: flex-end;
align-items: center;
height: 100%;
width: 100%;
word-break: break-all;
.sprite-icon {
margin-bottom: toRpx(2);
}
......@@ -345,6 +435,7 @@ export default {
width: 100%;
border: none;
padding: 0;
background-color: transparent;
}
.input-bottom {
min-height: toRpx(100);
......
......@@ -567,8 +567,6 @@ export default {
const noInterceptPage = ['DailyReport', 'DeliveryManagement'],
{ sceneType } = this
if (!noInterceptPage.includes(item.name)) {
// 日报
if (await this.checkDailyReport(sceneType != 7)) return
if (sceneType != 7) {
// if (await this.inspectionOfProhibitionBill()) return
// 检查是否限制录单
......@@ -579,6 +577,7 @@ export default {
return
}
}
if (await this.checkDailyReport(sceneType != 7)) return
}
if (item.name === 'EvaluationFormList') {
mediaResourceManager.cleanupExpired()
......
<template>
<view
class="car-model-box"
:key="viewKey"
>
<scroll-view
class="scroll-view"
scroll-y
:scroll-into-view="letter"
>
<template v-if="listData.length">
<template v-for="(i, index) in listData">
<view
class="item-box"
:key="index"
:id="i.letter"
>
<view class="letter-title flex">{{i.letter}}</view>
<template v-for="(c,cindex) in i.list">
<view
class="car-model"
:key="cindex"
>
<view class="brand-name">{{c.name}}</view>
<view class="brand-list">
<template v-for="(j, jindex) in c.childs_list">
<view
:key="jindex"
:class="['sub-brand-name']"
>
<view
class="subtitle subtitle-one flex"
@click.stop="chooseSubBrand(j, c , jindex, cindex, index)"
>
{{j.name}}
<uni-icons
:type="`${j.children && j.children.length?'down':'right'}`"
size="18"
></uni-icons>
</view>
</view>
<template v-for="(k,kindex) in j.children">
<view
class="sub-item flex"
:key="`${k.id}_${kindex}`"
>
<view
class="subtitle subtitle-two flex"
@click.stop="chooseSeries(k,jindex, cindex, index ,kindex)"
>
{{k.name}}
<uni-icons
:type="`${k.children && k.children.length?'down':'right'}`"
size="18"
></uni-icons>
</view>
<template v-for="(s,sindex) in k.children">
<view
:class="['item flex',{active: checkActive(s)}]"
:key="`${s.id}_${sindex}`"
@click.stop="chooseCarType(s,c)"
>
{{s.name}}
<view class="sprite-icon icon-tag-checked"></view>
</view>
</template>
</view>
</template>
</template>
</view>
</view>
</template>
</view>
</template>
<view class="block"></view>
</template>
</scroll-view>
<view class="letter-list">
<template v-for="(i, index) in listData">
<view
class="letter-item"
:key="index"
@click="letter = i.letter"
>
{{i.letter}}
</view>
</template>
</view>
<view class="right-box">
</view>
</view>
</template>
<script type='text/ecmascript-6'>
import popupmixin from './popupmixin'
export default {
mixins: [popupmixin],
name: 'CarBrand',
data () {
return {
letter: 'A',
viewKey: Date.now()
}
},
mounted () {
},
methods: {
async getList (searchValue) {
const { userInfo, params } = this,
{ cacheData } = params
this.currentId = ''
if (cacheData && cacheData.length) {
this.initData(cacheData)
if (searchValue) this.handleSearch(searchValue)
return
}
const data = await uni.$api.popupApi.getCarBrandList()
this.updateParams(params, data || [])
},
initData (carData) {
let { params: { idKey }, data: { customer, carInfo }, sceneType } = this,
letterList = Array.from(new Set([...carData.map((e) => e.letter)])),
carModelList = letterList.map(e => {
let list = []
carData.map(i => {
if (e === i.letter) {
i.childs_list = i.childs;
list.push(i)
}
})
return {
letter: e,
list,
}
})
this.list = carModelList
this.$emit('onComplete')
},
handleSearch (searchValue) {
if (!searchValue) {
this.searchStatus = false
this.letter = 'A'
} else {
searchValue = searchValue.toUpperCase()
let { list } = this,
carBrand = JSON.parse(JSON.stringify(list))
let arr = [];
carBrand.map(c => {
c.list.map(i => {
let childs_list = [],
i_name = i.name.toUpperCase()
i.childs_list.map((k) => {
let k_name = k.name.toUpperCase()
if (k_name.indexOf(searchValue) != -1) {
childs_list.push(k);
}
});
if (i_name.indexOf(searchValue) != -1 || childs_list.length > 0) {
i.childs_list = childs_list.length > 0 ? childs_list : i.childs_list;
arr.push(i);
}
})
})
let letterList = Array.from(new Set([...arr.map((e) => e.letter)]));
let searchList = letterList.map((l) => {
let _list = [];
arr.map((i) => {
if (l === i.letter) {
_list.push(i);
}
})
return {
letter: l,
list: _list,
}
})
this.searchList = searchList
this.searchStatus = true
}
},
async chooseSubBrand (that, item, jindex, cindex, index) {
if(that.children && that.children.length) return
uni.showLoading({
mask: true
})
const data = await uni.$api.popupApi.getCarSeriesList({
brandId: item.id,
childBrandId: that.id
})
uni.hideLoading()
this.listData[index].list[cindex].childs_list[jindex].children = data
this.viewKey = Date.now()
},
async chooseSeries (k, jindex, cindex, index, kindex) {
if (k.children && k.children.length) return
uni.showLoading({
mask: true
})
const data = await uni.$api.popupApi.getCarTypeList({
carSeriesId: k.id
})
uni.hideLoading()
this.listData[index].list[cindex].childs_list[jindex].children[kindex].children = data
this.viewKey = Date.now()
},
chooseCarType (s, c) {
let chooseItem = {
vehicleBrandId: c.id,
vehicleBrandName: c.name,
vehicleSubBrandId: s.brandId,
vehicleSubBrandName: s.brandName,
vehicleSeriesId: s.seriesId,
vehicleSeriesName: s.seriesName,
vehicleShapeId: s.id,
vehicleShapeName: s.name
}
this.currentId = s.id
this.$emit('choose', chooseItem)
},
checkActive (j) {
let { currentId, data, params } = this
return currentId ?
j.id == currentId : j.id == data[params.idKey]
},
}
}
</script>
<style scoped lang='scss'>
.car-model-box {
position: relative;
height: 100%;
width: 100%;
.scroll-view {
height: 100%;
}
.letter-list {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 0;
color: #888888;
font-size: toRpx(28);
line-height: toRpx(28);
padding: 0 toRpx(18);
text-align: center;
}
.item-box {
margin-bottom: toRpx(32);
.letter-title {
color: #888888;
font-size: toRpx(28);
height: toRpx(40);
background: #f5f7fa;
padding-left: toRpx(48);
}
.car-model {
margin: 0 toRpx(48);
.brand-name {
color: #333333;
font-size: toRpx(32);
line-height: toRpx(44);
margin: toRpx(16) 0;
}
.sub-brand-name {
color: #888888;
font-size: toRpx(28);
line-height: toRpx(40);
width: 100%;
flex-shrink: 0;
border-bottom: toRpx(2) solid #888;
}
}
}
.brand-list {
// display: grid;
// grid-template-columns: repeat(4, 1fr);
display: flex;
// gap: toRpx(32) 0;
flex-wrap: wrap;
.subtitle {
width: 100%;
flex-shrink: 0;
}
.subtitle-one {
margin: toRpx(10) 0;
}
.subtitle-two {
color: #000;
font-size: toRpx(36);
font-weight: 500;
}
.sub-item {
width: 100%;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: toRpx(32);
display: flex;
flex-wrap: wrap;
gap: toRpx(32);
margin-top: toRpx(20);
align-items: stretch;
}
.item {
width: calc((100% - #{toRpx(96)}) / 4);
justify-content: center;
min-height: toRpx(72);
border-radius: toRpx(8);
border: toRpx(2) solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: toRpx(32);
padding: toRpx(10);
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
}
.block {
width: 100%;
height: toRpx(24);
}
</style>
\ No newline at end of file
......@@ -282,17 +282,17 @@ export default {
.step-box {
height: toRpx(64);
justify-content: center;
gap: 0 96rpx;
gap: 0 toRpx(96);
position: relative;
margin-bottom: 16rpx;
margin-bottom: toRpx(16);
.step {
height: 64rpx;
border-radius: 12rpx;
height: toRpx(64);
border-radius: toRpx(12);
background: #f2f2f2;
justify-content: center;
padding: 0 32rpx;
padding: 0 toRpx(32);
color: #666666;
font-size: 28rpx;
font-size: toRpx(28);
}
.step-active {
background: #dee7ff;
......@@ -304,8 +304,8 @@ export default {
left: 50%;
transform: translate(-50%, -50%);
content: '';
width: 16rpx;
height: 2rpx;
width: toRpx(16);
height: toRpx(2);
background: #cccccc;
}
}
......
<template>
<view class="gearbox-list">
<template v-for="(i, index) in list">
<view
:key="index"
@click="choose(i)"
:class="['item flex', { active: currentId ? i.value == currentId : i.value == data[params.idKey] }]"
>
<view class="sprite-icon icon-tag-checked"></view>
<template v-if="!i.type">
{{ i.value }}
</template>
<template v-else>
<input
type="text"
v-model="i.value"
class="input"
:placeholder="i.label"
>
</template>
</view>
</template>
</view>
</template>
<script type="text/ecmascript-6">
import popupmixin from './popupmixin'
export default {
mixins: [popupmixin],
name: 'Gearbox',
inject: ['userInfo'],
data () {
return {
}
},
mounted () {
},
methods: {
async getList () {
const { params } = this
this.currentId = ''
let data = [
{
value: 'MT变速箱'
},
{
value: 'AMT变速箱'
},
{
value: 'AT变速箱'
},
{
value: 'CVT变速箱'
},
{
value: 'DCT变速箱'
},
{
label: '自定义',
value: '',
type: 'input'
}
]
this.updateParams(params, data)
},
initData (list) {
const { params: { idKey }, data } = this
console.log(data[idKey])
if (data[idKey]) {
this.currentId = data[idKey]
this.$emit('choose', data[idKey])
let index = list.findIndex(item => item.value == data[idKey])
if(index == -1) list[list.length - 1].value = data[idKey]
}
this.list = list
this.$emit('onComplete')
},
handleSearch (searchValue) {
this.list = []
this.getList(searchValue, true)
},
choose (i) {
this.currentId = i.value
this.$emit('choose', i.value)
}
}
}
</script>
<style scoped lang="scss">
.gearbox-list {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: toRpx(32);
margin: 0 toRpx(48);
.item {
justify-content: center;
height: toRpx(72);
border-radius: toRpx(8);
border: toRpx(2) solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: toRpx(32);
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
.input{
width: 100%;
height: 100%;
text-align: center;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
</style>
<template>
<view class="seat-list">
<template v-for="(i, index) in list">
<view
:key="index"
@click="choose(i)"
:class="['item flex', { active: currentId != null ? i.optionId == currentId : i.optionId == data[params.idKey] }]"
>
<view class="sprite-icon icon-tag-checked"></view>
{{ i.optionLabel }}
</view>
</template>
</view>
</template>
<script type="text/ecmascript-6">
import popupmixin from './popupmixin'
export default {
mixins: [popupmixin],
name: 'Options',
inject: ['userInfo'],
data () {
return {
}
},
mounted () {
},
methods: {
async getList () {
const { params } = this
this.currentId = '-1'
this.updateParams(params, params.options)
},
initData (list) {
const { params: { idKey }, data } = this
if (data[idKey] != null) {
this.currentId = data[idKey]
this.$emit('choose', data[idKey])
}
this.list = list
this.$emit('onComplete')
},
choose (i) {
this.currentId = i.optionId
this.$emit('choose', i)
}
}
}
</script>
<style scoped lang="scss">
.seat-list {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: toRpx(32);
margin: 0 toRpx(48);
.item {
justify-content: center;
height: toRpx(72);
border-radius: toRpx(8);
border: toRpx(2) solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: toRpx(32);
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
</style>
......@@ -21,6 +21,12 @@
* 18: 座位数
* 19: 客户档案
* 20: 战败客户档案
* 21: 客户类型
* 22: 证件类型
* 23: 购车类型
* 24: 车辆使用性质
* 25: 选择品牌车系
* 26: 变速箱类型
*/
const componentConfig = {
......@@ -239,6 +245,108 @@ const componentConfig = {
searchValue: '',
noData: false,
defeat: true
}
},
21: {
name: 'Options',
title: '客户类型',
nullTips: '请选择客户类型',
idKey: 'customerType',
hideSearch: true,
loadComplete: false,
options: [{
optionId: 1,
optionLabel: '个人'
}, {
optionId: 2,
optionLabel: '企业'
}, {
optionId: 3,
optionLabel: '个人(港澳)'
}, {
optionId: 4,
optionLabel: '个人(台)'
}, {
optionId: 5,
optionLabel: '个人(军官)'
}]
},
22: {
name: 'Options',
title: '证件类型',
nullTips: '请选择证件类型',
idKey: 'cardType',
hideSearch: true,
loadComplete: false,
options: [{
optionId: 1,
optionLabel: '身份证'
}, {
optionId: 2,
optionLabel: '统一社会信息代码'
}, {
optionId: 3,
optionLabel: '港澳返乡证'
}, {
optionId: 4,
optionLabel: '台胞证'
}, {
optionId: 5,
optionLabel: '军官证'
}, {
optionId: 7,
optionLabel: '护照'
}]
},
23: {
name: 'Options',
title: '购车类型',
nullTips: '请选择购车类型',
idKey: 'buyCarType',
hideSearch: true,
loadComplete: false,
options: [{
optionId: 0,
optionLabel: '贷款车'
}, {
optionId: 1,
optionLabel: '全款车'
}]
},
24: {
name: 'Options',
title: '车辆使用性质',
nullTips: '请选择车辆使用性质',
idKey: 'vehicleNature',
hideSearch: true,
loadComplete: false,
options: [{
optionId: 0,
optionLabel: '营运'
}, {
optionId: 1,
optionLabel: '非营运'
}]
},
25: {
name: 'CarBrand',
title: '选择品牌车系',
placeholder: '查找',
idKey: 'vehicleShapeId',
nullTips: '请选择品牌车系',
cacheData: [],
loadComplete: false,
searchValue: '',
noData: false,
hideSearch: true,
popupStyle: 'height:90vh;'
},
26: {
name: 'Gearbox',
title: '变速箱类型',
nullTips: '请选择变速箱类型',
idKey: 'gearbox',
hideSearch: true,
loadComplete: false
},
}
export default { componentConfig }
......@@ -8,6 +8,8 @@
@onCancel="cancel"
@onReset="reset"
:showReset="popupType === 15"
:hideFooter="componentObject[popupType].hideFooter"
:popupStyle="componentObject[popupType].popupStyle || ''"
>
<view class="popup-title flex">
{{ title }}
......@@ -44,7 +46,11 @@
</view>
</view>
</template>
<view :class="['popup-body', { 'hide-search': componentObject[popupType].hideSearch }]">
<view :class="['popup-body',
{'hide-footer': componentObject[popupType].hideFooter },
{'hide-search': componentObject[popupType].hideSearch },
{'hide-footer-search':componentObject[popupType].hideFooter && componentObject[popupType].hideSearch }
]">
<scroll-view
scroll-y
:class="['popup-scroll-view', { show: componentObject[popupType].loadComplete }]"
......@@ -100,6 +106,10 @@ import AgeRange from './components/AgeRange.vue'
import City from './components/City.vue'
import Seat from './components/Seat.vue'
import Customer from './components/Customer.vue'
import Options from './components/Options.vue'
import CarBrand from './components/CarBrand.vue'
import Gearbox from './components/Gearbox.vue'
export default {
components: {
Popup,
......@@ -119,6 +129,9 @@ export default {
City,
Seat,
Customer,
Options,
CarBrand,
Gearbox
},
name: '',
props: {
......@@ -202,7 +215,7 @@ export default {
sceneType () {
const { sceneType } = uni.$storage.get('userInfo')
return sceneType
}
},
},
mounted () {
},
......@@ -250,7 +263,7 @@ export default {
if (!autoClose) this.$refs.popup.close()
return
}
if (chooseContent) {
if (chooseContent != null) {
if (Array.isArray(chooseContent) && !chooseContent.length && componentObject[popupType].nullTips) throw componentObject[popupType].nullTips
this.$emit('onConfirm', {
chooseContent,
......@@ -381,6 +394,15 @@ export default {
padding-top: 0;
}
}
.hide-footer {
height: calc(100% - #{toRpx(184)});
}
.hide-footer-search {
height: calc(100% - #{toRpx(104)});
.popup-scroll-view {
padding-top: 0;
}
}
.popup-footer {
padding: toRpx(64) 0;
justify-content: center;
......@@ -412,6 +434,11 @@ export default {
justify-content: center;
}
}
.car-popup {
.popup-box {
height: 90vh;
}
}
.right-box {
width: 46vw;
height: 100vh;
......
<template>
<uni-popup ref="popup" :type="position" :is-mask-click="maskClick" :animation="animation">
<view :class="['popup-box', { 'right-box': position == 'right' }]">
<view :class="['popup-box', { 'right-box': position == 'right' }]" :style="popupStyle">
<slot></slot>
<view class="popup-footer flex" v-if="showReset">
<view class="popup-btn-three popup-cancel" @click="cancel">{{ cancelText }}</view>
<view class="popup-btn-three popup-reset" @click="reset">{{ resetText }}</view>
<view class="popup-btn-three popup-confirm" @click="confirm">{{ confirmText }}</view>
</view>
<view class="popup-footer flex" v-else>
<view class="popup-btn popup-cancel" @click="cancel">{{ cancelText }}</view>
<view class="popup-btn popup-confirm" @click="confirm">{{ confirmText }}</view>
</view>
<template v-if="!hideFooter">
<view class="popup-footer flex" v-if="showReset">
<view class="popup-btn-three popup-cancel" @click="cancel">{{ cancelText }}</view>
<view class="popup-btn-three popup-reset" @click="reset">{{ resetText }}</view>
<view class="popup-btn-three popup-confirm" @click="confirm">{{ confirmText }}</view>
</view>
<view class="popup-footer flex" v-else>
<view class="popup-btn popup-cancel" @click="cancel">{{ cancelText }}</view>
<view class="popup-btn popup-confirm" @click="confirm">{{ confirmText }}</view>
</view>
</template>
</view>
</uni-popup>
</template>
......@@ -47,7 +49,12 @@ export default {
showReset: {
type: Boolean,
default: false
}
},
popupStyle: {
type: String,
default: ''
},
hideFooter:Boolean
},
......
......@@ -186,6 +186,7 @@ export default {
padding: 0 toRpx(40);
flex-shrink: 0;
position: relative;
background-color: #eef4fe;
&:first-of-type {
padding-left: toRpx(80);
}
......
......@@ -218,7 +218,7 @@ export default {
positionTypeList: [],
valueKey: '',
totalPrice: 0,
validateState:true,
validateState: true,
// 产品槽位配置,用于循环渲染产品组件
productSlots: {
frontGear: true,
......@@ -285,7 +285,12 @@ export default {
// 防止从补录进来4s店收款为禁用
const cell = this.formList[2].find(item => item.value == 'payeeType')
if (cell) {
cell.current = 1
// 编辑订单时,使用已有的payeeType值,新建订单时使用默认值1
if (!this.orderObj.id) {
cell.current = 1
} else {
cell.current = this.orderObj.payeeType
}
cell.radioList[1].disabled = false
}
this.getConfig()
......@@ -385,21 +390,23 @@ export default {
inputBlur(e, val) {
console.log(e, val)
this.orderObj.customer[val.value] = this.orderObj[val.value]
// VIN车架号动态校验:车架号字段,动态转换为大写
let standNoVal = this.orderObj.standNo;
if (val.value === 'standNo' && standNoVal) {
this.orderObj.standNo = formatVinInput(standNoVal)
validateVin(this.orderObj.standNo).then(result => {
console.log("validateVin",result);
let { valid } = result.data;
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
}).catch(err => {
console.log("validateVinErr",result);
})
}
// VIN车架号动态校验:车架号字段,动态转换为大写
let standNoVal = this.orderObj.standNo
if (val.value === 'standNo' && standNoVal) {
this.orderObj.standNo = formatVinInput(standNoVal)
validateVin(this.orderObj.standNo)
.then(result => {
console.log('validateVin', result)
let { valid } = result.data
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
})
.catch(err => {
console.log('validateVinErr', result)
})
}
},
// 校验必填等规则
checkRequired() {
......@@ -476,22 +483,22 @@ export default {
// 提交
async submit() {
// VIN车架号-动态校验
const carVin = this.orderObj.standNo
console.log("validateState",this.validateState);
if (carVin) {
// 前置判断
if (carVin.length !== 17) {
uni.showToast({title:'请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)',icon:'none'})
return false
}
// 根据接口校验结果判断
if (carVin.length === 17 && !this.validateState) {
uni.showToast({title:'车架号校验不匹配,请核对后重新输入',icon:'none'})
return false
}
}
// VIN车架号-动态校验
const carVin = this.orderObj.standNo
console.log('validateState', this.validateState)
if (carVin) {
// 前置判断
if (carVin.length !== 17) {
uni.showToast({ title: '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)', icon: 'none' })
return false
}
// 根据接口校验结果判断
if (carVin.length === 17 && !this.validateState) {
uni.showToast({ title: '车架号校验不匹配,请核对后重新输入', icon: 'none' })
return false
}
}
if (!(await this.checkDailyReport())) {
const { orderCreateType } = this
const obj = utils.deepClone(this.orderObj)
......
......@@ -595,35 +595,38 @@ export default {
this.dateKey.staffCount = Date.now()
},
handleBlur (e, i) {
let { value } = e.detail
let { value } = e.detail,
{ orderObj, userInfo } = this,
key = i.value
if (value) {
let { orderObj, userInfo } = this
let key = i.value,
numbers = value.match(/\d+/g)
let numbers = value.match(/\d+/g)
numbers = numbers ? numbers.join('') : ''
if (numbers.length > 1) numbers = numbers.replace(/^0+/, '')
this.orderObj[key] = Math.min(Math.max(Number(numbers), 0), 100).toString()
this.dateKey[key] = Date.now()
if (
this.isNotEmpty(orderObj.recordStaffCount) &&
this.isNotEmpty(value) &&
orderObj.recordStaffCount != value &&
orderObj.lastStaffUuid &&
userInfo.uuid != orderObj.lastStaffUuid
) {
this.noticeObj = {
title: '重要提示',
text: `今日驻店人数与 ${orderObj.lastStaffName} 提交不一致,再次确认!不一致提交日报时,今日驻店人数将被清空。`,
type: 'warning',
buttons: [
{
text: '确定',
type: 'primary',
}
]
}
this.$nextTick(() => this.$refs.reportNotice.open())
} else {
this.orderObj[key] = ''
this.dateKey[key] = Date.now()
}
if (
this.isNotEmpty(orderObj.recordStaffCount) &&
this.isNotEmpty(value) &&
orderObj.recordStaffCount != value &&
orderObj.lastStaffUuid &&
userInfo.uuid != orderObj.lastStaffUuid
) {
this.noticeObj = {
title: '重要提示',
text: `今日驻店人数与 ${orderObj.lastStaffName} 提交不一致,再次确认!不一致提交日报时,今日驻店人数将被清空。`,
type: 'warning',
buttons: [
{
text: '确定',
type: 'primary',
}
]
}
this.$nextTick(() => this.$refs.reportNotice.open())
}
},
isNotEmpty (value) {
......@@ -635,15 +638,19 @@ export default {
)
},
handleCarInputBlur (e, i, item, index) {
let { value } = e.detail
let { value } = e.detail,
{ key, max } = i
if (value) {
let { key, max } = i,
numbers = value.match(/\d+/g)
let numbers = value.match(/\d+/g)
numbers = numbers ? numbers.join('') : ''
if (numbers.length > 1) numbers = numbers.replace(/^0+/, '')
item[key] = Math.min(Math.max(Number(numbers), 0), max).toString()
this.dateKey[`${key}_${index}`] = Date.now()
} else {
item[key] = ''
this.dateKey[`${key}_${index}`] = Date.now()
}
console.log(item[key])
},
async submit () {
uni.showLoading({
......@@ -660,7 +667,7 @@ export default {
orderObj.sceneType = 1
orderObj.brandDataList = carBandList
if (orderObj.pickerValue == 0) {
if (orderObj.staffCount == null) throw {
if (['', null].includes(orderObj.staffCount)) throw {
message: '今日驻店人数(按店)',
refId: 'staffCount'
}
......
......@@ -147,14 +147,14 @@ module.exports = {
background: '#EAF1FF'
}
},
// 0待补单;2提单成功;3提单失败
// 0待补单;2提单成功;3提单失败,4已退单
equityStatus: {
0: {
2: {
text: '已完成',
color: '#2cca74',
background: '#eaf9f1'
},
2: {
0: {
text: '待补录',
color: '#F7A431',
background: '#FFF5E6'
......@@ -163,7 +163,8 @@ module.exports = {
text: '提单失败',
color: '#f24724',
background: '#fdece9'
}
},
4: { text: '已退单', color: '#999999', background: 'rgba(153, 153, 153, 0.1)' }
},
// 订单状态 1 待跟进, 2 不升级, 3 待支付,4 已支付,6 已评价 , 9 已撤销
statusList: [
......@@ -211,7 +212,7 @@ module.exports = {
4: { text: '已支付', color: '#2CCA74', background: '#EAF9F1' },
5: { text: '已完成', color: '#F7A431', background: '#FFF5E6' },
'-1': { text: '战败', color: '#F24724', background: '#FDECE9' },
9: { text: '已撤销', color: '#999999', background: ' #9999991a;' },
9: { text: '已撤销', color: '#999999', background: 'rgba(153, 153, 153, 0.1)' },
11: { text: '已失效', color: '#F7A431', background: '#FFF5E6' },
6: { text: '已退款', color: '#F7A431', background: '#FFF5E6' }
}
......
<template>
<view class="equity-box">
<view class="common-title">服务信息录入</view>
<view class="box">
<scroll-view
scroll-y
class="scroll-view"
>
<view class="box-content">
<GlCell
:formList="formList"
:formData="orderObj"
@inputBlur="inputBlur"
@handleCell="handleCell"
:titleList="titleList"
@collapseAll="collapseAll"
<template v-if="loadComplete">
<view class="box">
<scroll-view
scroll-y
class="scroll-view"
>
<view
class="box-content"
:key="viewKey"
>
<template #goodsHtml>
恒河猴
</template>
<template #uploadHtml>
恒河猴1
</template>
</GlCell>
<GlCell
:formList="formList"
:formData="orderObj"
@inputBlur="inputBlur"
@handleCell="handleCell"
:titleList="titleList"
@collapseAll="collapseAll"
collapseControl
@radioChange="radioChange"
>
<template #goodsHtml>
<EquityGoods
:externalData="orderObj"
ref="goodsRef"
/>
</template>
<template #tireHtml>
<template v-if="orderObj.tireFlag == 1">
<EquityTire
:externalData="orderObj"
ref="tireRef"
/>
</template>
</template>
<template #uploadHtml>
<EquityUpload
:externalData="orderObj"
ref="uplopdRef"
/>
</template>
<template #conversion>
<template v-if="orderObj.inclueType == 1">
<EquityConversion
:externalData="orderObj"
ref="conversionRef"
/>
</template>
</template>
</GlCell>
</view>
<view class="btns flex">
<view
class="btn save"
@click="handleEditSave"
>存草稿</view>
<view
@click="submit"
class="btn"
>确认提交</view>
</view>
</scroll-view>
</view>
</view>
<view class="btns flex">
<view
class="btn save"
@click="submit(0)"
>存草稿</view>
<view
@click="submit(1)"
class="btn"
>确认提交</view>
</view>
</scroll-view>
</view>
</template>
<order-popup
ref="orderPopup"
:data="orderObj"
@onConfirm="onConfirm"
:popupType="popupType"
/>
<uni-calendar
ref="calendar"
:insert="false"
:clearDate="false"
:endDate="endDate"
@confirm="confirmCalendar($event,'billingDate')"
:date="orderObj.billingDate"
showBottomBtn
/>
<uni-calendar
ref="futureCalendar"
:insert="false"
:clearDate="false"
:startDate="endDate"
@confirm="confirmCalendar($event,'effectiveDate')"
:date="orderObj.effectiveDate"
showBottomBtn
/>
<NoticePopup
ref="reportNotice"
:title="noticeObj.title"
:text="noticeObj.text"
:type="noticeObj.type || 'success'"
:buttons="noticeObj.buttons"
></NoticePopup>
</view>
</template>
<script type='text/ecmascript-6'>
import utils from '@/utils/utils'
import { EQUITY_FORM_LIST, EQUITY_FORM_TITLE_LIST, popupTypeEnum } from '../contant'
import {
EQUITY_FORM_LIST
, EQUITY_FORM_TITLE_LIST,
EQUITY_POPUP_ENUM,
tireObjList,
EQUITY_FORM_RULE,
energyFormRule,
oilFormRule,
extendServiceFormRule
} from '../contant'
import GlCell from '@/components/Form/GlCell.vue'
import OrderPopup from '@/components/OrderPopup/index.vue'
import dayjs from 'dayjs'
import EquityGoods from './EquityForm/EquityGoods.vue'
import EquityTire from './EquityForm/EquityTire.vue'
import EquityUpload from './EquityForm/EquityUpload.vue'
import EquityConversion from './EquityForm/EquityConversion.vue'
import NP from 'number-precision'
import NoticePopup from '@/components/NoticePopup.vue'
import { validateVin, formatVinInput } from '@/utils/vinVaildate'
const codeToAttr = {
YB0001: 'invoice',
YB0003: 'driveFront',
YB0004: 'driveBack',
YB0002: 'contract',
YB0005: 'other',
QS0001: 'retrofitInvoice',
QS0002: 'retrofit'
},
attrToCode = {
invoice: 'YB0001',
driveFront: 'YB0003',
driveBack: 'YB0004',
contract: 'YB0002',
other: 'YB0005',
retrofitInvoice: 'QS0001',
retrofit: 'QS0002'
},
ybAttachmentFlagTips = {
YB0001: '购车发票',
YB0003: '行驶证主页',
YB0004: '行驶证副页',
YB0002: '合同购买时里程数',
YB0005: '其他',
},
qsFlagTips = {
QS0001: '发票或收据',
QS0002: '加改装部位'
}
export default {
name: 'CreateEquity',
components: {
GlCell,
OrderPopup
OrderPopup,
EquityGoods,
EquityTire,
EquityUpload,
EquityConversion,
NoticePopup
},
props: {
transmissionOfData: {
type: Object,
default: () => null
}
},
data () {
return {
formList: utils.deepClone(EQUITY_FORM_LIST),
titleList: utils.deepClone(EQUITY_FORM_TITLE_LIST),
orderObj: {
carSeriesId: ''
endDate: dayjs().format('YYYY-MM-DD'),
equityFormRule: utils.deepClone(EQUITY_FORM_RULE),
orderObj: {},
loadComplete: false,
popupType: 0,
viewKey: Date.now(),
conSecondObj: {
vin: ''
},
noticeObj: {},
validateState: true
}
},
watch: {
transmissionOfData: {
handler (val) {
if (val && val.contractNo) this.getServiceInfoDetail(val.contractNo)
},
popupType: 0
deep: true,
immediate: true
}
},
computed: {
orderPopupRef () {
return this.$refs.orderPopup
}
},
mounted () {
this.getServiceInfoDetail()
},
methods: {
// 车架号动态校验
validateVin () {
let carVinVal = this.orderObj.vin;
if (carVinVal) {
this.orderObj.carVin = formatVinInput(carVinVal)
validateVin(this.orderObj.carVin).then(result => {
console.log("validateVin", result);
let { valid } = result.data;
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
}).catch(err => {
console.log("validateVinErr", result);
})
}
},
// 单选框change事件
radioChange (e, val) {
this.$set(this.orderObj, val.value, e.detail.value)
this.formList.map(k => {
k.map(i => {
if (i.value == val.value) i.current = e.detail.value
})
})
this.viewKey = Date.now()
},
handleCell (val) {
console.log(val)
this.popupType = Object.keys(popupTypeEnum).find(key => popupTypeEnum[key].key === val.key) * 1
this.$refs.orderPopup.open()
if (['calendar', 'futureCalendar'].includes(val.key)) return this.$refs[val.key]?.open()
this.popupType = Object.keys(EQUITY_POPUP_ENUM).find(key => EQUITY_POPUP_ENUM[key].key === val.key) * 1
this.orderPopupRef.open()
},
onConfirm (val) {
console.log(val)
const { chooseContent, popupType } = val,
_typeValue = EQUITY_POPUP_ENUM[popupType]
console.log(_typeValue)
if (_typeValue.key == 'carBrand') {
Object.assign(this.orderObj, chooseContent)
this.$set(this.orderObj, 'carBrandText',
`${chooseContent.vehicleBrandName}/${chooseContent.vehicleSubBrandName}/${chooseContent.vehicleSeriesName}/${chooseContent.vehicleShapeName}`)
return
} else if (_typeValue.options) {
this.$set(this.orderObj, _typeValue.targetIdKey, chooseContent[_typeValue.sourceIdKey || 'optionId'])
this.$set(this.orderObj, _typeValue.targetNameKey, chooseContent[_typeValue.sourceNameKey || 'optionLabel'])
return
}
this.$set(this.orderObj, _typeValue.value, chooseContent)
this.viewKey = Date.now()
},
inputBlur (e, val) {
this.orderObj[val.value] = this.orderObj[val.value]
// VIN车架号动态校验:车架号字段,动态转换为大写
if (val.value === 'vin') this.validateVin()
},
async getServiceInfoDetail () {
const data = await uni.$api.equityApi.getServiceInfoDetail({
contractNo: 'car998467117191905280'
})
console.log(data)
async getServiceInfoDetail (contractNo) {
try {
uni.showLoading({
title: '加载中...',
mask: true
})
const data = await uni.$api.equityApi.getServiceInfoDetail({
contractNo
})
if (!data) throw '获取数据失败'
if (data.ybAttachmentFlag != 0) this.formList[3] = []
if (data.qsFlag != 1) this.formList[4] = []
this.orderObj.goodInfoList = data.goodInfoList
this.orderObj.tireFlag = data.tireFlag
let carInfo = {},
params = {}
if (data.vehicleShapeId) {
carInfo = {
carBrandText: `${data.vehicleBrandName}/${data.vehicleSubBrandName}/${data.vehicleSeriesName}/${data.vehicleShapeName}`,
vehicleShapeId: data.vehicleShapeId,
vehicleShapeName: data.vehicleShapeName,
vehicleSeriesId: data.vehicleSeriesId,
vehicleSeriesName: data.vehicleSeriesName,
vehicleBrandId: data.vehicleBrandId,
vehicleBrandName: data.vehicleBrandName,
vehicleSubBrandId: data.vehicleSubBrandId,
vehicleSubBrandName: data.vehicleSubBrandName,
}
}
if (!data.customerType) data.customerType = 1
if (data.customerType) {
const customerTypeEnum = this.orderPopupRef.componentObject[21].options
params = {
customerType: data.customerType,
customerTypeName: customerTypeEnum.find(i => i.optionId == data.customerType).optionLabel
}
}
if (data.cardType) {
const cardTypeEnum = this.orderPopupRef.componentObject[22].options
params.cardType = data.cardType
params.cardTypeName = cardTypeEnum.find(i => i.optionId == data.cardType).optionLabel
}
if (data.buyCarType == null) data.buyCarType = 1
if (data.buyCarType != null) {
const buyCarTypeEnum = this.orderPopupRef.componentObject[23].options
params.buyCarType = data.buyCarType
params.buyCarTypeName = buyCarTypeEnum.find(i => i.optionId == data.buyCarType).optionLabel
}
let priceList = ['actualSalesPrice']
data.goodInfoList.map((item, idx) => {
if (item.actualSalesPrice) item.actualSalesPrice = NP.divide(Number(item.actualSalesPrice), 100).toFixed(2)
// priceList.forEach(k => {
// data.goodInfoList[idx][k] = item[k] === null ? null : (item[k] / 100).toFixed(2)
// })
if (item.vehicleRegistrationDate) {
item.vehicleRegistrationDate = dayjs(item.vehicleRegistrationDate).format('YYYY-MM-DD')
}
if (item.buyDate) {
item.buyDate = dayjs(item.buyDate).format('YYYY-MM-DD')
}
if (item.qualityBeginDate) {
item.qualityBeginDate = dayjs(item.qualityBeginDate).format('YYYY-MM-DD')
}
if (item.itemsCode == 'YB0003') {
item.gearbox = item.gearbox || ''
item.vehicleNature = typeof item.vehicleNature == 'number' ? item.vehicleNature : 1
let val = constantData.vehicleNatureList.find(k => k.optionId == item.vehicleNature)
if (val) {
item.vehicleNatureName = val.optionLabel
}
}
if (item.printType == 2 && !['YB0001', 'YB0002', 'YB0003'].includes(item.itemsCode)) item.displacementPowerFlag = item.displacementPowerFlag || 0
})
// 判断购买商品是否全部是延保allWarrantyFlag
const allWarrantyFlag = data?.goodInfoList?.some(v => v.printType != 2),
imgObj = {}
Object.keys(codeToAttr).map(key => {
if (codeToAttr[key] == 'other') imgObj[codeToAttr[key]] = []
else imgObj[codeToAttr[key]] = ''
})
this.formList.map(i => {
i.map(e => {
if (e.value == 'effectiveDate') e.hidden = !allWarrantyFlag //false 显示生效日期 true不显示
})
})
/**图片 */
if ((data.ybAttachmentFlag == 0 || data.qsFlag == 1) && data.attachmentList?.length) {
data.attachmentList.forEach(item => {
if (item.attachmentCode == 'YB0005') imgObj[codeToAttr[item.attachmentCode]].push(item.attachmentFile)
else imgObj[codeToAttr[item.attachmentCode]] = item.attachmentFile
})
}
if (data.tireFlag == 0) {
const list = ['tireBrand', 'tireScale', 'leftFrontDTO', 'leftFrontBatch', 'rightFrontDTO', 'rightFrontBatch', 'leftRearDTO', 'leftRearBatch', 'rightRearDTO', 'rightRearBatch']
list.map(key => {
this.equityFormRule[key][0].required = false
})
}
/**轮胎 */
if (data.attributeList?.length) {
data.attributeList.map((e, idx) => {
if (e.attributeValue) data[tireObjList[idx].attr] = e.attributeValue
})
}
let inclueType = data.addOnsFlag == 0 ? 2 : 1
Object.assign(this.orderObj, {
...data,
vin: data.vin,
invoicePrice: NP.divide(Number(data.invoicePrice || 0), 100).toFixed(2),
seatesNum: data.seatesNum,
seat: data.seatesNum,
engineNo: data.engineNo,
vehicleColor: data.vehicleColor,
billingDate: data.billingDate ? dayjs(data.billingDate).format('YYYY-MM-DD') : dayjs().format('YYYY-MM-DD'),
customerName: data.customerName,
customerPhone: data.customerPhone,
cardNo: data.cardNo,
customerAddress: data.customerAddress,
goodInfoList: data.goodInfoList,
effectiveDate: data.effectiveDate ? dayjs(data.effectiveDate).format('YYYY-MM-DD') : dayjs().add(1, 'day').format('YYYY-MM-DD'),
tireFlag: data.tireFlag,
compensationName: data.compensationName || data.customerName,
attachmentList: data.attachmentList || [],
merchantName: data.merchantName,
merchantPhone: data.merchantPhone,
merchantAddress: data.merchantAddress,
imgObj,
inclueType,
...carInfo,
...params
})
this.formList[4].map(e => {
if (e.value == 'inclueType') e.current = inclueType
})
console.log(JSON.parse(JSON.stringify(this.orderObj)))
this.viewKey = Date.now()
this.loadComplete = true
uni.hideLoading()
} catch (error) {
uni.hideLoading()
this.viewKey = Date.now()
this.loadComplete = true
if (error) uni.showToast({
title: error,
icon: 'none'
})
}
},
collapseAll (index) {
this.titleList[index].collapseAll = !this.titleList[index].collapseAll
}
},
confirmCalendar (e, key) {
this.orderObj[key] = e.fulldate
this.viewKey = Date.now()
},
async submit (operationType) {
// VIN车架号-动态校验
const carVin = this.orderObj.vin
if (carVin) {
// 前置判断
if (carVin.length !== 17) {
uni.showToast({ title: '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)', icon: 'none' })
return false
}
// 根据接口校验结果判断
if (carVin.length === 17 && !this.validateState) {
uni.showToast({ title: '车架号校验不匹配,请核对后重新输入', icon: 'none' })
return false
}
}
uni.showLoading({
title: '提交中...',
mask: true
})
const { orderObj, conSecondObj } = this,
{ goodsRef, tireRef, uplopdRef, conversionRef } = this.$refs
let params = utils.deepClone(orderObj),
attachmentList = [],
attributeList = []
if (tireRef) {
let { tireObj } = tireRef
tireObjList.map(item => {
if (tireObj[item.attr]) {
attributeList.push({
attributeValue: tireObj[item.attr],
sort: item.sort,
attributeGroup: item.attributeGroup,
attributeName: item.attributeName
})
params[item.attr] = tireObj[item.attr]
}
})
params.attributeList = attributeList
params.tireBrand = tireObj.tireBrand
params.tireScale = tireObj.tireScale
}
if (goodsRef) {
let goodInfoList = utils.deepClone(goodsRef.goodInfoList)
goodInfoList.map(item => {
item.actualSalesPrice = NP.times(Number(item.actualSalesPrice), 100)
})
params.goodInfoList = goodInfoList
}
if (uplopdRef || conversionRef) {
let imgObj = {}
if (uplopdRef) imgObj = uplopdRef.imgObj
if (conversionRef && params.inclueType == 1) imgObj = {
...imgObj,
...conversionRef.imgObj
}
Object.keys(imgObj).map(key => {
if (Array.isArray(imgObj[key])) {
imgObj[key].map(item => {
attachmentList.push({
attachmentCode: attrToCode[key],
attachmentType: 'IMG',
attachmentFile: item
})
})
} else {
attachmentList.push({
attachmentCode: attrToCode[key],
attachmentType: 'IMG',
attachmentFile: imgObj[key]
})
}
})
}
params.invoicePrice = NP.times(Number(params.invoicePrice), 100)
params.attachmentList = attachmentList
if (operationType == 0) {
this.confirm(params, operationType)
return
}
console.log(params)
if (!this.checkOrder(params)) return uni.hideLoading()
const { code, message } = await uni.$api.equityApi.checkVinBuyEquityOrder({
vin: orderObj.vin
})
if (code == 0) {
this.confirm(params, operationType)
} else if (code == '-2') {
if (conSecondObj.vin == orderObj.vin) {
this.confirm(params, operationType)
this.conSecondObj.vin = ''
} else {
this.conSecondObj.vin = orderObj.vin
this.openNotice(message, params)
}
} else this.openNotice(message, params)
},
checkOrder (params) {
let { equityFormRule } = this
try {
Object.keys(equityFormRule).map(key => {
let [nullCheck, validatorCheck] = equityFormRule[key]
if (nullCheck.required) {
if (!params[key]) throw equityFormRule[key][0].message
} else {
if (validatorCheck && validatorCheck.validator) {
const res = validatorCheck.validator('', params[key])
console.log(res, key)
if (res && res.message) throw res.message
}
}
})
params.goodInfoList?.map(item => {
if (item.printType == 2) {
if (item.itemsCode == 'YB0003') Object.keys(oilFormRule).map(key => {
let [nullCheck, validatorCheck] = oilFormRule[key]
if (nullCheck.required) {
if (!item[key]) throw oilFormRule[key][0].message
else {
if (validatorCheck && validatorCheck.validator) {
const res = validatorCheck.validator('', item[key])
if (res && res.message) throw res.message
}
}
}
})
if (item.itemsCode == 'YB0001' || item.itemsCode == 'YB0002') Object.keys(energyFormRule).map(key => {
let [nullCheck, validatorCheck] = energyFormRule[key]
if (nullCheck.required) {
if (!item[key]) throw energyFormRule[key][0].message
} else {
if (validatorCheck && validatorCheck.validator) {
const res = validatorCheck.validator('', item[key])
if (res && res.message) throw res.message
}
}
})
if (item.itemsCode != 'YB0001' && item.itemsCode != 'YB0002' && item.itemsCode != 'YB0003') Object.keys(extendServiceFormRule).map(key => {
let [nullCheck, validatorCheck] = extendServiceFormRule[key]
if (nullCheck.required) {
if (!item[key]) throw extendServiceFormRule[key][0].message
} else {
if (validatorCheck && validatorCheck.validator) {
const res = validatorCheck.validator('', item[key])
if (res && res.message) throw res.message
}
}
})
}
})
if (params.ybAttachmentFlag == 0 || params.qsFlag == 1) {
if (params.ybAttachmentFlag == 0) {
params.attachmentList.map(e => {
let item = ybAttachmentFlagTips[e.attachmentCode]
if (e.attachmentCode != 'YB0005') {
if (!e.attachmentFile) throw `请上传${item}`
}
})
}
if (params.qsFlag == 0) {
params.attachmentList.map(e => {
let item = qsFlagTips[e.attachmentCode]
if (!e.attachmentFile) throw `请上传${item}`
})
}
}
} catch (error) {
console.log(error, '===')
uni.showToast({
title: error,
icon: 'none'
})
return false
}
return true
},
async confirm (paramsData, operationType) {
try {
let params = utils.deepClone(paramsData)
this.$refs.reportNotice.close()
console.log(params, '===')
// 0草稿,1提单
params.operationType = operationType
params.addOnsFlag = params.inclueType == 2 ? 0 : 1
params.seatesNum = params.seat
delete params.imgObj
delete params.inclueType
delete params.seat
uni.showLoading({
mask: true
})
const { code, message } = await uni.$api.equityApi.addEquityOrder(params)
if (code == 0) {
if (operationType == 0) {
uni.hideLoading()
uni.showToast({
title: '保存成功',
icon: 'none',
mask: true
})
setTimeout(() => {
this.$emit('jump', 'EquityManagement')
}, 1500)
} else {
uni.showLoading({
mask: true
})
setTimeout(async () => {
// 从URL获取文件名
const getFileNameFromUrl = (url) => {
return url.split('/').pop().split('?')[0] || '未知文件'
}
const { contractNo } = params,
url = await uni.$api.equityApi.printContract({ contractNo }),
fileName = getFileNameFromUrl(url),
type = 3
if (!url) throw '获取合同失败'
this.noticeObj = {
title: '提单成功',
text: '提单合同支持分享或保存',
type: 'success',
buttons: [
{
text: '查看合同',
type: 'primary',
callback: _ => {
this.$refs.reportNotice.close()
this.$emit('jump', 'EquityManagement')
// 跳转到预览页面
uni.navigateTo({
url: `/pages/common/filePreview?fileUrl=${encodeURIComponent(url)}&fileType=${type}&fileName=${encodeURIComponent(fileName)}`
})
}
}
]
}
setTimeout(() => {
uni.hideLoading()
this.$refs.reportNotice.open()
}, 100)
}, 1500)
}
} else throw message
} catch (error) {
console.log(error)
uni.hideLoading()
if (error) uni.showToast({
title: error,
icon: 'none'
})
}
},
openNotice (message, params) {
uni.hideLoading()
let title = '出单失败',
btnText = '重新提单',
callbackFun = () => { }
if (message.includes('该车架已经购买过')) {
title = '信息确认'
btnText = '继续出单'
callbackFun = () => {
this.confirm(params, 1)
}
}
this.noticeObj = {
title,
text: message,
type: 'warning',
buttons: [
{
text: btnText,
type: 'primary',
callback: callbackFun
}
]
}
this.$nextTick(() => this.$refs.reportNotice.open())
},
}
}
</script>
......
......@@ -508,7 +508,6 @@ export default {
},
// 输入框失去焦点事件
inputBlur (e, val) {
console.log("SSSSSS");
console.log(e, val)
if (val.value == 'price') {
this.orderObj[val.value] = parseFloat(this.orderObj[val.value]) > 2000000 ? 2000000 : this.orderObj[val.value]
......
......@@ -680,35 +680,38 @@ export default {
this.dateKey.staffCount = Date.now()
},
handleBlur (e, i) {
let { value } = e.detail
let { value } = e.detail,
{ orderObj, userInfo } = this,
key = i.value
if (value) {
let { orderObj, userInfo } = this
let key = i.value,
numbers = value.match(/\d+/g)
let numbers = value.match(/\d+/g)
numbers = numbers ? numbers.join('') : ''
if (numbers.length > 1) numbers = numbers.replace(/^0+/, '')
this.orderObj[key] = Math.min(Math.max(Number(numbers), 0), 100).toString()
this.dateKey[key] = Date.now()
console.log(key)
if (
this.isNotEmpty(orderObj.recordStaffCount) &&
orderObj.recordStaffCount != value &&
orderObj.lastStaffUuid &&
userInfo.uuid != orderObj.lastStaffUuid
) {
this.noticeObj = {
title: '重要提示',
text: `今日驻店人数与 ${orderObj.lastStaffName} 提交不一致,再次确认!不一致提交日报时,今日驻店人数将被清空。`,
type: 'warning',
buttons: [
{
text: '确定',
type: 'primary',
}
]
}
this.$nextTick(() => this.$refs.reportNotice.open())
} else {
this.orderObj[key] = ''
this.dateKey[key] = Date.now()
}
if (
this.isNotEmpty(orderObj.recordStaffCount) &&
orderObj.recordStaffCount != value &&
orderObj.lastStaffUuid &&
userInfo.uuid != orderObj.lastStaffUuid
) {
this.noticeObj = {
title: '重要提示',
text: `今日驻店人数与 ${orderObj.lastStaffName} 提交不一致,再次确认!不一致提交日报时,今日驻店人数将被清空。`,
type: 'warning',
buttons: [
{
text: '确定',
type: 'primary',
}
]
}
this.$nextTick(() => this.$refs.reportNotice.open())
}
},
isNotEmpty (value) {
......@@ -720,43 +723,45 @@ export default {
)
},
handleCarInputBlur (e, i, item, index) {
const { orderObj,
let { orderObj,
userInfo,
carBandList
} = this
let { value } = e.detail
} = this,
{ value } = e.detail,
{ key, max } = i
if (value) {
let { key, max } = i,
numbers = value.match(/\d+/g)
let numbers = value.match(/\d+/g)
numbers = numbers ? numbers.join('') : ''
if (numbers.length > 1) numbers = numbers.replace(/^0+/, '')
item[key] = Math.min(Math.max(Number(numbers), 0), max).toString()
this.dateKey[`${key}_${index}`] = Date.now()
if (['deliveryCount', 'notDeliveryCount'].includes(key) && orderObj.onBreak == 'N') {
let checkName = `${key}Record`,
checkValue = carBandList[index][checkName]
if (
this.isNotEmpty(item[key]) &&
this.isNotEmpty(carBandList[index][checkName]) &&
checkValue != value &&
orderObj.lastStaffUuid &&
userInfo.uuid != orderObj.lastStaffUuid) {
let context = i.label
this.noticeObj = {
title: '重要提示',
text: `${context}与 ${orderObj.lastStaffName} 提交不一致,再次确认!不一致提交日报时,${context}将被清空。`,
type: 'warning',
buttons: [
{
text: '确定',
type: 'primary',
}
]
}
this.$nextTick(() => this.$refs.reportNotice.open())
} else {
item[key] = ''
this.dateKey[`${key}_${index}`] = Date.now()
}
if (['deliveryCount', 'notDeliveryCount'].includes(key) && orderObj.onBreak == 'N') {
let checkName = `${key}Record`,
checkValue = carBandList[index][checkName]
if (
this.isNotEmpty(item[key]) &&
this.isNotEmpty(carBandList[index][checkName]) &&
checkValue != value &&
orderObj.lastStaffUuid &&
userInfo.uuid != orderObj.lastStaffUuid) {
let context = i.label
this.noticeObj = {
title: '重要提示',
text: `${context}与 ${orderObj.lastStaffName} 提交不一致,再次确认!不一致提交日报时,${context}将被清空。`,
type: 'warning',
buttons: [
{
text: '确定',
type: 'primary',
}
]
}
this.$nextTick(() => this.$refs.reportNotice.open())
}
console.log(key)
}
},
async submit () {
......@@ -770,7 +775,7 @@ export default {
orderObj.sceneType = 0
orderObj.brandDataList = carBandList
if (orderObj.pickerValue == 0) {
if (orderObj.staffCount == null) throw {
if (['', null].includes(orderObj.staffCount)) throw {
message: '今日驻店人数(按店)',
refId: 'staffCount'
}
......
......@@ -34,9 +34,9 @@
<view v-if="((!userInfo.isSuper && userInfo.userType == 2 && orderCardDetail.orderStatus != 4) || orderCardDetail.orderStatus == 2) && isOrder">
<view class="btn_box_class">
<view class="order-btn default-btn" @click="handleSignature">{{ orderCardDetail.customerNameUrl ? '修改客户签名' : '补录客户签名' }}</view>
<view v-if="orderCardDetail.orderStatus == '2'" class="order-btn default-btn" @click="handlePreviewContract">下载合同</view>
<view v-if="orderCardDetail.orderStatus == '2'" class="order-btn" @click="handlePreviewContract">{{ btnTxt[orderCardDetail.orderStatus] }}</view>
<view v-else class="order-btn" @click="handleRecordOrder">{{ btnTxt[orderCardDetail.orderStatus] }}</view>
<view v-if="orderCardDetail.orderStatus == '2'" class="order-btn default-btn" @click.stop="handlePreviewContract('download')">下载合同</view>
<view v-if="orderCardDetail.orderStatus == '2'" class="order-btn" @click.stop="handlePreviewContract()">{{ btnTxt[orderCardDetail.orderStatus] }}</view>
<view v-else class="order-btn" @click.stop="handleRecordOrder">{{ btnTxt[orderCardDetail.orderStatus] }}</view>
</view>
</view>
</view>
......@@ -80,113 +80,6 @@ export default {
},
status() {
return order_mixins.data.equityStatus || {}
},
buttonConfig() {
const config = {
showMoreBtn: false,
showReceptionBtn: false,
primaryButton: null,
secondaryButtons: []
}
const order = this.orderCardDetail
const localUser = this.localUserInfo
// 超管或商户类型1不可操作
if (localUser?.isSuper || localUser?.userType !== 2) {
config.showMoreBtn = order.showInvoiceEntrance || ((order.orderStatus == 3 || order.orderStatus == 5 || (order.orderStatus == 6 && order.refundAmount)) && this.isOrder)
return config
}
// 待上传合同协议且是已支付的订单 (zyPayStatus == 1 且 orderStatus 为 3/4/7)
if (order.zyPayStatus == 1 && (order.orderStatus == 3 || order.orderStatus == 4 || order.orderStatus == 7)) {
config.showMoreBtn = order.showInvoiceEntrance || order.invoicing == 2
config.showReceptionBtn = order.orderStatus != '0'
config.primaryButton = { text: '上传协议', type: 'primary', dataType: 'upload' }
if (order.equityOrderStatus == 0 && order.equityGoodsFlag == 1) {
config.secondaryButtons.push({ text: '去处理', type: 'secondary', dataType: 'handle' })
}
return config
}
// 其他情况 - 订单状态不是4,11,9
if (order.orderStatus != '4' && order.orderStatus != 11 && order.orderStatus != 9) {
config.showMoreBtn = order.showInvoiceEntrance || ((order.orderStatus == 3 || order.orderStatus == 5 || order.orderStatus == 6) && this.isOrder)
config.showReceptionBtn = order.orderStatus != '0'
// 修改协议按钮
if (order.canUpdateZyPayUrl == 1 && order.zyPayStatus == 2) {
config.secondaryButtons.push({ text: '修改协议', type: 'secondary', dataType: 'upload' })
}
if (this.isOrder) {
// 待跟进或待支付状态
if (order.orderStatus == '-1' || order.orderStatus == '0') {
config.primaryButton = {
text: this.btnTxt[order.orderStatus] || (order.orderStatus == '-1' ? '去报价' : '去报价'),
type: 'primary',
dataType: 'price'
}
}
// 非已完成状态
else if (order.orderStatus != 6) {
// 战败状态
if (order.orderStatus == '2') {
config.secondaryButtons.push({ text: '战败', type: 'secondary', dataType: 'defeat' })
config.primaryButton = {
text: this.btnTxt[order.orderStatus] || '去支付',
type: 'primary',
dataType: 'pay'
}
}
// 已支付状态
else if (order.orderStatus == '3') {
if (order.equityGoodsFlag == '1') {
// config.secondaryButtons.push({ text: '客户签名', type: 'secondary', dataType: 'signature' })
}
// 已支付未录单
if (order.equityOrderStatus == '0' && order.equityGoodsFlag == '1') {
config.primaryButton = {
text: this.btnTxt[order.orderStatus] || '去处理',
type: 'primary',
dataType: 'handle'
}
}
}
// 已完成状态
else if (order.orderStatus == '5') {
// 已完成未录单
if (order.equityOrderStatus == '0' && order.equityGoodsFlag == '1') {
config.primaryButton = {
text: this.btnTxt[order.orderStatus] || '去处理',
type: 'primary',
dataType: 'handle'
}
}
}
// 其他状态
else {
config.primaryButton = {
text: this.btnTxt[order.orderStatus] || '处理',
type: 'primary',
dataType: 'default'
}
}
}
// 除待跟进工单,支付方式为门店收款的订单可以在工单详情页面展示撤销按钮
if (!(order.orderStatus == '-1' && order.selectPayType == 2)) {
config.secondaryButtons.push({ text: '撤销', type: 'secondary', dataType: 'revoke' })
}
}
} else {
// 订单状态为4,11,9的情况
config.showMoreBtn = order.showInvoiceEntrance || ((order.orderStatus == 3 || order.orderStatus == 5 || order.orderStatus == 6) && this.isOrder)
}
return config
}
},
data() {
......@@ -245,81 +138,65 @@ export default {
}
})
},
handleClickBtn(type) {
switch (type) {
case 'upload':
// 处理上传协议
this.uploadContract()
break
case 'handle':
// 处理去处理
this.createorder()
break
case 'price':
// 处理去报价
this.$emit('jump', 'CreateOrder', { paramsData: this.orderCardDetail, type: 'CreateOrder' })
break
case 'pay':
this.$emit('openPay', this.orderCardDetail)
// 处理去支付
break
case 'defeat':
// 处理战败
this.defeatOrder()
break
case 'revoke':
// 处理撤销
this.revokeOrder()
break
case 'default':
// 处理默认情况
break
default:
// 其他情况
break
}
},
// 撤销工单方法
revokeOrder() {
// 配置弹窗按钮
this.$refs.notice.buttonsList = [
{
text: '取消',
type: 'default',
callback: () => {
this.transmissionOfData = null
this.$refs.notice.close()
}
},
{
text: '撤销',
type: 'primary',
callback: async () => {
// 校验订单是否可撤销(在退款流程中无法撤销)
let refundStep = await uni.$api.equityApi.getOrderRefundStep({ orderCode: this.orderCardDetail.payId })
if (refundStep?.data == 'Y') return _this.showRefundAlert()
this.repeal(this.orderCardDetail.id)
}
}
]
// 打开弹窗
this.$refs.notice.open()
},
//修改客户信息
jumpUpdate() {
this.$emit('jump', 'UpdateOrderInfo', { paramsData: this.orderCardDetail, type: 'UpdateOrderInfo' })
// 录单/重新录单
async handleRecordOrder(e) {
// 校验是否填写昨日日报
if (await this.checkDailyReport()) return
this.$emit('jump', 'CreateEquity', { contractNo: this.orderCardDetail.contractNo, type: 'CreateEquity' })
},
//去处理
createorder() {
this.$emit('jump', 'CreateOrder', { paramsData: this.orderCardDetail, type: 'CreateOrder' })
},
//上传协议
uploadContract() {
this.$refs.contractPopupRef.open(this.orderCardDetail)
// 补录客户签名
handleSignature() {
this.$emit('jump', 'SignName', { paramsData: this.orderCardDetail, type: 'SignName' })
},
//战败
defeatOrder() {
this.$refs.defeatOrderPopup.open(this.orderCardDetail)
// 预览文件
handlePreviewContract(type) {
let params = {
contractNo: this.orderCardDetail.contractNo
// contractNo: 'car679883190869172224' //开发测试用
}
console.log(this.orderCardDetail)
uni.showLoading({
title: '加载中...',
mask: true
})
uni.$api.equityApi
.equityOrderList({ orderId: this.orderCardDetail.orderId })
.then(res => {
if (res.length == 1) {
uni.$api.equityApi
.printContract(params)
.then(res => {
console.log(res)
uni.hideLoading()
const url = res.url || res
if (type == 'download') {
this.handleDownload(url)
} else {
const fileName = this.getFileNameFromUrl(res.url || res)
const type = 3
console.log(url, fileName, type)
// 跳转到预览页面
uni.navigateTo({
url: `/pages/common/filePreview?fileUrl=${encodeURIComponent(url)}&fileType=${type}&fileName=${encodeURIComponent(fileName)}`
})
}
})
.catch(err => {
uni.hideLoading()
})
} else {
uni.hideLoading()
this.$emit('jump', 'PreviewList', { paramsData: res, type: 'PreviewList' })
}
})
.catch(err => {
uni.hideLoading()
})
},
showRefundAlert(type) {
const text = type == 'error' ? '订单已发起退款,禁止标记为错误工单!如需标记错误请联系总部运营。' : '订单已发起退款,禁止撤销!如需撤销请联系总部运营。'
......@@ -330,35 +207,6 @@ export default {
confirmText: '好的'
})
},
repeal(id, revokeReason) {
uni.showLoading({
mask: true
})
let _this = this
let params = {
id
}
if (revokeReason) {
params.revokeReason = revokeReason
}
uni.$api.equityApi.cancelOrderById(params).then(_res_ => {
if (_res_) {
uni.hideLoading()
uni.showToast({
title: '操作成功',
icon: 'success'
})
this.transmissionOfData = null
this.$refs.notice.close()
setTimeout(() => {
this.$emit('refresh')
// _this.getList();
}, 500)
} else {
uni.hideLoading()
}
})
},
confirmSelection() {
if (this.textareaValue) {
uni.$api.equityApi
......@@ -384,87 +232,35 @@ export default {
})
}
},
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)
// 从URL获取文件名
getFileNameFromUrl(url) {
return url.split('/').pop().split('?')[0] || '未知文件'
},
getFileTypeFromUrl(url) {
const ext = url.split('.').pop().toLowerCase()
return ext === 'pdf' ? 'pdf' : 'image'
},
handleDownload(url) {
if (!url) {
uni.showToast({ title: '没有合同', icon: 'none' })
return
}
console.log(urls)
const that = this
if (this.orderCardDetail.zyPayStatus == 2 && this.orderCardDetail.canUpdateZyPayUrl == 1) {
uni.showModal({
title: '修改确认',
content: '本次操作将永久替换原图或协议(仅限1次修改权限),请确认是否更新?',
confirmText: '确定',
confirmColor: '#347BFF',
success(res) {
if (res.confirm) {
uni.showLoading({
mask: true
})
console.log(that.orderCardDetail)
uni.$api.equityApi.updateZyInfo({ id: that.orderCardDetail?.id, zyPayUrl: urls.join(',') }).then(res => {
uni.hideLoading()
uni.showToast({
title: '提交成功',
icon: 'none'
})
setTimeout(() => {
that.$emit('refresh')
// _this.getList();
}, 500)
})
}
}
})
} else {
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.downloadFile({
url: url,
success: res => {
if (res.statusCode === 200) {
uni.showToast({ title: '保存成功', icon: 'none' })
var filePath = res.tempFilePath
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function (res) {
console.log('打开文档成功')
}
})
uni.$api.equityApi
.updateCustomerInfo({
...orderInfo,
zyPayUrl: urls.join(',')
})
.then(result => {
console.log(result, 'resultresult')
this.$refs.contractPopupRef.close()
uni.hideLoading()
uni.showToast({
title: '提交成功',
icon: 'none'
})
setTimeout(() => {
this.$emit('refresh')
// _this.getList();
}, 500)
})
.catch(err => {
console.log(err)
uni.hideLoading()
})
})
.catch(err => {
uni.hideLoading()
})
}
}
}
})
}
},
get methods() {
......
<template>
<view
class="upload-content"
:key="viewKey"
>
<view class="upload-box">
<view class="label">发票或收据</view>
<view class="upload-item">
<template v-if="imgObj.retrofitInvoice">
<image
class="img"
:src="imgObj.retrofitInvoice"
@click="previewMedia(imgObj.retrofitInvoice)"
/>
<view class="del flex">
<uni-icons
type="closeempty"
:size="10"
color="#fff"
@click="delImage('retrofitInvoice')"
></uni-icons>
</view>
</template>
<template v-else>
<view
class="upload-component"
@click="chooseImage('retrofitInvoice')"
>
<uni-icons
type="plusempty"
:size="22"
color="#347BFF"
class="icon"
></uni-icons>
<view class="text">上传照片</view>
</view>
</template>
</view>
</view>
<view class="upload-box">
<view class="label">加改装部位照片</view>
<view class="upload-item">
<template v-if="imgObj.retrofit">
<image
class="img"
:src="imgObj.retrofit"
@click="previewMedia(imgObj.retrofit)"
/>
<view class="del flex">
<uni-icons
type="closeempty"
:size="10"
color="#fff"
@click="delImage('retrofit')"
></uni-icons>
</view>
</template>
<template v-else>
<view
class="upload-component"
@click="chooseImage('retrofit')"
>
<uni-icons
type="plusempty"
:size="22"
color="#347BFF"
class="icon"
></uni-icons>
<view class="text">上传照片</view>
</view>
</template>
</view>
</view>
</view>
</template>
<script type='text/ecmascript-6'>
import { uploadFile } from '@/utils/ossUpload.js'
import permision from '@/js_sdk/wa-permission/permission.js'
export default {
name: 'EquityUpload',
props: {
externalData: null,
},
watch: {
externalData: {
handler (val) {
let { imgObj } = val
if (Object.keys(this.imgObj).length) return
this.imgObj = {
retrofitInvoice: imgObj.retrofitInvoice || '',
retrofit: imgObj.retrofit || ''
}
},
deep: true,
immediate: true
}
},
data () {
return {
viewKey: Date.now(),
imgObj: {}
}
},
mounted () {
},
methods: {
previewMedia (urls, index = 0) {
uni.previewImage({
current: index,
urls: Array.isArray(urls) ? urls : [urls],
})
},
delImage (key) {
this.imgObj[key] = ''
this.viewKey = Date.now()
},
async chooseImage (key) {
let _this = this
try {
// #ifdef APP-PLUS
const photoLibrary = await permision.requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE')
const camera = await permision.requestAndroidPermission('android.permission.CAMERA')
const isOnline = await uni.$isNetWork()
if (photoLibrary != 1) throw '您的设备不支持相册功能或未授权访问,请前往设置中开启相册权限'
if (camera != 1) throw '您的设备不支持摄像头功能或未授权访问,请前往设置中开启摄像头权限'
if (!isOnline) throw '当前无网络连接,请连接网络后重试'
// #endif
uni.chooseImage({
count: 1,
async success (res) {
uni.showLoading({ title: '上传中...', mask: true })
const url = await uploadFile(res.tempFiles[0], res.tempFilePaths[0])
_this.imgObj[key] = url
_this.viewKey = Date.now()
uni.hideLoading()
},
fail (err) {
uni.hideLoading()
if (err.errMsg.indexOf('cancel') === -1) {
return uni.showToast({
title: '图片上传失败',
icon: 'none'
})
}
},
})
} catch (error) {
uni.hideLoading()
return uni.showToast({
title: error,
icon: 'none'
})
}
},
}
}
</script>
<style scoped lang='scss'>
.upload-content {
padding: toRpx(32) toRpx(32) 0;
.upload-box {
display: flex;
margin-bottom: toRpx(32);
.label {
width: toRpx(168);
flex-shrink: 0;
margin-right: toRpx(32);
}
.value {
gap: toRpx(16);
flex-wrap: wrap;
}
.upload-item {
width: toRpx(192);
height: toRpx(192);
border-radius: toRpx(12);
background: #f5f8ff;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #999999;
font-size: toRpx(20);
position: relative;
.del {
position: absolute;
width: toRpx(32);
height: toRpx(32);
background: #00000080;
border-radius: 100%;
top: toRpx(8);
right: toRpx(4);
justify-content: center;
}
.upload-component {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.icon {
font-weight: 700;
margin-bottom: toRpx(22);
}
.img {
width: 100%;
height: 100%;
}
.text {
width: 80%;
text-align: center;
}
}
}
}
</style>
\ No newline at end of file
<template>
<view
class="equity-goods-box"
:key="viewKey"
>
<template v-if="goodInfoList && goodInfoList.length">
<template v-for="(item,index) in goodInfoList">
<view
class="goods-item"
:key="index"
>
<view class="goods-head">
<view class="goods-name">{{item.goodName}}</view>
<view class="goods-pervice">包含{{item.items}}</view>
</view>
<view class="goods-list">
<template v-if="item.printType == 2">
<!-- itemsCode标识:YB0001-延保-6大件,YB0002-延保-3电,YB0003-延保-油车 -->
<template v-if="item.itemsCode == 'YB0003'">
<GlCell
:formList="[formatFormList(item, oilProFormList)]"
:formData="item"
:cellBoxStyle="cellBoxStyle"
@inputBlur="inputBlur"
@handleCell="handleCell"
@confirmCalendar="confirmCalendar"
:index="index"
>
<template #warranty>
<view class="warranty flex">
<input
type="number"
class="warranty-input"
placeholder="请输入"
placeholder-class="placeholder"
maxlength="140"
v-model="item.warrantyPeriod"
>
<view class="warranty-suffix">年或</view>
<input
type="digit"
class="warranty-input"
placeholder="请输入"
placeholder-class="placeholder"
maxlength="140"
v-model="item.warrantyKm"
>
<view class="warranty-suffix">万公里</view>
</view>
</template>
</GlCell>
</template>
<template v-if="item.itemsCode == 'YB0001' || item.itemsCode == 'YB0002'">
<GlCell
:formList="[formatFormList(item,energyProFormList)]"
:formData="item"
:cellBoxStyle="cellBoxStyle"
@inputBlur="inputBlur"
@handleCell="handleCell"
@confirmCalendar="confirmCalendar"
:index="index"
>
<template #warranty>
<view class="warranty flex">
<input
type="number"
class="warranty-input"
placeholder="请输入"
placeholder-class="placeholder"
maxlength="140"
v-model="item.warrantyPeriod"
>
<view class="warranty-suffix">年或</view>
<input
type="digit"
class="warranty-input"
placeholder="请输入"
placeholder-class="placeholder"
maxlength="140"
v-model="item.warrantyKm"
>
<view class="warranty-suffix">万公里</view>
</view>
</template>
</GlCell>
</template>
<template v-if="item.itemsCode != 'YB0001' && item.itemsCode != 'YB0002' && item.itemsCode != 'YB0003'">
<GlCell
:formList="[formatFormList(item,extendServiceFormList)]"
:formData="item"
:cellBoxStyle="cellBoxStyle"
@inputBlur="inputBlur"
@handleCell="handleCell"
@confirmCalendar="confirmCalendar"
:index="index"
>
<template #displacementPower>
<view class="displacement-power flex">
<view class="switch-box flex">
<template v-for="(s,sindex) in displacementPowerSwitch">
<view
:class="['switch-item flex',{'switch-active':item.displacementPowerFlag == s.value}]"
:key="sindex"
@click="changeDisplacementPower(index, s.value)"
>{{s.label}}</view>
</template>
</view>
<view class="warranty flex">
<input
type="digit"
class="warranty-input"
placeholder="请输入"
placeholder-class="placeholder"
maxlength="140"
v-model="item.displacementPowerValue"
>
<view class="warranty-suffix">{{item.displacementPowerFlag == 0 ? 'L' : 'KW'}}</view>
</view>
</view>
</template>
</GlCell>
</template>
</template>
<template v-else>
<GlCell
:formList="[formatFormList(item, equityProFormList)]"
:formData="item"
:cellBoxStyle="cellBoxStyle"
@inputBlur="inputBlur"
@handleCell="handleCell"
@confirmCalendar="confirmCalendar"
:index="index"
>
</GlCell>
</template>
</view>
</view>
</template>
</template>
<order-popup
ref="orderPopup"
:data="currentData"
@onConfirm="onConfirm"
:popupType="popupType"
/>
</view>
</template>
<script type='text/ecmascript-6'>
import { energyProFormList, equityProFormList, extendServiceFormList, oilProFormList, displacementPowerSwitch } from './contant.js'
import GlCell from '@/components/Form/GlCell.vue'
import dayjs from 'dayjs'
import utils from '@/utils/utils'
import OrderPopup from '@/components/OrderPopup/index.vue'
const popupTypeEnum = {
24: {
options: true,
key: 'vehicleNature',
targetIdKey: 'vehicleNature',
targetNameKey: 'vehicleNatureName',
},
26: {
key: 'gearbox',
value: 'gearbox'
}
}
export default {
name: 'EquityGoods',
props: {
externalData: null,
},
components: {
GlCell,
OrderPopup
},
watch: {
externalData: {
handler (val) {
this.goodInfoList = val.goodInfoList || []
},
deep: true,
immediate: true
}
},
data () {
return {
endDate: dayjs().format('YYYY-MM-DD'),
displacementPowerSwitch,
energyProFormList,
equityProFormList,
extendServiceFormList,
oilProFormList,
cellBoxStyle: 'background: #f5f7fa;',
goodInfoList:[],
viewKey: Date.now(),
currentData: {},
popupType: 0,
popupIndex: 0
}
},
mounted () {
},
methods: {
inputBlur (e, item, index) {
let { inputLimit, value: keyValue } = item,
value = this.goodInfoList[index][keyValue]
if (inputLimit) {
let { minVal, maxVal } = inputLimit
if (maxVal) {
value = value >= maxVal ? maxVal : value
}
if (minVal) {
value = value <= minVal ? minVal : value
}
if (inputLimit.type == 'digit') {
let [number, decimal] = value.toString().split('.')
if (decimal != undefined) {
decimal = decimal.substring(0, inputLimit.decimalDigit || 2)
number += `.${decimal}`
value = number
}
}
}
this.updateFormValue(index, keyValue, value)
},
confirmCalendar (e, key, index) {
this.updateFormValue(index, key, e.fulldate)
},
formatFormList (formData, formList) {
let data = utils.deepClone(formList)
data.map(item => {
if (!item.hidden && item.isShowObj && formData) {
const index = item.isShowObj.list?.findIndex(i => i == formData[item.isShowObj.attr])
if (index == -1) item.hidden = true
}
})
return data
},
isShowFn (formData, targetItem) {
var flag = false
if (targetItem.isShowObj && formData) {
const index = targetItem.isShowObj.list.findIndex(i => i == formData[targetItem.isShowObj.attr])
console.log(index, '---')
if (index == 0) flag = true
} else {
flag = false
}
return flag
},
updateFormValue (index, key, value) {
this.goodInfoList[index][key] = value
this.viewKey = Date.now()
},
changeDisplacementPower (index, value) {
this.goodInfoList[index].displacementPowerFlag = value
this.viewKey = Date.now()
},
onConfirm (val) {
const { chooseContent, popupType } = val,
{ popupIndex } = this,
_typeValue = popupTypeEnum[popupType]
if (_typeValue.options) {
this.$set(this.goodInfoList[popupIndex], _typeValue.targetIdKey, chooseContent[_typeValue.sourceIdKey || 'optionId'])
this.$set(this.goodInfoList[popupIndex], _typeValue.targetNameKey, chooseContent[_typeValue.sourceNameKey || 'optionLabel'])
return
}
this.$set(this.goodInfoList[popupIndex], _typeValue.value, chooseContent)
this.viewKey = Date.now()
},
handleCell (val, index) {
this.currentData = this.goodInfoList[index]
this.popupIndex = index
this.popupType = Object.keys(popupTypeEnum).find(key => popupTypeEnum[key].key === val.key) * 1
this.$refs.orderPopup.open()
}
}
}
</script>
<style scoped lang='scss'>
.equity-goods-box {
padding: 0 toRpx(32);
.goods-item {
margin-bottom: toRpx(8);
.goods-head {
padding: toRpx(16) 0;
.goods-name {
color: #333333;
font-size: toRpx(28);
line-height: toRpx(40);
}
.goods-pervice {
color: #999999;
font-size: toRpx(26);
line-height: toRpx(36);
}
}
.goods-list {
background: #f5f7fa;
border-radius: toRpx(16);
}
}
.displacement-power {
width: 100%;
box-sizing: border-box;
padding: 0 toRpx(32);
.switch-box {
width: toRpx(208);
height: toRpx(52);
border-radius: toRpx(64);
background: #ffffff;
box-sizing: border-box;
padding: 0 toRpx(4);
.switch-item {
width: 50%;
height: toRpx(44);
border-radius: toRpx(40);
color: #333333;
font-size: toRpx(26);
justify-content: center;
transition: all 0.15s;
}
.switch-active {
background: #333333;
color: #fff;
}
}
}
.warranty {
margin-left: auto;
&-input {
width: toRpx(84);
font-size: toRpx(28);
margin-left: toRpx(16);
}
&-suffix {
margin-left: toRpx(16);
}
.placeholder {
color: #999999;
font-size: toRpx(28);
line-height: toRpx(28);
}
}
}
</style>
\ No newline at end of file
<template>
<view class="equity-tire">
<GlCell
:formList="[formList]"
:formData="tireObj"
@handleLabelTips="handleLabelTips"
>
<template #tireHtml>
<view class="tire-box">
<template v-for="(i,index) in tireList">
<view
class="tire-item"
:key="index"
>
<view class="label flex">
{{i.name}}
<template v-if="index == 0">
<view
class="tips"
@click="handleLabelTips(i)"
>位置示例</view>
</template>
</view>
<view class="content">
<GlCell
:formList="[i.list]"
:formData="tireObj"
:index="index"
:cellBoxStyle="cellBoxStyle"
/>
</view>
</view>
</template>
</view>
</template>
</GlCell>
</view>
</template>
<script type='text/ecmascript-6'>
import { TIRE_FORM_LIST, TIRE_LIST } from './contant'
import utils from '@/utils/utils'
import GlCell from '@/components/Form/GlCell.vue'
export default {
name: 'EquityTire',
props: {
externalData: null,
},
components: {
GlCell,
},
data () {
return {
formList: utils.deepClone(TIRE_FORM_LIST),
tireList: utils.deepClone(TIRE_LIST),
cellBoxStyle: 'background: #f5f7fa;',
tireObj: {}
}
},
watch: {
externalData: {
handler (val) {
const keyList = [
'tireBrand', 'tireScale',
'leftFrontDTO', 'leftFrontBatch',
'rightFrontDTO', 'rightFrontBatch',
'leftRearDTO', 'leftRearBatch',
'rightRearDTO', 'rightRearBatch'
]
keyList.map(key => {
this.tireObj[key] = val[key]
})
},
deep: true,
immediate: true
}
},
mounted () {
},
methods: {
handleLabelTips (item) {
let { tipsUrl } = item
uni.previewImage({
urls: [tipsUrl]
})
},
}
}
</script>
<style scoped lang='scss'>
.tire-box {
display: grid;
grid-template-columns: repeat(2, 1fr);
padding: 0 toRpx(32);
gap: toRpx(16) toRpx(32);
.tire-item {
.label {
height: toRpx(68);
color: #999999;
font-size: toRpx(26);
.tips {
color: #4673ff;
font-size: toRpx(24);
margin-left: toRpx(8);
}
}
.content {
border-radius: toRpx(16);
}
}
}
</style>
\ No newline at end of file
<template>
<view
class="upload-content"
:key="viewKey"
>
<view class="upload-box">
<view class="label">购车发票</view>
<view class="upload-item">
<template v-if="imgObj.invoice">
<image
class="img"
:src="imgObj.invoice"
@click="previewMedia(imgObj.invoice)"
/>
<view class="del flex">
<uni-icons
type="closeempty"
:size="10"
color="#fff"
@click="delImage('invoice')"
></uni-icons>
</view>
</template>
<template v-else>
<view
class="upload-component"
@click="chooseImage('invoice')"
>
<uni-icons
type="plusempty"
:size="22"
color="#347BFF"
class="icon"
></uni-icons>
<view class="text">上传照片</view>
</view>
</template>
</view>
</view>
<view class="upload-box">
<view class="label">行驶证或车辆合格证</view>
<view class="value flex">
<view class="upload-item">
<template v-if="imgObj.driveFront">
<image
class="img"
:src="imgObj.driveFront"
@click="previewMedia(imgObj.driveFront)"
/>
<view class="del flex">
<uni-icons
type="closeempty"
:size="10"
color="#fff"
@click="delImage('driveFront')"
></uni-icons>
</view>
</template>
<template v-else>
<view
class="upload-component"
@click="chooseImage('driveFront')"
>
<uni-icons
type="plusempty"
:size="22"
color="#347BFF"
class="icon"
></uni-icons>
<view class="text">行驶证主页/车辆合格证</view>
</view>
</template>
</view>
<view class="upload-item">
<template v-if="imgObj.driveBack">
<image
class="img"
:src="imgObj.driveBack"
@click="previewMedia(imgObj.driveBack)"
/>
<view class="del flex">
<uni-icons
type="closeempty"
:size="10"
color="#fff"
@click="delImage('driveBack')"
></uni-icons>
</view>
</template>
<template v-else>
<view
class="upload-component"
@click="chooseImage('driveBack')"
>
<uni-icons
type="plusempty"
:size="22"
color="#347BFF"
class="icon"
></uni-icons>
<view class="text">行驶证副页/车辆合格证</view>
</view>
</template>
</view>
</view>
</view>
<view class="upload-box">
<view class="label">合同购买时里程数</view>
<view class="upload-item">
<template v-if="imgObj.contract">
<image
class="img"
:src="imgObj.contract"
@click="previewMedia(imgObj.contract)"
/>
<view class="del flex">
<uni-icons
type="closeempty"
:size="10"
color="#fff"
@click="delImage('contract')"
></uni-icons>
</view>
</template>
<template v-else>
<view
class="upload-component"
@click="chooseImage('contract')"
>
<uni-icons
type="plusempty"
:size="22"
color="#347BFF"
class="icon"
></uni-icons>
<view class="text">上传照片</view>
</view>
</template>
</view>
</view>
<view class="upload-box">
<view class="label">其他</view>
<view class="value flex">
<template v-if="imgObj.other.length < 9">
<view
class="upload-item"
@click="chooseImage('other',true)"
>
<uni-icons
type="plusempty"
:size="22"
color="#347BFF"
class="icon"
></uni-icons>
<view>上传照片最多9张</view>
</view>
</template>
<template v-if="imgObj.other.length">
<template v-for="(i,index) in imgObj.other">
<view
class="upload-item"
:key="index"
>
<image
class="img"
:src="i"
@click="previewMedia(imgObj.other,index)"
/>
<view class="del flex">
<uni-icons
type="closeempty"
:size="10"
color="#fff"
@click="delImage('other',index , true)"
></uni-icons>
</view>
</view>
</template>
</template>
</view>
</view>
</view>
</template>
<script type='text/ecmascript-6'>
import { uploadFile } from '@/utils/ossUpload.js'
import permision from '@/js_sdk/wa-permission/permission.js'
export default {
name: 'EquityUpload',
props: {
externalData: null,
},
watch: {
externalData: {
handler (val) {
let { imgObj } = val
if(Object.keys(this.imgObj).length) return
this.imgObj = {
invoice: imgObj.invoice || '',
driveFront: imgObj.driveFront || '',
driveBack: imgObj.driveBack || '',
contract: imgObj.contract || '',
other: imgObj.other || []
}
},
deep: true,
immediate: true
}
},
data () {
return {
viewKey: Date.now(),
imgObj: { }
}
},
mounted () {
},
methods: {
previewMedia (urls, index = 0) {
uni.previewImage({
current: index,
urls: Array.isArray(urls) ? urls : [urls],
})
},
delImage (key, index, isArray) {
if (isArray) this.imgObj[key].splice(index, 1)
else this.imgObj[key] = ''
this.viewKey = Date.now()
},
async chooseImage (key, isArray) {
let _this = this
try {
// #ifdef APP-PLUS
const photoLibrary = await permision.requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE')
const camera = await permision.requestAndroidPermission('android.permission.CAMERA')
const isOnline = await uni.$isNetWork()
if (photoLibrary != 1) throw '您的设备不支持相册功能或未授权访问,请前往设置中开启相册权限'
if (camera != 1) throw '您的设备不支持摄像头功能或未授权访问,请前往设置中开启摄像头权限'
if (!isOnline) throw '当前无网络连接,请连接网络后重试'
// #endif
uni.chooseImage({
count: 1,
async success (res) {
uni.showLoading({ title: '上传中...', mask: true })
const url = await uploadFile(res.tempFiles[0], res.tempFilePaths[0])
if (isArray) _this.imgObj[key].push(url)
else _this.imgObj[key] = url
_this.viewKey = Date.now()
uni.hideLoading()
},
fail (err) {
uni.hideLoading()
if (err.errMsg.indexOf('cancel') === -1) {
return uni.showToast({
title: '图片上传失败',
icon: 'none'
})
}
},
})
} catch (error) {
uni.hideLoading()
return uni.showToast({
title: error,
icon: 'none'
})
}
},
}
}
</script>
<style scoped lang='scss'>
.upload-content {
padding: 0 toRpx(32);
.upload-box {
display: flex;
margin-bottom: toRpx(32);
.label {
width: toRpx(168);
flex-shrink: 0;
margin-right: toRpx(32);
}
.value {
gap: toRpx(16);
flex-wrap: wrap;
}
.upload-item {
width: toRpx(192);
height: toRpx(192);
border-radius: toRpx(12);
background: #f5f8ff;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #999999;
font-size: toRpx(20);
position: relative;
.del {
position: absolute;
width: toRpx(32);
height: toRpx(32);
background: #00000080;
border-radius: 100%;
top: toRpx(8);
right: toRpx(4);
justify-content: center;
}
.upload-component {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.icon {
font-weight: 700;
margin-bottom: toRpx(22);
}
.img {
width: 100%;
height: 100%;
}
.text {
width: 80%;
text-align: center;
}
}
}
}
</style>
\ No newline at end of file
<template>
<uni-popup
ref="centerPopupRef"
type="center"
:is-mask-click="false"
animation
class="center-popup"
>
<view class="box">
<view class="title flex">
<view class="text">车架号复核</view>
<view
class="icon-close-box flex"
@click="close"
>
<uni-icons
class="icon-close"
type="closeempty"
:size="20"
color="#1A1A1A"
></uni-icons>
</view>
</view>
<view class="content flex">
<view class="tips">请核对车架号是否正确,如信息有误后期将无法申请补偿服务!</view>
<view class="input-box flex">
<view class="input">
<view class="label">车架号</view>
<input type="text" maxlength="17" v-model="obj.vin" />
</view>
<view class="edit"></view>
</view>
<view class="footer-box">
</view>
</view>
</view>
</uni-popup>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'CenterPopup',
props: {
list: Array,
title: String,
tag: String,
id: [Number, String],
isLine: Boolean
},
data () {
return {
}
},
mounted () {
},
methods: {
open () {
this.$refs.centerPopupRef.open();
},
close () {
this.$refs.centerPopupRef.close();
this.$emit('cancel')
},
choose: uni.$throttle(function (index) {
this.$emit('choose', index)
this.$refs.centerPopupRef.close();
}, 200)
}
}
</script>
<style scoped lang='scss'>
.center-popup {
z-index: 99 !important;
}
.box {
width: 848rpx;
height: 608rpx;
border-radius: 32rpx;
background: linear-gradient(180deg, #e6f0ff 0%, #ffffff 100%);
.title {
width: 100%;
height: toRpx(160);
// background: url('@/assets/images/boutique/customer-type-bg.webp') no-repeat;
background-size: 100% 100%;
position: relative;
.text {
font-weight: 500;
font-size: toRpx(40);
color: #1a1a1a;
position: absolute;
left: 64rpx;
top: 50%;
transform: translateY(-50%);
}
.icon-close-box {
height: 100%;
margin-left: auto;
padding: 0 toRpx(48);
font-weight: 700;
}
}
.content {
padding: 0 toRpx(64);
width: 100%;
.tips {
color: #666666;
font-size: 32rpx;
line-height: 48rpx;
}
.input-box {
margin: 48rpx 0 16rpx;
}
}
}
</style>
\ No newline at end of file
import dayjs from "dayjs"
const energyProFormList = [
{
label: '服务年限',
value: 'servicePeriod',
type: 'input',
readonly: true,
suffix: '年',
},
{
label: '车辆登记日期',
value: 'vehicleRegistrationDate',
type: 'single-calendar',
endDate: dayjs().subtract(1, 'day').format('YYYY-MM-DD')
},
{
label: '车型排量',
value: 'vehicleDisplacement',
type: 'input',
suffix: 'L',
inputType: 'digit',
inputLimit: {
type: 'digit',
minVal: 0,
maxVal: 100
},
},
{
label: '原厂质保',
value: 'warranty',
cellHtml: 'warranty'
},
{
label: '合同购买时里程数',
value: 'mileage',
type: 'input',
suffix: 'KM',
inputType: 'digit',
inputLimit: {
type: 'digit',
minVal: 0
},
}
]
// 权益表单
const equityProFormList = [
{
label: '服务年限',
value: 'servicePeriod',
type: 'input',
readonly: true,
suffix: '年',
},
{
label: '无忧保障服务费',
value: 'actualSalesPrice',
placeholder: '非必填',
type: 'input',
inputType: 'digit',
inputLimit: {
type: 'digit',
maxVal: 100000,
minVal: 0
},
maxlength: '9',
},
{
label: '无忧卡卡号',
value: 'card',
type: 'input',
maxlength: '6',
noBorder: true,
noCellHeight: true,
isJudgeShow: true,
isShowObj: {
attr: 'entityCardFlag',
list: ['Y']
}
}
]
// 延保配置服务项目
const extendServiceFormList = [
{
label: '服务年限',
value: 'servicePeriod',
type: 'input',
readonly: true,
suffix: '年',
cellStyle: 'height: var(--fontSize90);'
},
{
value: 'displacementPower',
rowHtml: 'displacementPower',
hidden: true
},
{
label: '购车发票日期',
value: 'buyDate',
type: 'single-calendar',
endDate: dayjs().subtract(1, 'day').format('YYYY-MM-DD')
},
{
label: '原厂质保开始日期',
value: 'qualityBeginDate',
type: 'single-calendar',
},
{
label: '原厂质保年限',
value: 'warrantyPeriod',
type: 'input',
},
{
label: '原厂质保公里(万公里)',
value: 'warrantyKm',
type: 'input',
},
{
label: '合同购买时的公里数',
value: 'mileage',
type: 'input',
}
]
// 燃油车4大件
const oilProFormList = [
{
label: '服务年限',
value: 'servicePeriod',
type: 'input',
readonly: true,
suffix: '年',
},
{
label: '车辆登记日期',
value: 'vehicleRegistrationDate',
type: 'single-calendar',
endDate: dayjs().format('YYYY-MM-DD')
},
{
label: '车辆使用性质',
value: 'vehicleNatureName',
type: 'select',
key: 'vehicleNature'
},
{
label: '变速箱类型',
value: 'gearbox',
type: 'select',
key: 'gearbox'
},
{
label: '车型排量',
value: 'vehicleDisplacement',
type: 'input',
suffix: 'L',
inputLimit: {
type: 'digit',
minVal: 0,
maxVal: 100
},
},
{
label: '原厂质保',
value: 'warranty',
},
{
label: '合同购买时里程数',
value: 'mileage',
type: 'input',
suffix: 'KM',
inputLimit: {
type: 'digit',
minVal: 0
},
}
]
const displacementPowerSwitch = [
{
label: '排量',
value: 0
},
{
label: '功率',
value: 1
}
]
const TIRE_FORM_LIST = [
{
label: '轮胎品牌',
value: 'tireBrand',
maxlength: '20',
type: 'input',
},
{
label: '轮胎规格',
value: 'tireScale',
maxlength: '20',
type: 'input',
labelTips: '位置示例',
tipsUrl: 'https://img02.glsx.com.cn/weapp/resource/app-zyzs/equity/tire-tips-1.webp'
},
{
hidden: true,
rowHtml: 'tireHtml'
}
]
const TIRE_LIST = [
{
name: '左前胎',
tipsUrl: 'https://img02.glsx.com.cn/weapp/resource/app-zyzs/equity/tire-tips-2.webp',
list: [
{
label: '轮胎DOT号',
value: 'leftFrontDTO',
type: 'input',
maxlength: '20',
},
{
label: '轮胎生产批次',
value: 'leftFrontBatch',
type: 'input',
maxlength: '20',
}
]
},
{
name: '右前胎',
list: [
{
label: '轮胎DOT号',
value: 'rightFrontDTO',
type: 'input',
maxlength: '20',
},
{
label: '轮胎生产批次',
value: 'rightFrontBatch',
type: 'input',
maxlength: '20',
}
]
},
{
name: '左后胎',
list: [
{
label: '轮胎DOT号',
value: 'leftRearDTO',
type: 'input',
maxlength: '20',
},
{
label: '轮胎生产批次',
value: 'leftRearBatch',
type: 'input',
maxlength: '20',
}
]
},
{
name: '右后胎',
list: [
{
label: '轮胎DOT号',
value: 'rightRearDTO',
type: 'input',
maxlength: '20',
},
{
label: '轮胎生产批次',
value: 'rightRearBatch',
type: 'input',
maxlength: '20',
}
]
}
]
export {
energyProFormList,
equityProFormList,
extendServiceFormList,
oilProFormList,
displacementPowerSwitch,
TIRE_FORM_LIST,
TIRE_LIST
}
<template>
<view class="order-management">
<view class="search-box">
<input class="search-input" placeholder-class="placeholder" v-model="customerName" confirm-type="search" @confirm="search" placeholder="输入客户姓名/商品名称/订单编号/手机号搜索" />
<input class="search-input" placeholder-class="placeholder" v-model="customerName" confirm-type="search" @confirm="search" placeholder="输入客户姓名搜索" />
<view class="clear flex" @click="clear">
<uni-icons type="closeempty" size="16" v-if="customerName"></uni-icons>
</view>
......@@ -20,6 +20,15 @@
<view class="sprite-icon icon-filter"></view>
</view> -->
</view>
<view class="px-48">
<view class="flex tips align-center justify-between" v-if="showTips">
<view class="flex align-center">
<view class="sprite-icon icon-equityTip"></view>
为保障客户权益,请尽快处理!
</view>
<view class="sprite-icon icon-equityClose" @click="showTips = false"></view>
</view>
</view>
<z-paging ref="paging" :fixed="false" paging-class="paging-class px-48" :loading-full-fixed="false" :auto-show-system-loading="true" :show-scrollbar="false" v-model="dataList" @query="queryList" :default-page-size="10">
<EquityCard v-for="(item, index) in dataList" :key="index" :orderCardDetail="item" @toggle-goods-list="handleToggleGoodsList" @jump="jump" @refresh="search()" @openPay="openPay"></EquityCard>
......@@ -87,8 +96,8 @@ export default {
tabList: [
{ tabName: '全部', num: 0, value: null },
{ tabName: '待补录', num: 0, value: 0 },
{ tabName: '提单失败', num: 0, value: 2 },
{ tabName: '已完成', num: 0, value: 3 }
{ tabName: '提单失败', num: 0, value: 3 },
{ tabName: '已完成', num: 0, value: 2 }
],
tabIndex: 0,
activeIndex: 0,
......@@ -111,7 +120,8 @@ export default {
abnormalPages: 1,
normalPages: 1,
checkListObj: {},
localUserInfo: null
localUserInfo: null,
showTips: true
}
},
mounted() {
......@@ -245,7 +255,7 @@ export default {
pageNum: pageNo,
customerName: this.customerName,
merchantId: localUserInfo.shopMerchantId,
orderStatus: ''
orderStatus: this.searchObj.orderStatus
}
uni.$api.equityApi
......@@ -307,7 +317,7 @@ export default {
.order-management {
height: 100%;
.paging-class {
height: calc(100% - #{toRpx(288)});
height: calc(100% - #{toRpx(380)});
}
.px-48 {
padding: 0 toRpx(48);
......@@ -343,8 +353,8 @@ export default {
.clear {
position: absolute;
right: toRpx(18);
top: toRpx(10);
height: 100%;
top: toRpx(40);
height: toRpx(72);
padding: 0 48rpx;
}
......@@ -446,155 +456,6 @@ export default {
}
}
.tips {
display: flex;
align-items: center;
justify-content: center;
font-size: toRpx(28);
width: 100%;
height: toRpx(76);
border-radius: 16px;
opacity: 1;
background: #fef5ea;
margin: toRpx(24) 0;
color: #ff9d0a;
&-text {
margin-top: toRpx(4);
}
.icon-study-tips {
margin-right: toRpx(8);
}
.waitinputorder-btn {
width: toRpx(136);
height: toRpx(50);
border-radius: toRpx(48);
opacity: 1;
background: #ffffff;
color: #4673ff;
font-size: toRpx(24);
font-weight: 500;
text-align: center;
line-height: toRpx(50);
}
}
.waitinputorderPopup .popup-content {
.waitinputorder-tab-container {
width: toRpx(488);
border-radius: toRpx(64);
opacity: 1;
background: #f5f7fa;
}
.waitinputorder-tab-buttons {
display: flex;
background-color: #f5f5f5;
border-radius: 24rpx;
overflow: hidden;
margin-bottom: 20rpx;
}
.waitinputorder-tab-button {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
font-size: toRpx(28);
font-weight: 500;
color: #333;
position: relative;
width: toRpx(236);
height: toRpx(56);
border-radius: toRpx(40);
&.active {
background-color: #000;
color: #fff;
}
.question-icon {
margin-left: 8rpx;
opacity: 0.6;
}
}
}
.order_no_box {
height: calc(67vh - #{toRpx(364)});
.order-gap {
display: grid;
grid-template-columns: 1fr 1fr;
gap: toRpx(36);
}
.order_no_item {
border-radius: toRpx(16);
opacity: 1;
border: toRpx(2) solid #dce0e6;
padding: toRpx(24) toRpx(32);
background: #f5f7fa;
position: relative;
.message {
.item {
margin-bottom: toRpx(12);
&:last-child {
margin-bottom: 0;
}
}
.label {
color: #999ea8;
font-size: toRpx(24);
font-weight: 400;
width: toRpx(120);
margin-right: toRpx(24);
}
.value {
color: #333333;
font-size: toRpx(24);
font-weight: 400;
}
}
.checked {
position: absolute;
top: 0;
right: 0;
}
}
.checkActive {
border: toRpx(2) solid #4673ff;
background: #4673ff1a;
}
.copy-btn {
display: flex;
align-items: center;
margin-left: auto;
color: #808291;
.copy {
margin-right: toRpx(8);
margin-left: toRpx(20);
}
}
.nothing {
width: 100%;
height: toRpx(228);
flex-direction: column;
margin-top: toRpx(76);
font-size: toRpx(24);
color: #999999;
box-sizing: border-box;
&.big-height {
height: toRpx(234);
}
.icon {
width: toRpx(288);
height: toRpx(144);
margin-bottom: toRpx(4);
}
}
}
.footer-box {
width: 100%;
height: toRpx(164);
......@@ -619,39 +480,17 @@ export default {
margin-left: toRpx(32);
}
}
}
::v-deep .waitinputorderPopup .uni-popup__wrapper {
border-radius: toRpx(32) toRpx(32) 0 0;
opacity: 1;
width: 100%;
height: 67vh;
background-color: #fff !important;
.popup-top-box {
padding: toRpx(32) toRpx(52);
}
}
::v-deep .abnormalTipsPopup .uni-popup__wrapper {
border-radius: toRpx(32) toRpx(32) 0 0;
opacity: 1;
width: 100%;
height: 51vh;
background-color: #fff !important;
.ul {
height: 100%;
.title {
font-weight: 600;
font-size: toRpx(26);
color: #282829;
margin-bottom: toRpx(8);
}
.li {
font-size: toRpx(26);
color: #282829;
margin-bottom: toRpx(8);
}
.last {
margin-bottom: toRpx(32);
.tips {
height: toRpx(72);
border-radius: toRpx(16);
background: #e0e8ff;
color: #2c66f7;
font-size: toRpx(28);
font-weight: 400;
padding: toRpx(0) toRpx(34);
margin-bottom: toRpx(24);
.icon-equityTip {
margin-right: toRpx(14);
}
}
}
......
......@@ -270,7 +270,8 @@ export default {
.quotationPage(params)
.then(result => {
console.log(result)
this.$refs.paging.complete(result.list)
let tempList = this.dealListData(result.list || [])
this.$refs.paging.complete(tempList)
})
.catch(err => {
this.$refs.paging.complete(false)
......@@ -316,6 +317,20 @@ export default {
},
jumpSuccess(params) {
this.$emit('jump', 'OrderDetail', params)
},
dealListData(arr) {
if (!arr) {
return arr
}
var attrList = ['equityPrice', 'quotedPrice', 'quotedPriceUpdate', 'refundAmount']
arr.forEach(item => {
attrList.forEach(k => {
if (item[k]) {
item[k] = (item[k] / 100).toFixed(2)
}
})
})
return arr
}
}
}
......@@ -361,8 +376,8 @@ export default {
.clear {
position: absolute;
right: toRpx(18);
top: toRpx(10);
height: 100%;
top: toRpx(40);
height: toRpx(72);
padding: 0 48rpx;
}
......
<template>
<view class="previewList">
<view class="previewList-box">
<view class="common-title">合同列表</view>
<view class="box">
<scroll-view class="scroll-view" scroll-y="true">
<view class="box-content">
<view class="box-shell">
<view class="flex align-item cell-item justify-between" v-for="item in list" :key="item.contractNo">
<view>{{ item.goodName ? '合同:' + item.goodName : '合同' + item.label }}</view>
<view class="flex align-item">
<view class="sprite-icon icon-preview" @click.stop="handlePreviewContract(item)"></view>
<view class="sprite-icon icon-previewDownLoad ml-36" @click.stop="handlePreviewContract(item, 'download')"></view>
</view>
</view>
</view>
</view>
</scroll-view>
</view>
</view>
</view>
</template>
<script>
import utils from '@/utils/utils'
export default {
name: 'PreviewList',
props: {
transmissionOfData: {
type: Object,
default: () => null
}
},
data() {
return {
list: []
}
},
computed: {
userInfo() {
return uni.$storage.get('userInfo') || {}
}
},
mounted() {
this.initData()
},
methods: {
initData() {
console.log('initData', this.transmissionOfData)
this.list = this.transmissionOfData.paramsData
},
handleDownload(url) {
if (!url) {
uni.showToast({ title: '没有合同', icon: 'none' })
return
}
uni.downloadFile({
url: url,
success: res => {
if (res.statusCode === 200) {
uni.showToast({ title: '保存成功', icon: 'none' })
var filePath = res.tempFilePath
uni.openDocument({
filePath: filePath,
showMenu: true,
success: function (res) {
console.log('打开文档成功')
}
})
}
}
})
},
handlePreviewContract(item, type) {
let params = {
contractNo: item.contractNo
}
uni.showLoading({
title: '加载中...',
mask: true
})
uni.$api.equityApi
.printContract(params)
.then(res => {
console.log(res)
uni.hideLoading()
const url = res.url || res
if (type == 'download') {
this.handleDownload(url)
} else {
const fileName = this.getFileNameFromUrl(res.url || res)
const type = 3
console.log(url, fileName, type)
// 跳转到预览页面
uni.navigateTo({
url: `/pages/common/filePreview?fileUrl=${encodeURIComponent(url)}&fileType=${type}&fileName=${encodeURIComponent(fileName)}`
})
}
})
.catch(err => {
uni.hideLoading()
})
},
// 从URL获取文件名
getFileNameFromUrl(url) {
return url.split('/').pop().split('?')[0] || '未知文件'
},
getFileTypeFromUrl(url) {
const ext = url.split('.').pop().toLowerCase()
return ext === 'pdf' ? 'pdf' : 'image'
}
}
}
</script>
<style scoped lang="scss">
.previewList {
height: 100%;
position: relative;
.previewList-box {
height: 100%;
position: relative;
}
.box {
height: calc(100% - #{toRpx(120)});
padding-bottom: toRpx(24);
.scroll-view {
height: 100%;
.box-content {
padding: 0 toRpx(48);
.box-shell {
width: 100%;
border-radius: toRpx(16);
background: #ffffff;
padding: toRpx(32);
margin-top: toRpx(16);
.cell-item {
padding: toRpx(28) 0;
border-bottom: toRpx(1) solid #f7f7f6;
}
}
}
}
}
.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%);
}
}
</style>
<template>
<view class="order">
<view :class="['order-box']">
<view class="common-title">客户签字</view>
<view class="box">
<scroll-view class="scroll-view" scroll-y="true">
<view class="box-content">
<view class="box-shell pt-32">
<view class="descTextTitle">尊敬的客户,您好!</view>
<view class="h3 descText">本人自愿在门店购买保险。门店已就新车投保项目及服务进行了说明,本人完全理解相关项目的服务流程及细则。</view>
</view>
<view class="box-shell">
<view class="tips descText">请在确认以上信息后,在下方的签字区内签字确认,感谢您的配合!</view>
<view class="title descTextTitle">签字处</view>
<view class="sign-box">
<l-signature disableScroll ref="signatureRef" :penColor="penColor" :penSize="penSize" :openSmooth="openSmooth" @touchstart="onSignatureTouch"></l-signature>
<view v-if="showPlaceHoder" class="placehoder">签字区</view>
<!-- <view @click="fullScreen" class="full_icon flex_scb sprite-icon icon-fullScreen">
</view> -->
<view @click.stop="onClick('clear')" class="delete_icon flex_scb sprite-icon icon-sign_del"></view>
</view>
</view>
</view>
</scroll-view>
<view class="btns flex">
<view class="btn save" @click="back">稍后处理</view>
<view @click="submit" class="btn">已完成</view>
</view>
</view>
</view>
<NoticePopup ref="notice" title="重要提示" text="当前页面暂未保存,是否确认退出" type="warning"></NoticePopup>
</view>
</template>
<script>
import utils from '@/utils/utils'
import { UpdateOrderInfo, popupTypeEnum, payTypeList, titleList } from '../contant'
import NoticePopup from '@/components/NoticePopup.vue'
import { uploadFile } from '@/utils/ossUploadFile/uploadFile.js'
import { interceptionMixin } from '@/mixin/index'
export default {
name: 'SignName',
mixins: [interceptionMixin],
components: {
NoticePopup
},
props: {
transmissionOfData: {
type: Object,
default: () => null
}
},
data() {
return {
showUpload: false,
showTips: true,
titleList,
formList: utils.deepClone(UpdateOrderInfo),
valueKey: '',
externalData: [],
popupType: 0,
baseConfigData: {},
landscape: false,
requiredList: [], // 录单设置的必填项
orderObj: {
owner: '',
phone: '',
salesType: '0',
carVin: '',
certificateNo: '',
notes: ''
},
title: 'Hello',
penColor: 'red',
penSize: 5,
url: '',
openSmooth: false,
showPlaceHoder: true
}
},
computed: {
userInfo() {
return uni.$storage.get('userInfo') || {}
}
},
watch: {
transmissionOfData: {
handler(newVal, oldVal) {
if (newVal) {
console.log(newVal, 'newVal')
} else {
console.log(oldVal, 'oldVal')
}
}
}
},
mounted() {
this.initData()
},
methods: {
initData() {
console.log('initData', this.transmissionOfData)
},
// 提交
async submit() {
if (await this.checkDailyReport()) return
this.$refs.signatureRef.canvasToTempFilePath({
success: async res => {
// 是否为空画板 无签名
console.log(res.isEmpty)
// 生成图片的临时路径
// H5 生成的是base64
uni.showLoading({
title: '上传中...',
mask: true
})
console.log(res, 'res')
let url = await uploadFile(res.tempFilePath)
uni.hideLoading()
let params = {
orderId: this.transmissionOfData.paramsData.orderId,
customerNameUrl: url
}
console.log(params, 'params')
uni.showLoading({
title: '提交中...',
mask: true
})
uni.$api.equityApi
.updateCustomerNameUrlAPI(params)
.then(result => {
uni.hideLoading()
console.log(result)
setTimeout(() => {
this.$emit('jump', 'EquityManagement', {})
}, 500)
})
.catch(err => {
uni.hideLoading()
})
},
fail: err => {
uni.hideLoading()
}
})
},
back() {
// 配置弹窗按钮
this.$refs.notice.buttonsList = [
{
text: '确认退出',
type: 'default',
callback: () => {
this.transmissionOfData = null
this.$refs.notice.close()
this.$emit('jump', 'EquityManagement', {})
}
},
{
text: '继续编辑',
type: 'primary',
callback: () => {
this.$refs.notice.close()
}
}
]
// 打开弹窗
this.$refs.notice.open()
},
onClick(type) {
if (type == 'openSmooth') {
this.openSmooth = !this.openSmooth
return
}
if (this.$refs.signatureRef) this.$refs.signatureRef[type]()
},
fullScreen() {
this.landscape = !this.landscape
},
onSignatureTouch(val) {
console.log(val, 'val')
// this.showPlaceHoder = val
// this.$refs.signatureRef.isEmpty
}
}
}
</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)});
.scroll-view {
// height: calc(100% - #{toRpx(148)});
}
}
.box-content {
padding: 0 toRpx(48);
}
.box-shell {
width: 100%;
border-radius: toRpx(16);
background: #ffffff;
padding: toRpx(32);
margin-top: toRpx(16);
}
.btns {
position: absolute;
bottom: 0;
width: 100%;
left: 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%);
}
.h3 {
text-indent: 2em;
}
.descTextTitle {
font-weight: 500;
font-size: toRpx(34);
color: #333333;
line-height: toRpx(48);
margin-bottom: toRpx(20);
}
.descText {
font-size: toRpx(28);
color: #333333;
}
.title {
margin-top: toRpx(32);
margin-bottom: toRpx(24);
}
.sign-box {
position: relative;
width: 100%;
height: toRpx(600);
border-radius: toRpx(12);
background: #f4f5f7;
// 全屏样式
&.landscape {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
border-radius: 0;
z-index: 999999;
background: #f4f5f7;
}
}
.full_icon {
position: absolute;
right: toRpx(26);
// top: var(--fontSize16);
top: toRpx(26);
z-index: 10000;
transition: all 0.3s ease;
}
.delete_icon {
position: absolute;
right: toRpx(26);
// top: var(--fontSize16);
bottom: toRpx(26);
z-index: 10000;
}
.placehoder {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: toRpx(32);
font-weight: 500;
color: #dfdfdf;
}
</style>
......@@ -28,8 +28,6 @@
<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>
......@@ -40,20 +38,15 @@ import utils from '@/utils/utils'
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'
import { validateVin, formatVinInput } from '@/utils/vinVaildate'
export default {
name: 'CreateOrder',
mixins: [interceptionMixin],
components: {
GlCell,
// OrderPopup,
UploadProofOfPayment,
OrderPay,
// UploadProofOfPayment,
NoticePopup
},
props: {
......@@ -72,7 +65,8 @@ export default {
externalData: [],
popupType: 0,
baseConfigData: {},
requiredList: [], // 录单设置的必填项
requiredList: [],
validateState: true, // 录单设置的必填项
orderObj: {
owner: '',
phone: '',
......@@ -130,8 +124,19 @@ export default {
},
// 输入框失去焦点事件
inputBlur(e, val) {
console.log(e, val)
this.orderObj[val.value] = this.orderObj[val.value]
console.log(e, val, val.value === 'carVin')
if (val.value === 'carVin') {
validateVin(this.orderObj.carVin).then(result => {
console.log('validateVin', result)
let { valid } = result.data
this.validateState = valid
// 校验成功,所有提示已在公共方法中处理
console.log('车架号校验成功:', result)
this.orderObj.carVin = formatVinInput(this.orderObj.carVin)
})
} else {
this.orderObj[val.value] = this.orderObj[val.value]
}
},
// 校验必填等规则
checkRequired() {
......@@ -158,10 +163,10 @@ export default {
// 如果是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.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) {
......@@ -176,6 +181,18 @@ export default {
// 提交
async submit() {
if (!this.checkRequired() || (await this.checkDailyReport())) return
if (this.orderObj.carVin) {
// 前置判断
if (this.orderObj.carVin.length !== 17) {
uni.showToast({ title: '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)', icon: 'none' })
return false
}
// 根据接口校验结果判断
if (this.orderObj.carVin.length === 17 && !this.validateState) {
uni.showToast({ title: '车架号校验不匹配,请核对后重新输入', icon: 'none' })
return false
}
}
let params = {
id: this.orderObj.id,
notes: this.orderObj.notes || '',
......
......@@ -465,7 +465,7 @@ const EQUITY_FORM_LIST = [
},
{
label: '座位数',
value: 'seatesNum',
value: 'seat',
type: 'select',
key: 'seat',
},
......@@ -485,6 +485,7 @@ const EQUITY_FORM_LIST = [
label: '购车日期',
value: 'billingDate',
type: 'select',
key: 'calendar'
},
{
label: '品牌车系',
......@@ -496,8 +497,9 @@ const EQUITY_FORM_LIST = [
[
{
label: '客户类型',
value: 'customerType',
value: 'customerTypeName',
type: 'select',
key: 'customerType'
},
{
label: '姓名',
......@@ -513,8 +515,9 @@ const EQUITY_FORM_LIST = [
},
{
label: '证件类型',
value: 'cardType',
value: 'cardTypeName',
type: 'select',
key: 'cardType'
},
{
label: '证件号码',
......@@ -533,7 +536,28 @@ const EQUITY_FORM_LIST = [
{
hidden: true,
rowHtml: 'goodsHtml'
}
},
{
label: '生效日期',
value: 'effectiveDate',
type: 'select',
key: 'futureCalendar'
},
{
hidden: true,
rowHtml: 'tireHtml'
},
{
label: '购车类型',
value: 'buyCarTypeName',
type: 'select',
key: 'buyCarType'
},
{
label: '第一受益人',
value: 'compensationName',
type: 'input'
},
],
[
{
......@@ -543,6 +567,28 @@ const EQUITY_FORM_LIST = [
],
[
{
label: '含加改装件',
value: 'inclueType',
type: 'radio',
current: '1',
radioList: [
{
value: '1',
name: '是'
},
{
value: '2',
name: '否'
}
],
},
{
hidden: true,
rowHtml: 'conversion'
}
],
[
{
label: '店面名称',
value: 'merchantName',
type: 'input',
......@@ -568,7 +614,273 @@ const EQUITY_FORM_TITLE_LIST = [
{ name: '客户信息', collapseAll: true },
{ name: '产品信息', collapseAll: true },
{ name: '上传资料', collapseAll: true },
{ name: '加改装信息', collapseAll: true },
{ name: '店面信息', collapseAll: true }
]
const EQUITY_POPUP_ENUM = {
18: {
value: 'seat',
key: 'seat'
},
21: {
options: true,
key: 'customerType',
targetIdKey: 'customerType',
targetNameKey: 'customerTypeName',
},
22: {
options: true,
key: 'cardType',
targetIdKey: 'cardType',
targetNameKey: 'cardTypeName',
},
23: {
options: true,
key: 'buyCarType',
targetIdKey: 'buyCarType',
targetNameKey: 'buyCarTypeName',
},
25: {
key: 'carBrand'
}
}
/**轮胎配置 */
const tireObjList = [
{
attr: 'leftFrontDTO',
sort: 0,
attributeGroup: 'tireDTONew',
attributeName: 'tireDTONew'
},
{
attr: 'rightFrontDTO',
sort: 1,
attributeGroup: 'tireDTONew',
attributeName: 'tireDTONew'
},
{
attr: 'leftRearDTO',
sort: 2,
attributeGroup: 'tireDTONew',
attributeName: 'tireDTONew'
},
{
attr: 'rightRearDTO',
sort: 3,
attributeGroup: 'tireDTONew',
attributeName: 'tireDTONew'
},
{
attr: 'leftFrontBatch',
sort: 0,
attributeGroup: 'tireBatchNew',
attributeName: 'tireBatchNew'
},
{
attr: 'rightFrontBatch',
sort: 1,
attributeGroup: 'tireBatchNew',
attributeName: 'tireBatchNew'
},
{
attr: 'leftRearBatch',
sort: 2,
attributeGroup: 'tireBatchNew',
attributeName: 'tireBatchNew'
},
{
attr: 'rightRearBatch',
sort: 3,
attributeGroup: 'tireBatchNew',
attributeName: 'tireBatchNew'
}
]
const EQUITY_FORM_RULE = {
vin: [
{ required: true, message: '车架号不能为空' },
{
validator: (rule, value) => {
// VIN 车架号格式校验:17位字符,支持大写 A-H/J-N/P-Z、0-9(排除 I、O、Q)
const VALID_VIN_REG = /^[A-HJ-NPR-Z0-9]{17}$/i
return VALID_VIN_REG.test(value) ? null : { message: '请输入 17 位有效字符(支持大写 A-H/J-N/P-Z、0-9)' }
}
}
],
seat: [{ required: true, message: '座位数不能为空' }],
engineNo: [
{ required: true, message: '发动机号不能为空' },
{
validator: (rule, value) => {
return /^[a-zA-Z0-9]{6,16}$/.test(value) ? null : { message: '发动机号请输入6-16位数字和字母组合' }
}
}
],
vehicleColor: [{ required: true, message: '车身颜色不能为空' }],
billingDate: [{ required: true, message: '购车日期不能为空' }],
vehicleBrandId: [{ required: true, message: '品牌车系不能为空' }],
customerType: [{ required: true, message: '客户类型不能为空' }],
customerName: [{ required: true, message: '姓名不能为空' }],
customerPhone: [
{ required: true, message: '联系电话不能为空' },
{
validator: (rule, value) => {
return !data.phoneRex.test(value) ? { message: '请输入正确的手机号' } : null
}
}
],
cardNo: [
{ required: true, message: '证件号码不能为空' },
{
validator: (rule, value) => {
let reg = value.cardType == 1 || value.cardType == 2 ? /[a-zA-Z0-9]{18}/.test(value) : /\S\s{0,18}/.test(value)
let tip = value.cardType == 1 || value.cardType == 2 ? '证件号码请输入18位数字或字母' : '证件号码不能为空'
return reg ? null : { message: tip }
},
trigger: 'change'
}
],
customerAddress: [{ required: true, message: '联系地址不能为空' }],
effectiveDate: [{ required: true, message: '生效日期不能为空' }],
tireBrand: [{ required: true, message: '轮胎品牌不能为空' }],
tireScale: [{ required: true, message: '轮胎规格不能为空' }],
leftFrontDTO: [{ required: true, message: '左前胎DOT不能为空' }],
leftFrontBatch: [{ required: true, message: '左前胎生产批次不能为空' }],
rightFrontDTO: [{ required: true, message: '右前胎DOT不能为空' }],
rightFrontBatch: [{ required: true, message: '右前胎生产批次不能为空' }],
leftRearDTO: [{ required: true, message: '左后胎DOT不能为空' }],
leftRearBatch: [{ required: true, message: '左后胎生产批次不能为空' }],
rightRearDTO: [{ required: true, message: '右后胎DOT不能为空' }],
rightRearBatch: [{ required: true, message: '右后胎生产批次不能为空' }],
compensationName: [{ required: true, message: '第一受益人不能为空' }],
merchantPhone: [{ required: true, message: '联系电话不能为空' }],
merchantAddress: [{ required: true, message: '联系地址不能为空' }]
}
export { FORM_LIST, popupTypeEnum, payTypeList, DEFEAT_FORM_LIST, titleList, UpdateOrderInfo, defeat_titleList, EQUITY_FORM_LIST, EQUITY_FORM_TITLE_LIST }
const energyFormRule = {
servicePeriod: [{ required: true, message: '服务年限不能为空' }],
vehicleRegistrationDate: [{ required: true, message: '车辆登记日期不能为空' }],
vehicleDisplacement: [
{ required: true, message: '车型排量不能为空' },
{
validator: (rule, value) => {
return /^\d+(\.\d{1,2})?$/.test(value) ? null : { message: '车型排量请输入仅有两位小数的数字' }
}
}
],
warrantyPeriod: [
{ required: true, message: '原厂质保年限不能为空' },
{
validator: (rule, value) => {
return /^\d+$/.test(value) ? null : { message: '原厂质保年限请输入整数' }
}
}
],
warrantyKm: [
{ required: true, message: '原厂质保里程数不能为空' },
{
validator: (rule, value) => {
return /^\d+(\.\d{1,2})?$/.test(value) ? null : { message: '原厂质保里程数请输入仅有两位小数的数字' }
}
}
],
mileage: [
{ required: true, message: '合同购买时里程数不能为空' },
{
validator: (rule, value) => {
return /^\d+(\.\d{1,2})?$/.test(value) ? null : { message: '合同购买时里程数请输入仅有两位小数的数字' }
}
}
]
}
const oilFormRule = {
servicePeriod: [{ required: true, message: '服务年限不能为空' }],
vehicleRegistrationDate: [{ required: true, message: '车辆登记日期不能为空' }],
vehicleNatureName: [{ required: true, message: '车辆使用性质不能为空' }],
gearbox: [{ required: true, message: '变速箱类型不能为空' }],
vehicleDisplacement: [
{ required: true, message: '车型排量不能为空' },
{
validator: (rule, value) => {
return /^\d+(\.\d{1,2})?$/.test(value) ? null : { message: '车型排量请输入仅有两位小数的数字' }
}
}
],
warrantyPeriod: [
{ required: true, message: '原厂质保年限不能为空' },
{
validator: (rule, value) => {
return /^\d+$/.test(value) ? null : { message: '原厂质保年限请输入整数' }
}
}
],
warrantyKm: [
{ required: true, message: '原厂质保里程数不能为空' },
{
validator: (rule, value) => {
return /^\d+(\.\d{1,2})?$/.test(value) ? null : { message: '原厂质保里程数请输入仅有两位小数的数字' }
}
}
],
mileage: [
{ required: true, message: '合同购买时里程数不能为空' },
{
validator: (rule, value) => {
return /^\d+(\.\d{1,2})?$/.test(value) ? null : { message: '合同购买时里程数请输入仅有两位小数的数字' }
}
}
]
}
const extendServiceFormRule = {
servicePeriod: [{ required: true, message: '服务年限不能为空' }],
displacementPowerValue: [
{ required: true, message: '排量或功率不能为空' },
{
validator: (rule, value) => {
return /^\d+(\.\d{1,2})?$/.test(value) ? null : { message: '排量或功率请输入仅有两位小数的数字' }
}
}
],
buyDate: [{ required: true, message: '购车发票日期不能为空' }],
qualityBeginDate: [{ required: true, message: '原厂质保开始日期不能为空' }],
warrantyPeriod: [
{ required: true, message: '原厂质保年限不能为空' },
{
validator: (rule, value) => {
return /^\d+$/.test(value) ? null : { message: '原厂质保年限请输入整数' }
}
}
],
warrantyKm: [
{ required: true, message: '原厂质保公里不能为空' },
{
validator: (rule, value) => {
return /^\d+(\.\d{1,2})?$/.test(value) ? null : { message: '原厂质保公里请输入仅有两位小数的数字' }
}
}
],
mileage: [
{ required: true, message: '合同购买时的公里数不能为空' },
{
validator: (rule, value) => {
return /^\d+(\.\d{1,2})?$/.test(value) ? null : { message: '合同购买时的公里数请输入仅有两位小数的数字' }
}
}
]
}
export {
FORM_LIST, popupTypeEnum, payTypeList,
DEFEAT_FORM_LIST, titleList, UpdateOrderInfo,
defeat_titleList, EQUITY_FORM_LIST, EQUITY_FORM_TITLE_LIST,
EQUITY_POPUP_ENUM, tireObjList, EQUITY_FORM_RULE,
energyFormRule,
oilFormRule,
extendServiceFormRule
}
......@@ -49,6 +49,8 @@ import StudyCenterPermissionPopup from '@/components/StudyCenterPermissionPopup.
import EquityManagement from './components/EquityManagement.vue'
import CreateEquity from './components/CreateEquity.vue'
import SignName from './components/SignName.vue'
import PreviewList from './components/PreviewList.vue'
export default {
mixins: [interceptionMixin],
......@@ -65,7 +67,9 @@ export default {
StudyPopup,
StudyCenterPermissionPopup,
EquityManagement,
CreateEquity
CreateEquity,
SignName,
PreviewList
},
data() {
return {
......
## 1.5.7(2025-11-24)
- fix: 修复uniappx 安卓打包报错问题
## 1.5.5(2025-09-18)
- fix: 修复uniappx 微信小程序 横屏时报错
## 1.5.4(2025-09-18)
- fix: 修复uniappx 微信小程序 删除离屏canvas报错
## 1.5.3(2025-08-31)
- feat: 兼容uniappx鸿蒙next
## 1.5.2(2025-04-01)
- fix: 修复`钉钉小程序`无法生成图片的问题
## 1.5.1(2025-03-28)
- fix: uniapp app 缺少,导致报错
## 1.5.0(2025-03-28)
- fix: uniappx 微信小程序的`landscape`报错
## 1.4.9(2025-03-27)
- fix: uniapp 缺少,导致报错
## 1.4.8(2025-03-26)
- fix: uniappx app `change`事件不生效的问题
## 1.4.7(2025-03-25)
- feat: 增加`change`事件
## 1.4.6(2024-07-18)
- chore: 更新文档
## 1.4.5(2024-07-17)
- chore: 删除多余console
## 1.4.4(2024-07-15)
- fix: 修复`钉钉小程序`无法生成图片的问题
## 1.4.3(2024-07-15)
- fix: 修复`钉钉小程序`无法使用的问题
## 1.4.2(2024-07-04)
- fix: 修复`vue2`因类型问题无法使用
## 1.4.1(2024-07-04)
- fix: 修复`uvue`因类型问题无法使用
## 1.4.0(2024-05-21)
- fix: 修复`nvue`因重复`width`和`height`重复导致无法使用
## 1.3.9(2024-04-11)
- feat: 增加`preferToDataURL`porps,是否优先使用`toDataURL`生成图片,在支持`toDataURL`的环境优先使用,会生成base64的图片
## 1.3.8(2024-04-10)
- fix: 修复因兼容抖音导致微信小程序图片不完整
## 1.3.7(2024-04-10)
- fix: 修复uniapp x(web)无法生图的问题
- feat: 支持uniapp x(web on pc)
## 1.3.6(2024-04-09)
- fix: 修复抖音小程序无法生成图片
## 1.3.5(2024-04-01)
- feat: 支持uniapp x ios(app-js)
## 1.3.4(2024-03-11)
- feat: app-vue,app-nvue支持生成图片时传`destWidth`,`destHeight`
## 1.3.3(2024-03-07)
- fix: 修复因小数导致mask无法生成
## 1.3.2(2024-03-06)
- fix: 修复app-vue多重复命名变量导致无法使用
## 1.3.1(2024-03-04)
- fix: 缺少this导致云打包失败
## 1.3.0(2024-02-28)
- feat: 支持uniapp x web
## 1.2.9(2024-02-21)
- fix: 修复微信小程序IOS会断断续续的问题
## 1.2.8(2023-12-21)
- fix: 修复redo函数漏了`,`
## 1.2.7(2023-12-19)
- fix: 修复因非uniapp x默认引入了uts文件,导入无法运行
## 1.2.6(2023-12-18)
- feat: 增加支持uniapp x
## 1.2.5(2023-10-11)
- fix: 修复PC浏览不生效的问题
## 1.2.4(2023-08-28)
- feat: 增加 `disabled`
## 1.2.3(2023-08-26)
- fix: 修复app-nvue 无法生成图片
## 1.2.2(2023-08-24)
- fix: 修复app端获取`boundingBox`尺寸异常
## 1.2.1(2023-08-23)
- fix: 修复因画板尺寸有小数导致`boundingBox`失效
## 1.2.0(2023-08-22)
- fix: vue3 app 无法在第一时间获取到 `getSystemInfoSync` 函数,故在生命周期里获取
## 1.1.9(2023-08-18)
- fix: 排除`backgroundColor`为`transparent`的参数,因为会导致生成空白图片
## 1.1.8(2023-08-16)
- chore: 去掉多余的console.log
## 1.1.7(2023-08-09)
- fix: 修复 支付宝无法生成的问题
## 1.1.6(2023-08-03)
- fix: 多了个 return
## 1.1.5(2023-07-27)
- fix: 修复 微信小程序PC端无法绘制问题
## 1.1.4(2023-07-21)
- fix: 修复 APP 报 `requestAnimationFrame` 的问题
## 1.1.3(2023-07-20)
- fix: 修复 性能较一般的手机 手写会卡顿的问题
## 1.1.2(2023-07-18)
- fix: 修复 非 canvas 2d 微信小程序 无法生成图片
## 1.1.1(2023-07-04)
- feat: 增加 `boundingBox` 属性,只生成有笔画的内容区域,从而缩小图片的尺寸节省空间
## 1.1.0(2023-06-20)
- feat: 增加 `canvasToTempFilePath` 质量参数
## 1.0.9(2023-06-13)
- fix: 修复大屏设备上,画板会被离屏canvas挡住的情况
## 1.0.8(2023-06-12)
- fix: 修复vue2 rendrejs 导入问题
## 1.0.7(2023-06-09)
- fix: 修复vue3 rendrejs 找到不节点问题
## 1.0.6(2023-05-23)
- chore: stylus 改为 scss
## 1.0.5(2023-05-16)
- fix: 修复转临时路径出错
## 1.0.4(2023-04-17)
- chore: 删除多余字符
## 1.0.3(2023-04-15)
- BUG: QQ小程序可以使用,会有报错但不影响使用
## 1.0.2(2023-04-15)
- feat: 支持横屏
- BUG: QQ小程序无法使用,为UNI官方问题,插件所需要的API传this都会报错。
## 1.0.1(2023-04-03)
- fix: 销毁时报错
## 1.0.0(2022-10-27)
- feat: 增加背景色
- feat: 修复 app canvasToTempFilePath 无操作只能执行一次的问题
## 0.8.0(2022-08-22)
- feat: 增加beforeDelay 延时初始化,可用于手写板在弹窗里时
## 0.7.0(2022-08-16)
- fix: 修复缺少 canvasWidth
## 0.6.0(2022-07-16)
- fix: 修复 success is no defined
## 0.5.0(2022-07-09)
- feat: canvasToTempFilePath success 增加返回 isEmpty
- fix: 修复 微信小程序 canvasToTempFilePath 无效问题
## 0.4.0(2022-07-04)
- fix: 生成图片缺少最后一笔
## 0.3.0(2022-05-24)
- chore: 支持多端 H5 小程序 APP APP-NVUE
## 0.2.0(2021-07-09)
- chore: 统一命名规范,无须主动引入组件
- fix: 修复错位问题
## 0.1.0(2021-03-07)
- 首次上传
- 撤消、清空、保存、模拟压感等功能
const uniPlatform = uni.getSystemInfoSync().uniPlatform
export const uniContext = (canvasId, context) => {
let ctx = uni.createCanvasContext(canvasId, context)
if (!ctx.uniDrawImage) {
ctx.uniDrawImage = ctx.drawImage
ctx.drawImage = (image, ...agrs) => {
ctx.uniDrawImage(image.src, ...agrs)
}
}
if (!ctx.getImageData) {
ctx.getImageData = (x, y, width, height) => {
return new Promise((resolve, reject) => {
// #ifdef MP || VUE2
if (context.proxy) context = context.proxy
// #endif
uni.canvasGetImageData({
canvasId,
x,
y,
width:parseInt(width),
height:parseInt(height),
success(res) {
resolve(res)
},
fail(error) {
reject(error)
}
}, context)
})
}
} else {
ctx._getImageData = ctx.getImageData
ctx.getImageData = (x, y, width, height) => {
return new Promise((resolve, reject) => {
ctx._getImageData({
x,
y,
width: parseInt(width) ,
height:parseInt(height),
success(res) {
resolve(res)
},
fail(error) {
reject(error)
}
})
})
}
}
return ctx
}
class Image {
constructor() {
this.currentSrc = null
this.naturalHeight = 0
this.naturalWidth = 0
this.width = 0
this.height = 0
this.tagName = 'IMG'
}
onerror() {}
onload() {}
set src(src) {
this.currentSrc = src
uni.getImageInfo({
src,
success: (res) => {
this.naturalWidth = this.width = res.width
this.naturalHeight = this.height = res.height
this.onload()
},
fail: () => {
this.onerror()
}
})
}
get src() {
return this.currentSrc
}
}
export const createImage = () => {
return new Image()
}
export function useCurrentPage() {
const pages = getCurrentPages();
return pages[pages.length - 1];
}
export const toDataURL = (canvasId, context, options = {}) => {
// #ifdef MP-QQ
// context = context.$scope
// #endif
// #ifdef MP-ALIPAY
context = ''
// #endif
return new Promise((resolve, reject) => {
let {
canvas,
width,
height,
destWidth = 0,
destHeight = 0,
x = 0,
y = 0,
preferToDataURL
} = options
const {
pixelRatio
} = uni.getSystemInfoSync()
// #ifdef MP-ALIPAY
const isDD = typeof dd != 'undefined'
if (!isDD && (!destWidth || !destHeight)) {
destWidth = width * pixelRatio;
destHeight = height * pixelRatio;
width = destWidth;
height = destHeight;
x = x * pixelRatio
y = y * pixelRatio
}
// #endif
const params = {
...options,
canvasId,
id: canvasId,
// #ifdef MP-ALIPAY
x,
y,
width,
height,
destWidth,
destHeight,
// #endif
canvas,
success: (res) => {
// 钉钉小程序 不存在tempFilePath
resolve(res.tempFilePath || res.filePath)
},
fail: (err) => {
reject(err)
}
}
// 抖音小程序canvas 2d不支持canvasToTempFilePath
if (canvas && canvas.toDataURL && preferToDataURL) {
let next = true
const devtools = uni.getSystemInfoSync().platform == 'devtools'
// #ifdef MP-TOUTIAO
next = uni.getSystemInfoSync().platform != 'devtools'
if (!next) {
console.warn('[lime-signature] 抖音开发工具不支持bbox')
}
// #endif
if ((x || y) && next) {
const offCanvas = uni.createOffscreenCanvas({
type: '2d'
});
const ctx = offCanvas.getContext("2d");
const destWidth = Math.floor(width * pixelRatio)
const destHeight = Math.floor(height * pixelRatio)
offCanvas.width = destWidth // canvas.width;
offCanvas.height = destHeight // canvas.height;
// ctx.scale(pixelRatio, pixelRatio)
// ctx.drawImage(canvas, Math.floor(x*pixelRatio), Math.floor(y*pixelRatio), destWidth, destHeight, 0,0, destWidth, destHeight);
// 抖音不能在drawImage使用canvas
const image = canvas.createImage()
image.onload = () => {
ctx.drawImage(image, Math.floor(x * pixelRatio), Math.floor(y * pixelRatio),
destWidth, destHeight, 0, 0, destWidth, destHeight)
const tempFilePath = offCanvas.toDataURL();
resolve(tempFilePath)
if (params.success) {
params.success({
tempFilePath
})
}
}
image.src = canvas.toDataURL()
} else {
const tempFilePath = canvas.toDataURL()
resolve(tempFilePath)
if (params.success) {
params.success({
tempFilePath
})
}
}
} else if (canvas && canvas.toTempFilePath) {
canvas.toTempFilePath(params)
} else {
uni.canvasToTempFilePath(params, context)
}
})
}
\ No newline at end of file
<template>
<view class="l-signature" ref="signatureRef" :style="[drawableStyle]">
<!-- #ifdef APP-ANDROID || APP-IOS -->
<view class="l-signature-landscape" ref="signatureLandscapeRef" v-if="landscape && url !=''"
:style="[landscapeStyle]">
<image class="l-signature-image" :style="[landscapeImageStyle]" :src="url"></image>
</view>
<!-- #endif -->
<!-- #ifdef APP-HARMONY -->
<canvas ref="signatureCanvasRef" class="l-signature__canvas"></canvas>
<!-- #endif -->
<!-- #ifndef APP -->
<canvas id="l-signature" class="l-signature__canvas" @touchstart="touchstart" @touchmove.stop="touchmove"
@touchend="touchend">
</canvas>
<!-- #endif -->
</view>
</template>
<script lang="uts" setup>
// @ts-nocheck
/**
* Signature 电子签名板组件
* @description 用于实现手写签名功能,支持多种画笔设置和手势控制
* <br>插件类型:LSignatureComponentPublicInstance
* @tutorial https://ext.dcloud.net.cn/plugin?name=lime-signature
*
* @property {string} styles 画布容器样式
* @property {string} penColor 画笔颜色
* @property {number} penSize 画笔基础粗细
* @property {string} backgroundColor 画布背景色
* @property {boolean} openSmooth 启用笔迹平滑
* @property {number} minLineWidth 最小笔触宽度
* @property {number} maxLineWidth 最大笔触宽度
* @property {number} minSpeed 最小绘制速度(像素/秒)
* @property {number} maxWidthDiffRate 宽度变化率限制
* @property {number} maxHistoryLength 撤销历史记录数
* @property {boolean} disableScroll 禁止滚动穿透
* @property {boolean} disabled 禁用签名板
* @property {boolean} landscape 横屏模式
* @event {Function} change 绘制内容变化时触发
*/
// #ifdef APP
import { Signature } from './signature.uts'
// #endif
// #ifndef APP
import { Signature } from './signature.js'
import { wrapEvent } from './utils'
// #endif
import { LimeSignatureToTempFilePathOptions, LimeSignatureToFileSuccess, LimeSignatureOptions } from '../../index.uts'
// type SignatureToFileSuccessCallback = (res : UTSJSONObject) => void
// type SignatureToFileFailCallback = (res : TakeSnapshotFail) => void
// type SignatureToFileCompleteCallback = (res : any) => void
const emit = defineEmits(['change'])
const props = defineProps({
styles: {
type: String,
default: ''
},
penColor: {
type: String,
default: 'black'
},
penSize: {
type: Number,
default: 2
},
backgroundColor: {
type: String,
default: ''
},
openSmooth: {
type: Boolean,
default: false
},
minLineWidth: {
type: Number,
default: 2
},
maxLineWidth: {
type: Number,
default: 6
},
minSpeed: {
type: Number,
default: 1.5
},
maxWidthDiffRate: {
type: Number,
default: 20
},
maxHistoryLength: {
type: Number,
default: 20
},
disableScroll: {
type: Boolean,
default: true
},
disabled: {
type: Boolean,
default: false
},
landscape: {
type: Boolean,
default: false
},
})
const drawableStyle = computed<string>(() : string => {
let style : string = ''
if (props.backgroundColor != '') {
style += `background-color: ${props.backgroundColor};`
}
if (props.styles != '') {
style += props.styles
}
return style
})
const signatureRef = ref<UniElement | null>(null)
const signatureCanvasRef = ref<UniElement | null>(null)
let signatureLandscapeRef = ref<UniElement | null>(null)
let landscapeStyle = ref<Map<string, string>>(new Map())
let landscapeImageStyle = ref<Map<string, string>>(new Map())
let isCanvasEmpty = true
let signature : Signature | null = null
let url = ref('')
// 检查并触发事件的方法
const checkAndEmitEmptyStatus = () => {
// #ifndef APP
// @ts-ignore
const isEmpty = signature?.isEmpty() ?? true
// #endif
// #ifdef APP
// @ts-ignore
const isEmpty = signature?.isEmpty ?? true
// #endif
if (isEmpty != isCanvasEmpty) {
isCanvasEmpty = isEmpty
emit('change', isCanvasEmpty)
}
}
// #ifndef APP
let canvas : HTMLCanvasElement | null = null;
const getTouch = (event : UniTouchEvent) => {
const touch = event.touches.length ? event.touches[0] : event.changedTouches[0];
return {
points: [
{
x: touch.clientX, //- rect.left,
y: touch.clientY //- rect.top
}
]
}
}
let touchstart = (e : UniTouchEvent) => {
// #ifndef WEB
signature!.canvas.emit('touchstart', getTouch(e))
// #endif
}
let touchmove = (e : UniTouchEvent) => {
// #ifndef WEB
signature!.canvas.emit('touchmove', getTouch(e))
// #endif
}
let touchend = (e : UniTouchEvent) => {
// #ifndef WEB
signature!.canvas.emit('touchend', getTouch(e))
// #endif
setTimeout(() => {
checkAndEmitEmptyStatus()
}, 0); // 绘制结束时检查
}
// #endif
const clear = () => {
signature?.clear()
checkAndEmitEmptyStatus() // 状态检查
}
const redo = () => {
signature?.redo()
checkAndEmitEmptyStatus() // 状态检查
}
const undo = () => {
signature?.undo()
checkAndEmitEmptyStatus() // 状态检查
}
const canvasToTempFilePath = (options : LimeSignatureToTempFilePathOptions) => {
const success = options.success // as SignatureToFileSuccessCallback | null
const fail = options.fail // as SignatureToFileFailCallback | null
const complete = options.complete// as SignatureToFileCompleteCallback | null
const format = options.format ?? 'png'
// #ifdef APP-ANDROID || APP-IOS
signatureRef.value?.takeSnapshot({
format,
success: (res) => {
if (props.landscape) {
url.value = res.tempFilePath;
setTimeout(() => {
signatureLandscapeRef.value?.takeSnapshot({
format,
success: (res2) => {
success?.({
tempFilePath: res2.tempFilePath,
isEmpty: signature?.isEmpty ?? false
} as LimeSignatureToFileSuccess)
}
})
}, 300)
} else {
success?.({
tempFilePath: res.tempFilePath,
isEmpty: signature?.isEmpty ?? false
} as LimeSignatureToFileSuccess)
}
},
fail: (res) => {
fail?.(res)
},
complete: (res) => {
complete?.(res)
}
} as TakeSnapshotOptions)
// #endif
// #ifdef APP-HARMONY
const image = signatureCanvasRef.value!.toDataURL()
success?.({
tempFilePath: image,
isEmpty: signature?.isEmpty ?? false
} as LimeSignatureToFileSuccess)
// #endif
// #ifndef APP
// @ts-ignore
const { backgroundColor, backgroundImage, landscape, boundingBox } = props
const { quality = 1 } = options
const flag = landscape || backgroundColor || boundingBox
const type = `image/${format}`.replace(/jpg/, 'jpeg');
const image = canvas?.toDataURL(!flag && type, !flag && quality)
if (flag) {
// @ts-ignore
// #ifdef WEB
const offCanvas = document.createElement('canvas')
// #endif
// #ifndef WEB
const offCanvas = uni.createOffscreenCanvas({ type: '2d' });
// #endif
// @ts-ignore
const pixelRatio = signature?.canvas.get('pixelRatio')
// @ts-ignore
let width = signature?.canvas.get('width')
// @ts-ignore
let height = signature?.canvas.get('height')
let x = 0
let y = 0
// @ts-ignore
const next = () => {
const size = [width, height]
if (landscape) {
size.reverse()
}
offCanvas.width = size[0] * pixelRatio
offCanvas.height = size[1] * pixelRatio
const param = [x, y, width, height, 0, 0, width, height].map(item => item * pixelRatio)
const context = offCanvas.getContext('2d')
if (landscape) {
context.translate(0, width * pixelRatio)
context.rotate(-Math.PI / 2)
}
if (backgroundColor) {
context.fillStyle = backgroundColor
context.fillRect(0, 0, width * pixelRatio, height * pixelRatio)
}
const drawImage = () => {
// @ts-ignore
// context.drawImage(image, ...param)//signature?.canvas!.get('el')
// #ifndef WEB
const img = offCanvas.createImage()
// #endif
// #ifdef WEB
const img = new Image()
// #endif
img.onload = ()=> {
context.drawImage(img, ...param)//signature?.canvas!.get('el')
success?.({
tempFilePath: offCanvas.toDataURL(type, quality),
// @ts-ignore
isEmpty: signature?.isEmpty() ?? false
} as LimeSignatureToFileSuccess)
}
img.onerror = ()=> {
success?.({
tempFilePath: image,
// @ts-ignore
isEmpty: signature?.isEmpty() ?? false
} as LimeSignatureToFileSuccess)
}
img.src = image
// #ifdef WEB
offCanvas.remove()
// #endif
}
if (backgroundImage) {
const img = new Image();
img.onload = () => {
context.drawImage(img, ...param)
drawImage()
}
img.src = backgroundImage
}
if (!backgroundImage) {
drawImage()
}
}
if (boundingBox) {
// @ts-ignore
const res = signature?.getContentBoundingBox()
width = res.width
height = res.height
x = res.startX
y = res.startY
next()
} else {
next()
}
} else {
success?.({
tempFilePath: image,
// @ts-ignore
isEmpty: signature?.isEmpty() ?? false
} as LimeSignatureToFileSuccess)
}
// #endif
}
defineExpose({
clear,
redo,
undo,
canvasToTempFilePath,
})
// #ifndef APP
// #ifdef WEB
let _touchstart, _touchmove, _touchend
// #endif
const instance = getCurrentInstance()!.proxy!;
uni.createCanvasContextAsync({
id: 'l-signature',
component: instance,
success: (context : CanvasContext) => {
const canvasContext = context.getContext('2d')!;
canvas = canvasContext.canvas;
// 处理高清屏逻辑
const dpr = uni.getDeviceInfo().devicePixelRatio ?? 1;
canvas.width = canvas.offsetWidth * dpr;
canvas.height = canvas.offsetHeight * dpr;
canvasContext.scale(dpr, dpr); // 仅需调用一次,当调用 reset 方法后需要再次 scale
signature = new Signature({
// @ts-ignore
context: canvasContext,
width: canvas.offsetWidth,
height: canvas.offsetHeight,
canvas: context,
pixelRatio: 1,
})
// signature = new Signature({el: canvas})
watchEffect(() => {
const options : LimeSignatureOptions = {
penColor: props.penColor,
openSmooth: props.openSmooth,
disableScroll: props.disableScroll,
disabled: props.disabled,
penSize: props.penSize,
minLineWidth: props.minLineWidth,
maxLineWidth: props.maxLineWidth,
minSpeed: props.minSpeed,
maxWidthDiffRate: props.maxWidthDiffRate,
maxHistoryLength: props.maxHistoryLength
}
// @ts-ignore
signature?.pen.setOption(options)
})
// #ifdef WEB
let isTouch = false
_touchstart = (event : UniMouseEvent) => {
isTouch = true
const rect = canvas?.getBoundingClientRect()
// @ts-ignore
signature!.canvas.emit('touchstart', {
points: [
{
x: event.clientX - rect.left,
y: event.clientY - rect.top
}
]
})
}
_touchmove = (event : UniMouseEvent) => {
if (!isTouch) return
const rect = canvas?.getBoundingClientRect()
// @ts-ignore
signature!.canvas.emit('touchmove', {
points: [
{
x: event.clientX - rect.left,
y: event.clientY - rect.top
}
]
})
}
_touchend = (event : UniMouseEvent) => {
isTouch = false
const rect = canvas?.getBoundingClientRect();
// @ts-ignore
signature!.canvas.emit('touchend', {
points: [
{
x: event.clientX - rect.left,
y: event.clientY - rect.top
}
]
})
setTimeout(function() {
checkAndEmitEmptyStatus()
}, 0); // 绘制结束时检查
}
canvas?.addEventListener('mousedown', _touchstart)
canvas?.addEventListener('mousemove', _touchmove)
canvas?.addEventListener('mouseup', _touchend)
// canvas?.addEventListener('mouseleave', _touchend)
// #endif
}
})
// #endif
onMounted(() => {
nextTick(() => {
setTimeout(()=>{
const width = signatureRef.value?.offsetWidth
const height = signatureRef.value?.offsetHeight
// #ifdef APP
landscapeStyle.value.set('width', `${height}px`)
landscapeStyle.value.set('height', `${width}px`)
landscapeImageStyle.value.set('width', `${width}px`)
landscapeImageStyle.value.set('height', `${height}px`)
landscapeImageStyle.value.set('transform', `rotate(-90deg) translateY(${width}px)`)
// #ifdef APP-ANDROID || APP-IOS
signature = new Signature(signatureRef.value!)
// #endif
// #ifndef APP-ANDROID || APP-IOS
signature = new Signature(signatureCanvasRef.value!)
// #endif
watchEffect(() => {
const options : LimeSignatureOptions = {
penColor: props.penColor,
openSmooth: props.openSmooth,
disableScroll: props.disableScroll,
disabled: props.disabled,
penSize: props.penSize,
minLineWidth: props.minLineWidth,
maxLineWidth: props.maxLineWidth,
minSpeed: props.minSpeed,
maxWidthDiffRate: props.maxWidthDiffRate,
maxHistoryLength: props.maxHistoryLength
}
// #ifdef APP
signature?.setOption(options)
signature?.onChange((_isEmpty: boolean)=>{
checkAndEmitEmptyStatus()
})
// #endif
})
// #endif
},300)
})
})
onUnmounted(() => {
// #ifdef WEB
canvas?.removeEventListener('mousedown', _touchstart)
canvas?.removeEventListener('mousemove', _touchmove)
canvas?.removeEventListener('mouseup', _touchend)
// canvas?.removeEventListener('mouseleave', touchend)
canvas?.remove()
// #endif
})
</script>
<style lang="scss">
/* #ifndef APP */
:host {
display: flex;
height: 100%;
}
/* #endif */
.l-signature {
flex: 1;
/* #ifndef APP */
width: 100%;
height: 100%;
/* #endif */
&__canvas {
width: 100%;
height: 100%;
}
&-landscape {
position: absolute;
pointer-events: none;
left: 1000rpx;
}
&-image {
transform-origin: 0% 0%;
}
}
</style>
\ No newline at end of file
<template>
<view class="lime-signature" v-if="show" :style="[canvasStyle, styles]" ref="limeSignature">
<!-- #ifndef APP-VUE || APP-NVUE -->
<canvas v-if="useCanvas2d" class="lime-signature__canvas" :id="canvasId" type="2d" :disableScroll="disableScroll" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd"></canvas>
<canvas v-else :disableScroll="disableScroll" class="lime-signature__canvas" :canvas-id="canvasId" :id="canvasId" :width="canvasWidth" :height="canvasHeight" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd" @mousedown="touchStart" @mousemove="touchMove" @mouseup="touchEnd"></canvas>
<canvas v-if="showOffscreen" class="offscreen" canvas-id="offscreen" id="offscreen" :style="'width:' + offscreenSize[0] + 'px;height:' + offscreenSize[1] + 'px'" :width="offscreenSize[0]" :height="offscreenSize[1]"></canvas>
<view v-if="showMask" class="mask" @touchstart="touchStart" @touchmove.stop.prevent="touchMove" @touchend="touchEnd"></view>
<!-- #endif -->
<!-- #ifdef APP-VUE -->
<view :id="canvasId" :disableScroll="disableScroll" :rparam="param" :change:rparam="sign.update" :rclear="rclear" :change:rclear="sign.clear" :rundo="rundo" :rredo="rredo" :change:rredo="sign.redo" :change:rundo="sign.undo" :rsave="rsave" :rmask="rmask" :change:rsave="sign.save" :change:rmask="sign.mask" :rdestroy="rdestroy" :change:rdestroy="sign.destroy" :rempty="rempty" :change:rempty="sign.isEmpty"></view>
<!-- #endif -->
<!-- #ifdef APP-NVUE -->
<web-view src="/uni_modules/lime-signature/hybrid/html/index.html" class="lime-signature__canvas" ref="webview" @pagefinish="onPageFinish" @error="onError" @onPostMessage="onMessage"></web-view>
<!-- #endif -->
</view>
</template>
<script>
/**
* Signature 电子签名板组件
* @description 用于实现手写签名功能,支持多种画笔设置和手势控制
* <br>插件类型:LSignatureComponentPublicInstance
* @tutorial https://ext.dcloud.net.cn/plugin?name=lime-signature
*
* @property {string} styles 画布容器样式
* @property {string} penColor 画笔颜色
* @property {number} penSize 画笔基础粗细
* @property {string} backgroundColor 画布背景色
* @property {boolean} openSmooth 启用笔迹平滑
* @property {number} minLineWidth 最小笔触宽度
* @property {number} maxLineWidth 最大笔触宽度
* @property {number} minSpeed 最小绘制速度(像素/秒)
* @property {number} maxWidthDiffRate 宽度变化率限制
* @property {number} maxHistoryLength 撤销历史记录数
* @property {boolean} disableScroll 禁止滚动穿透
* @property {boolean} disabled 禁用签名板
* @property {boolean} landscape 横屏模式
* @event {Function} change 绘制内容变化时触发
*/
// #ifndef APP-NVUE
import { canIUseCanvas2d, wrapEvent, requestAnimationFrame, sleep, isTransparent } from './utils'
import { Signature } from './signature.js'
// import {Signature} from '@signature';
import { uniContext, createImage, toDataURL } from './context'
// #endif
import props from './props'
import { base64ToPath, getRect } from './utils'
export default {
props,
// emits: ['change'],
data() {
return {
canvasWidth: null,
canvasHeight: null,
offscreenWidth: null,
offscreenHeight: null,
useCanvas2d: true,
show: true,
offscreenStyles: '',
showMask: false,
showOffscreen: false,
isPC: false,
isCanvasEmpty: true,
// #ifdef APP-PLUS
rclear: 0,
rdestroy: 0,
rundo: 0,
rredo: 0,
rsave: JSON.stringify({
n: 0,
fileType: 'png',
quality: 1,
destWidth: 0,
destHeight: 0
}),
rmask: JSON.stringify({
n: 0,
destWidth: 0,
destHeight: 0
}),
rempty: 0,
risEmpty: true,
toDataURL: null,
tempFilePath: []
// #endif
}
},
computed: {
canvasId() {
// #ifdef VUE2
return `lime-signature${this._uid}`
// #endif
// #ifdef VUE3
return `lime-signature${this._.uid}`
// #endif
},
offscreenId() {
return this.canvasId + 'offscreen'
},
offscreenSize() {
const { offscreenWidth, offscreenHeight } = this
return this.landscape ? [offscreenHeight, offscreenWidth] : [offscreenWidth, offscreenHeight]
},
canvasStyle() {
const { canvasWidth, canvasHeight, backgroundColor } = this
return {
width: canvasWidth && canvasWidth + 'px',
height: canvasHeight && canvasHeight + 'px',
background: backgroundColor
}
},
param() {
const { penColor, penSize, backgroundColor, backgroundImage, landscape, boundingBox, openSmooth, minLineWidth, maxLineWidth, minSpeed, maxWidthDiffRate, maxHistoryLength, disableScroll, disabled } = this
return JSON.parse(
JSON.stringify({
penColor,
penSize,
backgroundColor,
backgroundImage,
landscape,
boundingBox,
openSmooth,
minLineWidth,
maxLineWidth,
minSpeed,
maxWidthDiffRate,
maxHistoryLength,
disableScroll,
disabled
})
)
}
},
// #ifdef APP-NVUE
watch: {
param(v) {
this.$refs.webview.evalJS(`update(${JSON.stringify(v)})`)
}
},
// #endif
// #ifndef APP-PLUS
created() {
const { platform } = uni.getSystemInfoSync()
this.isPC = /windows|mac/.test(platform)
this.useCanvas2d = this.type == '2d' && canIUseCanvas2d() && !this.isPC
// #ifndef H5
this.showMask = this.isPC
// #endif
},
// #endif
// #ifndef APP-PLUS
async mounted() {
if (this.beforeDelay) {
await sleep(this.beforeDelay)
}
const config = await this.getContext()
this.signature = new Signature(config)
this.canvasEl = this.signature.canvas.get('el')
this.offscreenWidth = this.canvasWidth = this.signature.canvas.get('width')
this.offscreenHeight = this.canvasHeight = this.signature.canvas.get('height')
this.stopWatch = this.$watch(
'param',
v => {
this.signature.pen.setOption(v)
},
{
immediate: true
}
)
},
// #endif
// #ifndef APP-PLUS
// #ifdef VUE3
beforeUnmount() {
this.stopWatch && this.stopWatch()
this.signature.destroy()
this.signature = null
this.show = false
// #ifdef APP-VUE || APP-NVUE
this.rdestroy++
// #endif
},
// #endif
// #ifdef VUE2
beforeDestroy() {
this.stopWatch && this.stopWatch()
this.signature.destroy()
this.show = false
this.signature = null
// #ifdef APP-VUE || APP-NVUE
this.rdestroy++
// #endif
},
// #endif
// #endif
methods: {
checkAndEmitEmptyStatus() {
setTimeout(() => {
// #ifdef APP-VUE || APP-NVUE
const isEmpty = this.risEmpty
// #endif
// #ifndef APP-VUE || APP-NVUE
const isEmpty = this.signature?.isEmpty() ?? true
// #endif
if (isEmpty != this.isCanvasEmpty) {
this.isCanvasEmpty = isEmpty
this.$emit('change', isEmpty)
}
}, 0)
},
// #ifdef MP-QQ
// toJSON() { return this },
// #endif
// #ifdef APP-PLUS
onPageFinish() {
this.$refs.webview.evalJS(`update(${JSON.stringify(this.param)})`)
},
onMessage(e = {}) {
const {
detail: {
data: [res]
}
} = e
if (res.event?.save) {
this.toDataURL = res.event.save
}
if (res.event?.changeSize) {
const { width, height } = res.event.changeSize
}
if (res.event.hasOwnProperty('isEmpty')) {
this.risEmpty = res.event.isEmpty
this.checkAndEmitEmptyStatus()
}
if (res.event?.file) {
this.tempFilePath.push(res.event.file)
if (this.tempFilePath.length > 7) {
this.tempFilePath.shift()
}
return
}
if (res.event?.success) {
if (res.event.success) {
this.tempFilePath.push(res.event.success)
if (this.tempFilePath.length > 8) {
this.tempFilePath.shift()
}
this.toDataURL = this.tempFilePath.join('')
this.tempFilePath = []
} else {
this.$emit('fail', 'canvas no data')
}
return
}
},
// #endif
redo() {
// #ifdef APP-VUE || APP-NVUE
this.rredo += 1
// #endif
// #ifdef APP-NVUE
this.$refs.webview.evalJS(`redo()`)
// #endif
// #ifndef APP-VUE
if (this.signature) {
this.signature.redo()
}
this.checkAndEmitEmptyStatus()
// #endif
},
restore() {
this.redo()
},
undo() {
// #ifdef APP-VUE || APP-NVUE
this.rundo += 1
// #endif
// #ifdef APP-NVUE
this.$refs.webview.evalJS(`undo()`)
// #endif
// #ifndef APP-VUE
if (this.signature) this.signature.undo()
this.checkAndEmitEmptyStatus()
// #endif
},
clear() {
// #ifdef APP-VUE || APP-NVUE
this.rclear += 1
// #endif
// #ifdef APP-NVUE
this.$refs.webview.evalJS(`clear()`)
// #endif
// #ifndef APP-VUE
if (this.signature) this.signature.clear()
this.checkAndEmitEmptyStatus()
// #endif
},
isEmpty() {
// #ifdef APP-NVUE
this.$refs.webview.evalJS(`isEmpty()`)
// #endif
// #ifdef APP-VUE || APP-NVUE
this.rempty += 1
// #endif
// #ifndef APP-VUE || APP-NVUE
return this.signature.isEmpty()
// #endif
},
async canvasToMaskPath(param = {}) {
const isEmpty = this.isEmpty()
// #ifdef APP-NVUE
this.$refs.webview.evalJS(`mask(${JSON.stringify(param)})`)
// #endif
// #ifdef APP-VUE || APP-NVUE
const stopURLWatch = this.$watch('toDataURL', (v, n) => {
if (v && v !== n) {
// if(param.pathType == 'url') {
base64ToPath(v).then(res => {
param.success({
tempFilePath: res,
isEmpty: this.risEmpty
})
})
// } else {
// param.success({tempFilePath: v,isEmpty: this.risEmpty })
// }
this.toDataURL = ''
}
stopURLWatch && stopURLWatch()
})
const { fileType, quality } = param
const rmask = JSON.parse(this.rmask)
rmask.n++
rmask.destWidth = param.destWidth ?? 0
rmask.destHeight = param.destHeight ?? 0
// rmask.fileType = fileType
// rmask.quality = quality
this.rmask = JSON.stringify(rmask)
// #endif
// #ifndef APP-VUE || APP-NVUE
this.showOffscreen = true
let width = this.signature.canvas.get('width')
let height = this.signature.canvas.get('height')
let pixelRatio = this.pixelRatio || uni.getSystemInfoSync().pixelRatio
if (this.useCanvas2d) {
this.offscreenWidth = width * pixelRatio
this.offscreenHeight = height * pixelRatio
} else {
this.offscreenWidth = width
this.offscreenHeight = height
}
await sleep(100)
const context = uni.createCanvasContext('offscreen', this)
const size = Math.max(this.offscreenWidth, this.offscreenHeight)
const success = success => param.success && param.success(success)
const fail = fail => param.fail && param.fail(fail)
this.signature.pen.getMaskedImageData(imageData => {
let canvasPutImageData = (options, comp) => {
if (uni.canvasPutImageData) {
uni.canvasPutImageData(options, comp)
} else if (context.putImageData) {
context.putImageData(options)
}
}
canvasPutImageData(
{
canvasId: 'offscreen',
x: 0,
y: 0,
width: width,
height: height,
data: imageData,
fail(err) {
fail(err)
},
success: re => {
toDataURL('offscreen', this, param).then(res => {
context.restore()
context.clearRect(0, 0, size, size)
this.offscreenWidth = width
this.offscreenHeight = height
this.showOffscreen = false
success({
tempFilePath: res,
isEmpty
})
})
}
},
this
)
})
// #endif
},
canvasToTempFilePath(param = {}) {
const isEmpty = this.isEmpty()
// #ifdef APP-NVUE
this.$refs.webview.evalJS(`save(${JSON.stringify(param)})`)
// #endif
// #ifdef APP-VUE || APP-NVUE
const stopURLWatch = this.$watch('toDataURL', (v, n) => {
if (v && v !== n) {
if (this.preferToDataURL) {
param.success({
tempFilePath: v,
isEmpty: this.risEmpty
})
} else {
base64ToPath(v).then(res => {
param.success({
tempFilePath: res,
isEmpty: this.risEmpty
})
})
}
this.toDataURL = ''
}
stopURLWatch && stopURLWatch()
})
const { fileType, quality } = param
const rsave = JSON.parse(this.rsave)
rsave.n++
rsave.fileType = fileType
rsave.quality = quality
rsave.destWidth = param.destWidth ?? 0
rsave.destHeight = param.destHeight ?? 0
this.rsave = JSON.stringify(rsave)
// #endif
// #ifndef APP-VUE || APP-NVUE
const useCanvas2d = this.useCanvas2d
const success = success => param.success && param.success(success)
const fail = err => param.fail && param.fail(err)
const { canvas } = this.signature.canvas.get('el')
const { backgroundColor, landscape, boundingBox } = this
let width = this.signature.canvas.get('width')
let height = this.signature.canvas.get('height')
let x = 0
let y = 0
const devtools = uni.getSystemInfoSync().platform == 'devtools'
let preferToDataURL = this.preferToDataURL
let scale = 1
// #ifdef MP-TOUTIAO
scale = devtools ? uni.getSystemInfoSync().pixelRatio : scale
// 由于抖音不支持canvasToTempFilePath故优先使用createOffscreenCanvas
preferToDataURL = true
// #endif
const canvasToTempFilePath = async image => {
const createCanvasContext = () => {
const useOffscreen = useCanvas2d && !!uni.createOffscreenCanvas && preferToDataURL
if (useOffscreen && !devtools) {
const offCanvas = uni.createOffscreenCanvas({
type: '2d'
})
offCanvas.width = this.offscreenSize[0] * scale
offCanvas.height = this.offscreenSize[1] * scale
const context = offCanvas.getContext('2d')
return [context, offCanvas]
} else {
const context = uni.createCanvasContext('offscreen', this)
return [context]
}
}
if ((boundingBox && !this.isPC) || landscape || (backgroundColor && !isTransparent(backgroundColor))) {
this.showOffscreen = true
await sleep(100)
const [context, offCanvas] = createCanvasContext()
context.save()
context.setTransform(1, 0, 0, 1, 0, 0)
if (landscape) {
context.translate(0, width * scale)
context.rotate(-Math.PI / 2)
}
if (backgroundColor && !isTransparent(backgroundColor)) {
context.fillStyle = backgroundColor
context.fillRect(0, 0, width, height)
}
if (offCanvas) {
const img = canvas.createImage()
img.src = image
img.onload = () => {
context.drawImage(img, 0, 0, width * scale, height * scale)
const tempFilePath = offCanvas.toDataURL()
this.showOffscreen = false
success({
tempFilePath,
isEmpty
})
}
} else {
context.drawImage(image, 0, 0, width * scale, height * scale)
context.draw(false, () => {
toDataURL('offscreen', this, param).then(res => {
const size = Math.max(width, height)
context.restore()
context.clearRect(0, 0, size, size)
this.showOffscreen = false
success({
tempFilePath: res,
isEmpty
})
})
})
}
} else {
success({
tempFilePath: image,
isEmpty
})
}
}
const next = async () => {
if (this.offscreenWidth != width || this.offscreenHeight != height) {
this.offscreenWidth = width
this.offscreenHeight = height
await sleep(100)
}
// #ifndef MP-WEIXIN
const param = {
x,
y,
width,
height,
canvas,
preferToDataURL
}
// #endif
// #ifdef MP-WEIXIN
const param = {
x,
y,
width,
height,
canvas: useCanvas2d ? canvas : null,
preferToDataURL
}
// #endif
toDataURL(this.canvasId, this, param).then(canvasToTempFilePath).catch(fail)
}
// PC端小程序获取不到 ImageData 数据,长度为0
if (boundingBox && !this.isPC) {
this.signature.getContentBoundingBox(async res => {
this.offscreenWidth = width = res.width
this.offscreenHeight = height = res.height
x = res.startX
y = res.startY
next()
})
} else {
next()
}
// #endif
},
// #ifndef APP-PLUS
getContext() {
return getRect(`#${this.canvasId}`, {
context: this,
type: this.useCanvas2d ? 'fields' : 'boundingClientRect'
}).then(res => {
if (res) {
let { width, height, node: canvas, left, top, right } = res
let pixelRatio = this.pixelRatio ?? uni.getSystemInfoSync().pixelRatio
let context
if (canvas) {
context = canvas.getContext('2d')
canvas.width = width * pixelRatio
canvas.height = height * pixelRatio
} else {
pixelRatio = 1
context = uniContext(this.canvasId, this)
canvas = {
getContext: type => (type == '2d' ? context : null),
createImage,
toDataURL: () => toDataURL(this.canvasId, this),
requestAnimationFrame
}
}
// 支付宝小程序 使用stroke有个默认背景色
context.clearRect(0, 0, width, height)
return {
left,
top,
right,
width,
height,
context,
canvas,
pixelRatio
}
}
})
},
getTouch(e) {
if (this.isPC && this.canvasRect) {
if (!e.touches) return []
e.touches = [...e.touches].map(item => {
return {
...item,
x: item.clientX - this.canvasRect.left,
y: item.clientY - this.canvasRect.top
}
})
}
return e
},
touchStart(e) {
if (!this.canvasEl) return
this.isStart = true
// 微信小程序PC端不支持事件,使用这方法模拟一下
if (this.isPC) {
getRect(`#${this.canvasId}`, {
context: this
}).then(res => {
this.canvasRect = res
this.canvasEl.dispatchEvent('touchstart', wrapEvent(this.getTouch(e)))
})
return
}
this.canvasEl.dispatchEvent('touchstart', wrapEvent(e))
},
touchMove(e) {
if (!this.canvasEl || (!this.isStart && this.canvasEl)) return
this.canvasEl.dispatchEvent('touchmove', wrapEvent(this.getTouch(e)))
},
touchEnd(e) {
if (!this.canvasEl) return
this.isStart = false
this.canvasEl.dispatchEvent('touchend', wrapEvent(e))
this.checkAndEmitEmptyStatus()
}
// #endif
}
}
</script>
<!-- #ifdef APP-VUE -->
<script module="sign" lang="renderjs">
import sign from './render'
export default sign
</script>
<!-- #endif -->
<style lang="scss">
.lime-signature,
.lime-signature__canvas {
/* #ifndef APP-NVUE */
position: relative;
width: 100%;
height: 100%;
/* #endif */
/* #ifdef APP-NVUE */
flex: 1;
/* #endif */
}
.mask {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
}
.offscreen {
position: fixed;
top: 0;
// left: 0;
pointer-events: none;
// background: rgba(0,255,0,0.5);
left: 9999px;
}
</style>
export default {
styles: String,
disableScroll: {
type: Boolean,
default: true
},
type: {
type: String,
default: '2d'
},
// 画笔颜色
penColor: {
type: String,
default: 'black'
},
penSize: {
type: Number,
default: 2
},
// 画板背景颜色
backgroundColor: String,
backgroundImage: String,
// 笔锋
openSmooth: Boolean,
// 画笔最小值
minLineWidth: {
type: Number,
default: 2
},
// 画笔最大值
maxLineWidth: {
type: Number,
default: 6
},
// 画笔达到最小宽度所需最小速度(px/ms),取值范围1.0-10.0,值越小,画笔越容易变细,笔锋效果会比较明显,可以自行调整查看效果,选出自己满意的值。
minSpeed: {
type: Number,
default: 1.5
},
// 相邻两线宽度增(减)量最大百分比,取值范围1-100,为了达到笔锋效果,画笔宽度会随画笔速度而改变,如果相邻两线宽度差太大,过渡效果就会很突兀,使用maxWidthDiffRate限制宽度差,让过渡效果更自然。可以自行调整查看效果,选出自己满意的值。
maxWidthDiffRate: {
type: Number,
default: 20
},
// 限制历史记录数,即最大可撤销数,传入0则关闭历史记录功能
maxHistoryLength: {
type: Number,
default: 20
},
beforeDelay: {
type: Number,
default: 0
},
landscape: {
type: Boolean
},
boundingBox: {
type: Boolean
},
disabled: {
type: Boolean
},
preferToDataURL: Boolean,
pixelRatio: Number
}
\ No newline at end of file
// #ifdef APP-VUE
// import { Signature } from '@signature'
import {
Signature
} from './signature.js'
import {
isTransparent
} from './utils'
export default {
data() {
return {
canvasid: null,
signature: null,
observer: null,
options: {},
saveCount: 0,
}
},
mounted() {
this.$nextTick(this.init)
},
methods: {
checkAndEmitEmptyStatus() {
setTimeout(()=>{
if (this.signature) {
const isEmpty = this.signature.isEmpty()
this.emit({
isEmpty
})
}
},0)
},
init() {
const el = this.$refs.limeSignature || this.$ownerInstance.$el;
this.canvas = document.createElement('canvas')
this.canvas.style = 'width: 100%; height: 100%;'
el.appendChild(this.canvas)
this.signature = new Signature({
el: this.canvas
})
this.signature.pen.setOption(this.options)
const width = this.signature.canvas.get('width')
const height = this.signature.canvas.get('height')
this.canvas?.addEventListener('touchend', this.checkAndEmitEmptyStatus.bind(this))
this.emit({
changeSize: {
width,
height
}
})
},
redo(v) {
if (v && this.signature) {
this.signature.redo()
this.checkAndEmitEmptyStatus()
}
},
undo(v) {
if (v && this.signature) {
this.signature.undo()
this.checkAndEmitEmptyStatus()
}
},
clear(v) {
if (v && this.signature) {
this.signature.clear()
this.checkAndEmitEmptyStatus()
}
},
destroy() {
if (this.canvas) {
this.canvas?.removeEventListener('touchend', this.checkAndEmitEmptyStatus.bind(this))
this.canvas.remove()
}
},
mask(param={}) {
if (this.signature) {
let {destWidth=0, destHeight=0} = JSON.parse(param)
let canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d');
const pixelRatio = this.signature.canvas.get('pixelRatio')
let width = this.signature.canvas.get('width')
let height = this.signature.canvas.get('height')
let context = this.signature.canvas.get('context')
canvas.width = width * pixelRatio
canvas.height = height * pixelRatio
const imageData = context.getImageData(0, 0, width * pixelRatio, height * pixelRatio);
for (let i = 0; i < imageData.data.length; i += 4) {
// 判断当前像素是否透明
const isTransparent = imageData.data[i + 3] === 0;
if (isTransparent) {
// 将透明像素设置为黑色背景
imageData.data[i] = 0;
imageData.data[i + 1] = 0;
imageData.data[i + 2] = 0;
} else {
// 将非透明像素设置为白色内容
imageData.data[i] = 255;
imageData.data[i + 1] = 255;
imageData.data[i + 2] = 255;
}
}
ctx.putImageData(imageData, 0, 0);
if(destWidth&&destHeight){
const _canvas = document.createElement('canvas')
_canvas.width = destWidth
_canvas.height = destHeight
const _context = _canvas.getContext('2d')
_context.drawImage(canvas, 0, 0, destWidth, destHeight)
canvas.remove()
canvas = _canvas
}
this.emit({
save: canvas.toDataURL()
})
canvas.remove()
}
},
save(param) {
let {
fileType = 'png',
quality = 1,
n,
destWidth = 0,
destHeight = 0,
} = JSON.parse(param)
const type = `image/${fileType}`.replace(/jpg/, 'jpeg');
if (n !== this.saveCount) {
this.saveCount = n;
const {
backgroundColor,
backgroundImage,
landscape,
boundingBox
} = this.options
const flag = landscape || backgroundColor || boundingBox||destWidth&&destHeight
const image = this.signature.canvas.get('el').toDataURL(!flag && type, !flag && quality)
if (flag) {
let canvas = document.createElement('canvas')
const pixelRatio = this.signature.canvas.get('pixelRatio')
let width = this.signature.canvas.get('width')
let height = this.signature.canvas.get('height')
let x = 0
let y = 0
const next = () => {
const size = [width, height]
if (landscape) {
size.reverse()
}
canvas.width = size[0] * pixelRatio
canvas.height = size[1] * pixelRatio
const param = [x, y, width, height, 0, 0, width, height].map(item => item * pixelRatio)
const context = canvas.getContext('2d')
if (landscape) {
context.translate(0, width * pixelRatio)
context.rotate(-Math.PI / 2)
}
if (backgroundColor && !isTransparent(backgroundColor)) {
context.fillStyle = backgroundColor
context.fillRect(0, 0, width * pixelRatio, height * pixelRatio)
}
const drawImage = () => {
// param
context.drawImage(this.signature.canvas.get('el'), ...param)
if(destWidth&&destHeight){
const _canvas = document.createElement('canvas')
_canvas.width = destWidth
_canvas.height = destHeight
const _context = _canvas.getContext('2d')
_context.drawImage(canvas, 0, 0, destWidth, destHeight)
canvas.remove()
canvas = _canvas
}
this.emit({
save: canvas.toDataURL(type, quality)
})
canvas.remove()
}
if (backgroundImage) {
const img = new Image();
img.onload = () => {
context.drawImage(img, ...param)
drawImage()
}
img.src = backgroundImage
}
if (!backgroundImage) {
drawImage()
}
}
if (boundingBox) {
const res = this.signature.getContentBoundingBox()
width = res.width
height = res.height
x = res.startX
y = res.startY
next()
} else {
next()
}
} else {
this.emit({
save: image
})
}
}
},
isEmpty(v) {
if (v && this.signature) {
const isEmpty = this.signature.isEmpty()
this.emit({
isEmpty
})
}
},
emit(event) {
this.$ownerInstance.callMethod('onMessage', {
detail: {
data: [{
event
}]
}
})
},
update(v) {
if (v) {
if (this.signature) {
this.options = v
this.signature.pen.setOption(v)
} else {
this.options = v
}
}
}
}
}
// #endif
\ No newline at end of file
function t(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function e(e){for(var i=1;arguments.length>i;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?t(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function a(t,e,i){return e&&o(t.prototype,e),i&&o(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function r(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&u(t,e)}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function u(t,e){return u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},u(t,e)}function c(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function l(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=h(t);if(e){var o=h(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return c(this,i)}}var v=function(t){var e=i(t);return null!==t&&"object"===e||"function"===e},f={}.toString,d=function(t,e){return f.call(t)==="[object "+e+"]"},p=function(t){return d(t,"String")},y=function(t){return d(t,"Number")},g=function(t){return d(t,"Function")},m=function(){function t(){n(this,t),this.__events=void 0,this.__events={}}return a(t,[{key:"on",value:function(t,e){if(t&&e){var i=this.__events[t]||[];i.push(e),this.__events[t]=i}}},{key:"emit",value:function(t,e){var i=this;if(v(t)&&(t=(e=t)&&e.type),t){var n=this.__events[t];n&&n.length&&n.forEach((function(t){t.call(i,e)}))}}},{key:"off",value:function(t,e){var i=this.__events,n=i[t];if(n&&n.length)if(e)for(var o=0,a=n.length;a>o;o++)n[o]===e&&(n.splice(o,1),o--);else delete i[t]}},{key:"getEvents",value:function(){return this.__events}}]),t}(),x=function(t){s(i,m);var e=l(i);function i(t,o){var a;return n(this,i),(a=e.call(this)).context=void 0,a.canvas=void 0,a.attrs=void 0,a.isCanvasElement=void 0,a.context=t,a.canvas=o.canvas||t.canvas||{width:o.width||0,height:o.height||0},a.attrs=o||{},a.isCanvasElement=!0,a}return a(i,[{key:"width",get:function(){return this.canvas.width},set:function(t){this.canvas.width=t}},{key:"height",get:function(){return this.canvas.height},set:function(t){this.canvas.height=t}},{key:"getContext",value:function(){return this.context}},{key:"getBoundingClientRect",value:function(){var t=this.attrs||{},e=t.top,i=t.right,n=t.width,o=t.height,a=t.left,r=t.bottom;return{top:void 0===e?0:e,width:void 0===n?0:n,right:void 0===i?0:i,height:void 0===o?0:o,bottom:void 0===r?0:r,left:void 0===a?0:a}}},{key:"setAttribute",value:function(t,e){this.attrs[t]=e}},{key:"addEventListener",value:function(t,e){this.on(t,e)}},{key:"removeEventListener",value:function(t,e){this.off(t,e)}},{key:"dispatchEvent",value:function(t,e){this.emit(t,e)}}]),i}();var w=function(t,e){return t?function(t){if(!t)return!1;if(1!==t.nodeType||!t.nodeName||"canvas"!==t.nodeName.toLowerCase())return!1;var e=!1;try{t.addEventListener("eventTest",(function(){e=!0})),t.dispatchEvent(new Event("eventTest"))}catch(t){e=!1}return e}(t.canvas)?t.canvas:new x(t,e):null};function b(t,e){try{return t.currentStyle?t.currentStyle[e]:document.defaultView&&document.defaultView.getComputedStyle(t,null).getPropertyValue(e)}catch(t){return{width:300,height:150}[e]}}function k(t,e){var i=e.get("el");if(!i)return t;var n=i.getBoundingClientRect(),o=n.top,a=void 0===o?0:o,r=n.left,s=void 0===r?0:r,h=parseFloat(b(i,"padding-left"))||0,u=parseFloat(b(i,"padding-top"))||0;return{x:t.x-s-h,y:t.y-a-u}}function _(t,e){var i=e.get("landscape");if(!i)return t;if(g(i))return i(t,e);var n=e.get("height");return{x:t.y,y:n-t.x}}var E=function(t,e){var i=t.touches;if(!i||!i.length)return[_(k({x:t.clientX,y:t.clientY},e),e)];i.length||(i=t.changedTouches||[]);for(var n=[],o=0,a=i.length;a>o;o++){var r=i[o],s=r.x,h=r.y,u=r.clientX,c=r.clientY,l=void 0;l=y(s)||y(h)?{x:s,y:h}:k({x:u,y:c},e),n.push(_(l,e))}return n},L=function(t,e){var i=e.x-t.x,n=e.y-t.y;return Math.abs(i)>Math.abs(n)?i>0?"right":"left":n>0?"down":"up"},M=function(t,e){var i=Math.abs(e.x-t.x),n=Math.abs(e.y-t.y);return Math.sqrt(i*i+n*n)},P=function(){function t(e){var i=this,o=e.canvas,a=e.el;n(this,t),this.processEvent=void 0,this.canvas=void 0,this.startTime=0,this.endTime=0,this.startPoints=null,this.startDistance=0,this.center=null,this.pressTimeout=void 0,this.eventType=null,this.direction=null,this.lastMoveTime=0,this.prevMovePoints=null,this.prevMoveTime=0,this.lastMovePoints=null,this.pinch=!1,this._click=function(t){var e=E(t,i.canvas);t.points=e,i.emitEvent("click",t)},this._start=function(t){var e,n,o=E(t,i.canvas);o&&(t.points=o,i.emitEvent("touchstart",t),i.reset(),i.startTime=Date.now(),i.startPoints=o,o.length>1?(i.startDistance=M(o[0],o[1]),i.center={x:(e=o[0]).x+((n=o[1]).x-e.x)/2,y:e.y+(n.y-e.y)/2}):i.pressTimeout=setTimeout((function(){var e="press",n="none";t.direction=n,i.emitStart(e,t),i.emitEvent(e,t),i.eventType=e,i.direction=n}),250))},this._move=function(t){var e=E(t,i.canvas);if(e){t.points=e,i.emitEvent("touchmove",t);var n=i.startPoints;if(n)if(e.length>1){var o=i.startDistance,a=M(e[0],e[1]);t.zoom=a/o,t.center=i.center,i.emitStart("pinch",t),i.emitEvent("pinch",t)}else{var r=e[0].x-n[0].x,s=e[0].y-n[0].y,h=i.direction||L(n[0],e[0]);i.direction=h;var u=i.getEventType(e);t.direction=h,t.deltaX=r,t.deltaY=s,i.emitStart(u,t),i.emitEvent(u,t);var c=i.lastMoveTime,l=Date.now();l-c>0&&(i.prevMoveTime=c,i.prevMovePoints=i.lastMovePoints,i.lastMoveTime=l,i.lastMovePoints=e)}}},this._end=function(t){var e=E(t,i.canvas);t.points=e,i.emitEnd(t),i.emitEvent("touchend",t);var n=i.lastMoveTime;if(100>Date.now()-n){var o=n-(i.prevMoveTime||i.startTime);if(o>0){var a=i.prevMovePoints||i.startPoints,r=i.lastMovePoints;if(!a||!r)return;var s=M(a[0],r[0])/o;s>.3&&(t.velocity=s,t.direction=L(a[0],r[0]),i.emitEvent("swipe",t))}}i.reset();var h=t.touches;h&&h.length>0&&i._start(t)},this._cancel=function(t){i.emitEvent("touchcancel",t),i.reset()},this.canvas=o,this.delegateEvent(a),this.processEvent={}}return a(t,[{key:"delegateEvent",value:function(t){t.addEventListener("click",this._click),t.addEventListener("touchstart",this._start),t.addEventListener("touchmove",this._move),t.addEventListener("touchend",this._end),t.addEventListener("touchcancel",this._cancel)}},{key:"emitEvent",value:function(t,e){this.canvas.emit(t,e)}},{key:"getEventType",value:function(t){var e,i=this.eventType,n=this.startTime,o=this.startPoints;if(i)return i;var a=this.canvas.__events.pan;if(a&&a.length){var r=Date.now();if(!o)return;e=r-n>250&&10>M(o[0],t[0])?"press":"pan"}else e="press";return this.eventType=e,e}},{key:"enable",value:function(t){this.processEvent[t]=!0}},{key:"isProcess",value:function(t){return this.processEvent[t]}},{key:"emitStart",value:function(t,e){this.isProcess(t)||(this.enable(t),this.emitEvent("".concat(t,"start"),e))}},{key:"emitEnd",value:function(t){}},{key:"clearPressTimeout",value:function(){this.pressTimeout&&(clearTimeout(this.pressTimeout),this.pressTimeout=null)}},{key:"reset",value:function(){this.clearPressTimeout(),this.startTime=0,this.startPoints=null,this.startDistance=0,this.direction=null,this.eventType=null,this.pinch=!1,this.prevMoveTime=0,this.prevMovePoints=null,this.lastMoveTime=0,this.lastMovePoints=null}}]),t}(),T=function(t){s(o,m);var e=l(o);function o(t){var i;n(this,o),(i=e.call(this))._attrs={},i._isWindow=void 0,i._attrs=Object.assign({},t),i._isWindow="undefined"!=typeof window,i._initPixelRatio(),i._initCanvas();return["createImage","toDataURL","requestAnimationFrame"].forEach((function(e){i._initAttrs(e,t.canvas||i.get("el"))})),i}return a(o,[{key:"get",value:function(t){return this._attrs[t]}},{key:"set",value:function(t,e){this._attrs[t]=e}},{key:"_initAttrs",value:function(t,e){var i=this;if(!this.get(t)){this.set(t,(function(){return e[t]?e[t].apply(e,arguments):i._isWindow?window[t]?(n=window)[t].apply(n,arguments):"createImage"==t?new Image:null:void 0;var n}))}}},{key:"_initCanvas",value:function(){var t,e,i=this.get("el"),n=this.get("context");if(!i&&!n)throw Error("请指定 id、el 或 context!");t=i?p(i)?(e=i)?document.getElementById(e):null:i:w(n,this._attrs),n&&t&&!t.getContext&&(t.getContext=function(){return n});var o=this.get("width")||function(t){var e=b(t,"width");return"auto"===e&&(e=t.offsetWidth),parseFloat(e)}(t)||t.width,a=this.get("height")||function(t){var e=b(t,"height");return"auto"===e&&(e=t.offsetHeight),parseFloat(e)}(t)||t.height;this.set("canvas",this),this.set("el",t),this.set("context",n||t.getContext("2d")),this.changeSize(o,a);var r=new P({canvas:this,el:t,parent:this.get("parent")});this.set("eventController",r)}},{key:"_initPixelRatio",value:function(){this.get("pixelRatio")||this.set("pixelRatio",window&&window.devicePixelRatio||1)}},{key:"changeSize",value:function(t,e){var n,o=this.get("pixelRatio"),a=this.get("el");(a.style&&(a.style.width=t+"px",a.style.height=e+"px"),(n=a)&&"object"===i(n)&&(1===n.nodeType&&n.nodeName||n.isCanvasElement))&&(a.width=t*o,a.height=e*o,1!==o&&this.get("context").scale(o,o));this.set("width",t),this.set("height",e)}},{key:"destroy",value:function(){if(!this.get("destroyed")){var t=this.get("el");t.width=0,t.height=0,this.clear(),this._attrs={},this.set("destroyed",!0)}}},{key:"clear",value:function(){}},{key:"isDestroyed",value:function(){return this.get("destroyed")}}]),o}();var S={penColor:"black",backgroundColor:"",openSmooth:!0,penSize:2,minLineWidth:2,maxLineWidth:6,minSpeed:1.5,maxWidthDiffRate:20,maxHistoryLength:20},D=null,O=function(){function t(e){var i=this;n(this,t),this.canAddHistory=!0,this.points=[],this.historyList=[],this.undoneList=[],this.canvas=void 0,this._isEmpty=!0,this.active=!1,this.getLineWidth=function(t){var e=i.get("options"),n=e.minSpeed,o=e.minLineWidth,a=i.getMaxLineWidth();return Math.min(Math.max(a-(a-o)*t/Math.max(Math.min(n,10),1),o),a)},this.drawTrapezoid=function(t,e,n,o){var a=i.get("context");a.beginPath(),a.moveTo(Number(t.x.toFixed(1)),Number(t.y.toFixed(1))),a.lineTo(Number(e.x.toFixed(1)),Number(e.y.toFixed(1))),a.lineTo(Number(n.x.toFixed(1)),Number(n.y.toFixed(1))),a.lineTo(Number(o.x.toFixed(1)),Number(o.y.toFixed(1))),a.fillStyle=i.get("options").penColor,a.fill(),a.draw&&a.draw(!0)},this.drawNoSmoothLine=function(t,e){e.lastX=t.x+.5*(e.x-t.x),e.lastY=t.y+.5*(e.y-t.y),"number"==typeof t.lastX&&i.drawCurveLine(t.lastX,t.lastY,t.x,t.y,e.lastX,e.lastY,i.getMaxLineWidth())},this.drawCurveLine=function(t,e,n,o,a,r,s){s=Number(s.toFixed(1));var h=i.get("context");h.lineWidth=s,h.beginPath(),h.moveTo(Number(t.toFixed(1)),Number(e.toFixed(1))),h.quadraticCurveTo(Number(n.toFixed(1)),Number(o.toFixed(1)),Number(a.toFixed(1)),Number(r.toFixed(1))),h.stroke(),h.draw&&h.draw(!0)},this.getRadianData=function(t,e,i,n){var o=i-t,a=n-e;if(0===o)return{val:0,pos:-1};if(0===a)return{val:0,pos:1};var r=Math.abs(Math.atan(a/o));return i>t&&e>n||t>i&&n>e?{val:r,pos:1}:{val:r,pos:-1}},this.getRadianPoints=function(t,e,i,n){if(0===t.val)return 1===t.pos?[{x:e,y:i+n},{x:e,y:i-n}]:[{y:i,x:e+n},{y:i,x:e-n}];var o=Math.sin(t.val)*n,a=Math.cos(t.val)*n;return 1===t.pos?[{x:e+o,y:i+a},{x:e-o,y:i-a}]:[{x:e+o,y:i-a},{x:e-o,y:i+a}]},this.drawSmoothLine=function(t,e){var n=e.x-t.x,o=e.y-t.y;if(Math.abs(n)+Math.abs(o)>2?(e.lastX1=t.x+.3*n,e.lastY1=t.y+.3*o,e.lastX2=t.x+.7*n,e.lastY2=t.y+.7*o):(e.lastX1=e.lastX2=t.x+.5*n,e.lastY1=e.lastY2=t.y+.5*o),e.perLineWidth=(t.lineWidth+e.lineWidth)/2,"number"==typeof t.lastX1){if(i.drawCurveLine(t.lastX2,t.lastY2,t.x,t.y,e.lastX1,e.lastY1,e.perLineWidth),t.isFirstPoint)return;if(t.lastX1===t.lastX2&&t.lastY1===t.lastY2)return;var a=i.getRadianData(t.lastX1,t.lastY1,t.lastX2,t.lastY2),r=i.getRadianPoints(a,t.lastX1,t.lastY1,t.perLineWidth/2),s=i.getRadianPoints(a,t.lastX2,t.lastY2,e.perLineWidth/2);i.drawTrapezoid(r[0],s[0],s[1],r[1])}else e.isFirstPoint=!0},this.addHistory=function(){var t=i.get("options").maxHistoryLength;if(t&&i.canAddHistory)if(i.canAddHistory=!1,i.get("createImage")){var e=null;e=i.get("createImage")();var n=i.get("toDataURL")&&i.get("toDataURL")();p(n)?e.src=n:n.then((function(t){e.src=t})),e.onload=function(){var n=D;D=e,i.historyList.push(n),i.historyList=i.historyList.slice(-t)}}else i.historyList.length++},this.drawByImage=function(t){var e=i.get("context"),n=i.get("width"),o=i.get("height");e.clearRect(0,0,n,o);try{t&&e.drawImage(t,0,0,n,o),e.draw&&e.draw(!0)}catch(t){i.historyList.length=0}},this.isEmpty=function(){return i.get("options").maxHistoryLength>0?0===i.historyList.length:i._isEmpty},this.clear=function(){if(!i.get("options").disabled){var t=i.get("context");t.clearRect(0,0,i.get("width"),i.get("height")),t.draw&&t.draw(),i._isEmpty=!0,D=null,i.historyList.length=0}},this.undo=function(){if(!i.get("options").disabled&&(0===i.get("options").maxHistoryLength&&i.clear(),i.get("createImage")&&i.historyList.length)){var t=i.historyList.pop();i.drawByImage(t),i.undoneList.push(D),D=t,i.historyList.length||i.undoneList.length||i.clear()}},this.redo=function(){if(i.undoneList.length&&!i.get("options").disabled){var t=i.undoneList.pop();i.historyList.push(D),i.drawByImage(t),D=t,i._isEmpty=!1}},this.canvas=e,this.canvas.set("pen",S),this.init()}return a(t,[{key:"getOption",value:function(){}},{key:"setOption",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e({},t),n=i.maxLineWidth;if(n&&t.penSize&&n==S.maxLineWidth){var o=Math.max(n,t.penSize);i.maxLineWidth=o}this.canvas.set("pen",Object.assign({},S,i))}},{key:"get",value:function(t){return this.canvas.get("options"==t?"pen":t)}},{key:"init",value:function(){var t=this;this.get("context").lineCap="round",this.canvas.on("touchstart",(function(e){return t.onDrawStart(e)})),this.canvas.on("touchmove",(function(e){return t.onDrawMove(e)})),this.canvas.on("touchend",(function(e){return t.onDrawEnd(e)}))}},{key:"drawBackground",value:function(){var t=this.get("context"),e=this.get("width"),i=this.get("height"),n=this.get("options"),o=n.backgroundColor,a=n.backgroundImage;o&&(t.fillStyle=o,t.fillRect(0,0,e,i),t.draw&&t.draw(!0)),a&&this.drawByImage(a)}},{key:"getImageData",value:function(t){if(t){var e=this.get("width"),i=this.get("height"),n=this.get("el"),o="CANVAS"===n.nodeName,a=o?e:n.width,r=o?i:n.height;if(o){var s=document.createElement("canvas");s.width=e,s.height=i;var h=s.getContext("2d");h.drawImage(n,0,0,e,i);var u=h.getImageData(0,0,e,i).data;return t(u)}var c,l=this.get("context").getImageData(0,0,a,r);return v(c=l)&&g(c.then)&&g(c.catch)?(l.then((function(e){return t(e.data)})),null):t(l.data)}}},{key:"getMaskedImageData",value:function(t){if(t)return this.getImageData((function(e){for(var i=0;e.length>i;i+=4){0===e[i+3]?(e[i]=0,e[i+1]=0,e[i+2]=0):(e[i]=255,e[i+1]=255,e[i+2]=255)}return t(e)}))}},{key:"getContentBoundingBox",value:function(t){var e=this.get("pixelRatio"),i=this.get("width"),n=this.get("height"),o=this.get("el"),a="CANVAS"===o.nodeName,r=a?i:o.width,s=a?n:o.height;e=a?1:e;return this.getImageData((function(i){for(var n=Math.floor(r),o=n,a=Math.floor(s),h=0,u=0,c=0;i.length>c;c+=4){if(i[c+3]>0){var l=c/4%n,v=Math.floor(c/4/n);o=Math.min(o,l),a=Math.min(a,v),h=Math.max(h,l),u=Math.max(u,v)}}var f={width:(h-o+1)/e,height:(u-a+1)/e,startX:o/e,startY:a/e};return t&&t(f),f}))}},{key:"remove",value:function(){var t=this;this.canvas.off("touchstart",(function(e){return t.onDrawStart(e)})),this.canvas.off("touchmove",(function(e){return t.onDrawMove(e)})),this.canvas.off("touchend",(function(e){return t.onDrawEnd(e)}))}},{key:"disableScroll",value:function(t){t.preventDefault&&this.get("options").disableScroll&&t.preventDefault()}},{key:"onDrawStart",value:function(t){if(!this.get("options").disabled){this.disableScroll(t),this.undoneList.length=0;var e=t.points;if(this.active){this.canAddHistory=!0,this.get("context").strokeStyle=this.get("options").penColor;var i=e[0];this.initPoint(i.x,i.y)}}}},{key:"onDrawMove",value:function(t){if(!this.get("options").disabled&&(this.disableScroll(t),this.active)){var e=t.points[0];this.initPoint(e.x,e.y),this.onDraw()}}},{key:"onDrawEnd",value:function(t){this.active&&!this.get("options").disabled&&(this.addHistory(),this.canAddHistory=!0,this.points=[])}},{key:"onDraw",value:function(){var t=this,e=this.get("context");if(this.points.length>=2){e.lineWidth=this.get("options").penSize||2;var i=this.points.slice(-1)[0],n=this.points.slice(-2,-1)[0],o=function(){t._isEmpty=!1,t.get("options").openSmooth?t.drawSmoothLine(n,i):t.drawNoSmoothLine(n,i)};o()}}},{key:"getMaxLineWidth",value:function(){var t=this.get("options");return Math.min(t.penSize,t.maxLineWidth)}},{key:"initPoint",value:function(t,e){var i={x:t,y:e,t:Date.now()},n=this.points.slice(-1)[0];if(!n||n.t!==i.t&&(n.x!==t||n.y!==e)){if(this.get("options").openSmooth&&n){var o=this.points.slice(-2,-1)[0];if(i.distance=Math.sqrt(Math.pow(i.x-n.x,2)+Math.pow(i.y-n.y,2)),i.speed=i.distance/(i.t-n.t||.1),i.lineWidth=this.getLineWidth(i.speed),o&&o.lineWidth&&n.lineWidth){var a=(i.lineWidth-n.lineWidth)/n.lineWidth,r=this.get("options").maxWidthDiffRate/100;if(r=r>1?1:.01>r?.01:r,Math.abs(a)>r)i.lineWidth=n.lineWidth*(1+(a>0?r:-r))}}this.points.push(i),this.points=this.points.slice(-3)}}}]),t}(),W=function(){function t(e){n(this,t),this.canvas=void 0,this._ee=void 0,this.pen=void 0;var i=new T(e);i.set("parent",this),this.canvas=i,this._ee=new m,this.pen=new O(i),this.init()}return a(t,[{key:"init",value:function(){this.pen.active=!0}},{key:"destroy",value:function(){this.canvas.destroy()}},{key:"clear",value:function(){this.pen.clear()}},{key:"undo",value:function(){this.pen.undo()}},{key:"redo",value:function(){this.pen.redo()}},{key:"save",value:function(){}},{key:"getContentBoundingBox",value:function(t){return this.pen.getContentBoundingBox(t)}},{key:"getMaskedImageData",value:function(t){return this.pen.getMaskedImageData(t)}},{key:"isEmpty",value:function(){return this.pen.isEmpty()}},{key:"on",value:function(t,e){this._ee.on(t,e)}},{key:"emit",value:function(t,e){this._ee.emit(t,e)}},{key:"off",value:function(t,e){this._ee.off(t,e)}}]),t}();export default W;export{W as Signature};
// @ts-nocheck
import { LimeSignatureOptions, LimeSignaturePoint, LimeSignatureLine } from '../../index.uts'
let points : LimeSignatureLine = []
let undoStack : LimeSignatureLine[] = [];
let redoStack : LimeSignatureLine[] = [];
let lastX = 0;
let lastY = 0;
// #ifdef APP-ANDROID || APP-IOS
type SignatureUniElement = UniElement
type SignatureCanvasContext = DrawableContext
// #endif
// #ifdef APP-HARMONY
type SignatureUniElement = UniCanvasElement
type SignatureCanvasContext = CanvasRenderingContext2D
// #endif
export class Signature {
el : SignatureUniElement
ctx : SignatureCanvasContext
options : LimeSignatureOptions = {
penColor: 'black',
openSmooth: true,
disableScroll: true,
disabled: false,
penSize: 2,
minLineWidth: 2,
maxLineWidth: 6,
minSpeed: 1.5,
maxWidthDiffRate: 20,
maxHistoryLength: 20
} as LimeSignatureOptions
isEmpty : boolean = true
isDrawing : boolean = false
// historyList : LimeSignaturePoint[][] = []
// id : string
// instance : ComponentPublicInstance
touchstartCallbackWrapper: UniCallbackWrapper|null = null
touchmoveCallbackWrapper: UniCallbackWrapper|null= null
touchendCallbackWrapper: UniCallbackWrapper|null= null
change: ((isEmpty: boolean) => void)|null = null
constructor(el : SignatureUniElement) {
this.el = el
// #ifdef APP-ANDROID || APP-IOS
this.ctx = el.getDrawableContext() as DrawableContext
// #endif
// #ifdef APP-HARMONY
const dpr = uni.getDeviceInfo().devicePixelRatio ?? 1;
el.width = el.offsetWidth * dpr;
el.height = el.offsetHeight * dpr;
this.ctx = el.getContext('2d')
this.ctx.scale(dpr, dpr); // 仅需调用一次,当调用 reset 方法后需要再次 scale
// #endif
this.init()
}
onChange(cb: (isEmpty: boolean) => void){
this.change = cb
}
init() {
this.touchstartCallbackWrapper = this.el.addEventListener('touchstart', this.onTouchStart)
this.touchmoveCallbackWrapper = this.el.addEventListener('touchmove', this.onTouchMove)
this.touchendCallbackWrapper = this.el.addEventListener('touchend', this.onTouchEnd)
}
remove() {
if(this.touchstartCallbackWrapper == null) return
this.el.removeEventListener('touchstart', this.touchstartCallbackWrapper!)
this.el.removeEventListener('touchmove', this.touchmoveCallbackWrapper!)
this.el.removeEventListener('touchend', this.touchendCallbackWrapper!)
}
setOption(options : LimeSignatureOptions) {
this.options = options
}
disableScroll(event : UniTouchEvent) {
event.stopPropagation()
if (this.options.disableScroll) {
{
event.preventDefault()
}
}
}
getTouchLimeSignaturePoint(event : UniTouchEvent) : LimeSignaturePoint {
const rect = this.el.getBoundingClientRect()
const touche = event.touches[0];
const x = touche.clientX
const y = touche.clientY
// const force = touche.force
return {
x: x - rect.left,
y: y - rect.top
} as LimeSignaturePoint
}
onTouchStart: (event : UniTouchEvent) => void = (event : UniTouchEvent) =>{
if (this.options.disabled) {
return
}
this.disableScroll(event)
const { x, y } = this.getTouchLimeSignaturePoint(event)
this.isDrawing = true;
this.isEmpty = false
lastX = x
lastY = y
points.push({ x, y } as LimeSignaturePoint);
}
onTouchMove: (event : UniTouchEvent) => void = (event : UniTouchEvent) =>{
if (this.options.disabled || !this.isDrawing) {
return
}
this.disableScroll(event)
const { x, y } = this.getTouchLimeSignaturePoint(event)
const lineWidth = this.options.penSize
const strokeStyle = this.options.penColor
const point = { x, y } as LimeSignaturePoint
const last = { x: lastX, y: lastY } as LimeSignaturePoint
this.drawLine(point, last, lineWidth, strokeStyle)
lastX = x
lastY = y
points.push({ x, y, c: strokeStyle, w: lineWidth } as LimeSignaturePoint);
}
onTouchEnd: (event : UniTouchEvent) => void = (event : UniTouchEvent) =>{
this.disableScroll(event)
this.isDrawing = false;
undoStack.push(points);
redoStack = [] as LimeSignatureLine[];
points = [] as LimeSignaturePoint[];
this.change?.(this.isEmpty);
}
drawLine(point : LimeSignaturePoint, last : LimeSignaturePoint, lineWidth : number, strokeStyle : string) {
const ctx = this.ctx
ctx.lineWidth = lineWidth
ctx.strokeStyle = strokeStyle
ctx.lineCap = 'round'
ctx.lineJoin = 'round'
ctx.beginPath()
ctx.moveTo(last.x, last.y)
ctx.lineTo(point.x, point.y)
ctx.stroke()
ctx.closePath()
// ctx.update()
this._draw()
}
_clear() {
// #ifdef APP-ANDROID || APP-IOS
this.ctx.reset()
// #endif
// #ifdef APP-HARMONY
this.ctx.clearRect(0,0,100000,100000)
// #endif
}
_draw() {
// #ifdef APP-ANDROID || APP-IOS
this.ctx.update()
// #endif
}
// addHistory() { }
clear() {
// this.ctx.reset()
// this.ctx.update()
this._clear()
this._draw()
this.isEmpty = true
undoStack = [] as LimeSignatureLine[];
redoStack = [] as LimeSignatureLine[];
points = [] as LimeSignaturePoint[];
}
undo() {
if(redoStack.length == this.options.maxHistoryLength && this.options.maxHistoryLength != 0){
return
}
// this.ctx.reset()
this._clear()
if(undoStack.length > 0){
const lastPath : LimeSignatureLine = undoStack.pop()!;
redoStack.push(lastPath);
if(undoStack.length == 0){
this.isEmpty = true
// this.ctx.update()
this._draw()
return
}
for (let l = 0; l < undoStack.length; l++) {
for (let i = 1; i < undoStack[l].length; i++) {
const last = undoStack[l][i - 1]
const point = undoStack[l][i]
this.drawLine(point, last, point.w!, point.c!)
}
}
} else {
// this.ctx.update()
this._draw()
}
}
redo() {
if(redoStack.length < 1) return
const lastPath : LimeSignatureLine = redoStack.pop()!;
undoStack.push(lastPath);
this.isEmpty = false
for (let l = 0; l < undoStack.length; l++) {
for (let i = 1; i < undoStack[l].length; i++) {
const last = undoStack[l][i - 1]
const point = undoStack[l][i]
this.drawLine(point, last, point.w!, point.c!)
}
}
}
// restore() { }
}
\ No newline at end of file
export interface SignaturePadProps {
/**
* 绘图样式(CSS样式字符串)
*/
styles: string
/**
* 画笔颜色
*/
penColor: string
/**
* 画笔粗细(像素)
*/
penSize: number
/**
* 背景颜色
*/
backgroundColor: string
/**
* 是否开启平滑绘制
*/
openSmooth: boolean
/**
* 最小笔触宽度
*/
minLineWidth: number
/**
* 最大笔触宽度
*/
maxLineWidth: number
/**
* 最小绘制速度(像素/秒)
*/
minSpeed: number
/**
* 最大宽度差异率
*/
maxWidthDiffRate: number
/**
* 历史记录最大长度
*/
maxHistoryLength: number
/**
* 是否禁止滚动穿透
*/
disableScroll: boolean
/**
* 组件是否禁用
*/
disabled: boolean
/**
* 是否横屏模式
*/
landscape: boolean
}
\ No newline at end of file
export function compareVersion(v1, v2) {
v1 = v1.split('.')
v2 = v2.split('.')
const len = Math.max(v1.length, v2.length)
while (v1.length < len) {
v1.push('0')
}
while (v2.length < len) {
v2.push('0')
}
for (let i = 0; i < len; i++) {
const num1 = parseInt(v1[i], 10)
const num2 = parseInt(v2[i], 10)
if (num1 > num2) {
return 1
} else if (num1 < num2) {
return -1
}
}
return 0
}
function gte(version) {
let { SDKVersion } = uni.getSystemInfoSync()
// #ifdef MP-ALIPAY
SDKVersion = my.SDKVersion
// #endif
return compareVersion(SDKVersion, version) >= 0;
}
export function canIUseCanvas2d() {
// #ifdef MP-WEIXIN
return gte('2.9.0');
// #endif
// #ifdef MP-ALIPAY
return gte('2.7.0');
// #endif
// #ifdef MP-TOUTIAO
return gte('1.78.0');
// #endif
return false
}
export const wrapEvent = (e) => {
if (!e) return;
if (!e.preventDefault) {
e.preventDefault = function() {};
}
return e;
}
export const requestAnimationFrame = (cb) => {
setTimeout(cb, 30)
}
// #ifdef MP
export const prefix = () => {
// #ifdef MP-TOUTIAO
return tt
// #endif
// #ifdef MP-WEIXIN
return wx
// #endif
// #ifdef MP-BAIDU
return swan
// #endif
// #ifdef MP-ALIPAY
return my
// #endif
// #ifdef MP-QQ
return qq
// #endif
// #ifdef MP-360
return qh
// #endif
}
// #endif
/**
* base64转路径
* @param {Object} base64
*/
export function base64ToPath(base64) {
const [, format, bodyData] = /data:image\/(\w+);base64,(.*)/.exec(base64) || [];
return new Promise((resolve, reject) => {
// #ifdef MP
const p = prefix()
const fs = p.getFileSystemManager()
//自定义文件名
if (!format) {
reject(new Error('ERROR_BASE64SRC_PARSE'))
}
const time = new Date().getTime();
const filePath = `${p.env.USER_DATA_PATH}/${time}.${format}`;
fs.writeFile({
filePath,
data: base64.split(',')[1],
encoding: 'base64',
success() {
resolve(filePath)
},
fail(err) {
reject(err)
}
})
// #endif
// #ifdef APP-PLUS
const bitmap = new plus.nativeObj.Bitmap('bitmap' + Date.now())
bitmap.loadBase64Data(base64, () => {
if (!format) {
reject(new Error('ERROR_BASE64SRC_PARSE'))
}
const time = new Date().getTime();
const filePath = `_doc/uniapp_temp/${time}.${format}`
bitmap.save(filePath, {},
() => {
bitmap.clear()
resolve(filePath)
},
(error) => {
bitmap.clear()
reject(error)
})
}, (error) => {
bitmap.clear()
reject(error)
})
// #endif
})
}
export function sleep(delay) {
return new Promise(resolve => setTimeout(resolve, delay))
}
export function getRect(selector, options = {}) {
const typeDefault = 'boundingClientRect'
const { context, type = typeDefault} = options
return new Promise((resolve, reject) => {
const dom = uni.createSelectorQuery().in(context).select(selector);
const result = (rect) => {
if(rect) {
resolve(rect)
} else {
reject()
}
}
if(type == typeDefault) {
dom[type](result).exec()
} else {
dom[type]({
node: true,
size: true,
rect: true
}, result).exec()
}
});
};
export function isTransparent(color) {
// 判断颜色是否为 transparent
if (color === 'transparent') {
return true;
}
// 判断颜色是否为 rgba 的 a 为 0
if (color.startsWith('rgba')) {
const regex = /\d+(\.\d+)?/g;
const matches = color.match(regex);
if (matches !== null) {
const alpha = parseFloat(matches[3]);
if (alpha === 0) {
return true;
}
}
}
return false;
}
\ No newline at end of file
<template>
<view style="height: 950rpx;">
<l-signature ref="signature" :pen-color="penColor" :pen-size="10" @change="change"></l-signature>
</view>
<image style="width: 750rpx;" :src="url" v-if="url" mode="widthFix"></image>
<!-- <view style="height: 200rpx; overflow: visible;"></view> -->
<view style="padding:16px">
<button type="primary" style="margin-bottom:10px" @click="clear">清空</button>
<button type="primary" style="margin-bottom:10px" @click="undo">撤消</button>
<button type="primary" style="margin-bottom:10px" @click="redo">恢复</button>
<button type="primary" style="margin-bottom:10px" @click="save">生成</button>
</view>
</template>
<script lang="uts">
import type {LimeSignatureToTempFilePathOptions, LimeSignatureToFileSuccess} from '@/uni_modules/lime-signature'
export default {
data() {
return {
penColor: 'red',
url: ''
}
},
methods: {
change(isEmpty:boolean) {
console.log('isEmpty:::', isEmpty)
},
clear() {
const signature = this.$refs['signature'] as LSignatureComponentPublicInstance
signature.clear()
},
undo() {
const signature = this.$refs['signature'] as LSignatureComponentPublicInstance
signature.undo()
},
redo() {
const signature = this.$refs['signature'] as LSignatureComponentPublicInstance
signature.redo()
},
save() {
const signature = this.$refs['signature'] as LSignatureComponentPublicInstance
signature.canvasToTempFilePath({
success: (res : LimeSignatureToFileSuccess) : void => {
console.log('isEmpty', res.isEmpty)
this.url = res.tempFilePath
}
} as LimeSignatureToTempFilePathOptions)
}
},
mounted() {
setTimeout(() => {
this.penColor = 'blue'
}, 2000)
}
}
</script>
<style>
</style>
\ No newline at end of file
<template>
<view class="signature" :class="{landscape}">
<text class="signature-text">请在此处签名</text>
<view class="signature-area" v-if="landscape">
<l-signature disableScroll ref="signatureRef" :penColor="penColor" :penSize="penSize" :key="landscape" uid="0"
:minLineWidth="2" :openSmooth="openSmooth" :boundingBox="bBox" landscape></l-signature>
</view>
<view class="signature-area" v-if="!landscape">
<l-signature disableScroll ref="signatureRef" :penColor="penColor" :penSize="penSize" :key="!landscape" uid="1"
:minLineWidth="2" :openSmooth="openSmooth" :boundingBox="bBox"></l-signature>
</view>
<view class="screen-handle" @click="change">
<!-- #ifdef APP-NVUE -->
<text>{{landscape ? '横':'竖'}}</text>
<!-- #endif -->
<!-- #ifndef APP-NVUE -->
<image class="screen-handle__image" :src="icon" mode="widthFix"></image>
<!-- #endif -->
</view>
<view class="tools">
<view class="tools-item" @tap="isShowPen = !isShowPen;">
<!-- #ifdef APP-NVUE -->
<text>设置</text>
<!-- #endif -->
<!-- #ifndef APP-NVUE -->
<image class="tools-item__image" src="https://fastly.jsdelivr.net/gh/liangei/image@latest/brush-fill.svg" mode="widthFix"></image>
<!-- #endif -->
</view>
<view class="tools-item" @tap="onClick('undo')">
<!-- #ifdef APP-NVUE -->
<text>撤消</text>
<!-- #endif -->
<!-- #ifndef APP-NVUE -->
<image class="tools-item__image" src="https://fastly.jsdelivr.net/gh/liangei/image@latest/reply-fill.svg" mode="widthFix"></image>
<!-- #endif -->
</view>
<view class="tools-item restore" @tap="onClick('restore')">
<!-- #ifdef APP-NVUE -->
<text>上一步</text>
<!-- #endif -->
<!-- #ifndef APP-NVUE -->
<image class="tools-item__image" src="https://fastly.jsdelivr.net/gh/liangei/image@latest/reply-fill.svg" mode="widthFix"></image>
<!-- #endif -->
</view>
<view class="tools-item" @tap="onClick('clear')">
<!-- #ifdef APP-NVUE -->
<text>清空</text>
<!-- #endif -->
<!-- #ifndef APP-NVUE -->
<image class="tools-item__image" src="https://fastly.jsdelivr.net/gh/liangei/image@latest/brush-2-fill.svg" mode="widthFix"></image>
<!-- #endif -->
</view>
<view class="tools-item" @tap="onClick('save')">
<!-- #ifdef APP-NVUE -->
<text>保存</text>
<!-- #endif -->
<!-- #ifndef APP-NVUE -->
<image class="tools-item__image" src="https://fastly.jsdelivr.net/gh/liangei/image@latest/save-fill.svg" mode="widthFix"></image>
<!-- #endif -->
</view>
<view class="tools-item" @tap="onClick('save2')">
<!-- #ifdef APP-NVUE -->
<text>保存</text>
<!-- #endif -->
<!-- #ifndef APP-NVUE -->
<image class="tools-item__image" src="https://fastly.jsdelivr.net/gh/liangei/image@latest/save-fill.svg" mode="widthFix"></image>
<!-- #endif -->
</view>
</view>
<uni-popup ref="popup" type="bottom" @change="isShowPen = $event.show">
<view class="popup-wrap">
<view class="popup-item">
<view class="popup-item__head">
<view class="popup-item__title">笔锋</view>
<view class="popup-item__more">
<text class="popup-item__more-text">{{openSmooth}}</text>
<switch class="popup-item__more-switch" @change="() => openSmooth = !openSmooth" :checked="openSmooth"/>
</view>
</view>
<view class="popup-item__head">
<view class="popup-item__title">包围盒</view>
<view class="popup-item__more">
<text class="popup-item__more-text">{{bBox}}</text>
<switch class="popup-item__more-switch" @change="() => bBox = !bBox" :checked="bBox"/>
</view>
</view>
<slider :value="penSize" max="20" @change="penSize = $event.detail.value" show-value/>
</view>
</view>
</uni-popup>
<!-- <view class="buttons">
<button @click="onClick('clear')">清空</button>
<button @click="onClick('undo')">撤销</button>
<button @click="onClick('save')">保存</button>
<button @click="bBox = !bBox">bBox{{bBox?'开':'关'}}</button>
<button @click="onClick('openSmooth')">压感{{openSmooth?'开':'关'}}</button>
</view> -->
<!-- <view style="background-color: #2196f3; text-align: center;">
<view style="border: 2px dashed #fff; display: inline-block;">
<image :src="url" v-if="url" style="width: 370rpx;" mode="widthFix"></image>
</view>
</view> -->
<view class="signature-preview" v-if="url">
<image class="signature-preview__image" :src="url" mode="widthFix"></image>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello',
penColor: 'red',
penSize: 16,
url: '',
show: false,
landscape: false,
openSmooth: true,
bottomHeight: 0,
bBox: true,
isShowPen: false,
customBar: this.CustomBar || 0,
}
},
watch:{
isShowPen(v) {
if(!v) {
this.$refs.popup.close()
} else {
this.$refs.popup.open()
}
}
},
computed: {
// styles() {
// if(this.landscape) {
// return `width: 100vw; height: 100vh`
// }
// return `flex:1`
// },
icon() {
if(this.landscape) {
return `data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik00MSAxOUgyOVY3IiBzdHJva2U9IiMzMzMiIHN0cm9rZS13aWR0aD0iNCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PHBhdGggZD0iTTE4IDZINlYxOCIgc3Ryb2tlPSIjMzMzIiBzdHJva2Utd2lkdGg9IjQiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxwYXRoIGQ9Ik0zMCA0Mkg0MlYzMCIgc3Ryb2tlPSIjMzMzIiBzdHJva2Utd2lkdGg9IjQiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxwYXRoIGQ9Ik03IDI5SDE5VjQxIiBzdHJva2U9IiMzMzMiIHN0cm9rZS13aWR0aD0iNCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PHBhdGggZD0iTTQyIDZMMjkgMTkiIHN0cm9rZT0iIzMzMyIgc3Ryb2tlLXdpZHRoPSI0IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48cGF0aCBkPSJNMTkgMjlMNiA0MiIgc3Ryb2tlPSIjMzMzIiBzdHJva2Utd2lkdGg9IjQiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==`
}
return `data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik02IDZMMTYgMTUuODk5NSIgc3Ryb2tlPSIjMzMzIiBzdHJva2Utd2lkdGg9IjQiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxwYXRoIGQ9Ik02IDQxLjg5OTVMMTYgMzIiIHN0cm9rZT0iIzMzMyIgc3Ryb2tlLXdpZHRoPSI0IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48cGF0aCBkPSJNNDIuMDAwMSA0MS44OTk1TDMyLjEwMDYgMzIiIHN0cm9rZT0iIzMzMyIgc3Ryb2tlLXdpZHRoPSI0IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48cGF0aCBkPSJNNDEuODk5NSA2TDMyIDE1Ljg5OTUiIHN0cm9rZT0iIzMzMyIgc3Ryb2tlLXdpZHRoPSI0IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48cGF0aCBkPSJNMzMgNkg0MlYxNSIgc3Ryb2tlPSIjMzMzIiBzdHJva2Utd2lkdGg9IjQiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxwYXRoIGQ9Ik00MiAzM1Y0MkgzMyIgc3Ryb2tlPSIjMzMzIiBzdHJva2Utd2lkdGg9IjQiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxwYXRoIGQ9Ik0xNSA0Mkg2VjMzIiBzdHJva2U9IiMzMzMiIHN0cm9rZS13aWR0aD0iNCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PHBhdGggZD0iTTYgMTVWNkgxNSIgc3Ryb2tlPSIjMzMzIiBzdHJva2Utd2lkdGg9IjQiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==`
}
},
methods: {
change() {
this.landscape = !this.landscape;
this.url = ''
},
open() {
// 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ,type 属性将失效 ,仅支持 ['top','left','bottom','right','center']
this.$refs.popup.open()
this.show = true
},
onClick(type) {
const {signatureRef} = this.$refs
if (type == 'openSmooth') {
this.openSmooth = !this.openSmooth
return
}
if (type == 'save') {
signatureRef.canvasToTempFilePath({
// destWidth: 300,
// destHeight: 200,
quality: 0.8,
success: (res) => {
uni.getImageInfo({
src: res.tempFilePath,
success(res) {
console.log('Temp res', res)
}
})
this.url = res.tempFilePath
}
})
return
}
if (type == 'save2') {
signatureRef.canvasToMaskPath({
// destWidth: 300,
// destHeight: 200,
success: (res) => {
uni.getImageInfo({
src: res.tempFilePath,
success(res) {
console.log('Mask res', res)
}
})
this.url = res.tempFilePath
}
})
return
}
if (signatureRef)
signatureRef[type]()
}
}
}
</script>
<style lang="scss">
.signature {
/* #ifndef APP-NVUE */
height: calc(100vh - var(--window-top));
/* #endif */
/* #ifdef APP-NVUE */
flex: 1;
/* #endif */
&-area {
/* #ifndef APP-NVUE */
height: calc(100vh - var(--window-top) - 120rpx);
/* #endif */
/* #ifdef APP-NVUE */
flex: 1;
/* #endif */
}
&-text {
position: absolute;
/* #ifndef APP-NVUE */
left: 50%;
top: 50%;
/* #endif */
/* #ifdef APP-NVUE */
left: 375rpx;
top: 375rpx;
/* #endif */
font-size: 60rpx;
color: #ddd;
transform: translate(-50%,-50%);
z-index: -1;
transition: transform 300ms;
}
&-preview {
position: absolute;
bottom: 120rpx;
right: 20rpx;
width: 120px;
background: #000;
box-shadow: 0 0 30rpx rgba(0, 0, 0, 0.05);
&__image {
/* #ifndef APP-NVUE */
width: 100%;
/* #endif */
/* #ifdef APP-NVUE */
flex: 1;
/* #endif */
}
}
&.landscape {
.signature-preview {
bottom: 20rpx;
width: 220px;
}
.signature-text {
transform: translate(-50%,-50%) rotate(90deg);
}
.tools {
z-index: 1;
position: absolute;
left: 10rpx;
bottom: 10rpx;
transform: rotate(90deg) translate(-100%, 0%);
transform-origin: bottom left;
padding: 0 16rpx;
border-radius: 50rpx;
&_item {
padding: 0 16rpx;
}
}
// .popup-wrap {
// box-sizing: border-box;
// height: 750rpx;
// padding-top: 100px;
// padding-bottom: 0;
// transform: rotate(90deg) translate(-100%, 0%);
// transform-origin: bottom left;
// }
}
}
.screen-handle {
position: absolute;
right: 10rpx;
top: 10rpx;
width: 60rpx;
height: 60rpx;
background-color: white;
border-radius: 10rpx;
border: 1rpx solid #ddd;
z-index: 10;
justify-content: center;
align-items: center;
&__image {
/* #ifndef APP-NVUE */
width: 80%;
/* #endif */
/* #ifdef APP-NVUE */
flex: 0.8;
/* #endif */
}
}
.tools {
background-color: #fff;
position: relative;
z-index: 999999;
display: flex;
height: 120rpx;
box-shadow: 0 -10rpx 30rpx rgba(0, 0, 0, 0.05);
/* #ifdef APP-NVUE */
flex-direction: row;
/* #endif */
/* #ifndef APP-NVUE */
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
/* #endif */
&-item {
flex: 1;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
align-items: center;
justify-content: center;
opacity: 0.6;
transition: opacity 0.1s ease-out;
&.restore{
/* #ifndef APP-NVUE */
transform: scaleX(-1);
/* #endif */
}
&.active {
opacity: 1;
}
&__image {
width: 60rpx;
}
}
}
.popup {
&-wrap {
padding-bottom: 120rpx;
background-color: #fff;
}
&-item {
padding-bottom: 30rpx;
&__head {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: 30rpx;
}
&__title {
font-size: 30rpx;
}
&__more {
flex-direction: row;
&-text {
font-size: 24rpx;
// padding-right 10rpx
color: #999;
}
&-switch {
transform: scale(0.7);
transform-origin: center right;
}
}
}
}
</style>
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title></title>
<style type="text/css">
html,
body,
canvas {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
overflow-y: hidden;
background-color: transparent;
}
</style>
</head>
<body>
<canvas id="lime-signature"></canvas>
<script type="text/javascript" src="./uni.webview.1.5.3.js"></script>
<script type="text/javascript" src="./signature.js"></script>
<script>
var signature = null;
var timer = null;
var isStart = false;
var options = null
console.log = function(...args) {
postMessage(args);
};
// function stringify(key, value) {
// if (typeof value === 'object' && value !== null) {
// if (cache.indexOf(value) !== -1) {
// return;
// }
// cache.push(value);
// }
// return value;
// };
function checkAndEmitEmptyStatus() {
setTimeout(() => {
if (signature) {
const isEmpty = signature.isEmpty()
emit({
isEmpty
});
}
}, 0)
}
function emit(event, data) {
postMessage({
event,
data: typeof data !== "object" && data !== null ? data : JSON.stringify(data),
});
// cache = [];
}
function postMessage(data) {
uni.postMessage({
data
});
}
function update(v = {}) {
if (signature) {
options = v
signature.pen.setOption(v);
} else {
signature = new Signature.Signature({
el: "lime-signature"
});
canvasEl = signature.canvas.get("el");
options = v
signature.pen.setOption(v)
const width = signature.canvas.get("width");
const height = signature.canvas.get("height");
canvasEl.addEventListener('touchend', checkAndEmitEmptyStatus)
emit({
changeSize: {
width,
height
}
})
}
}
function clear() {
signature.clear()
checkAndEmitEmptyStatus()
}
function undo() {
signature.undo()
checkAndEmitEmptyStatus()
}
function redo() {
signature.redo()
checkAndEmitEmptyStatus()
}
function isEmpty() {
const isEmpty = signature.isEmpty()
emit({
isEmpty
});
}
function isTransparent(color) {
// 判断颜色是否为 transparent
if (color === 'transparent') {
return true;
}
// 判断颜色是否为 rgba 的 a 为 0
if (color.startsWith('rgba')) {
const regex = /\d+(\.\d+)?/g;
const matches = color.match(regex);
if (matches !== null) {
const alpha = parseFloat(matches[3]);
if (alpha === 0) {
return true;
}
}
}
return false;
}
function mask(param) {
clearTimeout(timer);
let {
destWidth = 0, destHeight = 0
} = param
let width = this.signature.canvas.get('width')
let height = this.signature.canvas.get('height')
let canvas = document.createElement('canvas')
const ctx = canvas.getContext('2d');
const pixelRatio = signature.canvas.get('pixelRatio')
canvas.width = width * pixelRatio
canvas.height = height * pixelRatio
this.signature.pen.getMaskedImageData((imageData) => {
ctx.putImageData(imageData, 0, 0);
if (destWidth && destHeight) {
const _canvas = document.createElement('canvas')
_canvas.width = destWidth
_canvas.height = destHeight
const _context = _canvas.getContext('2d')
_context.drawImage(canvas, 0, 0, destWidth, destHeight)
canvas.remove()
canvas = _canvas
}
const path = canvas.toDataURL();
canvas.remove()
if (typeof path == "string") {
const index = Math.ceil(path.length / 8);
for (var i = 0; i < 8; i++) {
if (i == 7) {
emit({
"success": path.substr(i * index, index)
});
} else {
emit({
"file": path.substr(i * index, index)
});
}
}
} else {
console.error("canvas no data");
emit({
"fail": "canvas no data"
});
}
})
}
function save(param) {
// delete param.success;
// delete param.fail;
clearTimeout(timer);
timer = setTimeout(() => {
let {
fileType = 'png', quality = 1, n, destWidth = 0, destHeight = 0
} = param
const type = `image/${fileType}`.replace(/jpg/, 'jpeg');
const {
backgroundColor,
landscape,
boundingBox
} = options
const flag = backgroundColor || landscape || boundingBox || destWidth && destHeight
let path = canvasEl.toDataURL(!flag && type, !flag && quality)
if (flag) {
let canvas = document.createElement('canvas')
const pixelRatio = signature.canvas.get('pixelRatio')
let width = signature.canvas.get('width')
let height = signature.canvas.get('height')
let x = 0
let y = 0
const next = () => {
const size = [width, height]
if (landscape) {
size.reverse()
}
canvas.width = size[0] * pixelRatio
canvas.height = size[1] * pixelRatio
const param = [x, y, width, height, 0, 0, width, height].map(item => item * pixelRatio)
const context = canvas.getContext('2d')
// context.scale(pixelRatio, pixelRatio)
if (landscape) {
context.translate(0, width * pixelRatio)
context.rotate(-Math.PI / 2)
}
if (backgroundColor && !isTransparent(backgroundColor)) {
context.fillStyle = backgroundColor
context.fillRect(0, 0, width * pixelRatio, height * pixelRatio)
}
const drawImage = () => {
}
// param
context.drawImage(signature.canvas.get('el'), ...param)
if (destWidth && destHeight) {
const _canvas = document.createElement('canvas')
_canvas.width = destWidth
_canvas.height = destHeight
const _context = _canvas.getContext('2d')
_context.drawImage(canvas, 0, 0, destWidth, destHeight)
canvas.remove()
canvas = _canvas
}
path = canvas.toDataURL(type, quality)
canvas.remove()
}
if (boundingBox) {
const res = signature.getContentBoundingBox()
width = res.width
height = res.height
x = res.startX
y = res.startY
next()
} else {
next()
}
}
if (typeof path == "string") {
const index = Math.ceil(path.length / 8);
for (var i = 0; i < 8; i++) {
if (i == 7) {
emit({
"success": path.substr(i * index, index)
});
} else {
emit({
"file": path.substr(i * index, index)
});
}
}
} else {
console.error("canvas no data");
emit({
"fail": "canvas no data"
});
}
}, 30);
}
</script>
</body>
</html>
\ No newline at end of file
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Signature={})}(this,(function(t){"use strict";function e(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function i(t){for(var i=1;arguments.length>i;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?e(Object(n),!0).forEach((function(e){s(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function r(t,e,i){return e&&a(t.prototype,e),i&&a(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function c(t,e){return c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},c(t,e)}function l(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function v(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=h(t);if(e){var o=h(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return l(this,i)}}var f=function(t){var e=n(t);return null!==t&&"object"===e||"function"===e},d={}.toString,p=function(t,e){return d.call(t)==="[object "+e+"]"},y=function(t){return p(t,"String")},g=function(t){return p(t,"Number")},m=function(t){return p(t,"Function")},x=function(){function t(){o(this,t),this.__events=void 0,this.__events={}}return r(t,[{key:"on",value:function(t,e){if(t&&e){var i=this.__events[t]||[];i.push(e),this.__events[t]=i}}},{key:"emit",value:function(t,e){var i=this;if(f(t)&&(t=(e=t)&&e.type),t){var n=this.__events[t];n&&n.length&&n.forEach((function(t){t.call(i,e)}))}}},{key:"off",value:function(t,e){var i=this.__events,n=i[t];if(n&&n.length)if(e)for(var o=0,a=n.length;a>o;o++)n[o]===e&&(n.splice(o,1),o--);else delete i[t]}},{key:"getEvents",value:function(){return this.__events}}]),t}(),w=function(t){u(i,t);var e=v(i);function i(t,n){var a;return o(this,i),(a=e.call(this)).context=void 0,a.canvas=void 0,a.attrs=void 0,a.isCanvasElement=void 0,a.context=t,a.canvas=n.canvas||t.canvas||{width:n.width||0,height:n.height||0},a.attrs=n||{},a.isCanvasElement=!0,a}return r(i,[{key:"width",get:function(){return this.canvas.width},set:function(t){this.canvas.width=t}},{key:"height",get:function(){return this.canvas.height},set:function(t){this.canvas.height=t}},{key:"getContext",value:function(){return this.context}},{key:"getBoundingClientRect",value:function(){var t=this.attrs||{},e=t.top,i=t.right,n=t.width,o=t.height,a=t.left,r=t.bottom;return{top:void 0===e?0:e,width:void 0===n?0:n,right:void 0===i?0:i,height:void 0===o?0:o,bottom:void 0===r?0:r,left:void 0===a?0:a}}},{key:"setAttribute",value:function(t,e){this.attrs[t]=e}},{key:"addEventListener",value:function(t,e){this.on(t,e)}},{key:"removeEventListener",value:function(t,e){this.off(t,e)}},{key:"dispatchEvent",value:function(t,e){this.emit(t,e)}}]),i}(x);var b=function(t,e){return t?function(t){if(!t)return!1;if(1!==t.nodeType||!t.nodeName||"canvas"!==t.nodeName.toLowerCase())return!1;var e=!1;try{t.addEventListener("eventTest",(function(){e=!0})),t.dispatchEvent(new Event("eventTest"))}catch(t){e=!1}return e}(t.canvas)?t.canvas:new w(t,e):null};function k(t,e){try{return t.currentStyle?t.currentStyle[e]:document.defaultView&&document.defaultView.getComputedStyle(t,null).getPropertyValue(e)}catch(t){return{width:300,height:150}[e]}}function _(t,e){var i=e.get("el");if(!i)return t;var n=i.getBoundingClientRect(),o=n.top,a=void 0===o?0:o,r=n.left,s=void 0===r?0:r,u=parseFloat(k(i,"padding-left"))||0,h=parseFloat(k(i,"padding-top"))||0;return{x:t.x-s-u,y:t.y-a-h}}function E(t,e){var i=e.get("landscape");if(!i)return t;if(m(i))return i(t,e);var n=e.get("height");return{x:t.y,y:n-t.x}}var L=function(t,e){var i=t.touches;if(!i||!i.length)return[E(_({x:t.clientX,y:t.clientY},e),e)];i.length||(i=t.changedTouches||[]);for(var n=[],o=0,a=i.length;a>o;o++){var r=i[o],s=r.x,u=r.y,h=r.clientX,c=r.clientY,l=void 0;l=g(s)||g(u)?{x:s,y:u}:_({x:h,y:c},e),n.push(E(l,e))}return n},M=function(t,e){var i=e.x-t.x,n=e.y-t.y;return Math.abs(i)>Math.abs(n)?i>0?"right":"left":n>0?"down":"up"},P=function(t,e){var i=Math.abs(e.x-t.x),n=Math.abs(e.y-t.y);return Math.sqrt(i*i+n*n)},T=function(){function t(e){var i=this,n=e.canvas,a=e.el;o(this,t),this.processEvent=void 0,this.canvas=void 0,this.startTime=0,this.endTime=0,this.startPoints=null,this.startDistance=0,this.center=null,this.pressTimeout=void 0,this.eventType=null,this.direction=null,this.lastMoveTime=0,this.prevMovePoints=null,this.prevMoveTime=0,this.lastMovePoints=null,this.pinch=!1,this._click=function(t){var e=L(t,i.canvas);t.points=e,i.emitEvent("click",t)},this._start=function(t){var e,n,o=L(t,i.canvas);o&&(t.points=o,i.emitEvent("touchstart",t),i.reset(),i.startTime=Date.now(),i.startPoints=o,o.length>1?(i.startDistance=P(o[0],o[1]),i.center={x:(e=o[0]).x+((n=o[1]).x-e.x)/2,y:e.y+(n.y-e.y)/2}):i.pressTimeout=setTimeout((function(){var e="press",n="none";t.direction=n,i.emitStart(e,t),i.emitEvent(e,t),i.eventType=e,i.direction=n}),250))},this._move=function(t){var e=L(t,i.canvas);if(e){t.points=e,i.emitEvent("touchmove",t);var n=i.startPoints;if(n)if(e.length>1){var o=i.startDistance,a=P(e[0],e[1]);t.zoom=a/o,t.center=i.center,i.emitStart("pinch",t),i.emitEvent("pinch",t)}else{var r=e[0].x-n[0].x,s=e[0].y-n[0].y,u=i.direction||M(n[0],e[0]);i.direction=u;var h=i.getEventType(e);t.direction=u,t.deltaX=r,t.deltaY=s,i.emitStart(h,t),i.emitEvent(h,t);var c=i.lastMoveTime,l=Date.now();l-c>0&&(i.prevMoveTime=c,i.prevMovePoints=i.lastMovePoints,i.lastMoveTime=l,i.lastMovePoints=e)}}},this._end=function(t){var e=L(t,i.canvas);t.points=e,i.emitEnd(t),i.emitEvent("touchend",t);var n=i.lastMoveTime;if(100>Date.now()-n){var o=n-(i.prevMoveTime||i.startTime);if(o>0){var a=i.prevMovePoints||i.startPoints,r=i.lastMovePoints;if(!a||!r)return;var s=P(a[0],r[0])/o;s>.3&&(t.velocity=s,t.direction=M(a[0],r[0]),i.emitEvent("swipe",t))}}i.reset();var u=t.touches;u&&u.length>0&&i._start(t)},this._cancel=function(t){i.emitEvent("touchcancel",t),i.reset()},this.canvas=n,this.delegateEvent(a),this.processEvent={}}return r(t,[{key:"delegateEvent",value:function(t){t.addEventListener("click",this._click),t.addEventListener("touchstart",this._start),t.addEventListener("touchmove",this._move),t.addEventListener("touchend",this._end),t.addEventListener("touchcancel",this._cancel)}},{key:"emitEvent",value:function(t,e){this.canvas.emit(t,e)}},{key:"getEventType",value:function(t){var e,i=this.eventType,n=this.startTime,o=this.startPoints;if(i)return i;var a=this.canvas.__events.pan;if(a&&a.length){var r=Date.now();if(!o)return;e=r-n>250&&10>P(o[0],t[0])?"press":"pan"}else e="press";return this.eventType=e,e}},{key:"enable",value:function(t){this.processEvent[t]=!0}},{key:"isProcess",value:function(t){return this.processEvent[t]}},{key:"emitStart",value:function(t,e){this.isProcess(t)||(this.enable(t),this.emitEvent("".concat(t,"start"),e))}},{key:"emitEnd",value:function(t){}},{key:"clearPressTimeout",value:function(){this.pressTimeout&&(clearTimeout(this.pressTimeout),this.pressTimeout=null)}},{key:"reset",value:function(){this.clearPressTimeout(),this.startTime=0,this.startPoints=null,this.startDistance=0,this.direction=null,this.eventType=null,this.pinch=!1,this.prevMoveTime=0,this.prevMovePoints=null,this.lastMoveTime=0,this.lastMovePoints=null}}]),t}(),S=function(t){u(i,t);var e=v(i);function i(t){var n;o(this,i),(n=e.call(this))._attrs={},n._isWindow=void 0,n._attrs=Object.assign({},t),n._isWindow="undefined"!=typeof window,n._initPixelRatio(),n._initCanvas();return["createImage","toDataURL","requestAnimationFrame"].forEach((function(e){n._initAttrs(e,t.canvas||n.get("el"))})),n}return r(i,[{key:"get",value:function(t){return this._attrs[t]}},{key:"set",value:function(t,e){this._attrs[t]=e}},{key:"_initAttrs",value:function(t,e){var i=this;if(!this.get(t)){this.set(t,(function(){return e[t]?e[t].apply(e,arguments):i._isWindow?window[t]?(n=window)[t].apply(n,arguments):"createImage"==t?new Image:null:void 0;var n}))}}},{key:"_initCanvas",value:function(){var t,e,i=this.get("el"),n=this.get("context");if(!i&&!n)throw Error("请指定 id、el 或 context!");t=i?y(i)?(e=i)?document.getElementById(e):null:i:b(n,this._attrs),n&&t&&!t.getContext&&(t.getContext=function(){return n});var o=this.get("width")||function(t){var e=k(t,"width");return"auto"===e&&(e=t.offsetWidth),parseFloat(e)}(t)||t.width,a=this.get("height")||function(t){var e=k(t,"height");return"auto"===e&&(e=t.offsetHeight),parseFloat(e)}(t)||t.height;this.set("canvas",this),this.set("el",t),this.set("context",n||t.getContext("2d")),this.changeSize(o,a);var r=new T({canvas:this,el:t,parent:this.get("parent")});this.set("eventController",r)}},{key:"_initPixelRatio",value:function(){this.get("pixelRatio")||this.set("pixelRatio",window&&window.devicePixelRatio||1)}},{key:"changeSize",value:function(t,e){var i,o=this.get("pixelRatio"),a=this.get("el");(a.style&&(a.style.width=t+"px",a.style.height=e+"px"),(i=a)&&"object"===n(i)&&(1===i.nodeType&&i.nodeName||i.isCanvasElement))&&(a.width=t*o,a.height=e*o,1!==o&&this.get("context").scale(o,o));this.set("width",t),this.set("height",e)}},{key:"destroy",value:function(){if(!this.get("destroyed")){var t=this.get("el");t.width=0,t.height=0,this.clear(),this._attrs={},this.set("destroyed",!0)}}},{key:"clear",value:function(){}},{key:"isDestroyed",value:function(){return this.get("destroyed")}}]),i}(x);var D={penColor:"black",backgroundColor:"",openSmooth:!0,penSize:2,minLineWidth:2,maxLineWidth:6,minSpeed:1.5,maxWidthDiffRate:20,maxHistoryLength:20},O=null,W=function(){function t(e){var i=this;o(this,t),this.canAddHistory=!0,this.points=[],this.historyList=[],this.undoneList=[],this.canvas=void 0,this._isEmpty=!0,this.active=!1,this.getLineWidth=function(t){var e=i.get("options"),n=e.minSpeed,o=e.minLineWidth,a=i.getMaxLineWidth();return Math.min(Math.max(a-(a-o)*t/Math.max(Math.min(n,10),1),o),a)},this.drawTrapezoid=function(t,e,n,o){var a=i.get("context");a.beginPath(),a.moveTo(Number(t.x.toFixed(1)),Number(t.y.toFixed(1))),a.lineTo(Number(e.x.toFixed(1)),Number(e.y.toFixed(1))),a.lineTo(Number(n.x.toFixed(1)),Number(n.y.toFixed(1))),a.lineTo(Number(o.x.toFixed(1)),Number(o.y.toFixed(1))),a.fillStyle=i.get("options").penColor,a.fill(),a.draw&&a.draw(!0)},this.drawNoSmoothLine=function(t,e){e.lastX=t.x+.5*(e.x-t.x),e.lastY=t.y+.5*(e.y-t.y),"number"==typeof t.lastX&&i.drawCurveLine(t.lastX,t.lastY,t.x,t.y,e.lastX,e.lastY,i.getMaxLineWidth())},this.drawCurveLine=function(t,e,n,o,a,r,s){s=Number(s.toFixed(1));var u=i.get("context");u.lineWidth=s,u.beginPath(),u.moveTo(Number(t.toFixed(1)),Number(e.toFixed(1))),u.quadraticCurveTo(Number(n.toFixed(1)),Number(o.toFixed(1)),Number(a.toFixed(1)),Number(r.toFixed(1))),u.stroke(),u.draw&&u.draw(!0)},this.getRadianData=function(t,e,i,n){var o=i-t,a=n-e;if(0===o)return{val:0,pos:-1};if(0===a)return{val:0,pos:1};var r=Math.abs(Math.atan(a/o));return i>t&&e>n||t>i&&n>e?{val:r,pos:1}:{val:r,pos:-1}},this.getRadianPoints=function(t,e,i,n){if(0===t.val)return 1===t.pos?[{x:e,y:i+n},{x:e,y:i-n}]:[{y:i,x:e+n},{y:i,x:e-n}];var o=Math.sin(t.val)*n,a=Math.cos(t.val)*n;return 1===t.pos?[{x:e+o,y:i+a},{x:e-o,y:i-a}]:[{x:e+o,y:i-a},{x:e-o,y:i+a}]},this.drawSmoothLine=function(t,e){var n=e.x-t.x,o=e.y-t.y;if(Math.abs(n)+Math.abs(o)>2?(e.lastX1=t.x+.3*n,e.lastY1=t.y+.3*o,e.lastX2=t.x+.7*n,e.lastY2=t.y+.7*o):(e.lastX1=e.lastX2=t.x+.5*n,e.lastY1=e.lastY2=t.y+.5*o),e.perLineWidth=(t.lineWidth+e.lineWidth)/2,"number"==typeof t.lastX1){if(i.drawCurveLine(t.lastX2,t.lastY2,t.x,t.y,e.lastX1,e.lastY1,e.perLineWidth),t.isFirstPoint)return;if(t.lastX1===t.lastX2&&t.lastY1===t.lastY2)return;var a=i.getRadianData(t.lastX1,t.lastY1,t.lastX2,t.lastY2),r=i.getRadianPoints(a,t.lastX1,t.lastY1,t.perLineWidth/2),s=i.getRadianPoints(a,t.lastX2,t.lastY2,e.perLineWidth/2);i.drawTrapezoid(r[0],s[0],s[1],r[1])}else e.isFirstPoint=!0},this.addHistory=function(){var t=i.get("options").maxHistoryLength;if(t&&i.canAddHistory)if(i.canAddHistory=!1,i.get("createImage")){var e=null;e=i.get("createImage")();var n=i.get("toDataURL")&&i.get("toDataURL")();y(n)?e.src=n:n.then((function(t){e.src=t})),e.onload=function(){var n=O;O=e,i.historyList.push(n),i.historyList=i.historyList.slice(-t)}}else i.historyList.length++},this.drawByImage=function(t){var e=i.get("context"),n=i.get("width"),o=i.get("height");e.clearRect(0,0,n,o);try{t&&e.drawImage(t,0,0,n,o),e.draw&&e.draw(!0)}catch(t){i.historyList.length=0}},this.isEmpty=function(){return i.get("options").maxHistoryLength>0?0===i.historyList.length:i._isEmpty},this.clear=function(){if(!i.get("options").disabled){var t=i.get("context");t.clearRect(0,0,i.get("width"),i.get("height")),t.draw&&t.draw(),i._isEmpty=!0,O=null,i.historyList.length=0}},this.undo=function(){if(!i.get("options").disabled&&(0===i.get("options").maxHistoryLength&&i.clear(),i.get("createImage")&&i.historyList.length)){var t=i.historyList.pop();i.drawByImage(t),i.undoneList.push(O),O=t,i.historyList.length||i.undoneList.length||i.clear()}},this.redo=function(){if(i.undoneList.length&&!i.get("options").disabled){var t=i.undoneList.pop();i.historyList.push(O),i.drawByImage(t),O=t,i._isEmpty=!1}},this.canvas=e,this.canvas.set("pen",D),this.init()}return r(t,[{key:"getOption",value:function(){}},{key:"setOption",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=i({},t),n=e.maxLineWidth;if(n&&t.penSize&&n==D.maxLineWidth){var o=Math.max(n,t.penSize);e.maxLineWidth=o}this.canvas.set("pen",Object.assign({},D,e))}},{key:"get",value:function(t){return this.canvas.get("options"==t?"pen":t)}},{key:"init",value:function(){var t=this;this.get("context").lineCap="round",this.canvas.on("touchstart",(function(e){return t.onDrawStart(e)})),this.canvas.on("touchmove",(function(e){return t.onDrawMove(e)})),this.canvas.on("touchend",(function(e){return t.onDrawEnd(e)}))}},{key:"drawBackground",value:function(){var t=this.get("context"),e=this.get("width"),i=this.get("height"),n=this.get("options"),o=n.backgroundColor,a=n.backgroundImage;o&&(t.fillStyle=o,t.fillRect(0,0,e,i),t.draw&&t.draw(!0)),a&&this.drawByImage(a)}},{key:"getImageData",value:function(t){if(t){var e=this.get("width"),i=this.get("height"),n=this.get("el"),o="CANVAS"===n.nodeName,a=o?e:n.width,r=o?i:n.height;if(o){var s=document.createElement("canvas");s.width=e,s.height=i;var u=s.getContext("2d");u.drawImage(n,0,0,e,i);var h=u.getImageData(0,0,e,i).data;return t(h)}var c,l=this.get("context").getImageData(0,0,a,r);return f(c=l)&&m(c.then)&&m(c.catch)?(l.then((function(e){return t(e.data)})),null):t(l.data)}}},{key:"getMaskedImageData",value:function(t){if(t)return this.getImageData((function(e){for(var i=0;e.length>i;i+=4){0===e[i+3]?(e[i]=0,e[i+1]=0,e[i+2]=0):(e[i]=255,e[i+1]=255,e[i+2]=255)}return t(e)}))}},{key:"getContentBoundingBox",value:function(t){var e=this.get("pixelRatio"),i=this.get("width"),n=this.get("height"),o=this.get("el"),a="CANVAS"===o.nodeName,r=a?i:o.width,s=a?n:o.height;e=a?1:e;return this.getImageData((function(i){for(var n=Math.floor(r),o=n,a=Math.floor(s),u=0,h=0,c=0;i.length>c;c+=4){if(i[c+3]>0){var l=c/4%n,v=Math.floor(c/4/n);o=Math.min(o,l),a=Math.min(a,v),u=Math.max(u,l),h=Math.max(h,v)}}var f={width:(u-o+1)/e,height:(h-a+1)/e,startX:o/e,startY:a/e};return t&&t(f),f}))}},{key:"remove",value:function(){var t=this;this.canvas.off("touchstart",(function(e){return t.onDrawStart(e)})),this.canvas.off("touchmove",(function(e){return t.onDrawMove(e)})),this.canvas.off("touchend",(function(e){return t.onDrawEnd(e)}))}},{key:"disableScroll",value:function(t){t.preventDefault&&this.get("options").disableScroll&&t.preventDefault()}},{key:"onDrawStart",value:function(t){if(!this.get("options").disabled){this.disableScroll(t),this.undoneList.length=0;var e=t.points;if(this.active){this.canAddHistory=!0,this.get("context").strokeStyle=this.get("options").penColor;var i=e[0];this.initPoint(i.x,i.y)}}}},{key:"onDrawMove",value:function(t){if(!this.get("options").disabled&&(this.disableScroll(t),this.active)){var e=t.points[0];this.initPoint(e.x,e.y),this.onDraw()}}},{key:"onDrawEnd",value:function(t){this.active&&!this.get("options").disabled&&(this.addHistory(),this.canAddHistory=!0,this.points=[])}},{key:"onDraw",value:function(){var t=this,e=this.get("context");if(this.points.length>=2){e.lineWidth=this.get("options").penSize||2;var i=this.points.slice(-1)[0],n=this.points.slice(-2,-1)[0],o=function(){t._isEmpty=!1,t.get("options").openSmooth?t.drawSmoothLine(n,i):t.drawNoSmoothLine(n,i)},a=this.get("el").canvas;a&&a.requestAnimationFrame?a.requestAnimationFrame((function(){return o()})):"function"==typeof requestAnimationFrame?requestAnimationFrame((function(){return o()})):o()}}},{key:"getMaxLineWidth",value:function(){var t=this.get("options");return Math.min(t.penSize,t.maxLineWidth)}},{key:"initPoint",value:function(t,e){var i={x:t,y:e,t:Date.now()},n=this.points.slice(-1)[0];if(!n||n.t!==i.t&&(n.x!==t||n.y!==e)){if(this.get("options").openSmooth&&n){var o=this.points.slice(-2,-1)[0];if(i.distance=Math.sqrt(Math.pow(i.x-n.x,2)+Math.pow(i.y-n.y,2)),i.speed=i.distance/(i.t-n.t||.1),i.lineWidth=this.getLineWidth(i.speed),o&&o.lineWidth&&n.lineWidth){var a=(i.lineWidth-n.lineWidth)/n.lineWidth,r=this.get("options").maxWidthDiffRate/100;if(r=r>1?1:.01>r?.01:r,Math.abs(a)>r)i.lineWidth=n.lineWidth*(1+(a>0?r:-r))}}this.points.push(i),this.points=this.points.slice(-3)}}}]),t}(),C=function(){function t(e){o(this,t),this.canvas=void 0,this._ee=void 0,this.pen=void 0;var i=new S(e);i.set("parent",this),this.canvas=i,this._ee=new x,this.pen=new W(i),this.init()}return r(t,[{key:"init",value:function(){this.pen.active=!0}},{key:"destroy",value:function(){this.canvas.destroy()}},{key:"clear",value:function(){this.pen.clear()}},{key:"undo",value:function(){this.pen.undo()}},{key:"redo",value:function(){this.pen.redo()}},{key:"save",value:function(){}},{key:"getContentBoundingBox",value:function(t){return this.pen.getContentBoundingBox(t)}},{key:"getMaskedImageData",value:function(t){return this.pen.getMaskedImageData(t)}},{key:"isEmpty",value:function(){return this.pen.isEmpty()}},{key:"on",value:function(t,e){this._ee.on(t,e)}},{key:"emit",value:function(t,e){this._ee.emit(t,e)}},{key:"off",value:function(t,e){this._ee.off(t,e)}}]),t}();t.Signature=C,t.default=C,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).uni=n()}(this,(function(){"use strict";try{var e={};Object.defineProperty(e,"passive",{get:function(){!0}}),window.addEventListener("test-passive",null,e)}catch(e){}var n=Object.prototype.hasOwnProperty;function i(e,i){return n.call(e,i)}var t=[];function o(){return window.__dcloud_weex_postMessage||window.__dcloud_weex_}var r=function(e,n){var i={options:{timestamp:+new Date},name:e,arg:n};if(o()){if("postMessage"===e){var r={data:[n]};return window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessage(r):window.__dcloud_weex_.postMessage(JSON.stringify(r))}var a={type:"WEB_INVOKE_APPSERVICE",args:{data:i,webviewIds:t}};window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessageToService(a):window.__dcloud_weex_.postMessageToService(JSON.stringify(a))}if(!window.plus)return window.parent.postMessage({type:"WEB_INVOKE_APPSERVICE",data:i,pageId:""},"*");if(0===t.length){var d=plus.webview.currentWebview();if(!d)throw new Error("plus.webview.currentWebview() is undefined");var s=d.parent(),w="";w=s?s.id:d.id,t.push(w)}if(plus.webview.getWebviewById("__uniapp__service"))plus.webview.postMessageToUniNView({type:"WEB_INVOKE_APPSERVICE",args:{data:i,webviewIds:t}},"__uniapp__service");else{var u=JSON.stringify(i);plus.webview.getLaunchWebview().evalJS('UniPlusBridge.subscribeHandler("'.concat("WEB_INVOKE_APPSERVICE",'",').concat(u,",").concat(JSON.stringify(t),");"))}},a={navigateTo:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;r("navigateTo",{url:encodeURI(n)})},navigateBack:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.delta;r("navigateBack",{delta:parseInt(n)||1})},switchTab:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;r("switchTab",{url:encodeURI(n)})},reLaunch:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;r("reLaunch",{url:encodeURI(n)})},redirectTo:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.url;r("redirectTo",{url:encodeURI(n)})},getEnv:function(e){o()?e({nvue:!0}):window.plus?e({plus:!0}):e({h5:!0})},postMessage:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r("postMessage",e.data||{})}},d=/uni-app/i.test(navigator.userAgent),s=/Html5Plus/i.test(navigator.userAgent),w=/complete|loaded|interactive/;var u=window.my&&navigator.userAgent.indexOf("AlipayClient")>-1;var g=window.swan&&window.swan.webView&&/swan/i.test(navigator.userAgent);var c=window.qq&&window.qq.miniProgram&&/QQ/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var v=window.tt&&window.tt.miniProgram&&/toutiaomicroapp/i.test(navigator.userAgent);var m=window.wx&&window.wx.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var p=window.qa&&/quickapp/i.test(navigator.userAgent);var f=window.ks&&window.ks.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);var l=window.tt&&window.tt.miniProgram&&/Lark|Feishu/i.test(navigator.userAgent);var _=window.jd&&window.jd.miniProgram&&/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent);for(var E,b=function(){window.UniAppJSBridge=!0,document.dispatchEvent(new CustomEvent("UniAppJSBridgeReady",{bubbles:!0,cancelable:!0}))},h=[function(e){if(d||s)return window.__dcloud_weex_postMessage||window.__dcloud_weex_?document.addEventListener("DOMContentLoaded",e):window.plus&&w.test(document.readyState)?setTimeout(e,0):document.addEventListener("plusready",e),a},function(e){if(m)return window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(e,0):document.addEventListener("WeixinJSBridgeReady",e),window.wx.miniProgram},function(e){if(c)return window.QQJSBridge&&window.QQJSBridge.invoke?setTimeout(e,0):document.addEventListener("QQJSBridgeReady",e),window.qq.miniProgram},function(e){if(u){document.addEventListener("DOMContentLoaded",e);var n=window.my;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){if(g)return document.addEventListener("DOMContentLoaded",e),window.swan.webView},function(e){if(v)return document.addEventListener("DOMContentLoaded",e),window.tt.miniProgram},function(e){if(p){window.QaJSBridge&&window.QaJSBridge.invoke?setTimeout(e,0):document.addEventListener("QaJSBridgeReady",e);var n=window.qa;return{navigateTo:n.navigateTo,navigateBack:n.navigateBack,switchTab:n.switchTab,reLaunch:n.reLaunch,redirectTo:n.redirectTo,postMessage:n.postMessage,getEnv:n.getEnv}}},function(e){if(f)return window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(e,0):document.addEventListener("WeixinJSBridgeReady",e),window.ks.miniProgram},function(e){if(l)return document.addEventListener("DOMContentLoaded",e),window.tt.miniProgram},function(e){if(_)return window.JDJSBridgeReady&&window.JDJSBridgeReady.invoke?setTimeout(e,0):document.addEventListener("JDJSBridgeReady",e),window.jd.miniProgram},function(e){return document.addEventListener("DOMContentLoaded",e),a}],y=0;y<h.length&&!(E=h[y](b));y++);E||(E={});var B="undefined"!=typeof uni?uni:{};if(!B.navigateTo)for(var S in E)i(E,S)&&(B[S]=E[S]);return B.webView=E,B}));
// @ts-nocheck
export type LimeSignatureToFileSuccess = {
tempFilePath: string
isEmpty: boolean
}
export type LimeSignatureToFileSuccessCallback = (res : LimeSignatureToFileSuccess) => void
export type LimeSignatureToFileFailCallback = (res : TakeSnapshotFail) => void
export type LimeSignatureToFileCompleteCallback = (res : any) => void
export type LimeSignatureToTempFilePathOptions = {
success?: LimeSignatureToFileSuccessCallback
fail?: LimeSignatureToFileFailCallback
complete?: LimeSignatureToFileCompleteCallback
format?: string
}
export type LimeSignatureOptions = {
penColor : string
// backgroundColor : string
openSmooth : boolean
disableScroll : boolean
disabled : boolean
penSize : number
minLineWidth : number
maxLineWidth : number
minSpeed : number
maxWidthDiffRate : number
maxHistoryLength : number
}
export type LimeSignaturePoint = {
x: number
y: number
c?: string
w?: number
}
export type LimeSignatureLine = LimeSignaturePoint[]
\ No newline at end of file
{
"id": "lime-signature",
"displayName": "lime-signature 手写板-签名签字",
"version": "1.5.7",
"description": "手写板签名插件:一款实用的签名插件,支持横屏、背景色、笔画颜色、笔画大小等功能,可生成有内容的区域,减小图片尺寸,节省空间。支持uniapp/uniappx",
"keywords": [
"写字",
"签名",
"电子签名",
"横屏",
"uvue"
],
"repository": "",
"engines": {
"HBuilderX": "^3.5.4",
"uni-app": "^4.74",
"uni-app-x": "^4.75"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "",
"type": "component-vue",
"darkmode": "x",
"i18n": "x",
"widescreen": "x"
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "√",
"aliyun": "√",
"alipay": "x"
},
"client": {
"uni-app": {
"vue": {
"vue2": "√",
"vue3": "√"
},
"web": {
"safari": "√",
"chrome": "√"
},
"app": {
"vue": "√",
"nvue": "-",
"android": {
"extVersion": "",
"minVersion": "21"
},
"ios": "√",
"harmony": "√"
},
"mp": {
"weixin": "√",
"alipay": "√",
"toutiao": "√",
"baidu": "√",
"kuaishou": "√",
"jd": "√",
"harmony": "-",
"qq": "√",
"lark": "√"
},
"quickapp": {
"huawei": "-",
"union": "-"
}
},
"uni-app-x": {
"web": {
"safari": "√",
"chrome": "√"
},
"app": {
"android": {
"extVersion": "",
"minVersion": "21"
},
"ios": "√",
"harmony": "√"
},
"mp": {
"weixin": "√"
}
}
}
}
}
}
\ No newline at end of file
# LimeSignature 写字板
一款用于业务签名等场景的写字板插件,支持横屏、压感模拟、撤销/重做等功能。
## 文档链接
📚 详细文档请访问以下站点:
- [signature 文档 - 站点1](https://limex.qcoon.cn/components/signature.html)
- [signature 文档 - 站点2](https://limeui.netlify.app/components/signature.html)
- [signature 文档 - 站点3](https://limeui.familyzone.top/components/signature.html)
## 安装方法
1. 在 uni-app 插件市场中搜索并导入 `lime-signature`
2. 导入后可能需要重新编译项目。
## 代码演示
### 基本用法
```html
<view style="width: 750rpx ;height: 750rpx;">
<l-signature disableScroll ref="signatureRef" :penColor="penColor" :penSize="penSize" :openSmooth="openSmooth" ></l-signature>
</view>
<view>
<button @click="onClick('clear')">清空</button>
<button @click="onClick('undo')">撤消</button>
<button @click="onClick('save')">保存</button>
<!-- uvue 不支持 openSmooth -->
<button @click="onClick('openSmooth')">压感{{openSmooth?'开':'关'}}</button>
</view>
```
### Uniapp
```js
export default {
data() {
return {
title: 'Hello',
penColor: 'red',
penSize: 5,
url: '',
openSmooth: true
}
},
methods: {
onClick(type) {
if(type == 'openSmooth') {
this.openSmooth = !this.openSmooth
return
}
if (type == 'save') {
this.$refs.signatureRef.canvasToTempFilePath({
success: (res) => {
// 是否为空画板 无签名
console.log(res.isEmpty)
// 生成图片的临时路径
// H5 生成的是base64
this.url = res.tempFilePath
}
})
return
}
if (this.$refs.signatureRef)
this.$refs.signatureRef[type]()
}
}
}
```
### Uniappx
```js
import {LimeSignatureToTempFilePathOptions, LimeSignatureToFileSuccess} from '@/uni_modules/lime-signature'
export default {
data() {
return {
title: 'Hello',
penColor: 'red',
penSize: 5,
url: '',
openSmooth: true
}
},
methods: {
onClick(type: string) {
const signatureRef = this.$refs['signatureRef'] as LSignatureComponentPublicInstance
// APP 不支持
// #ifndef APP
if(type == 'openSmooth') {
this.openSmooth = !this.openSmooth
}
// #endif
if (type == 'save') {
signatureRef.canvasToTempFilePath({
success: (res: LimeSignatureToFileSuccess) => {
// 是否为空画板 无签名
console.log(res.isEmpty)
// 生成图片的临时路径
// H5 生成的是base64
this.url = res.tempFilePath
}
} as LimeSignatureToTempFilePathOptions)
return
}
if(type == 'undo'){
signatureRef.undo()
}
if(type == 'redo'){
signatureRef.redo()
}
if(type == 'clear'){
signatureRef.clear()
}
}
}
}
```
### 横屏
通过设置`landscape`,改变生成图片的方向,达到横屏的作用
```html
<view style="width: 100vw; height: 100vh;">
<l-signature landscape></l-signature>
</view>
<view style="transform: rotate(90deg);">
<button @click="onClick('clear')">清空</button>
<button @click="onClick('undo')">撤消</button>
<button @click="onClick('save')">保存</button>
<button @click="onClick('openSmooth')">压感{{openSmooth?'开':'关'}}</button>
</view>
```
## API 文档
### Props
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| `penSize` | 画笔大小 | `number` | `2` |
| `minLineWidth` | 线条最小宽度 | `number` | `2` |
| `maxLineWidth` | 线条最大宽度 | `number` | `6` |
| `penColor` | 画笔颜色 | `string` | `black` |
| `backgroundColor` | 背景颜色(透明背景需留空) | `string` | `` |
| `openSmooth` | 是否模拟压感 | `boolean` | `false` |
| `landscape` | 横屏模式 | `boolean` | `false` |
| `disableScroll` | 禁用滚动 | `boolean` | `true` |
| `disabled` | 禁用写字板 | `boolean` | `false` |
### 事件
| 事件名 | 说明 |
| --- | --- |
| `undo` | 撤销操作 |
| `clear` | 清空画板 |
| `canvasToTempFilePath` | 保存为图片 |
## 支持与赞赏
如果你觉得本插件解决了你的问题,可以考虑支持作者:
| 支付宝赞助 | 微信赞助 |
|------------|------------|
| ![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/alipay.png) | ![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/wpay.png) |
\ No newline at end of file
......@@ -215,7 +215,9 @@ export default {
},
rangeValue: {
type: Object,
default: () => { { } }
default: () => {
return {}
}
},
backgroundColor: {
type: String,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!