123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- var user = require('../../../services/user.js');
- var app = getApp();
- Page({
- data: {
- unPayNum:0,
- unTakeNum:0,
- unEvalNum:0,
- userInfo: {},
- curUser:{},
- isQueryCrossQuotal: null
- },
- onLoad: function (options) {
- // 页面初始化 options为页面跳转所带来的参数
- let that = this;
- },
- onReady: function () {
- },
- onShow: function () {
- let that = this;
- let userInfo = wx.getStorageSync('userInfo');
- let token = wx.getStorageSync('token');
- if (wx.getStorageSync('storeId')) {
- util.request(api.ChooseStoreId, {
- storeId: wx.getStorageSync('storeId'),
- merchSn: wx.getStorageSync('merchSn'),
- isRefusedLogin: wx.getStorageSync('isRefusedLogin')
- }, 'POST').then(function (res) {
- if (res.errno === 0) {
- wx.setStorageSync('storeId', wx.getStorageSync('storeId'));
- wx.setStorageSync('merchSn', wx.getStorageSync('merchSn'));
- }
- });
- }
- if(userInfo){
- app.globalData.userInfo = userInfo;
- this.setData({
- userInfo: app.globalData.userInfo,
- });
- }else{
- app.globalData.userInfo = {
- nickName: '点击头像登录',
- avatarUrl: 'http://120.76.26.84:80/group1/M00/00/02/rBJEdVvr3_eAJe0WAAAB_us54MA728.png'
- };
- this.setData({
- userInfo: app.globalData.userInfo,
- });
- }
- if (token) {
- app.globalData.token = token;
- }
- // 页面显示
- if (userInfo && token) {
- util.request(api.getCurUser, {
- userInfo: app.globalData.userInfo
- }, 'POST').then(function (res) {
- if (res.errno === 0) {
- that.setData({
- curUser: res.data
- });
- }
- });
- // 根据用户信息查询订单信息
- util.request(api.UcenterIndex, {}).then(function (res) {
- if (res.errno === 0) {
- that.setData({
- isQueryCrossQuotal: res.data.countMap.isQueryCrossQuotal
- });
- if (res.data.countMap.orders > 0) {
- that.setData({
- unPayNum: res.data.countMap.unPayNum,
- unPaymentNum: res.data.countMap.unPaymentNum,
- unTakeNum: res.data.countMap.unTakeNum,
- unEvalNum: res.data.countMap.unEvalNum,
- isQueryCrossQuotal: res.data.countMap.isQueryCrossQuotal
- });
- console.log(res.data.countMap.isQueryCrossQuotal)
- }
- }
- });
- if (wx.getStorageSync('storeId') && wx.getStorageSync('merchSn')){
- that.reLoad();
- }
- } else {
- // console.log('拒绝授权:' + wx.getStorageSync('isRefusedLogin'))
- // if (wx.getStorageSync('isRefusedLogin') != 'true') {
- // wx.navigateTo({
- // url: '/pages/auth/btnAuth/btnAuth',
- // })
- // }
- }
- },
- onHide: function () {
- // 页面隐藏
- },
- onUnload: function () {
- // 页面关闭
- },
- reLoad: function () {
- let that = this;
- if (wx.getStorageSync('storeId')) {
- if (wx.getStorageSync('userId')) {
- wx.request({
- url: api.updateLoginUser,
- data: {
- userId: wx.getStorageSync('userId'), storeId: wx.getStorageSync('storeId'), merchSn: wx.getStorageSync('merchSn')
- },
- method: 'POST',
- header: {
- 'Content-Type': 'application/json'
- },
- success: function (wxRes) {
- if (wxRes.data.errno === 0) {
- // console.log("用户信息更新成功");
- }
- },
- fail: function (err) {
- console.log("failed");
- }
- });
- }
- }
- },
- bindMobile:function(){
- wx.navigateTo({
- url: '../../auth/newuser/newuser'
- })
- },
- // goLogin(){
- // user.loginByWeixin().then(res => {
- // this.setData({
- // userInfo: res.data.data.userInfo
- // });
- // app.globalData.userInfo = res.data.data.userInfo;
- // app.globalData.token = res.data.token;
- // }).catch((err) => {
- // console.log(err)
- // });
- // },
- allOrder() {
- let userInfo = wx.getStorageSync('userInfo');
- let token = wx.getStorageSync('token');
- if (userInfo && token) {
- wx.navigateTo({
- url: '/pages/ucenter/order/order'
- })
- }else{
- util.showErrorToast('请先登录');
- return false;
- }
- },
- checkUnNum(e){
- console.log(e.currentTarget.dataset.index)
- let userInfo = wx.getStorageSync('userInfo');
- let token = wx.getStorageSync('token');
- if (userInfo && token) {
- wx.navigateTo({
- url: '/pages/ucenter/order/order?tabIndex=' + e.currentTarget.dataset.index
- })
- } else {
- util.showErrorToast('请先登录');
- return false;
- }
- },
- exitLogin: function () {
- var that = this;
- wx.showModal({
- title: '',
- confirmColor: '#b4282d',
- content: '退出登录?',
- success: function (res) {
- if (res.confirm) {
- wx.removeStorageSync('token');
- wx.removeStorageSync('userInfo');
- wx.removeStorageSync('isRefusedLogin');
- that.setData({
- unPayNum: 0,
- unPaymentNum: 0,
- unTakeNum: 0,
- unEvalNum: 0
- });
- app.globalData.userInfo = {
- nickName: '点击头像登录',
- avatarUrl: 'http://120.76.26.84:80/group1/M00/00/02/rBJEdVvr3_eAJe0WAAAB_us54MA728.png'
- };
- wx.switchTab({
- url: '/pages/index/index'
- });
- }
- }
- })
- },
- loginUser() {
- wx.navigateTo({
- url: '/pages/ucenter/userLogin/userLogin'
- })
- },
- checkCouponLogin() {
- let userInfo = wx.getStorageSync('userInfo');
- let token = wx.getStorageSync('token');
- if (userInfo && token) {
- wx.navigateTo({
- url: '/pages/ucenter/coupon/coupon'
- })
- } else {
- util.showErrorToast('请先登录');
- return false;
- }
- },
- checkCollectLogin() {
- let userInfo = wx.getStorageSync('userInfo');
- let token = wx.getStorageSync('token');
- if (userInfo && token) {
- wx.navigateTo({
- url: '/pages/ucenter/collect/collect'
- })
- } else {
- util.showErrorToast('请先登录');
- return false;
- }
- },
- checkFootLogin() {
- let userInfo = wx.getStorageSync('userInfo');
- let token = wx.getStorageSync('token');
- if (userInfo && token) {
- wx.navigateTo({
- url: '/pages/ucenter/footprint/footprint'
- })
- } else {
- util.showErrorToast('请先登录');
- return false;
- }
- },
- checkAddressLogin() {
- let userInfo = wx.getStorageSync('userInfo');
- let token = wx.getStorageSync('token');
- if (userInfo && token) {
- wx.navigateTo({
- url: '/pages/ucenter/address/address'
- })
- } else {
- util.showErrorToast('请先登录');
- return false;
- }
- },
- checkCardLogin() {
- let userInfo = wx.getStorageSync('userInfo');
- let token = wx.getStorageSync('token');
- if (userInfo && token) {
- wx.navigateTo({
- url: '/pages/ucenter/idCard/idCard'
- })
- } else {
- util.showErrorToast('请先登录');
- return false;
- }
- },
- checkFeedLogin() {
- let userInfo = wx.getStorageSync('userInfo');
- let token = wx.getStorageSync('token');
- if (userInfo && token) {
- wx.navigateTo({
- url: '/pages/ucenter/feedback/feedback'
- })
- } else {
- util.showErrorToast('请先登录');
- return false;
- }
- },
- crossBoundaryQuotaQuery() {
- let that = this;
- let userInfo = wx.getStorageSync('userInfo');
- let token = wx.getStorageSync('token');
- if (userInfo && token) {
- if(that.data.curUser.idNo){
- wx.navigateTo({
- url: '/pages/ucenter/crossBoundaryQuotaQuery/crossBoundaryQuotaQuery'
- })
- }else{
- util.showErrorToast('请先实名认证');
- return false;
- }
- } else {
- util.showErrorToast('请先登录');
- return false;
- }
- },
- })
|