Browse Source

envx修改

featrue/v4.2
huziyuan 5 years ago
parent
commit
34bce87292
8 changed files with 160 additions and 74 deletions
  1. 2
      app.js
  2. 4
      pages/api/moment.js
  3. 3
      pages/api/payment.js
  4. 3
      pages/api/saas.js
  5. 4
      pages/api/user.js
  6. 3
      pages/api/ztb.js
  7. 213
      pages/index/index.js
  8. 2
      pages/login/index.js

2
app.js

@ -1,7 +1,7 @@
//app.js
App({
//----------------------------------------------globalData--------------------------------------
release: 0,
evn: 0,//0:开发环境,1:测试环境,2:生产环境
tmplIds: ['SUjEgwDopCv9xkkSZ4KbS0L7XbAiVQor6GmPg14K760'],
agentMsgIds: ['kG8DErWDpyzBHCFaLlSKYMF7xVy8UpgogCwV_WSNt10', 'oLbv-IyJOia2tenh64_Lc8xeAzwgzu3gh1vFJ1Se-ME'],
version: 152,

4
pages/api/moment.js

@ -3,9 +3,11 @@
*/
import { mGet, mPost } from "./request"
const app = getApp()
const urls = ['https://api-client-ztb-dev.qniao.cn', 'https://api-client-ztb-test.qniao.cn', 'https://api-client-ztb.qniao.cn']
const mconfig = {
baseUrl: app.release ? `https://api-client-ztb.qniao.cn` : `http://47.113.118.47:9000`
baseUrl: urls[app.evn]
}
// *******************************************************************账户业务***********************************************************
// /article/save/Article 发文章

3
pages/api/payment.js

@ -3,9 +3,10 @@
*/
import { mGet, mPost } from "./request"
const app = getApp()
const urls = ['https://api-client-psc-dev.qniao.cn', 'https://api-client-psc-test.qniao.cn', 'https://api-client-psc.qniao.cn']
const pconfig = {
baseUrl: app.release ? `http://api-client-ztb.qniao.cn` : `http://47.113.118.47:9000`
baseUrl: urls[app.evn]
}
// *******************************************************账户业务***********************************************************
const getBankcardInfo = (cardNo) => mGet(`/payment-settlement-center/bankcard/bankcard/home/${cardNo}`, null, pconfig)

3
pages/api/saas.js

@ -3,9 +3,10 @@
*/
import { mGet, mPost, mDelete, mPut } from "./request"
const app = getApp()
const urls = ['https://api-client-ztb-dev.qniao.cn', 'https://api-client-ztb-test.qniao.cn', 'https://api-client-ztb.qniao.cn']
const sconfig = {
baseUrl: app.release ? `https://api-client-ztb.qniao.cn` : `http://47.113.118.47:9000`
baseUrl: urls[app.evn]
}
// *******************************************************************账户业务***********************************************************
const getOrderExists = () => mGet(`/saas-trade/receive/v150/get/OrderExists`, null, sconfig)

4
pages/api/user.js

@ -9,9 +9,11 @@ import { zconfig } from "./ztb"
const util = require('../../utils/util')
const storage = require('../../utils/storage')
const app = getApp()
const urls = ['https://uec-dev.qniao.cn', 'https://uec-test.qniao.cn', 'https://uec.qniao.cn']
const config = {
baseUrl: app.release ? 'https://uec.qniao.cn' : 'https://uec-dev.qniao.cn'
baseUrl: urls[app.evn]
}
const wechatApplet = (params) => mPost('/uec/get/wechat-applet-session', params, config)
const loginCaptcha = (params) => mPost(`/uec/authorize/by-captcha`, params, config)

3
pages/api/ztb.js

@ -3,9 +3,10 @@
*/
import { mGet, mPost } from "./request"
const app = getApp()
const urls = ['https://api-client-ztb-dev.qniao.cn', 'https://api-client-ztb-test.qniao.cn', 'https://api-client-ztb.qniao.cn']
const zconfig = {
baseUrl: app.release ? `https://api-client-ztb.qniao.cn` : `http://47.113.118.47:9000`
baseUrl: urls[app.evn]
}
// *******************************************************************账户业务***********************************************************
// /authorize/get/product-line-token/by/login-token通过登录token获取产品线token

213
pages/index/index.js

@ -1,8 +1,24 @@
import { config, getUserInfo} from "../api/user"
import { zconfig, loginToken, getBaseInfo, getPopupInfo,updateUserInfo } from "../api/ztb"
import { pconfig } from "../api/payment"
import { mconfig } from "../api/moment"
import { sconfig, getOrderExists } from "../api/saas"
import {
config,
getUserInfo
} from "../api/user"
import {
zconfig,
loginToken,
getBaseInfo,
getPopupInfo,
updateUserInfo
} from "../api/ztb"
import {
pconfig
} from "../api/payment"
import {
mconfig
} from "../api/moment"
import {
sconfig,
getOrderExists
} from "../api/saas"
const util = require('../../utils/util')
const event = require('../../utils/event')
const storage = require('../../utils/storage')
@ -10,10 +26,24 @@ const app = getApp()
Page({
data: {
TabList: [
{ index: 0, value: 'article', badge: 0, name: '情报' },
{ index: 1, value: 'mall', badge: 0, name: '交易' },
{ index: 2, value: 'home', badge: 0, name: '我的' }
TabList: [{
index: 0,
value: 'article',
badge: 0,
name: '情报'
},
{
index: 1,
value: 'mall',
badge: 0,
name: '交易'
},
{
index: 2,
value: 'home',
badge: 0,
name: '我的'
}
],
pageIndex: 1,
safeBottom: app.globalData.safeBottom,
@ -22,7 +52,8 @@ Page({
landInfo: null,
visible: false,
hasShowedLoginTag:false,//是否已展示过登陆标签填写页面
hasShowedLoginTag: false, //是否已展示过登陆标签填写页面
isTokenHaveStatus: false,
},
/************************************** 初始化流程 ********************************************/
onLoad: function (options) {
@ -35,20 +66,23 @@ Page({
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
})
if(options.url){
if (options.url) {
this.data.path = options.url
if(options.key && options.value){
if (options.key && options.value) {
this.data.path += '?' + options.key + '=' + options.value
}
}
},
onReady: function () {
wx.showLoading({ title: '获取中', mask: true })
wx.showLoading({
title: '获取中',
mask: true
})
wx.getSystemInfo({
success: e => {
app.globalData.isIos = this.checkIos(e)
app.globalData.dev = e.platform == 'devtools'
let custom = wx.getMenuButtonBoundingClientRect()
app.globalData.Custom = custom
// 顶部操作栏高度
@ -56,7 +90,7 @@ Page({
let windowHeight = e.windowHeight * (750 / e.windowWidth)
let safeBottom = e.windowHeight - e.safeArea.bottom
if(safeBottom > e.windowHeight){
if (safeBottom > e.windowHeight) {
safeBottom = 34
}
app.globalData.safeBottom = safeBottom * (750 / e.windowWidth)
@ -71,10 +105,16 @@ Page({
this.data.inited = true
const fheght = (app.globalData.safeFragmentHeight + app.globalData.statusBarHeight) - 100
event.emit('InitMessage', { what: 8, desc: 'Logined' })
this.setData({fragment: fheght, safeBottom: app.globalData.safeBottom })
event.emit('InitMessage', {
what: 8,
desc: 'Logined'
})
this.setData({
fragment: fheght,
safeBottom: app.globalData.safeBottom
})
var authorization = app.globalData.token || storage.get('Authorization')
if(authorization){
if (authorization) {
app.globalData.token = authorization
this.fetchUserInfo()
} else {
@ -92,45 +132,62 @@ Page({
}
return false
},
fetchUserInfo:function(){
config.header = { 'Authorization': 'QNT ' + app.globalData.token }
fetchUserInfo: function () {
config.header = {
'Authorization': 'QNT ' + app.globalData.token
}
getUserInfo().then(result => {
this.toIndex()
}).catch(err => {
wx.hideLoading()
})
},
defaultIndex: function(){
defaultIndex: function () {
this.onResume()
if(this.data.path){
wx.navigateTo({ url: this.data.path })
if (this.data.path) {
wx.navigateTo({
url: this.data.path
})
}
getPopupInfo().then(result => {
if(result.data){
this.setData({ landInfo: result.data })
if (result.data) {
this.setData({
landInfo: result.data
})
}
})
},
toIndex: function(){
if(!app.globalData.token){
toIndex: function () {
if (!app.globalData.token) {
wx.hideLoading()
this.defaultIndex()
return
}
loginToken({loginToken: app.globalData.token}).then(result => {
zconfig.header = { 'Authorization': 'QNT ' + result.data.token }
pconfig.header = { 'Authorization': 'QNT ' + result.data.token }
mconfig.header = { 'Authorization': 'QNT ' + result.data.token }
loginToken({
loginToken: app.globalData.token
}).then(result => {
zconfig.header = {
'Authorization': 'QNT ' + result.data.token
}
pconfig.header = {
'Authorization': 'QNT ' + result.data.token
}
mconfig.header = {
'Authorization': 'QNT ' + result.data.token
}
this.setData({
isTokenHaveStatus: true
})
getBaseInfo().then(result => {
this.setData({
hasShowedLoginTag:result.data.hasShowedLoginTag
hasShowedLoginTag: result.data.hasShowedLoginTag
})
app.globalData.userInfo = result.data
app.globalData.userInfo = result.data
// 登录流程完成;
if(!util.isEmpty(result.data.userToken)){
if (!util.isEmpty(result.data.userToken)) {
this.handleUserToken(result.data.userToken)
return
}
}
wx.hideLoading()
this.defaultIndex()
}).catch(err => {
@ -142,14 +199,18 @@ Page({
this.defaultIndex()
})
},
handleUserToken: function(userToken){
sconfig.header = {'user-token': userToken }
handleUserToken: function (userToken) {
sconfig.header = {
'user-token': userToken
}
getOrderExists().then(result => {
wx.hideLoading()
if (Number(result.data) != 1 || !app.release) {
if (Number(result.data) != 1 || !app.evn) {
wx.navigateBack()
} else {
wx.reLaunch({ url: '/pages/paper/index' })
wx.reLaunch({
url: '/pages/paper/index'
})
}
}).catch(err => {
wx.hideLoading()
@ -157,68 +218,86 @@ Page({
this.defaultIndex()
})
},
onResume: function(){
onResume: function () {
var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value)
if (pageView && this.data.inited) {
pageView.onRestart()
}
},
//事件处理函数
onNavChange: function(e) {
onNavChange: function (e) {
// 处理用户的登录校验
this.setData({ pageIndex: Number(e.currentTarget.dataset.tab) })
this.setData({
pageIndex: Number(e.currentTarget.dataset.tab)
})
this.onResume()
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
if(this.data.inited){
if (this.data.inited) {
this.onResume()
}
// wx.navigateTo({ url: '/pages/home/tab1/index' })
getBaseInfo().then(result => {
this.setData({
hasShowedLoginTag:result.data.hasShowedLoginTag
if (this.data.isTokenHaveStatus) {
getBaseInfo().then(result => {
this.setData({
hasShowedLoginTag: result.data.hasShowedLoginTag
})
if (this.data.hasShowedLoginTag == false) {
this.updateUserInfoFct({
hasShowedLoginTag: true
})
wx.navigateTo({
url: '/pages/home/tab1/index'
})
}
})
if(this.data.hasShowedLoginTag==false){
this.updateUserInfoFct({hasShowedLoginTag:true})
wx.navigateTo({ url: '/pages/home/tab1/index' })
}
})
}
},
updateUserInfoFct: function (model) {
updateUserInfo(model).then(result => {
})
updateUserInfo(model).then(result => {})
},
onEvent: function (message) {
if(message.what == 250){
this.setData({ pageIndex: 0 })
}
if (message.what == 250) {
this.setData({
pageIndex: 0
})
}
},
stopTouchMove: function(e){
stopTouchMove: function (e) {
return false
},
// 弹出框的处理;
onClose: function(){
this.setData({ visible: false, landInfo: null })
onClose: function () {
this.setData({
visible: false,
landInfo: null
})
},
onImageLoad: function(){
this.setData({ visible: true })
onImageLoad: function () {
this.setData({
visible: true
})
},
onImageClick: function(){
if(this.data.landInfo.redirectInfo.targetView == 'showH5'){
onImageClick: function () {
if (this.data.landInfo.redirectInfo.targetView == 'showH5') {
util.navigateTo('/pages/html/html/index?link=' + this.data.landInfo.redirectInfo.params.id + '?title=' + this.data.landInfo.title)
return
}
util.navigateTarget(this.data.landInfo.redirectInfo)
this.setData({ visible: false, landInfo: null })
this.setData({
visible: false,
landInfo: null
})
},
toRule: function(){
if(this.data.landInfo.ruleRedirectInfo.targetView == 'showH5'){
toRule: function () {
if (this.data.landInfo.ruleRedirectInfo.targetView == 'showH5') {
util.navigateTo('/pages/html/html/index?link=' + this.data.landInfo.ruleRedirectInfo.params.id + '?title=' + this.data.landInfo.title)
return
}
util.navigateTarget(this.data.landInfo.ruleRedirectInfo)
}
})
})

2
pages/login/index.js

@ -140,7 +140,7 @@ Page({
}
getOrderExists().then(result => {
wx.hideLoading()
if (Number(result.data) != 1 || !app.release) {
if (Number(result.data) != 1 || !app.evn) {
wx.navigateBack()
} else {
wx.reLaunch({

Loading…
Cancel
Save