Browse Source

no message

featrue/v4.5
xpz2018 4 years ago
parent
commit
2f53f9c6cd
11 changed files with 153 additions and 518 deletions
  1. 51
      app.js
  2. 4
      pages/home/index/index.wxml
  3. 2
      pages/home/personal/personal.wxml
  4. 184
      pages/home/tab1/index.js
  5. 2
      pages/home/tab1/index.json
  6. 20
      pages/home/tab1/index.wxml
  7. 9
      pages/home/tab1/index.wxss
  8. 101
      pages/home/tab2/index.js
  9. 222
      pages/index/index.js
  10. 55
      pages/login/index.js
  11. 21
      pages/ztbvip/index.wxss

51
app.js

@ -1,7 +1,7 @@
//app.js //app.js
App({ App({
//----------------------------------------------globalData-------------------------------------- //----------------------------------------------globalData--------------------------------------
evn: 0,//0:开发环境,1:测试环境,2:生产环境
evn: 1,//0:开发环境,1:测试环境,2:生产环境
tmplIds: ['SUjEgwDopCv9xkkSZ4KbS0L7XbAiVQor6GmPg14K760'], tmplIds: ['SUjEgwDopCv9xkkSZ4KbS0L7XbAiVQor6GmPg14K760'],
agentMsgIds: ['kG8DErWDpyzBHCFaLlSKYMF7xVy8UpgogCwV_WSNt10', 'lOQ8Gvyy_dTk68bYGpRVnVA0M7DsYYrV81Gd39GUPBA'], agentMsgIds: ['kG8DErWDpyzBHCFaLlSKYMF7xVy8UpgogCwV_WSNt10', 'lOQ8Gvyy_dTk68bYGpRVnVA0M7DsYYrV81Gd39GUPBA'],
version: 152, version: 152,
@ -12,5 +12,54 @@ App({
token: null, token: null,
isIos: false, isIos: false,
kg: 0 kg: 0
},
onShow: function() {
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
// console.log('updateManager>>>' + res.hasUpdate)
})
updateManager.onUpdateReady(function () {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
})
if(this.globalData.Custom){
return
}
wx.getSystemInfo({
success: e => {
this.globalData.isIos = this.checkIos(e)
this.globalData.dev = e.platform == 'devtools'
let custom = wx.getMenuButtonBoundingClientRect()
this.globalData.Custom = custom
// 顶部操作栏高度
this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight + (this.globalData.isIos ? 4 : 0)
let windowHeight = e.windowHeight * (750 / e.windowWidth)
let safeBottom = e.windowHeight - e.safeArea.bottom
if(safeBottom > e.windowHeight){
safeBottom = 34
}
this.globalData.safeBottom = safeBottom * (750 / e.windowWidth)
// 状态栏高度
this.globalData.StatusBar = e.statusBarHeight * (750 / e.windowWidth)
let statusBarHeight = this.globalData.CustomBar * (750 / e.windowWidth)
this.globalData.statusBarHeight = statusBarHeight
// fragmentHeight:指的是整个页面statusBarHeight以下的高度
this.globalData.fragmentHeight = windowHeight - statusBarHeight
this.globalData.safeFragmentHeight = windowHeight - statusBarHeight - this.globalData.safeBottom
this.globalData.windowWidth = e.windowWidth
}
})
},
checkIos: function (e) {
if ('ios' === e.platform) {
return true
}
if (e.system.startsWith('iOS')) {
return true
}
return false
} }
}) })

4
pages/home/index/index.wxml

