Authored by bevishuang

fix

... ... @@ -45,7 +45,7 @@ App({
// yas 注册成功后上报
event.on('yas-user-register-success', params => {
accountModel.recordRegisterSource({
storeId: 1, // 线下店ID写死1
storeId: config.storeId, // 线下店ID写死1
fromPage: params.TRIGGER_PAGE_NAME
});
yas.report('YB_REGISTER_SUCCESS', params);
... ...
... ... @@ -144,7 +144,7 @@ const api = {
miniapp_version: config.apiParams.miniapp_version,
storeId: config.storeId,
udid: udid.get(),
business_line: 'miniappOffshop'
business_line: config.business_line
}, params);
},
get(params) {
... ...
... ... @@ -27,8 +27,8 @@ const config = {
unionType: '100000000011678', // 渠道号
MINI_APP_DOMAIN: 'miniapp.yohobuy.com',
appid: 'wx668c1fe6f44f24c4', // 业务中使用、与package.config.json内appid保持一致
business_line: 'miniappOffshop', // 业务线
storeId: '94', // 线下店ID
business_line: 'miniappOffshopMkt', // 业务线
storeId: '11', // 线下店ID
miniapp_type: '67'
};
... ...
... ... @@ -14,7 +14,7 @@ export default class yas {
dm: '', // 设备型号
res: '', // 屏幕大小
osv: '', // 系统版本
ak: 'yohostore_mp',
ak: 'yohostoremkt_mp',
ch: this.app.globalData.unionType,
udid: this.app.globalData.udid
};
... ...
... ... @@ -38,7 +38,7 @@ Component({
*/
getVerifyImage: function() {
let timestamp = Date.parse(new Date());
let url = `${config.domains.api}/passport/img-check?business_line=miniappOffshop&app_version=0.0.1&udid=${udid.get()}&client_type=${config.apiParams.client_type}&fromPage=${config.apiParams.client_type}&t=${timestamp}`; // eslint-disable-line
let url = `${config.domains.api}/passport/img-check?business_line=${config.business_line}&app_version=0.0.1&udid=${udid.get()}&client_type=${config.apiParams.client_type}&fromPage=${config.apiParams.client_type}&t=${timestamp}`; // eslint-disable-line
return url;
},
... ...
... ... @@ -36,7 +36,6 @@ Component({
}else{
this.data.src = this.formatImageUrl(this.data.src, 750, 300, this.data.mode);
}
this.setData({
src: this.data.src,
style: `width: ${width}`
... ...
... ... @@ -23,7 +23,7 @@ Component({
wx.getSystemInfo({
success: function(res) {
let windowWidth = res.screenWidth;
windowWidth = floorData.is_extend == 1 ? windowWidth : windowWidth - 30;
windowWidth = floorData.is_extend === 1 ? windowWidth : windowWidth - 30;
let realHeight = Math.ceil(windowWidth * height / width);
let style = `margin: 0 ${floorData.is_extend == 1 ? 0 : 15}px; height:${realHeight}px`;
that.setData({
... ...
... ... @@ -2,15 +2,15 @@ import wx from '../../utils/wx';
import helper from '../../utils/helper';
import event from '../../common/event';
import {
getUserLocation,
getAuthorization
getUserLocation,
getAuthorization
} from '../../common/login';
import gominiapp from '../../router/jump-to-miniapp.js';
import accountModel from '../../models/account/index';
import fissionModel from '../../models/activity/fission/index';
import Yas from '../../common/yas';
import {
stringify
stringify
} from '../../vendors/query-stringify';
import config from '../../common/config'
... ... @@ -21,755 +21,766 @@ let yas;
let runCoupon = false;
Page({
data: {
hasLocationSetting: false,
showMsg: false,
messageTitle: '请确保打开手机定位,并允许微信获取您的位置信息',
isShow: false, // 底部弹层
isBaseShow: false, // 领取基础优惠券成功弹层
isCanvasShow: false, // 分享朋友圈图片
closeStatus: false,
runCoupon: false, // 标识当前是否正在领取优惠券操作
isClickCoupon: false, // 标识是单击领取优惠券且未登录情况
snapWidth: 530 * scale,
snapHeight: 930 * scale,
canvasImg: '', // 生成的图片连接
detail: {},
stepData: {},
couponData: {},
notLogin: false, // 默认未登录
},
onLoad: function(options) {
// 禁止分享
wx.hideShareMenu();
if (options.scene) {
this.setData({
closeStatus: true
});
data: {
hasLocationSetting: false,
showMsg: false,
messageTitle: '请确保打开手机定位,并允许微信获取您的位置信息',
isShow: false, // 底部弹层
isBaseShow: false, // 领取基础优惠券成功弹层
isCanvasShow: false, // 分享朋友圈图片
closeStatus: false,
runCoupon: false, // 标识当前是否正在领取优惠券操作
isClickCoupon: false, // 标识是单击领取优惠券且未登录情况
snapWidth: 530 * scale,
snapHeight: 930 * scale,
canvasImg: '', // 生成的图片连接
detail: {},
stepData: {},
couponData: {},
notLogin: false, // 默认未登录
},
onLoad: function(options) {
// 禁止分享
wx.hideShareMenu();
if (options.scene) {
this.setData({
closeStatus: true
});
accountModel.getMiniAppRealParam(decodeURIComponent(options.scene || '')).then(res => {
return wx.redirectTo({
url: `/pages/activity/fission?${stringify(res)}`,
});
});
} else {
event.on('user-login-success', this.initTap.bind(this));
accountModel.getMiniAppRealParam(decodeURIComponent(options.scene || '')).then(res => {
return wx.redirectTo({
url: `/pages/activity/fission?${stringify(res)}`,
});
});
} else {
event.on('user-login-success', this.initTap.bind(this));
this.setData({
options
});
this.setData({
options
});
yas = new Yas(app); // 实例化埋点
yas && yas.pageOpenReport(); // 进入页面后 上报
}
wx.getSetting().then(res => {
this.setData({
hasLocationSetting: res.authSetting['scope.userLocation'] || false
});
});
},
onShow() {
this.initTap().then(res => {
if (this.data.closeStatus) {
return global.router.go('fissionClose', {eventStatus: this.data.detail.eventStatus});
}
this.friendDraw();
return res;
yas = new Yas(app); // 实例化埋点
yas && yas.pageOpenReport(); // 进入页面后 上报
}
wx.getSetting().then(res => {
this.setData({
hasLocationSetting: res.authSetting['scope.userLocation'] || false
});
});
},
onShow() {
this.initTap().then(res => {
if (this.data.closeStatus) {
return global.router.go('fissionClose', {
eventStatus: this.data.detail.eventStatus
});
},
onShareAppMessage: function(res) {
let params = {
FROM: res.from,
SHARE_RESULT: 0,
// TITLE: '“送”你一双激罕球鞋!快凭本事来“捉”',
TITLE: this.data.detail.shareContentCaption,
imageUrl: helper.imgView(this.data.detail.banner, 940, 750, 1),
PATH: `/pages/activity/fission?id=${this.data.options.id}&shareType=1`
};
}
return {
title: params.TITLE, // 分享标题
imageUrl: params.imageUrl,
path: params.PATH,
success: () => {
this.addEventShare();
yas.report('YB_SHARE_TYPE', {
SHARE_NUM: 1,
PAGE_PARAM: stringify(this.data.options),
PAGE_PATH: '/pages/activity/fission'
});
}
};
},
openMsg: function() {
let {hadGetCoupon} = this.data.couponData;
if (hadGetCoupon == 1) { //已领券,不可点击
return;
this.friendDraw();
return res;
});
},
onShareAppMessage: function(res) {
let params = {
FROM: res.from,
SHARE_RESULT: 0,
// TITLE: '“送”你一双激罕球鞋!快凭本事来“捉”',
TITLE: this.data.detail.shareContentCaption,
imageUrl: helper.imgView(this.data.detail.banner, 940, 750, 1),
PATH: `/pages/activity/fission?id=${this.data.options.id}&shareType=1`
};
return {
title: params.TITLE, // 分享标题
imageUrl: params.imageUrl,
path: params.PATH,
success: () => {
this.addEventShare();
yas.report('YB_SHARE_TYPE', {
SHARE_NUM: 1,
PAGE_PARAM: stringify(this.data.options),
PAGE_PATH: '/pages/activity/fission'
});
}
this.setData({
showMsg: true
};
},
openMsg: function() {
let {
hadGetCoupon
} = this.data.couponData;
if (hadGetCoupon == 1) { //已领券,不可点击
return;
}
this.setData({
showMsg: true
});
},
/**
* 修改设置之后的回调
*/
onSettingComplete: function(e) {
console.log(e.detail);
this.setData({
hasLocationSetting: e.detail.hasLocationSetting
});
},
_showToast: function(res) {
if (res.message) {
return wx.showToast({
icon: 'none',
title: res.message || '',
duration: 3000
});
},
/**
* 修改设置之后的回调
*/
onSettingComplete: function(e) {
console.log(e.detail);
}
return res;
},
_showModel: function(res) {
if (res.message) {
return wx.showModal({
icon: 'none',
content: res.message || '',
confirmText: '知道了',
showCancel: false,
duration: 3000
});
}
return res;
},
addEventShare: function() {
return fissionModel.addEventShare({
eventId: this.data.options.id
}).then(res => {
if (res.code === 200 && res.data.executeStatus === 1) {
let detail = this.data.detail;
detail.whetherJoinedShare = 1;
this.setData({
hasLocationSetting: e.detail.hasLocationSetting
detail,
});
},
_showToast: function(res) {
if (res.message) {
return wx.showToast({
icon: 'none',
title: res.message || '',
duration: 3000
});
}
return res;
},
_showModel: function(res) {
if (res.message) {
return wx.showModal({
icon: 'none',
content: res.message || '',
confirmText: '知道了',
showCancel: false,
duration: 3000
});
}
this._getStep(detail);
return res;
},
addEventShare: function() {
return fissionModel.addEventShare({
eventId: this.data.options.id
}).then(res => {
if (res.code === 200 && res.data.executeStatus === 1) {
let detail = this.data.detail;
detail.whetherJoinedShare = 1;
this.setData({
detail,
});
this._getStep(detail);
return res;
}
return this._showToast(res);
});
},
_getStep: function(detail) {
let stepData = {
isExpire: false, // 活动结束标识
disable: false, // 底部按钮样式
isShare: false, // 是否分享
couponsData: {}, // 待领取的优惠券(基础或分享券)
name: '' // 底部显示名称
};
}
// 领券显示内容处理
let hadGetCoupon = 2;// 1-是 2-否
let couponPic = detail.awardSharePic;
let couponName = detail.awardShareName;
let eventType = detail.eventType;
let whetherReceivedBaseCoupon = detail.whetherReceivedBaseCoupon;
let whetherReceivedShareCoupon = detail.whetherReceivedShareCoupon;
if (eventType == 1) { // 分享后领取 类型
if (whetherReceivedShareCoupon == 1) {
hadGetCoupon = 1;
}
} else if (eventType == 2) { // 领取后分享再领取 类型
if (whetherReceivedBaseCoupon == 2) { // 未领取基础券
couponPic = detail.awardBasePic;
couponName = detail.awardBaseName;
} else if (whetherReceivedBaseCoupon == 1 && whetherReceivedShareCoupon == 1) {
hadGetCoupon = 1;
} else if (whetherReceivedBaseCoupon == 1 && whetherReceivedShareCoupon == 2) {
couponPic = detail.awardSharePic;
couponName = detail.awardShareName;
hadGetCoupon = 2;
} else {
couponPic = detail.awardBasePic;
couponName = detail.awardBaseName;
hadGetCoupon = 2;
}
}
let couponData = {
couponPic,
couponName,
hadGetCoupon
return this._showToast(res);
});
},
_getStep: function(detail) {
let stepData = {
isExpire: false, // 活动结束标识
disable: false, // 底部按钮样式
isShare: false, // 是否分享
couponsData: {}, // 待领取的优惠券(基础或分享券)
name: '' // 底部显示名称
};
// 领券显示内容处理
let hadGetCoupon = 2; // 1-是 2-否
let couponPic = detail.awardSharePic;
let couponName = detail.awardShareName;
let eventType = detail.eventType;
let whetherReceivedBaseCoupon = detail.whetherReceivedBaseCoupon;
let whetherReceivedShareCoupon = detail.whetherReceivedShareCoupon;
if (eventType == 1) { // 分享后领取 类型
if (whetherReceivedShareCoupon == 1) {
hadGetCoupon = 1;
}
} else if (eventType == 2) { // 领取后分享再领取 类型
if (whetherReceivedBaseCoupon == 2) { // 未领取基础券
couponPic = detail.awardBasePic;
couponName = detail.awardBaseName;
} else if (whetherReceivedBaseCoupon == 1 && whetherReceivedShareCoupon == 1) {
hadGetCoupon = 1;
} else if (whetherReceivedBaseCoupon == 1 && whetherReceivedShareCoupon == 2) {
couponPic = detail.awardSharePic;
couponName = detail.awardShareName;
hadGetCoupon = 2;
} else {
couponPic = detail.awardBasePic;
couponName = detail.awardBaseName;
hadGetCoupon = 2;
}
}
let couponData = {
couponPic,
couponName,
hadGetCoupon
};
// 底部分享按钮显示内容处理
if (detail.eventStatus == 5) {
stepData = {
isExpire: true,
disable: true,
name: '活动已结束'
};
} else if (detail.whetherJoinedShare == 1) { // 分享过
stepData = {
isExpire: false,
disable: false,
isShare: true,
name: '继续分享',
subName: '去使用'
};
} else { // 未分享过
// 扫码球鞋机进来的
if (parseInt(`0${this.data.options.shareType}`, 10) === 3 || eventType == 1) {
stepData = {
isExpire: false,
disable: false,
isShare: false,
name: detail.leadingWords
};
// 底部分享按钮显示内容处理
if (detail.eventStatus == 5) {
stepData = {
isExpire: true,
disable: true,
name: '活动已结束'
};
} else if (detail.whetherJoinedShare == 1) { // 分享过
stepData = {
isExpire: false,
disable: false,
isShare: true,
name: '继续分享',
subName: '去使用'
};
} else { // 未分享过
// 扫码球鞋机进来的
if (parseInt(`0${this.data.options.shareType}`, 10) === 3 || eventType == 1) {
stepData = {
isExpire: false,
disable: false,
isShare: false,
name: detail.leadingWords
};
} else { // 非扫码球鞋机进来的
if (whetherReceivedBaseCoupon == 1) { // 1-是 2-否
stepData = {
isExpire: false,
disable: false,
isShare: false,
name: detail.leadingWords,
};
} else { // unclaimed status
stepData = {
isExpire: false,
disable: false,
isShare: false,
name: ''
};
}
}
} else { // 非扫码球鞋机进来的
if (whetherReceivedBaseCoupon == 1) { // 1-是 2-否
stepData = {
isExpire: false,
disable: false,
isShare: false,
name: detail.leadingWords,
};
} else { // unclaimed status
stepData = {
isExpire: false,
disable: false,
isShare: false,
name: ''
};
}
}
}
this.setData({
stepData,
couponData
});
this.setData({
stepData,
couponData
});
return stepData;
},
initTap: function() {
let eventId = this.data.options.id;
return stepData;
},
initTap: function() {
let eventId = this.data.options.id;
if (!(app && app.getUid())) {
this.setData({notLogin: true});
} else {
this.setData({notLogin: false});
}
return Promise.all([
fissionModel.getDetailById({
eventId: eventId
}),
]).then(res => {
if (!(app && app.getUid())) {
this.setData({
notLogin: true
});
} else {
this.setData({
notLogin: false
});
}
let detail = res[0].data || {};
return Promise.all([
fissionModel.getDetailById({
eventId: eventId
}),
]).then(res => {
this._getStep(detail);
let detail = res[0].data || {};
this.setData({
detail: detail,
closeStatus: [0, 2, 3].indexOf(detail.eventStatus || 0) > -1// 2-关闭 3-删除
});
this._getStep(detail);
return res;
}).then(res => {
this.setData({
detail: detail,
closeStatus: [0, 2, 3].indexOf(detail.eventStatus || 0) > -1 // 2-关闭 3-删除
});
this.data.isClickCoupon && this.tapSendCoupon().then(() => {
this.setData({
isClickCoupon: false
});
});
return res;
}).then(res => {
return res;
});
},
ifOutOfLimit: function() {
return getUserLocation().then(lres => {
return lres;
this.data.isClickCoupon && this.tapSendCoupon().then(() => {
this.setData({
isClickCoupon: false
});
},
});
// 领券
tapSendCoupon: function() {
if (this.data.detail.eventStatus == 6) { // 未开始
wx.showToast({
title: '还未到活动时间',
icon: 'none',
duration: 3000
});
return;
}
app = app || getApp();
let eventType = this.data.detail.eventType;
let whetherReceivedBaseCoupon = this.data.detail.whetherReceivedBaseCoupon;
let whetherReceivedShareCoupon = this.data.detail.whetherReceivedShareCoupon;
return res;
});
},
ifOutOfLimit: function() {
return getUserLocation().then(lres => {
return lres;
});
},
// 领券
tapSendCoupon: function() {
if (this.data.detail.eventStatus == 6) { // 未开始
wx.showToast({
title: '还未到活动时间',
icon: 'none',
duration: 3000
});
return;
}
app = app || getApp();
let eventType = this.data.detail.eventType;
let whetherReceivedBaseCoupon = this.data.detail.whetherReceivedBaseCoupon;
let whetherReceivedShareCoupon = this.data.detail.whetherReceivedShareCoupon;
var isGettingBaseCoupon = false;// true 领取基础券 false 领取分享券
var isGettingBaseCoupon = false; // true 领取基础券 false 领取分享券
if (eventType == 1) { // 分享后领取 类型
isGettingBaseCoupon = false;// 领取分享券
if (eventType == 1) { // 分享后领取 类型
isGettingBaseCoupon = false; // 领取分享券
} else if (eventType == 2) { // 领取后分享再领取 类型
// 是否领取:1-是 2-否
isGettingBaseCoupon = whetherReceivedBaseCoupon == 2 ? true : false;
}
} else if (eventType == 2) { // 领取后分享再领取 类型
// 是否领取:1-是 2-否
isGettingBaseCoupon = whetherReceivedBaseCoupon == 2 ? true : false;
}
if (!(app && app.getUid())) {
if (!(app && app.getUid())) {
this.setData({
isClickCoupon: true
});
return Promise.resolve({
code: 401,
message: ''
});
} else if (whetherReceivedShareCoupon == 1) { // 1-是 2-否
this.data.isClickCoupon && wx.showModal({
content: '您已领取过福利啦',
showCancel: false
});
return Promise.resolve({
code: 401,
message: ''
});
} else if (runCoupon) {
return Promise.resolve({
code: 401,
message: ''
});
}
runCoupon = true;
return this.ifOutOfLimit().then(lres => {
if (lres.code !== 200) {
return this._showToast(lres);
}
let eventId = this.data.options.id;
let longitude = lres.data.longitude;
let latitude = lres.data.latitude;
return fissionModel.sendCoupon({
eventId,
longitude,
latitude
}, isGettingBaseCoupon).then(res => {
if (res.code === 200 && res.data.executeStatus === 1) {
let detail = this.data.detail;
if (isGettingBaseCoupon) {
detail.whetherReceivedBaseCoupon = 1;
this.setData({
isClickCoupon: true
});
return Promise.resolve({
code: 401,
message: ''
});
} else if (whetherReceivedShareCoupon == 1) { // 1-是 2-否
this.data.isClickCoupon && wx.showModal({
content: '您已领取过福利啦',
showCancel: false
detail,
isBaseShow: true
});
return Promise.resolve({
code: 401,
message: ''
} else {
detail.whetherReceivedShareCoupon = 1;
wx.showToast({
title: '奖品已经放入您的账户',
icon: 'none',
duration: 3000
});
} else if (runCoupon) {
return Promise.resolve({
code: 401,
message: ''
this.setData({
detail
});
}
return this._getStep(detail);
}
return this._showModel(res.data);
});
}).then(res => {
runCoupon = false;
return res;
}).catch(() => {
runCoupon = false;
});
},
// 未开始活动,倒计时结束
endcountdown: function() {
this.initTap().then(res => {
if (this.data.closeStatus) {
return global.router.go('fissionClose', {
eventStatus: this.data.detail.eventStatus
});
}
runCoupon = true;
return this.ifOutOfLimit().then(lres => {
if (lres.code !== 200) {
return this._showToast(lres);
}
let eventId = this.data.options.id;
let longitude = lres.data.longitude;
let latitude = lres.data.latitude;
return fissionModel.sendCoupon({
eventId,
longitude,
latitude
}, isGettingBaseCoupon).then(res => {
if (res.code === 200 && res.data.executeStatus === 1) {
let detail = this.data.detail;
if (isGettingBaseCoupon) {
detail.whetherReceivedBaseCoupon = 1;
this.setData({
detail,
isBaseShow: true
});
} else {
detail.whetherReceivedShareCoupon = 1;
wx.showToast({
title: '奖品已经放入您的账户',
icon: 'none',
duration: 3000
});
this.setData({
detail
});
}
return this._getStep(detail);
}
return this._showModel(res.data);
});
}).then(res => {
runCoupon = false;
return res;
return res;
});
},
tapCloseBase: function() {
this.setData({
isBaseShow: false
});
},
tapShareOpen: function() {
app = app || getApp();
if (this.data.stepData.disable || !(app && app.getUid())) {
return false;
}
// 显示分享
wx.showShareMenu();
this.setData({
isShow: true,
isBaseShow: false
});
},
tapActionSheetMenu: function(e) {
let dataset = e.detail.dataset || {};
let isCanvasShow = false;
if (dataset.type === 'share') {
this.addEventShare();
this.setData({
isShow: false
});
return yas.report('YB_SHARE_TYPE', {
SHARE_NUM: 1,
PAGE_PARAM: stringify(this.data.options),
PAGE_PATH: '/pages/activity/fission'
});
}
if (dataset.type === 'friend') {
isCanvasShow = true;
}
// 禁止分享
wx.hideShareMenu();
this.setData({
isShow: false,
isCanvasShow: isCanvasShow
});
},
friendDraw: function() {
let awardImageWith = 70;
let allArray = [
wx.getImageInfo({
src: helper.imgView(this.data.detail.banner, 460, 300, 1).replace('http://', 'https://')
}),
wx.getImageInfo({
src: `https://api.yoho.cn/wechat/miniapp/img-check.jpg?param={"id":${this.data.options.id},"shareType":2}&miniQrType=13&miniapp_type=${config.miniapp_type}`
}).catch(() => {
return Promise.resolve({});
}),
// 分享券图
wx.getImageInfo({
src: helper.imgView(this.data.detail.awardSharePic, awardImageWith, awardImageWith, 1).replace('http://', 'https://')
}).catch(() => {
return Promise.resolve({});
})
];
if (this.data.detail.awardBasePic) { // 基础券图
allArray.push(
wx.getImageInfo({
src: helper.imgView(this.data.detail.awardBasePic, awardImageWith, awardImageWith, 1).replace('http://', 'https://')
}).catch(() => {
runCoupon = false;
});
},
return Promise.resolve({});
})
);
}
return Promise.all(allArray).then(res => {
let ctx = wx.createCanvasContext('canvas', this);
ctx.setFillStyle('white');
ctx.fillRect(0, 0, this.data.snapWidth, this.data.snapHeight);
ctx.setStrokeStyle('#e0e0e0');
let rectWidth = 460 * scale;
let logoWidth = 176 * scale;
let logoHeight = 60 * scale;
let rectLeft = (this.data.snapWidth - rectWidth) / 2;
let ptop = 30 * scale;
let middle = this.data.snapWidth / 2;
let awardWith = awardImageWith * scale;
ctx.drawImage(
'/static/images/logo@3x.png',
(this.data.snapWidth - logoWidth) / 2,
ptop,
logoWidth,
logoHeight
);
ptop += logoHeight + 30 * scale;
ctx.strokeRect(rectLeft, ptop, rectWidth, 600 * scale);
ctx.drawImage(
res[0].path,
rectLeft, ptop, rectWidth, 300 * scale
);
ptop += 370 * scale;
ctx.setFontSize(27 * scale);
ctx.setTextAlign('center');
this.drawLongText(this.data.detail.shareContentCaption, ctx, middle, ptop, 'black', 27, 13, 3, true, 22);
let awardSpace = 25 * scale;
let awardShareLeft = (this.data.snapWidth - awardWith) / 2;
// 基础券图
if (res[3]) {
let plusViewWith = 21 * scale;
let awardBaseLeft = (this.data.snapWidth - awardWith * 2 - plusViewWith - awardSpace * 2) / 2;
awardShareLeft = awardBaseLeft + awardWith + plusViewWith + awardSpace * 2;
ctx.drawImage(
res[3].path,
awardBaseLeft, ptop + 120 * scale, awardWith, awardWith
);
ctx.drawImage(
'/static/images/activity/fission/combined_shape@3x.png',
awardBaseLeft + awardWith + awardSpace,
ptop + 120 * scale + (awardWith - plusViewWith) / 2,
plusViewWith,
plusViewWith
);
}
// 未开始活动,倒计时结束
endcountdown: function() {
this.initTap().then(res => {
if (this.data.closeStatus) {
return global.router.go('fissionClose', {eventStatus: this.data.detail.eventStatus});
}
// 分享券图
if (res[2]) {
ctx.drawImage(
res[2].path,
awardShareLeft, ptop + 120 * scale, awardWith, awardWith
);
}
return res;
});
},
ptop += (135 * scale + 120 * scale);
if (res[1].path) {
ctx.drawImage(
res[1].path,
rectLeft, ptop, 160 * scale, 160 * scale
);
}
tapCloseBase: function() {
this.setData({
isBaseShow: false
ctx.setTextAlign('left');
ctx.setFillStyle('#444444');
ctx.setFontSize(20 * scale);
ptop += 60 * scale;
ctx.fillText('长按识别小程序码', rectLeft + 182 * scale, ptop, );
ctx.setFillStyle('#b0b0b0');
ctx.setFontSize(18 * scale);
ptop += 30 * scale;
ctx.fillText('全球潮品一手掌握!', rectLeft + 182 * scale, ptop);
ctx.setFillStyle('#b0b0b0');
ctx.setFontSize(18 * scale);
ptop += 25 * scale;
ctx.fillText('超多福利活动等你来潮!', rectLeft + 182 * scale, ptop);
ctx.draw(true, () => {
return wx.canvasToTempFilePath({
x: 0,
y: 0,
width: this.data.snapWidth,
height: this.data.snapHeight,
destWidth: this.data.snapWidth * 4,
destHeight: this.data.snapHeight * 4,
quality: 1.0,
canvasId: 'canvas'
}).then(dres => {
this.setData({
canvasImg: dres.tempFilePath
});
return dres;
});
},
tapShareOpen: function() {
app = app || getApp();
});
if (this.data.stepData.disable || !(app && app.getUid())) {
return false;
}
return res;
});
},
// 显示分享
wx.showShareMenu();
// 绘制长文本
drawLongText(longtext, cxt, begin_width, begin_height, color, fontSize, numsForLine, numberOfLine, isCenter = true, lineL = 0) {
let linelenght = lineL; // 行间距
this.setData({
isShow: true,
isBaseShow: false
});
},
tapActionSheetMenu: function(e) {
let dataset = e.detail.dataset || {};
let isCanvasShow = false;
if (linelenght == 0) {
linelenght = (fontSize + 2) * scale;
}
if (!numberOfLine) {
numberOfLine = 2;
}
var text = '';
var count = 0;
var lineNumber = 1;
var begin_width = begin_width;
var begin_height = begin_height;
var stringLenght = longtext.length;
var newtext = longtext.split('');
cxt.setFillStyle(color);
cxt.setFontSize(fontSize * scale);
if (isCenter) {
cxt.setTextAlign('center');
}
if (dataset.type === 'share') {
this.addEventShare();
this.setData({
isShow: false
});
return yas.report('YB_SHARE_TYPE', {
SHARE_NUM: 1,
PAGE_PARAM: stringify(this.data.options),
PAGE_PATH: '/pages/activity/fission'
});
}
// 为了计算y初始坐标,以实现文字上下居中...
var textCount = 0;
var maxLineNumer = 1;
if (dataset.type === 'friend') {
isCanvasShow = true;
}
for (var i = 0; i <= stringLenght; i++) {
if (textCount == numsForLine) {
maxLineNumer++;
textCount = 0;
}
textCount++;
if (maxLineNumer > numberOfLine) {
maxLineNumer--;
break;
}
}
begin_height += (96 * scale - linelenght * maxLineNumer) / 2;
// 禁止分享
wx.hideShareMenu();
for (var i = 0; i <= stringLenght; i++) {
if (count == numsForLine) {
if (lineNumber === numberOfLine) {
var t = text + '...';
this.setData({
isShow: false,
isCanvasShow: isCanvasShow
});
},
friendDraw: function() {
let awardImageWith = 70;
let allArray = [
wx.getImageInfo({
src: helper.imgView(this.data.detail.banner, 460, 300, 1).replace('http://', 'https://')
}),
wx.getImageInfo({
src: `https://api.yoho.cn/wechat/miniapp/img-check.jpg?param={"id":${this.data.options.id},"shareType":2}&miniQrType=13&miniapp_type=${config.miniapp_type}`
}).catch(() => {
return Promise.resolve({});
}),
// 分享券图
wx.getImageInfo({
src: helper.imgView(this.data.detail.awardSharePic, awardImageWith, awardImageWith, 1).replace('http://', 'https://')
}).catch(() => {
return Promise.resolve({});
})
];
if (this.data.detail.awardBasePic) { // 基础券图
allArray.push(
wx.getImageInfo({
src: helper.imgView(this.data.detail.awardBasePic, awardImageWith, awardImageWith, 1).replace('http://', 'https://')
}).catch(() => {
return Promise.resolve({});
})
);
cxt.fillText(t, begin_width, begin_height);
} else {
cxt.fillText(text, begin_width, begin_height);
}
return Promise.all(allArray).then(res => {
let ctx = wx.createCanvasContext('canvas', this);
ctx.setFillStyle('white');
ctx.fillRect(0, 0, this.data.snapWidth, this.data.snapHeight);
ctx.setStrokeStyle('#e0e0e0');
let rectWidth = 460 * scale;
let logoWidth = 176 * scale;
let logoHeight = 60 * scale;
let rectLeft = (this.data.snapWidth - rectWidth) / 2;
let ptop = 30 * scale;
let middle = this.data.snapWidth / 2;
let awardWith = awardImageWith * scale;
ctx.drawImage(
'/static/images/logo@3x.png',
(this.data.snapWidth - logoWidth) / 2,
ptop,
logoWidth,
logoHeight
);
ptop += logoHeight + 30 * scale;
ctx.strokeRect(rectLeft, ptop, rectWidth, 600 * scale);
ctx.drawImage(
res[0].path,
rectLeft, ptop, rectWidth, 300 * scale
);
ptop += 370 * scale;
ctx.setFontSize(27 * scale);
ctx.setTextAlign('center');
this.drawLongText(this.data.detail.shareContentCaption, ctx, middle, ptop, 'black', 27, 13, 3, true, 22);
let awardSpace = 25 * scale;
let awardShareLeft = (this.data.snapWidth - awardWith) / 2;
// 基础券图
if (res[3]) {
let plusViewWith = 21 * scale;
let awardBaseLeft = (this.data.snapWidth - awardWith * 2 - plusViewWith - awardSpace * 2) / 2;
awardShareLeft = awardBaseLeft + awardWith + plusViewWith + awardSpace * 2;
ctx.drawImage(
res[3].path,
awardBaseLeft, ptop + 120 * scale, awardWith, awardWith
);
ctx.drawImage(
'/static/images/activity/fission/combined_shape@3x.png',
awardBaseLeft + awardWith + awardSpace,
ptop + 120 * scale + (awardWith - plusViewWith) / 2,
plusViewWith,
plusViewWith
);
}
// 分享券图
if (res[2]) {
ctx.drawImage(
res[2].path,
awardShareLeft, ptop + 120 * scale, awardWith, awardWith
);
}
ptop += (135 * scale + 120 * scale);
if (res[1].path) {
ctx.drawImage(
res[1].path,
rectLeft, ptop, 160 * scale, 160 * scale
);
}
ctx.setFillStyle('#444444');
ctx.setFontSize(20 * scale);
ptop += 60 * scale;
ctx.fillText('长按识别图中小程序二维码', rectLeft + 300 * scale, ptop);
ctx.setFillStyle('#b0b0b0');
ctx.setFontSize(18 * scale);
ptop += 30 * scale;
ctx.fillText('全球潮品一手掌握!', rectLeft + 262 * scale, ptop);
ctx.setFillStyle('#b0b0b0');
ctx.setFontSize(18 * scale);
ptop += 25 * scale;
ctx.fillText('超多福利活动等你来潮!', rectLeft + 282 * scale, ptop);
ctx.draw(true, () => {
return wx.canvasToTempFilePath({
x: 0,
y: 0,
width: this.data.snapWidth,
height: this.data.snapHeight,
destWidth: this.data.snapWidth * 4,
destHeight: this.data.snapHeight * 4,
quality: 1.0,
canvasId: 'canvas'
}).then(dres => {
this.setData({
canvasImg: dres.tempFilePath
});
return dres;
});
});
begin_height = begin_height + linelenght;
text = '';
count = 0;
lineNumber++;
}
if (i == stringLenght) {
cxt.fillText(text, begin_width, begin_height);
}
text = text + newtext[0];
count++;
newtext.shift();
if (lineNumber > numberOfLine) {
break;
}
}
},
return res;
});
},
longTextSplit: function(text, rowCharNumber, rowNumber = 2) {
let textSplit = text.split('');
let result = [];
let char = '';
let num = 0;
// 绘制长文本
drawLongText(longtext, cxt, begin_width, begin_height, color, fontSize, numsForLine, numberOfLine, isCenter = true, lineL = 0) {
let linelenght = lineL;// 行间距
for (let i = 0; i < textSplit.length; i++) {
if (result.length === rowNumber) {
let tchar = result[rowNumber - 1];
if (linelenght == 0) {
linelenght = (fontSize + 2) * scale;
}
if (!numberOfLine) {
numberOfLine = 2;
}
var text = '';
var count = 0;
var lineNumber = 1;
var begin_width = begin_width;
var begin_height = begin_height;
var stringLenght = longtext.length;
var newtext = longtext.split('');
cxt.setFillStyle(color);
cxt.setFontSize(fontSize * scale);
if (isCenter) {
cxt.setTextAlign('center');
}
result[rowNumber - 1] = tchar.substr(tchar.length - 3) + '...';
break;
}
// 为了计算y初始坐标,以实现文字上下居中...
var textCount = 0;
var maxLineNumer = 1;
for (var i = 0; i <= stringLenght; i++) {
if (textCount == numsForLine) {
maxLineNumer++;
textCount = 0;
}
textCount++;
if (maxLineNumer > numberOfLine) {
maxLineNumer--;
break;
}
}
begin_height += (96 * scale - linelenght * maxLineNumer) / 2;
for (var i = 0; i <= stringLenght; i++) {
if (count == numsForLine) {
if (lineNumber === numberOfLine) {
var t = text + '...';
cxt.fillText(t, begin_width, begin_height);
} else {
cxt.fillText(text, begin_width, begin_height);
}
begin_height = begin_height + linelenght;
text = '';
count = 0;
lineNumber++;
}
if (i == stringLenght) {
cxt.fillText(text, begin_width, begin_height);
}
text = text + newtext[0];
count++;
newtext.shift();
if (lineNumber > numberOfLine) {
break;
}
}
},
longTextSplit: function(text, rowCharNumber, rowNumber = 2) {
let textSplit = text.split('');
let result = [];
let char = '';
let num = 0;
for (let i = 0; i < textSplit.length; i++) {
if (result.length === rowNumber) {
let tchar = result[rowNumber - 1];
result[rowNumber - 1] = tchar.substr(tchar.length - 3) + '...';
break;
}
if (/^[\u4e00-\u9fa5]/.test(textSplit[i])) {
num += 2;
} else {
num += 1;
}
if (num >= rowNumber) {
result.push(char);
num = 0;
}
}
if (/^[\u4e00-\u9fa5]/.test(textSplit[i])) {
num += 2;
} else {
num += 1;
}
if (num >= rowNumber) {
result.push(char);
num = 0;
}
}
return result;
},
tapActionCanvas: function(e) {
let dataset = e.detail.dataset || {};
return result;
},
tapActionCanvas: function(e) {
let dataset = e.detail.dataset || {};
dataset.index = parseInt(dataset.index, 10);
dataset.index = parseInt(dataset.index, 10);
this.setData({
isCanvasShow: false
});
this.setData({
isCanvasShow: false
});
if (dataset.index !== 1) {
return;
}
if (dataset.index !== 1) {
return;
return getAuthorization('scope.writePhotosAlbum').then(() => {
return wx.canvasToTempFilePath({
x: 0,
y: 0,
width: this.data.snapWidth,
height: this.data.snapHeight,
destWidth: this.data.snapWidth * 4,
destHeight: this.data.snapHeight * 4,
quality: 1.0,
canvasId: 'canvas'
}).then(res => {
if (!this.data.canvasImg) {
this.setData({
canvasImg: res.tempFilePath
});
}
return getAuthorization('scope.writePhotosAlbum').then(() => {
return wx.canvasToTempFilePath({
x: 0,
y: 0,
width: this.data.snapWidth,
height: this.data.snapHeight,
destWidth: this.data.snapWidth * 4,
destHeight: this.data.snapHeight * 4,
quality: 1.0,
canvasId: 'canvas'
}).then(res => {
if (!this.data.canvasImg) {
this.setData({
canvasImg: res.tempFilePath
});
}
return wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath
}).then(() => {
return this.addEventShare();
}).then(() => {
yas.report('YB_SHARE_TYPE', {
SHARE_NUM: 2,
PAGE_PARAM: stringify(this.data.options),
PAGE_PATH: '/pages/activity/fission'
});
return wx.showToast({
title: '图片已经保存',
icon: 'success',
duration: 3000
});
});
});
});
},
tapAccount: function() {
return global.router.go('userCenter', {}, 'switchTab');
},
tapRule: function() {
return global.router.go('fissionRule', {
id: this.data.options.id
return wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath
}).then(() => {
return this.addEventShare();
}).then(() => {
yas.report('YB_SHARE_TYPE', {
SHARE_NUM: 2,
PAGE_PARAM: stringify(this.data.options),
PAGE_PATH: '/pages/activity/fission'
});
return wx.showToast({
title: '图片已经保存',
icon: 'success',
duration: 3000
});
});
},
tapCouponList: function() {
// return global.router.go('couponList', {
// type: 4,
// mername: 'MKT'
// });
return global.router.go('userCenter', {}, 'switchTab');
},
// goYOhobuy: function() {
// return gominiapp({
// app: 'yohobuy',
// page: 'index',
// data: {}
// });
// },
onImageUrl({
detail: {
url
}
}) {
console.log('open=>', url);
global.router.goUrl(url);
});
});
},
tapAccount: function() {
return global.router.go('userCenter', {}, 'switchTab');
},
tapRule: function() {
return global.router.go('fissionRule', {
id: this.data.options.id
});
},
tapCouponList: function() {
// return global.router.go('couponList', {
// type: 4,
// mername: 'MKT'
// });
return global.router.go('userCenter', {}, 'switchTab');
},
// goYOhobuy: function() {
// return gominiapp({
// app: 'yohobuy',
// page: 'index',
// data: {}
// });
// },
onImageUrl({
detail: {
url
}
});
}) {
console.log('open=>', url);
global.router.goUrl(url);
}
});
\ No newline at end of file
... ...
import saleModel from '../../models/activity/sale/index';
import myScrollTap from '../my-scroll-tap';
import Yas from '../../common/yas.js';
import config from '../../common/config.js'
let initData = {
data: [],
... ... @@ -12,7 +13,8 @@ let app = getApp();
Page(Object.assign(myScrollTap, {
data: {
saleItem: Object.assign({}, initData)
saleItem: Object.assign({}, initData),
pageSize: 10
},
onLoad: function() {
this.tapLoadMore();
... ... @@ -30,6 +32,7 @@ Page(Object.assign(myScrollTap, {
};
},
queryLimitActivityList: function(refresh) {
let that = this
let saleItem = refresh ? Object.assign({}, initData) : this.data.saleItem;
if (saleItem.end) {
... ... @@ -41,8 +44,8 @@ Page(Object.assign(myScrollTap, {
}
let params = {
pageNum: saleItem.page++,
pageSize: 10,
belongStoreId: 94,
pageSize: this.data.pageSize,
belongStoreId: config.storeId,
}
return saleModel.queryLimitActivityList(params).then(res => {
... ... @@ -53,7 +56,7 @@ Page(Object.assign(myScrollTap, {
let limitActivityList = res.data && res.data.limitActivityList || [];
saleItem.data = saleItem.data.concat(limitActivityList);
saleItem.end = !limitActivityList.length;
saleItem.end = limitActivityList.length < that.data.pageSize ? true : false;
this.setData({
saleItem
});
... ...
... ... @@ -3,7 +3,7 @@
<my-scroll-view class="limit-sale-page"
isTop="{{isTop}}"
bindbackToTop="backToTop">
<view class="limit-sale-container">
<view class="limit-sale-container" wx:if="{{saleItem.data.length}}">
<view class="sale-item" bindtap="tapDetail"
wx:for="{{saleItem.data}}" wx:key="index" wx:index="index"
data-id="{{item.id}}"
... ... @@ -24,4 +24,5 @@
</view>
<load-more end="{{saleItem.end}}"></load-more>
</view>
<view wx:else class="noData">暂无限定数据</view>
</my-scroll-view>
... ...
... ... @@ -79,3 +79,9 @@ page {
display: inline-block;
margin-right: 8rpx;
}
.noData {
margin-top: 50rpx;
color: #b1b1b1;
text-align: center;
font-size: 28rpx;
}
... ...
... ... @@ -60,10 +60,9 @@ Page({
}
result = result && result.data && result.data.rows || [];
if (result.length <= 0) {
newsData.end = true;
} else {
newsData.end = result.length < newsData.limit ? true : false;
if (result.length > 0) {
result = result.map(item => {
return Object.assign({}, item, {url: `/pages/cms/newsDetail?id=${item.id}`});
});
... ...