Skip to content

Commit 717c7f1

Browse files
committed
添加清除位置信息功能
1 parent 06ea4f3 commit 717c7f1

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

src/api/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,17 @@ let api = {
282282
}
283283
)
284284
},
285+
clearLocation(cb) {
286+
axios.post('/apis/user/clearLocation').then(
287+
() => {
288+
cb(true)
289+
},
290+
(err) => {
291+
console.error(err)
292+
cb(false)
293+
}
294+
)
295+
},
285296
createMessage ({content, session}, cb) {
286297
const message = {
287298
id: 'm_' + uuidv4(),

src/i18n/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import VueI18n from 'vue-i18n'
22
import Vue from 'vue'
3-
import messages from '../locales'
3+
import messages from './locales'
44

55
Vue.use(VueI18n)
66

src/locales.js renamed to src/i18n/locales.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ export default {
8080
upload: '上传',
8181
readFail: '读取图片失败',
8282
comingSoon: '敬请期待',
83-
photoTooLarge: '图片太大'
83+
photoTooLarge: '图片太大',
84+
clearLocation: '清除位置信息'
8485
}
8586
},
8687
en: {
@@ -164,7 +165,8 @@ export default {
164165
upload: 'Upload',
165166
readFail: 'Read file fail',
166167
comingSoon: 'Coming soon',
167-
photoTooLarge: 'Photo was too large'
168+
photoTooLarge: 'Photo was too large',
169+
clearLocation: 'Clear location'
168170
}
169171
}
170172
}

src/views/NearbyPeople.vue

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<a href="javascript:;" slot="left" @click="back">
55
<mt-button icon="back">{{$t('msg.back')}}</mt-button>
66
</a>
7+
<mt-button icon="more" slot="right" @click.native="sheetVisible = true"></mt-button>
78
</mt-header>
89
<div class="nearby-people-list">
910
<mt-cell v-for="(p, i) in nearbyPeoples" isLink :to="(friendsInfo.hasOwnProperty(p.username) ? '/friendCard' : '/AddNearbyPeople') + '?friendName=' + p.username" :key="i" :title="p.username" :label="formatDistance(p.distance)" @click.native="">
@@ -12,12 +13,24 @@
1213
</mt-cell>
1314
<div v-show="nearbyPeoples.length === 0" class="no-data">{{ $t('msg.noData') }}</div>
1415
</div>
16+
<mt-actionsheet :actions="[
17+
{
18+
name: this.$t('msg.clearLocation'),
19+
method: () => {
20+
this.handleClearLocation()
21+
}
22+
}
23+
]"
24+
:cancelText="$t('msg.cancel')"
25+
v-model="sheetVisible">
26+
</mt-actionsheet>
1527
</div>
1628
</template>
1729
<script>
1830
import {Toast, Indicator} from 'mint-ui'
1931
import {mapGetters} from 'vuex'
2032
import WcProfilePhoto from "../components/ProfilePhoto"
33+
import api from '../api'
2134
2235
export default {
2336
name: 'wc-nearby-people',
@@ -27,7 +40,8 @@
2740
position: {
2841
latitude: -1,
2942
longitude: -1
30-
}
43+
},
44+
sheetVisible: false
3145
}
3246
},
3347
computed: {
@@ -89,6 +103,13 @@
89103
return d.toFixed(2) + u + '以内'
90104
}
91105
return 'Within: ' + d.toFixed(2) + u
106+
},
107+
handleClearLocation() {
108+
api.clearLocation((isOk) => {
109+
if (isOk) {
110+
this.back()
111+
}
112+
})
92113
}
93114
},
94115
mounted() {

0 commit comments

Comments
 (0)