求大佬们帮忙,邀请好友一起参加抽签活动,好友点击后一直卡在加载页面?
发布于 4 年前 作者 tianli 4313 次浏览 来自 官方Issues

问题显示如下,手机上体验版邀请好友参加,好友会一直卡在这个加载页面

求大佬们帮帮忙。源码如下

import tools from "../../tools/tools";

var t = getApp();

Page({
    data: {
        canIUse: wx.canIUse("button.open-type.getUserInfo"),
        loadingHidden: !0,
        chouqed:true,
        animationData: {},
        showResult1,
        showComfirm: !1,
        drawlotsId0,
        title"",
        dttitle"",
        drawlotsResult: {},
        detailnull
    },
    onLoadfunction (option{
        var that = this,
            a = option.drawlotsId || 0;
        t.onGetOpenid().then(function (resOpenid{
            that.getDrawlots(a);
        });
        var n = wx.createAnimation({
            duration250,
            timingFunction"ease"
        });
        that.animation = n, that.setData({
            drawlotsId: a,
            loadingHidden: !1
        });
    },
    onReadyfunction () {},
    onShowfunction () {
        let that = this;
        t.onGetOpenid().then(function (resOpenid{
            that.getDrawlots(that.data.drawlotsId)
        });
    },
    onHidefunction () {},
    onUnloadfunction () {},
    onPullDownRefreshfunction () {},
    onReachBottomfunction () {},
    onShareAppMessagefunction (t{},
    bindDraw: tools.debounce(function (e{
        let that = this;
        var o = that.data.drawlotsId;

        let userinfo = t.globalData.userInfo;
        if (!userinfo.username) {
            that.setData({
                showComfirm: !0
            });
            return false;
        }else{
            console.log("666")
            that.setData({
                chouqedfalse,
                loadingHidden:false
            });
        }
        that.doDrawlots(o)
    }),
    getDrawlotsfunction (o{
        let that = this;
        const db = wx.cloud.database()
        // 查询当前用户所有的 chouqianList
        db.collection('chouqianList').where({
            _id: o
        }).get({
            successres => {
                let title = res.data[0].title;
                that.setData({
                    detail: res.data[0].detail,
                });
                let object = res.data[0].detail.find(v => {
                    return v.openid === t.globalData.openid;
                });
                if (!object) { // 不存在可抽签
                    let kongopenid = res.data[0].detail.find(v => {
                        return v.openid == "" || v.openid == undefined;
                    });
                    if (!kongopenid) { // 都有openid
                        that.setData({
                            showResult: !0,
                            dttitle"抽签次数已用完",
                            loadingHidden: !0
                        });
                    } else {
                        that.setData({
                            title: title,
                            showResult:0,
                            loadingHidden: !0
                        });
                    }

                } else { // 已抽签
                    that.setData({
                        title: title,
                        showResult: !0,
                        drawlotsResult: object,
                        dttitle"你抽中了",
                        loadingHidden: !0
                    });
                }
                console.log('[数据库] [查询记录] 成功: ', res)
            },
            failerr => {
                wx.showToast({
                    icon'none',
                    title'查询记录失败'
                })
                console.error('[数据库] [查询记录] 失败:', err)
            }
        })
    },
    doDrawlotsfunction (o{
        var a = this;
        a.edchouqian().then(function (objectIndex// res 随机返回数组中某个对象的index字段
            for (let j = 0; j < a.data.detail.length; j++) {
                if (a.data.detail[j].index === objectIndex) {
                    a.data.detail[j].openid = t.globalData.openid;
                    a.data.detail[j].username = t.globalData.userInfo.username;
                    a.data.detail[j].icon = t.globalData.userInfo.icon;
                }

            }
            const db = wx.cloud.database()
            db.collection('chouqianList').doc(a.data.drawlotsId).update({
                data: {
                    detail: a.data.detail
                },
                successres => {
                    a.getDrawlots(a.data.drawlotsId)
                },
                failerr => {
                    icon'none',
                    console.error('[数据库] [更新记录] 失败:', err)
                }
            })
        })

    },
    // 递归判断是否已经抽签
    edchouqian() {
        let that = this;
        return new Promise(function (n, s{
            const db = wx.cloud.database()
            // 查询当前用户所有的 chouqianList
            db.collection('chouqianList').where({
                _id: that.data.drawlotsId
            }).get({
                successres => {
                    that.setData({
                        detail: res.data[0].detail,
                    });
                    let nullDetail = res.data[0].detail.filter(item => item.openid == "");
                    let arrIndex = Math.floor((Math.random() * nullDetail.length));
                    let objindex = nullDetail[arrIndex].index;
                    n(objindex)
                },
                failerr => {

                    wx.showToast({
                        icon'none',
                        title'查询记录失败'
                    })
                    console.error('[数据库] [查询记录] 失败:', err);
                    s(err);
                }
            })

        });

    },
    clickCancelComfirmfunction (t{
        this.setData({
            showComfirm: !1
        });
    },
    bindGetUserInfofunction () {
        let that = this;
        wx.getUserProfile({
            desc'我们需要获取您的用户信息',
            lang:'zh_CN',
            successfunction (res{
                t.globalData.userInfo.username = res.userInfo.nickName;
                t.globalData.userInfo.icon = res.userInfo.avatarUrl;
                that.setData({
                    showComfirm: !1
                });
            },
            failfunction (error{
                console.log(error);
            }
        })
    },
    bindDetailfunction (t{
        var o = this.data.drawlotsId;
        wx.navigateTo({
            url"../user/detail/detail?drawlotsId=" + o
        });
    },
    bindToHomefunction (t{
        wx.switchTab({
            url"../index/index"
        });
    }
});
回到顶部