123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- var util = require('../../../../utils/util.js');
- var api = require('../../../../config/api.js');
- var user = require('../../../../utils/user.js');
- var app = getApp();
- Page({
- data: {
- userInfo: {
- nickName: '点击登录',
- avatarUrl: '/static/images/new/icon-user.png',
- isDis: false
- },
- order: {
- unpaid: 0,
- unship: 0,
- unrecv: 0,
- uncomment: 0
- },
- hasLogin: false,
- isdis: false, //是否分销员
- issign: true, //是否注册完成了信息,
- isMember: false, //是否是会员
- },
- onLoad: function (options) {
- // 页面初始化 options为页面跳转所带来的参数
- },
- onReady: function () {},
- goReferee() {
- if (this.data.hasLogin) {
- wx.navigateTo({
- url: "/pages/referee/index"
- });
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- }
- },
- onShow: function () {
- console.info(app.globalData.hasLogin);
- //获取用户的登录信息
- if (app.globalData.hasLogin) {
- let userInfo = wx.getStorageSync('userInfo');
- //console.info(userInfo);
- this.setData({
- userInfo: userInfo,
- hasLogin: true
- });
- app.globalData.userInfo = userInfo;
- //console.log(app.globalData.hasLogin);
- //console.log(userInfo);
- let that = this;
- util.request(api.UserIndex).then(function (res) {
- if (res.errno === 0) {
- console.log(res);
- that.setData({
- collectCount: res.data.collectCount,
- couponCount: res.data.couponCount,
- order: res.data.order,
- isdis: res.data.isdis,
- issign: res.data.issign,
- isMember: res.data.level == '1' ? true : false,
- });
- app.globalData.isMember = (res.data.level == '1' ? true : false);
- }
- });
- }
- },
- onHide: function () {
- // 页面隐藏
- },
- onUnload: function () {
- // 页面关闭
- },
- goAftersaleList() {
- console.log('来了');
- if (this.data.hasLogin) {
- wx.navigateTo({
- url: "/pages/ucenter/aftersaleList/aftersaleList"
- });
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- }
- },
- goLogin() {
- if (!this.data.hasLogin) {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- }
- },
- goOrder() {
- if (this.data.hasLogin) {
- try {
- wx.setStorageSync('tab', 0);
- } catch (e) {
- }
- wx.navigateTo({
- url: "/pages/ucenter/order/order",
- });
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- }
- },
- goOrderIndex(e) {
- if (this.data.hasLogin) {
- let tab = e.currentTarget.dataset.index
- let route = e.currentTarget.dataset.route
- try {
- wx.setStorageSync('tab', tab);
- } catch (e) {
- }
- wx.navigateTo({
- url: route,
- success: function (res) {},
- fail: function (res) {},
- complete: function (res) {},
- })
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- };
- },
- goSign() {
- wx.navigateTo({
- url: "/pages/ucenter/parter/sign/index"
- });
- },
- goStar() {
- if (this.data.hasLogin) {
- if (this.data.isdis) {
- let url = "/pages/ucenter/parter/index";
- // if(!this.data.isnid)//是否实名过
- // url="/pages/auth/register/register";
- //跳转
- wx.navigateTo({
- url: url
- });
- } else {
- wx.navigateTo({
- url: "/pages/ucenter/parter/join/joinapply"
- });
- }
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- };
- },
- goCoupon() {
- if (this.data.hasLogin) {
- wx.navigateTo({
- url: "/pages/ucenter/couponList/couponList"
- });
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- };
- },
- goGroupon() {
- if (this.data.hasLogin) {
- wx.navigateTo({
- url: "/pages/groupon/myGroupon/myGroupon"
- });
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- };
- },
- goCollect() {
- if (this.data.hasLogin) {
- wx.navigateTo({
- url: "/pages/ucenter/collect/collect"
- });
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- };
- },
- goFeedback(e) {
- if (this.data.hasLogin) {
- wx.navigateTo({
- url: "/pages/ucenter/feedback/feedback"
- });
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- };
- },
- goRegistr() {
- if (this.data.hasLogin) {
- wx.navigateTo({
- url: "/pages/auth/register/register"
- });
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- };
- },
- goFootprint() {
- if (this.data.hasLogin) {
- wx.navigateTo({
- url: "/pages/ucenter/footprint/footprint"
- });
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- };
- },
- goAddress() {
- if (this.data.hasLogin) {
- wx.navigateTo({
- url: "/pages/ucenter/address/address"
- });
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- };
- },
- wxLogin: function () {
- let that = this;
- console.log();
- wx.getUserProfile({
- desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
- success: (res) => {
- console.log(res);
- let e = res;
- if (e.userInfo == null) {
- wx.showToast({
- title: '未授权,无法完善信息',
- icon: 'success',
- duration: 3000
- });
- return;
- }
- e.userInfo.encryptedData = e.encryptedData;
- user.loginByWeixin(e.userInfo).then(function (res) {
- app.globalData.userInfo=res.data.userInfo;
- wx.setStorageSync('userInfo', res.data.userInfo);
- that.setData({
- issign: true,
- userInfo:res.data.userInfo
- })
-
- wx.showToast({
- title: '信息完善成功',
- icon: 'success',
- duration: 3000
- });
- }).catch((err) => {
- console.info(err);
- wx.showToast({
- title: '请求失败,稍后再试',
- icon: 'success',
- duration: 3000
- });
- });
- }
- })
- },
- goAfterSale: function () {
- if (this.data.hasLogin) {
- wx.navigateTo({
- url: "/pages/ucenter/aftersaleList/aftersaleList"
- });
- } else {
- wx.navigateTo({
- url: "/pages/auth/login/login"
- });
- };
- },
- aboutUs: function () {
- wx.navigateTo({
- url: '/pages/ucenter/about/about'
- });
- },
- goHelp: function () {
- wx.navigateTo({
- url: '/pages/ucenter/help/help'
- });
- },
- createQrcode: function () { //二维码生成
- util.request(api.QrCodeCreate, {
- path: '/pages/index/index'
- }, 'POST').then(function (res) {
- console.log(res);
- wx.previewImage({
- current: res.data.imgUrl, // 当前显示图片的http链接
- urls: [res.data.imgUrl] // 需要预览的图片http链接列表
- })
- });
- },
- exitLogin: function () {
- wx.showModal({
- title: '',
- confirmColor: '#b4282d',
- content: '退出登录?',
- success: function (res) {
- if (!res.confirm) {
- return;
- }
- util.request(api.AuthLogout, {}, 'POST');
- app.globalData={};
- wx.removeStorageSync('token');
- wx.removeStorageSync('userInfo');
- wx.reLaunch({
- url: '/pages/tabBar/ucenter/index/index'
- });
- // wx.reLaunch({
- // url: '/pages/index/index'
- // });
- }
- })
- },
- goMemberCenter() {
- wx.navigateTo({
- url: "/pages/member/memberCenter/memberCenter"
- });
- },
- goBuyMember() {
- wx.navigateTo({
- url: "/pages/member/buyMember/buyMember"
- });
- },
- })
|