var t = getApp(), i = null, a = 0;
Page({
data: {
age: "",
height: "",
weight: "",
pickGirl: "",
traitArr: "",
love: "",
loading: !1,
girlName: "",
date: "",
girlHeight: "",
girlWeight: "",
girlCup: "",
girlHair: "",
girlCharacter: "",
professionIncome: "",
wifePhoto: "",
showPhoto: "",
avatar: "",
nickName: "",
canvasHidden: !1,
share: "",
ismotal: !1
},
onLoad: function(e) {
var o = this, r = e.age, n = parseInt(e.height), s = parseInt(e.weight), c = e.pickGirl, l = e.traitArr, g = e.love;
1 == e.share ? (console.log("分享进来的:" + e.share), o.setData({
share: e.share,
avatar: e.avatar,
nickName: e.nickName,
wifePhoto: e.wifePhoto,
girlName: e.girlName,
date: e.date,
girlHeight: e.girlHeight,
girlWeight: e.girlWeight,
girlCup: e.girlCup,
girlHair: e.girlHair,
girlCharacter: e.girlCharacter,
professionIncome: e.professionIncome
}), this.playCanvas()) : (o.setData({
age: r,
height: n,
weight: s,
pickGirl: c,
traitArr: JSON.parse(l),
love: g,
avatar: t.globalData.userInfo.avatarUrl,
nickName: t.globalData.userInfo.nickName
}), this.algorithm(), this.playCanvas()), o.setData({
ismotal: !0
}), wx.createRewardedVideoAd && ((i = wx.createRewardedVideoAd({
adUnitId: "adunit-9f27451723f8ec9e"
})).onLoad(function() {
console.log("createRewardedVideoAd onLoad");
}), i.onError(function(t) {
console.log("createRewardedVideoAd onError");
}), i.onClose(function(t) {
t && t.isEnded ? o.setData({
ismotal: !1
}) : wx.showModal({
title: "提示",
showCancel: !1,
content: "请观看完整视频,才可以查看结果"
});
})), wx.request({
url: "https://xcx.codeagod.com/love/1.json",
method: "GET",
success: function(t) {
console.log(t), a = t.data.ret;
}
});
},
motkBtn: function() {
i && 1 == a ? i.show().catch(function() {
i.load().then(function() {
return i.show();
}).catch(function(t) {
console.log("激励视频 广告显示失败");
});
}) : this.setData({
ismotal: !1
});
},
playCanvas: function() {
var t = this, i = wx.createCanvasContext("wife"), a = t.data.avatar;
i.drawImage("../../images/bg.jpg", 5, 5, 352, 524), i.save(), i.arc(65, 55, 25, 0, 2 * Math.PI),
i.clip(), wx.getImageInfo({
src: a,
success: function(a) {
var e = a.path;
i.drawImage(e, 40, 30, 50, 50), i.restore(), i.beginPath(), i.textAlign = "center",
i.font = "bold 20px Arial", i.lineWidth = 1, i.fillStyle = "rgb(0,0,0)", i.fillText(t.data.nickName + "理想中的老婆", 200, 60),
i.save();
var o = t.data.wifePhoto;
i.drawImage(o, 130, 85, 100, 100), i.lineWidth = 5, i.lineJoin = "round", i.strokeRect(130, 85, 101, 101),
i.beginPath(), i.textAlign = "left", i.font = "bold 18px Arial", i.lineWidth = 1,
i.fillStyle = "rgb(0,0,0)", i.fillText("姓名:" + t.data.girlName, 80, 220), i.fillText("生日:" + t.data.date, 80, 250),
i.fillText("身高:" + t.data.girlHeight + "CM", 80, 280), i.fillText("体重:" + t.data.girlWeight + "KG", 80, 310),
i.fillText("罩杯:" + t.data.girlCup + "罩杯", 80, 340), i.fillText("头发:" + t.data.girlHair, 80, 370),
i.fillText("性格:" + t.data.girlCharacter, 80, 400), i.fillText("职业/收入:" + t.data.professionIncome, 80, 430),
i.save(), i.draw(!1, function() {
wx.canvasToTempFilePath({
canvasId: "wife",
quality: 1,
success: function(i) {
console.log(i.tempFilePath), t.setData({
showPhoto: i.tempFilePath,
canvasHidden: !0
});
},
fail: function(t) {
console.log(t);
}
});
});
}
});
},
saveWifePath: function() {
var t = this.data.showPhoto;
wx.saveImageToPhotosAlbum({
filePath: t,
success: function(t) {
console.log(t), wx.showToast({
title: "图片保存成功",
icon: "success",
duration: 2e3
});
},
fail: function(t) {
console.log(t), wx.showToast({
title: "图片保存失败",
icon: "success",
duration: 2e3
});
}
});
},
getNewWife: function() {
wx.navigateTo({
url: "pages/index/index"
});
},
algorithm: function() {
var t = this, i = [ "周", "李", "何", "范", "尹", "倪", "张", "韩", "粱", "黄", "柏", "戚", "杨", "沈", "刘", "胡", "朱", "林", "袁", "王", "吴", "陈" ], a = [ "思", "雅", "晴", "彦", "婉", "仪", "伊", "琪", "薇", "颖", "倩", "媛", "语", "媛", "晗", "佳", "玲", "嘉", "璐", "俪", "凝", "莉", "茹", "温", "贻", "姗", "美", "琴", "菲", "梦", "雨", "萱", "洁", "妍", "欣", "玉", "悦", "娜", "婷", "熙", "玉", "宁", "爽", "莉", "瑶", "荷", "秋", "蕊", "羽", "希" ], e = i[t.randomNum(0, i.length - 1)] + a[t.randomNum(0, a.length - 1)] + a[t.randomNum(0, a.length - 1)];
console.log("女孩名字:" + e), t.setData({
girlName: e
});
var o = "", r = "", n = "", s = void 0, c = t.data.age, l = t.data.height, g = (t.data.weight,
t.data.pickGirl), f = t.data.traitArr, m = t.data.love;
c > 30 && (c = 28), "a" == m && (s = 2018 - c + 2, "能力" == f[0].trait && (o = s - 2),
"能力" == f[1].trait && (o = s - 1), "能力" == f[2].trait && (o = s), "能力" == f[3].trait && (o = s + 1)),
"b" == m && (s = 2018 - c - 3, "能力" == f[0].trait && (o = s - 2), "能力" == f[1].trait && (o = s - 1),
"能力" == f[2].trait && (o = s), "能力" == f[3].trait && (o = s + 1)), "c" == m && (s = 2018 - c + 1,
"能力" == f[0].trait && (o = s - 2), "能力" == f[1].trait && (o = s - 1), "能力" == f[2].trait && (o = s),
"能力" == f[3].trait && (o = s + 1)), "d" == m && (s = 2018 - c + 4, "能力" == f[0].trait && (o = s - 2),
"能力" == f[1].trait && (o = s - 1), "能力" == f[2].trait && (o = s), "能力" == f[3].trait && (o = s + 1)),
r = t.randomNum(1, 12);
var d = t.getDates(r, o), p = o + "年" + r + "月" + (n = t.randomNum(1, d)) + "日";
t.setData({
date: p
});
var h = "", u = "", w = "", v = "", C = "", x = "", D = void 0, N = l - 10;
1 == g && (D = N + 4, "身材" == f[0].trait && (h = D + 2), "身材" == f[1].trait && (h = D + 1),
"身材" == f[2].trait && (h = D - 1), "身材" == f[3].trait && (h = D - 2)), 2 == g && (D = N + 2,
"身材" == f[0].trait && (h = D + 2), "身材" == f[1].trait && (h = D + 1), "身材" == f[2].trait && (h = D - 1),
"身材" == f[3].trait && (h = D - 2)), 3 == g && (D = N, "身材" == f[0].trait && (h