@ -199,12 +199,12 @@
</view> </view>
<button open-type="share" title="快来看看你的纸通宝吧!" hover-class="none" class="fxztb">分享纸通宝</button> <button open-type="share" title="快来看看你的纸通宝吧!" hover-class="none" class="fxztb">分享纸通宝</button>
</view> </view>
<view class="dmArea4Content" style="margin-top:20rpx">
<!-- <view class="dmArea4Content" style="margin-top:20rpx">
<view class="dmArea4ImgView" id="cscs" is-link bindtap="toPage"> <view class="dmArea4ImgView" id="cscs" is-link bindtap="toPage">
<image class="dmArea4Img" src="/assets/myinfo/qnwl.png"></image> <image class="dmArea4Img" src="/assets/myinfo/qnwl.png"></image>
</view> </view>
<view class="dmArea4text">城市测试</view> <view class="dmArea4text">城市测试</view>
</view>
</view> -->
</view> </view>
</view> </view>
</view> </view>

2
pages/home/personal/personal.wxml

@ -15,7 +15,7 @@
<view slot="footer">{{linkman || ''}}</view> <view slot="footer">{{linkman || ''}}</view>
</wux-cell> --> </wux-cell> -->
<wux-cell wx:if="{{userType == 1}}" is-link data-cid='card' data-tag='从业身份' bindtap="toTab1">
<wux-cell wx:if="{{userType == 1}}" data-cid='card' data-tag='从业身份'>
<view slot="header" class="text-gray">从业身份</view> <view slot="header" class="text-gray">从业身份</view>
<view slot="footer" class="{{userInfo.identityTag? 'text-black':'text-gray'}}">{{userInfo.identityTag || '点击修改从业身份'}}</view> <view slot="footer" class="{{userInfo.identityTag? 'text-black':'text-gray'}}">{{userInfo.identityTag || '点击修改从业身份'}}</view>
</wux-cell> </wux-cell>

184
pages/home/tab1/index.js

