|
@@ -11,6 +11,12 @@ import {
|
|
|
exchangePhone,
|
|
|
bindPhone
|
|
|
} from '~/api/user'
|
|
|
+import {
|
|
|
+ createStoreBindings
|
|
|
+} from 'mobx-miniprogram-bindings'
|
|
|
+import {
|
|
|
+ store
|
|
|
+} from '~/store/index'
|
|
|
const app = getApp()
|
|
|
Page({
|
|
|
data: {
|
|
@@ -23,6 +29,13 @@ Page({
|
|
|
},
|
|
|
onLoad() {
|
|
|
this.getProducts()
|
|
|
+ // 手工绑定
|
|
|
+ this.storeBindings = createStoreBindings(this, {
|
|
|
+ store,
|
|
|
+ actions: {
|
|
|
+ setUser: 'setUser'
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
async onShow() {
|
|
|
if (typeof this.getTabBar === 'function') {
|
|
@@ -43,6 +56,7 @@ Page({
|
|
|
async setUserInfo() {
|
|
|
let userInfo = await getMyInfo()
|
|
|
let vipTime = await getVipInfo()
|
|
|
+ this.setUser(userInfo.user)
|
|
|
this.getTasks()
|
|
|
this.setData({
|
|
|
userInfo,
|
|
@@ -119,7 +133,6 @@ Page({
|
|
|
setTimeout(() => {
|
|
|
this.setUserInfo()
|
|
|
}, 1500)
|
|
|
-
|
|
|
},
|
|
|
fail(res) {
|
|
|
wx.showToast({
|
|
@@ -148,18 +161,20 @@ Page({
|
|
|
async getPhoneNumber({
|
|
|
detail
|
|
|
}) {
|
|
|
- let mobile = await exchangePhone({
|
|
|
- code: detail.code
|
|
|
- })
|
|
|
- await bindPhone({
|
|
|
- mobile
|
|
|
- })
|
|
|
- this.setUserInfo()
|
|
|
- wx.showToast({
|
|
|
- title: '绑定成功!已获得7天VIP',
|
|
|
- icon: "none",
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
+ if (detail.code) {
|
|
|
+ let mobile = await exchangePhone({
|
|
|
+ code: detail.code
|
|
|
+ })
|
|
|
+ await bindPhone({
|
|
|
+ mobile
|
|
|
+ })
|
|
|
+ this.setUserInfo()
|
|
|
+ wx.showToast({
|
|
|
+ title: '绑定成功!已获得7天VIP',
|
|
|
+ icon: "none",
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
jump({
|
|
|
currentTarget
|