This commit is contained in:
saplf
2019-09-08 13:03:43 +08:00
parent b004908af9
commit 5351afaae3
25 changed files with 263 additions and 14 deletions

7
.gitignore vendored
View File

@@ -21,3 +21,10 @@
/.vscode /.vscode
/.idea /.idea
*.iml *.iml
# HBuilder
/h5pack/*.js
/h5pack/*.css
/h5pack/index.html
/h5pack/favicon.ico
/h5pack/static/

225
h5pack/manifest.json Normal file
View File

@@ -0,0 +1,225 @@
{
"@platforms" : [ "android", "iPhone" ],
"id" : "H51E9A088", /**/
"name" : "FIV", /**/
"version" : {
"name" : "1.0", /**/
"code" : 1
},
"description" : "", /**/
"icons" : {
"72" : "icon.png"
},
"launch_path" : "index.html", /*index.htmlhttp://或https://开头*/
"developer" : {
"name" : "", /**/
"email" : "", /**/
"url" : "" /**/
},
"permissions" : {
"Accelerometer" : {
"description" : "访问加速度感应器"
},
"Audio" : {
"description" : "访问麦克风"
},
"Cache" : {
"description" : "管理应用缓存"
},
"Camera" : {
"description" : "访问摄像头"
},
"Console" : {
"description" : "跟踪调试输出日志"
},
"Device" : {
"description" : "访问设备信息"
},
"Downloader" : {
"description" : "文件下载管理"
},
"Events" : {
"description" : "应用扩展事件"
},
"File" : {
"description" : "访问本地文件系统"
},
"Gallery" : {
"description" : "访问系统相册"
},
"Geolocation" : {
"description" : "访问位置信息"
},
"Invocation" : {
"description" : "使用Native.js能力"
},
"Orientation" : {
"description" : "访问方向感应器"
},
"Proximity" : {
"description" : "访问距离感应器"
},
"Share" : {
"description" : "分享"
},
"Storage" : {
"description" : "管理应用本地数据"
},
"Uploader" : {
"description" : "管理文件上传任务"
},
"Runtime" : {
"description" : "访问运行期环境"
},
"XMLHttpRequest" : {
"description" : "跨域网络访问"
},
"Zip" : {
"description" : "文件压缩与解压缩"
},
"Barcode" : {
"description" : "管理二维码扫描插件"
},
"Webview" : {
"description" : "窗口管理"
},
"NativeUI" : {
"description" : "原生UI控件"
},
"Navigator" : {
"description" : "浏览器信息"
},
"NativeObj" : {
"description" : "原生对象"
}
},
"plus" : {
"splashscreen" : {
"autoclose" : true, /*truefalseplus.navigator.closeSplashscreen()*/
"waiting" : true /*truefalse*/
},
"popGesture" : "close", /*Webview"none""hide"Webviewhttp://ask.dcloud.net.cn/article/102*/
"runmode" : "normal", /*liberatenormalliberateAndroidFile API访_www*/
"signature" : "Sk9JTiBVUyBtYWlsdG86aHIyMDEzQGRjbG91ZC5pbw==", /*使*/
"distribute" : {
"apple" : {
"appid" : "org.faronear.fiv", /*iOSappidio.dcloud.HelloH5*/
"mobileprovision" : "", /*iOS*/
"password" : "", /*iOS*/
"p12" : "", /*iOS*/
"devices" : "iphone", /*iOSiphone/ipad/universal*/
"frameworks" : [] /*Native.jsObjective-c APIFrameWorkGameCenter"GameKit.framework"*/
},
"google" : {
"packagename" : "org.faronear.fiv", /*Androidio.dcloud.HelloH5*/
"keystore" : "unpackage/key/fiv.keystore", /*Android使*/
"password" : "fivfiv", /*Android使*/
"aliasname" : "fiv", /*Android使*/
"permissions" : [
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>"
]
},
/*使Native.jsAPI使*/
"orientation" : [ "portrait-primary" ], /*portrait-primaryportrait-secondarylandscape-primarylandscape-secondary*/
"icons" : {
"ios" : {
"prerendered" : true, /*iOS6*/
"auto" : "", /*512x512*/
"iphone" : {
"normal" : "", /*iPhone3/3GS57x57*/
"retina" : "", /*iPhone4114x114*/
"retina7" : "", /*iPhone4S/5/6120x120*/
"retina8" : "", /*iPhone6 Plus180x180*/
"spotlight-normal" : "", /*iPhone3/3GS Spotlight29x29*/
"spotlight-retina" : "", /*iPhone4 Spotlight58x58*/
"spotlight-retina7" : "", /*iPhone4S/5/6 Spotlight80x80*/
"settings-normal" : "", /*iPhone429x29*/
"settings-retina" : "", /*iPhone4S/5/658x58*/
"settings-retina8" : "", /*iPhone6Plus87x87*/
"app@2x" : "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"notification@3x" : "unpackage/res/icons/60x60.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png"
},
"ipad" : {
"normal" : "", /*iPad72x72*/
"retina" : "", /*iPad144x144*/
"normal7" : "", /*iPad iOS776x76*/
"retina7" : "", /*iPad iOS7152x152*/
"spotlight-normal" : "", /*iPad Spotlight50x50*/
"spotlight-retina" : "", /*iPadSpotlight100x100*/
"spotlight-normal7" : "", /*iPad iOS7 Spotlight40x40*/
"spotlight-retina7" : "", /*iPad iOS7Spotlight80x80*/
"settings-normal" : "", /*iPad29x29*/
"settings-retina" : "", /*iPad58x58*/
"app" : "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png",
"notification" : "unpackage/res/icons/20x20.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"proapp@2x" : "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png"
},
"appstore" : "unpackage/res/icons/1024x1024.png"
},
"android" : {
"mdpi" : "", /*48x48*/
"ldpi" : "", /*48x48*/
"hdpi" : "unpackage/res/icons/72x72.png", /*72x72*/
"xhdpi" : "unpackage/res/icons/96x96.png", /*720P96x96*/
"xxhdpi" : "unpackage/res/icons/144x144.png", /*1080P 144x144*/
"xxxhdpi" : "unpackage/res/icons/192x192.png"
}
},
"splashscreen" : {
"ios" : {
"iphone" : {
"default" : "", /*iPhone3320x480*/
"retina35" : "", /*3.5(iPhone4)640x960*/
"retina40" : "", /*4.0 (iPhone5/iPhone5s)640x1136*/
"retina47" : "", /*4.7 (iPhone6)750x1334*/
"retina55" : "", /*5.5 (iPhone6 Plus)1242x2208*/
"retina55l" : "" /*5.5 (iPhone6 Plus)2208x1242*/
},
"ipad" : {
"portrait" : "", /*iPad768x1004*/
"portrait-retina" : "", /*iPad1536x2008*/
"landscape" : "", /*iPad1024x748*/
"landscape-retina" : "", /*iPad2048x1496*/
"portrait7" : "", /*iPad iOS7768x1024*/
"portrait-retina7" : "", /*iPad iOS71536x2048*/
"landscape7" : "", /*iPad iOS71024x768*/
"landscape-retina7" : "" /*iPad iOS72048x1536*/
}
},
"android" : {
"mdpi" : "", /*240x282*/
"ldpi" : "", /*320x442*/
"hdpi" : "", /*480x762*/
"xhdpi" : "", /*720P720x1242*/
"xxhdpi" : "" /*1080P1080x1882*/
}
},
"plugins" : {
"speech" : {}
}
}
}
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1003 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

