Commit 1cb6e92b by 严立

LL - 优化登录逻辑

parent a8a533de
import iMui from './component/m-init.js' import iMui from './component/m-init.js'
import iBase64 from './npm/base64.js' import iBase64 from './npm/base64.js'
import iMiment from './npm/miment.js' import iMiment from './npm/miment.js'
import iPageExtend from './utils/page-extend.js' import iPageExtend from './utils/extend/page.js'
import iUtils from './utils/utils.js' import iUtils from './utils/utils.js'
import iLogin from './utils/login/login.js'
import iRule from './utils/rule/rule.js' import iRule from './utils/rule/rule.js'
import iRequest from './utils/request/corvus.js' import iRequest from './utils/request/corvus.js'
import iEnvironmental from './environmental.js' import iEnvironmental from './environmental.js'
...@@ -23,47 +24,40 @@ App({ ...@@ -23,47 +24,40 @@ App({
appResourcesBase: 'https://sm-web.meiqicloud.com/userfiles/appResourcesS2/', appResourcesBase: 'https://sm-web.meiqicloud.com/userfiles/appResourcesS2/',
shopId: iEnvironmental.shopId, shopId: iEnvironmental.shopId,
pointInfo: iEnvironmental.pointInfo, pointInfo: iEnvironmental.pointInfo,
payStateTimer: 0, payStateTimer: 0,
token: '',
refreshToken: '',
userInfo: null, userInfo: null,
baseUrl: iOption.baseUrl,//测试 baseUrl: iOption.baseUrl,//测试
debug: true,
isRefreshToken: false,
}, },
onLaunch: function () { onLaunch: function () {
iMui(this) iPageExtend(this) // Page 实例拓展,为所有 Page 统一增加属性或者方法
iPageExtend() iMui(this) // m-ui 相关函数引入
iLogin(this) // 全局登录,根据 token 的情况执行相关操作
this.setUnitProportion() this.setUnitProportion()
this.login()
if (this.globalData.token === '') return
this.queryUserStatus()
}, },
onShow: function () { onShow: function () {
this.setAppStatus() this.setAppStatus()
this.setUserStatus()
}, },
/**
* 查询 app 功能启用状态
* @function
* @param
* @returns
*/
setAppStatus: function () { setAppStatus: function () {
console.log('setAppStatus') this.request({
this.wxRequest({
url: 'v1/common/getDictByType', url: 'v1/common/getDictByType',
method: 'POST', params: {
data: {
'type': 'is_open' 'type': 'is_open'
},
success: (response) => {
let funcResponse = response.data
this.globalData.appStatus = Boolean(Number(funcResponse[0].value))
// this.globalData.appStatus = true
} }
}) }).then((response) => {
let funcData = response.data
this.globalData.appStatus = Boolean(Number(funcData[0].value))
console.log('setAppStatus', this.globalData.appStatus)
}).catch(() => {})
}, },
/** /**
...@@ -78,18 +72,81 @@ App({ ...@@ -78,18 +72,81 @@ App({
}, },
/** /**
* css 样式对象转换 css 字符串 * 更新用户信息
* 只更新某些即时属性,不再获取基础信息。
* @function * @function
* @param * @param
* @returns * @returns
*/ */
cssObjectToCssString: function (funcCssObject) { userUpdate: function () {
let funcCss = '' console.log('userUpdate')
let funcObjectKey = Object.keys(funcCssObject) },
for (let i = 0, l = funcObjectKey.length; i < l; i++) {
funcCss = funcCss + funcObjectKey[i] + ': ' + funcCssObject[funcObjectKey[i]] + '; ' /**
} * 登录
return funcCss * @function
* @param
* @returns
*/
userLogin: function () {
wx.login({
success: (response) => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
this.request({
url: 'v1/login/getSmallSession?code=' + response.code,
method: 'GET',
}).then((response) => {
let funcData = response.data
// 缓存令牌信息
wx.setStorageSync('token', funcData.token)
wx.setStorageSync('tokenRefresh', funcData.refreshToken)
wx.setStorageSync('sessionKey', funcData.session_key)
let funcUserInfo = {
'openId': funcData.openid,
'name': funcData.nickName,
'phone': funcData.mobile,
'phoneHide': funcData.mobile.substring(0, 3) + '****' + funcData.mobile.substring(7),
'avatar': funcData.avatarUrl,
'address': funcData.address,
'birthday': funcData.birthday,
'gender': funcData.sex ? Number(funcData.sex) : 0,
'userType': Number(funcData.userType),
'status': '', // 只有游客身份该值为 ''
'isSignIn': false,
}
// 以返回信息中是否包含手机号码判断用户是否注册过
if (funcUserInfo.phone) {
funcUserInfo.isSignIn = true
this.setUserStatus()
}
wx.setStorageSync('userInfo', funcUserInfo)
}).catch(() => {})
}
})
},
/**
* 刷新令牌
* @function
* @param
* @returns
*/
refreshToken: function () {
return this.request({
url: 'v1/login/refreshToken',
header: {
token: wx.getStorageSync('token'),
refreshToken: wx.getStorageSync('tokenRefresh')
},
}).then((response) => {
let funcData = response.data
wx.setStorageSync('token', funcData.token)
wx.setStorageSync('tokenRefresh', funcData.refreshToken)
}).catch(() => {})
}, },
/** /**
...@@ -99,7 +156,7 @@ App({ ...@@ -99,7 +156,7 @@ App({
* @returns * @returns
*/ */
wxRequest: function (obj) { wxRequest: function (obj) {
var token = this.globalData.token var token = wx.getStorageSync('token')
var param = obj.data ? JSON.stringify(obj.data) : '' var param = obj.data ? JSON.stringify(obj.data) : ''
var header = obj.header ? obj.header : { 'token': token || '' } var header = obj.header ? obj.header : { 'token': token || '' }
...@@ -115,7 +172,7 @@ App({ ...@@ -115,7 +172,7 @@ App({
obj.success(res.data) obj.success(res.data)
} }
} else if (402 == code) { } else if (402 == code) {
this.refreshToken(obj) // this.refreshToken(obj)
} else if (500 === code) { } else if (500 === code) {
if (obj.success) { if (obj.success) {
obj.success(res) obj.success(res)
...@@ -150,77 +207,6 @@ App({ ...@@ -150,77 +207,6 @@ App({
}, },
/** /**
* 登录
* @function
* @param
* @returns
*/
login: function (obj) {
let token = this.globalData.token
if (token) {
if (obj.success) {
obj.success(token)
}
} else {
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
this.wxRequest({
url: 'v1/login/getSmallSession?code=' + res.code,
method: 'GET',
success: (response) => {
this.globalData.isRefreshToken = false
let funcResponse = response.data
// 缓存令牌信息
this.globalData.token = funcResponse.token
this.globalData.refreshToken = funcResponse.refreshToken
wx.setStorageSync('token', funcResponse.token)
wx.setStorageSync('tokenRefresh', funcResponse.refreshToken)
wx.setStorageSync('sessionKey', funcResponse.session_key)
let funcUserInfo = {
'openId': funcResponse.openid,
'name': funcResponse.nickName,
'phone': funcResponse.mobile,
'phoneHide': funcResponse.mobile.substring(0, 3) + '****' + funcResponse.mobile.substring(7),
'avatar': funcResponse.avatarUrl,
'address': funcResponse.address,
'birthday': funcResponse.birthday,
'gender': funcResponse.sex ? Number(funcResponse.sex) : 0,
'userType': Number(funcResponse.userType),
'status': '', // 只有游客身份该值为 ''
'isSignIn': false,
}
// 以返回信息中是否包含手机号码判断用户是否注册过
if (funcUserInfo.phone) {
funcUserInfo.isSignIn = true
// 测试数据
// funcUserInfo.isSignIn = false
this.queryUserStatus()
}
wx.setStorageSync('userInfo', funcUserInfo)
if (obj && obj.success) {
obj.success(funcResponse.token)
}
// 防止无限刷新 token 的紧急修复手段
if (obj && obj.error) {
wx.switchTab({
url: '/pages/home/home/home'
})
}
},
})
}
})
}
},
/**
* 注册 * 注册
* @function * @function
* @param {number} - funcAmountValue 金额,单位分 * @param {number} - funcAmountValue 金额,单位分
...@@ -245,105 +231,48 @@ App({ ...@@ -245,105 +231,48 @@ App({
/** /**
* 查询用户认证状态 * 查询用户认证状态
* 在用户已经注册的前提下会查询此函数 * 在用户已经注册的前提下会查询此函数
* @function * @function
* @param * @param
* @returns * @returns
*/ */
queryUserStatus: function () { setUserStatus: function () {
this.wxRequest({ this.request({
url: 'v1/userAuth/getAuth', url: 'v1/userAuth/getAuth',
method: 'GET', method: 'GET'
success: (response) => { }).then((response) => {
let funcResponse = response.data let funcData = response.data
let funcUserInfo = wx.getStorageSync('userInfo') let funcUserInfo = wx.getStorageSync('userInfo')
let funcStatus = Number(funcResponse.state) // 最新的用户身份 let funcStatus = Number(funcData.state) // 最新的用户身份
let funcStatusRaw = funcUserInfo.status // 当前的用户身份,用于对比用户身份是否更新 let funcStatusRaw = funcUserInfo.status // 当前的用户身份,用于对比用户身份是否更新
let funcStatusText = '去认证'
switch (funcStatus) {
switch (funcStatus) { // 审核中
// 正在审核 case 0:
case 0: funcUserInfo.status = funcStatus
funcStatusText = '审核中' funcUserInfo.userType = 0
funcUserInfo.status = funcStatus break
funcUserInfo.userType = 0
break // 审核通过
case 1:
// 通过 funcUserInfo.status = funcStatus
case 1: funcUserInfo.userType = 1
funcStatusText = '审核通过 ' break
funcUserInfo.status = funcStatus
funcUserInfo.userType = 1 // 审核失败
break case 2:
funcUserInfo.status = funcStatus
// 拒绝 funcUserInfo.userType = 0
case 2: break
funcStatusText = '审核失败'
funcUserInfo.status = funcStatus
funcUserInfo.userType = 0
break
}
// // 测试数据 - 游客
// funcUserInfo.status = ''
// funcUserInfo.userType = 0
// // 测试数据 - 业主
// funcUserInfo.status = 1
// funcUserInfo.userType = 1
// wx.setStorageSync('userInfo', funcUserInfo)
// 如果用户身份有更新,则自动跳转到首页
if (funcStatus !== funcStatusRaw) {
console.log('status change')
// wx.switchTab({ url: '/pages/home/home/home' })
}
} }
})
},
/** // 如果用户身份有更新,则自动跳转到首页
* 刷新令牌 if (funcStatus !== funcStatusRaw) {
* @function wx.setStorageSync('userInfo', funcUserInfo)
* @param // wx.switchTab({ url: '/pages/home/home/home' })
* @returns
*/
refreshToken: function (obj) {
if (this.globalData.isRefreshToken) return
this.globalData.isRefreshToken = true
this.wxRequest({
url: 'v1/login/refreshToken',
header: {
token: this.globalData.token,
refreshToken: this.globalData.refreshToken
},
success: (response) => {
let funcResponse = response.data
switch (Number(funcResponse.code)) {
case 200:
this.globalData.token = funcResponse.token
this.globalData.refreshToken = funcResponse.refreshToken
wx.setStorageSync('token', funcResponse.token)
wx.setStorageSync('tokenRefresh', funcResponse.refreshToken)
this.globalData.isRefreshToken = false
this.wxRequest(obj)
break
case 402:
this.globalData.token = ''
this.globalData.refreshToken = ''
this.login({ error: true })
break
}
},
fail: () => {
this.globalData.isRefreshToken = false
} }
}) }).catch((response) => {})
}, },
/** /**
...@@ -379,13 +308,12 @@ App({ ...@@ -379,13 +308,12 @@ App({
}, },
/** /**
* 全局函数 - 设置商品信息 * 全局函数 - 设置商品信息 - 未完成
* @function * @function
* @param {object} - { commodity: '商品数据对象', complete: '回调函数' } * @param {object} - { commodity: '商品数据对象', complete: '回调函数' }
* @returns * @returns
*/ */
setCommodityInfo: function (funcInfoRaw) { setCommodityInfo: function (funcInfoRaw) {
// 特殊数据格式化 // 特殊数据格式化
switch (Number(funcInfoRaw.genre)) { switch (Number(funcInfoRaw.genre)) {
case 1: case 1:
...@@ -438,15 +366,52 @@ App({ ...@@ -438,15 +366,52 @@ App({
funcInfo.priceType = 3 funcInfo.priceType = 3
} }
} }
return funcInfo return funcInfo
}, },
// s3 新增函数 // s3 新增函数
/**
* 全局函数 - 设置价格类型
* @function
* @param {array} funcCommodityData - 商品信息,活动信息数组
* @returns
*/
setPriceType: function (funcCommodityData) {
let funcUserType = wx.getStorageSync('userInfo').userType
for (let i = 0, l = funcCommodityData.length; i < l; i++) {
// 根据后台判断价格显示类型
// 活动价优先级最高,如果存在活动价,则只显示活动价和普通价
if (funcCommodityData[i].priceDiscount || funcCommodityData[i].priceDiscount === 0) {
funcCommodityData[i].priceType = 1
} else {
// 活动价不存在,进一步判断普通价与业主价是否一致,如果不一致,则显示两者
if (funcCommodityData[i].price !== funcCommodityData[i].priceSpecial && funcUserType) {
funcCommodityData[i].priceType = 2
} else {
funcCommodityData[i].priceType = 3
}
}
}
return funcCommodityData
},
/**
* 全局函数 - 请求封装
* @function
* @param {array} funcOption - 请求配置
* @returns
*/
request: function (funcOption) { request: function (funcOption) {
return iRequest(funcOption) return iRequest(funcOption)
}, },
/**
* 全局函数 - 页面滚动事件优化
* @function
* @param {object} funcEvent - 事件对象
* @param {object} funcPage - Page 对象
* @returns
*/
pageScroll: function (funcEvent, funcPage) { pageScroll: function (funcEvent, funcPage) {
// 滚动触发函数 // 滚动触发函数
function execute () { function execute () {
...@@ -464,24 +429,4 @@ App({ ...@@ -464,24 +429,4 @@ App({
clearTimeout(this.scrollTimestamp) clearTimeout(this.scrollTimestamp)
}, funcFrequency) }, funcFrequency)
}, },
setPriceType: function (funcCommodityData) {
let funcUserType = wx.getStorageSync('userInfo').userType
for (let i = 0, l = funcCommodityData.length; i < l; i++) {
// 根据后台判断价格显示类型
// 活动价优先级最高,如果存在活动价,则只显示活动价和普通价
if (funcCommodityData[i].priceDiscount || funcCommodityData[i].priceDiscount === 0) {
funcCommodityData[i].priceType = 1
} else {
// 活动价不存在,进一步判断普通价与业主价是否一致,如果不一致,则显示两者
if (funcCommodityData[i].price !== funcCommodityData[i].priceSpecial && funcUserType) {
funcCommodityData[i].priceType = 2
} else {
funcCommodityData[i].priceType = 3
}
}
}
return funcCommodityData
},
}) })
\ No newline at end of file
...@@ -50,8 +50,8 @@ ...@@ -50,8 +50,8 @@
"pages/club/member/member", "pages/club/member/member",
"pages/club/create/create", "pages/club/create/create",
"pages/club/enter/enter", "pages/club/enter/enter",
"pages/login/login", "pages/mall/home/home",
"pages/mall/home/home" "pages/login/login"
], ],
"usingComponents": { "usingComponents": {
"m-button-bottom": "./component/m-button-bottom/m-button-bottom", "m-button-bottom": "./component/m-button-bottom/m-button-bottom",
......
...@@ -17,6 +17,11 @@ ...@@ -17,6 +17,11 @@
height: 32rpx; height: 32rpx;
} }
.icon_48 {
width: 48rpx;
height: 48rpx;
}
.bg-gradient { .bg-gradient {
background: linear-gradient(180deg, #FFFFFF 0%, #F3F4F6 20%, #F3F4F6 100%); background: linear-gradient(180deg, #FFFFFF 0%, #F3F4F6 20%, #F3F4F6 100%);
} }
......
<view class="z-input"> <view class="m-input">
<view class="container-text row ac {{className}}" hidden="{{!winText}}" bindtap="setInputShow"> <view class="container-text row ac {{className}}" hidden="{{!winText}}" bindtap="setInputShow">
<text class="container-text-value" hidden="{{value === '' ? true : false}}">{{value}}</text> <text class="container-text-value" hidden="{{value === '' ? true : false}}">{{value}}</text>
<text class="container-text-placeholder" hidden="{{value === '' ? false : true}}">{{placeholder}}</text> <text class="container-text-placeholder" hidden="{{value === '' ? false : true}}">{{placeholder}}</text>
......
.z-input { .m-input {
position: relative; position: relative;
} }
...@@ -11,9 +11,13 @@ ...@@ -11,9 +11,13 @@
} }
.container-text { .container-text {
color: green; overflow: hidden;
} }
.container-input { .container-input {
color: #15191F; color: #15191F;
}
.container-input > input {
width: 100%;
} }
\ No newline at end of file
...@@ -8,31 +8,34 @@ Component({ ...@@ -8,31 +8,34 @@ Component({
}, },
properties: { properties: {
tabClass: { // tab 整体样式
classTab: {
type: String, type: String,
value: '', value: 'm-tab-container',
}, },
itemClass: { // tab 列表样式
classTabList: {
type: String, type: String,
value: '', value: 'm-tab-list',
}, },
// 导航栏是否固定在视图顶部 // tab 列表项目样式
isFixed: { classTabItem: {
type: Boolean, type: String,
value: false, value: 'm-item',
}, },
fixedTop: { // 点击样式
type: Number, classActive: {
value: 0, type: String,
value: 'm-item-active',
}, },
// 导航栏是否占用空间,仅在 isFixed 为 true 时有效。 // 默认样式
isOccupy: { classInactive: {
type: Boolean, type: String,
value: true, value: 'm-item-inactive',
}, },
item: { item: {
...@@ -64,7 +67,7 @@ Component({ ...@@ -64,7 +67,7 @@ Component({
// 获取购物车高度 // 获取购物车高度
let funcQuery = this.createSelectorQuery() let funcQuery = this.createSelectorQuery()
funcQuery.selectAll('.m-item').boundingClientRect() funcQuery.selectAll('.m-item-mark').boundingClientRect()
funcQuery.exec((funcResult) => { funcQuery.exec((funcResult) => {
let funcSelectionElement = funcResult[0] let funcSelectionElement = funcResult[0]
this.scrollStart = funcSelectionElement[0].left this.scrollStart = funcSelectionElement[0].left
......
<view class="m-tab {{tabClass}} {{isFixed ? 'm-tab-fixed' : ''}}" style="{{'top: ' + fixedTop + 'px;'}}"> <view class="m-tab {{classTab}}">
<scroll-view class="m-item-list row ae {{tabClass}}" scroll-x="true" scroll-left="{{scrollLeft}}" bindscroll="eventTabScroll"> <scroll-view class="{{classTabList}}" scroll-x="true" scroll-left="{{scrollLeft}}" bindscroll="eventTabScroll">
<block wx:for="{{item}}" wx:for-item="item" wx:for-index="index" wx:key="index"> <block wx:for="{{item}}" wx:for-item="item" wx:for-index="index" wx:key="index">
<view <view class="m-item-mark {{classTabItem}}" data-item="{{item}}" data-index="{{index}}" bindtap="onItem">
class="m-item row cc ac {{itemClass}}" <view class="row cc ac {{classActive}}" wx:if="{{activeIndex === index}}">
data-item="{{item}}" <text>{{item.text}}</text>
data-index="{{index}}" </view>
bindtap="onItem"
> <view class="row cc ac {{classInactive}}" wx:if="{{activeIndex !== index}}">
<text class="{{activeIndex === index ? 'm-item-active' : 'm-item-inactive'}}">{{item.text}}</text> <text>{{item.text}}</text>
</view>
</view> </view>
</block> </block>
</scroll-view> </scroll-view>
</view> </view>
\ No newline at end of file
<!-- 导航栏占位元素 -->
<view wx:if="{{isOccupy && isFixed}}" class="m-tab-occupy"></view>
\ No newline at end of file
.m-tab { .m-tab-container {
z-index: 4; z-index: 4;
width: 750rpx; width: 750rpx;
border-bottom: 1px #E2E7EF solid; border-bottom: 1px #E2E7EF solid;
background: #FFFFFF; background: #FFFFFF;
} }
.m-tab-fixed { .m-tab-list {
position: fixed;
top: 0;
left: 0;
}
.m-item-list {
width: 750rpx; width: 750rpx;
margin: 0; margin: 0;
padding: 0; padding: 0;
...@@ -19,33 +13,34 @@ ...@@ -19,33 +13,34 @@
border: none; border: none;
} }
.m-item-list::-webkit-scrollbar { .m-tab-list::-webkit-scrollbar {
display: none; display: none;
} }
.m-item { .m-item {
display: inline-block; display: inline-block;
margin-right: 80rpx; margin: 0 40rpx;
text-align: center; text-align: left;
} }
.m-item > text { .m-item-active {
display: inline-block;
height: 60rpx; height: 60rpx;
padding: 0 0 24rpx 0;
border-bottom: 4rpx #15191F solid;
font-size: 26rpx; font-size: 26rpx;
font-weight: 500; font-weight: 800;
line-height: 36rpx;
color: #15191F; color: #15191F;
} }
.m-item-active {
border-bottom: 4rpx #15191F solid;
}
.m-item-inactive { .m-item-inactive {
height: 60rpx;
padding: 0 0 24rpx 0;
border-bottom: 4rpx rgba(0, 0, 0, 0) solid; border-bottom: 4rpx rgba(0, 0, 0, 0) solid;
}
.m-tab-occupy { font-size: 26rpx;
height: 74rpx; font-weight: 800;
line-height: 36rpx;
color: #656E7B;
} }
\ No newline at end of file
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
position: relative; position: relative;
} }
.m-textarea-text {
overflow: hidden;
}
.m-textarea-text-value { .m-textarea-text-value {
color: #000000; color: #000000;
} }
......
...@@ -13,7 +13,7 @@ Page({ ...@@ -13,7 +13,7 @@ Page({
data: { data: {
imageBase: App.globalData.appImageBase, imageBase: App.globalData.appImageBase,
resourcesBase: App.globalData.appResourcesBase, resourcesBase: App.globalData.appResourcesBase,
establishInfo: {} establishInfo: {},
}, },
onLoad: function (options) { onLoad: function (options) {
...@@ -56,6 +56,12 @@ Page({ ...@@ -56,6 +56,12 @@ Page({
}, },
onEstablish: function () { onEstablish: function () {
App.ui.showToast({
iconType: 'loading',
title: '正在提交',
duration: 30000
})
let funcPass = true let funcPass = true
let funcEstablishInfoKey = Object.keys(this.data.establishInfo) let funcEstablishInfoKey = Object.keys(this.data.establishInfo)
for (let i = 0, l = funcEstablishInfoKey.length; i < l; i++) { for (let i = 0, l = funcEstablishInfoKey.length; i < l; i++) {
...@@ -73,9 +79,11 @@ Page({ ...@@ -73,9 +79,11 @@ Page({
} }
} }
if (!funcPass) return if (!funcPass) {
App.ui.hideToast()
return
}
console.log('验证通过')
App.request({ App.request({
url: 'v3/club/createClub', url: 'v3/club/createClub',
params: { params: {
...@@ -86,6 +94,7 @@ Page({ ...@@ -86,6 +94,7 @@ Page({
'wxAccount': 'wxAccount' 'wxAccount': 'wxAccount'
} }
}).then((response) => { }).then((response) => {
App.ui.hideToast()
wx.setStorageSync('tempBackInfo', 'winEstablish') wx.setStorageSync('tempBackInfo', 'winEstablish')
wx.navigateBack() wx.navigateBack()
}).catch((response) => { }).catch((response) => {
......
<m-nav titleText="申请创建俱乐部" styleIndex="{{1}}"></m-nav> <m-nav titleText="申请创建俱乐部" styleIndex="{{1}}"></m-nav>
<m-toast></m-toast>
<view class="container"> <view class="container">
<view class="club-enter"> <view class="club-enter">
......
...@@ -11,6 +11,7 @@ Page({ ...@@ -11,6 +11,7 @@ Page({
data: { data: {
clubInfo: {}, clubInfo: {},
enterInfo: {}, enterInfo: {},
enterInfoCustom: [],
isButtonEnable: false, isButtonEnable: false,
}, },
...@@ -30,8 +31,25 @@ Page({ ...@@ -30,8 +31,25 @@ Page({
'clubId': this.data.clubInfo.id, 'clubId': this.data.clubInfo.id,
} }
}).then((response) => { }).then((response) => {
console.log(response)
let funcData = response.data let funcData = response.data
// 获取自定义的字段
let funcCustom = JSON.parse(funcData.jsonData)
let funcCustomKey = []
let funcEnterInfo = this.enterInfoBuffer
for (let i = 0, l = funcCustom.length; i < l; i++) {
let funcItem = {
'label': funcCustom[i].label,
'field': funcCustom[i].prop,
'value': funcCustom[i].value,
}
funcCustomKey.push(funcItem)
funcEnterInfo[funcCustom[i].prop] = ''
funcEnterInfo['error' + funcCustom[i].prop] = ''
}
this.setData({ this.setData({
clubInfo: { clubInfo: {
'id': funcData.clubId, 'id': funcData.clubId,
...@@ -40,7 +58,8 @@ Page({ ...@@ -40,7 +58,8 @@ Page({
'describe': funcData.summary, 'describe': funcData.summary,
'member': funcData.memberNum, 'member': funcData.memberNum,
'isOwner': Number(funcData.owner) === 0 ? false : true 'isOwner': Number(funcData.owner) === 0 ? false : true
} },
enterInfoCustom: funcCustomKey,
}) })
}).catch((response) => {}) }).catch((response) => {})
}, },
...@@ -48,6 +67,7 @@ Page({ ...@@ -48,6 +67,7 @@ Page({
onInputBlur: function (funcEvent) { onInputBlur: function (funcEvent) {
let funcType = funcEvent.detail.id let funcType = funcEvent.detail.id
let funcValue = funcEvent.detail.value let funcValue = funcEvent.detail.value
let funcItem = funcEvent.currentTarget.dataset.item
switch (funcType) { switch (funcType) {
case 'name': case 'name':
...@@ -63,60 +83,88 @@ Page({ ...@@ -63,60 +83,88 @@ Page({
case 'remark': case 'remark':
this.enterInfoBuffer.remark = funcValue this.enterInfoBuffer.remark = funcValue
this.enterInfoBuffer.errorRemark = App.modular.rule.item('required', funcValue) this.enterInfoBuffer.errorRemark = App.modular.rule.item('required', funcValue)
if (this.enterInfoBuffer.errorRemark !== '') this.enterInfoBuffer.errorRemark = '备注' + this.enterInfoBuffer.errorRemark if (this.enterInfoBuffer.errorRemark !== '') {
this.enterInfoBuffer.errorRemark = '备注' + this.enterInfoBuffer.errorRemark
}
break
case 'other':
this.enterInfoBuffer[funcItem.field] = funcValue
this.enterInfoBuffer['error' + funcItem.field] = App.modular.rule.item('required', funcValue)
if (this.enterInfoBuffer['error' + funcItem.field] !== '') {
this.enterInfoBuffer['error' + funcItem.field] = funcItem.label + this.enterInfoBuffer['error' + funcItem.field]
}
break break
} }
this.setData({ this.setData({
enterInfo: this.enterInfoBuffer enterInfo: this.enterInfoBuffer
}) })
if (this.enterInfoBuffer.name !== '' && this.enterInfoBuffer.phone !== '' && this.enterInfoBuffer.remark !== '') { if (this.enterInfoBuffer.name !== '' && this.enterInfoBuffer.phone !== '' && this.enterInfoBuffer.remark !== '') {
console.log('没有空值')
this.setData({ this.setData({
isButtonEnable: true isButtonEnable: true
}) })
} else { } else {
console.log('存在空值')
this.setData({ this.setData({
isButtonEnable: false isButtonEnable: false
}) })
} }
console.log(this.data.enterInfo)
}, },
inspectForm: function () { inspectForm: function () {
console.log('inspectForm')
let funcPass = true let funcPass = true
let funcEnterInfoKey = Object.keys(this.data.enterInfo) let funcEnterInfoKey = Object.keys(this.data.enterInfo)
for (let i = 0, l = funcEnterInfoKey.length; i < l; i++) { for (let i = 0, l = funcEnterInfoKey.length; i < l; i++) {
// error 信息验证,如果存在非空字段,则表示有数据校验不通过。 // error 信息验证,如果存在非空字段,则表示有数据校验不通过。
if (funcEnterInfoKey[i].indexOf('error') >= 0 && this.data.enterInfo[funcEnterInfoKey[i]]) { if (funcEnterInfoKey[i].indexOf('error') >= 0 && this.data.enterInfo[funcEnterInfoKey[i]]) {
console.log('验证不通过')
funcPass = false funcPass = false
} }
// 常规字段验证,确保没有非空字段。 // 常规字段验证,确保没有非空字段。
if (funcEnterInfoKey[i].indexOf('error') < 0 && this.data.enterInfo[funcEnterInfoKey[i]] === '') { if (funcEnterInfoKey[i].indexOf('error') < 0 && this.data.enterInfo[funcEnterInfoKey[i]] === '') {
this.onInputBlur({ detail: { id: funcEnterInfoKey[i], value: '' }}) let funcEnterInfoCustom = this.data.enterInfoCustom
console.log('验证不通过') let ii = 0
let ll = 0
custom:for (ii = 0, ll = funcEnterInfoCustom.length; ii < ll; ii++) {
if (funcEnterInfoKey[i] === funcEnterInfoCustom[ii].field.toString()) {
this.onInputBlur({
detail: { id: 'other', value: '' },
currentTarget: { dataset: { item:funcEnterInfoCustom[ii] }}
})
break custom
}
}
if (ii === funcEnterInfoCustom.length) {
this.onInputBlur({ detail: { id: funcEnterInfoKey[i], value: '' }})
}
funcPass = false funcPass = false
} }
} }
return funcPass return funcPass
}, },
onEnter: function () { onEnter: function () {
console.log('onEnter')
if (!this.inspectForm()) return if (!this.inspectForm()) return
console.log('验证通过') let funcEnterInfo = this.data.enterInfo
let funcEnterInfoCustom = this.data.enterInfoCustom
let funcList = []
for (let i = 0, l = funcEnterInfoCustom.length; i < l; i++) {
let funcItem = {
'label': funcEnterInfoCustom[i].label,
'prop': funcEnterInfoCustom[i].field,
'val': funcEnterInfo[funcEnterInfoCustom[i].field]
}
funcList.push(funcItem)
}
App.request({ App.request({
url: 'v3/club/joinClub', url: 'v3/club/joinClub',
params: { params: {
'name': this.data.enterInfo.name, 'name': this.data.enterInfo.name,
'nickname': wx.getStorageSync('userInfo').name, 'nickname': wx.getStorageSync('userInfo').name,
'mobile': this.data.enterInfo.phone, 'mobile': this.data.enterInfo.phone,
'jsonData': '{}', 'jsonData': funcList.length > 0 ? JSON.stringify(funcList) : '[]',
'smClub': { id: this.data.clubInfo.id } 'smClub': { id: this.data.clubInfo.id }
} }
}).then((response) => { }).then((response) => {
...@@ -127,7 +175,6 @@ Page({ ...@@ -127,7 +175,6 @@ Page({
'iconType': 'error', 'iconType': 'error',
'title': response.message 'title': response.message
}) })
console.log('catch', response)
}) })
} }
}) })
\ No newline at end of file
<m-toast></m-toast> <m-toast></m-toast>
<m-nav titleText="申请加入俱乐部"></m-nav> <m-nav titleText="申请加入俱乐部" styleIndex="{{1}}"></m-nav>
<view class="container"> <view class="container">
<view class="club-info col cc ac"> <view class="club-info col cc ac">
...@@ -42,6 +42,20 @@ ...@@ -42,6 +42,20 @@
</m-input> </m-input>
<text>{{enterInfo.errorRemark}}</text> <text>{{enterInfo.errorRemark}}</text>
</view> </view>
<block wx:for="{{enterInfoCustom}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="form-item col">
<text>{{item.label}}</text>
<m-input
inputId="other"
className="form-item-input row ac"
placeholder="{{'请输入' + item.label}}"
data-item="{{item}}"
bindblur="onInputBlur">
</m-input>
<text>{{enterInfo['error' + item.field]}}</text>
</view>
</block>
</view> </view>
</view> </view>
......
...@@ -71,7 +71,7 @@ Page({ ...@@ -71,7 +71,7 @@ Page({
}) })
this.queryClub(0) this.queryClub(0)
console.log(response) console.log(this.data.tabItem)
}).catch((response) => { }).catch((response) => {
console.log(response) console.log(response)
}) })
...@@ -83,7 +83,8 @@ Page({ ...@@ -83,7 +83,8 @@ Page({
* @param {object} - funcEvent * @param {object} - funcEvent
* @returns * @returns
*/ */
queryClub: function (funcTabIndex) { queryClub: function (funcTabIndex) {
console.log(funcTabIndex)
App.request({ App.request({
url: 'v3/club/getClubList', url: 'v3/club/getClubList',
params: { params: {
...@@ -185,6 +186,7 @@ Page({ ...@@ -185,6 +186,7 @@ Page({
* @returns * @returns
*/ */
onTabChange: function (funcEvent) { onTabChange: function (funcEvent) {
console.log(funcEvent6)
let funcItem = funcEvent.detail let funcItem = funcEvent.detail
this.setData({ this.setData({
clubList: [], clubList: [],
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<!-- tab --> <!-- tab -->
<view class="tab"> <view class="tab">
<m-tab item="{{tabItem}}" tabClass="tab_list" bindtabChange="onTabChange"></m-tab> <m-tab item="{{tabItem}}" bindtabChange="onTabChange"></m-tab>
</view> </view>
<view class="club-list"> <view class="club-list">
......
...@@ -92,9 +92,8 @@ ...@@ -92,9 +92,8 @@
background: #999999; background: #999999;
} }
.tab_list { .tab {
margin: 64rpx 0 0 0; margin: 54rpx 0 0 0;
padding: 0 0 0 40rpx;
} }
.club-list { .club-list {
...@@ -135,6 +134,12 @@ ...@@ -135,6 +134,12 @@
font-weight: 400; font-weight: 400;
line-height: 36rpx; line-height: 36rpx;
color: #959DA9; color: #959DA9;
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
} }
.club-info-other { .club-info-other {
......
...@@ -71,10 +71,63 @@ Page({ ...@@ -71,10 +71,63 @@ Page({
}, },
}).then((response) => { }).then((response) => {
console.log(response) console.log(response)
let funcData = response.data.list
let funcList = []
for (let i = 0, l = funcData.length; i < l; i++) {
// 活动暂时没有活动价格
let funcItem = {
'cover': funcData[i].cover ? funcData[i].cover : this.data.resourcesBase + 'play/shop/commodity-card.png',
'id': funcData[i].id,
'title': funcData[i].name,
'officeId': funcData[i].officeId,
'price': funcData[i].visitorPrice, // 游客价
'priceText': App.modular.utils.formatAmount(funcData[i].visitorPrice),
'priceSpecial': funcData[i].ownerPrice, // 业主价
'priceSpecialText': App.modular.utils.formatAmount(funcData[i].ownerPrice),
'priceDiscount': funcData[i].price, // 活动价
'priceDiscountText':  App.modular.utils.formatAmount(funcData[i].price),
'tagIds': funcData[i].tagIds,
'tagNames': funcData[i].tagNames,
'date': funcData[i].activeDate.replace(/月/g, '.').replace(/日/g, '') + ' ' + funcData[i].activeTime,
'priceType': 1,
}
funcList.push(funcItem)
}
funcList = App.setPriceType(funcList)
this.setData({
clubActivity: funcList
})
console.log(funcList)
}).catch((response) => {}) }).catch((response) => {})
}, },
/** /**
* 更多俱乐部活动
* @function
* @param {object} - funcEvent
* @returns
*/
onClubActivityMore: function () {
wx.navigateTo({ url: '/pages/play/activity/activity?fromPage=club&id=' + this.data.clubInfo.id})
},
/**
* 报名俱乐部活动
* @function
* @param {object} - funcEvent
* @returns
*/
onClubActivityEnter: function (funcEvent) {
console.log(funcEvent)
let funcItem = funcEvent.currentTarget.dataset.item
wx.navigateTo({
url: '/pages/play/activity-detail/activity-detail?id=' + funcItem.id,
})
},
/**
* 申请加入俱乐部 * 申请加入俱乐部
* @function * @function
* @param {object} - funcEvent * @param {object} - funcEvent
......
...@@ -37,47 +37,56 @@ ...@@ -37,47 +37,56 @@
</view> </view>
<!-- 近期活动 --> <!-- 近期活动 -->
<view class="card"> <view class="card" wx:if="{{clubActivity.length > 0}}">
<view class="card-title row cb ac"> <view class="card-title row cb ac">
<text class="title">近期活动</text> <text class="title">近期活动</text>
<text>查看全部</text> <text bindtap="onClubActivityMore">查看全部</text>
</view> </view>
<block wx:if="{{clubActivity.length > 0}}"> <view class="card-list row">
<view class="card-list row"> <block wx:for="{{clubActivity}}" wx:for-item="item" wx:for-index="index" wx:key="index">
<block wx:for="{{clubActivity}}" wx:for-item="item" wx:for-index="index" wx:key="index"> <view class="card-item column ac" data-item="{{item}}" bindtap="onClubActivityEnter">
<view class="card-item column ac"> <image class="card-item-cover" src="{{item.cover}}"></image>
<image class="card-item-cover"></image> <view class="card-item-info">
<view class="card-item-info"> <view class="card-item-info-title row cb ac">
<view class="card-item-info-title row cb ac"> <text>{{item.title}}</text>
<text>八月银湖湾儿童马术节</text> <text class="tag-blue" wx:if="{{tagNames}}">{{item.tagNames}}</text>
<text class="tag-blue">亲子教育</text> </view>
</view> <view class="card-item-info-time row ac">
<view class="card-item-info-time row ac"> <image class="arrow-more" src="{{imageBase + 'icon/clock-2.png'}}"></image>
<image class="arrow-more" src="{{imageBase + 'icon/clock-2.png'}}"></image> <text>{{item.date}}</text>
<text>9.20-9.25 10:00-11:30</text> </view>
</view> <view class="card-item-other row cb ac">
<view class="card-item-other row cb ac"> <view class="card-item-price row">
<view class="card-item-price row"> <!-- 活动价 - 暂无 -->
<block wx:if="{{item.priceType === 1}}">
<text class="discount-mark">活动价</text>
<text>{{'¥ ' + item.priceDiscountText}}</text>
<text>{{'¥ ' + item.priceText}}</text>
</block>
<!-- 业主价 -->
<block wx:if="{{item.priceType === 2}}">
<text class="owner-mark">业主价</text> <text class="owner-mark">业主价</text>
<text>免费</text> <text>{{'¥' + item.priceSpecialText}}</text>
<text>¥ 149</text> <text>{{'¥' + item.priceText}}</text>
</view> </block>
<button class="row cc ac">报名</button>
<!-- 普通价 -->
<block wx:if="{{item.priceType === 3}}">
<text></text>
<text>{{item.priceDiscountText}}</text>
<text></text>
</block>
</view> </view>
<button class="row cc ac">报名</button>
</view> </view>
</view> </view>
</block> </view>
<view class="card-item column ac" wx:if="{{true}}"></view> </block>
</view> <view class="card-item column ac"></view>
</block>
</view>
<block wx:if="{{clubActivity.length === 0}}">
<view class="item-nothing col con-c align-c">
<image class="nothing-activity" src="{{imageBase + 'icon/fireworks-2.png'}}"></image>
<text>近期暂无活动安排</text>
</view> </view>
</block> </view>
<!-- 详情 --> <!-- 详情 -->
<view class="club-detail"> <view class="club-detail">
......
...@@ -65,6 +65,12 @@ ...@@ -65,6 +65,12 @@
font-weight: 300; font-weight: 300;
line-height: 50rpx; line-height: 50rpx;
color: #15191F; color: #15191F;
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
} }
/* 近期活动 */ /* 近期活动 */
...@@ -109,8 +115,8 @@ ...@@ -109,8 +115,8 @@
} }
.card-item:last-child { .card-item:last-child {
width: 1rpx !important; width: 1px !important;
min-width: 1rpx !important; background: rgba(0, 0, 0, 0);
} }
.card-item-cover { .card-item-cover {
...@@ -174,26 +180,6 @@ ...@@ -174,26 +180,6 @@
color: #C2C7CF; color: #C2C7CF;
} }
/* 没有活动样式 */
.item-nothing {
width: 670rpx;
height: 478rpx;
}
.item-nothing text {
margin-top: 42rpx;
font-size: 30rpx;
color: #959da9;
line-height: 42rpx;
font-weight: 600;
}
.nothing-activity {
display: block;
width: 96rpx;
height: 76rpx;
}
/* 俱乐部详情 */ /* 俱乐部详情 */
.club-detail { .club-detail {
margin-top: 80rpx; margin-top: 80rpx;
......
...@@ -112,13 +112,12 @@ Page({ ...@@ -112,13 +112,12 @@ Page({
checkFinish: function () { checkFinish: function () {
if (this.data.islogin && this.data.isphone) { if (this.data.islogin && this.data.isphone) {
// 在注册完成之后 login 一次,重新设置用户信息以及相关状态参数 // 在注册完成之后 login 一次,重新设置用户信息以及相关状态参数
console.log('注册成功') App.userLogin()
App.globalData.token = ''
App.login({ let funcTimer = setTimeout(() => {
success: () => { wx.navigateBack({})
wx.navigateBack({}) clearTimeout(funcTimer)
} }, 1000)
})
} }
} }
}) })
\ No newline at end of file
// pages/mall/home/home.js let App = getApp()
Page({ Page({
/**
* 页面的初始数据
*/
data: { data: {
tabItemCommodity: [
{ text: '全部', value: '' },
{ text: '文创', value: '' },
{ text: '彩妆', value: '' },
{ text: '节日特供', value: '' },
{ text: '节日特供', value: '' },
{ text: '节日特供', value: '' },
],
tabItemPrice: [
{ text: '全部', value: '' },
{ text: '1-100', value: '' },
{ text: '100-500', value: '' },
{ text: '500-5000', value: '' },
{ text: '5000-10000', value: '' },
],
}, },
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) { onLoad: function (options) {
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 页面滚动事件
*/ * @function
onReady: function () { * @param {object} - funcEvent
* @returns
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { onPageScroll: function (funcEvent) {
App.pageScroll(funcEvent, this)
}, },
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
}) })
\ No newline at end of file
<!--pages/mall/home/home.wxml--> <m-toast></m-toast>
<text>pages/mall/home/home.wxml</text> <m-nav titleText="积分优享" scrollHeight="{{navScroll}}" styleIndex="{{2}}" isOccupy="{{false}}"></m-nav>
<view class="container">
<view class="integral_operation">
<image src="{{resourcesBase + 'mall/home-bgi.png'}}"></image>
<view class="row ae">
<view class="integral_quantity column">
<text>18560</text>
<text>我的积分</text>
</view>
<view class="integral_record column cc ac">
<image class="icon_48" src="{{imageBase + 'icon/exchange-3.png'}}"></image>
<text>兑换记录</text>
</view>
<view class="integral_detail column cc ac">
<image class="icon_48" src="{{imageBase + 'icon/list-3.png'}}"></image>
<text>积分明细</text>
</view>
</view>
</view>
<view class="commodity_info column cc ac">
<!-- 专场商品列表 -->
<view class="recommend">
<view class="recommend_card">
<view class="recommend_title">
<text>亲自专场</text>
</view>
<view class="recommend_list">
<block wx:for="{{3}}" wx:for-item="item" wx:for-index="index" wx:key="index">
<view class="recommend_item">
<view class="recommend_item_info column">
<image src=""></image>
<text class="recommend_item_info_name">金桂浮月收纳盒</text>
<view class="recommend_item_info_price row ac">
<text>20000</text>
<text>积分</text>
</view>
</view>
</view>
</block>
</view>
</view>
</view>
<!-- 专场商品列表 -->
<view class="recommend">
<view class="recommend_card">
<view class="recommend_title">
<text>亲自专场</text>
</view>
<view class="recommend_list">
<block wx:for="{{3}}" wx:for-item="item" wx:for-index="index" wx:key="index">
<view class="recommend_item">
<view class="recommend_item_info column">
<image src=""></image>
<text class="recommend_item_info_name">金桂浮月收纳盒</text>
<view class="recommend_item_info_price row ac">
<text>20000</text>
<text>积分</text>
</view>
</view>
</view>
</block>
</view>
</view>
</view>
<!-- 常规商品列表 -->
<view class="routine">
<m-tab
item="{{tabItemCommodity}}"
classTab="commodity_tab"
classTabItem="commodity_tab_item"
classActive="commodity_tab_item_active"
classInactive="commodity_tab_item_inactive"
bindtabChange="onTabChange">
</m-tab>
<m-tab
item="{{tabItemPrice}}"
classTab="price_tab"
classTabList="price_tab_list"
classTabItem="price_tab_item"
classActive="price_tab_item_active"
classInactive="price_tab_item_inactive"
bindtabChange="onTabChange">
</m-tab>
<view class="routine_list">
<block wx:for="{{3}}" wx:for-item="item" wx:for-index="index" wx:key="index">
<view class="routine_item">
<view class="routine_item_info column">
<image src=""></image>
<view class="routine_item_info_name row as">
<text>故宫 金桂浮月收纳盒书签香薰盒</text>
</view>
<view class="routine_item_info_price row ac">
<text>20000</text>
<text>积分</text>
</view>
<view class="routine_item_info_exchange row ac">
<text>{{'已兑换' + '2000' + '件'}}</text>
</view>
</view>
</view>
</block>
</view>
</view>
</view>
</view>
\ No newline at end of file
/* pages/mall/home/home.wxss */ /* 积分信息 */
\ No newline at end of file .integral_operation {
display: block;
width: 750rpx;
height: 480rpx;
padding: 208rpx 40rpx 0 40rpx;
}
.integral_quantity {
flex-grow: 1;
}
.integral_quantity > text:nth-child(1) {
height: 104rpx;
font-size: 74rpx;
font-weight: 800;
line-height: 104rpx;
color: #F0DABB;
}
.integral_quantity > text:nth-child(2) {
height: 36rpx;
margin: 2rpx 0 0 0;
font-size: 26rpx;
font-weight: 400;
line-height: 36rpx;
color: #FFFFFF;
}
.integral_record {
margin: 0 32rpx 0 0;
}
.integral_record > text,
.integral_detail > text {
height: 36rpx;
margin: 16rpx 0 0 0;
font-size: 26rpx;
font-weight: 400;
line-height: 36rpx;
color: #FFFFFF;
}
.integral_operation > image {
z-index: -1;
position: absolute;
top: 0;
left: 0;
width: 750rpx;
height: 480rpx;
}
.commodity_info {
width: 750rpx;
padding: 0 0 140rpx 0;
background: #F3F4F6;
}
/* 推荐商品 */
.recommend {
position: relative;
top: -74rpx;
margin: 0 0 24rpx 0;
}
.recommend_card {
width: 670rpx;
height: 466rpx;
padding: 32rpx 0 38rpx 32rpx;
border-radius: 4px;
background: #FFFFFF;
}
.recommend_title {
height: 44rpx;
font-size: 38rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 800;
line-height: 44rpx;
color: #15191F;
}
.recommend_list {
width: 638rpx;
height: 320rpx;
margin: 32rpx 0 0 0;
overflow-x: scroll;
white-space: nowrap;
}
.recommend_item {
display: inline-block;
margin: 0 24rpx 0 0;
}
.recommend_item_info > image {
width: 208rpx;
height: 208rpx;
border-radius: 4px;
background: #999999;
}
.recommend_item_info_name {
height: 44rpx;
margin: 20rpx 0 0 0;
font-size: 26rpx;
font-weight: 800;
line-height: 44rpx;
color: #15191F;
}
.recommend_item_info_price {
margin: 4rpx 0 0 0;
}
.recommend_item_info_price > text:nth-child(1) {
height: 44rpx;
margin: 0 4rpx 0 0;
font-size: 26rpx;
font-weight: 500;
line-height: 44rpx;
color: #EF4E4E;
}
.recommend_item_info_price > text:nth-child(2) {
height: 44rpx;
font-size: 22rpx;
font-weight: 400;
line-height: 44rpx;
color: #15191F;
}
/* 所有商品 */
.routine {
width: 750rpx;
}
.commodity_tab {
width: 750rpx;
padding: 0 0 0 40rpx;
border-bottom: 1px #E2E7EF solid;
overflow-x: scroll;
}
.commodity_tab_item {
display: inline-block;
margin: 0 80rpx 0 0;
text-align: left;
}
.commodity_tab_item_active {
height: 64rpx;
border-bottom: 4rpx #15191F solid;
font-size: 26rpx;
font-weight: 800;
line-height: 36rpx;
color: #15191F;
}
.commodity_tab_item_inactive {
height: 36rpx;
border-bottom: 4rpx rgba(0, 0, 0, 0) solid;
font-size: 26rpx;
font-weight: 800;
line-height: 36rpx;
color: #656E7B;
}
/* 积分范围 tab */
.price_tab {
width: 750rpx;
margin: 40rpx 0 0 0;
padding: 0 0 0 40rpx;
overflow-x: scroll;
}
.price_tab_list {
white-space: nowrap;
}
.price_tab_item {
display: inline-block;
margin: 0 16rpx 0 0;
font-size: 26rpx;
font-weight: 800;
line-height: 36rpx;
}
.price_tab_item_active {
height: 60rpx;
padding: 0 32rpx;
border: 1px solid #000000;
border-radius: 4px;
color: #000000;
}
.price_tab_item_inactive {
height: 60rpx;
padding: 0 32rpx;
border: 1px solid #D4D9E2;
border-radius: 4px;
color: #656E7B;
}
/* 商品列表 */
.routine_list {
width: 750rpx;
margin: 56rpx 0 0 0;
padding: 0 40rpx;
}
.routine_item {
display: inline-block;
width: 324rpx;
height: 554rpx;
border-radius: 4px;
margin: 0 22rpx 24rpx 0;
background: #FFFFFF;
overflow: hidden;
}
.routine_item:nth-child(2n) {
margin: 0 0 24rpx 0;
}
.routine_item_info > image {
width: 324rpx;
height: 324rpx;
background: #999999;
}
.routine_item_info_name {
width: 276rpx;
height: 72rpx;
margin: 32rpx 24rpx 0 24rpx;
}
.routine_item_info_name > text {
font-size: 26rpx;
font-weight: 800;
color: #15191F;
}
.routine_item_info_price {
margin: 4rpx 24rpx 0 24rpx;
}
.routine_item_info_price > text:nth-child(1) {
height: 44rpx;
margin: 0 4rpx 0 0;
font-size: 26rpx;
font-weight: 500;
line-height: 44rpx;
color: #EF4E4E;
}
.routine_item_info_price > text:nth-child(2) {
height: 44rpx;
font-size: 22rpx;
font-weight: 400;
line-height: 44rpx;
color: #15191F;
}
.routine_item_info_exchange {
height: 32rpx;
margin: 8rpx 24rpx 0 24rpx;
font-size: 22rpx;
font-weight: 400;
line-height: 32rpx;
color: #959DA9;
}
\ No newline at end of file
...@@ -2,7 +2,14 @@ ...@@ -2,7 +2,14 @@
<m-dialog></m-dialog> <m-dialog></m-dialog>
<m-nav titleText="我的俱乐部" styleIndex="{{1}}"></m-nav> <m-nav titleText="我的俱乐部" styleIndex="{{1}}"></m-nav>
<m-tab item="{{tabItem}}" tabClass="tab" itemClass="tab-item" bindtabChange="eventTabChange"></m-tab> <m-tab
item="{{tabItem}}"
classTab="tab"
classTabItem="tab_item"
classActive="tab_item_active"
classInactive="tab_item_inactive"
bindtabChange="eventTabChange">
</m-tab>
<view class="container"> <view class="container">
<view class="club-list bg-gradient {{clubList.length ? 'column' : 'row cc ac'}}"> <view class="club-list bg-gradient {{clubList.length ? 'column' : 'row cc ac'}}">
<block wx:for="{{clubList}}" wx:for-item="item" wx:for-index="index" wx:key="index"> <block wx:for="{{clubList}}" wx:for-item="item" wx:for-index="index" wx:key="index">
......
.tab { .tab {
display: flex;
flex-direction: row;
justify-content: space-between;
margin-top: 60rpx; margin-top: 60rpx;
border-bottom: 1px #E2E7EF solid;
}
.tab_item {
display: inline-block;
} }
.tab-item { .tab_item_active {
width: 104rpx;
height: 50px;
margin: 0 136rpx; margin: 0 136rpx;
border-bottom: 4rpx #000000 solid;
font-size: 26rpx; font-size: 26rpx;
font-weight: 800; font-weight: 800;
line-height: 36px;
color: #15191F; color: #15191F;
} }
.tab_item_inactive {
width: 104rpx;
height: 50rpx;
margin: 0 136rpx;
border-bottom: 4rpx rgba(0, 0, 0, 0) solid;
font-size: 26rpx;
font-weight: 800;
line-height: 36px;
color: #959DA9;
}
/* 俱乐部列表 */ /* 俱乐部列表 */
.club-list { .club-list {
width: 750rpx; width: 750rpx;
......
...@@ -131,7 +131,7 @@ Page({ ...@@ -131,7 +131,7 @@ Page({
}, },
/** /**
* 设置用户信息 * 设置用户面板信息
* @function * @function
* @param * @param
* @returns * @returns
...@@ -506,8 +506,8 @@ Page({ ...@@ -506,8 +506,8 @@ Page({
* @param * @param
* @returns * @returns
*/ */
onIntegralDetail: function (event) { onIntegralDetail: function (funcEvent) {
let integral = event.currentTarget.dataset.integral let integral = funcEvent.currentTarget.dataset.integral
wx.navigateTo({ wx.navigateTo({
url: '/pages/mine/accumulate/accumulate?integral=' + integral, url: '/pages/mine/accumulate/accumulate?integral=' + integral,
}) })
......
...@@ -222,7 +222,7 @@ Page({ ...@@ -222,7 +222,7 @@ Page({
name: 'file', name: 'file',
header: { header: {
'Content-Type': 'multipart/form-data', 'Content-Type': 'multipart/form-data',
'token': App.globalData.token 'token': wx.getStorageSync('token')
}, },
success: function (res) { success: function (res) {
wx.hideLoading({ wx.hideLoading({
......
...@@ -1079,6 +1079,17 @@ Page({ ...@@ -1079,6 +1079,17 @@ Page({
'totalPrice': Number(this.data.payAmount), 'totalPrice': Number(this.data.payAmount),
}, },
success: (response) => { success: (response) => {
if (/非该俱乐部成员/.test(response.data.msg)) {
App.ui.showToast({
iconType: 'error',
title: response.data.msg,
})
this.setData({
isPaySubmit: false,
})
return
}
if (/请勿重复报名/.test(response.data.msg)) { if (/请勿重复报名/.test(response.data.msg)) {
App.ui.showToast({ App.ui.showToast({
iconType: 'error', iconType: 'error',
......
...@@ -14,6 +14,7 @@ Page({ ...@@ -14,6 +14,7 @@ Page({
other: [], other: [],
selectedOther: [], selectedOther: [],
shopInfo: {}, shopInfo: {},
clubInfo: {},
options: {}, options: {},
}, },
...@@ -26,7 +27,15 @@ Page({ ...@@ -26,7 +27,15 @@ Page({
}) })
} }
// this.queryTab() if (options.fromPage === 'club') {
let shopInfo = wx.getStorageSync('shopInfoBuffer')
this.setData({
options: options,
clubInfo: { id: options.id }
})
}
this.queryTab()
this.queryActivityLately() this.queryActivityLately()
this.queryActivityExpire() this.queryActivityExpire()
}, },
...@@ -62,6 +71,9 @@ Page({ ...@@ -62,6 +71,9 @@ Page({
'pageSize': 99, 'pageSize': 99,
'pageNo': 1, 'pageNo': 1,
'tagId': this.data.tabClass, 'tagId': this.data.tabClass,
'officeId': this.data.shopInfo.id ? this.data.shopInfo.id : '',
'clubId': this.data.clubInfo.id ? this.data.clubInfo.id : '',
'type': this.data.clubInfo.id ? 2 : '',
} }
}).then((response) => { }).then((response) => {
let funcData = response.data.list let funcData = response.data.list
...@@ -102,6 +114,9 @@ Page({ ...@@ -102,6 +114,9 @@ Page({
'pageSize': 10, 'pageSize': 10,
'pageNo': this.data.pageIndex, 'pageNo': this.data.pageIndex,
'tagId': this.data.tabClass, 'tagId': this.data.tabClass,
'officeId': this.data.shopInfo.id ? this.data.shopInfo.id : '',
'clubId': this.data.clubInfo.id ? this.data.clubInfo.id : '',
'type': this.data.clubInfo.id ? 2 : '',
} }
}).then((response) => { }).then((response) => {
let funcData = response.data.list let funcData = response.data.list
......
const App = getApp() let App = getApp()
Page({ Page({
// 此处属性是页面全局属性,通常用于记录不进行渲染的逻辑数据,避免过多 setData 操作。 // 此处属性是页面全局属性,通常用于记录不进行渲染的逻辑数据,避免过多 setData 操作。
option: {}, option: {},
......
...@@ -64,5 +64,7 @@ for (let i = 0, l = funcData.length; i < l; i++) { ...@@ -64,5 +64,7 @@ for (let i = 0, l = funcData.length; i < l; i++) {
let funcItem = { let funcItem = {
} }
funcList.push(funcItem) funcList.push(funcItem)
} }
\ No newline at end of file
// 界面循环 <block wx:for="{{lineStyle}}" wx:for-index="index" wx:for-item="item" wx:key="index">
\ No newline at end of file
let funcPageExtend = function () { let funcPageExtend = function (App) {
let funcPage = Page let funcPage = Page
Page = function (funcOption) { Page = function (funcOption) {
let App = getApp() // 增加全局资源引用路径
let funcData = { funcOption.data = Object.assign(funcOption.data, {
'appStatus': App.globalData.appStatus, 'appStatus': App.globalData.appStatus,
'imageBase': App.globalData.appImageBase, 'imageBase': App.globalData.appImageBase,
'resourcesBase': App.globalData.appResourcesBase, 'resourcesBase': App.globalData.appResourcesBase,
} })
funcOption = Object.assign({
data: funcData,
onShareAppMessage: function () { // 增加全局分享
return { funcOption.onShareAppMessage = function () {
title: '碧海银湖 | 理想生活', return {
path: '/pages/home/home/home', title: '碧海银湖 | 理想生活',
imageUrl: App.globalData.appImageBase + 'share.png', path: '/pages/home/home/home',
} imageUrl: App.globalData.appImageBase + 'share.png',
} }
}, funcOption) }
funcPage(funcOption) funcPage(funcOption)
} }
} }
......
let Base64 = {
keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
encode: function (e) {
var t = "";
var n, r, i, s, o, u, a;
var f = 0;
e = Base64._utf8_encode(e);
while (f < e.length) {
n = e.charCodeAt(f++);
r = e.charCodeAt(f++);
i = e.charCodeAt(f++);
s = n >> 2;
o = (n & 3) << 4 | r >> 4;
u = (r & 15) << 2 | i >> 6;
a = i & 63;
if (isNaN(r)) {
u = a = 64
} else if (isNaN(i)) {
a = 64
}
t = t + this.keyStr.charAt(s) + this.keyStr.charAt(o) + this.keyStr.charAt(u) + this.keyStr.charAt(a)
}
return t
},
decode: function (e) {
var t = "";
var n, r, i;
var s, o, u, a;
var f = 0;
e = e.replace(/[^A-Za-z0-9+/=]/g, "");
while (f < e.length) {
s = this.keyStr.indexOf(e.charAt(f++));
o = this.keyStr.indexOf(e.charAt(f++));
u = this.keyStr.indexOf(e.charAt(f++));
a = this.keyStr.indexOf(e.charAt(f++));
n = s << 2 | o >> 4;
r = (o & 15) << 4 | u >> 2;
i = (u & 3) << 6 | a;
t = t + String.fromCharCode(n);
if (u != 64) {
t = t + String.fromCharCode(r)
}
if (a != 64) {
t = t + String.fromCharCode(i)
}
}
t = Base64._utf8_decode(t);
return t
},
_utf8_encode: function (e) {
e = e.replace(/rn/g, "n");
var t = "";
for (var n = 0; n < e.length; n++) {
var r = e.charCodeAt(n);
if (r < 128) {
t += String.fromCharCode(r)
} else if (r > 127 && r < 2048) {
t += String.fromCharCode(r >> 6 | 192);
t += String.fromCharCode(r & 63 | 128)
} else {
t += String.fromCharCode(r >> 12 | 224);
t += String.fromCharCode(r >> 6 & 63 | 128);
t += String.fromCharCode(r & 63 | 128)
}
}
return t
},
_utf8_decode: function (e) {
var t = "";
var n = 0;
var r = 0;
var c1 = 0
var c2 = 0
var c3 = 0
while (n < e.length) {
r = e.charCodeAt(n);
if (r < 128) {
t += String.fromCharCode(r);
n++
} else if (r > 191 && r < 224) {
c2 = e.charCodeAt(n + 1);
t += String.fromCharCode((r & 31) << 6 | c2 & 63);
n += 2
} else {
c2 = e.charCodeAt(n + 1);
c3 = e.charCodeAt(n + 2);
t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
n += 3
}
}
return t
}
}
// // 定义字符串
// var string = "{name: mm,exp:1549106019}";
// // 加密
// var encodedString = Base64.encode(string);
// console.log(encodedString); // 输出: "SGVsbG8gV29ybGQh"
// // 解密
// var decodedString = Base64.decode(encodedString);
// console.log(decodedString); // 输出: "Hello World!"
export default Base64
\ No newline at end of file
import iToken from './token.js'
let output = function (App) {
let funcToken = wx.getStorageSync('token')
let funcTokenRefresh = wx.getStorageSync('tokenRefresh')
let funcTokenState
if (funcToken && funcTokenRefresh) {
funcTokenState = iToken.state(funcToken, funcTokenRefresh)
} else {
funcTokenState = 'nothing'
}
switch (funcTokenState) {
case 'valid':
console.log('[login] valid')
App.userUpdate()
break
case 'refresh':
App.refreshToken()
.then((response) => {
console.log('[login] refresh token success!')
App.userUpdate()
}).catch((response) => {
console.log('[login] refresh token fail!')
App.userLogin()
})
break
case 'invalid':
console.log('[login] invalid')
App.userLogin()
break
case 'nothing':
console.log('[login] nothing')
App.userLogin()
break
}
console.log(funcTokenState)
}
export default output
\ No newline at end of file
let App = getApp() import iBase64 from './base64.js'
let output = { let output = {
/** /**
...@@ -13,7 +13,7 @@ let output = { ...@@ -13,7 +13,7 @@ let output = {
funcIndex = funcDateBase.indexOf('.') funcIndex = funcDateBase.indexOf('.')
funcDateBase = funcDateBase.substring(0, funcIndex) funcDateBase = funcDateBase.substring(0, funcIndex)
let funcDateInfo = App.modular.base64.Base64.decode(funcDateBase) let funcDateInfo = iBase64.decode(funcDateBase)
let funcDateKey = '"exp":' let funcDateKey = '"exp":'
let funcDateString = funcDateInfo.substring(funcDateInfo.indexOf(funcDateKey) + funcDateKey.length, funcDateInfo.length) let funcDateString = funcDateInfo.substring(funcDateInfo.indexOf(funcDateKey) + funcDateKey.length, funcDateInfo.length)
funcDateString = funcDateString.substring(0, funcDateString.indexOf(',')) funcDateString = funcDateString.substring(0, funcDateString.indexOf(','))
...@@ -27,36 +27,19 @@ let output = { ...@@ -27,36 +27,19 @@ let output = {
* @param {string} - funcToken * @param {string} - funcToken
* @returns * @returns
*/ */
state: function (funcToken) { state: function (funcToken, funcTokenRefresh) {
let funcDate = output.term(funcToken) let funcDate = output.term(funcToken)
let funcNowDate = Math.round(new Date() / 1000) let funcNowDate = Math.round(new Date() / 1000)
// token 有效
if (funcNowDate < funcDate) return 'valid'
// 令牌有效 // token 无效,refreshToken 有效
if (funcNowDate < funcDate) { funcDate = output.term(funcTokenRefresh)
// 判断当前时间是否小于令牌期限 if (funcNowDate < funcDate) return 'refresh'
if (funcNowDate + 1200 < funcDate) {
// 令牌有效时间大于安全时间
console.log('[token] valid')
return 'valid'
} else {
console.log('[token] refresh')
return 'refresh'
}
}
// 令牌无效继续判断刷新令牌是否有效 // token 无效,refreshToken 无效
funcDate = output.term(localStorage.getItem('refresh')) if (funcNowDate > funcDate) return 'invalid'
// 令牌过期,刷新令牌有效需要重新登录
if (funcNowDate < funcDate) {
console.log('[token] relist')
return 'relist'
}
// 令牌过期,刷新令牌过期默认游客身份
if (funcNowDate > funcDate) {
console.log('[token] invalid')
return 'invalid'
}
}, },
} }
......
...@@ -8,9 +8,7 @@ let Output = { ...@@ -8,9 +8,7 @@ let Output = {
* @returns {object || boolean} * @returns {object || boolean}
*/ */
request: function (option) { request: function (option) {
let App = getApp() let funcToken = wx.getStorageSync('token')
let funcToken = App.globalData.token
if (funcToken) { if (funcToken) {
option.header.token = funcToken option.header.token = funcToken
} }
......
const output = { const output = {
// 二期测试环境 // 二期测试环境
baseUrl: 'https://sm-web2.meiqicloud.com/api/', // baseUrl: 'https://sm-web2.meiqicloud.com/api/',
// 三期测试环境 // 三期测试环境
// baseUrl: 'https://sm-web.meiqicloud.com/api/', baseUrl: 'https://sm-web.meiqicloud.com/api/',
// 正式环境 // 正式环境
......
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 sign in to comment