默认提交
Showing
2 changed files
with
71 additions
and
12 deletions
| ... | @@ -19,6 +19,7 @@ Page({ | ... | @@ -19,6 +19,7 @@ Page({ | 
| 19 | code: "", // 手输入码 / 扫出的奖金码 | 19 | code: "", // 手输入码 / 扫出的奖金码 | 
| 20 | memberCode: "", // 扫出的用户码 | 20 | memberCode: "", // 扫出的用户码 | 
| 21 | isVerify: true, // 是否已经认证 | 21 | isVerify: true, // 是否已经认证 | 
| 22 | options: {} | ||
| 22 | }, | 23 | }, | 
| 23 | onShareAppMessage() {}, | 24 | onShareAppMessage() {}, | 
| 24 | showAuth() { | 25 | showAuth() { | 
| ... | @@ -27,6 +28,17 @@ Page({ | ... | @@ -27,6 +28,17 @@ Page({ | 
| 27 | }) | 28 | }) | 
| 28 | }, | 29 | }, | 
| 29 | onLoad(options) { | 30 | onLoad(options) { | 
| 31 | this.setData({ | ||
| 32 | options: options | ||
| 33 | }) | ||
| 34 | |||
| 35 | |||
| 36 | }, | ||
| 37 | |||
| 38 | onShow() { | ||
| 39 | this.hideMask(); | ||
| 40 | let options = this.data.options; | ||
| 41 | |||
| 30 | let q = decodeURIComponent(options.q); | 42 | let q = decodeURIComponent(options.q); | 
| 31 | 43 | ||
| 32 | // 获取会员码 | 44 | // 获取会员码 | 
| ... | @@ -60,12 +72,7 @@ Page({ | ... | @@ -60,12 +72,7 @@ Page({ | 
| 60 | if (m || c || sessionId) { | 72 | if (m || c || sessionId) { | 
| 61 | this.initData(); | 73 | this.initData(); | 
| 62 | } | 74 | } | 
| 63 | }, | 75 | console.log("onLoad"); | 
| 64 | |||
| 65 | onShow() { | ||
| 66 | this.hideMask(); | ||
| 67 | // console.log("onShow memberCode:", this.data.memberCode); | ||
| 68 | // console.log("onShow code:", this.data.code); | ||
| 69 | }, | 76 | }, | 
| 70 | 77 | ||
| 71 | initData() { | 78 | initData() { | ... | ... | 
| ... | @@ -44,11 +44,42 @@ Page({ | ... | @@ -44,11 +44,42 @@ Page({ | 
| 44 | this.initData(); | 44 | this.initData(); | 
| 45 | }, | 45 | }, | 
| 46 | initData() { | 46 | initData() { | 
| 47 | // this.queryMember().then((result) => {}); | ||
| 48 | this.initOpenid(); | ||
| 49 | }, | ||
| 50 | |||
| 51 | /** | ||
| 52 | * 初始化Openid | ||
| 53 | * 发红包用 该段代码参考自 user-center.js | ||
| 54 | */ | ||
| 55 | initOpenid() { | ||
| 56 | this.queryMember().then((result) => { | ||
| 57 | let subscriptionOpenid = result.subscriptionOpenid; | ||
| 58 | if (subscriptionOpenid) { | ||
| 59 | // member表 已有openid 继续流程 | ||
| 60 | this.initVipLogin(); // 原有业务 | ||
| 61 | } else { | ||
| 62 | // member表无openid ,重h5授权回来的local拿,成功就继续往下走 | ||
| 63 | this.querySaveOpenid().then((result) => { | ||
| 47 | this.queryMember().then((result) => { | 64 | this.queryMember().then((result) => { | 
| 65 | this.initVipLogin(); // 原有业务 | ||
| 66 | }) | ||
| 67 | }).catch((err) => { | ||
| 68 | // 如果均没有,则去h5授权 | ||
| 69 | app.router.push({ | ||
| 70 | path: "webview" | ||
| 71 | }) | ||
| 72 | }); | ||
| 73 | } | ||
| 74 | }); | ||
| 75 | }, | ||
| 76 | |||
| 77 | /** | ||
| 78 | * 初始化VipLogin 原initData内容 | ||
| 79 | */ | ||
| 80 | initVipLogin() { | ||
| 48 | let auditStatus = this.data.userInfo && this.data.userInfo.auditStatus || ""; | 81 | let auditStatus = this.data.userInfo && this.data.userInfo.auditStatus || ""; | 
| 49 | // console.log("viplogin - auditStatus:", auditStatus); | ||
| 50 | let isModify = this.data.isModify; | 82 | let isModify = this.data.isModify; | 
| 51 | // console.log("isModify:", isModify) | ||
| 52 | if ((auditStatus == "authorization" || auditStatus == "unauthorized") && !isModify) { | 83 | if ((auditStatus == "authorization" || auditStatus == "unauthorized") && !isModify) { | 
| 53 | // 未验证和待验证 | 84 | // 未验证和待验证 | 
| 54 | app.router.push({ | 85 | app.router.push({ | 
| ... | @@ -77,11 +108,32 @@ Page({ | ... | @@ -77,11 +108,32 @@ Page({ | 
| 77 | }) | 108 | }) | 
| 78 | }) | 109 | }) | 
| 79 | } | 110 | } | 
| 111 | }, | ||
| 80 | 112 | ||
| 81 | 113 | /** | |
| 82 | 114 | * 保存openid | |
| 83 | }) | 115 | */ | 
| 84 | 116 | querySaveOpenid() { | |
| 117 | return new Promise((resolve, reject) => { | ||
| 118 | let openid = app.store.getItem("openid"); | ||
| 119 | if (openid) { | ||
| 120 | app.post({ | ||
| 121 | toast: false, | ||
| 122 | url: app.api.saveOpenid, | ||
| 123 | data: { | ||
| 124 | subscriptionOpenid: openid | ||
| 125 | } | ||
| 126 | }).then((result) => { | ||
| 127 | console.log("result:", result); | ||
| 128 | app.store.clear("openid"); | ||
| 129 | resolve(); | ||
| 130 | }).catch((err) => { | ||
| 131 | reject(); | ||
| 132 | }); | ||
| 133 | } else { | ||
| 134 | reject(); | ||
| 135 | } | ||
| 136 | }); | ||
| 85 | }, | 137 | }, | 
| 86 | 138 | ||
| 87 | /** | 139 | /** | ... | ... | 
- 
Please register or sign in to post a comment