Commit d8a02087 by 杨明

fixed

1 parent c808cf13
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-05-22 20:12:55
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-07-06 13:41:22
* @FilePath: \scrm-micro-home\src\utils\color.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
var img_width = 0,
img_height = 0
var canvas = document.createElement('canvas')
var context = canvas.getContext('2d')
var myColor = []
function getColor() {
var imageData = context.getImageData(img_width - 10, img_height - 10, img_width, img_height)
myColor = [imageData.data[0], imageData.data[1], imageData.data[2]]
var hexColor = gethex(...myColor)
return `#${hexColor}`
}
// 获取16进制颜色
function gethex(r, g, b) {
console.log(r, g, b)
r = r.toString(16)
g = g.toString(16)
b = b.toString(16)
// 补0
r.length == 1 ? (r = '0' + r) : ''
g.length == 1 ? (g = '0' + g) : ''
b.length == 1 ? (b = '0' + b) : ''
var hex = r + g + b
// 简化处理,如 FFEEDD 可以写为 FED
if (r.slice(0, 1) == r.slice(1, 1) && g.slice(0, 1) == g.slice(1, 1) && b.slice(0, 1) == b.slice(1, 1)) {
hex = r.slice(0, 1) + g.slice(0, 1) + b.slice(0, 1)
}
return hex
}
async function uploadImg(url, callbackFn) {
var image = new Image()
image.src = url
image.setAttribute('crossOrigin', 'Anonymous')
image.onload = function() {
img_width = this.width
img_height = this.height
// 设置画布尺寸
canvas.width = img_width
canvas.height = img_height
// 将图片按像素写入画布
context.drawImage(this, 0, 0, img_width, img_height)
callbackFn(getColor())
}
}
export default uploadImg
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn * @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2023-05-10 17:17:31 * @Date: 2023-05-10 17:17:31
* @LastEditors: yangming yangming@didihu.com.cn * @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-07-06 17:38:54 * @LastEditTime: 2023-07-13 16:33:10
* @FilePath: \outbound\src\views\calendar\add.vue * @FilePath: \outbound\src\views\calendar\add.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
--> -->
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
<script> <script>
import selectGoodsDialog from './components/SelectGoodsDialog' import selectGoodsDialog from './components/SelectGoodsDialog'
import PhoneView from './components/PhoneView' import PhoneView from './components/PhoneView'
import getUploadImgColor from '@/utils/color'
export default { export default {
name: 'addCalendar', name: 'addCalendar',
data() { data() {
...@@ -176,6 +177,9 @@ export default { ...@@ -176,6 +177,9 @@ export default {
if (res.startTime) { if (res.startTime) {
this.$set(this.editForm, 'activityTime', [res.startTime, res.endTime]) this.$set(this.editForm, 'activityTime', [res.startTime, res.endTime])
} }
getUploadImgColor(res.backgroundImg, color => {
this.editForm.mainColor = color
})
this.selectedGoodsList = this.editForm.couponItemList || [] this.selectedGoodsList = this.editForm.couponItemList || []
this.selectedGoodsList.forEach(item => { this.selectedGoodsList.forEach(item => {
item.id = item.couponId item.id = item.couponId
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!