myPoints.js 3.6 KB
"use strict";
var common_vendor = require("../../common/vendor.js");
var api_index = require("../../api/index.js");
require("../../utils/request.js");
if (!Array) {
  const _easycom_u_navbar2 = common_vendor.resolveComponent("u-navbar");
  _easycom_u_navbar2();
}
const _easycom_u_navbar = () => "../../uni_modules/uview-plus/components/u-navbar/u-navbar.js";
if (!Math) {
  _easycom_u_navbar();
}
const _sfc_main = {
  setup(__props) {
    common_vendor.onLoad((e) => {
      type.value = e.type;
      if (e.type == 0) {
        getyues();
        getMoneyDetails();
      } else {
        getMyScores();
        getScoreDetails();
      }
    });
    const toRecharge = () => {
      common_vendor.index.navigateTo({
        url: "/pages/mine/recharge"
      });
    };
    let integral = common_vendor.ref(0);
    let recordList = common_vendor.ref([]);
    let type = common_vendor.ref(0);
    const getyues = async () => {
      try {
        const res = await api_index.getyue();
        integral.value = res.money;
        common_vendor.index.setStorageSync("balance", res.money);
        console.log("getyue", res);
      } catch (err) {
        common_vendor.index.showToast({ title: err, icon: "none" });
        console.log("getyue", err);
      }
    };
    const getMoneyDetails = async () => {
      try {
        const res = await api_index.getMoneyDetail();
        recordList.value = res;
        console.log("getMoneyDetail", res);
      } catch (err) {
        common_vendor.index.showToast({ title: err, icon: "none" });
        console.log("getMoneyDetail", err);
      }
    };
    const getMyScores = async () => {
      try {
        const res = await api_index.getMyScore();
        integral.value = res.score;
        common_vendor.index.setStorageSync("myPoints", res.score);
        console.log("getMyScore", res);
      } catch (err) {
        common_vendor.index.showToast({ title: err, icon: "none" });
        console.log("getMyScore", err);
      }
    };
    const getScoreDetails = async () => {
      try {
        const res = await api_index.getScoreDetail();
        recordList.value = res;
        console.log("getScoreDetail", res);
      } catch (err) {
        common_vendor.index.showToast({ title: err, icon: "none" });
        console.log("getScoreDetail", err);
      }
    };
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.p({
          placeholder: true,
          title: common_vendor.unref(type) == 0 ? "\u6211\u7684\u4F59\u989D" : "\u6211\u7684\u79EF\u5206",
          bgColor: "#F6F8FA",
          autoBack: true
        }),
        b: common_vendor.t(common_vendor.unref(type) == 0 ? "\u4F59\u989D" : "\u79EF\u5206"),
        c: common_vendor.unref(type) == 0
      }, common_vendor.unref(type) == 0 ? {
        d: common_vendor.t(common_vendor.unref(integral)),
        e: common_vendor.o(toRecharge)
      } : {
        f: common_vendor.t(common_vendor.unref(integral))
      }, {
        g: common_vendor.t(common_vendor.unref(type) == 0 ? "\u4F59\u989D\u660E\u7EC6" : "\u79EF\u5206\u660E\u7EC6"),
        h: common_vendor.f(common_vendor.unref(recordList), (item, k0, i0) => {
          return {
            a: common_vendor.t(item.createtime),
            b: common_vendor.t(item.before * 1 - item.after * 1 > 0 ? "-" : "+"),
            c: common_vendor.t(common_vendor.unref(type) == 0 ? item.money : item.score),
            d: item.id
          };
        })
      });
    };
  }
};
var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/vue/\u5927\u5065\u5EB7\u5546\u57CE/healthMall/pages/mine/myPoints.vue"]]);
wx.createPage(MiniProgramPage);