Commit 824456cf authored by haiyoucuv's avatar haiyoucuv

init

parent 10dfbccc
...@@ -29,18 +29,21 @@ ComponentWithStore({ ...@@ -29,18 +29,21 @@ ComponentWithStore({
canIUseGetUserProfile: wx.canIUse('getUserProfile'), canIUseGetUserProfile: wx.canIUse('getUserProfile'),
canIUseNicknameComp: wx.canIUse('input.type.nickname'), canIUseNicknameComp: wx.canIUse('input.type.nickname'),
}, },
created() {
// 登录
wx.login({
success: async (res) => {
console.log(res.code)
// 发送 res.code 到后台换取 openId, sessionKey, unionId
await dbLogin({code: res.code});
await this.updateHomeInfo();
},
});
},
methods: { methods: {
async onShow() { async onShow() {
store.doLog(507, 10) store.doLog(507, 10)
// 登录 await this.updateHomeInfo();
wx.login({
success: async (res) => {
console.log(res.code)
// 发送 res.code 到后台换取 openId, sessionKey, unionId
await dbLogin({code: res.code});
await this.updateHomeInfo();
},
});
const {channel, city} = this.options || {}; const {channel, city} = this.options || {};
store.paramsObj = {channel, city}; store.paramsObj = {channel, city};
}, },
...@@ -99,8 +102,8 @@ ComponentWithStore({ ...@@ -99,8 +102,8 @@ ComponentWithStore({
// 跳转活动页 // 跳转活动页
jumpActPage: _asyncThrottle(async function () { jumpActPage: _asyncThrottle(async function () {
store.doLog(508, 4) store.doLog(508, 4)
wx.switchTab({ url: "/pages/activity/activity" }) wx.switchTab({url: "/pages/activity/activity"})
}), }),
closeGetPanel() { closeGetPanel() {
...@@ -118,43 +121,43 @@ ComponentWithStore({ ...@@ -118,43 +121,43 @@ ComponentWithStore({
// this.getPos() // this.getPos()
}, },
getPos() { getPos() {
wx.getLocation({ wx.getLocation({
type: 'wgs84', type: 'wgs84',
success (res) { success(res) {
const latitude = res.latitude const latitude = res.latitude
const longitude = res.longitude const longitude = res.longitude
const speed = res.speed const speed = res.speed
const accuracy = res.accuracy const accuracy = res.accuracy
} }
}) })
}, },
async onChooseAvatar(e: any) { async onChooseAvatar(e: any) {
const {avatarUrl} = e.detail const {avatarUrl} = e.detail
console.log('avatarUrl', avatarUrl); console.log('avatarUrl', avatarUrl);
wx.getFileSystemManager().readFile({ wx.getFileSystemManager().readFile({
filePath: e.detail.avatarUrl, //地址 filePath: e.detail.avatarUrl, //地址
encoding: 'base64', //编码格式 encoding: 'base64', //编码格式
success: async(res) => { success: async (res) => {
let base64 = 'data:image/png;base64,' + res.data let base64 = 'data:image/png;base64,' + res.data
const data = await store.doImgUpload(base64) const data = await store.doImgUpload(base64)
console.info('头像上传后data', data); console.info('头像上传后data', data);
if (data) { if (data) {
await dbLogin({ await dbLogin({
avatar: data, avatar: data,
}); });
await this.updateHomeInfo(); await this.updateHomeInfo();
}
} }
}
}) })
}, },
async onInputChange(e: any) { async onInputChange(e: any) {
const nickName = e.detail.value const nickName = e.detail.value
if (nickName) { if (nickName) {
await dbLogin({ await dbLogin({
nickname: nickName, nickname: nickName,
}); });
await this.updateHomeInfo(); await this.updateHomeInfo();
} }
}, },
getUserProfile() { getUserProfile() {
......
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 to comment