Skip to content

Commit

Permalink
bufixed: 更改全局数据命名问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Hope committed Mar 4, 2018
1 parent e10741f commit 522bbb7
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/app.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default class extends wepy.app {
this.intercept('request', {
config(params) {
let header = {
'openId': wepy.getStorageSync('openId') || ''
'openId': wepy.getStorageSync('gnb_primary_openId') || ''
}
wepy.showNavigationBarLoading()
params.header = header
Expand Down
6 changes: 3 additions & 3 deletions src/pages/init/grade.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
success (res) {
wepy.hideLoading()
wepy.setStorageSync('User', res)
wepy.setStorageSync('gnb_primary_User', res)
resolve(res)
},
fail (err) {
Expand All @@ -69,7 +69,7 @@
await this._setUserInfo({
grade: grade,
encryptedData: this.encryptedData,
session_key: wepy.getStorageSync('session_key'),
session_key: wepy.getStorageSync('gnb_primary_session_key'),
iv: this.iv
})
let name = ''
Expand All @@ -80,7 +80,7 @@
case '6': { name = '六年级下册'; break }
}
// 获取当前年级的教材
let textbookId = (wepy.getStorageSync('User').textbook)[Number(grade) - 3].id
let textbookId = (wepy.getStorageSync('gnb_primary_User').textbook)[Number(grade) - 3].id
wepy.redirectTo({ url: `/pages/init/add?grade=${grade}&name=${name}&textbookId=${textbookId}` })
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/my/email.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
async _send() {
// 如果当前的Email和信息相同则发送,否则更新Email信息在发送
let mail = this.form_email.value + this.emailCodes[this.emailCodeIndex]
if (mail !== wepy.getStorageSync('User').email) {
if (mail !== wepy.getStorageSync('gnb_primary_User').email) {
await this._setUserEmail(this.form_email.value + this.emailCodes[this.emailCodeIndex])
}
await this._sendEmail(this.id, this.type)
Expand All @@ -101,7 +101,7 @@
email: email
},
success (res) {
wepy.setStorageSync('User', res)
wepy.setStorageSync('gnb_primary_User', res)
resolve(res)
},
fail (err) {
Expand Down Expand Up @@ -160,7 +160,7 @@
}

onShow() {
let email = wepy.getStorageSync('User').email
let email = wepy.getStorageSync('gnb_primary_User').email
// 获取邮箱和邮箱类型
this.form_email.value = email.split('@')[0]
let type = `@${email.split('@')[1]}`
Expand Down
28 changes: 14 additions & 14 deletions src/pages/my/index.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
await this._setRefund()
// 重新获得用户信息
await this._getUserInfo()
this.userInfo.vip = wepy.getStorageSync('User').vip
this.userInfo.refund = wepy.getStorageSync('User').refund
this.userInfo.vip = wepy.getStorageSync('gnb_primary_User').vip
this.userInfo.refund = wepy.getStorageSync('gnb_primary_User').refund
this.$apply()
wepy.hideLoading()
wepy.showModal({
Expand Down Expand Up @@ -134,9 +134,9 @@
app: 'primary'
},
success (res) {
wepy.setStorageSync('openId', res.openid)
wepy.setStorageSync('gnb_primary_openId', res.openid)
console.log(res.session_key)
wepy.setStorageSync('session_key', res.session_key)
wepy.setStorageSync('gnb_primary_session_key', res.session_key)
resolve(res)
},
fail (err) {
Expand All @@ -152,7 +152,7 @@
wepy.request({
url: 'https://primary.guinaben.com/member/info',
success (res) {
wepy.setStorageSync('User', res)
wepy.setStorageSync('gnb_primary_User', res)
resolve(res)
},
fail (err) {
Expand All @@ -170,15 +170,15 @@
* 3 在通过openId获得用户信息
*/
wepy.showLoading({title: '请稍候'})
if (wepy.getStorageSync('openId').length === 0) {
if (wepy.getStorageSync('gnb_primary_openId').length === 0) {
let code = await this._login()
await this._getOpenId(code)
}
await this._getUserInfo()
this.userInfo.name = wepy.getStorageSync('User').name
this.userInfo.headImg = wepy.getStorageSync('User').headImg
this.userInfo.refund = wepy.getStorageSync('User').refund
this.userInfo.vip = wepy.getStorageSync('User').vip
this.userInfo.name = wepy.getStorageSync('gnb_primary_User').name
this.userInfo.headImg = wepy.getStorageSync('gnb_primary_User').headImg
this.userInfo.refund = wepy.getStorageSync('gnb_primary_User').refund
this.userInfo.vip = wepy.getStorageSync('gnb_primary_User').vip
wepy.hideLoading()
wepy.switchTab({ url: `/pages/workbook/index` })
this.$apply()
Expand All @@ -189,10 +189,10 @@

async onShow () {
await this._getUserInfo()
this.userInfo.name = wepy.getStorageSync('User').name
this.userInfo.headImg = wepy.getStorageSync('User').headImg
this.userInfo.refund = wepy.getStorageSync('User').refund
this.userInfo.vip = wepy.getStorageSync('User').vip
this.userInfo.name = wepy.getStorageSync('gnb_primary_User').name
this.userInfo.headImg = wepy.getStorageSync('gnb_primary_User').headImg
this.userInfo.refund = wepy.getStorageSync('gnb_primary_User').refund
this.userInfo.vip = wepy.getStorageSync('gnb_primary_User').vip
this.$apply()
}
onShareAppMessage (res) {
Expand Down
16 changes: 8 additions & 8 deletions src/pages/my/info.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@
}

data = {
gradeIndex: Number(wepy.getStorageSync('User').grade) - 3,
gradeIndex: Number(wepy.getStorageSync('gnb_primary_User').grade) - 3,
gradeList: gradeList,
base_school: {
title: '学校',
value: wepy.getStorageSync('User').school,
value: wepy.getStorageSync('gnb_primary_User').school,
placeholder: '请输入您的学校名称'
},
base_name: {
title: '姓名',
value: wepy.getStorageSync('User').name,
value: wepy.getStorageSync('gnb_primary_User').name,
placeholder: '请输入您的姓名'
},
base_sex: {
title: '性别',
value: (Number(wepy.getStorageSync('User').sex) === 1 ? '男' : '女'),
value: (Number(wepy.getStorageSync('gnb_primary_User').sex) === 1 ? '男' : '女'),
disabled: true
}
}
Expand Down Expand Up @@ -108,7 +108,7 @@
},
success (res) {
wepy.hideLoading()
wepy.setStorageSync('User', res)
wepy.setStorageSync('gnb_primary_User', res)
resolve(res)
},
fail (err) {
Expand All @@ -120,9 +120,9 @@
}

onShow () {
this.base_name.value = wepy.getStorageSync('User').name
this.base_school.value = wepy.getStorageSync('User').school
this.gradeIndex = Number(wepy.getStorageSync('User').grade) - 3
this.base_name.value = wepy.getStorageSync('gnb_primary_User').name
this.base_school.value = wepy.getStorageSync('gnb_primary_User').school
this.gradeIndex = Number(wepy.getStorageSync('gnb_primary_User').grade) - 3
this.$apply()
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/my/pay.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class MyPay extends wepy.page {
wepy.request({
url: 'https://primary.guinaben.com/member/info',
success (res) {
wepy.setStorageSync('User', res)
wepy.setStorageSync('gnb_primary_User', res)
resolve(res)
},
fail (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/my/vip.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
wepy.request({
url: 'https://primary.guinaben.com/member/info',
success (res) {
wepy.setStorageSync('User', res)
wepy.setStorageSync('gnb_primary_User', res)
resolve(res)
},
fail (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/statistics/correct.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
async onLoad(options) {
wx.setNavigationBarTitle({title: options.name})
this.result = await this._getContent(options.id)
this.name = wepy.getStorageSync('User').name
this.name = wepy.getStorageSync('gnb_primary_User').name
this.$apply()
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/statistics/error.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class StatisticsError extends wepy.page {
/** 下载试卷 */
_download () {
// 不是会员跳转到VIP购买, 是跳转到下载
if (Number(wepy.getStorageSync('User').vip)) {
if (Number(wepy.getStorageSync('gnb_primary_User').vip)) {
wepy.navigateTo({
url: `/pages/my/email?id=${this.id}&type=statistics`
})
Expand Down
4 changes: 2 additions & 2 deletions src/pages/statistics/index.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
}

onLoad() {
this.grade = wepy.getStorageSync('User').grade - 3
this.textBookList = wepy.getStorageSync('User').textbook
this.grade = wepy.getStorageSync('gnb_primary_User').grade - 3
this.textBookList = wepy.getStorageSync('gnb_primary_User').textbook
this.textbook = this.textBookList[Number(this.grade)].id
this.$apply()
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workbook/correct.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
async onLoad(options) {
wx.setNavigationBarTitle({title: options.name})
this.result = await this._getContent(options.id)
this.name = wepy.getStorageSync('User').name
this.name = wepy.getStorageSync('gnb_primary_User').name
this.$apply()
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/workbook/error.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},
_download () {
// 不是会员跳转到VIP购买, 是跳转到下载
if (Number(wepy.getStorageSync('User').vip)) {
if (Number(wepy.getStorageSync('gnb_primary_User').vip)) {
wepy.navigateTo({
url: `/pages/my/email?id=${this.id}&type=workbook`
})
Expand Down
31 changes: 19 additions & 12 deletions src/pages/workbook/index.wpy
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
<style lang="less">
<style lang="less" scoped>
.workbookIndex{
.header{
height:40px;
width: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 2;
}
}
.add_button {
position: fixed;
background:#4cc0be;
color:#fff;
font-size: 70rpx;
height: 120rpx;
line-height: 120rpx;
line-height: 110rpx;
width: 120rpx;
border-radius: 50%;
bottom: 5%;
Expand All @@ -14,15 +24,12 @@
}
</style>
<template>
<view class="container">
<gnbTextbookSelect :value.sync="grade" :key.sync="textbook" @event.user="textbookChange" :textbook.sync="textBookList"/>
<view class="container workbookIndex">
<gnbTextbookSelect class="header" :value.sync="grade" :key.sync="textbook" @event.user="textbookChange" :textbook.sync="textBookList"/>
<view>
<view class="zan-row" style="padding: 10px 0 0;">
<text class="zan-panel-title zan-font-bold zan-c-black">我的习题册</text>
</view>
<!--习题册区间-->
<view class="zan-panel">
<scroll-view scroll-y="true" style="height: 780rpx;background:#fff;" scroll-with-animation="true" enable-back-to-top="true">
<view class="zan-panel" style='margin-top: 38px;'>
<scroll>
<repeat for="{{ workbookList }}" key="pindex" index="pindex" item="item">
<view class="zan-card" bindtap="_intoChapter({{item}})">
<!--习题册图片-->
Expand All @@ -43,7 +50,7 @@
</view>
</view>
</repeat>
</scroll-view>
</scroll>
</view>
</view>
<button class="add_button" bindtap='_initAdd'>+</button>
Expand Down Expand Up @@ -111,9 +118,9 @@ export default class Statistics extends wepy.page {
}

onLoad() {
this.textBookList = wepy.getStorageSync('User').textbook
this.textBookList = wepy.getStorageSync('gnb_primary_User').textbook
if (this.textBookList) {
this.grade = wepy.getStorageSync('User').grade - 3
this.grade = wepy.getStorageSync('gnb_primary_User').grade - 3
this.textbook = this.textBookList[Number(this.grade)].id
this.$apply()
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workbook/want.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
name: 'file',
header: {
'Content-Type': 'multipart/form-data',
'openId': wepy.getStorageSync('openId')
'openId': wepy.getStorageSync('gnb_primary_openId')
},
formData: {
'type': 'wantworkbook'
Expand Down

0 comments on commit 522bbb7

Please sign in to comment.