Commit 6b03a114 by 杨北旺

Merge branch 'v3.0' of http://192.168.3.233:8090/saas_plus/store-assistant into v3.0

2 parents a2e80071 87552f2c
...@@ -73,6 +73,13 @@ class ActivityApi { ...@@ -73,6 +73,13 @@ class ActivityApi {
...data ...data
}) })
} }
// 获取当前活动的海报
getActivityPosters(data) {
return api.post({
method: `scrm.api.assistant.crowdFunding.poster`,
...data
})
}
} }
export default ActivityApi export default ActivityApi
\ No newline at end of file \ No newline at end of file
...@@ -45,13 +45,11 @@ class UsersApi { ...@@ -45,13 +45,11 @@ class UsersApi {
} }
/**授权手机号登录 */ /**授权手机号登录 */
async authUserPhone(detail, loginToken) { async authUserPhone(detail, loginToken) {
console.log(221)
if (!loginToken) { if (!loginToken) {
wx.$api.showToast('缺少loginToken') wx.$api.showToast('缺少loginToken')
Promise.reject() Promise.reject()
return return
} }
console.log(111)
if (detail.errMsg && detail.errMsg == 'getPhoneNumber:fail user deny') Promise.reject() if (detail.errMsg && detail.errMsg == 'getPhoneNumber:fail user deny') Promise.reject()
delete detail.errMsg delete detail.errMsg
if (detail.iv && detail.encryptedData) { if (detail.iv && detail.encryptedData) {
......
...@@ -80,7 +80,8 @@ ...@@ -80,7 +80,8 @@
"van-popup": "@vant/weapp/popup/index", "van-popup": "@vant/weapp/popup/index",
"install-popup": "/components/installPopup/installPopup", "install-popup": "/components/installPopup/installPopup",
"van-loading": "@vant/weapp/loading/index", "van-loading": "@vant/weapp/loading/index",
"mp-html": "/components/mp-html" "mp-html": "/components/mp-html",
"share-popup": "/components/sharePopup/sharePopup"
}, },
"resolveAlias": { "resolveAlias": {
"~/*": "/*" "~/*": "/*"
......
...@@ -52,7 +52,7 @@ Component({ ...@@ -52,7 +52,7 @@ Component({
/** /**
* 禁止滑动 * 禁止滑动
*/ */
// noScroll: wx.$util.noScroll(), noScroll(){},
cancel(e) { cancel(e) {
let { confirm } = e.currentTarget.dataset let { confirm } = e.currentTarget.dataset
let { buttonType, title } = this.data let { buttonType, title } = this.data
......
// components/sharePopup/sharePopup.js
import {imgUrlMixin} from '~/mixins/index'
import index_const from "~/pages/tab/index/index_const"
import { IMG_URL } from '~/utils/constantData'
import Draw from '~/utils/Draw'
Component({
/**
* 组件的属性列表
*/
behaviors: [imgUrlMixin],
properties: {
data: {
type: Object,
observer(val) {
let thisPage = wx.$router.getPageInstance()
this.setData({
navHeight: thisPage.data.navHeight
})
if (val.showSharePopup) {
wx.$util.getViewInfo('.user-box', res => {
this.setData({
boxImageHeight: res.height,
})
val.boxImageHeight = res.height
// 计算弹窗图片区域最大高度
wx.$util.getViewInfo('.layout', res => {
this.setData({
postersBoxHeight: res.height * 0.7,
postersImageHeight: res.height * 0.7 - this.data.boxImageHeight - 20
})
val.postersBoxHeight = res.height * 0.7,
val.postersImageHeight = res.height * 0.7 - this.data.boxImageHeight - 20
this.init(val)
// this.init(val)
})
}, this)
}
}
}
},
/**
* 组件的初始数据
*/
data: {
USERINFO: wx.$storage.get('userInfo'),
activityTypList: index_const.data.activityTypList
},
/**
* 组件的方法列表
*/
methods: {
async init(n) {
wx.$api.showLoading()
const drawfun = new Draw({
width: 280,
height: 560 + n.boxImageHeight
}, this),
{
userInfo
} = wx.$storage.get(),
res = await drawfun.begin({
imageList: [{
x: 0,
y: 0,
width: 279,
height: n.boxImageHeight,
url: `${this.data.IMGURL}taskDetail_bg.png`
},
// {
// x: 12,
// y: 12,
// width: 20,
// height: 20,
// url: `${userInfo.weChatAvatarUrl ? userInfo.weChatAvatarUrl : this.data.IMGURL}order_person_default.png`
// },
{
x: 16,
y: n.boxImageHeight + 10,
width: 247,
height: 500,
url: n.posterImg
},
// {
// x: 204,
// y: n.postersImageHeight / 2 + boxImageHeight + 20,
// width: 60,
// height: 60,
// url: n.imagePath
// }
],
textList: [{
x: 44,
y: 14,
fontSize: 14,
color: '#2D2D33',
text: userInfo.name,
textBaseline: 'top'
},
{
x: 44 + drawfun.getTextWidth(userInfo.name, 14),
y: 15,
fontSize: 12,
color: '#6E6E7A',
text: '邀请你参加',
textBaseline: 'top'
},
{
x: 44,
y: 36,
fontSize: 14,
color: '#1B233D',
text: n.activityName,
textBaseline: 'top',
fontWeight: 500
},
{
x: 44 + drawfun.getTextWidth(n.activityName, 14) + 9,
y: 39,
fontSize: 10,
color: '#4466F0',
text: '众筹',
border: {
width: 1,
color: '#8FA5FF',
radius: 2,
padding: [5, 5]
}
},
// {
// x: 16,
// y: (n.postersImageHeight / 2) + boxImageHeight + 30,
// fontSize: 13,
// color: '#1B233D',
// text: userInfo.merchantName
// },
// {
// x: 16,
// y: n.postersImageHeight / 2 + boxImageHeight + 50,
// fontSize: 11,
// color: '#6E6E7A',
// text: n.address,
// lineNum: 3,
// width: 193
// }
],
})
wx.hideLoading()
this.setData({
poster: res.path
})
},
close() {
let thisPage = wx.$router.getPageInstance()
thisPage.setData({
sharePopupData: {
showSharePopup: false
}
})
},
saveImage(e) {
const filePath = this.data.poster,
_this = this
wx.saveImageToPhotosAlbum({
filePath,
success(){
wx.$api.showToast('保存成功')
},
fail(err) {
const auth = _this.selectComponent('#auth')
auth.check()
}
}
)
},
noScroll() {},
authFail(e) {
this.setData({
showAuth: true
})
}
}
})
{
"component": true,
"usingComponents": {
"authorize":"/components/Authorize/Authorize"
}
}
\ No newline at end of file \ No newline at end of file
/* components/sharePopup/sharePopup.wxss */
.share-popup {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 998;
perspective: 99999999px;
.share-popup-bg {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
animation: show-popup-bg .1s forwards .1s;
}
.share-box{
width: 560rpx;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
box-sizing: border-box;
animation: show-modal .1s forwards;
}
.close-box{
text-align: right;
margin-bottom: 16rpx;
.close_btn{
display: inline-block;
width: 56rpx;
height: 56rpx;
}
}
.share-popup-content{
position: relative;
background: #FFFFFF;
border-radius: 16rpx;
box-shadow: 0 4rpx 20rpx 0 rgba(0, 0, 0, 0.10);
overflow-y: auto;
.bg{
width: 100%;
height: 132rpx;
}
.user-box{
position: absolute;
top: 0;
padding: 24rpx;
display: flex;
image{
width: 40rpx;
height: 40rpx;
margin-right: 24rpx;
flex-shrink: 0;
border-radius: 20rpx;
}
.message{
display: flex;
flex-flow: column;
justify-content: space-between;
font-size: 28rpx;
color: #2D2D33;
.name{
font-size: 28rpx;
text{
font-size: 24rpx;
color: #6E6E7A;
margin-left: 16rpx;
}
}
.activity{
word-break: break-all;
.activity-type-tag{
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;
white-space: nowrap;
}
}
}
}
.content-box{
width: 100%;
padding: 32rpx 32rpx 0 32rpx;
box-sizing: border-box;
.posters_img{
margin: 0 auto;
width: 100%;
}
.merchant_box{
display: flex;
justify-content: space-between;
margin-top: 16rpx;
.name{
font-weight: 500;
font-size: 26rpx;
color: #1B233D;
}
.address{
font-weight: 400;
font-size: 22rpx;
color: #6E6E7A;
}
.qrcode{
flex-shrink: 0;
width: 120rpx;
height: 120rpx;
}
}
}
}
.btn-box{
display: flex;
flex-flow: column;
align-items: center;
color: #fff;
margin-top: 32rpx;
.btn{
width: 320rpx;
height: 88rpx;
line-height: 88rpx;
text-align: center;
background-image: linear-gradient(-60deg, #556AF5 0%, #7197FF 100%);
border-radius: 16rpx;
}
.tips{
font-weight: 400;
font-size: 24rpx;
}
}
}
.canvas-box {
position: absolute;
left: -9999rpx;
top: -9999rpx;
width: 750rpx;
height: 750rpx;
}
@keyframes show-popup-bg {
0% {
background-color: rgba(0, 0, 0, 0);
}
100% {
background-color: rgba(45, 45, 51, .6);
}
}
\ No newline at end of file \ No newline at end of file
<!--components/sharePopup/sharePopup.wxml-->
<view class="share-popup" wx:if="{{data.showSharePopup}}" catchtouchmove="noScroll">
<view class="share-popup-bg" />
<view class="share-box" style="transform: translate(-50%, calc(-50% + {{navHeight / 2}}px));">
<view class="close-box">
<view class="close_btn" bindtap="close">
<image webp src="{{IMGURL}}popup_close_btn.png"></image>
</view>
</view>
<view class="share-popup-content" style="height: {{postersBoxHeight}}px;">
<!-- 用户活动信息 -->
<block>
<image class="bg" style="height: {{boxImageHeight}}px;" webp src="{{IMGURL}}taskDetail_bg.png"></image>
<view class="user-box">
<image webp class="user_image" src="{{USERINFO.weChatAvatarUrl ? USERINFO.weChatAvatarUrl : IMGURL + 'order_person_default.png'}}"></image>
<view class="message">
<view class="name">{{USERINFO.weChatNickName || USERINFO.name || ""}}<text>邀请你参加</text></view>
<view class="activity"><text>{{data.activityName || ""}}</text><text class="activity-type-tag">{{activityTypList[0]}}</text></view>
</view>
</view>
</block>
<!-- 海报 -->
<block>
<view class="content-box">
<image class="posters_img" style="height: {{postersImageHeight}}px;" mode="aspectFit" src="{{data.posterImg}}"></image>
<!-- <view class="merchant_box">
<view class="merchant_message">
<view class="name">{{USERINFO.merchantName}}</view>
<view class="address">{{data.address}}</view>
</view>
<view class="qrcode">
<image src="{{data.imagePath}}"></image>
</view>
</view> -->
</view>
</block>
<!-- 保存 -->
</view>
<view class="btn-box">
<view class="btn" bind:tap="saveImage">保存至相册</view>
<view class="tip">提示:这是您的专属活动海报,请保存至手机相册后转发给客户微信,系统将自动记录成交订单归属,并发放积分奖励!</view>
</view>
</view>
<view class="canvas-box">
<canvas style="width:355px;height:370px; margin:0 auto;" canvas-id="mycanvas" />
</view>
</view>
<authorize scopeType="writePhotosAlbum" bindfail="authFail" show="{{showAuth}}" id="auth"></authorize>
...@@ -88,9 +88,9 @@ Page({ ...@@ -88,9 +88,9 @@ Page({
reportData({ reportData({
openId: WXUSERINFO.openId || '', openId: WXUSERINFO.openId || '',
unionId: USERINFO.uuid || '', unionId: USERINFO.uuid || '',
nickName: USERINFO.weChatNickName || USERINFO.name, nickName: USERINFO.name || '',
avatar: USERINFO.weChatAvatarUrl || '', avatar: USERINFO.weChatAvatarUrl || '',
phone: USERINFO.weChatPhone || '', phone: USERINFO.phone || USERINFO.weChatPhone || '',
merchantId: USERINFO.merchantId || '', merchantId: USERINFO.merchantId || '',
shopName: USERINFO.merchantName || '', shopName: USERINFO.merchantName || '',
sceneCode: currentSceneCode || '', sceneCode: currentSceneCode || '',
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import index_const from "~/pages/tab/index/index_const" import index_const from "~/pages/tab/index/index_const"
import ActivityApi from '~/api/activityApi/index' import ActivityApi from '~/api/activityApi/index'
import { showEmoji } from '~/utils/emoji' import { showEmoji } from '~/utils/emoji'
import QR from '~/utils/lib/wxqrcode'
import { import {
taskShareReport taskShareReport
} from '~/api/api.js' } from '~/api/api.js'
...@@ -20,10 +21,6 @@ Page({ ...@@ -20,10 +21,6 @@ Page({
materialTypeArr: [], // 素材类型 materialTypeArr: [], // 素材类型
userStorage: {} userStorage: {}
}, },
shareTitle: '',
shareImage: '',
sharePath: '',
noPageAuth: true,
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
...@@ -38,10 +35,9 @@ Page({ ...@@ -38,10 +35,9 @@ Page({
}) })
let id = this.options.missionId.toString().split('&')[0] let id = this.options.missionId.toString().split('&')[0]
this.getActiveTaskDetail(id) this.getActiveTaskDetail(id)
this.sharePath = `packageActivity/pages/shareTaskDetail/shareTaskDetail?missionId=${id}&name=${userStorage.weChatNickName || userStorage.name}`
}) })
}, },
// 拼接活动专属链接
filterJumpUrl(id) { filterJumpUrl(id) {
const userStorage = wx.$storage.get('userInfo') 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)}&isExclusive=1&exclusiveUuid=${userStorage.uuid}&shareStaffType=2&sharedTime=${Date.now()}` return `${domain}/scrm-wx-merchant-activity/#/?id=${id}&merchantId=${userStorage.merchantId}&shareStaffUuid=${userStorage.uuid}&shareStaffName=${this.toUnicode(userStorage.name)}&isExclusive=1&exclusiveUuid=${userStorage.uuid}&shareStaffType=2&sharedTime=${Date.now()}`
...@@ -62,9 +58,9 @@ Page({ ...@@ -62,9 +58,9 @@ Page({
// missonType 任务类型1注册 2分享 3浏览 4访客 5下单 // missonType 任务类型1注册 2分享 3浏览 4访客 5下单
if (res.missonType != 2) { // 非分享任务 显示活动专属链接 if (res.missonType != 2) { // 非分享任务 显示活动专属链接
res.linkUrl = this.filterJumpUrl(res.activityId) res.linkUrl = this.filterJumpUrl(res.activityId)
wx.hideShareMenu({ // wx.hideShareMenu({
menus: ['shareAppMessage'], // menus: ['shareAppMessage'],
}) // })
} }
let typeArr = [] let typeArr = []
res.platformMerchantMissionMaterialResponseList && res.platformMerchantMissionMaterialResponseList.forEach(val => { res.platformMerchantMissionMaterialResponseList && res.platformMerchantMissionMaterialResponseList.forEach(val => {
...@@ -72,7 +68,7 @@ Page({ ...@@ -72,7 +68,7 @@ Page({
// materialType 素材类型1文案 2图片 3视频 4专属链接 // materialType 素材类型1文案 2图片 3视频 4专属链接
if (val.materialType == 1) { // 文案 if (val.materialType == 1) { // 文案
res.textContent = val.materialContent res.textContent = val.materialContent
res.filterTextContent = `<view>${showEmoji(val.materialContent)}</view>` res.filterTextContent = `<view style="word-break: break-all;">${showEmoji(val.materialContent)}</view>`
} }
if (val.materialType == 2 || val.materialType == 3) { // 图片视频 if (val.materialType == 2 || val.materialType == 3) { // 图片视频
res.imgUrlList.push({ res.imgUrlList.push({
...@@ -81,17 +77,18 @@ Page({ ...@@ -81,17 +77,18 @@ Page({
}) })
} }
if (val.materialType == 4) { // 链接 if (val.materialType == 4) { // 链接
res.linkUrl = val.materialContent res.linkUrl = this.filterJumpUrl(res.activityId)
} }
}) })
// 分享埋点上报
this.shareTrackData = { item_id: res.activityId }
this.setData({ this.setData({
detailInfo: res, detailInfo: res,
materialTypeArr: typeArr materialTypeArr: typeArr
}) })
this.shareImage = res.imgUrlList[0] && res.imgUrlList[0].materialType == 2 ? res.imgUrlList[0].url : `${this.data.IMGURL}share_task_default_img.png` wx.$util.getViewInfo('.user-box', res => {
this.shareTitle = res.activityName || '门店助手' if (res) this.setData({
boxImageHeight: res.height,
})
})
}) })
}, },
...@@ -104,8 +101,8 @@ Page({ ...@@ -104,8 +101,8 @@ Page({
// 跳转链接 // 跳转链接
goShareLink(e) { goShareLink(e) {
let {url} = e.currentTarget.dataset let {linkUrl} = this.data.detailInfo
wx.$router.jumpH5(url) wx.$router.jumpH5(linkUrl)
}, },
// 预览图片/视频 // 预览图片/视频
...@@ -118,34 +115,63 @@ Page({ ...@@ -118,34 +115,63 @@ Page({
}) })
}, },
// 分享按钮
shareEvent() {
// 分享类型任务
if (this.data.detailInfo.missonType == 2) {
if (this.data.isloading) return
this.setData({
isloading: true
})
Promise.all([this.copyText(), this.saveWith(), this.reportShareData()]).then(() => {
this.setData({
isloading: false
})
wx.showToast({
title: '图片及视频已保存到手机相册,文案已黏贴到剪切板',
icon: 'none'
})
})
} else {
let item = this.data.detailInfo
wx.$api.showLoading()
ActivityApi.getActivityPosters({id: item.activityId}).then(res => {
this.setData({
sharePopupData: {
posterImg: res,
activityName: item.activityName,
showSharePopup: true
},
})
})
}
},
// 复制文案 // 复制文案
copyText(e) { copyText() {
return new Promise((resolve, reject) => {
let { textContent } = this.data.detailInfo let { textContent } = this.data.detailInfo
wx.setClipboardData({ wx.setClipboardData({
data: textContent, data: textContent,
success (res) { success () {
wx.showToast({ wx.hideLoading()
title: '文案已复制,请黏贴到微信或企微进行转发', resolve()
icon: "none" },
fail () {
this.setData({
isloading: false
}) })
reject('文案复制失败')
} }
}) })
})
}, },
// 复制链接 // 分享埋点
copyUrl(e) { reportShareData() {
let that = this return new Promise((resolve, reject) => {
let { linkUrl, activityName, missonType } = that.data.detailInfo
const userStorage = wx.$storage.get('userInfo')
wx.setClipboardData({
data: `${userStorage.name || ''}邀请你参加${activityName || ""} ${linkUrl}`,
success (res) {
wx.showToast({
title: '活动链接已复制,请打开企微进行转发',
icon: "none"
})
if (missonType == 2) { // 复制触发一次埋点上报
const USERINFO = wx.$storage.get('userInfo') const USERINFO = wx.$storage.get('userInfo')
let { detailInfo } = this.data
let data = { let data = {
action_type: 4, // 事件类型固定为4-分享 action_type: 4, // 事件类型固定为4-分享
item_type: 3, // 商品类型,固定为3-众筹活动 item_type: 3, // 商品类型,固定为3-众筹活动
...@@ -154,22 +180,26 @@ Page({ ...@@ -154,22 +180,26 @@ Page({
business_type: 1, // 业务类型,固定为1 business_type: 1, // 业务类型,固定为1
add_way: 104, // 来源,固定为104 add_way: 104, // 来源,固定为104
create_time: new Date().format("yyyy-MM-dd hh:mm:ss"), // 分享时间 create_time: new Date().format("yyyy-MM-dd hh:mm:ss"), // 分享时间
...that.shareTrackData item_id: detailInfo.activityId
} }
let jsonList = [JSON.stringify(data)] let jsonList = [JSON.stringify(data)]
taskShareReport({jsonList}) taskShareReport({jsonList}).then((res) => {
} if (res) {
resolve()
} else {
this.setData({
isloading: false
})
reject()
} }
}) })
})
}, },
// 一键保存 // 一键保存
saveWith() { saveWith() {
return new Promise((resolve, reject) => {
var that = this var that = this
if (that.data.isloading) return
that.setData({
isloading: true
})
// 获取保存到相册权限 // 获取保存到相册权限
wx.getSetting({ wx.getSetting({
success(res) { success(res) {
...@@ -179,44 +209,38 @@ Page({ ...@@ -179,44 +209,38 @@ Page({
success () { success () {
// 调用保存图片promise队列 // 调用保存图片promise队列
that.queue(that.data.detailInfo.imgUrlList) that.queue(that.data.detailInfo.imgUrlList)
.then(res => { .then(() => {
that.setData({ resolve()
isloading: false
})
wx.showToast({
title: '下载完成'
})
}) })
.catch(err => { .catch(() => {
that.setData({ that.setData({
isloading: false isloading: false
}) })
reject()
}) })
}, },
fail() { fail() {
that.setData({ that.setData({
isloading: false isloading: false
}) })
wx.showToast({ reject()
title: '您拒绝了保存到相册'
})
} }
}) })
} else { } else {
that.queue(that.data.detailInfo.imgUrlList) that.queue(that.data.detailInfo.imgUrlList)
.then(res => { .then(() => {
that.setData({ resolve()
isloading: false
}) })
}) .catch(() => {
.catch(err => {
that.setData({ that.setData({
isloading: false isloading: false
}) })
reject()
}) })
} }
} }
}) })
})
}, },
// 队列 // 队列
...@@ -257,7 +281,7 @@ Page({ ...@@ -257,7 +281,7 @@ Page({
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow(options) { onShow() {
}, },
/** /**
...@@ -291,7 +315,7 @@ Page({ ...@@ -291,7 +315,7 @@ Page({
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage() { // onShareAppMessage() {
} // }
}) })
\ No newline at end of file \ No newline at end of file
/* packageActivity/pages/taskDetail/taskDetail.wxss */ /* packageActivity/pages/taskDetail/taskDetail.wxss */
.layout{
height: 100vh;;
}
.task-detail-box{ .task-detail-box{
padding: 32rpx 24rpx; padding: 32rpx 24rpx;
box-sizing: border-box; box-sizing: border-box;
overflow-y: auto;
.title{ .title{
margin: 0 0 24rpx 16rpx; margin: 0 0 24rpx 16rpx;
font-weight: 600; font-weight: 600;
...@@ -62,7 +66,7 @@ ...@@ -62,7 +66,7 @@
color: #9299AD; color: #9299AD;
.text-message{ .text-message{
view{ view{
word-break: break-all;
} }
.name{ .name{
font-size: 28rpx; font-size: 28rpx;
...@@ -104,6 +108,7 @@ ...@@ -104,6 +108,7 @@
height: 96rpx; height: 96rpx;
margin-right: 24rpx; margin-right: 24rpx;
flex-shrink: 0; flex-shrink: 0;
border-radius: 48rpx;
} }
.message{ .message{
display: flex; display: flex;
...@@ -120,6 +125,7 @@ ...@@ -120,6 +125,7 @@
} }
} }
.activity{ .activity{
word-break: break-all;
.activity-type-tag{ .activity-type-tag{
font-size: 20rpx; font-size: 20rpx;
color: #4466F0; color: #4466F0;
...@@ -135,6 +141,13 @@ ...@@ -135,6 +141,13 @@
} }
.content{ .content{
padding: 40rpx 48rpx; padding: 40rpx 48rpx;
.link-box{
word-break: break-all;
margin-top: 10rpx;
text{
color: #4466F0;
}
}
.img_video{ .img_video{
margin-top: 32rpx; margin-top: 32rpx;
display: flex; display: flex;
...@@ -197,4 +210,11 @@ ...@@ -197,4 +210,11 @@
color: #fff; color: #fff;
} }
} }
.canvas-box {
position: absolute;
left: -9999rpx;
top: -9999rpx;
width: 750rpx;
height: 750rpx;
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
} }
module.exports.indexOf = indexOf module.exports.indexOf = indexOf
</wxs> </wxs>
<view class="task-detail-box"> <view class="task-detail-box layout">
<view class="title">任务</view> <view class="title">任务</view>
<view class="task-box"> <view class="task-box">
<view class="left"> <view class="left">
...@@ -23,18 +23,19 @@ ...@@ -23,18 +23,19 @@
<!-- 分享内容 --> <!-- 分享内容 -->
<view class="title">分享内容</view> <view class="title">分享内容</view>
<view class="share-box" wx:if="{{detailInfo.missonType == 2}}"> <view class="share-box" wx:if="{{detailInfo.missonType == 2}}">
<image class="bg" webp src="{{IMGURL}}taskDetail_bg.png"></image> <image class="bg" style="height: {{boxImageHeight}}px;" webp src="{{IMGURL}}taskDetail_bg.png"></image>
<view class="user-box"> <view class="user-box">
<image webp src="{{userStorage.weChatAvatarUrl ? userStorage.weChatAvatarUrl : IMGURL + 'order_person_default.png'}}"></image> <image webp class="user_image" src="{{userStorage.weChatAvatarUrl ? userStorage.weChatAvatarUrl : IMGURL + 'order_person_default.png'}}"></image>
<view class="message"> <view class="message">
<view class="name">{{userStorage.weChatNickName || userStorage.name || ""}}<text>邀请你参加</text></view> <view class="name">{{userStorage.weChatNickName || userStorage.name || ""}}<text>邀请你参加</text></view>
<view class="activity">{{userStorage.merchantName || ""}}{{detailInfo.activityName || ""}}<text class="activity-type-tag">{{activityTypList[0]}}</text></view> <view class="activity"><text>{{userStorage.merchantName || ""}}{{detailInfo.activityName || ""}}</text><text class="activity-type-tag">{{activityTypList[0]}}</text></view>
</view> </view>
</view> </view>
<view class="content" wx:if="{{!fn.indexOf(materialTypeArr, 4) && detailInfo.platformMerchantMissionMaterialResponseList.length}}"> <view class="content" wx:if="{{detailInfo.platformMerchantMissionMaterialResponseList.length}}">
<view class="text-box"> <view class="text-box">
<mp-html content="{{detailInfo.filterTextContent}}"></mp-html> <mp-html content="{{detailInfo.filterTextContent}}"></mp-html>
</view> </view>
<view class="link-box" wx:if="{{fn.indexOf(materialTypeArr, 4)}}">活动链接:<text bind:tap="goShareLink">{{detailInfo.linkUrl}}</text></view>
<view class="img_video"> <view class="img_video">
<block wx:for="{{detailInfo.imgUrlList}}" wx:key="index"> <block wx:for="{{detailInfo.imgUrlList}}" wx:key="index">
<view wx:if="{{item.type == 'image'}}" class="image-box"> <view wx:if="{{item.type == 'image'}}" class="image-box">
...@@ -49,7 +50,7 @@ ...@@ -49,7 +50,7 @@
</view> </view>
</view> </view>
<!-- 专属链接 --> <!-- 专属链接 -->
<view wx:if="{{detailInfo.missonType != 2 || fn.indexOf(materialTypeArr, 4)}}"> <view wx:if="{{detailInfo.missonType != 2}}">
<view class="copyWriting">将链接转发给好友或发送朋友圈可提高活动曝光度</view> <view class="copyWriting">将链接转发给好友或发送朋友圈可提高活动曝光度</view>
<view class="link-share" bind:tap="goShareLink" data-url="{{detailInfo.linkUrl}}"> <view class="link-share" bind:tap="goShareLink" data-url="{{detailInfo.linkUrl}}">
<image src="{{detailInfo.activityImage ? detailInfo.activityImage : IMGURL+'share_task_default_img.png'}}"></image> <image src="{{detailInfo.activityImage ? detailInfo.activityImage : IMGURL+'share_task_default_img.png'}}"></image>
...@@ -59,14 +60,21 @@ ...@@ -59,14 +60,21 @@
</view> </view>
</view> </view>
</view> </view>
<view class="btn-box"> <!-- <view class="btn-box">
<view class="btn" wx:if="{{fn.indexOf(materialTypeArr, 1)}}" bind:tap="copyText">复制文案</view> <view class="btn" wx:if="{{fn.indexOf(materialTypeArr, 1)}}" bind:tap="copyText">复制文案</view>
<view class="btn" wx:if="{{detailInfo.missonType != 2 || fn.indexOf(materialTypeArr, 4)}}" bind:tap="copyUrl">复制链接</view> <view class="btn" wx:if="{{detailInfo.missonType != 2 || fn.indexOf(materialTypeArr, 4)}}" bind:tap="copyUrl">复制链接</view>
<view class="btn" bind:tap="saveWith" wx:if="{{fn.indexOf(materialTypeArr, 2) || fn.indexOf(materialTypeArr, 3)}}"> <view class="btn" bind:tap="saveWith" wx:if="{{fn.indexOf(materialTypeArr, 2) || fn.indexOf(materialTypeArr, 3)}}">
<text>一键保存{{fn.indexOf(materialTypeArr, 2) ? '图片' : '视频'}}</text> <text>一键保存{{fn.indexOf(materialTypeArr, 2) ? '图片' : '视频'}}</text>
<van-loading wx:if="{{isloading}}" size="30rpx" style="margin-left: 20rpx;" type="spinner" />
</view> </view>
<!-- <view class="btn primary" bind:tap="share">分享</view> -->
<button class="btn primary" wx:if="{{detailInfo.missonType == 2 && !fn.indexOf(materialTypeArr, 4)}}" open-type="share">分享</button> <button class="btn primary" wx:if="{{detailInfo.missonType == 2 && !fn.indexOf(materialTypeArr, 4)}}" open-type="share">分享</button>
</view> -->
<view class="btn-box">
<view class="btn primary" bind:tap="shareEvent">分享<van-loading wx:if="{{isloading}}" size="30rpx" style="margin-left: 20rpx;" type="spinner" /></view>
</view>
<!-- 分享活动弹窗 -->
<share-popup show="{{sharePopupData.showSharePopup}}" data="{{sharePopupData}}"></share-popup>
<view class="canvas-box">
<canvas style="width: 352rpx;height: 352rpx;" canvas-id="mycanvas" />
</view> </view>
</view> </view>
...@@ -42,7 +42,7 @@ Page({ ...@@ -42,7 +42,7 @@ Page({
this.init() this.init()
}, },
async init() { async init(tip) {
try { try {
const { const {
data, data,
...@@ -51,12 +51,15 @@ Page({ ...@@ -51,12 +51,15 @@ Page({
} = await USERAPI.wxCodeLogin() } = await USERAPI.wxCodeLogin()
if (code == '0') { if (code == '0') {
this.loginToken = data this.loginToken = data
if(tip){
wx.$api.showToast(`${tip == 1 ? '登录':'注册'}信息已失效,请重试`)
}
} else this.reLogin(message) } else this.reLogin(message)
wx.hideLoading() wx.hideLoading()
} catch ({ } catch ({
errMsg errMsg
}) { }) {
console.error(errMsg) console.log(errMsg)
this.reLogin(errMsg) this.reLogin(errMsg)
} }
}, },
...@@ -101,15 +104,15 @@ Page({ ...@@ -101,15 +104,15 @@ Page({
mobile: formData.phone, mobile: formData.phone,
code: formData.code code: formData.code
} }
wx.showLoading()
if(this.data.showLoading || this.data.disabled) return; if(this.data.showLoading || this.data.disabled) return;
this.setShowLoading(true)
USERAPI.phoneSmsLogin(obj).then(({ USERAPI.phoneSmsLogin(obj).then(({
code, code,
data, data,
message, message,
errId errId
}) => { }) => {
this.setShowLoading(false) wx.hideLoading()
if (code == '0') { if (code == '0') {
this.checkLoginUserInfo(data) this.checkLoginUserInfo(data)
} else if(errId=='30990103') { } else if(errId=='30990103') {
...@@ -120,7 +123,7 @@ Page({ ...@@ -120,7 +123,7 @@ Page({
wx.$api.showToast(message || '系统异常') wx.$api.showToast(message || '系统异常')
} }
}).catch(err => { }).catch(err => {
this.setShowLoading(false) wx.hideLoading()
wx.$api.showToast('系统异常') wx.$api.showToast('系统异常')
}) })
}, },
...@@ -132,7 +135,7 @@ Page({ ...@@ -132,7 +135,7 @@ Page({
/**多个账号 */ /**多个账号 */
console.log(loginUserInfoList,'loginUserInfoList') console.log(loginUserInfoList,'loginUserInfoList')
if (loginUserInfoList.length > 1) wx.$router.go('/pages/authentication/accountItems/accountItems', { if (loginUserInfoList.length > 1) wx.$router.reLaunch('/pages/authentication/accountItems/accountItems', {
sessionId, sessionId,
...this.options ...this.options
}) })
...@@ -184,8 +187,12 @@ Page({ ...@@ -184,8 +187,12 @@ Page({
// this.setData({ // this.setData({
// smsLoading: false // smsLoading: false
// }) // })
if (code == '0') this.countDown(countDown) if (code == '0') {
else wx.$api.showToast(message || '发送验证码失败') wx.$api.showToast('验证码已发送')
this.countDown(countDown)
}else{
wx.$api.showToast(message || '发送验证码失败')
}
}).catch(err => { }).catch(err => {
// this.setData({ // this.setData({
// smsLoading: false // smsLoading: false
...@@ -220,27 +227,30 @@ Page({ ...@@ -220,27 +227,30 @@ Page({
detail detail
}) { }) {
if (!detail.code || this.data.showLoading) return if (!detail.code || this.data.showLoading) return
this.setShowLoading(true) // this.setShowLoading(true)
wx.showLoading()
USERAPI.authUserPhone(detail, this.loginToken).then(({ USERAPI.authUserPhone(detail, this.loginToken).then(({
code, code,
data, data,
message, message,
errId errId
}) => { }) => {
this.setShowLoading(false) wx.hideLoading()
if (code == '0'){ if (code == '0'){
this.checkLoginUserInfo(data) this.checkLoginUserInfo(data)
}else if(errId=='30990103'){ }else if(errId=='30990103'){
this.setData({ this.setData({
authorized:true authorized:true
}) })
}else if(errId == '200122'){
this.init(1)
}else{ }else{
wx.$api.showToast(message || '系统异常') wx.$api.showToast(message || '系统异常')
} }
}).catch(({ }).catch(({
errMsg errMsg
}) => { }) => {
this.setShowLoading(false) wx.hideLoading()
wx.$api.showToast('系统异常') wx.$api.showToast('系统异常')
}) })
}, },
......
...@@ -22,7 +22,7 @@ Page({ ...@@ -22,7 +22,7 @@ Page({
headerHeight: height, headerHeight: height,
}); });
}, },
async init() { async init(tip) {
try { try {
const { const {
data, data,
...@@ -30,10 +30,10 @@ Page({ ...@@ -30,10 +30,10 @@ Page({
message message
} = await USERAPI.wxCodeLogin() } = await USERAPI.wxCodeLogin()
if (code == '0') { if (code == '0') {
this.setData({
disabled: false
})
this.loginToken = data this.loginToken = data
if(tip){
wx.$api.showToast(`${tip == 1 ? '登录':'注册'}信息已失效,请重试`)
}
} else this.reLogin(message) } else this.reLogin(message)
wx.hideLoading() wx.hideLoading()
} catch ({ } catch ({
...@@ -83,9 +83,12 @@ Page({ ...@@ -83,9 +83,12 @@ Page({
}, },
register(params,detail){ register(params,detail){
USERAPI.register(params).then((res) => { USERAPI.register(params).then((res) => {
console.log(res,'errId')
if (res.code == '0'){ if (res.code == '0'){
this.toLogin(detail) this.toLogin(detail)
}else{ }else if(res.errId == '200122'){
this.init(2)
}else {
wx.$api.showToast(res.message || '系统异常') wx.$api.showToast(res.message || '系统异常')
} }
}) })
...@@ -99,6 +102,8 @@ Page({ ...@@ -99,6 +102,8 @@ Page({
}) => { }) => {
if (code == '0'){ if (code == '0'){
this.checkLoginUserInfo(data) this.checkLoginUserInfo(data)
}else if(errId == '200122'){
this.init(1)
}else{ }else{
wx.$api.showToast(message || '系统异常') wx.$api.showToast(message || '系统异常')
} }
......
...@@ -42,7 +42,7 @@ Page({ ...@@ -42,7 +42,7 @@ Page({
onLoad(options) { onLoad(options) {
this.init() this.init()
}, },
async init() { async init(tip) {
try { try {
const { const {
data, data,
...@@ -51,6 +51,9 @@ Page({ ...@@ -51,6 +51,9 @@ Page({
} = await USERAPI.wxCodeLogin() } = await USERAPI.wxCodeLogin()
if (code == '0') { if (code == '0') {
this.loginToken = data this.loginToken = data
if(tip){
wx.$api.showToast(`${tip == 1 ? '登录':'注册'}信息已失效,请重试`)
}
} else this.reLogin(message) } else this.reLogin(message)
wx.hideLoading() wx.hideLoading()
} catch ({ } catch ({
...@@ -111,6 +114,8 @@ Page({ ...@@ -111,6 +114,8 @@ Page({
USERAPI.register(params).then((res) => { USERAPI.register(params).then((res) => {
if (res.code == '0'){ if (res.code == '0'){
this.toLogin() this.toLogin()
}else if(res.errId == '200122'){
this.init(2)
}else{ }else{
wx.$api.showToast(res.message || '系统异常') wx.$api.showToast(res.message || '系统异常')
} }
...@@ -126,6 +131,8 @@ Page({ ...@@ -126,6 +131,8 @@ Page({
}) => { }) => {
if (code == '0'){ if (code == '0'){
this.checkLoginUserInfo(data) this.checkLoginUserInfo(data)
}else if(errId == '200122'){
this.init(1)
}else{ }else{
wx.$api.showToast(message || '系统异常') wx.$api.showToast(message || '系统异常')
} }
......
...@@ -95,7 +95,7 @@ Component({ ...@@ -95,7 +95,7 @@ Component({
v.forEach(k => { v.forEach(k => {
k.time = (new Date(k.activityTime).getMonth() + 1).toString().padStart(2, "0") + "月" + new Date(k.activityTime).getDate().toString().padStart(2, "0") + "日" k.time = (new Date(k.activityTime).getMonth() + 1).toString().padStart(2, "0") + "月" + new Date(k.activityTime).getDate().toString().padStart(2, "0") + "日"
k.ind = ind k.ind = ind
if (d.getTime() > new Date(`${k.activityTime} 23:59:59`).getTime()) k.status = 2 if (d.getTime() > new Date(`${k.activityTime.replace(/-/g,'/')} 23:59:59`).getTime()) k.status = 2
if (nowDate == k.time) { if (nowDate == k.time) {
val.calenderActiveIndex = index val.calenderActiveIndex = index
this.setData({activeDateIndex : ind}) this.setData({activeDateIndex : ind})
...@@ -140,27 +140,42 @@ Component({ ...@@ -140,27 +140,42 @@ Component({
// 分享活动(复制链接) // 分享活动(复制链接)
copyActivityUrl(e) { copyActivityUrl(e) {
const userStorage = wx.$storage.get('userInfo')
let { item } = e.currentTarget.dataset let { item } = e.currentTarget.dataset
wx.setClipboardData({ let thisPage = wx.$router.getPageInstance()
data: `${userStorage.name || ''}邀请你参加${item.activityName || ""}${item.activityUrl}`, wx.$api.showLoading()
success (res) { ActivityApi.getActivityPosters({id: item.id}).then(res => {
wx.showToast({ // var code= QR.createQrCodeImg(res.activityUrl);
title: '复制成功', // /*code是指图片base64格式数据*/
icon: "none" // //声明文件系统
}) // const fs = wx.getFileSystemManager();
} // //随机定义路径名称
}) // var times = new Date().getTime();
// let { item } = e.currentTarget.dataset // var codeimg = wx.env.USER_DATA_PATH + '/' + times + '.png';
// let qrcodeURL = QR.createQrCodeImg(`${item.activityUrl}`) // //将base64图片写入
// let thisPage = wx.$router.getPageInstance() // fs.writeFile({
// filePath: codeimg,
// data: code.slice(22),
// encoding: 'base64',
// success: () => {
// thisPage.setData({ // thisPage.setData({
// shareData: { // sharePopupData: {
// imagePath: qrcodeURL, // imagePath: codeimg,
// activityName: item.activityName // activityName: res.activityName,
// }, // address: res.activityAddressDetailName,
// posterImg: res.posterImg,
// showSharePopup: true // showSharePopup: true
// },
// }) // })
// }
// });
thisPage.setData({
sharePopupData: {
posterImg: res,
activityName: item.activityName,
showSharePopup: true
},
})
})
}, },
// 活动详情 // 活动详情
goToDetail(e) { goToDetail(e) {
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<block wx:if="{{nothing}}"> <block wx:if="{{nothing}}">
<view class="list-nothing to-bottom"></view> <view class="list-nothing to-bottom"></view>
</block> </block>
<!-- <view class="canvas-box"> <view class="canvas-box">
<canvas type="2d" style="width:352rpx;height:352rpx;background:#fff;" id="mycanvas" /> <canvas style="width: 352rpx;height: 352rpx;" canvas-id="mycanvas" />
</view> --> </view>
</view> </view>
...@@ -44,9 +44,9 @@ Component({ ...@@ -44,9 +44,9 @@ Component({
}, },
// 任务详情 // 任务详情
jump(e) { jump(e) {
let { status, item, activityimg } = e.currentTarget.dataset let { item } = e.currentTarget.dataset
if (status == 2) return // 已完成 if (item.completeStatus == 2) return // 已完成
wx.$router.go('packageActivity.taskDetail', {...item, activityImg: activityimg}) wx.$router.go('packageActivity.taskDetail', {...item})
}, },
// 切换日期查看任务 // 切换日期查看任务
changeDate(e) { changeDate(e) {
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
</view> </view>
</view> </view>
<view class="task-btn"> <view class="task-btn">
<view class="btn {{val.completeStatus == 1 ? 'primary' : ''}}" wx:if="{{fn.timeFilter(data.missionList[activeDateIndex].activityTime) || val.completeStatus == 2}}" bind:tap="jump" data-status="{{val.completeStatus}}" data-item="{{val}}" data-activityimg="{{data.activityImg}}">{{val.completeStatus == 1 ? '去完成' : '已完成'}}</view> <view class="btn {{val.completeStatus == 1 ? 'primary' : ''}}" wx:if="{{fn.timeFilter(data.missionList[activeDateIndex].activityTime, 1) || val.completeStatus == 2 || fn.timeFilter(data.startTime, 2)}}" bind:tap="jump" data-item="{{val}}">{{val.completeStatus == 1 ? '去完成' : '已完成'}}</view>
<view class="btn_title" wx:if="{{val.completeStatus == 2}}">奖励已发放</view> <view class="btn_title" wx:if="{{val.completeStatus == 2}}">奖励已发放</view>
</view> </view>
</view> </view>
......
...@@ -12,9 +12,9 @@ var formatNumber = function (e) { ...@@ -12,9 +12,9 @@ var formatNumber = function (e) {
: e; : e;
} }
var timeFilter = function(e) { var timeFilter = function(e, num) {
console.log(getDate(e).getTime(), getDate().setHours(8, 0, 0, 0)) // num=1 活动已开始 num=2 活动未开始(当前时间小于活动开始时间显示去完成按钮)
return getDate(e).getTime() == getDate().setHours(8, 0, 0, 0); return num == 1 ? getDate(e).getTime() == getDate().setHours(8, 0, 0, 0) : getDate(e).getTime() > getDate().getTime()
} }
module.exports = { module.exports = {
......
...@@ -169,9 +169,17 @@ Page({ ...@@ -169,9 +169,17 @@ Page({
// 滚动中 // 滚动中
scrollIng(e) { scrollIng(e) {
let {type} = e.currentTarget.dataset
if (type == 1) {
this.setData({ this.setData({
translateValue: e.detail.scrollTop / 2.3 > 140 ? 130 : e.detail.scrollTop / 2.3 activeTranslateValue: e.detail.scrollTop / 2.3 > 140 ? 130 : e.detail.scrollTop / 2.3
}) })
} else {
this.setData({
activityEndTranslateValue: e.detail.scrollTop / 2.3 > 140 ? 130 : e.detail.scrollTop / 2.3
})
}
}, },
// 下拉刷新 // 下拉刷新
......
...@@ -21,24 +21,27 @@ ...@@ -21,24 +21,27 @@
</block> </block>
</view> </view>
<!-- 活动中 --> <!-- 活动中 -->
<scroll-view scroll-y class="content" refresher-enabled bindrefresherrefresh="activityRefresh" bindscrolltolower="scrollonReachBottom" bindscroll="scrollIng" binddragend="scrollEnd" data-type="{{1}}" refresher-triggered="{{activeTrigger}}" hidden="{{tabIndex != 0}}"> <scroll-view scroll-y class="content" refresher-enabled bindrefresherrefresh="activityRefresh" bindscrolltolower="scrollonReachBottom" bindscroll="scrollIng" data-type="{{1}}" refresher-triggered="{{activeTrigger}}" hidden="{{tabIndex != 0}}">
<block> <block>
<active-box activeList="{{activeList}}" nothing="{{nothing}}" activeDateIndex="{{activeDateIndex}}"></active-box> <active-box activeList="{{activeList}}" nothing="{{nothing}}" activeDateIndex="{{activeDateIndex}}"></active-box>
</block> </block>
</scroll-view> </scroll-view>
<!-- 活动诊断 --> <!-- 活动诊断 -->
<scroll-view scroll-y class="content" refresher-enabled bindrefresherrefresh="activityRefresh" bindscrolltolower="scrollonReachBottom" data-type="{{2}}" refresher-triggered="{{activeTrigger}}" hidden="{{tabIndex != 1}}"> <scroll-view scroll-y class="content" refresher-enabled bindrefresherrefresh="activityRefresh" bindscrolltolower="scrollonReachBottom" data-type="{{2}}" refresher-triggered="{{activeTrigger}}" bindscroll="scrollIng" hidden="{{tabIndex != 1}}">
<block> <block>
<activity-diagnosis activityList="{{activityEndList}}" nothing="{{nothing}}"></activity-diagnosis> <activity-diagnosis activityList="{{activityEndList}}" nothing="{{nothing}}"></activity-diagnosis>
</block> </block>
</scroll-view> </scroll-view>
<!-- 申请活动 --> <!-- 申请活动 -->
<view class="add-activity" style="transform: translateX({{translateValue}}rpx);transition: all {{translateValue >= 130 ? 0.3 : 0}}s;" bind:tap="applyActivity"> <view class="add-activity" style="transform: translateX({{tabIndex == 0 ? activeTranslateValue : activityEndTranslateValue}}rpx);transition: all {{tabIndex == 0 ? (activeTranslateValue >= 130 ? 0.3 : 0) : (activityEndTranslateValue >= 130 ? 0.3 : 0)}}s;" bind:tap="applyActivity">
<image webp src="{{IMGURL}}application_activity.png"></image> <image webp src="{{IMGURL}}application_activity.png"></image>
</view> </view>
<!-- 预约安装弹窗 --> <!-- 预约安装弹窗 -->
<install-popup show="{{showPopup}}" data="{{installItem}}" bind:hidePopup="hidePopup"></install-popup> <install-popup show="{{showPopup}}" data="{{installItem}}" bind:hidePopup="hidePopup"></install-popup>
<!-- 分享活动弹窗 --> <!-- 分享活动弹窗 -->
<!-- <share-popup show="{{showSharePopup}}" data="{{shareData}}"></share-popup> --> <share-popup data="{{sharePopupData}}"></share-popup>
<!-- <van-popup show="{{ showSharePopup }}" round bind:close="onClose">
<image style="width: 352rpx; height: 352rpx;" src="{{imagePath}}"></image>
</van-popup> -->
</view> </view>
</block> </block>
...@@ -16,7 +16,7 @@ class Draw { ...@@ -16,7 +16,7 @@ class Draw {
type: '2d', type: '2d',
width, width,
height, height,
compInst:isCompInst compInst: isCompInst
}), }),
ctx = canvas.getContext('2d') ctx = canvas.getContext('2d')
this[_canvas_] = canvas this[_canvas_] = canvas
...@@ -58,6 +58,7 @@ class Draw { ...@@ -58,6 +58,7 @@ class Draw {
} }
let image = this[_canvas_].createImage() let image = this[_canvas_].createImage()
image.src = `${url}?v=${Date.now()}` image.src = `${url}?v=${Date.now()}`
console.log(image.src)
return new Promise(resolve => { return new Promise(resolve => {
image.onload = () => { image.onload = () => {
this[_ctx_].drawImage(image, x, y, width, height) this[_ctx_].drawImage(image, x, y, width, height)
...@@ -65,6 +66,14 @@ class Draw { ...@@ -65,6 +66,14 @@ class Draw {
if (callback) callback() if (callback) callback()
resolve(imageParams) resolve(imageParams)
} }
image.onerror = err => {
console.log(image.src)
wx.hideLoading()
wx.showToast({
title: '图片加载失败',
icon: 'error'
})
}
}) })
} }
toRpx(val) { toRpx(val) {
...@@ -133,44 +142,10 @@ class Draw { ...@@ -133,44 +142,10 @@ class Draw {
this[_ctx_].globalAlpha = opacity this[_ctx_].globalAlpha = opacity
this[_ctx_].font = `${fontWeight || 400} ${fontSize}px${font}` this[_ctx_].font = `${fontWeight || 400} ${fontSize}px${font}`
this[_ctx_].fillStyle = color || '#000' this[_ctx_].fillStyle = color || '#000'
this[_ctx_].strokeStyle = color || '#000'
this[_ctx_].textBaseline = textBaseline this[_ctx_].textBaseline = textBaseline
this[_ctx_].textAlign = textAlign this[_ctx_].textAlign = textAlign
this[_ctx_].lineWidth = this.toRpx(2) this[_ctx_].lineWidth = this.toRpx(2)
let text_width = this.getTextWidth(text) let text_width = this.getTextWidth(text)
if (textParams.border) {
let boxX = this.toRpx(textParams.x - 4.5),
boxY = this.toRpx(textParams.y - 0.5),
boxWidth = text_width + this.toRpx(9),
boxHeight = lineHeight + this.toRpx(4)
if (boxWidth > width - fontX - this.getTextWidth('…') - fontSize) {
boxWidth = width - boxX + this.toRpx(9)
}
this.drawFill({
x: boxX,
y: boxY,
width: boxWidth,
height: boxHeight,
color: textParams.border
})
}
if (textParams.background) {
let boxX = this.toRpx(textParams.x - 4),
boxY = this.toRpx(textParams.y),
boxWidth = text_width + this.toRpx(8),
boxHeight = lineHeight + this.toRpx(3)
if (boxWidth > width - fontX - this.getTextWidth('…') - fontSize) {
boxWidth = width - boxX + this.toRpx(8)
}
this.drawFill({
x: boxX,
y: boxY,
width: boxWidth,
height: boxHeight,
color: textParams.background
})
}
const drawOneLineText = () => { const drawOneLineText = () => {
let textArr = text.toString().split(''), let textArr = text.toString().split(''),
newText = '', newText = '',
...@@ -249,11 +224,112 @@ class Draw { ...@@ -249,11 +224,112 @@ class Draw {
drawOneLineText() drawOneLineText()
} }
} else drawOneLineText() } else drawOneLineText()
if (textParams.border) this.drawBorder({
text,
x: textParams.x,
y: textParams.y,
fontSize: textParams.fontSize || 12,
...textParams.border
})
this[_ctx_].stroke()
}
drawBorder(params) {
let {
x,
y,
text,
color,
width,
radius,
opacity,
padding,
fontSize
} = params,
paddingX = 0,
paddingY = 0
if (padding && padding.length) {
paddingX = this.toRpx(padding[0])
paddingY = this.toRpx(padding[0])
if (padding.length > 1) paddingX = this.toRpx(padding[1])
}
let startX = this.toRpx(x) - paddingX,
endX = this.toRpx(x) + this.getTextWidth(text) + paddingX,
startY = this.toRpx(y) - paddingY,
endY = this.toRpx(y + fontSize) + paddingY / 2,
arr = [{
x: startX,
y: startY,
width: endX
},
{
x: endX,
y: startY,
height: endY
},
{
x: startX,
y: endY,
width: endX
},
{
x: startX,
y: startY,
height: endY
}
]
console.log(this.toRpx(y) , paddingY)
this[_ctx_].beginPath()
this[_ctx_].globalAlpha = typeof opacity === 'number' ? opacity : 1
this[_ctx_].lineWidth = width || this.toRpx(1)
if (radius) {
radius = this.toRpx(radius)
let arcArr = [{
moveTo: [startX, startY + radius],
arcTo: [startX, startY, startX + radius, startY],
}, {
moveTo: [endX - radius, startY],
arcTo: [endX, startY, endX, startY + radius],
},
{
moveTo: [startX, endY - radius],
arcTo: [startX, endY, startX + radius, endY],
},
{
moveTo: [endX, endY - radius],
arcTo: [endX, endY, endX - radius, endY],
}
]
arr.map((e,index) =>{
if(index == 0 || index == 2) {
e.x += radius
e.width -= radius
} else{
e.y += radius
e.height -= radius
}
})
arcArr.map((e, index) => {
this[_ctx_].moveTo(...e.moveTo)
this[_ctx_].arcTo(...e.arcTo, radius)
this[_ctx_].stroke() this[_ctx_].stroke()
this[_ctx_].restore()
this[_ctx_].save()
})
}
arr.map((e, index) => {
this[_ctx_].moveTo(e.x, e.y)
this[_ctx_].lineTo(e.width ? e.width : e.x, e.height ? e.height : e.y)
this[_ctx_].stroke()
this[_ctx_].restore()
this[_ctx_].strokeStyle = color || '#000'
this[_ctx_].save()
})
} }
drawLine(lineParams, callback) { drawLine(lineParams, callback) {
this[_ctx_].beginPath() this[_ctx_].beginPath()
let { let {
noTransition,
opacity, opacity,
startX, startX,
startY, startY,
...@@ -262,18 +338,20 @@ class Draw { ...@@ -262,18 +338,20 @@ class Draw {
endX, endX,
endY endY
} = lineParams } = lineParams
if (!noTransition) {
startX = this.toRpx(startX) startX = this.toRpx(startX)
startY = this.toRpx(startY) startY = this.toRpx(startY)
width = this.toRpx(width) width = this.toRpx(width)
endX = this.toRpx(endX) endX = this.toRpx(endX)
endY = this.toRpx(endY) endY = this.toRpx(endY)
}
this[_ctx_].globalAlpha = typeof opacity === 'number' ? opacity : 1 this[_ctx_].globalAlpha = typeof opacity === 'number' ? opacity : 1
this[_ctx_].strokeStyle = color || '#000'
this[_ctx_].lineWidth = width || this.toRpx(1) this[_ctx_].lineWidth = width || this.toRpx(1)
this[_ctx_].moveTo(startX, startY) this[_ctx_].moveTo(startX, startY)
this[_ctx_].lineTo(endX, endY) this[_ctx_].lineTo(endX, endY)
this[_ctx_].stroke() this[_ctx_].stroke()
this[_ctx_].restore() this[_ctx_].restore()
this[_ctx_].strokeStyle = color || '#000'
this[_ctx_].save() this[_ctx_].save()
if (callback) callback() if (callback) callback()
} }
...@@ -411,7 +489,7 @@ class Draw { ...@@ -411,7 +489,7 @@ class Draw {
if (index == data.imageList.length - 1) drawFun() if (index == data.imageList.length - 1) drawFun()
} }
else drawFun() else drawFun()
} } else drawFun()
}) })
} }
} }
......
...@@ -1588,6 +1588,7 @@ var createImgTag = function(width, height, getPixel, alt) { ...@@ -1588,6 +1588,7 @@ var createImgTag = function(width, height, getPixel, alt) {
// returns qrcode function. // returns qrcode function.
var createQrCodeImg = function(text, options) { var createQrCodeImg = function(text, options) {
console.log(text, '1212121')
options = options || {}; options = options || {};
var typeNumber = options.typeNumber || 4; var typeNumber = options.typeNumber || 4;
var errorCorrectLevel = options.errorCorrectLevel || 'M'; var errorCorrectLevel = options.errorCorrectLevel || 'M';
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!