diff --git a/.DS_Store b/.DS_Store index 082e3dd4..760c2524 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/ios/twolife.xcodeproj/project.pbxproj b/ios/twolife.xcodeproj/project.pbxproj index ed89fdd0..dc5dc259 100644 --- a/ios/twolife.xcodeproj/project.pbxproj +++ b/ios/twolife.xcodeproj/project.pbxproj @@ -5,6 +5,7 @@ }; objectVersion = 46; objects = { + /* Begin PBXBuildFile section */ 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; }; 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; }; @@ -33,9 +34,11 @@ 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; }; 61305C7114B34B5FA49EB341 /* RCTWeChatTests.xctest in Frameworks */ = {isa = PBXBuildFile; fileRef = 9205A697341B40CE9892ADF8 /* RCTWeChatTests.xctest */; }; 6AE5977016704210A78499D6 /* Foundation.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 06E5ABDD9D214552BE226BE6 /* Foundation.ttf */; }; + 6C309C80D9B544DC95026FC5 /* libRNRandomBytes.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 340DE058FF5A4D12BC218138 /* libRNRandomBytes.a */; }; 6CD1211A9B7347DABC6B640D /* EvilIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A8563AD954754FA79DC7BFD2 /* EvilIcons.ttf */; }; 72333F08C04248CF9B56EB53 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0E14EDFD7B6B4A8587820696 /* UserNotifications.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; + 8753BFA3EA9549C3A4505E6C /* libRNFetchBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3CA5914D62CA405D91AC8093 /* libRNFetchBlob.a */; }; 8DD68603354F47E9A70960B0 /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C0596769BFEE40AA90A8875B /* Ionicons.ttf */; }; 92B785A105714938A4CCB03C /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 75FE64CED75040DFA12ED2D5 /* CoreTelephony.framework */; }; 94BC4A8211D34096A7172DC4 /* libRCTJCoreModule.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EA0BF20A7F0F4D64A67BF17D /* libRCTJCoreModule.a */; }; @@ -56,8 +59,6 @@ E677AB462BA94DF7888044CE /* MaterialCommunityIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C6B2BD8D1EEF4CD3BFF8AE36 /* MaterialCommunityIcons.ttf */; }; F15975032708487CA067E050 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1BFF6A3CE2D24A5BA61607A3 /* SystemConfiguration.framework */; }; F4DB41B3C20847258E17BC9D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F10A05898C9844D6B90702E3 /* UIKit.framework */; }; - 8753BFA3EA9549C3A4505E6C /* libRNFetchBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3CA5914D62CA405D91AC8093 /* libRNFetchBlob.a */; }; - 6C309C80D9B544DC95026FC5 /* libRNRandomBytes.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 340DE058FF5A4D12BC218138 /* libRNRandomBytes.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -348,6 +349,34 @@ remoteGlobalIDString = 3D7682761D8E76B80014119E; remoteInfo = SplashScreen; }; + A03B037221135B0B009749AD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 05901D607EDC466A94BCA43E /* RCTWeChat.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 10D6D7A41F160C250066F0F3; + remoteInfo = RCTWeChatTests; + }; + A03B038E21135B0B009749AD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C59EA149FE56410FAE4A12F5 /* RNRandomBytes.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 73EEC9391BFE4B1D00D468EB; + remoteInfo = RNRandomBytes; + }; + A03B039021135B0B009749AD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C59EA149FE56410FAE4A12F5 /* RNRandomBytes.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 163CDE4E2087CAD3001065FB; + remoteInfo = "RNRandomBytes-tvOS"; + }; + A03B039521135B0B009749AD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = E0C2A9424E9D46B8B8D6E0E9 /* RNFetchBlob.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = A15C300E1CD25C330074CB35; + remoteInfo = RNFetchBlob; + }; A07C4BC420906D93007CF633 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; @@ -442,7 +471,9 @@ 1CFDC721882643849D92DD16 /* RNVectorIcons.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNVectorIcons.xcodeproj; path = "../node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj"; sourceTree = ""; }; 2E18BEB16A674C4CB8680AD3 /* libresolv.tbd */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; }; 2F18567F109544FD8498190E /* RNIap.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNIap.xcodeproj; path = "../node_modules/react-native-iap/ios/RNIap.xcodeproj"; sourceTree = ""; }; + 340DE058FF5A4D12BC218138 /* libRNRandomBytes.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNRandomBytes.a; sourceTree = ""; }; 39B5C8A559C744A2A9DCFDBA /* FontAwesome.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = FontAwesome.ttf; path = "../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf"; sourceTree = ""; }; + 3CA5914D62CA405D91AC8093 /* libRNFetchBlob.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNFetchBlob.a; sourceTree = ""; }; 545E5818A6094122BF5038E6 /* RCTJPushModule.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RCTJPushModule.xcodeproj; path = "../node_modules/jpush-react-native/ios/RCTJPushModule.xcodeproj"; sourceTree = ""; }; 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = ""; }; 61D69C474DBB43DFA6423FCC /* SplashScreen.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = SplashScreen.xcodeproj; path = "../node_modules/react-native-splash-screen/ios/SplashScreen.xcodeproj"; sourceTree = ""; }; @@ -471,22 +502,20 @@ B59C1ACFF2F04CF6A163F4C6 /* libSplashScreen.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libSplashScreen.a; sourceTree = ""; }; C0596769BFEE40AA90A8875B /* Ionicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Ionicons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf"; sourceTree = ""; }; C5988C38694A474A9D26EE6E /* Security.framework */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; + C59EA149FE56410FAE4A12F5 /* RNRandomBytes.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNRandomBytes.xcodeproj; path = "../node_modules/react-native-randombytes/RNRandomBytes.xcodeproj"; sourceTree = ""; }; C6B2BD8D1EEF4CD3BFF8AE36 /* MaterialCommunityIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialCommunityIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf"; sourceTree = ""; }; CED43EC1C21140D1AF2B695C /* libz.tbd */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; D54BAE62E35D4BBDB2655095 /* libReactNativeNavigation.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libReactNativeNavigation.a; sourceTree = ""; }; D6311CD01EF4E118001D305E /* twolife.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = twolife.entitlements; path = twolife/twolife.entitlements; sourceTree = ""; }; DD10E3BB5B0D4691A3348CD8 /* Foundation.framework */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; DFEDE23D26454B0BACF5F50B /* libRNSVG.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNSVG.a; sourceTree = ""; }; + E0C2A9424E9D46B8B8D6E0E9 /* RNFetchBlob.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNFetchBlob.xcodeproj; path = "../node_modules/rn-fetch-blob/ios/RNFetchBlob.xcodeproj"; sourceTree = ""; }; EA0BF20A7F0F4D64A67BF17D /* libRCTJCoreModule.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTJCoreModule.a; sourceTree = ""; }; EB85D2CEDB3F48BEAB0B4520 /* Octicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Octicons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Octicons.ttf"; sourceTree = ""; }; F10A05898C9844D6B90702E3 /* UIKit.framework */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; F268BB9C26E64FF1973CC673 /* libRCTJPushModule.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTJPushModule.a; sourceTree = ""; }; F8CAD2C6107F41359A851F13 /* RNSVG.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNSVG.xcodeproj; path = "../node_modules/react-native-svg/ios/RNSVG.xcodeproj"; sourceTree = ""; }; FE2B1BF901624642909105E4 /* libRNImagePicker.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNImagePicker.a; sourceTree = ""; }; - E0C2A9424E9D46B8B8D6E0E9 /* RNFetchBlob.xcodeproj */ = {isa = PBXFileReference; name = "RNFetchBlob.xcodeproj"; path = "../node_modules/rn-fetch-blob/ios/RNFetchBlob.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; - 3CA5914D62CA405D91AC8093 /* libRNFetchBlob.a */ = {isa = PBXFileReference; name = "libRNFetchBlob.a"; path = "libRNFetchBlob.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; - C59EA149FE56410FAE4A12F5 /* RNRandomBytes.xcodeproj */ = {isa = PBXFileReference; name = "RNRandomBytes.xcodeproj"; path = "../node_modules/react-native-randombytes/RNRandomBytes.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; - 340DE058FF5A4D12BC218138 /* libRNRandomBytes.a */ = {isa = PBXFileReference; name = "libRNRandomBytes.a"; path = "libRNRandomBytes.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -824,6 +853,8 @@ 0654BA6CDA184C4685B61E3C /* libRNIap.a */, 9FABAE4CD11649FCB73CF427 /* libRCTWeChat.a */, 9205A697341B40CE9892ADF8 /* RCTWeChatTests.xctest */, + 3CA5914D62CA405D91AC8093 /* libRNFetchBlob.a */, + 340DE058FF5A4D12BC218138 /* libRNRandomBytes.a */, ); name = "Recovered References"; sourceTree = ""; @@ -868,6 +899,23 @@ name = Products; sourceTree = ""; }; + A03B038A21135B0B009749AD /* Products */ = { + isa = PBXGroup; + children = ( + A03B038F21135B0B009749AD /* libRNRandomBytes.a */, + A03B039121135B0B009749AD /* libRNRandomBytes-tvOS.a */, + ); + name = Products; + sourceTree = ""; + }; + A03B039221135B0B009749AD /* Products */ = { + isa = PBXGroup; + children = ( + A03B039621135B0B009749AD /* libRNFetchBlob.a */, + ); + name = Products; + sourceTree = ""; + }; A07C4BE220908150007CF633 /* Products */ = { isa = PBXGroup; children = ( @@ -880,6 +928,7 @@ isa = PBXGroup; children = ( A0FB14E820BA7DB500E71FFF /* libRCTWeChat.a */, + A03B037321135B0B009749AD /* RCTWeChatTests.xctest */, ); name = Products; sourceTree = ""; @@ -1008,6 +1057,10 @@ ProductGroup = 146834001AC3E56700842450 /* Products */; ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; }, + { + ProductGroup = A03B039221135B0B009749AD /* Products */; + ProjectRef = E0C2A9424E9D46B8B8D6E0E9 /* RNFetchBlob.xcodeproj */; + }, { ProductGroup = 9DBAAD8B20A169690006BC8A /* Products */; ProjectRef = 2F18567F109544FD8498190E /* RNIap.xcodeproj */; @@ -1016,6 +1069,10 @@ ProductGroup = A07C4BE220908150007CF633 /* Products */; ProjectRef = 046D6C076C264CACA77FF613 /* RNImagePicker.xcodeproj */; }, + { + ProductGroup = A03B038A21135B0B009749AD /* Products */; + ProjectRef = C59EA149FE56410FAE4A12F5 /* RNRandomBytes.xcodeproj */; + }, { ProductGroup = 9D24494A209D7C3500171DF5 /* Products */; ProjectRef = F8CAD2C6107F41359A851F13 /* RNSVG.xcodeproj */; @@ -1324,6 +1381,34 @@ remoteRef = 9DD2BF451EEEF08D000D68C8 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + A03B037321135B0B009749AD /* RCTWeChatTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = RCTWeChatTests.xctest; + remoteRef = A03B037221135B0B009749AD /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + A03B038F21135B0B009749AD /* libRNRandomBytes.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libRNRandomBytes.a; + remoteRef = A03B038E21135B0B009749AD /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + A03B039121135B0B009749AD /* libRNRandomBytes-tvOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libRNRandomBytes-tvOS.a"; + remoteRef = A03B039021135B0B009749AD /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + A03B039621135B0B009749AD /* libRNFetchBlob.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libRNFetchBlob.a; + remoteRef = A03B039521135B0B009749AD /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; A07C4BC520906D93007CF633 /* libReact.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; diff --git a/ios/twolife.xcodeproj/project.xcworkspace/xcuserdata/light.xcuserdatad/UserInterfaceState.xcuserstate b/ios/twolife.xcodeproj/project.xcworkspace/xcuserdata/light.xcuserdatad/UserInterfaceState.xcuserstate index 8c6d233f..7dc7f93c 100644 Binary files a/ios/twolife.xcodeproj/project.xcworkspace/xcuserdata/light.xcuserdatad/UserInterfaceState.xcuserstate and b/ios/twolife.xcodeproj/project.xcworkspace/xcuserdata/light.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/res/images/profile/.DS_Store b/res/images/profile/.DS_Store index cfbc04c0..40f5d947 100644 Binary files a/res/images/profile/.DS_Store and b/res/images/profile/.DS_Store differ diff --git a/src/common/util.js b/src/common/util.js index 3c6a34ea..4ec44292 100644 --- a/src/common/util.js +++ b/src/common/util.js @@ -499,7 +499,13 @@ export async function updateFile(obj) { // 不用同步直接删除日记 if (obj.action === 'delete') { - diaryList = diaryList.filter(diary => diary.uuid !== obj.data.uuid) + if (obj.data instanceof Array) { + for (let i = 0; i < obj.data.length; i++) { + diaryList = diaryList.filter(diary => diary.uuid !== obj.data[i].uuid) + } + } else { + diaryList = diaryList.filter(diary => diary.uuid !== obj.data.uuid) + } } // 删除匹配对象到日记 @@ -514,7 +520,8 @@ export async function updateFile(obj) { } await fs.writeFile(FILE_PATH, JSON.stringify(newContent), 'utf8') - + console.log(obj.action) + console.log(obj.data) DeviceEventEmitter.emit('flush_local_note') } diff --git a/src/containers/Index.js b/src/containers/Index.js index 85432bbd..6492e5f0 100644 --- a/src/containers/Index.js +++ b/src/containers/Index.js @@ -54,7 +54,6 @@ export default class Index extends Component { }) // 刷新通知、刷新日记、刷新用户 DeviceEventEmitter.emit('flush_notification', {}) - const res = await HttpUtils.get(USERS.user, { user_id: this.props.user.id }) if (res.code === 0) { store.dispatch(fetchProfileSuccess(res.data)) diff --git a/src/containers/home/DiaryBanner.js b/src/containers/home/DiaryBanner.js index c3bf74db..a25f794b 100644 --- a/src/containers/home/DiaryBanner.js +++ b/src/containers/home/DiaryBanner.js @@ -124,11 +124,14 @@ export default class DiaryBanner extends Component { width={WIDTH} height={getResponsiveWidth(282)} style={styles.swiper} - loop={false} + autoplay + loop={false} //true有BUG dot={} activeDot={} bounces={true} onIndexChanged={this._onImgChanged.bind(this)} + onTouchStart={this.props.onTouchStart} + onTouchEnd={this.props.onTouchEnd} > {this.state.imgListComponent} diff --git a/src/containers/home/DiaryDetail.js b/src/containers/home/DiaryDetail.js index 40335e79..4e4f730e 100644 --- a/src/containers/home/DiaryDetail.js +++ b/src/containers/home/DiaryDetail.js @@ -216,11 +216,11 @@ export default class DiaryDetail extends Component { setKeyboard() { Keyboard.addListener('keyboardWillShow', event => { - this.setState({showKeyboard: true}) + this.setState({ showKeyboard: true }) this.toggleInputComment(true, event) }) Keyboard.addListener('keyboardWillHide', event => { - this.setState({showKeyboard: false}) + this.setState({ showKeyboard: false }) this.toggleInputComment(false, event) }) } @@ -275,18 +275,19 @@ export default class DiaryDetail extends Component { return ( - this.setState({ showImgPreview: true })} - activeOpacity={1} - > - - + this.setState({ touchStartTs: Date.now() })} + onTouchEnd={() => { + if (Date.now() - this.state.touchStartTs < 80) { + this.setState({ showImgPreview: true }) + } + }} + /> {/* 在无图片日记下的顶部导航 */} {this.state.likeComponent} - + { this._fetchDiary() @@ -98,7 +98,7 @@ export default class Home extends Component { } async _fetchDiary() { - this.setState({ isRefreshing: true }) + if (!this.props.user.id) return if (this.props.user.user_other_id === -1) { await updateFile({ @@ -113,9 +113,10 @@ export default class Home extends Component { const { partner, recommend, user } = res.data let diaryList = [...partner, ...user] - // 版本过渡:保存网络日记到本地配置文件 const localDiaryList = await readFile(this.props.user.id) + const localPartnerDiaryList = localDiaryList.filter(diary => diary.user_id !== this.props.user.id) + // 保存新日记 let newDiaryList = [] if (localDiaryList.length) { for (let i = 0; i < diaryList.length; i++) { @@ -129,7 +130,31 @@ export default class Home extends Component { } } } else { - newDiaryList = [...diaryList] + newDiaryList = [...diaryList] + } + + // 删除、更新伙伴日记, + let deleteDiaryList = [], updateDiaryList = [] + if (partner.length) { + for (let i = 0; i < localPartnerDiaryList.length; i++) { + for (let j = 0; j < partner.length; j++) { + if (localPartnerDiaryList[i].id === partner[j].id) { + break + } + if (j === partner.length - 1) { + deleteDiaryList.push(localPartnerDiaryList[i]) + } + } + + for (let z = 0; z < partner.length; z++) { + if ((localPartnerDiaryList[i].id === partner[z].id) && (localPartnerDiaryList[i].updated_at !== partner[z].updated_at)) { + updateDiaryList.push({ ...localPartnerDiaryList[i], ...partner[z] }) + break + } + } + } + } else { + deleteDiaryList = [...localPartnerDiaryList] } for (let newDiary of newDiaryList) { @@ -146,19 +171,40 @@ export default class Home extends Component { } } - this._formDiaryList(newDiaryList) - // 更新配置文件 - updateFile({ + // 增加日记 + newDiaryList.length && + await updateFile({ user_id: this.props.user.id || 0, action: 'add', data: newDiaryList }) - } - // this.setState({ isRefreshing: false }) + // 更新日记 + updateDiaryList.length && + await updateFile({ + user_id: this.props.user.id || 0, + action: 'update', + data: updateDiaryList + }) + + // 删除日记 + deleteDiaryList.length && + await updateFile({ + user_id: this.props.user.id || 0, + action: 'delete', + data: deleteDiaryList + }) + + this._formDiaryList(await readFile(this.props.user.id)) + } } - _formDiaryList(diaryList) { + async _formDiaryList(diaryList) { + this.setState({ isRefreshing: false }) + if (!diaryList) { + diaryList = await readFile(this.props.user.id) + } + diaryList.sort((a, b) => b.date - a.date) diaryList = diaryClassify(diaryList) @@ -535,7 +581,7 @@ export default class Home extends Component { renderItem={this._renderItem} ListEmptyComponent={() => this._emptyDiary()} ListFooterComponent={() => this._listFooter()} - onRefresh={async () => this._formDiaryList(await readFile(this.props.user.id))} + onRefresh={() => this._fetchDiary()} refreshing={this.state.isRefreshing} /> diff --git a/src/containers/profile/Profile.js b/src/containers/profile/Profile.js index 4cd999b9..70fa4e72 100644 --- a/src/containers/profile/Profile.js +++ b/src/containers/profile/Profile.js @@ -72,10 +72,10 @@ export default class Profile extends Component { // 平均情绪值和日记数量 this.setState({ - myAverageMode: Math.floor(myTotalMode / myDiaryList.length), - otherAverageMode: Math.floor(otherTotalMode / otherDiaryList.length), - myDiaryCount: myDiaryList.length, - otherDiaryCount: otherDiaryList.length + myAverageMode: Math.floor(myTotalMode / myDiaryList.length) || 0, + otherAverageMode: Math.floor(otherTotalMode / otherDiaryList.length) || 0, + myDiaryCount: myDiaryList.length || 0, + otherDiaryCount: otherDiaryList.length || 0 }) } diff --git a/src/containers/profile/ProfileTest.js b/src/containers/profile/ProfileTest.js index f2090632..e2d683ce 100644 --- a/src/containers/profile/ProfileTest.js +++ b/src/containers/profile/ProfileTest.js @@ -106,6 +106,7 @@ export default class ProfileReward extends Component { 性格测试完成啦,但为了让结果更准确,你还需要多写几篇真情流露的日记呢 + 稍后可在「个人页」→「情绪管理」查看更详细内容 ) @@ -183,6 +184,13 @@ const styles = StyleSheet.create({ fontWeight: '400', textAlign: 'center' }, + text_small: { + color: '#aaa', + fontSize: 12, + fontWeight: '400', + textAlign: 'center', + marginTop: getResponsiveWidth(8) + }, question_container: { width: WIDTH - getResponsiveWidth(48), height: getResponsiveWidth(360), diff --git a/src/network/HttpUtils.js b/src/network/HttpUtils.js index 8b1011bb..52af510e 100644 --- a/src/network/HttpUtils.js +++ b/src/network/HttpUtils.js @@ -14,7 +14,6 @@ export function setToken(data) { } // let baseUrl = 'http://localhost:3002' -// let baseUrl = 'http://172.20.10.4:3002' let baseUrl = 'https://2life.api.ursb.me' axios.defaults.timeout = 20000