配置全局变量
This commit is contained in:
@@ -7,6 +7,9 @@ App({
|
|||||||
const logs = wx.getStorageSync('logs') || []
|
const logs = wx.getStorageSync('logs') || []
|
||||||
logs.unshift(Date.now())
|
logs.unshift(Date.now())
|
||||||
wx.setStorageSync('logs', logs)
|
wx.setStorageSync('logs', logs)
|
||||||
|
wx.removeStorage({
|
||||||
|
key: 'avatarUrl',
|
||||||
|
})
|
||||||
// 长时间不操作导致token失效之后执行自动微信登录操作
|
// 长时间不操作导致token失效之后执行自动微信登录操作
|
||||||
wx.getStorage({
|
wx.getStorage({
|
||||||
key: 'rsaPublicKey',
|
key: 'rsaPublicKey',
|
||||||
|
|||||||
+4
-2
@@ -1,3 +1,5 @@
|
|||||||
|
import {appId, secret} from '../js/project.config'
|
||||||
|
console.log(appId)
|
||||||
export function wxBind(callback){
|
export function wxBind(callback){
|
||||||
// 获取openid进行手机号和微信的绑定
|
// 获取openid进行手机号和微信的绑定
|
||||||
let count = 1
|
let count = 1
|
||||||
@@ -7,8 +9,8 @@ export function wxBind(callback){
|
|||||||
wx.request({
|
wx.request({
|
||||||
url: 'https://api.weixin.qq.com/sns/jscode2session',
|
url: 'https://api.weixin.qq.com/sns/jscode2session',
|
||||||
data: {
|
data: {
|
||||||
appid: 'wx457dfcb58fd556ea',
|
appid: appId,
|
||||||
secret: 'e8d2ee25e32c77561efccb7145ba9dc8',
|
secret: secret,
|
||||||
js_code: res.code,
|
js_code: res.code,
|
||||||
grant_type: 'authorization_code'
|
grant_type: 'authorization_code'
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import http from './http.js'
|
import http from './http.js'
|
||||||
let baseUrl = http.baseUrl
|
import { baseUrl, URL_CONFIG } from '../project.config'
|
||||||
let URL_CONFIG = http.URL_CONFIG
|
|
||||||
/* 配置路径 */
|
/* 配置路径 */
|
||||||
|
|
||||||
|
|
||||||
@@ -10,8 +10,6 @@ let apiUrl = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
baseUrl,
|
|
||||||
URL_CONFIG,
|
|
||||||
//微信账号密码登陆--1
|
//微信账号密码登陆--1
|
||||||
wxLoginByUserName(option, success, error) {
|
wxLoginByUserName(option, success, error) {
|
||||||
http.post1(baseUrl + apiUrl.wxLoginByUserName, option).then(res => {
|
http.post1(baseUrl + apiUrl.wxLoginByUserName, option).then(res => {
|
||||||
@@ -39,8 +37,3 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export{
|
|
||||||
baseUrl,
|
|
||||||
URL_CONFIG
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
|
import { baseUrl } from '../project.config'
|
||||||
let headerDefault = {
|
let headerDefault = {
|
||||||
'Accept': 'application/json'
|
'Accept': 'application/json'
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,6 @@ let headerDefault1 = {
|
|||||||
'content-type': 'application/x-www-form-urlencoded'
|
'content-type': 'application/x-www-form-urlencoded'
|
||||||
}
|
}
|
||||||
let TokenKey = 'X-Access-Token'
|
let TokenKey = 'X-Access-Token'
|
||||||
let baseUrl = 'http://bxxt.hzwlsoft.com:1015'
|
|
||||||
let URL_CONFIG = '/jero-boot/'
|
|
||||||
|
|
||||||
const http = (method, url, data, header= headerDefault) => {
|
const http = (method, url, data, header= headerDefault) => {
|
||||||
let Authorization = wx.getStorageSync(TokenKey) ? wx.getStorageSync(TokenKey) : '';
|
let Authorization = wx.getStorageSync(TokenKey) ? wx.getStorageSync(TokenKey) : '';
|
||||||
@@ -39,8 +37,6 @@ const http = (method, url, data, header= headerDefault) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
baseUrl,
|
|
||||||
URL_CONFIG,
|
|
||||||
get: (url, data, header) => http('GET', url, data, header),
|
get: (url, data, header) => http('GET', url, data, header),
|
||||||
post: (url, data, header) => http('POST', url, data, header),
|
post: (url, data, header) => http('POST', url, data, header),
|
||||||
post1: (url, data, header) => http('POST', url, data, headerDefault1),
|
post1: (url, data, header) => http('POST', url, data, headerDefault1),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import MeetingApi from '../js/http/meetingApi'
|
import MeetingApi from '../js/http/meetingApi'
|
||||||
import { baseUrl } from '../../assets/js/http/api'
|
import { baseUrl } from '../js/project.config'
|
||||||
/**
|
/**
|
||||||
* 预览文件的方法
|
* 预览文件的方法
|
||||||
* @param fileId 文件id
|
* @param fileId 文件id
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export const appId = 'wx322b63d1e6ff4765'
|
||||||
|
export const secret = 'a3e81ffa80aa5f04d0b104b2ccda7f32'
|
||||||
|
|
||||||
|
export let baseUrl = 'http://bxxt.hzwlsoft.com:1015' // 外网环境
|
||||||
|
// export let baseUrl = 'http://10.10.10.46:8055/' // 测试环境
|
||||||
|
// export const baseUrl = 'http://10.0.1.9:8080' // 本地环境
|
||||||
|
export const URL_CONFIG = '/jero-boot/'
|
||||||
|
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
// components/imageUpload/imageUpload.js
|
// components/imageUpload/imageUpload.js
|
||||||
|
|
||||||
import {
|
import {baseUrl, URL_CONFIG} from '../../assets/js/project.config'
|
||||||
baseUrl,
|
|
||||||
URL_CONFIG
|
|
||||||
} from "../../assets/js/http/api"
|
|
||||||
Component({
|
Component({
|
||||||
/**
|
/**
|
||||||
* 组件的属性列表
|
* 组件的属性列表
|
||||||
|
|||||||
+9
-9
@@ -49,15 +49,15 @@ Page({
|
|||||||
const reg = new RegExp("<p>","g")
|
const reg = new RegExp("<p>","g")
|
||||||
const reg1 = new RegExp("</p>","g")
|
const reg1 = new RegExp("</p>","g")
|
||||||
if(res.result.records && res.result.records.length){
|
if(res.result.records && res.result.records.length){
|
||||||
res.result.records.forEach(item=>{
|
// res.result.records.forEach(item=>{
|
||||||
item.msgContent = item.msgContent.replace(reg,"")
|
// item.msgContent = item.msgContent.replace(reg,"")
|
||||||
item.msgContent = item.msgContent.replace(reg1,"")
|
// item.msgContent = item.msgContent.replace(reg1,"")
|
||||||
const startIndex = item.msgContent.indexOf("<a")
|
// const startIndex = item.msgContent.indexOf("<a")
|
||||||
const endIndex = item.msgContent.lastIndexOf("</a>")
|
// const endIndex = item.msgContent.lastIndexOf("</a>")
|
||||||
if(startIndex > -1 && endIndex > -1 ){
|
// if(startIndex > -1 && endIndex > -1 ){
|
||||||
item.msgContent = item.msgContent.substring(0, startIndex) + item.msgContent.slice(endIndex + 4) + '点击报名'
|
// item.msgContent = item.msgContent.substring(0, startIndex) + item.msgContent.slice(endIndex + 4) + '点击报名'
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
this.setData({
|
this.setData({
|
||||||
list: [...this.data.list, ...res.result.records]
|
list: [...this.data.list, ...res.result.records]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<text class="content-time">{{item.sendTime}}</text>
|
<text class="content-time">{{item.sendTime}}</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="content-bottom">{{item.msgContent}}</text>
|
<rich-text class="content-bottom" nodes="{{item.msgContent}}"></rich-text>
|
||||||
<text class="status" wx:if="{{item.readFlag == 0}}"></text>
|
<text class="status" wx:if="{{item.readFlag == 0}}"></text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -30,8 +30,8 @@
|
|||||||
<text bindtap="updateInfo">忘记密码?</text>
|
<text bindtap="updateInfo">忘记密码?</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="other-way">或用以下方式登录</text>
|
<text class="other-way">或用以下方式登录</text>
|
||||||
<view class="weixin">
|
<view class="weixin" bindtap="wxLogin">
|
||||||
<image src="../../assets/images/wx.png" bindtap="wxLogin"></image>
|
<image src="../../assets/images/wx.png"></image>
|
||||||
</view>
|
</view>
|
||||||
</form>
|
</form>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -7,10 +7,7 @@ import {
|
|||||||
import MeetingApi from '../../assets/js/http/meetingApi'
|
import MeetingApi from '../../assets/js/http/meetingApi'
|
||||||
import signUpApi from '../../assets/js/http/signUp'
|
import signUpApi from '../../assets/js/http/signUp'
|
||||||
import UserApi from '../../assets/js/http/userApi'
|
import UserApi from '../../assets/js/http/userApi'
|
||||||
import {
|
import {baseUrl, URL_CONFIG} from '../../assets/js/project.config.js'
|
||||||
baseUrl,
|
|
||||||
URL_CONFIG
|
|
||||||
} from '../../assets/js/http/api'
|
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+2
-2
@@ -166,7 +166,7 @@ Page({
|
|||||||
*/
|
*/
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
let userInfo = wx.getStorageSync('userInfo')
|
let userInfo = wx.getStorageSync('userInfo')
|
||||||
let userInfoTemp = wx.getStorageSync('userInfoTemp')
|
let avatarUrl = wx.getStorageSync('avatarUrl')
|
||||||
let token = wx.getStorageSync('X-Access-Token')
|
let token = wx.getStorageSync('X-Access-Token')
|
||||||
this.setData({
|
this.setData({
|
||||||
token
|
token
|
||||||
@@ -177,7 +177,7 @@ Page({
|
|||||||
phone: userInfo.phone.substr(0, 3) + '-' + userInfo.phone.substr(3, 4) + '-' + userInfo.phone.substr(7, 4)
|
phone: userInfo.phone.substr(0, 3) + '-' + userInfo.phone.substr(3, 4) + '-' + userInfo.phone.substr(7, 4)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (userInfoTemp) {
|
if (avatarUrl) {
|
||||||
this.setData({
|
this.setData({
|
||||||
avatarUrl: userInfoTemp.avatarUrl
|
avatarUrl: userInfoTemp.avatarUrl
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import UserApi from '../../assets/js/http/userApi'
|
import UserApi from '../../assets/js/http/userApi'
|
||||||
import { baseUrl, URL_CONFIG } from '../../assets/js/http/api'
|
import {baseUrl, URL_CONFIG} from '../../assets/js/project.config.js'
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,10 +5,7 @@ import {
|
|||||||
previewFile,
|
previewFile,
|
||||||
getFileInfo
|
getFileInfo
|
||||||
} from '../../assets/js/preview'
|
} from '../../assets/js/preview'
|
||||||
import {
|
import {baseUrl, URL_CONFIG} from '../../assets/js/project.config.js'
|
||||||
baseUrl,
|
|
||||||
URL_CONFIG
|
|
||||||
} from '../../assets/js/http/api'
|
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,7 @@ import {
|
|||||||
phoneReg,
|
phoneReg,
|
||||||
postcode
|
postcode
|
||||||
} from '../../utils/validate'
|
} from '../../utils/validate'
|
||||||
import {
|
import {baseUrl, URL_CONFIG} from '../../assets/js/project.config.js'
|
||||||
baseUrl,
|
|
||||||
URL_CONFIG
|
|
||||||
} from '../../assets/js/http/api'
|
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
1. assets/js/project.config.js 为全局的配置文件
|
||||||
Reference in New Issue
Block a user