小程序经验分享

分享一些写小程序的经验

function t(t, a, e) {
    return a in t ? Object.defineProperty(t, a, {
        value: e,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : t[a] = e, t;
}

var a = getApp();

Page({
    data: {
        loading: !0,
        nickName: "",
        height: "",
        weight: "",
        age: "",
        pickGirl: "",
        trait1: "",
        trait1Bg: "",
        trait2: "",
        trait2Bg: "",
        trait3: "",
        trait3Bg: "",
        trait4: "",
        trait4Bg: "",
        traitArr: [ {
            bg: "",
            trait: ""
        }, {
            bg: "",
            trait: ""
        }, {
            bg: "",
            trait: ""
        }, {
            bg: "",
            trait: ""
        } ],
        temTrait1: "",
        temTrait2: "",
        temTrait3: "",
        temTrait4: "",
        love: ""
    },
    onLoad: function(t) {
        this.setData({
            nickName: a.globalData.userInfo.nickName
        });
    },
    getHeight: function(t) {
        var a = this, e = t.detail.value;
        e >= 300 ? wx.showModal({
            title: "提示",
            content: "你也高得太不正常了吧?",
            showCancel: !1,
            success: function(t) {
                t.confirm && a.setData({
                    height: ""
                });
            }
        }) : e > 0 && e < 140 ? wx.showModal({
            title: "提示",
            content: "你也太矮了",
            showCancel: !1,
            success: function(t) {
                t.confirm && a.setData({
                    height: ""
                });
            }
        }) : "" == e ? a.setData({
            height: ""
        }) : e <= 0 ? wx.showModal({
            title: "提示",
            content: "输入有误",
            showCancel: !1,
            success: function(t) {
                t.confirm && a.setData({
                    height: ""
                });
            }
        }) : a.setData({
            height: e
        });
    },
    getWeight: function(t) {
        var a = this, e = t.detail.value;
        e >= 300 ? wx.showModal({
            title: "提示",
            content: "您太重了",
            showCancel: !1,
            success: function(t) {
                t.confirm && a.setData({
                    weight: ""
                });
            }
        }) : e > 0 && e < 40 ? wx.showModal({
            title: "提示",
            content: "您太轻了",
            showCancel: !1,
            success: function(t) {
                t.confirm && a.setData({
                    weight: ""
                });
            }
        }) : "" == e ? a.setData({
            weight: ""
        }) : e <= 0 ? wx.showModal({
            title: "提示",
            content: "输入有误",
            showCancel: !1,
            success: function(t) {
                t.confirm && a.setData({
                    weight: ""
                });
            }
        }) : a.setData({
            weight: e
        });
    },
    getAge: function(t) {
        var a = this, e = t.detail.value;
        e >= 100 ? wx.showModal({
            title: "提示",
            content: "您宝刀未老啊",
            showCancel: !1,
            success: function(t) {
                t.confirm && a.setData({
                    age: ""
                });
            }
        }) : e > 0 && e < 18 ? wx.showModal({
            title: "提示",
            content: "您太小了",
            showCancel: !1,
            success: function(t) {
                t.confirm && a.setData({
                    age: ""
                });
            }
        }) : "" == e ? a.setData({
            age: ""
        }) : e <= 0 ? wx.showModal({
            title: "提示",
            content: "输入有误",
            showCancel: !1,
            success: function(t) {
                t.confirm && a.setData({
                    age: ""
                });
            }
        }) : a.setData({
            age: e
        });
    },
    pickGirl: function(t) {
        var a = t.currentTarget.dataset.girl;
        this.setData({
            pickGirl: a
        });
    },
    pickTrait: function(t) {
        var a = this, e = t.currentTarget.dataset.trait, i = t.currentTarget.dataset.bgc, n = a.data.traitArr;
        if (!n.some(function(t) {
            return t.trait == e;
        })) {
            var o = n.findIndex(function(t) {
                return "" == t.trait;
            }), s = {
                bg: i,
                trait: e
            };
            n.splice(o, 1, s);
            for (var r = 0; r < n.length; r++) "" != n[r].bg && "" != n[r].trait && a.setData({
                trait1: n[0].trait,
                trait1Bg: n[0].bg,
                trait2: n[1].trait,
                trait2Bg: n[1].bg,
                trait3: n[2].trait,
                trait3Bg: n[2].bg,
                trait4: n[3].trait,
                trait4Bg: n[3].bg
            });
            "颜值" == e && a.setData({
                temTrait1: !0
            }), "身材" == e && a.setData({
                temTrait2: !0
            }), "性格" == e && a.setData({
                temTrait3: !0
            }), "能力" == e && a.setData({
                temTrait4: !0
            });
        }
    },
    closeTrait: function(a) {
        var e = this, i = e.data.traitArr;
        console.log(i);
        var n = a.currentTarget.dataset.trait;
        if ("" != n) {
            var o, s = i.findIndex(function(t) {
                return t.trait == n;
            });
            i.splice(s, 1, {
                bg: "",
                trait: ""
            });
            var r = "trait" + (s + 1), c = "trait" + (s + 1) + "Bg";
            console.log(i, s, r), e.setData((o = {}, t(o, r, ""), t(o, c, ""), o)), "颜值" == n && e.setData({
                temTrait1: !1
            }), "身材" == n && e.setData({
                temTrait2: !1
            }), "性格" == n && e.setData({
                temTrait3: !1
            }), "能力" == n && e.setData({
                temTrait4: !1
            });
        }
    },
    pickLove: function(t) {
        this.setData({
            love: t.currentTarget.dataset.love
        });
    },
    getCanvas: function() {
        var t = this, a = this.data.height, e = this.data.weight, i = this.data.age, n = this.data.pickGirl, o = this.data.traitArr, s = this.data.trait1, r = this.data.trait2, c = this.data.trait3, l = this.data.trait4, h = this.data.love;
        "" != a && "" != e && "" != i ? "" == n ? wx.showModal({
            title: "提示",
            content: "第二题未选择",
            showCancel: !1,
            success: function(t) {
                t.confirm;
            }
        }) : "" == s || "" == r || "" == c || "" == l ? wx.showModal({
            title: "提示",
            content: "第三题未完成",
            showCancel: !1,
            success: function(t) {
                t.confirm;
            }
        }) : "" == h ? wx.showModal({
            title: "提示",
            content: "第四题未选择",
            showCancel: !1,
            success: function(t) {
                t.confirm;
            }
        }) : (console.log("画图"), t.setData({
            loading: !1
        }), setTimeout(function() {
            t.setData({
                loading: !0
            }), wx.navigateTo({
                url: "/pages/wife/wife?height=" + a + "&weight=" + e + "&age=" + i + "&pickGirl=" + n + "&traitArr=" + JSON.stringify(o) + "&love=" + h
            });
        }, 2e3)) : "" == a ? wx.showModal({
            title: "提示",
            content: "身高未填写",
            showCancel: !1,
            success: function(t) {
                t.confirm;
            }
        }) : "" == e ? wx.showModal({
            title: "提示",
            content: "体重未填写",
            showCancel: !1,
            success: function(t) {
                t.confirm;
            }
        }) : "" == i && wx.showModal({
            title: "提示",
            content: "年龄未填写",
            showCancel: !1,
            success: function(t) {
                t.confirm;
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return {
            title: this.data.nickName + "最理想的女友居然是这样的,你呢?",
            imageUrl: "",
            path: "/pages/index/index"
        };
    }
});

在这里插入图片描述
怎样设计一个漂亮的UI界面,以下是设计方法
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值