Files
2024-08-22 12:53:28 +08:00

134 lines
3.8 KiB
JavaScript

require("../../@babel/runtime/helpers/Arrayincludes");
var e = getApp();
Page({
data: {
isadmin: !1,
isLogin: !1,
nocancel: !1,
showCodeImg: !0,
qrcode: "",
qrcodeTitle: "",
userInfo: {},
orderCount: {},
sh: !1,
yu: "00.00"
},
onLoad: function(e) {
var t = wx.getStorageSync("storedata");
t && (console.log(t), this.setData({
sh: t.sh
})), this.getqian();
},
cancel: function() {
this.setData({
showCodeImg: !0
});
},
confirm: function() {
this.setData({
showCodeImg: !0
});
},
onShow: function() {
if (this.setData({
isLogin: e.checkIsLogin()
}), this.data.isLogin) {
var t = wx.getStorageSync("phone"), n = wx.getStorageSync("storedata");
if (!t && n.sh) return void wx.navigateTo({
url: "../phone/phone"
});
this.getUserDetail(), this.getqian();
}
},
getUserDetail: function() {
var t = this, n = wx.getStorageSync("values");
e._get("user.index/detail", {}, function(e) {
t.setData(e.data), "" != e.data.userInfo.phone && n.includes(e.data.userInfo.phone) && t.setData({
isadmin: !0
});
});
},
getCode: function(t) {
var n = this;
if (!n.onCheckLogin()) return !1;
n.setData({
qrcode: ""
});
var i = wx.getStorageSync("user_id"), o = t.currentTarget.dataset.type, a = "";
"a" == o || "b" == o ? a = "邀请经销商" : "c" == o && (a = "邀请分销商"), e._get("user.index/getCode", {
codeType: o,
uid: i
}, function(e) {
console.log(e), 1 == e.code && n.setData({
showCodeImg: !1,
qrcodeTitle: a,
qrcode: e.data.base64String.replace(/[\r\n]/g, "")
});
});
},
onTargetOrder: function(e) {
if (!this.onCheckLogin()) return !1;
wx.navigateTo({
url: {
all: "/pages/order/index?type=all",
payment: "/pages/order/index?type=payment",
delivery: "/pages/order/index?type=delivery",
received: "/pages/order/index?type=received"
}[e.currentTarget.dataset.type]
});
},
getqian: function() {
var t = this;
e._get("user/userqian", {}, function(e) {
t.setData({
yu: e.data.yu
});
});
},
ontx: function() {
if (!this.onCheckLogin()) return !1;
wx.navigateTo({
url: "/pages/user/tx"
});
},
ontxlist: function() {
if (!this.onCheckLogin()) return !1;
wx.navigateTo({
url: "/pages/user/txlist"
});
},
onyongjinjilu: function() {
if (!this.onCheckLogin()) return !1;
wx.navigateTo({
url: "/pages/user/onyongjinjilu"
});
},
onTargetDailiList: function(e) {
if (!this.onCheckLogin()) return !1;
wx.navigateTo({
url: "/pages/user/daililist"
});
},
onTargetYonghuList: function(e) {
if (!this.onCheckLogin()) return !1;
wx.navigateTo({
url: "/pages/user/yonghulist"
});
},
onTargetMenus: function(e) {
if (!this.onCheckLogin()) return !1;
wx.navigateTo({
url: "/" + e.currentTarget.dataset.url
});
},
onLogin: function() {
wx.navigateTo({
url: "../login/login"
});
},
onCheckLogin: function() {
return !!this.data.isLogin || (e.showError("很抱歉,您还没有登录"), !1);
}
});