Commit e451828d by 钟乾明

u: 兼容轻应用

parent a47484d9
Showing with 369 additions and 61 deletions
{ {
"name": "城投项目动态", "name": "城投大运营",
"identifier": "com.cnd.jffc.testbaobiao", "identifier": "com.cnd.jffc.cityinvestment",
"build": 90, "build": 90,
"version": "1.0.90", "version": "1.0.90",
"releaseNote": "湖滨取消强拆" "releaseNote": "湖滨取消强拆"
} }
\ No newline at end of file
...@@ -10,7 +10,10 @@ npm install ...@@ -10,7 +10,10 @@ npm install
npm run dev npm run dev
# build for production with minification # build for production with minification
npm run build npm run build:test // 打包美信云测试环境
npm run build:prod// 打包美信云正式环境
npm run build:test:qing // 打包云之家测试环境
npm run build:prod:qing // 打包云之家正式环境
# build for production and view the bundle analyzer report # build for production and view the bundle analyzer report
npm run build --report npm run build --report
......
// see http://vuejs-templates.github.io/webpack for documentation. // see http://vuejs-templates.github.io/webpack for documentation.
var path = require('path') var path = require('path')
const appConfFileMap = {
prod: 'CubeModule-prod.json',
test: 'CubeModule-test.json',
}
module.exports = { module.exports = {
build: { build: {
env: require('./prod.env'), env: require('./prod.env'),
...@@ -8,6 +11,7 @@ module.exports = { ...@@ -8,6 +11,7 @@ module.exports = {
assetsRoot: path.resolve(__dirname, '../../dist'), assetsRoot: path.resolve(__dirname, '../../dist'),
assetsSubDirectory: 'static', assetsSubDirectory: 'static',
assetsPublicPath: '/', assetsPublicPath: '/',
// assetsPublicPath: process.env.PACK_PLATFORM === 'qing' ? "/jffc-fe-newfkdyy" : '',
productionSourceMap: false, productionSourceMap: false,
appConfFile: 'CubeModule.json', appConfFile: 'CubeModule.json',
eslint: false, eslint: false,
...@@ -35,7 +39,20 @@ module.exports = { ...@@ -35,7 +39,20 @@ module.exports = {
autoOpenBrowser: false, autoOpenBrowser: false,
assetsSubDirectory: 'static', assetsSubDirectory: 'static',
assetsPublicPath: '', assetsPublicPath: '',
proxyTable: {}, proxyTable: {
'/mas/proxy': {
target: 'https://staging.jffctest.com/', // 测试
// target: 'https://portal.cndrealty.com/', // 生产
secure: false, // 如果是https接口,需要配置这个参数
changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
},
'/mas-api/proxy': {
// target: 'https://mxytest.cndrealty.com:4433/', // 测试
target: 'https://jffcvp.cndrealty.com:4433/', // 生产
secure: false, //
changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
},
},
appConfFile: 'CubeModule.json', appConfFile: 'CubeModule.json',
eslint: false, eslint: false,
autoRoutes: false, autoRoutes: false,
......
...@@ -85,7 +85,7 @@ var baseWebpackConfig = { ...@@ -85,7 +85,7 @@ var baseWebpackConfig = {
'~lib':resolve('src/libraries'), '~lib':resolve('src/libraries'),
'~com': resolve('src/shared/components'), '~com': resolve('src/shared/components'),
'~config' : resolve('src/shared/config'), '~config' : resolve('src/shared/config'),
'~proj' : resolve('src/projectDynamic'), '~proj' : resolve('src/projectOfCityInvestment'),
'configuration': resolve(process.env.PACK_ENV === 'prod' 'configuration': resolve(process.env.PACK_ENV === 'prod'
? './src/shared/config/prod' ? './src/shared/config/prod'
: './src/shared/config/test') : './src/shared/config/test')
...@@ -101,7 +101,7 @@ var baseWebpackConfig = { ...@@ -101,7 +101,7 @@ var baseWebpackConfig = {
{ {
test: /\.js$/, test: /\.js$/,
loader: 'babel-loader', loader: 'babel-loader',
include: [resolve('src/shared'), resolve('src/libraries'), resolve('src/projectDynamic'), resolve('test')], include: [resolve('src/shared'), resolve('src/libraries'), resolve('src/projectOfCityInvestment'), resolve('test')],
exclude: /(node_modules|router\.js)/ exclude: /(node_modules|router\.js)/
}, },
{ {
......
...@@ -33,7 +33,8 @@ var webpackConfig = merge(baseWebpackConfig, { ...@@ -33,7 +33,8 @@ var webpackConfig = merge(baseWebpackConfig, {
// http://vuejs.github.io/vue-loader/en/workflow/production.html // http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({ new webpack.DefinePlugin({
'process.env': env, 'process.env': env,
'process.env.PACK_ENV': JSON.stringify(process.env.PACK_ENV) 'process.env.PACK_ENV': JSON.stringify(process.env.PACK_ENV),
'process.env.PACK_PLATFORM': JSON.stringify(process.env.PACK_PLATFORM),
}), }),
new webpack.optimize.UglifyJsPlugin({ new webpack.optimize.UglifyJsPlugin({
compress: { compress: {
......
.common-config:
only:
refs:
- test
- uat
- master
.test-common-config:
extends: .common-config
only:
refs:
- test
environment:
name: test
url: 'https://bpmtest.cndrealty.com/jffc-fe-newfkdyy/'
variables:
IMG_STASH: 'harbor.jffctest.com/test-fangkai'
IMG_NAME: 'fe-jffc-newfkdyy'
DEPLOYMENT_PATH: 'test/jffc-new-fkdyy/deployment.yaml'
K8S_APP_NAME: 'test-fangkai-jffc-newfkdyy-frontend'
K8S_WORKSPACE_ID: '39'
K8S_WORKSPACE_NAME: 'test-fangkai-frontend'
.prod-common-config:
extends: .common-config
only:
refs:
- master
environment:
name: prod
url: 'https://bpm.cndrealty.com/jffc-fe-newfkdyy/'
variables:
IMG_STASH: 'harbor.cndrealty.com/prod-fangkai'
IMG_NAME: 'fe-jffc-newfkdyy'
DEPLOYMENT_PATH: 'prod/jffc-new-fkdyy/deployment.yaml'
K8S_APP_NAME: 'prod-fangkai-jffc-newfkdyy-frontend'
K8S_WORKSPACE_ID: '96'
K8S_WORKSPACE_NAME: 'prod-fangkai-jffc-fkdyy-frontend'
image:
name: node:14.18.1
stages:
# 依赖安装
- install
# 构建
- build
# 构建并推送镜像
- image-update
# 更新deploy配置文件
- deploy-config-update
# 部署
- deploy
cache:
key: $CI_COMMIT_REF_NAME
paths:
- node_modules
# test jobs
test_install:
extends: .test-common-config
stage: install
script: npm install
test_build:
extends: .test-common-config
stage: build
script: npm run build:test:qing
dependencies:
- test_install
artifacts:
name: $CI_PROJECT_NAME-$CI_COMMIT_REF_NAME
expire_in: 180 day
paths:
- dist/
test_image-update:
extends: .test-common-config
image: docker:stable
services:
- docker:24.0.7-dind
dependencies:
- test_build
stage: image-update
script:
- echo "打包docker镜像并上传至harbor"
- IMAGE_TAG=$(date +%Y%m%d_%H%M)
- echo "$IMAGE_TAG" >> vars.env
- docker login $IMG_STASH -u $HARBOR_USER -p $HARBOR_PASS
- docker build -f deploy/Dockerfile -t $IMG_STASH/$IMG_NAME:$IMAGE_TAG .
- docker push $IMG_STASH/$IMG_NAME:$IMAGE_TAG
- docker rmi $IMG_STASH/$IMG_NAME:$IMAGE_TAG
- echo "镜像($IMG_STASH/$IMG_NAME:$IMAGE_TAG)成功上传至harbor ---->成功"
artifacts:
expire_in: 30 mins
paths:
- vars.env
test_deploy-config-update:
extends: .test-common-config
stage: deploy-config-update
script:
- echo "更改k8s deploy配置文件的image版本号"
- IMAGE_TAG=$(cat vars.env)
- git config --global user.name "gitlab-ci"
- git config --global user.email "gitlab-ci@xxx.com"
- git clone "http://${GIT_USER}:${GIT_PASS}@gitlab.cndrealty.com/fe/k8s-deploy-config.git"
- cd ./k8s-deploy-config
- grep 'harbor' $DEPLOYMENT_PATH
- sed -i "s#${IMG_STASH}.*#${IMG_STASH}/${IMG_NAME}:${IMAGE_TAG}#g" $DEPLOYMENT_PATH
- git add . && git commit -m "update image: ${DEPLOYMENT_PATH}"
- git push "http://${GIT_USER}:${GIT_PASS}@gitlab.cndrealty.com/fe/k8s-deploy-config.git"
- echo "更改k8s deploy配置文件的image版本号---->成功"
test_deploy:
extends: .test-common-config
stage: deploy
script:
- echo "请求执行 gitops 同步操作"
- SYNC_RES_HTTP_CODE=$(curl -o /dev/null -s -w "%{http_code}" -X POST -H "Content-Type:application/json" -H "Authorization:Bearer ${K8S_TOKEN}" -d "{\"workspaceId\":\"${K8S_WORKSPACE_ID}\",\"name\":\"${K8S_APP_NAME}\",\"dryRun\":false,\"prune\":false,\"applyOnly\":false,\"force\":false,\"revision\":\"master\",\"syncPolicy\":{\"options\":{\"skipSchemaValidate\":false,\"replace\":false,\"pruneLast\":false,\"applyOutOfSyncOnly\":false,\"respectIgnoreDifferences\":false,\"prunePropagationPolicy\":\"Background\"}},\"resources\":[{\"group\":\"apps\",\"name\":\"${K8S_APP_NAME}\",\"kind\":\"Deployment\",\"namespace\":\"${K8S_WORKSPACE_NAME}\"}]}" https://k8s-dev.jffctest.com/apis/gitops.amamba.io/v1alpha1/workspaces/${K8S_WORKSPACE_ID}/applications/${K8S_APP_NAME}:sync)
- if [ "$SYNC_RES_HTTP_CODE" != "200" ]; then echo -e "\e[31m k8s gitOpt 同步异常,${SYNC_RES_HTTP_CODE} \e[0m"; exit 1; fi;
- echo "同步操作---->成功"
#prod jobs
prod_install:
extends: .prod-common-config
stage: install
script: npm install
prod_build:
extends: .prod-common-config
stage: build
script: npm run build:prod:qing
dependencies:
- prod_install
artifacts:
name: $CI_PROJECT_NAME-$CI_COMMIT_REF_NAME
expire_in: 365 day
paths:
- dist/
prod_image-update:
extends: .prod-common-config
image: docker:stable
services:
- docker:24.0.7-dind
dependencies:
- prod_build
stage: image-update
script:
- echo "打包docker镜像并上传至harbor"
- IMAGE_TAG=$(date +%Y%m%d_%H%M)
- echo "$IMAGE_TAG" >> vars.env
- docker login $IMG_STASH -u $HARBOR_USER -p $HARBOR_PASS
- docker build -f deploy/Dockerfile -t $IMG_STASH/$IMG_NAME:$IMAGE_TAG .
- docker push $IMG_STASH/$IMG_NAME:$IMAGE_TAG
- docker rmi $IMG_STASH/$IMG_NAME:$IMAGE_TAG
- echo "镜像($IMG_STASH/$IMG_NAME:$IMAGE_TAG)成功上传至harbor ---->成功"
artifacts:
expire_in: 30 mins
paths:
- vars.env
prod_deploy-config-update:
extends: .prod-common-config
stage: deploy-config-update
script:
- echo "更改k8s deploy配置文件的image版本号"
- IMAGE_TAG=$(cat vars.env)
- git config --global user.name "gitlab-ci"
- git config --global user.email "gitlab-ci@xxx.com"
- git clone "http://${GIT_USER}:${GIT_PASS}@gitlab.cndrealty.com/fe/k8s-deploy-config.git"
- cd ./k8s-deploy-config
- grep 'harbor' $DEPLOYMENT_PATH
- sed -i "s#${IMG_STASH}.*#${IMG_STASH}/${IMG_NAME}:${IMAGE_TAG}#g" $DEPLOYMENT_PATH
- git add . && git commit -m "update image: ${DEPLOYMENT_PATH}"
- git push "http://${GIT_USER}:${GIT_PASS}@gitlab.cndrealty.com/fe/k8s-deploy-config.git"
- echo "更改k8s deploy配置文件的image版本号---->成功"
FROM harbor.cndrealty.com/bmp-front/nginx:1.25.5
WORKDIR /app/
COPY dist ./
COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
server {
listen 80;
server_name localhost;
# 静态资源重写地址 去掉/jffc-fe-fkdyy目录
location ^~ /jffc-fe-newfkdyy {
rewrite ^/jffc-fe-newfkdyy/(.*)$ /$1 last;
}
location / {
# 配置页面不缓存html和htm结尾的文件
if ($request_filename ~* .*\.(?:htm|html)$) {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
expires off;
}
root /app/;
index index.html index.htm;
# try_files $uri $uri/ /index.html; # history模式防止重刷新返回404
}
}
\ No newline at end of file
...@@ -2,10 +2,50 @@ ...@@ -2,10 +2,50 @@
<html lang="zh-CN"> <html lang="zh-CN">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>jf-citySheet</title> <title>城投大运营</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="format-detection" content="telephone=no"/> <meta name="format-detection" content="telephone=no"/>
<script src="miniapp://common/js/qing/qing.js"></script> <script>
console.log('开始引入库>>');
const ua = window.navigator.userAgent.toLocaleLowerCase();
if (ua.indexOf('qing') > -1) {
console.log('ua qing>>')
if (ua.indexOf('miniapp') > -1) {
console.log('ua 云之家小程序>>')
document.write('<scr' + 'ipt src="miniapp://common/js/qing/qing.js"></scr' + 'ipt>');
sessionStorage.setItem('runClientEnv', 'miniapp');
} else {
console.log('轻应用>>');
document.write('<scr' + 'ipt src="https://portal.cndrealty.com/public/js/qing/latest/qing.js"></scr' + 'ipt>');
// 轻应用从url上取ticket
let urlParamStr = location.href.split('?')[ 1 ] || '';
urlParamStr = urlParamStr.split('/')[ 0 ] || ''; // 截止/。用于去除尾部 /
urlParamStr = urlParamStr.split('#')[ 0 ] || ''; // 截止#。用于去除尾部 #
const urlParams = new URLSearchParams(((location.href.split('?')[ 1 ] || '').split('/')[ 0 ] || '').split('#')[ 0 ]);
// 从url上取ticket 存至全局
sessionStorage.setItem('ticket', urlParams.get('ticket') || '');
sessionStorage.setItem('runClientEnv', 'qing');
const testFlags = ['test', 'localhost', '192.168'];// 测试环境的url标志
if (testFlags.some(flag => location.origin.includes(flag))) {
sessionStorage.setItem('env', 'test');
} else {
sessionStorage.setItem('env', 'prod');
}
}
}
</script>
<script>
console.log('window.qing 已经引入>>',window.qing)
window.qing && window.qing.ready(() => {
// 隐藏轻应用自带的标题栏
window.qing && window.qing.call('setWebViewTitleBar', {isShow: false})
// 适配iPhone X底部偏移量
window.qing && window.qing.call('setWebBottomInset', {show: true});
})
</script>
<!-- <script src="https://staging.jffctest.com/public/js/qing/latest/qing.js"></script>--> <!-- <script src="https://staging.jffctest.com/public/js/qing/latest/qing.js"></script>-->
</head> </head>
<body> <body>
......
No preview for this file type
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
"~config/*": [ "~config/*": [
"./src/shared/config/*" "./src/shared/config/*"
] ,"~proj/*": [ ] ,"~proj/*": [
"./src/projectDynamic/*" "./src/projectOfCityInvestment/*"
] ]
} }
} }
......
{ {
"name": "jf-operation2", "name": "jf-city-investment",
"version": "1.0.0", "version": "1.0.0",
"description": "建发V+移动开发框架", "description": "建发V+城投大运营",
"author": "zhj701", "author": "zhj701",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "node build/dev-server.js", "dev": "node build/dev-server.js",
"start": "npm run dev", "start": "npm run dev",
"build": "npm run build:test", "build": "npm run build:test",
"build:test": "cross-env PACK_ENV=test node build/build.js", "build:test": "cross-env PACK_ENV=test PACK_PLATFORM=cordova node build/build.js",
"build:prod": "cross-env PACK_ENV=prod node build/build.js", "build:prod": "cross-env PACK_ENV=prod PACK_PLATFORM=cordova node build/build.js",
"build:test:cordova": "cross-env PACK_ENV=test PACK_PLATFORM=cordova node build/build.js",
"build:test:qing": "cross-env PACK_ENV=test PACK_PLATFORM=qing node build/build.js",
"build:prod:cordova": "cross-env PACK_ENV=prod PACK_PLATFORM=cordova node build/build.js",
"build:prod:qing": "cross-env PACK_ENV=prod PACK_PLATFORM=qing node build/build.js",
"build:report": "npm run build --report" "build:report": "npm run build --report"
}, },
"dependencies": { "dependencies": {
......
...@@ -31,8 +31,8 @@ class MAS { ...@@ -31,8 +31,8 @@ class MAS {
*/ */
static get TYPE() { static get TYPE() {
return { return {
PROXY: 'mas-api/proxy?alias=', PROXY:process.env.NODE_ENV === 'development' ? 'mas-api/proxy?alias=' : process.env.PACK_PLATFORM === 'qing' ? 'mas/proxy?alias=' : 'mas-api/proxy?alias=',
RESTFUL: 'mas-api/restful/' RESTFUL:process.env.NODE_ENV === 'development' ? 'mas-api/restful/' : process.env.PACK_PLATFORM === 'qing' ? 'mas/restful/' : 'mas-api/restful/',
} }
} }
...@@ -54,7 +54,7 @@ class MAS { ...@@ -54,7 +54,7 @@ class MAS {
* @memberof MAS * @memberof MAS
*/ */
responser(result) { responser(result) {
if (result.status === 200) { if (result.status === 200) {
...@@ -98,9 +98,9 @@ class MAS { ...@@ -98,9 +98,9 @@ class MAS {
data: method === 'post' && params, data: method === 'post' && params,
...options ...options
}).then(result => this.responser(result)).catch(error => { }).then(result => this.responser(result)).catch(error => {
}) })
} }
/** /**
...@@ -113,7 +113,7 @@ class MAS { ...@@ -113,7 +113,7 @@ class MAS {
*/ */
proxy(alias, params, options) { proxy(alias, params, options) {
params = Object.assign({ params = Object.assign({
[this.tokenKey]: this.token [this.tokenKey]: this.token
}, params, options && options.params) }, params, options && options.params)
...@@ -457,4 +457,4 @@ const errorCode = { ...@@ -457,4 +457,4 @@ const errorCode = {
* 错误代码 * 错误代码
* @type {{}} * @type {{}}
*/ */
MAS.ERROR_CODE = errorCode MAS.ERROR_CODE = errorCode
\ No newline at end of file
...@@ -27,28 +27,31 @@ export default class CordovaApi extends NativeApi { ...@@ -27,28 +27,31 @@ export default class CordovaApi extends NativeApi {
if (typeof window !== 'undefined' && typeof window.document !== 'undefined') { if (typeof window !== 'undefined' && typeof window.document !== 'undefined') {
var self = this var self = this
/* if (process.env.PACK_PLATFORM === 'qing') {
if (!window.document.getElementById('cordovaJS')) { window.qing.ready(() => {
var script = window.document.createElement('script') self.doReady(self)
script.id = 'cordovaJS' })
script.src = 'cordova.js' } else {
script.type = 'text/javascript' console.log('走的这里 cordova>>')
script.async = false if (!window.document.getElementById('cordovaJS')) {
script.onload = function () { var script = window.document.createElement('script')
console.log('Loading Cordova Plugin...') script.id = 'cordovaJS'
window.document.addEventListener('deviceready', function () { script.src = 'cordova.js'
self.doReady(self) script.type = 'text/javascript'
}, false) script.async = false
} script.onload = function () {
script.onerror = function () { console.log('Loading Cordova Plugin...')
console.error('Cannot Load Cordova Plugin!') window.document.addEventListener('deviceready', function () {
console.log('cordova 就绪!!!>>')
self.doReady(self)
}, false)
}
script.onerror = function () {
console.error('Cannot Load Cordova Plugin!')
}
window.document.body.appendChild(script)
} }
window.document.body.appendChild(script)
} }
*/
qing.ready(() => {
self.doReady(self)
})
} }
} }
......
...@@ -4,7 +4,7 @@ import GeoLocation from './modules/geoLocation' ...@@ -4,7 +4,7 @@ import GeoLocation from './modules/geoLocation'
import UserInteraction from './modules/userInteraction' import UserInteraction from './modules/userInteraction'
import Account from './modules/account' import Account from './modules/account'
import Navigator from './modules/navigator' import Navigator from './modules/navigator'
import DataInteraction from './modules/DataInteraction' import DataInteraction from './modules/dataInteraction'
export default function (config) { export default function (config) {
return new CordovaApi(config) return new CordovaApi(config)
......
/** @module extend/common **/ /** @module extend/common **/
import * as types from '../types' import * as types from '../types'
import BaseModel from '../../native/BaseModel' import BaseModel from '../../native/baseModel'
/** /**
* 用户账户 * 用户账户
* @extends BaseModel * @extends BaseModel
......
/** @module extend/common **/ /** @module extend/common **/
import * as types from '../types' import * as types from '../types'
import BaseModel from '../../native/BaseModel' import BaseModel from '../../native/baseModel'
/** /**
* 原生与h5数据交互相关 * 原生与h5数据交互相关
* @extends BaseModel * @extends BaseModel
......
/** @module extend/common **/ /** @module extend/common **/
import * as types from '../types' import * as types from '../types'
import BaseModel from '../../native/BaseModel' import BaseModel from '../../native/baseModel'
/** /**
* 地图定位导航相关接口 * 地图定位导航相关接口
* @extends BaseModel * @extends BaseModel
......
/** @module extend/common **/ /** @module extend/common **/
import * as types from '../types' import * as types from '../types'
import BaseModel from '../../native/BaseModel' import BaseModel from '../../native/baseModel'
/** /**
* 应用导航器 * 应用导航器
* @extends BaseModel * @extends BaseModel
......
/** @module extend/common **/ /** @module extend/common **/
import * as types from '../types' import * as types from '../types'
import BaseModel from '../../native/BaseModel' import BaseModel from '../../native/baseModel'
import configJson from '../../../../../../CubeModule.json' import configJsonProd from '../../../../../../CubeModule-prod.json'
import configJsonTest from '../../../../../../CubeModule-test.json'
/** /**
* 系统通用接口 * 系统通用接口
...@@ -122,7 +123,7 @@ export default class System extends BaseModel { ...@@ -122,7 +123,7 @@ export default class System extends BaseModel {
} }
/** /**
* 改变状态栏样式 * 改变状态栏样式
* @param {Array=} params [0] * @param {Array=} params [0]
* @return {Promise} * @return {Promise}
* @result # * @result #
*/ */
...@@ -213,11 +214,12 @@ export default class System extends BaseModel { ...@@ -213,11 +214,12 @@ export default class System extends BaseModel {
identifier: 'com.meicloud.vue.template', identifier: 'com.meicloud.vue.template',
widget_name: '', widget_name: '',
widget_version: '' widget_version: ''
}] }]
* @return {Promise} * @return {Promise}
* @result # * @result #
*/ */
uploadUserData (valParams) { uploadUserData (valParams) {
const configJson = process.env.PACK_ENV === 'test' ? configJsonTest : configJsonProd
let tmpParams = Object.assign({ let tmpParams = Object.assign({
identifier:configJson.identifier, identifier:configJson.identifier,
widget_name:configJson.name, widget_name:configJson.name,
......
/** @module extend/common **/ /** @module extend/common **/
import * as types from '../types' import * as types from '../types'
import BaseModel from '../../native/BaseModel' import BaseModel from '../../native/baseModel'
/** /**
* 用户交互相关 * 用户交互相关
* @extends BaseModel * @extends BaseModel
......
import './cordova.js' import './cordova.js'
import './request.js' import './request.js'
const events = {} const events = {}
window.customEvt = { window.customEvt = {
addEventListener: function (name, fn) { addEventListener: function (name, fn) {
console.log('customEvt addEventListener>>', name)
if (!events[name]) { if (!events[name]) {
events[name] = [] events[name] = []
} }
......
...@@ -24,7 +24,7 @@ export function randomNumber(minNum, maxNum) { ...@@ -24,7 +24,7 @@ export function randomNumber(minNum, maxNum) {
} }
//获取cookie、 //获取cookie、
export function getCookie(name) { export function getCookie_qing(name) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
qing.call('getStorage', { qing.call('getStorage', {
key: name, key: name,
...@@ -57,7 +57,7 @@ export function getCookie(name) { ...@@ -57,7 +57,7 @@ export function getCookie(name) {
} }
//设置cookie,增加到vue实例方便全局调用 //设置cookie,增加到vue实例方便全局调用
export function setCookie(name, value, days) { export function setCookie_qing(name, value, days) {
days = days || 1 days = days || 1
if (days < 0) { if (days < 0) {
return delCookie(name) return delCookie(name)
...@@ -87,10 +87,9 @@ export function setCookie(name, value, days) { ...@@ -87,10 +87,9 @@ export function setCookie(name, value, days) {
} }
//删除cookie //删除cookie
export function delCookie(name) { export function delCookie_qing(name) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getCookie(name) getCookie(name).then((val) => {
.then((val) => {
if (val === null) { if (val === null) {
resolve() resolve()
return return
...@@ -112,3 +111,33 @@ export function delCookie(name) { ...@@ -112,3 +111,33 @@ export function delCookie(name) {
}) })
}) })
} }
//获取cookie、
export function getCookie_cordova(name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg))
return (arr[ 2 ]);
else
return null;
}
//设置cookie,增加到vue实例方便全局调用
export function setCookie_cordova(c_name, value, expiredays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + expiredays);
document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}
//删除cookie
export function delCookie_cordova(name) {
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval = getCookie(name);
if (cval != null)
document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
}
export const setCookie = process.env.PACK_PLATFORM === 'qing' ? setCookie_qing : setCookie_cordova
export const getCookie = process.env.PACK_PLATFORM === 'qing' ? getCookie_qing : getCookie_cordova
export const delCookie = process.env.PACK_PLATFORM === 'qing' ? delCookie_qing : delCookie_cordova
const testToken = 'T5542469125211136' // 华南区域:xuhy@cndrealty.com账号 const testToken = 'yzj_97f7215ff22d58013b61d9f47abe7679' // 华南区域:xuhy@cndrealty.com账号
const testUid = '' // 华南区域:xuhy@cndrealty.com账号 const testUid = '' // 华南区域:xuhy@cndrealty.com账号
export const SetToken = function (val) { export const SetToken = function (val) {
let env = process.env.NODE_ENV let env = process.env.NODE_ENV
......
This diff could not be displayed because it is too large.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment