Commit 3ba6ca09 by zhangquan

Merge branch 'v3.0' into zq_dev_3.0

2 parents fec7ae10 3d932f03
...@@ -6,14 +6,14 @@ class ActivityApi { ...@@ -6,14 +6,14 @@ class ActivityApi {
return api.post({ return api.post({
method: `scrm.api.assistant.activity.page`, method: `scrm.api.assistant.activity.page`,
...data ...data
}) }, false, true)
} }
// 获取活动中任务内容 // 获取活动中任务内容
getActiveTaskList(data) { getActiveTaskList(data) {
return api.post({ return api.post({
method: `stoassistant.api.mission.findStaffMissionList`, method: `stoassistant.api.mission.findStaffMissionList`,
...data ...data
}) }, false, true)
} }
// 获取单个任务详情内容 // 获取单个任务详情内容
getActiveTaskDetail(data) { getActiveTaskDetail(data) {
...@@ -35,12 +35,19 @@ class ActivityApi { ...@@ -35,12 +35,19 @@ class ActivityApi {
return api.post({ return api.post({
method: `${path}.service.activity.detail.old`, method: `${path}.service.activity.detail.old`,
...data ...data
}, false, true)
}
// 获取申请活动已开通场景
getOpenSceneList(data) {
return api.post({
method: 'scrm.api.busassistant.activity.SceneOpenStatus.stoAss',
...data
}) })
} }
// 申请活动 // 获取申请活动可开通的产品
applyActivity(data) { getNotOpenProductsList(data) {
return api.post({ return api.post({
method: `${path}.service.activity.apply`, method: 'scrm.api.busassistant.activity.productOpenStatus.stoAss',
...data ...data
}) })
} }
...@@ -66,12 +73,6 @@ class ActivityApi { ...@@ -66,12 +73,6 @@ class ActivityApi {
...data ...data
}) })
} }
getOpenSceneList(data) {
return api.post({
method: 'scrm.api.busassistant.activity.SceneOpenStatus.stoAss',
...data
})
}
} }
export default ActivityApi export default ActivityApi
\ No newline at end of file \ No newline at end of file
...@@ -51,5 +51,12 @@ module.exports = { ...@@ -51,5 +51,12 @@ module.exports = {
operationDate: new Date().format('yyyy-MM-dd hh:mm:ss'), operationDate: new Date().format('yyyy-MM-dd hh:mm:ss'),
}) })
},
// 任务分享埋点
taskShareReport(data) {
return api.post({
method: 'entmicro.api.customercollect.reportCustomerList',
...data
})
} }
} }
/* packageActivity/pages/shareTaskDetail/shareTaskDetail.wxss */ /* packageActivity/pages/shareTaskDetail/shareTaskDetail.wxss */
.share-box{ .share-box{
background: #FFFFFF;
box-shadow: 0 8rpx 24rpx 0 rgba(106,126,204,0.12); box-shadow: 0 8rpx 24rpx 0 rgba(106,126,204,0.12);
position: relative; position: relative;
margin-bottom: 30rpx;
.bg{ .bg{
width: 100%; width: 100%;
height: 176rpx; height: 176rpx;
...@@ -104,7 +104,16 @@ ...@@ -104,7 +104,16 @@
} }
.type-text{ .type-text{
font-size: 24rpx; font-size: 24rpx;
color: #9299AD; color: #9299AD;
margin-top: 10rpx;
} }
} }
}
.copyWriting{
margin-left: 20rpx;
font-weight: 400;
font-size: 24rpx;
color: #7A8299;
line-height: 40rpx;
margin-bottom: 24rpx;
} }
\ No newline at end of file \ No newline at end of file
...@@ -5,16 +5,7 @@ ...@@ -5,16 +5,7 @@
} }
module.exports.indexOf = indexOf module.exports.indexOf = indexOf
</wxs> </wxs>
<view wx:if="{{fn.indexOf(materialTypeArr, 4)}}"> <view class="share-box">
<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" wx:if="{{!fn.indexOf(materialTypeArr, 4)}}">
<image class="bg" webp src="{{IMGURL}}taskDetail_bg.png"></image> <image class="bg" webp src="{{IMGURL}}taskDetail_bg.png"></image>
<view class="user-box"> <view class="user-box">
<image webp src="{{detailInfo.weChatAvatarUrl ? detailInfo.weChatAvatarUrl : IMGURL + 'order_person_default.png'}}"></image> <image webp src="{{detailInfo.weChatAvatarUrl ? detailInfo.weChatAvatarUrl : IMGURL + 'order_person_default.png'}}"></image>
...@@ -23,7 +14,7 @@ ...@@ -23,7 +14,7 @@
<view class="activity">{{detailInfo.merchantName || ""}}{{detailInfo.activityName || ""}}<text>{{activityTypList[0]}}</text></view> <view class="activity">{{detailInfo.merchantName || ""}}{{detailInfo.activityName || ""}}<text>{{activityTypList[0]}}</text></view>
</view> </view>
</view> </view>
<view class="content"> <view class="content" wx:if="{{!fn.indexOf(materialTypeArr, 4)}}">
<view class="text-box"> <view class="text-box">
<text>{{detailInfo.textContent}}</text> <text>{{detailInfo.textContent}}</text>
</view> </view>
...@@ -40,3 +31,13 @@ ...@@ -40,3 +31,13 @@
</view> </view>
</view> </view>
</view> </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>
// packageActivity/pages/taskDetail/taskDetail.js // packageActivity/pages/taskDetail/taskDetail.js
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 {
domain
} from '~/utils/request/http'
Page({ Page({
/** /**
...@@ -35,13 +38,34 @@ Page({ ...@@ -35,13 +38,34 @@ Page({
}) })
}, },
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)}&isExclusive=1&exclusiveUuid=${userStorage.uuid}&shareStaffType=2&sharedTime=${Date.now()}`
},
toUnicode (chineseStr = '') {
let unicodeStr = ''
for (let i = 0, iLength = chineseStr.length; i < iLength; i++) {
unicodeStr += '@' + chineseStr.charCodeAt(i).toString(16)
}
return unicodeStr
},
// 获取任务详情 // 获取任务详情
getActiveTaskDetail(missionId) { getActiveTaskDetail(missionId) {
ActivityApi.getActiveTaskDetail({missionId: missionId}).then(res => { ActivityApi.getActiveTaskDetail({missionId: missionId}).then(res => {
res.imgUrlList = [] res.imgUrlList = []
// missonType 任务类型1注册 2分享 3浏览 4访客 5下单
if (res.missonType != 2) { // 非分享任务 显示活动专属链接
res.linkUrl = this.filterJumpUrl(res.activityId)
wx.hideShareMenu({
menus: ['shareAppMessage'],
})
}
let typeArr = [] let typeArr = []
res.platformMerchantMissionMaterialResponseList && res.platformMerchantMissionMaterialResponseList.forEach(val => { res.platformMerchantMissionMaterialResponseList && res.platformMerchantMissionMaterialResponseList.forEach(val => {
typeArr.push(val.materialType) typeArr.push(val.materialType)
// materialType 素材类型1文案 2图片 3视频 4专属链接
if (val.materialType == 1) { // 文案 if (val.materialType == 1) { // 文案
res.textContent = val.materialContent res.textContent = val.materialContent
} }
...@@ -55,6 +79,8 @@ Page({ ...@@ -55,6 +79,8 @@ Page({
res.linkUrl = val.materialContent res.linkUrl = val.materialContent
} }
}) })
// 分享埋点上报
this.shareTrackData = { item_id: res.activityId }
this.setData({ this.setData({
detailInfo: res, detailInfo: res,
materialTypeArr: typeArr materialTypeArr: typeArr
...@@ -103,9 +129,10 @@ Page({ ...@@ -103,9 +129,10 @@ Page({
// 复制链接 // 复制链接
copyUrl(e) { copyUrl(e) {
let { linkUrl } = this.data.detailInfo let { linkUrl, activityName } = this.data.detailInfo
const userStorage = wx.$storage.get('userInfo')
wx.setClipboardData({ wx.setClipboardData({
data: linkUrl, data: `${userStorage.name || ''}邀请你参加${activityName || ""} ${linkUrl}`,
success (res) { success (res) {
wx.showToast({ wx.showToast({
title: '活动链接已复制,请打开企微进行转发', title: '活动链接已复制,请打开企微进行转发',
......
...@@ -36,12 +36,12 @@ ...@@ -36,12 +36,12 @@
.type-text{ .type-text{
font-size: 24rpx; font-size: 24rpx;
color: #9299AD; color: #9299AD;
margin-top: 10rpx;
} }
} }
} }
.task-box{ .task-box{
width: 100%; width: 100%;
height: 72px;
background: #FFFFFF; background: #FFFFFF;
border-radius: 10px; border-radius: 10px;
padding: 32rpx; padding: 32rpx;
...@@ -50,12 +50,13 @@ ...@@ -50,12 +50,13 @@
margin-bottom: 40rpx; margin-bottom: 40rpx;
justify-content: space-between; justify-content: space-between;
image{ image{
flex-shrink: 0;
width: 80rpx; width: 80rpx;
height: 80rpx; height: 80rpx;
margin-right: 20rpx; margin-right: 20rpx;
} }
.left{ .left{
flex: 0 0 75%; flex: 0 0 70%;
display: flex; display: flex;
font-size: 22rpx; font-size: 22rpx;
color: #9299AD; color: #9299AD;
...@@ -88,6 +89,7 @@ ...@@ -88,6 +89,7 @@
box-shadow: 0 8rpx 24rpx 0 rgba(106,126,204,0.12); box-shadow: 0 8rpx 24rpx 0 rgba(106,126,204,0.12);
border-radius: 32rpx; border-radius: 32rpx;
position: relative; position: relative;
margin-bottom: 30rpx;
.bg{ .bg{
width: 100%; width: 100%;
height: 176rpx; height: 176rpx;
......
...@@ -20,18 +20,9 @@ ...@@ -20,18 +20,9 @@
<view>+{{detailInfo.gainScore}}积分</view> <view>+{{detailInfo.gainScore}}积分</view>
</view> </view>
</view> </view>
<!-- 分享内容 -->
<view class="title">分享内容</view> <view class="title">分享内容</view>
<view wx:if="{{fn.indexOf(materialTypeArr, 4)}}"> <view class="share-box" wx:if="{{detailInfo.missonType == 2}}">
<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" wx:if="{{!fn.indexOf(materialTypeArr, 4)}}">
<image class="bg" webp src="{{IMGURL}}taskDetail_bg.png"></image> <image class="bg" 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 src="{{userStorage.weChatAvatarUrl ? userStorage.weChatAvatarUrl : IMGURL + 'order_person_default.png'}}"></image>
...@@ -40,7 +31,7 @@ ...@@ -40,7 +31,7 @@
<view class="activity">{{userStorage.merchantName || ""}}{{detailInfo.activityName || ""}}<text>{{activityTypList[0]}}</text></view> <view class="activity">{{userStorage.merchantName || ""}}{{detailInfo.activityName || ""}}<text>{{activityTypList[0]}}</text></view>
</view> </view>
</view> </view>
<view class="content" wx:if="{{detailInfo.platformMerchantMissionMaterialResponseList.length}}"> <view class="content" wx:if="{{!fn.indexOf(materialTypeArr, 4)}}">
<view class="text-box"> <view class="text-box">
<text>{{detailInfo.textContent}}</text> <text>{{detailInfo.textContent}}</text>
</view> </view>
...@@ -57,14 +48,25 @@ ...@@ -57,14 +48,25 @@
</view> </view>
</view> </view>
</view> </view>
<!-- 专属链接 -->
<view wx:if="{{detailInfo.missonType != 2 || 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="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="{{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>一键保存图片</text> <text>一键保存图片</text>
<van-loading wx:if="{{isloading}}" size="30rpx" style="margin-left: 20rpx;" type="spinner" /> <van-loading wx:if="{{isloading}}" size="30rpx" style="margin-left: 20rpx;" type="spinner" />
</view> </view>
<!-- <view class="btn primary" bind:tap="share">分享</view> --> <!-- <view class="btn primary" bind:tap="share">分享</view> -->
<button class="btn primary" open-type="share">分享</button> <button class="btn primary" wx:if="{{detailInfo.missonType == 2}}" open-type="share">分享</button>
</view> </view>
</view> </view>
// packageActivity/pages/visitor/visitor.js // packageActivity/pages/visitor/visitor.js
import ActivityApi from '~/api/activityApi/index' import ActivityApi from '~/api/activityApi/index'
import index_const from "~/pages/tab/index/index_const" import index_const from "~/pages/tab/index/index_const"
import { commentTime } from '~/utils/format'
Page({ Page({
/** /**
...@@ -20,12 +21,13 @@ Page({ ...@@ -20,12 +21,13 @@ Page({
}, },
onRoute(options) { onRoute(options) {
console.log(options)
let activityId = options.id let activityId = options.id
console.log(activityId)
ActivityApi.getActivityVisitorList({ ActivityApi.getActivityVisitorList({
activityId activityId
}).then(res => { }).then(res => {
res.visitorList && res.visitorList.forEach(val => {
val.lastVisitFormatTime = commentTime(val.lastVisitDate)
})
this.setData({ this.setData({
allNum: res.visitorTotal, allNum: res.visitorTotal,
todayNum: res.todayTotal, todayNum: res.todayTotal,
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</view> </view>
<view class="footprint"> <view class="footprint">
<text>浏览 {{item.visitCount}} 次</text> <text>浏览 {{item.visitCount}} 次</text>
<text>{{item.lastVisitTime}} 访问过</text> <text>{{item.lastVisitFormatTime}} 访问过</text>
</view> </view>
</view> </view>
</view> </view>
......
...@@ -9,10 +9,12 @@ Page({ ...@@ -9,10 +9,12 @@ Page({
}, },
toSumbitData() { toSumbitData() {
let { sumbitScore,withdrawalScore } = this.data let { sumbitScore,withdrawalScore } = this.data
let isString = typeof sumbitScore == 'string'
if (!sumbitScore) return wx.$api.showToast('请输入有效的积分值') if (!sumbitScore) return wx.$api.showToast('请输入有效的积分值')
if (sumbitScore == 0) return wx.$api.showToast('请输入有效的积分值') if (sumbitScore == 0) return wx.$api.showToast('请输入有效的积分值')
if(isString&&sumbitScore.indexOf('.')==(sumbitScore.length-1)) return wx.$api.showToast('请输入有效的积分值')
if(sumbitScore<0.3) return wx.$api.showToast('至少提现0.3') if(sumbitScore<0.3) return wx.$api.showToast('至少提现0.3')
if(Number(sumbitScore)>Number(withdrawalScore)) return wx.$api.showToast('请输入有效的积分值') if(Number(sumbitScore)>Number(withdrawalScore)) return wx.$api.showToast(`当前可提现最大积分为${Number(withdrawalScore)}`)
Dialog.confirm({ Dialog.confirm({
title: '提示', title: '提示',
message: `请确认是否将${sumbitScore}积分进行提现`, message: `请确认是否将${sumbitScore}积分进行提现`,
......
...@@ -51,6 +51,7 @@ page { ...@@ -51,6 +51,7 @@ page {
box-sizing: border-box; box-sizing: border-box;
padding: 8rpx 0; padding: 8rpx 0;
margin-top: 32rpx; margin-top: 32rpx;
line-height: 60rpx;
.input-placeholder { .input-placeholder {
font-weight: 400; font-weight: 400;
...@@ -61,9 +62,10 @@ page { ...@@ -61,9 +62,10 @@ page {
.intClass { .intClass {
width: calc(100% - 174rpx); width: calc(100% - 174rpx);
font-weight: 400; font-weight: 400;
font-size: 24rpx; font-size: 60rpx;
color: #333; color: #333;
caret-color:#556AF5; caret-color:#556AF5;
height: 62rpx;
} }
.btn { .btn {
......
...@@ -20,6 +20,12 @@ Component({ ...@@ -20,6 +20,12 @@ Component({
}, },
nothing: { nothing: {
type: Boolean type: Boolean
},
activeDateIndex: {
type: Number
},
allTaskCount: {
type: Number
} }
}, },
...@@ -61,17 +67,18 @@ Component({ ...@@ -61,17 +67,18 @@ Component({
val.newtaskCalenderList = this.calenderFilter(JSON.parse(JSON.stringify(val.missionList)) || [], 7) val.newtaskCalenderList = this.calenderFilter(JSON.parse(JSON.stringify(val.missionList)) || [], 7)
let d = new Date() let d = new Date()
let nowDate = (d.getMonth() + 1).toString().padStart(2, "0") + "月" + d.getDate().toString().padStart(2, "0") + "日" let nowDate = (d.getMonth() + 1).toString().padStart(2, "0") + "月" + d.getDate().toString().padStart(2, "0") + "日"
let ind = 0 let ind = 0 // 下标值
let allTaskCount = 0 // 任务总数
val.calenderActiveIndex = 0
val.newtaskCalenderList.forEach((v, index) => { val.newtaskCalenderList.forEach((v, index) => {
v.forEach(k => { v.forEach(k => {
allTaskCount+=k.platformMerchantMissionResponseList.length
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} 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})
} else {
val.calenderActiveIndex = 0
} }
ind++ ind++
}) })
...@@ -79,10 +86,29 @@ Component({ ...@@ -79,10 +86,29 @@ Component({
val.isCollapse = false val.isCollapse = false
let itemVal = 'activeList['+idx+']' let itemVal = 'activeList['+idx+']'
this.setData({ this.setData({
[itemVal]: val [itemVal]: val,
allTaskCount
})
})
} else if (flag && val.missionList) { // 已请求数据 展开默认选中当天
val.newtaskCalenderList = this.calenderFilter(JSON.parse(JSON.stringify(val.missionList)) || [], 7)
let d = new Date()
let nowDate = (d.getMonth() + 1).toString().padStart(2, "0") + "月" + d.getDate().toString().padStart(2, "0") + "日"
let ind = 0 // 下标值
val.calenderActiveIndex = 0
val.newtaskCalenderList.forEach((v, index) => {
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.ind = ind
if (d.getTime() > new Date(`${k.activityTime} 23:59:59`).getTime()) k.status = 2
if (nowDate == k.time) {
val.calenderActiveIndex = index
this.setData({activeDateIndex : ind})
}
ind++
}) })
console.log(itemVal)
}) })
val.isCollapse = false
} else { } else {
val.isCollapse = !flag val.isCollapse = !flag
} }
...@@ -112,16 +138,17 @@ Component({ ...@@ -112,16 +138,17 @@ Component({
return unicodeStr return unicodeStr
}, },
filterJumpUrl(id, num) { filterJumpUrl(item) {
const userStorage = wx.$storage.get('userInfo') const userStorage = wx.$storage.get('userInfo')
return num == 2 ? `${domain}/scrm-wx-merchant-activity/#/?id=${id}&merchantId=${userStorage.merchantId}&shareStaffUuid=${userStorage.uuid}&shareStaffName=${this.toUnicode(userStorage.name)}&shareStaffType=2&sharedTime=${Date.now()}` : `${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=${item.id}&merchantId=${userStorage.merchantId}&shareStaffUuid=${userStorage.uuid}&shareStaffName=${this.toUnicode(userStorage.name)}&isExclusive=1&exclusiveUuid=${userStorage.uuid}&shareStaffType=2&sharedTime=${Date.now()}`
}, },
// 分享活动(复制链接) // 分享活动(复制链接)
copyActivityUrl(e) { copyActivityUrl(e) {
let { id } = e.currentTarget.dataset const userStorage = wx.$storage.get('userInfo')
let { item } = e.currentTarget.dataset
wx.setClipboardData({ wx.setClipboardData({
data: this.filterJumpUrl(id, 1), data: `${userStorage.name || ''}邀请你参加${item.activityName || ""}${item.activityUrl}`,
success (res) { success (res) {
wx.showToast({ wx.showToast({
title: '复制成功', title: '复制成功',
...@@ -132,9 +159,8 @@ Component({ ...@@ -132,9 +159,8 @@ Component({
}, },
// 活动详情 // 活动详情
goToDetail(e) { goToDetail(e) {
let { id } = e.currentTarget.dataset let { item } = e.currentTarget.dataset
let h5Url = this.filterJumpUrl(id, 2) let h5Url = this.filterJumpUrl(item)
console.log(h5Url)
wx.$router.jumpH5(h5Url) wx.$router.jumpH5(h5Url)
}, },
// 活动战报 // 活动战报
......
...@@ -9,20 +9,20 @@ ...@@ -9,20 +9,20 @@
<!-- 活动top信息 --> <!-- 活动top信息 -->
<activity-top data="{{item}}" widthStyle="flex: 0 0 62%;"> <activity-top data="{{item}}" widthStyle="flex: 0 0 62%;">
<image webp src="{{IMGURL}}hot-icon.png?v={{img_version}}"></image> <image webp src="{{IMGURL}}hot-icon.png?v={{img_version}}"></image>
<view class="hot">火爆进行中</view> <text class="hot">火爆进行中</text>
</activity-top> </activity-top>
<!-- 活动操作按钮 --> <!-- 活动操作按钮 -->
<view class="active-btn"> <view class="active-btn">
<view class="btn" bind:tap="jump" data-item="{{item}}">活动战报</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" bind:tap="copyActivityUrl" data-item="{{item}}">分享活动</view>
<view class="btn primary" bind:tap="goToDetail" data-id="{{item.id}}">查看详情</view> <view class="btn primary" bind:tap="goToDetail" data-item="{{item}}">查看详情</view>
</view> </view>
<!-- 活动概览 --> <!-- 活动概览 -->
<activity-overview data="{{item}}" activityOverviewList="{{activityOverviewList}}" backStyle="{{backStyle}}" textType="{{1}}"></activity-overview> <activity-overview data="{{item}}" activityOverviewList="{{activityOverviewList}}" backStyle="{{backStyle}}" textType="{{1}}"></activity-overview>
<!-- 任务日历 --> <!-- 任务日历 -->
<view class="task-box {{item.isCollapse ? 'hidden' : ''}}"> <view class="task-box {{item.isCollapse ? 'hidden' : ''}}">
<view class="box-content"> <view class="box-content">
<activity-calender data="{{item}}" activeDateIndex="{{activeDateIndex}}" isCollapse="{{item.isCollapse}}"></activity-calender> <activity-calender data="{{item}}" activeDateIndex="{{activeDateIndex}}" allTaskCount="{{allTaskCount}}" isCollapse="{{item.isCollapse}}"></activity-calender>
</view> </view>
</view> </view>
<!-- 展开/收起 --> <!-- 展开/收起 -->
......
...@@ -22,8 +22,10 @@ Component({ ...@@ -22,8 +22,10 @@ Component({
}, },
// 默认选中日期(今天) // 默认选中日期(今天)
activeDateIndex: { activeDateIndex: {
type: Number, type: Number
value: 0 },
allTaskCount: {
type: Number
} }
}, },
......
...@@ -38,6 +38,9 @@ ...@@ -38,6 +38,9 @@
color: #1B233D; color: #1B233D;
} }
} }
.active{
background-image: linear-gradient(180deg, #FFF7DB 15%, #FFF1E0 87%);
}
.completed{ .completed{
background-image: linear-gradient(180deg, #FFD84B 28%, #FFB33E 76%); background-image: linear-gradient(180deg, #FFD84B 28%, #FFB33E 76%);
.task-time{ .task-time{
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
<wxs src="../index.wxs" module="fn"></wxs> <wxs src="../index.wxs" module="fn"></wxs>
<block wx:if="{{!isCollapse}}"> <block wx:if="{{!isCollapse}}">
<view class="title">任务日历<text> · {{data.missionList.length}}</text></view> <view class="title">任务日历<text> · {{allTaskCount}}</text></view>
<view wx:if="{{data.newtaskCalenderList.length}}" class="calender-box {{data.newtaskCalenderList.length > 1 ? 'p-b-54' : ''}}"> <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}}"> <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"> <block wx:for="{{data.newtaskCalenderList}}" wx:for-item="val" wx:for-index="k" wx:key="k">
<swiper-item class='swiper_item'> <swiper-item class='swiper_item'>
<block wx:for="{{val}}" wx:for-item="v" wx:for-index="j" wx:key="j"> <block wx:for="{{val}}" wx:for-item="v" wx:for-index="j" wx:key="j">
<view class="time-box {{v.status == 2 ? 'completed' : ''}}" bind:tap="changeDate" data-dateindex="{{v.ind}}"> <view class="time-box {{v.status == 2 ? 'completed' : (activeDateIndex == v.ind ? 'active' : '')}}" bind:tap="changeDate" data-dateindex="{{v.ind}}">
<image webp src="{{IMGURL}}{{v.status == 2 ? 'task_completed.png' : 'calender_integral_icon.png'}}"></image> <image webp src="{{IMGURL}}{{v.status == 2 ? 'task_completed.png' : 'calender_integral_icon.png'}}"></image>
<view class="task-time">{{v.status == 2 ? '已完成' : v.time}}</view> <view class="task-time">{{v.status == 2 ? '已完成' : v.time}}</view>
</view> </view>
...@@ -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' : ''}}" 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) || val.completeStatus == 2}}" 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 class="btn_title" wx:if="{{val.completeStatus == 2}}">奖励已发放</view>
</view> </view>
</view> </view>
......
...@@ -19,6 +19,12 @@ Component({ ...@@ -19,6 +19,12 @@ Component({
}, },
nothing: { nothing: {
type: Boolean type: Boolean
},
isShow: {
type: Boolean,
observer(val) {
console.log(val)
}
} }
}, },
...@@ -85,15 +91,15 @@ Component({ ...@@ -85,15 +91,15 @@ Component({
return unicodeStr return unicodeStr
}, },
filterJumpUrl(id) { filterJumpUrl(item) {
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)}&shareStaffType=2&sharedTime=${Date.now()}` return `${domain}/scrm-wx-merchant-activity/#/?id=${item.id}&merchantId=${userStorage.merchantId}&shareStaffUuid=${userStorage.uuid}&shareStaffName=${this.toUnicode(userStorage.name)}&isExclusive=1&exclusiveUuid=${userStorage.uuid}&shareStaffType=2&sharedTime=${Date.now()}`
}, },
// 活动详情 // 活动详情
goToDetail(e) { goToDetail(e) {
let { id } = e.currentTarget.dataset let { item } = e.currentTarget.dataset
let h5Url = this.filterJumpUrl(id) let h5Url = this.filterJumpUrl(item)
console.log(h5Url) console.log(h5Url)
wx.$router.jumpH5(h5Url) wx.$router.jumpH5(h5Url)
}, },
......
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
</view> </view>
<view class="item-box" wx:if="{{imageLoaded}}"> <view class="item-box" wx:if="{{imageLoaded}}">
<!-- 活动top信息 --> <!-- 活动top信息 -->
<activity-top data="{{item}}" widthStyle="flex: 0 0 72%;"> <activity-top data="{{item}}" widthStyle="flex: 0 0 72%;" isShow="{{isShow}}">
<image webp src="{{IMGURL}}activity_end_icon.png?v={{img_version}}"></image> <image webp src="{{IMGURL}}activity_end_icon.png?v={{img_version}}"></image>
<view class="end">已结束</view> <text class="end">已结束</text>
</activity-top> </activity-top>
<!-- 活动操作按钮 --> <!-- 活动操作按钮 -->
<view class="active-btn"> <view class="active-btn">
<view class="btn" bind:tap="jump" data-item="{{item}}">活动战报</view> <view class="btn" bind:tap="jump" data-item="{{item}}">活动战报</view>
<view class="btn primary" bind:tap="goToDetail" data-id="{{item.id}}">查看详情</view> <view class="btn primary" bind:tap="goToDetail" data-item="{{item}}">查看详情</view>
</view> </view>
<!-- 活动概览 --> <!-- 活动概览 -->
<activity-overview data="{{item}}" backStyle="{{backStyle}}" textType="{{2}}"></activity-overview> <activity-overview data="{{item}}" backStyle="{{backStyle}}" textType="{{2}}"></activity-overview>
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<view class="title">累计收益</view> <view class="title">累计收益</view>
<view class="sort">最终排名:{{item.statics.incomeRank || "-"}}</view> <view class="sort">最终排名:{{item.statics.incomeRank || "-"}}</view>
</view> </view>
<view class="integral-num">{{fn.filterIntegral(item.statics.income)}}<text>积分</text></view> <view class="integral-num">{{fn.filterIntegral(item.statics.income || 0)}}<text>积分</text></view>
</view> </view>
<!-- 转化分析 --> <!-- 转化分析 -->
<view class="invert-box {{item.isCollapse ? 'hidden' : ''}}"> <view class="invert-box {{item.isCollapse ? 'hidden' : ''}}">
......
...@@ -4,6 +4,7 @@ Component({ ...@@ -4,6 +4,7 @@ Component({
/** /**
* 组件的属性列表 * 组件的属性列表
*/ */
properties: { properties: {
data: { data: {
type: Object, type: Object,
...@@ -11,15 +12,16 @@ Component({ ...@@ -11,15 +12,16 @@ Component({
}, },
widthStyle: { widthStyle: {
type: String type: String
} }
}, },
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
activityTypList: index_const.data.activityTypList, activityTypList: index_const.data.activityTypList,
activityTypeStyle: 'margin-top: 8rpx;height: 44rpx;line-height: 44rpx;',
}, },
/** /**
* 组件的方法列表 * 组件的方法列表
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
.active-img{ .active-img{
position: relative; position: relative;
width: 160rpx; width: 160rpx;
height: 120rpx; height: 160rpx;
margin-right: 24rpx; margin-right: 24rpx;
.thum-icon{ .thum-icon{
width: 100%; width: 100%;
...@@ -35,17 +35,25 @@ ...@@ -35,17 +35,25 @@
justify-content: space-between; justify-content: space-between;
padding: 8rpx 0; padding: 8rpx 0;
.name{ .name{
display: flex; // display: flex;
align-items: center; // align-items: center;
.left{ .name-left{
font-weight: 600; font-weight: 600;
font-size: 36rpx; font-size: 36rpx;
color: #1B233D; color: #1B233D;
line-height: 48rpx; line-height: 48rpx;
white-space: nowrap; word-break: break-all;
text-overflow: ellipsis; .activity-type{
overflow: hidden; float: right;
word-break: break-all; line-height: 44rpx;
font-size: 28rpx;
color: #FE5662;
image{
margin-top: 4rpx;
width: 32rpx;
height: 32rpx;
}
}
} }
.right{ .right{
display: flex; display: flex;
......
...@@ -9,8 +9,9 @@ ...@@ -9,8 +9,9 @@
</view> </view>
<view class="active-title"> <view class="active-title">
<view class="name"> <view class="name">
<view class="left" style="{{widthStyle}}">{{data.activityName}}</view> <!-- <view class="left" style="{{widthStyle}}">{{data.activityName}}</view> -->
<view class="right"> <view class="name-left" style="{{activityNameStyle}}">{{data.activityName}}<view wx:if="{{data.titleIsWarp}}" class="activity-type"><slot></slot></view></view>
<view wx:if="{{!data.titleIsWarp}}" class="right" style="{{activityTypeStyle}}">
<slot></slot> <slot></slot>
</view> </view>
</view> </view>
......
...@@ -11,8 +11,14 @@ var formatNumber = function (e) { ...@@ -11,8 +11,14 @@ var formatNumber = function (e) {
? (e / 1000).toFixed(1) + "k" ? (e / 1000).toFixed(1) + "k"
: e; : e;
} }
var timeFilter = function(e) {
return getDate(e) > getDate().setHours(0, 0, 0, 0);
}
module.exports = { module.exports = {
filterIntegral: filterIntegral, filterIntegral: filterIntegral,
mathABS: mathABS, mathABS: mathABS,
formatNumber: formatNumber formatNumber: formatNumber,
timeFilter: timeFilter
} }
\ No newline at end of file \ No newline at end of file
...@@ -18,7 +18,8 @@ Page({ ...@@ -18,7 +18,8 @@ Page({
], ],
tabIndex: 0, tabIndex: 0,
activeList: [], activeList: [],
activityEndList: [] activityEndList: [],
allTaskCount: 0
}, },
onPageScroll({ onPageScroll({
...@@ -56,6 +57,14 @@ Page({ ...@@ -56,6 +57,14 @@ Page({
this.getActivityList(2, onPullDown) this.getActivityList(2, onPullDown)
}, },
// 计算文本宽度
getTextWidth(text, font, bold) {
var canvas = wx.createOffscreenCanvas({ type: '2d', width: 300, height: 300 })
var context = canvas.getContext('2d')
context.font = context.font = `${bold} ${font}px PingFangSC-Semibold`
var metrics = context.measureText(text)
return metrics.width
},
getActivityList(num, onPullDown) { getActivityList(num, onPullDown) {
let {activePageNum, pageSize, pageNum, activeList, activityEndList, tabIndex} = this.data let {activePageNum, pageSize, pageNum, activeList, activityEndList, tabIndex} = this.data
ActivityApi.getActivityList({ ActivityApi.getActivityList({
...@@ -63,12 +72,14 @@ Page({ ...@@ -63,12 +72,14 @@ Page({
pageNum: num == 1 ? activePageNum : pageNum, pageNum: num == 1 ? activePageNum : pageNum,
pageSize pageSize
}).then(res => { }).then(res => {
res.data && res.data.forEach((val, index) => { let activityTitleViewWidth = wx.getSystemInfoSync().windowWidth - 139 // 活动title区域宽度
res.list && res.list.forEach((val, index) => {
val.isCollapse = true val.isCollapse = true
val.startTime = val.startTime.split(' ')[0] val.startTime = val.startTime.split(' ')[0]
val.endTime = val.endTime.split(' ')[0] val.endTime = val.endTime.split(' ')[0]
val.tabIndex = num - 1 val.tabIndex = num - 1
if (num == 1 && activePageNum == 1 && index == 0) { // 活动中默认展开第一条 val.titleIsWarp = this.getTextWidth(val.activityName, '18', 600) > activityTitleViewWidth
if (num == 1 && activePageNum == 1 && index == 0) { // 活动中默认展开第一条 数据处理
val.isloading = true val.isloading = true
ActivityApi.getActiveTaskList({activityId: val.id}).then(res => { ActivityApi.getActiveTaskList({activityId: val.id}).then(res => {
val.isloading = false val.isloading = false
...@@ -77,16 +88,17 @@ Page({ ...@@ -77,16 +88,17 @@ Page({
let d = new Date() let d = new Date()
let nowDate = (d.getMonth() + 1).toString().padStart(2, "0") + "月" + d.getDate().toString().padStart(2, "0") + "日" let nowDate = (d.getMonth() + 1).toString().padStart(2, "0") + "月" + d.getDate().toString().padStart(2, "0") + "日"
let ind = 0 let ind = 0
val.calenderActiveIndex = 0
let allTaskCount = 0
val.newtaskCalenderList.forEach((v, index) => { val.newtaskCalenderList.forEach((v, index) => {
v.forEach(k => { v.forEach(k => {
allTaskCount += k.platformMerchantMissionResponseList.length
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} 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})
} else {
val.calenderActiveIndex = 0
} }
ind++ ind++
}) })
...@@ -94,7 +106,8 @@ Page({ ...@@ -94,7 +106,8 @@ Page({
val.isCollapse = false val.isCollapse = false
let itemVal = 'activeList['+index+']' let itemVal = 'activeList['+index+']'
this.setData({ this.setData({
[itemVal]: val [itemVal]: val,
allTaskCount
}) })
}) })
} }
...@@ -117,13 +130,13 @@ Page({ ...@@ -117,13 +130,13 @@ Page({
}) })
if (num == 1) { if (num == 1) {
this.setData({ this.setData({
activeList: onPullDown ? res.data : [...activeList, ...res.data], activeList: onPullDown ? res.list : [...activeList, ...res.list],
activeTotal: res.count activeTotal: res.total
}) })
} else { } else {
this.setData({ this.setData({
activityEndList: onPullDown ? res.data : [...activityEndList, ...res.data], activityEndList: onPullDown ? res.list : [...activityEndList, ...res.list],
total: res.count total: res.total
}) })
} }
}) })
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<!-- 活动中 --> <!-- 活动中 -->
<view class="active-content" hidden="{{tabIndex != 0}}"> <view class="active-content" hidden="{{tabIndex != 0}}">
<block> <block>
<active-box activeList="{{activeList}}" nothing="{{nothing}}"></active-box> <active-box activeList="{{activeList}}" nothing="{{nothing}}" activeDateIndex="{{activeDateIndex}}" allTaskCount="{{allTaskCount}}"></active-box>
</block> </block>
</view> </view>
<!-- 活动诊断 --> <!-- 活动诊断 -->
......
...@@ -96,4 +96,7 @@ ...@@ -96,4 +96,7 @@
} }
.marleft158{
margin-left: 158rpx;
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -32,15 +32,17 @@ ...@@ -32,15 +32,17 @@
</view> </view>
<view class="logout flex_cc" bind:tap="toLogout">退出登录</view> <view class="logout flex_cc" bind:tap="toLogout">退出登录</view>
</view> </view>
<view class="store_widget flex_cc"> <view class="store_widget {{user.seriseName?'flex_cc':'flex_sc marleft158'}}">
<view class="flex_sc label"> <block wx:if="{{user.seriseName}}">
<image class="icon" src="{{IMGURL}}merchant_icon.png" /> <view class="flex_sc label">
<view class="tip">{{user.seriseName}}</view> <image class="icon" src="{{IMGURL}}merchant_icon.png" />
</view> <view class="tip">{{user.seriseName}}</view>
<view class="line"></view> </view>
<view class="line"></view>
</block>
<view class="flex_sc label"> <view class="flex_sc label">
<image class="icon" src="{{IMGURL}}shop_icon.png" /> <image class="icon" src="{{IMGURL}}shop_icon.png" />
<view class="tip">{{strSubstr.getString(user.merchantName,10)}}</view> <view class="tip">{{strSubstr.getString(user.merchantName,user.seriseName?10:20)}}</view>
</view> </view>
</view> </view>
</view> </view>
\ No newline at end of file \ No newline at end of file
...@@ -85,7 +85,7 @@ Page({ ...@@ -85,7 +85,7 @@ Page({
merchantName: userStorage.merchantName, merchantName: userStorage.merchantName,
phone: userStorage.phone, phone: userStorage.phone,
} }
const { id, staffPhone, phone, department, weChatNickName, weChatAvatarUrl, weChatOpenId, staffName,merchantFileResponse } = data const { id, staffPhone, phone, department, weChatNickName, weChatAvatarUrl,weChatPhone, weChatOpenId, staffName,merchantFileResponse } = data
let avatar = '' let avatar = ''
if(merchantFileResponse){ if(merchantFileResponse){
avatar = merchantFileResponse.fileUrl avatar = merchantFileResponse.fileUrl
...@@ -94,7 +94,7 @@ Page({ ...@@ -94,7 +94,7 @@ Page({
headImgUrl: avatar || weChatAvatarUrl, headImgUrl: avatar || weChatAvatarUrl,
nickName: staffName, nickName: staffName,
seriseName: DEPARTMENTLIST[department - 1], seriseName: DEPARTMENTLIST[department - 1],
brandName: weChatNickName || phone || staffPhone, brandName: weChatNickName || weChatPhone || staffPhone,
bindStatus: weChatOpenId ? 1 : 0, bindStatus: weChatOpenId ? 1 : 0,
bussinessId: id, bussinessId: id,
...storage ...storage
......
...@@ -8,15 +8,16 @@ import { ...@@ -8,15 +8,16 @@ import {
import { import {
getSessionId getSessionId
} from '~/utils/cache/storageApi' } from '~/utils/cache/storageApi'
let requestTimes = 0
/**接口 */ /**接口 */
class Request { class Request {
get(params, returnAll = false) { get(params, returnAll = false, isShowLoading = false) {
return this.request('GET', params, returnAll) return this.request('GET', params, returnAll, isShowLoading)
} }
post(params, returnAll = false) { post(params, returnAll = false, isShowLoading = false) {
return this.request('POST', params, returnAll) return this.request('POST', params, returnAll, isShowLoading)
} }
request(RequestMethods, params, returnAll) { request(RequestMethods, params, returnAll, isShowLoading) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wx.showNavigationBarLoading() wx.showNavigationBarLoading()
let header = let header =
...@@ -29,6 +30,12 @@ class Request { ...@@ -29,6 +30,12 @@ class Request {
if (!projectName) projectName = this.getRopProject(params.method) if (!projectName) projectName = this.getRopProject(params.method)
const path = pathEnum[projectName] const path = pathEnum[projectName]
params = this.getData(params) params = this.getData(params)
requestTimes++
if (isShowLoading) {
wx.showLoading({
title: '加载中'
})
}
wx.request({ wx.request({
url: `${domain}${path}router?method=${params.method}`, url: `${domain}${path}router?method=${params.method}`,
data: params, data: params,
...@@ -77,6 +84,8 @@ class Request { ...@@ -77,6 +84,8 @@ class Request {
reject(error) reject(error)
}, },
complete() { complete() {
requestTimes--;
if (requestTimes == 0) wx.hideLoading();
wx.stopPullDownRefresh() wx.stopPullDownRefresh()
wx.hideNavigationBarLoading() wx.hideNavigationBarLoading()
} }
......
...@@ -9,133 +9,113 @@ ...@@ -9,133 +9,113 @@
* @param {*} onViewTrack 开启浏览埋点 * @param {*} onViewTrack 开启浏览埋点
* @returns * @returns
*/ */
import { import {
reportData taskShareReport
} from '~/api/api.js' } from '~/api/api.js'
import USERAPI from '~/api/usersApi/index' // import USERAPI from '~/api/usersApi/index'
class Share { class Share {
constructor() { constructor() {
console.log('---------------- 分享初始化 ----------------') console.log('---------------- 分享初始化 ----------------')
this.initPageProxy() this.initPageProxy()
} }
/**全局注册事件 */ /**全局注册事件 */
initPageProxy() { initPageProxy() {
let thisPage = Page let thisPage = Page
let _this = this let _this = this
Page = function (el) { Page = function (el) {
try { try {
el || (el = {}), _this.pageLeaveProxy(el), thisPage.apply(this, arguments) el || (el = {}), _this.pageLeaveProxy(el), thisPage.apply(this, arguments)
} catch (el) { } catch (el) {
thisPage.apply(this, arguments) thisPage.apply(this, arguments)
}
} }
} }
}
/**设置全局分享 */ /**设置全局分享 */
pageLeaveProxy(page) { pageLeaveProxy(page) {
const onLoad = page.onLoad, const onLoad = page.onLoad,
that = this that = this
if (page.onShareAppMessage) { if (page.onShareAppMessage) {
const that = this const that = this
page.onShareAppMessage = function () { page.onShareAppMessage = function () {
let { let {
shareTitle, shareTitle,
sharePath, sharePath,
shareImage, shareImage,
shareQuery, shareQuery,
noPageAuth, noPageAuth,
shareFun, shareFun,
shareTrackData shareTrackData
} = this, } = this,
path = `/${this.route}` path = `/${this.route}`
if (sharePath) path = `/${sharePath}` if (sharePath) path = `/${sharePath}`
path += that.setCommonShareQuery() // path += that.setCommonShareQuery()
if (shareQuery) path += `&${shareQuery}` if (shareQuery) path += `?${shareQuery}`
console.log('===============', path)
if (!noPageAuth) path = `/login/loading/loading?url=${encodeURIComponent(path)}` if (!noPageAuth) path = `/login/loading/loading?url=${encodeURIComponent(path)}`
if (shareFun) shareFun() if (shareFun) shareFun()
if (shareTrackData) that.reportShareData(shareTrackData) if (shareTrackData) that.reportShareData(shareTrackData)
return { console.log('::', path)
path, return {
title: shareTitle, path,
imageUrl: shareImage title: shareTitle,
} imageUrl: shareImage
}
}
if (page.onShareTimeline) {
page.onShareTimeline = function () {
let {
shareTitle,
shareImage,
shareQuery,
shareFun,
shareTrackData
} = this
if (shareFun) shareFun()
if (shareTrackData) that.reportShareData(shareTrackData)
shareQuery = that.setCommonShareQuery(shareQuery)
console.log(shareQuery)
return {
query: shareQuery,
title: shareTitle,
imageUrl: shareImage
}
} }
} }
page.onLoad = async function () { }
onLoad && onLoad.apply(this, arguments) if (page.onShareTimeline) {
if (this.onViewTrack) { page.onShareTimeline = function () {
const WXUSERINFO = await USERAPI.getWXUserInfo(), let {
{ shareTitle,
USERINFO shareImage,
} = that.getCommonData(), shareQuery,
shareInfo = this.options shareFun,
if (shareInfo.shareOpenId) reportData({ shareTrackData
openId: WXUSERINFO.openId || '', } = this
unionId: WXUSERINFO.unionId || '', if (shareFun) shareFun()
nickName: WXUSERINFO.nickName || '', // if (shareTrackData) that.reportShareData(shareTrackData)
avatar: WXUSERINFO.avatarUrl || '', // shareQuery = that.setCommonShareQuery(shareQuery)
phone: WXUSERINFO.phone || USERINFO.phone || '', console.log(shareQuery)
...shareInfo return {
}, 1) query: shareQuery,
title: shareTitle,
imageUrl: shareImage
} }
} }
} }
getCommonData() {
const WXUSERINFO = wx.$storage.get('wx_user_info'), }
USERINFO = wx.$storage.get('userInfo') getCommonData() {
return { const USERINFO = wx.$storage.get('userInfo')
WXUSERINFO, return {
USERINFO USERINFO
}
} }
setCommonShareQuery(query) { }
const { setCommonShareQuery(query) {
WXUSERINFO, const {
USERINFO WXUSERINFO,
} = this.getCommonData(), USERINFO
} = this.getCommonData()
query = `${query? `?${query}&`:'?'}merchantId=${USERINFO.merchantId}&shareOpenId=${WXUSERINFO.openId}`
if (USERINFO.phone) query += `&sharePhone=${USERINFO.phone}`
return query
}
reportShareData(shareTrackData) {
const {
USERINFO
} = this.getCommonData(),
thisPage = wx.$router.getPageInstance() thisPage = wx.$router.getPageInstance()
query = `${query? `?${query}&`:'?'}merchantId=${thisPage.merchantId ||USERINFO.merchantId}&shareOpenId=${thisPage.shareOpenId || WXUSERINFO.openId}&sharePhone=${thisPage.sharePhone || USERINFO.phone}` let data = {
return query action_type: 4, // 事件类型固定为4-分享
} item_type: 3, // 商品类型,固定为3-众筹活动
reportShareData(shareTrackData) { merchant_id: USERINFO.merchantId, // 门店号
const { staff_uuid: USERINFO.uuid,
WXUSERINFO, business_type: 1, // 业务类型,固定为1
USERINFO add_way: 104, // 来源,固定为104
} = this.getCommonData(), create_time: new Date().format("yyyy-MM-dd hh:mm:ss"), // 分享时间
thisPage = wx.$router.getPageInstance().options ...shareTrackData
reportData({
openId: WXUSERINFO.openId || '',
unionId: WXUSERINFO.unionId || '',
nickName: WXUSERINFO.nickName || '',
avatar: WXUSERINFO.avatarUrl || '',
phone: USERINFO.phone || '',
merchantId: thisPage.merchantId || USERINFO.merchantId || '',
shareOpenId: thisPage.shareOpenId || WXUSERINFO.openId || '',
sharePhone: thisPage.sharePhone || USERINFO.phone || '',
...shareTrackData
})
} }
let jsonList = JSON.stringify(data)
taskShareReport({jsonList})
}
} }
new Share() new Share()
\ No newline at end of file \ No newline at end of file
...@@ -113,11 +113,24 @@ const getImgVersion = () => { ...@@ -113,11 +113,24 @@ const getImgVersion = () => {
return commonApi.getImgVersion() return commonApi.getImgVersion()
} }
/**获取节点信息
* name(id获取class)
* callBack 回调函数
* isComponents是否在组件
*/
const getViewInfo = (name, callBack, isComponents) => {
const query = !isComponents ? wx.createSelectorQuery() : wx.createSelectorQuery().in(isComponents)
query.select(name).boundingClientRect(res => {
callBack(res)
}).exec()
}
const Util = { const Util = {
getImgVersion, getImgVersion,
onReachBottom, onReachBottom,
isFullSucreen, isFullSucreen,
clearObjNull, clearObjNull,
throttle throttle,
getViewInfo
} }
export default Util export default Util
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!