const Parse = getApp().Parse;
const company = getApp().globalData.company;
var Nova = getApp().Nova;
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        options: null,
        bgColor: {
            type: String,
            value: "#009de1",
        },
        active: {
            type: Number,
            value: 0,
        },
        bg: {
            type: String,
            value: "",
        },
    },

    /**
     * 组件的初始数据
     */
    data: {
        cells: [{
            name: "邀请开店",
            image: "",
            url: "/nova-shop/pages/nova-shopadmin/pages/index",
        }, ],
        orders: [{
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/48v41b053445.png",
                title: "待付款",
                url: "/nova-shop/pages/myOrder/index?status=100",
            },
            {
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/b1ct81053443.png",
                title: "待发货",
                url: "/nova-shop/pages/myOrder/index?status=200",
            },
            {
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/i5dhua053443.png",
                title: "待收货",
                url: "/nova-shop/pages/myOrder/index?status=300",
            },
            {
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/391obv053444.png",
                title: "待评价",
                url: "/nova-shop/pages/myOrder/index?status=700",
            },
            {
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/m7oco1053444.png",
                title: "售后",
                url: "/nova-shop/pages/myOrder/afterSale/index",
            },
        ],

        orders_4: [{
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/4v1m71045125.png",
                title: "已付款",
                url: "/nova-shop/pages/myOrder/index?status=100",
            },
            {
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/539a1i045125.png",
                title: "待发货",
                url: "/nova-shop/pages/myOrder/index?status=200",
            },
            {
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/kso4ii045126.png",
                title: "待收货",
                url: "/nova-shop/pages/myOrder/index?status=300",
            },
            {
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/31l4d1045125.png",
                title: "评价",
                url: "/nova-shop/pages/myOrder/index?status=700",
            },
            {
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/bau13p045126.png",
                title: "退货/售后",
                url: "/nova-shop/pages/myOrder/afterSale/index",
            },
        ],
        orders_5: [{
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/9tir12041446.png",
                title: "已付款",
                url: "/nova-shop/pages/myOrder/index?status=100",
            },
            {
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/f1ufod041446.png",
                title: "待发货",
                url: "/nova-shop/pages/myOrder/index?status=200",
            },
            {
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/d724j1041447.png",
                title: "待收货",
                url: "/nova-shop/pages/myOrder/index?status=300",
            },
            {
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/f1ca9l041446.png",
                title: "评价",
                url: "/nova-shop/pages/myOrder/index?status=700",
            },
            {
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/ikpa11041447.png",
                title: "退货/售后",
                url: "/nova-shop/pages/myOrder/afterSale/index",
            },
        ],
        brandShop: [{
                id: 1111,
                image: "https://file-cloud.fmode.cn/lb486SzXLP/20211207/gq1rq8091433.png",
                txt: "待付款",
                url: "/nova-shop/pages/myOrder/index?status=100",
            },
            {
                id: 2222,
                image: "https://file-cloud.fmode.cn/lb486SzXLP/20211207/44pj91091432.png",
                txt: "待发货",
                url: "/nova-shop/pages/myOrder/index?status=200",
            },
            {
                id: 3333,
                image: "https://file-cloud.fmode.cn/lb486SzXLP/20211207/2gm0os091432.png",
                txt: "待收货",
                url: "/nova-shop/pages/myOrder/index?status=300",
            },
            {
                id: 4444,
                image: "https://file-cloud.fmode.cn/lb486SzXLP/20211207/f12m5m091433.png",
                txt: "待评价",
                url: "/nova-shop/pages/myOrder/index?status=700",
            },
            {
                id: 5555,
                image: "https://file-cloud.fmode.cn/lb486SzXLP/20211207/uh105n091433.png",
                txt: "退换/售后",
                url: "/nova-shop/pages/myOrder/afterSale/index",
            },
        ],

        brShop: [{
                id: 1111,
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/hqi7h1044726.png",
                txt: "待付款",
                url: "/nova-shop/pages/myOrder/index?status=100",
            },
            {
                id: 2222,
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/e3se1t044727.png",
                txt: "待发货",
                url: "/nova-shop/pages/myOrder/index?status=200",
            },
            {
                id: 3333,
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/smnh1b044727.png",
                txt: "待收货",
                url: "/nova-shop/pages/myOrder/index?status=300",
            },
            {
                id: 4444,
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/m1ui91044727.png",
                txt: "待评价",
                url: "/nova-shop/pages/myOrder/index?status=700",
            },
            {
                id: 5555,
                image: "https://file-cloud.fmode.cn/nCCirOU5zn/20211215/4j5u1q044726.png",
                txt: "退换/售后",
                url: "/nova-shop/pages/myOrder/afterSale/index",
            },
        ],
    },
    ready: function() {
        this.getUser();
        this.getAccount();
    },
    /**
     * 组件的方法列表
     */
    methods: {
        async getUser() {
            let _user = new Parse.Query("_User");
            if (Parse.User.current() && Parse.User.current().id) {
                let user = await _user.get(Parse.User.current().id);
                console.log(user);
                this.setData({
                    user: user.toJSON(),
                });
            }
        },

        async getAccount() {
            if (Parse.User.current() && Parse.User.current().id) {
                let uid = Parse.User.current().id;
                let account = new Parse.Query("Account");
                account.equalTo("user", uid);
                let res = await account.first();
                if (res && res.id) {
                    console.log(res.toJSON());
                    let account = res.toJSON()
                    account.balance = account.balance ? Number(account.balance.toFixed(2)) : 0
                    account.credit = account.credit ? Number(account.credit.toFixed(2)) : 0
                    this.setData({
                        account: account,
                    });
                }
            }
        },

        _toEdit() {
            console.log("edit");
        },

        goNovaURL: function(ev) {
            console.log(ev)
            let url = ev.currentTarget.dataset.url;
            Nova.goNovaURL(url);
        },
        toVIP() {
            wx.navigateTo({
                url: '/nova-shop/pages/vip/index',
            });
        },
        cellClick() {
            // wx.showToast({
            //     title: "功能开发中,尽请期待",
            //     icon: "none",
            // });
            wx.navigateTo({
                url: '/nova-shop/pages/coupons/index',
            });

        },
        sign() {
            wx.navigateTo({
                url: '/nova-common/pages/daily-check/index',
            });
        },
        coupons() {
            wx.navigateTo({
                url: '',
            });
        },
    },
});