@@ -1,8 +1,10 @@
import { Model } from 'dva'; import { Model } from 'dva';
import { delay } from 'dva/saga';
import _ from 'lodash'; import _ from 'lodash';
import { getLocale, setLocale } from 'umi-plugin-locale' import { getLocale, setLocale } from 'umi-plugin-locale'
import { loadUser, storeUser, clearUser, clearMineList, clearCoins, clearDrawCoins } from '@/utils/storage'; import { loadUser, storeUser, clearUser, clearMineList, clearCoins, clearDrawCoins } from '@/utils/storage';
import { User } from '@/types/common'; import { User } from '@/types/common';
import { isApp, restart } from '@/utils/h5plus';
const initState = () => { const initState = () => {
const user = loadUser(); const user = loadUser();
@@ -55,7 +57,7 @@ const model: Model = {
}, },
*changeLang({ payload: lang }, { put }) { *changeLang({ payload: lang }, { put }) {
setLocale(lang); setLocale(lang, false);
yield put({ type: 'onUpdateState', payload: { lang } }); yield put({ type: 'onUpdateState', payload: { lang } });
}, },
}, },

View File

@@ -1,6 +1,6 @@
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { connect, DispatchProp, routerRedux } from 'dva'; import { connect, DispatchProp, routerRedux } from 'dva';
import { Spin, Icon } from 'antd'; import _ from 'lodash';
import { formatMessage } from 'umi-plugin-locale'; import { formatMessage } from 'umi-plugin-locale';
import FittedImage from 'react-fitted-image'; import FittedImage from 'react-fitted-image';
import { HomeCommunityModelState } from './model'; import { HomeCommunityModelState } from './model';
@@ -10,6 +10,7 @@ import List from '@/components/List';
import { dispatch } from '@/utils/utils'; import { dispatch } from '@/utils/utils';
import styles from './style.less'; import styles from './style.less';
import { displayPhone } from '@/utils/transform';
const CommunityPage: React.FC<HomeCommunityModelState & DispatchProp> = ({ const CommunityPage: React.FC<HomeCommunityModelState & DispatchProp> = ({
dispatch, dispatch,
@@ -79,10 +80,10 @@ const CommunityPage: React.FC<HomeCommunityModelState & DispatchProp> = ({
{it.avatar ? <FittedImage {it.avatar ? <FittedImage
src={it.avatar} src={it.avatar}
fit="cover" fit="cover"
/> : <div className="fake">{(it.nickname && it.nickname[0]) || 'F'}</div>} /> : <div className="fake">{(it.nickname && it.nickname[0]) || _.last(it.phone) || 'F'}</div>}
</div> </div>
<div className="line"> <div className="line">
<span>{it.nickname || it.phone}</span> <span>{it.nickname || displayPhone(it.phone)}</span>
<span className="time">{formatMessage({ id: 'home.community.time' })}{it.createdAt}</span> <span className="time">{formatMessage({ id: 'home.community.time' })}{it.createdAt}</span>
</div> </div>
</div> </div>

View File

@@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import FittedImage from 'react-fitted-image'; import FittedImage from 'react-fitted-image';
import { connect, DispatchProp, routerRedux } from 'dva'; import { connect, DispatchProp, routerRedux } from 'dva';
import _ from 'lodash';
import { UserModelState } from '@/models/user'; import { UserModelState } from '@/models/user';
import SettingItem from '@/components/SettingItem'; import SettingItem from '@/components/SettingItem';
import logoAccount from '@/assets/p_account.png'; import logoAccount from '@/assets/p_account.png';
@@ -24,7 +25,7 @@ const ProfilePage: React.FC<UserModelState & DispatchProp> = ({
<div className="avatar"> <div className="avatar">
{user.avatar ? {user.avatar ?
<FittedImage src={user.avatar} fit="cover" /> : <FittedImage src={user.avatar} fit="cover" /> :
<span>{user.nickname ? user.nickname[0] : user.phone[0]}</span> <span>{user.nickname ? user.nickname[0] : _.last(user.phone)}</span>
} }
</div> </div>
<span className="name">{user.nickname || user.phone}</span> <span className="name">{user.nickname || user.phone}</span>

View File

@@ -1,15 +1,17 @@
import { dispatch, getState } from './utils'; import { dispatch, getState } from './utils';
import { routerRedux } from 'dva'; import { routerRedux } from 'dva';
const plus = window.plus; const isApp = () => {
const r = typeof window.plus !== 'undefined';
const isApp = () => typeof plus !== 'undefined'; // console.log(r);
return r;
};
const barcodeId = 'barcode' const barcodeId = 'barcode'
const scan = () => { const scan = () => {
if (!isApp()) return Promise.resolve(''); if (!isApp()) return Promise.resolve('');
return new Promise<string>(resolve => { return new Promise<string>(resolve => {
const { barcode, webview } = plus; const { barcode, webview } = window.plus;
const bc = barcode.create(barcodeId, [barcode.QR], { const bc = barcode.create(barcodeId, [barcode.QR], {
position: 'absolute', position: 'absolute',
left: '0px', left: '0px',
@@ -38,42 +40,48 @@ const firstPaths = [
'/home/profile', '/home/profile',
]; ];
const backButtonHandler = () => { const backButtonHandler = () => {
const barcode = plus.barcode.getBarcodeById(barcodeId); const barcode = window.plus.barcode.getBarcodeById(barcodeId);
if (barcode) { if (barcode) {
barcode.close(); barcode.close();
return; return;
} }
const { pathname } = getState().router.location; const { pathname } = getState().router.location;
if (firstPaths.includes(pathname)) { if (firstPaths.includes(pathname)) {
plus.runtime.quit(); window.plus.runtime.quit();
} else { } else {
dispatch(routerRedux.goBack()); dispatch(routerRedux.goBack());
} }
}; };
const init = () => { const init = () => {
if (!isApp()) return; if (!isApp()) return;
plus.key.addEventListener('backbutton', backButtonHandler); window.plus.key.addEventListener('backbutton', backButtonHandler);
}; };
const destory = () => { const destory = () => {
if (!isApp()) return; if (!isApp()) return;
plus.key.removeEventListener('backbutton', backButtonHandler); window.plus.key.removeEventListener('backbutton', backButtonHandler);
}; };
const share = (content: string) => { const share = (content: string) => {
if (!isApp()) return; if (!isApp()) return;
plus.share.sendWithSystem({ window.plus.share.sendWithSystem({
type: 'text', type: 'text',
content, content,
}, () => { }); }, () => { });
}; };
const restart = () => {
if (!isApp()) return;
window.plus.runtime.restart();
}
export { export {
init, init,
isApp, isApp,
scan, scan,
share, share,
destory, destory,
restart,
}; };
export default { export default {
@@ -82,4 +90,5 @@ export default {
scan, scan,
share, share,
destory, destory,
restart,
}; };

View File

@@ -46,3 +46,7 @@ export function fromLangToText(lang: string) {
export function encryptPwd(pwd: string): string { export function encryptPwd(pwd: string): string {
return md5(pwd); return md5(pwd);
} }
export function displayPhone(phone: string): string {
return `1******${_.takeRight(phone, 4).join('')}`;
}