Commit f1178ed2 authored by 俞嘉婷's avatar 俞嘉婷

feat: 活动页&我的页面 授权手机号流程

parent 58d06a09
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { ComponentWithStore } from "mobx-miniprogram-bindings"; import { ComponentWithStore } from "mobx-miniprogram-bindings";
import { store } from "../../store/store"; import { store } from "../../store/store";
import { _asyncThrottle } from "../../utils/util"; import { _asyncThrottle } from "../../utils/util";
import { dbLogin } from "../../utils/request";
ComponentWithStore({ ComponentWithStore({
storeBindings: { storeBindings: {
...@@ -34,6 +35,20 @@ ComponentWithStore({ ...@@ -34,6 +35,20 @@ ComponentWithStore({
store.doLog(508, 5 + item.index) store.doLog(508, 5 + item.index)
wx.navigateTo({ url: `/pages/activityDetail/activityDetail?imgUrl=${item.detailImg}` }) wx.navigateTo({ url: `/pages/activityDetail/activityDetail?imgUrl=${item.detailImg}` })
}), }),
getPhoneNumber(e: any) {
if (e.detail?.iv && e.detail?.encryptedData) {
wx.login({
success: async (res) => {
console.log(res.code)
await dbLogin({
code: res.code,
iv: e.detail.iv,
encryptedData: e.detail.encryptedData,
});
},
});
}
},
// onShareAppMessage() { // onShareAppMessage() {
// return { // return {
......
...@@ -8,6 +8,13 @@ import { _asyncThrottle, defaultInfo } from "../../utils/util"; ...@@ -8,6 +8,13 @@ import { _asyncThrottle, defaultInfo } from "../../utils/util";
const app = getApp<IAppOption>() const app = getApp<IAppOption>()
ComponentWithStore({ ComponentWithStore({
storeBindings: {
store,
fields: {
showPhoneBtn: () => !store.homeInfo.mobile,
},
actions: {},
},
data: { data: {
defaultInfo: defaultInfo, defaultInfo: defaultInfo,
userInfo: { userInfo: {
...@@ -27,6 +34,20 @@ ComponentWithStore({ ...@@ -27,6 +34,20 @@ ComponentWithStore({
}, },
}); });
}, },
getPhoneNumber(e: any) {
if (e.detail?.iv && e.detail?.encryptedData) {
wx.login({
success: async (res) => {
console.log(res.code)
await dbLogin({
code: res.code,
iv: e.detail.iv,
encryptedData: e.detail.encryptedData,
});
},
});
}
},
async onChooseAvatar(e: any) { async onChooseAvatar(e: any) {
const { avatarUrl } = e.detail const { avatarUrl } = e.detail
console.log('avatarUrl', avatarUrl); console.log('avatarUrl', avatarUrl);
......
...@@ -29,3 +29,12 @@ ...@@ -29,3 +29,12 @@
</view> </view>
</view> </view>
</view> </view>
<!--获取手机号按钮-->
<button
type="primary"
wx:if="{{showPhoneBtn}}"
class="getPhoneBtn"
open-type="getPhoneNumber"
bindgetphonenumber="getPhoneNumber"
></button>
\ No newline at end of file
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