slimming.js 3.95 KB
var e = getApp(), os = e.globalData.setting;
var utils = require('../../../../utils/util.js');
var regeneratorRuntime = require('../../../../utils/runtime.js');

Page({
    /**
     * 页面的初始数据
     */
    data: {

        userInfo:null,
        iurl: os.imghost,
        portrait_list: [],
        loading: 0,
        portrait_req: {},
        industry:'',
        is_get:0
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that=this;

        this.setData({
            userInfo: getApp().globalData.userInfo
        })


        getApp().getConfig(function (e){
            that.init_data();
        })


    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: async function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    init_data() {

        let userInfo = getApp().globalData.userInfo;
        var portrait_req = {
            ApiName:'api.slimming.member.portrait',
            store_id: userInfo.store_id,
            //StaffId: that.idd,
            vipid: userInfo.erpvipid,
        };
        this.get_service_portrait(portrait_req);
    },


    get_service_portrait(portrait_req) {

        //var str='{"code":0,"msg":"操作成功!","data":[{"id":"a1ff01bc-b755-4a5c-8675-06b33354d5ec","customerno":"18650904780","customername":"心如水","sex":"女","mobiletel":"18650904780","birthday":"2000-11-23","age":22,"signingdate":"2022-11-22","weightlosscourse":4,"shapecourse":3,"weight":62,"targetweight":30,"subtracted":26,"advisername":"泉州万达纪莉(工号:07)","beautyconsultant":"泉州万达纪莉(工号:07)","diffweight":24,"minweight":100,"ideaweight":92,"tostoreqty":3,"dayweight":102,"previousweight":100,"lastweight":102,"actualweight":22,"ringratioweight":2,"undeduced":10,"standardweight":98}]}';
        //var res=JSON.parse(str);
        //this.setData({portrait_list: res.data});
        //return false;
        var that = this;
        if (that.loading) {
            return false;
        }
        that.loading = 1;

        if (portrait_req) {
            that.setData({
                noMore: false,
                portrait_list: [],
                is_get: 0,
                noMore: false
            })

        } else {
            if (that.noMore) {
                that.loading = 0;
                return false;
            }
            portrait_req = that.portrait_req; //如果不是全选的参数,就是page分页+1
            portrait_req.page++;
        }

        //请求参数进行存储
        that.portrait_req = portrait_req;
        wx.showLoading({
            title: '加载中'
        });

        console.log(getApp().globalData.config,1111);


        var url = '/api/weshop/delphiapi/pageErpApi?accdb='+getApp().globalData.config.erpid;
        getApp().request.promiseGet(url, {
            data: portrait_req
        })
            .then((res) => {
                wx.hideLoading();
                that.loading = 0;

                that.setData({is_get: 1})

                if (res.data.code == 0 && res.data.data  && res.data.data.pageData && res.data.data.pageData.length) {

                    var list=res.data.data.pageData;

                    list[0].weight = list[0].weight * 2
                    if (list[0].tostoreqty == 0) {
                        list[0].undeduced = list[0].undeduced + list[0].actualweight
                        list[0].actualweight = 0
                        list[0].ringratioweight = 0

                    } else if (list[0].tostoreqty == 1) {
                        list[0].ringratioweight = 0
                    }

                    that.setData({portrait_list: list})

                } else {
                    that.setData({
                        noMore:true
                    })
                }
            });
    },

    goto:function (e){
       var url=e.currentTarget.dataset.url;
       getApp().goto(url);
    }


})