@ -1,100 +1,26 @@
// pages/home/tab1/index.js // pages/home/tab1/index.js
import {
updateUserInfo,
getBaseInfo,
postRelation
} from '../../api/ztb'
const storage = require('../../../utils/storage')
import { updateUserInfo, getBaseInfo } from '../../api/ztb'
const util = require('../../../utils/util') const util = require('../../../utils/util')
const math = require('../../../utils/math')
const event = require('../../../utils/event.js')
const app = getApp() const app = getApp()
Page({
Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
safeBottom: app.globalData.safeBottom,
bidType: 0, bidType: 0,
identityTag: '',
isFristLogin:false,
identityTag: ''
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.setData({
isFristLogin:storage.get('isfirstlogin')
})
this.setData({ safeBottom: app.globalData.safeBottom })
this.getUerInfoFct() this.getUerInfoFct()
}, },
toNextTab: function () { toNextTab: function () {
wx.navigateTo({
url: '/pages/home/tab2/index'
})
},
toMyInfo: function () {
wx.redirectTo({
url: '/pages/index/index'
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
// 分享至朋友圈
onShareTimeline() {
},
backspace: function () {
return
wx.redirectTo({ url: '/pages/home/tab2/index' })
}, },
onTabChangeTop: function (e) { onTabChangeTop: function (e) {
if (this.data.bidType == Number(e.currentTarget.dataset.index)) { if (this.data.bidType == Number(e.currentTarget.dataset.index)) {
@ -102,103 +28,45 @@ Page({
} }
var tabIndex = Number(e.currentTarget.dataset.index) var tabIndex = Number(e.currentTarget.dataset.index)
this.data.firstCategoryId = '' this.data.firstCategoryId = ''
this.setData({
['bidType']: tabIndex
})
var model = {
identityTag: ''
}
this.setData({ ['bidType']: tabIndex })
if (this.data.bidType == 1) { if (this.data.bidType == 1) {
model.identityTag = '打包站'
this.submitForm(model)
this.data.identityTag = '打包站'
this.submitForm()
} }
if (this.data.bidType == 2) { if (this.data.bidType == 2) {
model.identityTag = '废品站'
this.submitForm(model)
this.data.identityTag = '废品站'
this.submitForm()
} }
if (this.data.bidType == 3) { if (this.data.bidType == 3) {
model.identityTag = '废纸厂'
this.submitForm(model)
this.data.identityTag = '废纸厂'
this.submitForm()
} }
}, },
submitForm: function (model) {
console.log(model)
updateUserInfo(model).then(result => {
this.data.loopRequesting = false
submitForm: function () {
this.setData({ requesting: true})
updateUserInfo({ identityTag: this.data.identityTag }).then(result => {
this.setData({ requesting: false})
setTimeout(() => this.toNextTab(), 200) setTimeout(() => this.toNextTab(), 200)
}).catch(err => { }).catch(err => {
this.data.loopRequesting = false
util.showToast(err)
this.setData({ requesting: false})
}) })
}, },
bindblur: function (e) {
var model = {
identityTag: e.detail.value
}
this.submitForm(model)
onInput: function (e) {
this.data.identityTag = e.detail.value
}, },
getUerInfoFct: function () { getUerInfoFct: function () {
getBaseInfo().then(res => { getBaseInfo().then(res => {
if(res.data.hasShowedLoginTag==false||this.data.isFristLogin){
this.showDialog()
}
if (res.data.identityTag == '打包站') { if (res.data.identityTag == '打包站') {
this.setData({
bidType: 1
})
this.setData({ bidType: 1 })
} else if (res.data.identityTag == '废品站') { } else if (res.data.identityTag == '废品站') {
this.setData({
bidType: 2
})
this.setData({ bidType: 2 })
} else if (res.data.identityTag == '造纸厂') { } else if (res.data.identityTag == '造纸厂') {
this.setData({
bidType: 3
})
this.setData({ bidType: 3 })
} else { } else {
this.setData({
bidType: 4,
identityTag: res.data.identityTag
})
this.setData({ bidType: 4, identityTag: res.data.identityTag })
} }
}) })
},
showDialog: function(){
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
var that = this
this.wuxDialog.prompt({
resetOnClose: false,
maskClosable: false,
title: '邀请码',
// content: '联系相关业务人员获取邀请码',
placeholder: '填写业务人员邀请码(必填)',
maxlength: 6,
onConfirm(e, response) {
if(util.isEmpty(response)){
util.showToast('请输入邀请码')
that.showDialog()
return
}
that.bindRelation(response)
},
onCancel(){
}
})
},
bindRelation: function(code){
wx.showLoading({ title: '处理中', mask: true })
postRelation(code).then(result => {
//成功回调
wx.hideLoading()
}).catch(err => {
//异常回调
wx.hideLoading()
util.showToast(err)
this.showDialog()
})
},
}
}) })

2
pages/home/tab1/index.json

@ -1,5 +1,5 @@
{ {
"usingComponents": { "usingComponents": {
"wux-dialog": "/components/dialog/index"
"wux-button": "/components/button/index"
} }
} }

20
pages/home/tab1/index.wxml

@ -1,14 +1,13 @@
<!--pages/home/tab1/index.wxml--> <!--pages/home/tab1/index.wxml-->
<!-- intercept="{{true}}" bindcustomevent="backspace" -->
<cu-custom bgColor="bg-white" isBack="{{true}}">
<cu-custom bgColor="bg-white">
<view slot="content">身份</view> <view slot="content">身份</view>
</cu-custom> </cu-custom>
<view class="bj"> <view class="bj">
<view style="width:100%;height:130rpx;padding-top:10rpx;padding-right:10rpx">
<!-- <view style="width:100%;height:130rpx;padding-top:10rpx;padding-right:10rpx">
<button class="cu-btn bg-red round shadow-blur vip-btn" bindtap="toMyInfo">跳出</button> <button class="cu-btn bg-red round shadow-blur vip-btn" bindtap="toMyInfo">跳出</button>
<button class="cu-btn bg-red round shadow-blur vip-btn" bindtap="toNextTab">下一页</button> <button class="cu-btn bg-red round shadow-blur vip-btn" bindtap="toNextTab">下一页</button>
</view>
</view> -->
<view class="top"> <view class="top">
<view class="topText"> <view class="topText">
<text>HI,\n欢迎使用纸通宝\n开启一站式废纸交易</text> <text>HI,\n欢迎使用纸通宝\n开启一站式废纸交易</text>
@ -56,8 +55,15 @@
</view> </view>
</view> </view>
</view> </view>
<view class="otherInpt" wx:if="{{bidType == 4}}" >
<input placeholder="请输入你的身份" value="{{identityTag}}" bindblur="bindblur" />
<view style="padding: 32rpx 48rpx;">
<view class="otherInpt flex flex-center" style="justify-content: flex-start;" wx:if="{{bidType == 4}}" >
<input placeholder="请输入你的身份" value="{{identityTag}}" bindinput="onInput" />
</view>
</view> </view>
</view> </view>
<wux-dialog id="wux-dialog" />
<view class="cu-bar bg-white foot" style="height:{{120 + safeBottom}}rpx;padding: 32rpx 32rpx {{safeBottom + 32}}rpx 32rpx;" wx:if="{{bidType == 4}}">
<view style="width:100%">
<wux-button block type="positive" bind:click="submitForm" disabled="{{requesting}}">提交</wux-button>
</view>
</view>

9
pages/home/tab1/index.wxss

@ -26,15 +26,14 @@ page{
height: 258rpx; height: 258rpx;
float: left; float: left;
padding-left: 48rpx; padding-left: 48rpx;
padding-top: 60rpx;
padding-top: 32rpx;
font-size: 44rpx; font-size: 44rpx;
color: #000000; color: #000000;
font-family: PingFangSC-Medium; font-family: PingFangSC-Medium;
} }
.mid { .mid {
height: 150rpx;
padding-top: 100rpx;
padding-top: 48rpx;
padding-left: 48rpx; padding-left: 48rpx;
font-family: PingFangSC-Medium; font-family: PingFangSC-Medium;
font-size: 36rpx; font-size: 36rpx;
@ -93,5 +92,7 @@ page{
padding: 22px 33px 22px 33px; padding: 22px 33px 22px 33px;
} }
.otherInpt{ .otherInpt{
padding-left: 48rpx;
height: 72rpx;
padding: 0rpx 24rpx;
border: 1rpx solid #f3f3f3;
} }

101
pages/home/tab2/index.js

@ -1,12 +1,8 @@
// pages/home/tab2/index.js // pages/home/tab2/index.js
import {
updateUserInfo,
getBaseInfo
} from '../../api/ztb'
const storage = require('../../../utils/storage')
import { updateUserInfo, getBaseInfo } from '../../api/ztb'
import regions from '../../../utils/region' import regions from '../../../utils/region'
Page({
Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
@ -35,85 +31,19 @@ Page({
this.getUerInfoFct() this.getUerInfoFct()
this.cascaderView = this.cascaderView || this.selectComponent('#wux-cascader') this.cascaderView = this.cascaderView || this.selectComponent('#wux-cascader')
this.pickerView = this.pickerView || this.selectComponent('#picker-view') this.pickerView = this.pickerView || this.selectComponent('#picker-view')
}, },
toNextTab: function () { toNextTab: function () {
wx.navigateTo({
url: '/pages/home/tab3/index'
})
wx.navigateTo({ url: '/pages/home/tab3/index' })
}, },
toMyInfo: function () { toMyInfo: function () {
wx.redirectTo({
url: '/pages/index/index'
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
// 分享至朋友圈
onShareTimeline() {
},
backspace: function () {
console.log('点击返回被触发2')
wx.redirectTo({
url: '/pages/home/tab1/index'
})
wx.redirectTo({ url: '/pages/index/index' })
}, },
showRegion: function () { showRegion: function () {
if (this.data.disabled) { if (this.data.disabled) {
return return
} }
this.cascaderView.showPicker(this.data.region) this.cascaderView.showPicker(this.data.region)
this.setData({
picking: true
})
this.setData({ picking: true })
}, },
onRegionChange: function (e) { onRegionChange: function (e) {
if (e.detail && e.detail.options) { if (e.detail && e.detail.options) {
@ -124,14 +54,10 @@ Page({
this.data.form['locDistrictId'] = e.detail.value[2] this.data.form['locDistrictId'] = e.detail.value[2]
this.data.form['locDistrictName'] = e.detail.options[2].label this.data.form['locDistrictName'] = e.detail.options[2].label
this.setData({ this.setData({
picking: false
})
this.setData({
'form.areaStr': e.detail.options[0].label + e.detail.options[1].label
})
this.submitForm({
locateCityTag: this.data.form.locCityId
picking: false,
['form.areaStr']: e.detail.options[0].label + e.detail.options[1].label
}) })
this.submitForm({ locateCityTag: this.data.form.locCityId })
} }
}, },
submitForm: function (model) { submitForm: function (model) {
@ -145,11 +71,12 @@ Page({
}, },
getUerInfoFct: function () { getUerInfoFct: function () {
getBaseInfo().then(res => { getBaseInfo().then(res => {
this.setData({
region: [res.data.locateCityTag.provinceId, res.data.locateCityTag.cityId, res.data.locateCityTag.districtId],
'form.areaStr': res.data.locateCityTag.provinceName + res.data.locateCityTag.cityName
})
console.log(this.data.region)
if(res.data.locateCityTag) {
this.setData({
region: [res.data.locateCityTag.provinceId, res.data.locateCityTag.cityId, res.data.locateCityTag.districtId],
'form.areaStr': res.data.locateCityTag.provinceName + res.data.locateCityTag.cityName
})
}
}) })
} }
}) })

222
pages/index/index.js

@ -1,24 +1,7 @@
import {
config,
getUserInfo
} from "../api/user"
import {
zconfig,
loginToken,
getBaseInfo,
getPopupInfo,
updateUserInfo
} from "../api/ztb"
import {
pconfig
} from "../api/payment"
import {
mconfig
} from "../api/moment"
import {
sconfig,
getOrderExists
} from "../api/saas"
import { config, getUserInfo } from "../api/user"
import { zconfig, loginToken, getBaseInfo, getPopupInfo } from "../api/ztb"
import { pconfig } from "../api/payment"
import { mconfig } from "../api/moment"
const util = require('../../utils/util') const util = require('../../utils/util')
const event = require('../../utils/event') const event = require('../../utils/event')
const storage = require('../../utils/storage') const storage = require('../../utils/storage')
@ -26,47 +9,19 @@ const app = getApp()
Page({ Page({
data: { data: {
TabList: [{
index: 0,
value: 'article',
badge: 0,
name: '情报'
},
{
index: 1,
value: 'mall',
badge: 0,
name: '交易'
},
{
index: 2,
value: 'home',
badge: 0,
name: '我的'
}
TabList: [{ index: 0, value: 'article', badge: 0, name: '情报' },
{ index: 1, value: 'mall', badge: 0, name: '交易' },
{ index: 2, value: 'home', badge: 0, name: '我的' }
], ],
pageIndex: 1, pageIndex: 1,
safeBottom: app.globalData.safeBottom, safeBottom: app.globalData.safeBottom,
inited: false, inited: false,
path: null, path: null,
landInfo: null, landInfo: null,
visible: false,
hasShowedLoginTag: false, //是否已展示过登陆标签填写页面
isTokenHaveStatus: false,
visible: false
}, },
/************************************** 初始化流程 ********************************************/ /************************************** 初始化流程 ********************************************/
onLoad: function (options) { onLoad: function (options) {
storage.put('isTokenHaveStatus', false)
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
// console.log('updateManager>>>' + res.hasUpdate)
})
updateManager.onUpdateReady(function () {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
})
if (options.url) { if (options.url) {
this.data.path = options.url this.data.path = options.url
if (options.key && options.value) { if (options.key && options.value) {
@ -74,70 +29,20 @@ Page({
} }
} }
event.on('EventMessage', this, this.onEvent) event.on('EventMessage', this, this.onEvent)
},
onReady: function () {
wx.showLoading({
title: '获取中',
mask: true
})
wx.getSystemInfo({
success: e => {
app.globalData.isIos = this.checkIos(e)
app.globalData.dev = e.platform == 'devtools'
let custom = wx.getMenuButtonBoundingClientRect()
app.globalData.Custom = custom
// 顶部操作栏高度
app.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight + (app.globalData.isIos ? 4 : 0)
let windowHeight = e.windowHeight * (750 / e.windowWidth)
let safeBottom = e.windowHeight - e.safeArea.bottom
if (safeBottom > e.windowHeight) {
safeBottom = 34
}
app.globalData.safeBottom = safeBottom * (750 / e.windowWidth)
// 状态栏高度
app.globalData.StatusBar = e.statusBarHeight * (750 / e.windowWidth)
let statusBarHeight = app.globalData.CustomBar * (750 / e.windowWidth)
app.globalData.statusBarHeight = statusBarHeight
// fragmentHeight:指的是整个页面statusBarHeight以下的高度
app.globalData.fragmentHeight = windowHeight - statusBarHeight
app.globalData.safeFragmentHeight = windowHeight - statusBarHeight - app.globalData.safeBottom
app.globalData.windowWidth = e.windowWidth
this.data.inited = true
const fheght = (app.globalData.safeFragmentHeight + app.globalData.statusBarHeight) - 100
event.emit('InitMessage', {
what: 8,
desc: 'Logined'
})
this.setData({
fragment: fheght,
safeBottom: app.globalData.safeBottom
})
var authorization = app.globalData.token || storage.get('Authorization')
if (authorization) {
app.globalData.token = authorization
this.fetchUserInfo()
} else {
this.toIndex()
}
}
})
},
checkIos: function (e) {
if ('ios' === e.platform) {
return true
}
if (e.system.startsWith('iOS')) {
return true
this.data.inited = true
wx.showLoading({ title: '获取中', mask: true })
const fheght = (app.globalData.safeFragmentHeight + app.globalData.statusBarHeight) - 100
this.setData({ fragment: fheght, safeBottom: app.globalData.safeBottom })
var authorization = app.globalData.token || storage.get('Authorization')
if (authorization) {
app.globalData.token = authorization
this.fetchUserInfo()
} else {
this.toIndex()
} }
return false
}, },
fetchUserInfo: function () { fetchUserInfo: function () {
config.header = {
'Authorization': 'QNT ' + app.globalData.token
}
config.header = { 'Authorization': 'QNT ' + app.globalData.token }
getUserInfo().then(result => { getUserInfo().then(result => {
this.toIndex() this.toIndex()
}).catch(err => { }).catch(err => {
@ -147,15 +52,11 @@ Page({
defaultIndex: function () { defaultIndex: function () {
this.onResume() this.onResume()
if (this.data.path) { if (this.data.path) {
wx.navigateTo({
url: this.data.path
})
wx.navigateTo({ url: this.data.path })
} }
getPopupInfo().then(result => { getPopupInfo().then(result => {
if (result.data) { if (result.data) {
this.setData({
landInfo: result.data
})
this.setData({ landInfo: result.data })
} }
}) })
}, },
@ -169,15 +70,12 @@ Page({
zconfig.header = { 'Authorization': 'QNT ' + result.data.token } zconfig.header = { 'Authorization': 'QNT ' + result.data.token }
pconfig.header = { 'Authorization': 'QNT ' + result.data.token } pconfig.header = { 'Authorization': 'QNT ' + result.data.token }
mconfig.header = { 'Authorization': 'QNT ' + result.data.token } mconfig.header = { 'Authorization': 'QNT ' + result.data.token }
storage.put('isTokenHaveStatus', true)
// 登录流程完成;
if(!util.isEmpty(result.data.userToken)){
this.handleUserToken(result.data.userToken)
return
}
getBaseInfo().then(result => { getBaseInfo().then(result => {
app.globalData.userInfo = result.data app.globalData.userInfo = result.data
wx.hideLoading() wx.hideLoading()
if(app.globalData.userInfo.hasShowedLoginTag == false){
wx.navigateTo({ url: '/pages/home/tab1/index' })
}
this.defaultIndex() this.defaultIndex()
}).catch(err => { }).catch(err => {
wx.hideLoading() wx.hideLoading()
@ -188,36 +86,6 @@ Page({
this.defaultIndex() this.defaultIndex()
}) })
}, },
handleUserToken: function (userToken) {
sconfig.header = {
'user-token': userToken
}
getOrderExists().then(result => {
if (Number(result.data) != 1 || !app.evn) {
getBaseInfo().then(result => {
app.globalData.userInfo = result.data
wx.hideLoading()
this.defaultIndex()
}).catch(err => {
wx.hideLoading()
this.defaultIndex()
})
} else {
getBaseInfo().then(result => {
app.globalData.userInfo = result.data
wx.hideLoading()
wx.redirectTo({ url: '/pages/paper/index' })
}).catch(err => {
wx.hideLoading()
wx.redirectTo({ url: '/pages/paper/index' })
})
}
}).catch(err => {
wx.hideLoading()
util.showToast(err)
this.defaultIndex()
})
},
onResume: function () { onResume: function () {
var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value) var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value)
if (pageView && this.data.inited) { if (pageView && this.data.inited) {
@ -227,9 +95,7 @@ Page({
//事件处理函数 //事件处理函数
onNavChange: function (e) { onNavChange: function (e) {
// 处理用户的登录校验 // 处理用户的登录校验
this.setData({
pageIndex: Number(e.currentTarget.dataset.tab)
})
this.setData({ pageIndex: Number(e.currentTarget.dataset.tab) })
this.onResume() this.onResume()
}, },
/** /**
@ -239,33 +105,13 @@ Page({
if (this.data.inited) { if (this.data.inited) {
this.onResume() this.onResume()
} }
// wx.navigateTo({ url: '/pages/home/tab1/index' })
var a=storage.get('isTokenHaveStatus')
if(a==true && app.globalData.token){
getBaseInfo().then(result => {
this.setData({
hasShowedLoginTag: result.data.hasShowedLoginTag
})
if (this.data.hasShowedLoginTag == false) {
this.updateUserInfoFct({
hasShowedLoginTag: true
})
storage.put('isfirstlogin',true)
wx.navigateTo({
url: '/pages/home/tab1/index'
})
}
})
if(app.globalData.userInfo && app.globalData.userInfo.hasShowedLoginTag == false){
wx.navigateTo({ url: '/pages/home/tab1/index' })
} }
}, },
updateUserInfoFct: function (model) {
updateUserInfo(model).then(result => {})
},
onEvent: function (message) { onEvent: function (message) {
if(message.what == 250){ if(message.what == 250){
this.setData({ pageIndex: 0 }) this.setData({ pageIndex: 0 })
} else if(message.what == 884){
wx.navigateBack()
} }
}, },
stopTouchMove: function (e) { stopTouchMove: function (e) {
@ -273,15 +119,10 @@ Page({
}, },
// 弹出框的处理; // 弹出框的处理;
onClose: function () { onClose: function () {
this.setData({
visible: false,
landInfo: null
})
this.setData({ visible: false, landInfo: null })
}, },
onImageLoad: function () { onImageLoad: function () {
this.setData({
visible: true
})
this.setData({ visible: true })
}, },
onImageClick: function () { onImageClick: function () {
if (this.data.landInfo.redirectInfo.targetView == 'showH5') { if (this.data.landInfo.redirectInfo.targetView == 'showH5') {
@ -289,10 +130,7 @@ Page({
return return
} }
util.navigateTarget(this.data.landInfo.redirectInfo) util.navigateTarget(this.data.landInfo.redirectInfo)
this.setData({
visible: false,
landInfo: null
})
this.setData({ visible: false, landInfo: null })
}, },
toRule: function () { toRule: function () {
if (this.data.landInfo.ruleRedirectInfo.targetView == 'showH5') { if (this.data.landInfo.ruleRedirectInfo.targetView == 'showH5') {

55
pages/login/index.js

@ -21,10 +21,7 @@ import {
import { import {
mconfig mconfig
} from "../api/moment" } from "../api/moment"
import {
sconfig,
getOrderExists
} from "../api/saas"
import { sconfig } from "../api/saas"
const storage = require('../../utils/storage') const storage = require('../../utils/storage')
const util = require('../../utils/util') const util = require('../../utils/util')
const event = require('../../utils/event') const event = require('../../utils/event')
@ -63,9 +60,7 @@ Page({
wxLogin: function () { wxLogin: function () {
wx.login({ wx.login({
success: res => { success: res => {
wechatApplet({
authCode: res.code
}).then(result => {
wechatApplet({ authCode: res.code }).then(result => {
storage.put('tmpAuthToken', result.data.tmpAuthToken, 98) storage.put('tmpAuthToken', result.data.tmpAuthToken, 98)
storage.put('isTokenHaveStatus', true) storage.put('isTokenHaveStatus', true)
}) })
@ -128,52 +123,20 @@ Page({
}, },
handleUserToken: function (userToken) { handleUserToken: function (userToken) {
storage.put('userToken', userToken) storage.put('userToken', userToken)
sconfig.header = {
'user-token': userToken
}
getOrderExists().then(result => {
sconfig.header = { 'user-token': userToken }
getBaseInfo().then(result => {
app.globalData.userInfo = result.data
this.setData({ loging: false})
wx.hideLoading() wx.hideLoading()
if (Number(result.data) != 1 || !app.evn) {
getBaseInfo().then(result => {
app.globalData.userInfo = result.data
this.setData({ loging: false})
wx.hideLoading()
wx.navigateBack()
event.emit('EventMessage', { what: 888, desc: 'Logined' })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
app.globalData.token = null
storage.remove('Authorization')
config.header = null
this.setData({ loging: false})
})
} else {
getBaseInfo().then(result => {
app.globalData.userInfo = result.data
this.setData({ loging: false})
wx.hideLoading()
event.emit('EventMessage', { what: 884, desc: 'Logined' })
wx.redirectTo({ url: '/pages/paper/index' })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
app.globalData.token = null
storage.remove('Authorization')
config.header = null
this.setData({ loging: false})
})
}
wx.navigateBack()
event.emit('EventMessage', { what: 888, desc: 'Logined' })
}).catch(err => { }).catch(err => {
wx.hideLoading() wx.hideLoading()
util.showToast(err) util.showToast(err)
app.globalData.token = null app.globalData.token = null
storage.remove('Authorization') storage.remove('Authorization')
config.header = null config.header = null
this.setData({
loging: false
})
wx.navigateBack()
this.setData({ loging: false})
}) })
}, },
changePwd: function () { changePwd: function () {

21
pages/ztbvip/index.wxss

@ -1,14 +1,5 @@
/* pages/ztbvip/index.wxss */ /* pages/ztbvip/index.wxss */
.header-bg {
margin-top: 0px;
width: 100%;
height: 80px;
background: linear-gradient(314deg, rgba(50, 107, 250, 1) 0%, rgba(0, 138, 255, 1) 100%);
border-bottom-left-radius: 64rpx;
border-bottom-right-radius: 64rpx;
}
.header-box { .header-box {
width: 700rpx; width: 700rpx;
height: 335rpx; height: 335rpx;
@ -19,15 +10,7 @@
border-radius: 6px; */ border-radius: 6px; */
} }
.userinfo-avatar {
overflow: hidden;
width: 120rpx;
height: 120rpx;
border-radius: 12rpx;
border: 2px solid #fff;
box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2);
}
.account-bg { .account-bg {
background: linear-gradient(314deg, rgba(50, 107, 250, 1) 0%, rgba(0, 138, 255, 1) 100%); background: linear-gradient(314deg, rgba(50, 107, 250, 1) 0%, rgba(0, 138, 255, 1) 100%);
border-radius: 6px; border-radius: 6px;

Loading…
Cancel
Save