From 1ad267ddc36d539ef0d2f2e5a26ca36a00cf37fd Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Tue, 12 Jan 2021 10:02:27 +0800 Subject: [PATCH] no message --- pages/api/article.js | 20 --------------- pages/api/moment.js | 50 +++++++++++++++++++++++++++++++++++++ pages/api/user.js | 2 +- pages/api/ztb.js | 20 +++++++++++++++ pages/article/list/index.js | 2 +- pages/home/index/index.js | 16 ++++++------ pages/index/index.js | 24 +++++++++++++++--- pages/login/index.js | 22 +++++++++++++--- 8 files changed, 120 insertions(+), 36 deletions(-) delete mode 100644 pages/api/article.js create mode 100644 pages/api/moment.js create mode 100644 pages/api/ztb.js diff --git a/pages/api/article.js b/pages/api/article.js deleted file mode 100644 index 974ec44..0000000 --- a/pages/api/article.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright © 2020-present LiuDanYang. All rights Reserved. - */ -import { mGet, mPost } from "./request" -const app = getApp() - -const aconfig = { - baseUrl: app.release ? `https://psc.qniao.cn` : `http://psc-dev.qniao.cn` -} -// *******************************************************************账户业务*********************************************************** -// /credit/get/self-enterprise-credit-by-enterprise-id查看个人的采购额度 -const getCreditInfo = (params) => mGet(`/payment-settlement-center/credit/get/self-enterprise-credit-by-enterprise-id`, params, aconfig) - -const paymentInfo = (params) => mPost(`/payment-settlement-center/pay`, params, aconfig) - -export { - aconfig, - getCreditInfo, - paymentInfo -} \ No newline at end of file diff --git a/pages/api/moment.js b/pages/api/moment.js new file mode 100644 index 0000000..2b01a5b --- /dev/null +++ b/pages/api/moment.js @@ -0,0 +1,50 @@ +/** + * Copyright © 2020-present LiuDanYang. All rights Reserved. + */ +import { mGet, mPost } from "./request" +const app = getApp() + +const mconfig = { + baseUrl: app.release ? `https://psc.qniao.cn` : `http://psc-dev.qniao.cn` +} +// *******************************************************************账户业务*********************************************************** +// /article/save/Article 发文章 +const postMoment = (params) => mPost(`/information-center/article/save/Article`, params, mconfig) +// /article/update/Article/{id} 编辑文章 +const updateMoment = (id, params) => mPost(`/information-center/article/update/Article/${id}`, params, mconfig) +// /article/get/Article-list/文章列表 +const getPreferList = (params) => mGet(`/information-center/article/get/Article-list`, params, mconfig) +// /article/get/Article-view-list 浏览文章历史列表 +const getViewedList = (params) => mGet(`/information-center/article/get/Article-view-list`, params, mconfig) +// /article/delete/Article删除文章 +const deleteMoment = (params) => mPost(`/information-center/article/delete/Article`, params, mconfig) +// /article/get/my-Article-list 我的文章列表 +const getMyList = (params) => mGet(`/information-center/article/get/my-Article-list`, params, mconfig) +// /article/get/Article-detail/{id} 文章详情 +const getMomentDetail = (id) => mGet(`/information-center/article/get/Article-detail/${id}`, params, mconfig) +// /article-reply/get/my-reply-list 我的评论列表 +const getReplyList = (params) => mGet(`/information-center/article-reply/get/my-reply-list`, params, mconfig) +// /article-reply/get/reply-list/in/{articleId} 帖子评论列表 +const getCommentList = (id) => mGet(`/information-center/article-reply/get/reply-list/in/${id}`, params, mconfig) +// /article-reply/like-or-cancel/article 点赞文章 +const likeMoment = (params) => mPost(`/information-center/article-reply/like-or-cancel/article`, params, mconfig) +// /article-reply/like-or-cancel/reply 点赞评论 +const likeComment = (params) => mPost(`/information-center/article-reply/like-or-cancel/reply`, params, mconfig) +// /article-reply/reply 评论 +const commentMoment = (params) => mPost(`/information-center/article-reply/reply`, params, mconfig) + +export { + mconfig, + getPreferList, + postMoment, + updateMoment, + getViewedList, + deleteMoment, + getMyList, + getMomentDetail, + getReplyList, + getCommentList, + likeMoment, + likeComment, + commentMoment +} \ No newline at end of file diff --git a/pages/api/user.js b/pages/api/user.js index 42c11d4..caf481d 100644 --- a/pages/api/user.js +++ b/pages/api/user.js @@ -7,7 +7,7 @@ const storage = require('../../utils/storage') const app = getApp() const config = { - baseUrl: app.release ? 'https://uec.qniao.cn' : 'http://47.107.97.166:9000' + baseUrl: app.release ? 'https://uec.qniao.cn' : 'https://uec-dev.qniao.cn' } // /uec/get/wechat-applet-session const wechatApplet = (params) => mPost('/uec/get/wechat-applet-session', params, config) diff --git a/pages/api/ztb.js b/pages/api/ztb.js new file mode 100644 index 0000000..6c91d26 --- /dev/null +++ b/pages/api/ztb.js @@ -0,0 +1,20 @@ +/** + * Copyright © 2020-present LiuDanYang. All rights Reserved. + */ +import { mGet, mPost } from "./request" +const app = getApp() + +const zconfig = { + baseUrl: app.release ? `https://api-client-ztb.qniao.cn` : `https://api-client-ztb-dev.qniao.cn` +} +// *******************************************************************账户业务*********************************************************** +// /authorize/get/product-line-token/by/login-token通过登录token获取产品线token +const loginToken = (params) => mPost(`/recycle-user-center/authorize/get/product-line-token/by/login-token`, params, zconfig) +///user/get/base-info基本信息 +const getBaseInfo = () => mGet(`/recycle-user-center/user/get/base-info`, null, zconfig) + +export { + zconfig, + loginToken, + getBaseInfo +} \ No newline at end of file diff --git a/pages/article/list/index.js b/pages/article/list/index.js index d798b18..08bd9b4 100644 --- a/pages/article/list/index.js +++ b/pages/article/list/index.js @@ -3,7 +3,7 @@ const request = require('../../../utils/request') //导入模块 const util = require('../../../utils/util') const event = require('../../../utils/event.js') const app = getApp() -const urlList = ['/information-center/article/get/my-Article-list', '/information-center/article-reply/get/my-reply-list', '/information-center//article/get/Article-view-list'] +const urlList = ['/information-center/article/get/my-Article-list', '/information-center/article-reply/get/my-reply-list', '/information-center/article/get/Article-view-list'] Page({ /** diff --git a/pages/home/index/index.js b/pages/home/index/index.js index b29513b..9488074 100644 --- a/pages/home/index/index.js +++ b/pages/home/index/index.js @@ -1,5 +1,5 @@ // pages/stock/index.js -const request = require('../../../utils/request'); //导入模块 +import { getBaseInfo } from "../../api/ztb" const util = require('../../../utils/util') const event = require('../../../utils/event') const math = require('../../../utils/math') @@ -48,7 +48,7 @@ Component({ if(!app.globalData.token){ return } - request.get('/recycle-service/user/get/base-info').then(result => { + getBaseInfo().then(result => { app.globalData.userInfo = result.data var nickname = '' if(app.globalData.userInfo.isAuth) { @@ -64,12 +64,12 @@ Component({ userName: nickname }) }) - request.get('/payment-settlement-center/balance/get/balance').then(result => { - this.setData({ accountMoney: math.minus(result.data.accountMoney, result.data.frozenMoney) }) - }) - request.get('/message-center/message/get/unread-number').then(result => { - this.setData({ messageNumber: result.data.messageNumber + result.data.notificationNumber }) - }) + // request.get('/payment-settlement-center/balance/get/balance').then(result => { + // this.setData({ accountMoney: math.minus(result.data.accountMoney, result.data.frozenMoney) }) + // }) + // request.get('/message-center/message/get/unread-number').then(result => { + // this.setData({ messageNumber: result.data.messageNumber + result.data.notificationNumber }) + // }) }, toPage: function(e){ if(e.currentTarget.id == 'bidding'){ diff --git a/pages/index/index.js b/pages/index/index.js index 2702d83..1924a75 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -1,7 +1,8 @@ -const app = getApp() +import { config, getUserInfo} from "../api/user" +import { zconfig, loginToken } from "../api/ztb" const event = require('../../utils/event.js') -const request = require('../../utils/request') //导入模块 const storage = require('../../utils/storage') +const app = getApp() Page({ data: { @@ -90,15 +91,32 @@ Page({ return (/iPhone 11/.test(t) || /iPhone X/.test(t) || /iPhone 12/.test(t)) && this.checkIos(e) }, fetchUserInfo:function(){ - request.get('/recycle-service/user/get/base-info').then(result => { + config.header = { 'Authorization': 'QNT ' + app.globalData.token } + getUserInfo().then(result => { app.globalData.userInfo = result.data + this.toIndex() + }).catch(err => { + wx.hideLoading() + }) + }, + toIndex: function(){ + loginToken({loginToken: app.globalData.token}).then(result => { + zconfig.header = { 'Authorization': 'QNT ' + result.data } + // cconfig.header = { 'Authorization': 'QNT ' + result.data } + // pconfig.header = { 'Authorization': 'QNT ' + result.data } wx.hideLoading() this.onResume() if(this.data.path){ wx.navigateTo({ url: this.data.path }) } + // event.emit('EventMessage', { what: 888, desc: 'Logined' }) }).catch(err => { + console.log(err) wx.hideLoading() + this.onResume() + if(this.data.path){ + wx.navigateTo({ url: this.data.path }) + } }) }, onResume: function(){ diff --git a/pages/login/index.js b/pages/login/index.js index 8aa77f7..50fae8f 100644 --- a/pages/login/index.js +++ b/pages/login/index.js @@ -1,6 +1,7 @@ //获取应用实例 import { $wuxCountDown } from '../../components/index' import { config, postCaptcha, loginCaptcha, wechatApplet, getUserInfo, loginWechat } from "../api/user" +import { zconfig, loginToken } from "../api/ztb" const storage = require('../../utils/storage') const request = require('../../utils/request') //导入模块 const util = require('../../utils/util') @@ -56,11 +57,26 @@ Page({ getUserInfo().then(result => { app.globalData.userInfo = result.data this.setData({ loging: false}) - event.emit('EventMessage', { what: 888, desc: 'Logined' }) - wx.hideLoading() - wx.navigateBack() + loginToken({loginToken: app.globalData.token}).then(result => { + zconfig.header = { 'Authorization': 'QNT ' + result.data } + // cconfig.header = { 'Authorization': 'QNT ' + result.data } + // pconfig.header = { 'Authorization': 'QNT ' + result.data } + // 登录流程完成; + wx.hideLoading() + wx.navigateBack() + event.emit('EventMessage', { what: 888, desc: 'Logined' }) + }).catch(err => { + console.log(err) + app.globalData.token = null + config.header = null + wx.hideLoading() + util.showToast(err) + wx.navigateBack() + }) }).catch(err => { wx.hideLoading() + app.globalData.token = null + config.header = null this.setData({ loging: false}) }) },