Commit 1a94f2e4 by 李伟康

Merge branch 'v1.0.0' of http://192.168.3.233:8090/saas/mini-program/hmd into v1.0.0

2 parents ed7b7e34 beb4ba74
...@@ -111,10 +111,17 @@ const defaultMerchantId = { ...@@ -111,10 +111,17 @@ const defaultMerchantId = {
uat: '44210895', uat: '44210895',
prod: '44189923' prod: '44189923'
}[target[index]] }[target[index]]
const CONFIG_ENV_MAP={
'1':'develope',
'2':'test',
'3':'production'
}
module.exports = { module.exports = {
index, index,
domain, domain,
pathEnum, pathEnum,
secretKey, secretKey,
defaultMerchantId defaultMerchantId,
env:CONFIG_ENV_MAP[index]
} }
...@@ -5,6 +5,7 @@ import homeApi from './home' ...@@ -5,6 +5,7 @@ import homeApi from './home'
import discoveryApi from './discovery' import discoveryApi from './discovery'
import shopmallApi from './shopmall' import shopmallApi from './shopmall'
import mineApi from './mine' import mineApi from './mine'
import systemApi from './system'
import couponsApi from './coupons' import couponsApi from './coupons'
module.exports = { module.exports = {
...@@ -15,5 +16,6 @@ module.exports = { ...@@ -15,5 +16,6 @@ module.exports = {
discoveryApi, discoveryApi,
shopmallApi, shopmallApi,
mineApi, mineApi,
systemApi,
couponsApi couponsApi
} }
\ No newline at end of file \ No newline at end of file
import http from "../request/http";
import { env } from "../env/index";
const serverConfig = {
mockRequestCount: null,
mockTimer: {},
mockCache: null,
};
const configModule = 'mini-hmd'
const configUrl = `https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=${configModule}&env=${env}`;
/**获取mock数据 */
const getMockData = async () => {
const MOCKDATA = wx.p.storage.get("mock_data");
try {
if (MOCKDATA && Date.now() - MOCKDATA.createTime < 5 * 60e3) {
return Promise.resolve(MOCKDATA);
} else {
if (!serverConfig.mockRequestCount) {
serverConfig.mockCache = null;
serverConfig.mockRequestCount = Date.now();
const data = await http.wx_request({ url:configUrl });;
data.createTime = Date.now();
serverConfig.mockCache = data;
wx.p.storage.set("mock_data", data);
return Promise.resolve(data);
} else {
const key = Date.now();
return new Promise((resolve) => {
serverConfig.mockTimer[key] = setInterval(() => {
if (serverConfig.mockCache) {
clearInterval(serverConfig.mockTimer[key]);
serverConfig.mockRequestCount = null;
resolve(serverConfig.mockCache);
}
}, 1e3);
});
}
}
} catch (error) {
if (serverConfig.mockTimer[key]) clearInterval(serverConfig.mockTimer[key]);
serverConfig.mockRequestCount = null;
return Promise.reject(error);
}
};
// 图片版本号
const getImageVersion = async () => {
const accountInfo = await getMockData()
return accountInfo?.version || Date.now()
}
module.exports={
getImageVersion
}
\ No newline at end of file \ No newline at end of file
import sign from './sign.js'
import { import {
defaultMerchantId, defaultMerchantId,
secretKey, secretKey,
pathEnum, pathEnum,
domain, domain,
index, } from '../env/index'
sign
} from './sign.js'
let INTERRUPT = false let INTERRUPT = false
/**接口 */ /**接口 */
class Request { class Request {
...@@ -24,6 +23,21 @@ class Request { ...@@ -24,6 +23,21 @@ class Request {
returnAll returnAll
); );
} }
wx_request({url,method='GET',data={},header={},dataType='json',responseType="text"}){
return new Promise((resolve) => {
wx.request({
url,
data,
method,
header,
dataType,
responseType,
success(response) {
resolve(response.data)
}
})
})
}
reportTrack(params) { reportTrack(params) {
return this.request('POST', params, true) return this.request('POST', params, true)
} }
...@@ -136,22 +150,5 @@ class Request { ...@@ -136,22 +150,5 @@ class Request {
const projectName = method.split('.')[2] const projectName = method.split('.')[2]
return projectName return projectName
} }
getMock() {
let url = 'https://oss-config.dev.glsx.com.cn/mock/6264ff4760f415276f6dfe62/aicard-config'
if (index == 3 || index == 4) url = 'https://oss-config.test.glsx.com.cn/mock/6274e3050da5034a58680aa6/aicard-config'
return new Promise((resolve) => {
wx.request({
url,
data: {},
method: 'GET',
header: {},
dataType: 'json',
responseType: 'text',
success(response) {
resolve(response.data)
}
})
})
}
} }
export default new Request() export default new Request()
\ No newline at end of file \ No newline at end of file
import {sha1,qs} from '../../lib/index' import {sha1,qs} from '../../lib/index'
import environment from '../env/index.js'
const sign = (params, secret, noSignAttr = []) => { const sign = (params, secret, noSignAttr = []) => {
delete params.sign delete params.sign
var objStr = qs.stringify(params, { var objStr = qs.stringify(params, {
...@@ -32,8 +31,4 @@ const sign = (params, secret, noSignAttr = []) => { ...@@ -32,8 +31,4 @@ const sign = (params, secret, noSignAttr = []) => {
realObj.sign = sha1(secret + str.join('') + secret).toUpperCase() realObj.sign = sha1(secret + str.join('') + secret).toUpperCase()
return realObj return realObj
} }
module.exports = {
...environment,
sign
}
\ No newline at end of file \ No newline at end of file
export default sign
\ No newline at end of file \ No newline at end of file
// components/image/index.js // components/image/index.js
import { import {
IMG_URL, IMG_URL,
IMG_VERSION } from '~/config'
} from '~/utils/constants' import {
systemApi
} from '~/api/index'
Component({ Component({
externalClasses: ['custom-class', 'class'], externalClasses: ['custom-class', 'class'],
/** /**
...@@ -19,7 +21,7 @@ Component({ ...@@ -19,7 +21,7 @@ Component({
let isFullAdd = checkList.map(item => url.includes(item)).some(item => item) let isFullAdd = checkList.map(item => url.includes(item)).some(item => item)
this.setData({ this.setData({
isWebp, isWebp,
imagePath: `${isFullAdd ? '' : IMG_URL}${url}?v=` + await IMG_VERSION() imagePath: `${isFullAdd ? '' : IMG_URL}${url}?v=` + await systemApi.getImageVersion()
}) })
} }
} }
......
...@@ -10,4 +10,4 @@ export const preReleaseAppId = 'wx6e40cfb83ce4ffb1' ...@@ -10,4 +10,4 @@ export const preReleaseAppId = 'wx6e40cfb83ce4ffb1'
export const dsnUrl = 'https://44b18e4acc2e4ab18f12a69a561b55bc@sentry.glsx.com.cn/39' export const dsnUrl = 'https://44b18e4acc2e4ab18f12a69a561b55bc@sentry.glsx.com.cn/39'
// cdn图片地址 // cdn图片地址
export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/hmd' export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/hmd/'
// packageMine/pages/order/detail/detail.js
import QR from '~/utils/lib/wxqrcode' import QR from '~/utils/lib/wxqrcode'
import { import {
orderMixin orderMixin
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
], ],
"include": [] "include": []
}, },
"appid": "wxfe82b8d65d07808f", "appid": "wx6e40cfb83ce4ffb1",
"projectname": "hmd", "projectname": "hmd",
"libVersion": "2.24.4" "libVersion": "2.24.4"
} }
\ No newline at end of file \ No newline at end of file
import getAppId from '~/utils/utils_wx'
// 图片cdn 加速使用地址
export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/hmd/'
// 缓存get方法为空的默认指定值 // 缓存get方法为空的默认指定值
export const DEFAULT_GET_STORAGEKEY = ['sessionId', 'merchantId', 'userInfo'] export const DEFAULT_GET_STORAGEKEY = ['sessionId', 'merchantId', 'userInfo']
export const appId = getAppId.getAppId()
// 缓存get方法key的对应才映射值 // 缓存get方法key的对应才映射值
export const STORAGE_OBJECTkEY = { export const STORAGE_OBJECTkEY = {
system_info: 'system_info', system_info: 'system_info',
...@@ -17,15 +11,7 @@ export const STORAGE_OBJECTkEY = { ...@@ -17,15 +11,7 @@ export const STORAGE_OBJECTkEY = {
sessionId: 'sessionId', sessionId: 'sessionId',
} }
// 图片版本号
export const IMG_VERSION = async () => {
const accountInfo = await wx.p.util.getMockData()
return accountInfo?.version || Date.now()
}
export default{ export default{
IMG_URL,
DEFAULT_GET_STORAGEKEY, DEFAULT_GET_STORAGEKEY,
STORAGE_OBJECTkEY, STORAGE_OBJECTkEY
IMG_VERSION
} }
\ No newline at end of file \ No newline at end of file
import api from '~/api/request/http'
/** /**
* 日期格式化 * 日期格式化
* let time = new Date().format('yyyy-MM-dd hh:mm:ss') //log 2020-07-31 10:00:00 * let time = new Date().format('yyyy-MM-dd hh:mm:ss') //log 2020-07-31 10:00:00
...@@ -127,44 +126,6 @@ const parseString = str => { ...@@ -127,44 +126,6 @@ const parseString = str => {
return obj return obj
} }
/**获取mock数据 */
let mockRequestCount = null,
mockTimer = {},
mockCache = null
const getMockData = async () => {
const MOCKDATA = wx.p.storage.get('mock_data')
try {
if (MOCKDATA && Date.now() - MOCKDATA.createTime < 5 * 60e3) {
return Promise.resolve(MOCKDATA)
} else {
if (!mockRequestCount) {
mockCache = null
mockRequestCount = Date.now()
const data = await api.getMock()
data.createTime = Date.now()
mockCache = data
wx.p.storage.set('mock_data', data)
return Promise.resolve(data)
} else {
const key = Date.now()
return new Promise((resolve) => {
mockTimer[key] = setInterval(() => {
if (mockCache) {
clearInterval(mockTimer[key])
mockRequestCount = null
resolve(mockCache)
}
}, 1e3)
})
}
}
} catch (error) {
if (mockTimer[key]) clearInterval(mockTimer[key])
mockRequestCount = null
return Promise.reject(error)
}
}
const Util = { const Util = {
onReachBottom, onReachBottom,
isFullSucreen, isFullSucreen,
...@@ -172,6 +133,5 @@ const Util = { ...@@ -172,6 +133,5 @@ const Util = {
throttle, throttle,
isEmptyObj, isEmptyObj,
parseString, parseString,
getMockData
} }
export default Util export default Util
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!