Commit 96813cfa by 杨北旺

合并v3.0

2 parents 3a9d87dc 8da0387d
Showing 46 changed files with 1057 additions and 192 deletions
......@@ -22,6 +22,14 @@ class ActivityApi {
...data
})
}
// 获取被分享者打开分享内容数据
getTaskShareDetail(data) {
return api.post({
method: 'stoassistant.api.mission.getMissionByIdAndNoSession',
...data
})
}
// 获取活动诊断订单数据
getActivityEndOrderList(data) {
return api.post({
......
......@@ -22,5 +22,17 @@ module.exports = {
noSignAttr: ['file']
})
},
},
/** 线索埋点数据上报
* operationType 操作类型(0:分享 1:浏览 2:申请活动)
*/
reportData(data = {}, operationType = 0) {
return api.post({
method: 'scrm.api.busassistant.clue.report',
...data,
operationType,
operationDate: new Date().format('yyyy-MM-dd hh:mm:ss'),
})
}
}
......@@ -10,7 +10,8 @@
"pages/authentication/registerSuccess/registerSuccess",
"pages/authentication/registerInfo/registerInfo",
"pages/authentication/accountItems/accountItems",
"pages/authentication/customerService/customerService"
"pages/authentication/customerService/customerService",
"pages/checkProduct/checkProduct"
],
"requiredPrivateInfos": [
"getLocation"
......@@ -56,7 +57,8 @@
"pages/taskDetail/taskDetail",
"pages/warReport/warReport",
"pages/applyActivity/applyActivity",
"pages/applySuccess/applySuccess"
"pages/applySuccess/applySuccess",
"pages/shareTaskDetail/shareTaskDetail"
]
},
{
......
......@@ -5,12 +5,12 @@
<view class="middle">
<view class="name">
<text class="label">联系人</text>
<text>{{data.name}}</text>
<text>{{data.reInstallContactsName}}</text>
</view>
<view class="mobile">
<text class="label">联系方式</text>
<text>{{data.mobile}}</text>
<image wx:if="{{data.mobile}}" webp src="{{IMGURL}}activity_order_phone_icon.png" bind:tap="callPhone" data-mobile="{{data.mobile}}"></image>
<text>{{data.reInstallContactsPhone}}</text>
<image wx:if="{{data.reInstallContactsPhone}}" webp src="{{IMGURL}}activity_order_phone_icon.png" bind:tap="callPhone" data-mobile="{{data.reInstallContactsPhone}}"></image>
</view>
</view>
<view class="btn-box">
......
import activityApi from "~/api/activityApi/index"
import {
reportData
} from '~/api/api.js'
Page({
data: {
......@@ -70,6 +73,23 @@ Page({
product.forEach(val => {
if (val.isSelect) arr.push(val.id)
})
console.log(reportData)
const {
USERINFO
} = this.getCommonData()
reportData({
openId: USERINFO.weChatOpenId || '',
unionId: USERINFO.uuid || '',
nickName: USERINFO.weChatNickName || '',
avatar: USERINFO.weChatAvatarUrl || '',
phone: USERINFO.weChatPhone || '',
shopId: USERINFO.merchantId || '',
shopName: USERINFO.merchantName || '',
shareOpenId: USERINFO.weChatOpenId || '',
}, 2).then(res => {
console.log(res)
})
if (!arr.length) return wx.showToast({
title: '请选择产品/活动',
icon: "none"
......@@ -81,9 +101,28 @@ Page({
productCodes: arr
}).then(res => {
if (res.code == 200) {
const {
USERINFO
} = this.getCommonData()
reportData({
openId: USERINFO.weChatOpenId || '',
unionId: USERINFO.uuid || '',
nickName: USERINFO.weChatNickName || '',
avatar: USERINFO.weChatAvatarUrl || '',
phone: USERINFO.weChatPhone || '',
merchantId: USERINFO.merchantId || ''
}).then(res => {
console.log(res)
})
wx.$router.go('packageActivity.applySuccess')
}
})
},
getCommonData() {
const USERINFO = wx.$storage.get('userInfo')
return {
USERINFO
}
}
})
\ No newline at end of file
......@@ -32,11 +32,13 @@ Page({
ActivityApi.getActivityOrderList({
activityId
}).then(res => {
res.orderList && res.orderList.forEach(val => {
val.time = val.payDate ? new Date(val.payDate).format('yyyy-MM-dd hh:mm:ss') : ''
})
console.log(res.orderTotal)
this.setData({
titleData: {
allNum: res.orderTotal,
todayNum: res.todayTotal
},
allNum: res.orderTotal,
todayNum: res.todayTotal,
list: res.orderList
})
})
......@@ -66,9 +68,7 @@ Page({
// 查看预约安装信息
showPopup(e) {
let { item } = e.currentTarget.dataset
item.name = item.reInstallContactsName
item.mobile = item.reInstallContactsPhone
if (!item.name || item.mobile) {
if (!item.reInstallContactsName && !item.reInstallContactsName) {
return wx.showToast({
title: '暂无安装联系人信息',
icon: 'none'
......
......@@ -15,11 +15,11 @@
<view class="top-left">
<image webp src="{{item.customerImageUrl ? item.customerImageUrl : IMGURL+'order_person_default.png'}}"></image>
<view class="name-mobile">
<view class="name" wx:if="{{item.customerNickName}}">
{{item.customerNickName}}
<view class="name">
{{item.customerNickName || ""}}
<text class="order-statue {{item.orderStatus == 1 ? '' : 'green'}}">{{item.orderStatus == 1 ? '未下单' : '已下单'}}</text>
</view>
<view class="mobile" wx:if="{{item.customerPhone}}">{{item.customerPhone}}</view>
<view class="mobile">{{item.customerPhone || ""}}</view>
</view>
</view>
<view class="top-right">
......
// packageActivity/pages/shareTaskDetail/shareTaskDetail.js
import index_const from "~/pages/tab/index/index_const"
import ActivityApi from '~/api/activityApi/index'
Page({
/**
* 页面的初始数据
*/
data: {
activityTypList: index_const.data.activityTypList,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
wx.hideHomeButton({
success: (res) => {},
})
let missionId = options.missionId
// 获取分享内容
ActivityApi.getTaskShareDetail({missionId: missionId}).then(res => {
res.imgUrlList = []
let typeArr = []
res.platformMerchantMissionMaterialResponseList && res.platformMerchantMissionMaterialResponseList.forEach(val => {
typeArr.push(val.materialType)
if (val.materialType == 1) { // 文案
res.textContent = val.materialContent
}
if (val.materialType == 2 || val.materialType == 3) { // 图片视频
res.imgUrlList.push({
url: val.materialContent,
type: val.materialType == 2 ? 'image' : 'video'
})
}
if (val.materialType == 4) { // 链接
res.linkUrl = val.materialContent
}
})
res.imgUrlList.push({
url: 'http://scrm.test.glsx.com.cn/group1/M00/00/59/wKgD3mGvIc2AHq2FAAtkYkTMHOI111.mp4',
type: 'video'
})
this.setData({
detailInfo: res,
materialTypeArr: typeArr
})
})
},
// 预览图片/视频
previewMedia(e) {
let { imgUrlList } = this.data.detailInfo
let { current } = e.currentTarget.dataset
wx.previewMedia({
sources: imgUrlList,
current: current
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
/* packageActivity/pages/shareTaskDetail/shareTaskDetail.wxss */
.share-box{
background: #FFFFFF;
box-shadow: 0 8rpx 24rpx 0 rgba(106,126,204,0.12);
position: relative;
.bg{
width: 100%;
height: 176rpx;
}
.user-box{
position: absolute;
top: 0;
padding: 40rpx;
display: flex;
image{
width: 96rpx;
height: 96rpx;
margin-right: 24rpx;
flex-shrink: 0;
}
.message{
display: flex;
flex-flow: column;
justify-content: space-between;
font-size: 28rpx;
color: #2D2D33;
.name{
font-size: 32rpx;
text{
font-size: 24rpx;
color: #6E6E7A;
margin-left: 16rpx;
}
}
.activity{
text{
font-size: 20rpx;
color: #4466F0;
background: rgba(255,255,255,0.32);
border: 1px solid rgba(143,165,255,0.50);
padding: 0 12rpx;
border-radius: 2px;
margin-left: 8rpx;
}
}
}
}
.content{
padding: 40rpx 48rpx;
.img_video{
margin-top: 32rpx;
display: flex;
flex-wrap: wrap;
.image-box{
flex: 0 0 33.3%;
width: 176rpx;
height: 176rpx;
margin-bottom: 16rpx;
text-align: center;
image{
display: inline-block;
}
}
.video-box{
flex: 0 0 33.3%;
position: relative;
text-align: center;
video{
width: 176rpx;
height: 176rpx;
display: inline-block;
}
.paly-icon{
width: 60rpx;
height: 60rpx;
position: absolute;
z-index: 2;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
}
}
}
.link-share{
background: #FFFFFF;
box-shadow: 0 4px 12px 0 rgba(106,126,204,0.12);
border-radius: 12px;
padding: 24rpx 32rpx;
margin: 20rpx;
height: 128rpx;
image{
width: 128rpx;
height: 128rpx;
margin-right: 22rpx;
}
.right{
display: inline-block;
view{
font-size: 32rpx;
color: #282829;
}
.type-text{
font-size: 24rpx;
color: #9299AD;
}
}
}
\ No newline at end of file
<!--packageActivity/pages/shareTaskDetail/shareTaskDetail.wxml-->
<view wx:if="{{fn.indexOf(materialTypeArr, 4)}}">
<view class="link-share" bind:tap="goShareLink" data-url="{{detailInfo.linkUrl}}">
<image src="{{detailInfo.activityImg ? detailInfo.activityImg : IMGURL+'share_task_default_img.png'}}"></image>
<view class="right">
<view>{{detailInfo.activityName}}</view>
<view class="type-text">{{activityTypList[0]}}活动</view>
</view>
</view>
</view>
<view class="share-box">
<image class="bg" webp src="{{IMGURL}}taskDetail_bg.png"></image>
<view class="user-box">
<image webp src="{{detailInfo.weChatAvatarUrl ? detailInfo.weChatAvatarUrl : IMGURL + 'order_person_default.png'}}"></image>
<view class="message">
<view class="name">{{detailInfo.staffName || ""}}<text>邀请你参加</text></view>
<view class="activity">{{detailInfo.merchantName || ""}}{{detailInfo.activityName || ""}}<text>{{activityTypList[0]}}</text></view>
</view>
</view>
<view class="content">
<view class="text-box">
<text>{{detailInfo.textContent}}</text>
</view>
<view class="img_video">
<block wx:for="{{detailInfo.imgUrlList}}" wx:key="index">
<view wx:if="{{item.type == 'image'}}" class="image-box">
<image class="image-box" bind:tap="previewMedia" data-current="{{index}}" src="{{item.url}}"></image>
</view>
<view wx:else class="video-box" bind:tap="previewMedia" data-current="{{index}}">
<image class="paly-icon" webp src="{{IMGURL}}video_paly_icon.png"></image>
<video controls="{{false}}" show-center-play-btn="{{false}}" show-fullscreen-btn="{{false}}" src="{{item.url}}"></video>
</view>
</block>
</view>
</view>
</view>
// packageActivity/pages/taskDetail/taskDetail.js
import index_const from "~/pages/tab/index/index_const"
import ActivityApi from '~/api/activityApi/index'
import { IMG_URL } from "~/utils/constantData"
Page({
/**
......@@ -8,28 +9,10 @@ Page({
*/
data: {
activityTypList: index_const.data.activityTypList,
detailInfo: {
title: '今日完成首次分享',
content: '指定分享内容在今日完成首次分享',
integralAccount: 20,
activityName: '360全景活动',
merchantName: '广汽丰田鹏峰4S店360全景活动360全景活动',
activityUrl: 'https://baidu.com',
userName: '余皖平123',
activityType: 1,
activityImg: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/order_person_default.png',
taskType: 1,
textContent: '💫广汽丰田鹏峰4S店💫\n#360全景影像系统大酬宾\n任意角度查看 行车无忧\n多角度高清采集,拒绝盲区\n活动时间:9月20日-26日\n联系我获取专属报名通道!',
imgUrlList: [
{url: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/order_person_default.png', type: 'image'},
{url: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/order_person_default.png', type: 'image'},
{url: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/order_person_default.png', type: 'image'},
{url: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/order_person_default.png', type: 'image'},
// {url: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/share_task_icon.png', type: 'image'},
{url: 'http://scrm.test.glsx.com.cn/group1/M00/00/59/wKgD3mGvIc2AHq2FAAtkYkTMHOI111.mp4', type: 'video', poster: 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/order_person_default.png'}
]
},
isloading: false
detailInfo: {},
isloading: false,
materialTypeArr: [], // 素材类型
userStorage: {}
},
shareTitle: '',
shareImage: '',
......@@ -38,21 +21,51 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.shareTitle = this.data.detailInfo.activityName
this.shareImage = this.data.detailInfo.activityImg
this.sharePath = `pages/webView/webView?url=${this.data.detailInfo.activityUrl}`
let id = null
const userStorage = wx.$storage.get('userInfo')
this.setData({
userStorage
})
if (Object.keys(options).length && options.missionId) {
id = options.missionId
this.getActiveTaskDetail(id)
}
wx.$router.getData(missionId => {
id = missionId
this.getActiveTaskDetail(id)
})
this.sharePath = `packageActivity/pages/shareTaskDetail/shareTaskDetail?missionId=${id}`
},
onRoute(options) {
let missionId = options.id
// 获取任务详情
// 获取任务详情
getActiveTaskDetail(missionId) {
ActivityApi.getActiveTaskDetail({missionId: missionId}).then(res => {
res.imgUrlList = []
let typeArr = []
res.platformMerchantMissionMaterialResponseList && res.platformMerchantMissionMaterialResponseList.forEach(val => {
typeArr.push(val.materialType)
if (val.materialType == 1) { // 文案
res.textContent = val.materialContent
}
if (val.materialType == 2 || val.materialType == 3) { // 图片视频
res.imgUrlList.push({
url: val.materialContent,
type: val.materialType == 2 ? 'image' : 'video'
})
}
if (val.materialType == 4) { // 链接
res.linkUrl = val.materialContent
}
})
this.setData({
detailInfo: res
detailInfo: res,
materialTypeArr: typeArr
})
this.shareImage = res.imgUrlList[0] ? res.imgUrlList[0].url : `${IMGURL}share_task_default_img.png`
this.shareTitle = res.activityName || '门店助手'
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
......@@ -60,6 +73,12 @@ Page({
},
// 跳转链接
goShareLink(e) {
let linkUrl = e.currentTarget.dataset
wx.$router.jumpH5(linkUrl)
},
// 预览图片/视频
previewMedia(e) {
let { imgUrlList } = this.data.detailInfo
......@@ -77,7 +96,21 @@ Page({
data: textContent,
success (res) {
wx.showToast({
title: '内容已复制',
title: '文案已复制,请黏贴到微信或企微进行转发',
icon: "none"
})
}
})
},
// 复制链接
copyUrl(e) {
let { linkUrl } = this.data.detailInfo
wx.setClipboardData({
data: linkUrl,
success (res) {
wx.showToast({
title: '活动链接已复制,请打开企微进行转发',
icon: "none"
})
}
......
......@@ -8,6 +8,36 @@
font-size: 32rpx;
color: #1B233D;
}
.copyWriting{
font-weight: 400;
font-size: 24rpx;
color: #7A8299;
line-height: 40rpx;
margin-bottom: 24rpx;
}
.link-share{
background: #FFFFFF;
box-shadow: 0 4px 12px 0 rgba(106,126,204,0.12);
border-radius: 12px;
padding: 24rpx 32rpx;
height: 128rpx;
image{
width: 128rpx;
height: 128rpx;
margin-right: 22rpx;
}
.right{
display: inline-block;
view{
font-size: 32rpx;
color: #282829;
}
.type-text{
font-size: 24rpx;
color: #9299AD;
}
}
}
.task-box{
width: 100%;
height: 72px;
......@@ -119,7 +149,7 @@
flex: 0 0 33.3%;
position: relative;
text-align: center;
image{
video{
width: 176rpx;
height: 176rpx;
display: inline-block;
......
<!--packageActivity/pages/taskDetail/taskDetail.wxml-->
<wxs module="fn">
var indexOf = function(e, num) {
return e.indexOf(num) > -1
}
module.exports.indexOf = indexOf
</wxs>
<view class="task-detail-box">
<view class="title">任务</view>
<view class="task-box">
......@@ -15,13 +21,23 @@
</view>
</view>
<view class="title">分享内容</view>
<view wx:if="{{fn.indexOf(materialTypeArr, 4)}}">
<view class="copyWriting" >将链接转发给好友或发送朋友圈可提高活动曝光度</view>
<view class="link-share" bind:tap="goShareLink" data-url="{{detailInfo.linkUrl}}">
<image src="{{detailInfo.activityImage ? detailInfo.activityImage : IMGURL+'share_task_default_img.png'}}"></image>
<view class="right">
<view>{{detailInfo.activityName}}</view>
<view class="type-text">{{activityTypList[0]}}活动</view>
</view>
</view>
</view>
<view class="share-box">
<image class="bg" webp src="{{IMGURL}}taskDetail_bg.png"></image>
<view class="user-box">
<image webp src="{{detailInfo.userImgUrl ? detailInfo.userImgUrl : IMGURL + 'order_person_default.png'}}"></image>
<image webp src="{{userStorage.weChatAvatarUrl ? userStorage.weChatAvatarUrl : IMGURL + 'order_person_default.png'}}"></image>
<view class="message">
<view class="name">{{detailInfo.userName}}<text>邀请你参加</text></view>
<view class="activity">{{detailInfo.merchantName}}{{detailInfo.activityName}}<text>{{activityTypList[0]}}</text></view>
<view class="name">{{userStorage.name || ""}}<text>邀请你参加</text></view>
<view class="activity">{{userStorage.merchantName || ""}}{{detailInfo.activityName || ""}}<text>{{activityTypList[0]}}</text></view>
</view>
</view>
<view class="content">
......@@ -34,18 +50,17 @@
<image class="image-box" bind:tap="previewMedia" data-current="{{index}}" src="{{item.url}}"></image>
</view>
<view wx:else class="video-box" bind:tap="previewMedia" data-current="{{index}}">
<image src="{{item.poster}}"></image>
<image class="paly-icon" webp src="{{IMGURL}}video_paly_icon.png"></image>
<video controls="{{false}}" show-center-play-btn="{{false}}" show-fullscreen-btn="{{false}}" src="{{item.url}}"></video>
</view>
</block>
</view>
</view>
</view>
<view class="btn-box">
<view class="btn" bind:tap="copyText" data-text="{{detailInfo.textContent}}">复制文案</view>
<view class="btn">复制链接</view>
<view class="btn" bind:tap="saveWith">
<view class="btn" wx:if="{{fn.indexOf(materialTypeArr, 1)}}" bind:tap="copyText">复制文案</view>
<view class="btn" wx:if="{{fn.indexOf(materialTypeArr, 4)}}" bind:tap="copyUrl">复制链接</view>
<view class="btn" bind:tap="saveWith" wx:if="{{fn.indexOf(materialTypeArr, 2) || fn.indexOf(materialTypeArr, 3)}}">
<text>一键保存图片</text>
<van-loading wx:if="{{isloading}}" size="30rpx" style="margin-left: 20rpx;" type="spinner" />
</view>
......
......@@ -16,8 +16,9 @@ Page({
},
onRoute(e) {
console.log(e)
this.setData({
infoData: e || {}
infoData: e
})
},
......
......@@ -2,12 +2,17 @@
.content{
width: 100%;
min-height: 100vh;
background: #000;
display: flex;
flex-flow: column;
background: #fff;
justify-content: center;
align-items: center;
}
.content video{
width: 100%;
height: 100%;
.time-box{
width: 100%;
height: 80rpx;
line-height: 80rpx;
font-size: 28rpx;
text-align: center;
color: #1B233D;
}
}
\ No newline at end of file
<!--packageActivity/pages/warReport/warReport.wxml-->
<view class="content">
<image src="{{infoData.linkUrl}}" mode="widthFix"></image>
<view class="time-box">{{infoData.reportCreatedDate}}</view>
<image src="{{infoData.reportUrl}}" mode="widthFix"></image>
</view>
// pages/checkProduct/checkProduct.js
// const navStyle = "background-color: transparent;";
import { IMG_URL } from "~/utils/constantData.js";
const navStyle = "background-color: #fff";
import { senceData } from "~/pages/tab/discovery/constant/data";
Page({
/**
* 页面的初始数据
*/
data: {
navStyle,
headerHeight: 0,
senceData,
// 模态框
isShow: true,
},
navbarReady(e) {
let {
height
} = e.detail;
this.setData({
headerHeight: height,
});
},
onPageScroll({
scrollTop
}) {
let opacity = scrollTop / 100
let color = `rgba(255,255,255${opacity > 1 ? 1 : opacity})`
this.setData({
navStyle: scrollTop == 0 ? navStyle : `background-color:${color};`
})
},
modelcloseFn(e) {
this.setData({
isShow: e.detail,
});
},
// 分享按钮
sharehandle() {
this.setData({
isShow: true,
});
},
onRouter(options) {
console.log("options: ", options);
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// actNum,activeNavIdx
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow(options) {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {},
});
{
"usingComponents": {
"product": "../tab/discovery/components/product/product",
"shareModel":"../tab/discovery/components/shareModel/shareModel"
},
"navigationBarTitleText": "特色产品",
"onReachBottomDistance": 10,
"backgroundColor": "#FC5B32",
"enablePullDownRefresh": true
}
/* pages/checkProduct/checkProduct.wxss */
page{
background-color: #fff;
}
\ No newline at end of file
<!--pages/checkProduct/checkProduct.wxml-->
<!-- <navigation-bar showBack="{{true}}" bindnavbarReady="navbarReady" navStyle="{{navStyle}}">特色产品</navigation-bar>
<view style="height:{{headerHeight}}px">
</view> -->
<product actNum="{{actNum}}" senceData="{{senceData}}" isShare="{{true}}"/>
<!-- 分享弹框 -->
<shareModel actNum="{{actNum}}" isShow="{{isShow}}" bindmodelclose="modelcloseFn" />
// pages/tab/discovery/components/product/product.js
import {imgUrlMixin} from '~/mixins/index'
const videoBaseUrl = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/'
Component({
behaviors: [imgUrlMixin],
/**
* 组件的属性列表
*/
properties: {
headerHeight: Number,
senceData:Object,
actNum: Number,
isShare:{
type: Boolean,
value: false
}
},
/**
* 组件的初始数据
*/
data: {
videoBaseUrl,
// senceData:['scene_talk.png','scene_delivery.png','scene_within_12mth.png','scene_more_12mth.png'],
navList:['数字无忧权益卡'],
activeNavIdx: 0, //特色产品
tab:['适用场景','营销链路','项目亮点','转化漏斗','合作流程','合作案例'],
......@@ -31,16 +29,12 @@ Component({
},
},
/**
* 组件的方法列表
*/
methods: {
changeSwiper(e){
console.log(e)
let actNum = e.detail.current
observers: {
actNum: function () {
let num = this.data.actNum;
let navList = []
let tab = ['适用场景','营销链路','项目亮点','转化漏斗','合作流程']
switch (actNum) {
switch (num) {
case 0:
navList = ["数字无忧权益卡"];
tab.push("合作案例");
......@@ -65,13 +59,15 @@ Component({
}
this.setData({
navList,
actNum,
intoViewId: `to-0`,
activeNavIdx: 0,
tab
})
this.getImgHeight();
},
},
methods: {
changeTab(e){
let idx = e.detail
this.setData({
......@@ -88,7 +84,6 @@ Component({
this.setData({
curTabIdx: idx
})
console.log(this.data.curTabIdx1)
},
getImgHeight(){
let query = wx.createSelectorQuery().in(this)
......@@ -115,10 +110,13 @@ Component({
heightArr.push(s);
});
this.data.heightArr = heightArr;
// console.log(heightArr[heightArr.length-1])
this.data.allHeight = heightArr[heightArr.length - 1];
})
.exec();
}
},
onShareFn() {
let { actNum, activeNavIdx ,senceData} = this.data;
wx.$router.go("checkProduct", { actNum, activeNavIdx ,senceData});
},
}
})
.scene-wrap {
white-space: nowrap;
height: 180rpx;
margin-bottom: 16rpx;
.scene-img {
width: 100%;
}
}
// 特色产品
.prod-wrap .big-title {
......
<view class="header">
<swiper bindchange="changeSwiper" class="scene-wrap" circular="{{true}}" previousMargin="40rpx" nextMargin="40rpx">
<block wx:for="{{senceData}}" wx:key="index">
<swiper-item>
<image class="scene-img" src="{{IMGURL}}{{item.img}}"></image>
</swiper-item>
</block>
</swiper>
</view>
<view class="prod-wrap">
<text class="big-title">特色产品</text>
<scroll-view enhanced="{{true}}" show-scrollbar="{{false}}" class="nav-wrap" scroll-x="{{true}}">
......@@ -29,7 +20,7 @@
</text>
</view>
<view class="share-btn">
<view class="share-btn" wx:if="{{!isShare}}" bindtap="onShareFn">
<image class="icon" src="{{IMGURL}}share.png"></image>
<text>分享</text>
</view>
......@@ -37,7 +28,7 @@
</view>
</view>
<view class="project-wrap">
<view style="position: sticky;top: {{headerHeight}}px ;z-index: 1;">
<view style="position: sticky;top: {{headerHeight}}px ;z-index: 1;background-color: #F5F7FB;">
<tab openScroll="{{true}}" tab="{{tab}}" index="{{curTabIdx}}" bindclick="changeTab"></tab>
</view>
<scroll-view class="project-img" scroll-into-view="{{intoViewId}}" bindscroll="scrolltoupper" scroll-y="{{true}}">
......@@ -52,7 +43,6 @@
<view class="video-text">{{item.name}}</view>
</view>
</block>
<!-- <view class="video-tips">- 如需开通请咨询客服 -</view> -->
</view>
</view>
</view>
......
// pages/tab/index/components/shareModel/shareModel.js
import { IMG_URL } from "~/utils/constantData.js";
const IMGURL = IMG_URL
import Draw from "~/utils/Draw.js";
import {imgUrlMixin} from '~/mixins/index'
Component({
behaviors: [imgUrlMixin],
/**
* 组件的属性列表
*/
properties: {
actNum: Number, //场景选择
isShow: Boolean,
// //分享方法
// onShareAppMessage:Function,
// onShareTimeline:Function,
},
/**
* 组件的初始数据
*/
data: {
btnList: [
{
src: `${IMGURL}wechat.png`,
name: "微信转发",
},
// {
// src: `${IMGURL}index/moments.png`,
// name: "朋友圈分享",
// },
{
src: `${IMGURL}down.png`,
name: "下载为海报",
},
],
// 4种场景下图片所有的高 (单位 rpx)
imgHeightArr: [
[1110, 1290, 596, 744, 490, 1532],
[2168, 1290, 596, 830, 490, 752],
[1110, 1290, 596, 984, 490],
[678, 1266, 1398, 830, 490, 1666],
],
posterUrl: "", //海报url
// imgList
// imgList:[
// {
// src:`${IMGURL}index/scene${actNum}1.png`,
// },
// ]
},
observers: {
actNum: function (actNum) {
let imgList = [
`${IMGURL}index/scene${actNum + 1}1.png`,
`${IMGURL}index/scene${actNum + 1}2.png`,
`${IMGURL}index/scene${actNum + 1}3.png`,
`${IMGURL}index/scene${actNum + 1}4.png`,
`${IMGURL}index/scene${actNum + 1}5.png`,
];
if (actNum != 2) {
imgList.push(`${IMGURL}index/scene${actNum + 1}6.png`);
}
this.setData({
imgList,
});
},
},
/**
* 组件的方法列表
*/
methods: {
// 分享按钮
handleClick(e) {
let { index } = e.currentTarget.dataset;
switch (index) {
case 0:
this.wechatFn();
break;
case 1:
this.download();
break;
}
},
// 微信转发
wechatFn() {
// this.data.onShareAppMessage()
this.modelClose();
},
// 下载海报
async download() {
let { actNum, imgHeightArr } = this.data;
//所有的长度
let imgAllHeight = imgHeightArr[actNum].reduce((total, current) => {
return total + current;
});
// 缺少视频的长度(前4张)+二维码的长度 (单位rpx)
let erCodeHeight =
imgHeightArr[actNum].slice(0, 4).reduce((total, current) => {
return total + current;
}) +
98 * 2;
// console.log("imgAllHeight: ", imgAllHeight);
let drawFun = new Draw({
width: 750,
height: imgAllHeight,
});
let imgList = [
{
x: 0,
y: 0,
width: 750,
height: imgAllHeight,
url: `${IMGURL}scene/longpic${
actNum + 1
}.png`,
},
{
x: 245*2,
y: erCodeHeight-11,
width: 120*2,
height: 120*2,
url: `https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/index/discovery_prod1.png`, //二维码
},
];
let posterUrl = await drawFun.begin({
imageList: imgList,
});
this.setData({
posterUrl: posterUrl.path,
});
console.log('posterUrl.path',posterUrl.path,wx.pro)
if(this.data.posterUrl){
wx.downloadFile({
url: this.data.posterUrl, //仅为示例,并非真实的资源
success (res) {
console.log('res: ', res);
}
})
}
this.modelClose();
},
//模态框关闭
modelClose() {
this.triggerEvent("modelclose", false);
},
// 图片加载事件
onloadFn(event) {
// console.log('event.detail',event.detail)
this.setData({
imgHeight: (event.detail.height * 0.2).toFixed(0),
});
},
},
});
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
/* pages/tab/index/components/shareModel/shareModel.wxss */
.share-wrap {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 1;
.img-wrap {
position: absolute;
top: 20%;
left: 50%;
transform: translateX(-50%);
width: 225px;
height: 311px;
// background-color: red;
overflow: auto;
.img {
width: 100%;
// height: auto;
height: 60%;
background-color: #fff;
}
}
.btns {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 154px;
background: #ffffff;
border-radius: 8px 8px 0 0;
.top {
display: flex;
justify-content: space-around;
.btn {
padding-top: 16px;
}
.img {
display: block;
margin: 0 auto 8px;
width: 40px;
height: 40px;
}
.name {
font-size: 12px;
color: #323436;
text-align: center;
line-height: 32rpx;
}
.btn-wechat{
width: auto;
margin: 0;
padding: 0;
background-color: #fff;
&::after{
border:none;
}
}
}
.btom {
margin: 18px auto 0;
width: 343px;
height: 44px;
line-height: 44px;
border: 1px solid #eeeeee;
border-radius: 4px;
text-align: center;
}
}
}
<!-- pages/tab/index/components/shareModel/shareModel.wxml -->
<view class="share-wrap" wx:if="{{isShow}}">
<view class="img-wrap">
<image class="img" style="height:{{imgHeight}}px" src="{{IMGURL}}scene/longpic{{actNum+1}}.png" bindload="onloadFn" />
<!-- <block wx:for="{{imgList}}" wx:key="*this">
<image class="img" src="{{item}}"/>
</block> -->
</view>
<button></button>
<view class="btns">
<view class="top">
<view class="btn" wx:for="{{btnList}}" wx:key="name" bindtap="handleClick" data-index="{{index}}">
<block wx:if="{{index == 0}}">
<button open-type="share" class="btn-wechat">
<image class="img" src="{{item.src}}" />
<view class="name">{{item.name}}</view>
</button>
</block>
<block wx:else>
<image class="img" src="{{item.src}}" />
<view class="name">{{item.name}}</view>
</block>
</view>
</view>
<view class="btom" bindtap="modelClose">取消</view>
</view>
</view>
\ No newline at end of file
......@@ -9,6 +9,7 @@ Page({
data: {
senceData,
headerHeight: 0,
actNum: 0,
navStyle,
// 预估弹框
visible: false,
......@@ -22,8 +23,7 @@ Page({
flow: 10000,
},
isFirst: true,
// tabList: pageData.tabList,
changeSale: 0, //每次改变的销量
changeSale: 0,
},
navbarReady(e) {
let {
......@@ -43,6 +43,12 @@ Page({
})
},
changeSwiper(e){
this.setData({
actNum:e.detail.current,
});
},
// 跳转咨询页面
goConsult() {
wx.pro.openCustomerServiceChat({
......
......@@ -2,6 +2,15 @@
.container{
position: relative;
.scene-wrap {
white-space: nowrap;
height: 180rpx;
margin-bottom: 16rpx;
.scene-img {
width: 100%;
}
}
.bg-img{
position: absolute;
top: 0;
......
......@@ -5,7 +5,16 @@
</navigation-bar>
<view style="padding-top: {{headerHeight}}px;">
<product senceData="{{senceData}}" headerHeight="{{headerHeight}}"></product>
<view class="header">
<swiper bindchange="changeSwiper" class="scene-wrap" circular="{{true}}" previousMargin="40rpx" nextMargin="40rpx">
<block wx:for="{{senceData}}" wx:key="index">
<swiper-item>
<image class="scene-img" src="{{IMGURL}}{{item.img}}"></image>
</swiper-item>
</block>
</swiper>
</view>
<product senceData="{{senceData}}" actNum="{{actNum}}" headerHeight="{{headerHeight}}"></product>
</view>
</view>
......
......@@ -13,11 +13,6 @@ Component({
activeList: {
type: Array,
observer(newVal) {
if (newVal) {
this.setData({
activeList: newVal
})
}
}
}
},
......@@ -78,12 +73,12 @@ Component({
this.setData({
[itemVal]: val
})
console.log(itemVal)
})
} else {
val.isCollapse = !flag
}
} else {
console.log(ind)
val.isCollapse = true
}
})
......@@ -121,7 +116,7 @@ Component({
data: this.filterJumpUrl(id),
success (res) {
wx.showToast({
title: '活动链接已复制',
title: '复制成功',
icon: "none"
})
}
......
......@@ -7,13 +7,13 @@
</view>
<view class="item-box" wx:if="{{imageLoaded}}">
<!-- 活动top信息 -->
<activity-top data="{{item}}">
<activity-top data="{{item}}" widthStyle="flex: 0 0 62%;">
<image webp src="{{IMGURL}}hot-icon.png?v={{img_version}}"></image>
<view class="hot">火爆进行中</view>
</activity-top>
<!-- 活动操作按钮 -->
<view class="active-btn">
<view class="btn" bind:tap="jump" data-id="{{item.id}}">活动战报</view>
<view class="btn" bind:tap="jump" data-item="{{item}}">活动战报</view>
<view class="btn" bind:tap="copyActivityUrl" data-id="{{item.id}}">分享活动</view>
<view class="btn primary" bind:tap="goToDetail" data-id="{{item.id}}">查看详情</view>
</view>
......
......@@ -45,10 +45,9 @@ Component({
},
// 任务详情
jump(e) {
let { status, item } = e.currentTarget.dataset
console.log(item)
let { status, item, activityimg } = e.currentTarget.dataset
if (status == 2) return // 已完成
wx.$router.go('packageActivity.taskDetail', item)
wx.$router.go('packageActivity.taskDetail', {...item, activityImg: activityimg})
},
// 切换日期查看任务
changeDate(e) {
......
......@@ -3,8 +3,8 @@
<wxs src="../index.wxs" module="fn"></wxs>
<block wx:if="{{!isCollapse}}">
<view class="title">任务日历<text> · {{data.missionList.length}}</text></view>
<view class="calender-box {{data.newtaskCalenderList.length > 1 ? 'p-b-54' : ''}}">
<swiper class="swiper" current="{{data.calenderActiveIndex}}" bindchange="changeTaskCalender" data-index="{{index}}">
<view wx:if="{{data.newtaskCalenderList.length}}" class="calender-box {{data.newtaskCalenderList.length > 1 ? 'p-b-54' : ''}}">
<swiper class="swiper" current="{{data.calenderActiveIndex}}" bindchange="changeTaskCalender" data-index="{{index}}">
<block wx:for="{{data.newtaskCalenderList}}" wx:for-item="val" wx:for-index="k" wx:key="k">
<swiper-item class='swiper_item'>
<block wx:for="{{val}}" wx:for-item="v" wx:for-index="j" wx:key="j">
......@@ -39,7 +39,7 @@
</view>
</view>
<view class="task-btn">
<view class="btn {{val.completeStatus == 1 ? 'primary' : ''}}" bind:tap="jump" data-status="{{val.completeStatus}}" data-item="{{val}}">{{val.completeStatus == 1 ? '去完成' : '已完成'}}</view>
<view class="btn {{val.completeStatus == 1 ? 'primary' : ''}}" bind:tap="jump" data-status="{{val.completeStatus}}" data-item="{{val}}" data-activityimg="{{data.activityImg}}">{{val.completeStatus == 1 ? '去完成' : '已完成'}}</view>
<view class="btn_title" wx:if="{{val.completeStatus == 2}}">奖励已发放</view>
</view>
</view>
......
// pages/tab/index/components/activityDiagnosis/activityDiagnosis.js
import {imgUrlMixin} from '~/mixins/index'
import ActivityApi from "~/api/activityApi/index"
import {
domain
} from '~/utils/request/http'
Component({
/**
* 组件的属性列表
......@@ -41,11 +44,16 @@ Component({
if (key == ind) {
if (flag && !val.orderList) {
val.isloading = true
ActivityApi.getActivityEndInstallOrderList({activityId: val.id}).then(res => {
ActivityApi.getActivityEndInstallOrderList({activityId: 495}).then(res => {
res.orderList && res.orderList.forEach(it => {
it.time = new Date(it.payDate).format('yyyy-MM-dd hh:mm:ss')
})
val.isloading = false
val.isCollapse = false
val.orderList = res.orderList
val.orderTotal = res.orderTotal
val.reInstallContactsName = res.reInstallContactsName
val.reInstallContactsPhone = res.reInstallContactsPhone
let itemVal = 'activityList['+ind+']'
this.setData({
[itemVal]: val
......@@ -63,6 +71,14 @@ Component({
})
},
toUnicode (chineseStr = '') {
let unicodeStr = ''
for (let i = 0, iLength = chineseStr.length; i < iLength; i++) {
unicodeStr += '@' + chineseStr.charCodeAt(i).toString(16)
}
return unicodeStr
},
filterJumpUrl(id) {
const userStorage = wx.$storage.get('userInfo')
return `${domain}/scrm-wx-merchant-activity/#/?id=${id}&merchantId=${userStorage.merchantId}&shareStaffUuid=${userStorage.uuid}&shareStaffName=${this.toUnicode(userStorage.name)}&shareStaffType=2&sharedTime=${Date.now()}`
......
......@@ -8,13 +8,13 @@
</view>
<view class="item-box" wx:if="{{imageLoaded}}">
<!-- 活动top信息 -->
<activity-top data="{{item}}">
<activity-top data="{{item}}" widthStyle="flex: 0 0 72%;">
<image webp src="{{IMGURL}}activity_end_icon.png?v={{img_version}}"></image>
<view class="end">已结束</view>
</activity-top>
<!-- 活动操作按钮 -->
<view class="active-btn">
<view class="btn" bind:tap="jump" data-id="{{item.id}}">活动战报</view>
<view class="btn" bind:tap="jump" data-item="{{item}}">活动战报</view>
<view class="btn primary" bind:tap="goToDetail" data-id="{{item.id}}">查看详情</view>
</view>
<!-- 活动概览 -->
......
......@@ -8,6 +8,9 @@ Component({
data: {
type: Object,
value: {}
},
widthStyle: {
type: String
}
},
......@@ -15,7 +18,7 @@ Component({
* 组件的初始数据
*/
data: {
activityTypList: index_const.data.activityTypList
activityTypList: index_const.data.activityTypList,
},
/**
......
......@@ -10,6 +10,8 @@
width: 100%;
height: 100%;
position: absolute;
border-radius: 16rpx;
overflow: hidden;
top: 0;
left: 0;
}
......@@ -36,7 +38,6 @@
display: flex;
align-items: center;
.left{
flex: 0 0 60%;
font-weight: 600;
font-size: 36rpx;
color: #1B233D;
......@@ -47,7 +48,6 @@
word-break: break-all;
}
.right{
flex: 0 0 40%;
display: flex;
flex-flow: 1;
font-size: 28rpx;
......
......@@ -9,7 +9,7 @@
</view>
<view class="active-title">
<view class="name">
<view class="left">{{data.activityName}}</view>
<view class="left" style="{{widthStyle}}">{{data.activityName}}</view>
<view class="right">
<slot></slot>
</view>
......
......@@ -10,7 +10,6 @@ Component({
type: Object,
value: {},
observer(newVal) {
}
},
showPopup: {
......@@ -53,7 +52,12 @@ Component({
// 查看预约安装信息
showPopup(e) {
let { item } = e.currentTarget.dataset
if (!item.reInstallContactsName && !item.reInstallContactsPhone)
if (!item.reInstallContactsName && !item.reInstallContactsPhone) {
return wx.showToast({
title: '暂无安装联系人信息',
icon: 'none'
})
}
this.setData({
installItem: item,
showPopup: true
......
......@@ -11,13 +11,13 @@
<view class="top-left">
<image webp src="{{item.customerImageUrl ? item.customerImageUrl : IMGURL+'order_person_default.png'}}"></image>
<view class="user-message">
<view class="name" wx:if="{{item.customerNickName}}">{{item.customerNickName}}</view>
<view class="mobile" wx:if="{{item.customerPhone}}">{{item.customerPhone}}</view>
<view class="name">{{item.customerNickName || ""}}</view>
<view class="mobile">{{item.customerPhone || ""}}</view>
</view>
</view>
<view class="btn-img">
<image wx:if="{{item.mobile}}" webp src="{{IMGURL}}activity_order_phone_icon.png" bind:tap="callPhone" data-mobile="{{item.mobile}}"></image>
<image wx:if="{{item.customerPhone}}" webp src="{{IMGURL}}activity_order_phone_icon.png" bind:tap="callPhone" data-mobile="{{item.customerPhone}}"></image>
<image wx:if="{{item.wechartNo}}" webp src="{{IMGURL}}activity_order_wechart_icon.png" bind:tap="copyWechart" data-wechartno="{{item.wechartNo}}"></image>
</view>
</view>
......
......@@ -53,7 +53,7 @@
.sort-box:last-child{
position: absolute;
left: -46rpx;
top: 55%;
top: 50%;
}
.sort{
font-size: 48rpx;
......
......@@ -51,12 +51,12 @@ Page({
this.getData()
},
getData() {
this.getActivityList(1)
this.getActivityList(2)
getData(onPullDown) {
this.getActivityList(1, onPullDown)
this.getActivityList(2, onPullDown)
},
getActivityList(num) {
getActivityList(num, onPullDown) {
let {activePageNum, pageSize, pageNum, activeList, activityEndList, tabIndex} = this.data
ActivityApi.getActivityList({
type: num,
......@@ -70,7 +70,7 @@ Page({
val.tabIndex = num - 1
if (num == 1 && activePageNum == 1 && index == 0) { // 活动中默认展开第一条
val.isloading = true
ActivityApi.getActiveTaskList({activityId: 1}).then(res => {
ActivityApi.getActiveTaskList({activityId: val.id}).then(res => {
val.isloading = false
val.missionList = res
val.newtaskCalenderList = this.calenderFilter(JSON.parse(JSON.stringify(val.missionList)) || [], 7)
......@@ -99,9 +99,14 @@ Page({
if (num == 2 && pageNum == 1 && index == 0) { // 活动诊断展开第一条
ActivityApi.getActivityEndInstallOrderList({activityId: val.id}).then(res => {
val.isCollapse = false
res.orderList && res.orderList.forEach(it => {
it.time = new Date(it.payDate).format('yyyy-MM-dd hh:mm:ss')
})
val.orderList = res.orderList
val.orderTotal = res.orderTotal
let itemVal = 'activityList['+ind+']'
val.reInstallContactsName = res.reInstallContactsName
val.reInstallContactsPhone = res.reInstallContactsPhone
let itemVal = 'activityEndList['+index+']'
this.setData({
[itemVal]: val
})
......@@ -110,13 +115,12 @@ Page({
})
if (num == 1) {
this.setData({
activeList: [...activeList, ...res.data],
activeList: onPullDown ? res.data : [...activeList, ...res.data],
activeTotal: res.count
})
if ([...activeList, ...res.data]) activeList.forEach
} else {
this.setData({
activityEndList: [...activityEndList, ...res.data],
activityEndList: onPullDown ? res.data : [...activityEndList, ...res.data],
total: res.count
})
}
......@@ -157,7 +161,7 @@ Page({
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.getData()
this.getData(true)
},
/**
......
......@@ -7,36 +7,41 @@ class Draw {
[_pixelRatio_] = null;
[_canvasObject_] = null;
[_canvas_] = null
constructor(canvasObject) {
wx.getSystemInfo().then(({ pixelRatio }) => {
// console.log(pixelRatio)
this[_canvasObject_] = canvasObject
this[_pixelRatio_] = canvasObject.pixelRatio || pixelRatio || 2
const height = this.toRpx(canvasObject.height),
width = this.toRpx(canvasObject.width),
canvas = wx.createOffscreenCanvas({
type: '2d',
width,
height
}),
ctx = canvas.getContext('2d')
this[_canvas_] = canvas
this[_ctx_] = ctx
this[_ctx_].clearRect(0, 0, width, height)
this.drawFill({
x: 0,
y: 0,
constructor(canvasObject, isCompInst) {
this[_canvasObject_] = canvasObject
this[_pixelRatio_] = canvasObject.pixelRatio || 2
const height = this.toRpx(canvasObject.height),
width = this.toRpx(canvasObject.width),
canvas = wx.createOffscreenCanvas({
type: '2d',
width,
height,
color: canvasObject.backgroundColor || 'rgb(255, 255, 255)'
})
this[_ctx_].save()
compInst:isCompInst
}),
ctx = canvas.getContext('2d')
this[_canvas_] = canvas
this[_ctx_] = ctx
this[_ctx_].clearRect(0, 0, width, height)
this.drawFill({
x: 0,
y: 0,
width,
height,
color: canvasObject.backgroundColor || 'rgb(255, 255, 255)'
})
this[_ctx_].save()
}
drawImages(imageParams, callback) {
async drawImages(imageParams, callback) {
this[_ctx_].beginPath()
this[_ctx_].save()
let { borderRadius, height, width, url, x, y } = imageParams
let {
borderRadius,
height,
width,
url,
x,
y
} = imageParams
height = this.toRpx(height)
width = this.toRpx(width)
x = this.toRpx(x)
......@@ -52,13 +57,14 @@ class Draw {
this[_ctx_].clip()
}
let image = this[_canvas_].createImage()
new Promise(resolve => {
image.onload = resolve
image.src = `${url}?v=${Date.now()}`
}).then(() => {
this[_ctx_].drawImage(image, x, y, width, height)
this[_ctx_].restore()
if (callback) callback()
image.src = `${url}?v=${Date.now()}`
return new Promise(resolve => {
image.onload = () => {
this[_ctx_].drawImage(image, x, y, width, height)
this[_ctx_].restore()
if (callback) callback()
resolve(imageParams)
}
})
}
toRpx(val) {
......@@ -69,7 +75,13 @@ class Draw {
if (fontSize) this[_ctx_].font = `${fontSize}px${font}`
return this[_ctx_].measureText(text).width
}
drawFill({ x, y, width, height, color }) {
drawFill({
x,
y,
width,
height,
color
}) {
height = this.toRpx(height)
width = this.toRpx(width)
x = this.toRpx(x)
......@@ -82,8 +94,25 @@ class Draw {
this[_ctx_].save()
}
drawText(textParams) {
let { textDecoration, textBaseline, lineHeight, fontWeight, textAlign, textWidth, maxWidth, fontSize, lastFont, opacity, lineNum, width, color, text, x, y } = textParams,
font = this[_ctx_].font.split('px')[1]
let {
textDecoration,
textBaseline,
lineHeight,
fontWeight,
textAlign,
textWidth,
maxWidth,
fontSize,
lastFont,
opacity,
lineNum,
width,
color,
text,
x,
y
} = textParams,
font = this[_ctx_].font.split('px')[1]
textAlign = textAlign || 'left'
textBaseline = textBaseline || 'normal'
opacity = typeof opacity === 'number' ? opacity : 1
......@@ -140,6 +169,7 @@ class Draw {
height: boxHeight,
color: textParams.background
})
}
const drawOneLineText = () => {
let textArr = text.toString().split(''),
......@@ -218,15 +248,20 @@ class Draw {
} else {
drawOneLineText()
}
} else {
drawOneLineText()
}
} else drawOneLineText()
this[_ctx_].stroke()
}
drawLine(lineParams, callback) {
this[_ctx_].beginPath()
let { opacity, startX, startY, width, color, endX, endY } = lineParams
let {
opacity,
startX,
startY,
width,
color,
endX,
endY
} = lineParams
startX = this.toRpx(startX)
startY = this.toRpx(startY)
width = this.toRpx(width)
......@@ -243,7 +278,12 @@ class Draw {
if (callback) callback()
}
setLineY = params => {
let { textDecoration, textBaseline, fontSize, y } = params
let {
textDecoration,
textBaseline,
fontSize,
y
} = params
let type = {
underline: {
top: y + fontSize,
......@@ -266,8 +306,11 @@ class Draw {
}
return type[textDecoration][textBaseline]
}
setLineX({ textAlign, text, x }) {
setLineX({
textAlign,
text,
x
}) {
let textWidth = this.getTextWidth(text)
let type = {
left: x,
......@@ -276,8 +319,13 @@ class Draw {
}
return type[textAlign]
}
drawRadiusRect({ borderRadius, height, width, x, y }, callBack) {
drawRadiusRect({
borderRadius,
height,
width,
x,
y
}, callBack) {
let radius = typeof borderRadius === 'string' ? ((Number(borderRadius.split('%')[0]) / 100) * width) / 2 : borderRadius / 2
radius = radius || 0
this[_ctx_].beginPath()
......@@ -288,7 +336,12 @@ class Draw {
}
if (callBack) callBack()
}
getFontWidth({ textAlign, fontSize, text, x }) {
getFontWidth({
textAlign,
fontSize,
text,
x
}) {
let type = {
left: x,
center: x - (fontSize * text.length) / 2,
......@@ -298,7 +351,12 @@ class Draw {
}
drawDecoration(params) {
let { newText, opacity, y, x } = params
let {
newText,
opacity,
y,
x
} = params
let lineX = x
let lineY = y
lineX = this.setLineX(params)
......@@ -329,10 +387,33 @@ class Draw {
})
}
base64src(url).then(img => {
console.log('img', img)
createLocalImg(img, callBack)
})
}
async begin(data = {}) {
return new Promise(async (resolve, reject) => {
const drawFun = () => {
data.textList && data.textList.length && data.textList.map(e => {
this.drawText(e)
})
data.lineList && data.lineList.length && data.lineList.map(e => {
this.drawLine(e)
})
wx.nextTick(() => {
this.toDataURL(res => resolve(res))
})
}
if (data.imageList && data.imageList.length) {
await this.drawImages(data.imageList[0])
if (data.imageList.length > 1)
for (let index = 1; index < data.imageList.length; index++) {
await this.drawImages(data.imageList[index])
if (index == data.imageList.length - 1) drawFun()
}
else drawFun()
}
})
}
}
const checkTextDecoration = textDecoration => {
return textDecoration && (textDecoration === 'underline' || textDecoration === 'overline' || textDecoration === 'line-through')
......@@ -355,4 +436,4 @@ const createLocalImg = (url, callBack) => {
}
})
}
export default Draw
export default Draw
\ No newline at end of file
......@@ -38,6 +38,7 @@ class Share {
if (sharePath) path = `/${sharePath}`
if (shareQuery) path += `?${shareQuery}`
if (!noPageAuth) path = `/login/loading/loading?url=${encodeURIComponent(path)}`
console.log(path)
return {
path,
title: shareTitle,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!