Skip to content

Commit

Permalink
1. separte ad unit for main page
Browse files Browse the repository at this point in the history
2. remove unused code
  • Loading branch information
infinityu committed Jan 29, 2020
1 parent 66f1d9e commit b1eac5a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 45 deletions.
4 changes: 2 additions & 2 deletions pages/happiness/add-happiness.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<view class="grid col-2 animation-shake animation-speed-2 animation-delay-3">
<!-- <button class="cu-btn block shaline-orange lg" open-type="share"> -->
<button class="cu-btn block line-orange lg share-btn" open-type="share">
<text class="cuIcon-upload"></text> 分享给好友</button>
<text class="cuIcon-upload"></text> 送福给好友</button>
</view>
<!-- <view class="grid col-3 animation-shake animation-speed-2 animation-delay-3">
<button class="cu-btn round action-btn bg-yellow shadow" @click="toSharePage" data-target="image">
Expand Down Expand Up @@ -189,7 +189,7 @@
// 在页面onLoad回调事件中创建插屏广告实例
if (wx.createInterstitialAd) {
interstitialAd = wx.createInterstitialAd({
adUnitId: 'adunit-beed4816676d471a'
adUnitId: 'adunit-6a39f22d22569c87'
})
interstitialAd.onLoad(() => {})
interstitialAd.onError((err) => {})
Expand Down
64 changes: 21 additions & 43 deletions pages/happiness/add-mask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
<scroll-view class="scrollView mask-scroll-view" scroll-x="true">
<view v-for="(item,index) in imgList" :key="index" style="display: inline-flex;">

<text v-if="currentMaskId == index && isAndroid" class="cuIcon-order cancel circle" @click="flipHorizontal" id="cancel" :style="{transform: 'rotate(' +90+ 'deg)'}"></text>
<text v-if="currentMaskId == index && isAndroid" class="cuIcon-order cancel circle" @click="flipHorizontal" id="cancel"
:style="{transform: 'rotate(' +90+ 'deg)'}"></text>
<image class="imgList" :src="'/static/image/mask/mask'+ index +'.png'" :data-mask-id="index" @tap="changeMask"></image>
</view>
</scroll-view>
Expand All @@ -64,14 +65,14 @@
},
data() {
return {
windowHeight: 0,
windowHeight: 0,
isAndroid: getApp().globalData.IS_ANDROID,
cansWidth: 270, // 宽度 px
cansHeight: 270, // 高度 px
avatarPath: '/static/image/mask/avatar_mask.png',
imgList: [0, 1, 2, 3, 4],
currentMaskId: -1,
showBorder: false,
showBorder: false,
maskCenterX: wx.getSystemInfoSync().windowWidth / 2,
maskCenterY: 250,
cancelCenterX: wx.getSystemInfoSync().windowWidth / 2 - 50 - 2,
Expand Down Expand Up @@ -127,15 +128,14 @@
},
methods: {
...mapMutations(["saveLoginUserInfo"]),
paint() {
},
touchAvatarBg(){
this.showBorder = false;
paint() {},
touchAvatarBg() {
this.showBorder = false;
},
touchStart(e) {
console.log('e.target.id', e.target.id);
if (e.target.id == "mask") {
this.touch_target = "mask";
this.touch_target = "mask";
this.showBorder = true;
} else if (e.target.id == "handle") {
this.touch_target = "handle"
Expand All @@ -155,12 +155,9 @@
this.cancel_center_y = this.cancelCenterY;
this.handle_center_x = this.handleCenterX;
this.handle_center_y = this.handleCenterY;
// }
this.touch_target = "";
this.scaleCurrent = this.scale;
this.rotateCurrent = this.rotate;
console.log('this.scale', this.scale);
console.log('this.rotate', this.rotate);
},
touchMove(e) {
var current_x = e.touches[0].clientX;
Expand All @@ -174,8 +171,6 @@
this.cancelCenterY = this.cancelCenterY + moved_y;
this.handleCenterX = this.handleCenterX + moved_x;
this.handleCenterY = this.handleCenterY + moved_y;
console.log('maskCenterX', this.maskCenterX);
console.log('maskCenterY', this.maskCenterY);
};
if (this.touch_target == "handle") {
this.handleCenterX = this.handleCenterX + moved_x;
Expand All @@ -192,9 +187,6 @@
let angle_after = Math.atan2(diff_y_after, diff_x_after) / Math.PI * 180;
this.scale = distance_after / distance_before * this.scaleCurrent;
console.log('distance_after', distance_after);
console.log('distance_before', distance_before);
console.log('this.scaleCurrent', this.scaleCurrent);
this.rotate = angle_after - angle_before + this.rotateCurrent;
}
this.start_x = current_x;
Expand All @@ -215,7 +207,6 @@
return;
}
let userInfo = result.detail.userInfo;
console.log(userInfo);
userInfo.avatarUrl = userInfo.avatarUrl.replace("132", "0"); // 使用最大分辨率头像 959 * 959
let self = this;
uni.downloadFile({
Expand Down Expand Up @@ -252,10 +243,8 @@
sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'],
success: function(res) {
console.log(res);
let tempImagePath = res.tempFilePaths[0];
self.imageCheck(tempImagePath, self.loadRecImageOrStartToCrop);
// self.loadRecImageOrStartToCrop(tempImagePath);
}
});
},
Expand Down Expand Up @@ -283,7 +272,6 @@
});
},
changeMask(e) {
console.log(e);
this.currentMaskId = e.target.dataset.maskId
},
draw() {
Expand All @@ -292,26 +280,23 @@
let mask_center_x = this.mask_center_x;
let mask_center_y = this.mask_center_y;
let _this = this;
//创建节点选择器
// 创建节点选择器
// 口罩中心位置的计算是从屏幕左上角开始,所以我们需要获取头像图片的位置,来得到口罩相对头像的位置
var query = wx.createSelectorQuery();
query.select('#avatar-bg').boundingClientRect()
query.exec(function(res) {
//res就是 所有标签为#的元素的信息的数组
console.log(res);
//取高度
mask_center_x = mask_center_x - res[0].left;
mask_center_y = mask_center_y - res[0].top;
console.log('mask_center_x', mask_center_x);
console.log('mask_center_y', mask_center_y);
const pc = wx.createCanvasContext('cans-id-mask');
const windowWidth = wx.getSystemInfoSync().windowWidth;
const mask_size = 100 * scale;
pc.clearRect(0, 0, _this.cansWidth, _this.cansHeight);
pc.drawImage(_this.avatarPath, 0, 0, _this.cansWidth, _this.cansHeight);
pc.translate(mask_center_x, mask_center_y);
pc.rotate(rotate * Math.PI / 180);
if(_this.isAndroid) {
pc.rotate(rotate * Math.PI / 180);
if (_this.isAndroid) {
_this.rotateY == 180 && pc.scale(-1, 1);
}
pc.drawImage(_this.maskPic, -mask_size / 2, -mask_size / 2, mask_size, mask_size);
Expand All @@ -320,14 +305,12 @@
})
},
flipHorizontal() {
this.rotateY = this.rotateY == 0 ? 180 : 0;
console.log('rotateY', this.rotateY);
this.rotateY = this.rotateY == 0 ? 180 : 0;
},
/**
* 保存
*/
saveCans() {
console.log('保存...')
let _this = this;
uni.showLoading({
title: '保存...',
Expand Down Expand Up @@ -402,7 +385,6 @@
}, this)
},
showModal: function(e) {
console.log(e.currentTarget.dataset);
this.modalName = e.currentTarget.dataset.target;
},
hideModal: function(e) {
Expand All @@ -419,11 +401,9 @@
quality: 1,
success: res => {
let tempFilePathCompressed = res.tempFilePath;
// console.log(res.tempFilePath)
wx.getFileSystemManager().readFile({
filePath: tempFilePathCompressed, // 压缩图片,然后安全检测
success: buffer => {
console.log(buffer.data);
uni.showLoading({
title: '加载中...'
});
Expand Down Expand Up @@ -484,7 +464,6 @@
margin-left: auto;
margin-right: auto;
// background-size: 100%;
}
.avatar-bg-border {
Expand Down Expand Up @@ -520,15 +499,15 @@
width: 100px;
position: absolute;
top: 100px;
border: 3px;
border: 3px solid rgba(255, 255, 255, 0.0);
}
.maskWithBorder {
border: dashed 3px white;
}
.maskWithBorder{
border: dashed 3px white;
}
.hideHandle{
display: none;
.hideHandle {
display: none;
}
.circle {
Expand Down Expand Up @@ -570,7 +549,6 @@
left: 1000px;
}
.flip-horizontal {
-moz-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
Expand Down

0 comments on commit b1eac5a

Please sign in to comment.