UNPKG

xlb-main-login

Version:

``` yarn install ```

183 lines (170 loc) 8.24 kB
import { axios } from '@/utils/request' import { weichat } from '@/api/config' //新增活动 ID:jP81P62q export function addEvent(formData, eventId = '') { const formTemp = {} // id formTemp.appId = eventId ? formData.information.appId : '' formTemp.corpId = eventId ? formData.information.corpId : '' formTemp.state = eventId ? formData.information.state : 0 if (eventId) { formTemp.id = eventId } /***************** 第一步 ******************/ // 第一步 活动名称 formTemp.title = formData.information.title // 第一步 活动描述 formTemp.description = formData.information.description // 第一步 上传封面图 formTemp.path = formData.information.path const msgList = [] // 第一步 裂变规则文案 msgList.push({ enable: 1, msg: formData.information.fissionText, msgType: 0, wxMessageType: 'text' }) // 第一步 活动结束文案 msgList.push({ enable: formData.information.endTextEnable ? 1 : 0, msg: formData.information.endText, msgType: 6, wxMessageType: 'text' }) // 第一步 活动结束图片 msgList.push({ enable: formData.information.endImgEnable ? 1 : 0, msg: formData.information.endImg, msgType: 6, wxMessageType: 'image' }) formTemp.msgList = msgList // 保存所有的文案 // 第一步 起止时间 formTemp.endTime = formData.information.endTime // 第一步 获客成员 formTemp.staffList = formData.information.staffList /***************** 第二步 ******************/ // 海报配置 带dr const item = formData.poster.posterFormData[0] formTemp.backgroundList = item.posterForm.backgroundList formTemp.imageConfig = { background: item.posterForm.background, // 背景图 circle: item.headData.circle, // 圆形头像 1_开启 0_关闭 dr: item.posterForm.dr || 0, // 默认0 eventId: eventId, // 对应活动的id fontColor: item.nameData.fontColor ? item.nameData.fontColor.replace('#', '0x') : '', //字体颜色 fontName: '', // 新增为空 编辑时有接口返回默认值 fontSize: item.nameData.fontSize, // 字体大小 为0就是隐藏 fontStyle: 0, // 新增为空 编辑时有接口返回默认值 fontx: item.nameData.fontSize == 0 ? 0 : parseInt(item.nameData.x * 2.5), // 字体x轴坐标 fonty: item.nameData.fontSize == 0 ? 0 : parseInt(item.nameData.y * 2.5), // 字体y轴坐标 headUrl: '', // 头像 为空 headUrlHeight: item.headData.show ? parseInt(item.headData.h * 2.5) : 0, // 头像大小 为0就是隐藏 headUrlWidth: item.headData.show ? parseInt(item.headData.w * 2.5) : 0, // 头像大小 为0就是隐藏 headUrlx: item.headData.show ? parseInt(item.headData.x * 2.5) : 0, // 头像大小 为0就是隐藏 headUrly: item.headData.show ? parseInt(item.headData.y * 2.5) : 0, // 头像大小 为0就是隐藏 id: item.posterForm.id || '', // 新增为空 编辑时有接口返回默认值 mini: 1, // mini头像 qrCodeHeight: item.qrData.h == 0 ? 0 : parseInt(item.qrData.h * 2.5), // 二维码大小 为0就是隐藏 qrCodeWeight: item.qrData.w == 0 ? 0 : parseInt(item.qrData.w * 2.5), // 二维码大小 为0就是隐藏 qrCodex: item.qrData.x == 0 ? 0 : parseInt(item.qrData.x * 2.5), // 二维码大小 为0就是隐藏 qrCodey: item.qrData.y == 0 ? 0 : parseInt(item.qrData.y * 2.5) // 二维码大小 为0就是隐藏 } /***************** 第三步 ******************/ // 第三步 自动打标签 formTemp.enableTag = formData.advanced.enableTag ? 1 : 0 // 开关 formTemp.tagList = formData.advanced.tagList console.log('趣味测试formData', formData) console.log('趣味测试formTemp', formTemp) //新增好友获客活动 return axios({ headers: { 'Content-Type': 'application/json;charset=UTF-8' }, url: weichat + 'v1/wechat/work/festival', method: eventId !== '' ? 'put' : 'post', data: formTemp }) } function getMagItem(type, magList, key = 'msg', msgType = 'text') { const indexId = magList.findIndex((items) => items.msgType == type && items.wxMessageType == msgType) if (indexId !== -1) { return magList[indexId][key] } else { return null } } //趣味测试活动详情 export function getEvent(id) { const formData = { information: {}, poster: { posterFormData: [] }, advanced: {} } return new Promise((resolve, reject) => { axios({ url: weichat + 'v1/wechat/work/festival/' + id, method: 'get' }).then((res) => { console.time() const resData = JSON.parse(JSON.stringify(res.value)) console.log(1111111111111, resData) /***************** 第一步 ******************/ formData.information = { corpId: resData.corpId, appId: resData.appId, state: resData.state, title: resData.title,// 第一步 活动名称 description: resData.description,// 第一步 活动描述 path: resData.path,// 第一步 上传封面图 fissionText: getMagItem(0, resData.msgList),// 第一步 裂变规则文案 endText: getMagItem(6, resData.msgList, 'msg', 'text'), // 活动结束文案 endTextEnable: getMagItem(6, resData.msgList, 'enable', 'text') == 1 ? true : false, // 活动结束文案-开关 endImgEnable: getMagItem(6, resData.msgList, 'enable', 'image') == 1 ? true : false, // 活动结束图片-开关 endImg: getMagItem(6, resData.msgList, 'msg', 'image'), // 活动结束图片 endTime: resData.endTime, staffList: resData.staffList } /***************** 第二步 ******************/ //海报 formData.poster.posterFormData = [] formData.poster.posterFormData.push({ headData: { show: resData.imageConfig.headUrly + resData.imageConfig.headUrlx + resData.imageConfig.headUrlWidth + resData.imageConfig.headUrlHeight == 0 ? false : true, circle: resData.imageConfig.circle, y: resData.imageConfig.headUrlWidth + resData.imageConfig.headUrlHeight == 0 ? 20 : parseInt(resData.imageConfig.headUrly / 2.5), x: resData.imageConfig.headUrlWidth + resData.imageConfig.headUrlHeight == 0 ? 20 : parseInt(resData.imageConfig.headUrlx / 2.5), w: resData.imageConfig.headUrlWidth + resData.imageConfig.headUrlHeight == 0 ? 60 : parseInt(resData.imageConfig.headUrlWidth / 2.5), h: resData.imageConfig.headUrlWidth + resData.imageConfig.headUrlHeight == 0 ? 60 : parseInt(resData.imageConfig.headUrlHeight / 2.5) }, nameData: { y: resData.imageConfig.fontSize == 0 ? 20 : parseInt(resData.imageConfig.fonty / 2.5), x: resData.imageConfig.fontSize == 0 ? 90 : parseInt(resData.imageConfig.fontx / 2.5), fontSize: resData.imageConfig.fontSize, fontColor: resData.imageConfig.fontColor ? resData.imageConfig.fontColor.replace('0x', '#') : '' }, qrData: { y: resData.imageConfig.qrCodeWeight + resData.imageConfig.qrCodeHeight == 0 ? 20 : parseInt(resData.imageConfig.qrCodey / 2.5), x: resData.imageConfig.qrCodeWeight + resData.imageConfig.qrCodeHeight == 0 ? 20 : parseInt(resData.imageConfig.qrCodex / 2.5), w: resData.imageConfig.qrCodeWeight + resData.imageConfig.qrCodeHeight == 0 ? 60 : parseInt(resData.imageConfig.qrCodeWeight / 2.5), h: resData.imageConfig.qrCodeWeight + resData.imageConfig.qrCodeHeight == 0 ? 60 : parseInt(resData.imageConfig.qrCodeHeight / 2.5) }, posterForm: { dr: resData.imageConfig.dr || 0, id: resData.imageConfig.id || '', background: resData.imageConfig.background, backgroundList: resData.backgroundList } }) /***************** 第三步 ******************/ formData.advanced = { tagList: resData.tagList, enableTag: resData.enableTag == 1 ? true : false } console.timeEnd() // 输出结构化后的数据 return resolve(formData) }) }) }