index.js 2.84 KB
// pages/tab/mine/index.js
import commonApi from "~/api/module/common";
import { ToolList } from "~/constants/index";
Page({
  /**
   * 页面的初始数据
   */
  data: {
    navStyle: "background-color: transparent;",
    scoreSummary: {
      currentScore: "-", //当前积分
      bankCardSize: "-",
      totalGoodExchangeScore: "-", //累计兑换积分
      totalRewardScore: "-", //累计收益积分
      totalWithdrawalScore: "-", //累计提现积分
    },
    toolList: ToolList,
    guideList: [
      {
        key: "currentScore",
        leftIcon: "logo",
      },
      {
        key: "bankCardSize",
        text: "银行卡",
      },
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let userInfo = wx.p.storage.get("userInfo");
    this.setData({
      userInfo,
    });
    this.searchScoreSummaryData();
    // this.getMemberCardData();
  },
  searchScoreSummaryData() {
    const {
      phone,
      channelSource,
      merchantId
    } = this.data.userInfo
    wx.p.api.withdrawalApi.searchScoreSummary({
      staffPhone:phone,
      merchantId,
      channelSource //1.阳光激励 2.续保用户 3.管理层
    }).then(res => {
      if (res.code == 0) {
        this.setData({
          scoreSummary: res.data
        })
      }

    }).catch((err) => {
      wx.p.wxApi.showToast(JSON.stringify(err))
    })
  },
  go(e) {
    console.log(e);
    const {
      currentScore,
    } = this.data.scoreSummary;
    let { index } = e.currentTarget.dataset;
    let arr = [
      () => {
        wx.p.router.go("/packageIndex/pages/integral/index/index");
      },
      () => {
        wx.p.router.go("/packageIndex/pages/bankAccount/list/list",{
          score: currentScore
        });
      },
    ];
    arr[index]();
  },
  navbarReady(e) {
    let { height } = e.detail;
    this.setData({
      navHeight: height,
    });
  },
  login() {
    wx.p.router.go("/pages/Login/Login");
  },
  goSetUp() {
    wx.p.router.go("/packageMine/pages/setting/index");
  },
  jump(e) {
    const { url } = e.currentTarget.dataset;
    wx.p.router.go(url);
  },
  // 切换门店
  changeMerchant() {
    // 获取门店接口 门店数量大于1跳转切换,否则不需切换
    let { userInfo } = this.data;
    commonApi
      .getMerchantData({
        staffPhone: userInfo?.phone,
        channelSource: userInfo?.channelSource,
      })
      .then((res) => {
        let { code, data, message } = res;
        if (code == 0) {
          if (data?.length > 1) {
            wx.p.router.go("/pages/chooseMerchant/index", {
              loginData: userInfo,
              merchantList: data,
            });
          }
        } else {
          wx.p.wxApi.showToast(message);
        }
      });
  },
  onShow:function() {
    this.searchScoreSummaryData();
    // this.getOrderNumberList();
    // this.toCheckMember();
  },
});