Commit a88b7965 authored by 石盼盼's avatar 石盼盼

Merge branch 'wuying' into 'master'

'登录注册页面,修改信息页面,js封装'

See merge request !1
parents c60950cc 649f632f
//app.js
App({ App({
onLaunch: function () { onLaunch: function () {
// 展示本地存储能力 this.isReload() // 小程序是否有新版本
var logs = wx.getStorageSync('logs') || [] this.getToken() // 获取token
logs.unshift(Date.now()) },
wx.setStorageSync('logs', logs) // 小程序是否有新版本
isReload: function () {
let that = this
if (wx.canIUse('getUpdateManager')) {
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
if (res.hasUpdate) {
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function (res) {
if (res.confirm) {
updateManager.applyUpdate()
}
}
})
})
updateManager.onUpdateFailed(function () {
wx.showModal({
title: '已经有新版本了哟~',
content: '新版本已经上线啦,请您删除当前小程序,重新搜索打开!'
})
})
}
})
} else {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试!'
})
}
},
// 登录 // 将token从缓存中 赋值到全局变量
getToken: function () {
try {
var token = wx.getStorageSync('token')
if (token) {
this.globalData.token = token
}
} catch (e) { }
},
// 获取sessionkey 提交后台换取基本openid unionid
getSessionKey: function (cb) {
let that = this
wx.login({ wx.login({
success: res => { success: function (res) {
// 发送 res.code 到后台换取 openId, sessionKey, unionId that.codeChangeToken(res.code, cb)
} }
}) })
// 获取用户信息 },
wx.getSetting({ // sessionkey 换取token
success: res => { codeChangeToken(code, cb) {
if (res.authSetting['scope.userInfo']) { // 发起网络请求
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 let that = this
wx.getUserInfo({ wx.request({
success: res => { url: 'https://openapi.xueyoubangedu.com/request/allrequest',
// 可以将 res 发送给后台解码出 unionId data: {
this.globalData.userInfo = res.userInfo url: 'https://wandoutiyu.test.xueyoubangedu.com/api/getsessionkey',
code: code
},
method: 'GET',
success: function (res) {
if (res.data.meta.code === 200) {
try {
wx.setStorageSync('token', res.data.data.token)
} catch (e) {
console.log('token缓存失败')
}
that.globalData.token = res.data.data.token
typeof cb == 'function' && cb()
} else {
console.log(res)
}
}
})
},
// 保存用户信息
saveUserInfo: function (info, cb) {
let that = this
wx.checkSession({
success() {
wx.request({
url: 'https://wandoutiyu.test.xueyoubangedu.com/api/saveinfo',
data: {
encryptedData: encodeURIComponent(info.encryptedData),
iv: encodeURIComponent(info.iv),
token: wx.getStorageSync('token'),
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 },
// 所以此处加入 callback 以防止这种情况 method: 'POST',
if (this.userInfoReadyCallback) { success: function (res) {
this.userInfoReadyCallback(res) if (res.data.meta.code == 200) {
} wx.showToast({
title: '已授权',
icon: 'none',
duration: 1000
})
that.globalData.userInfo = res.data.data;
wx.setStorageSync('userInfo', res.data.data)
} else {
wx.showToast({
title: res.data.meta.message,
icon: 'none',
duration: 1000
})
} }
}) typeof cb == 'function' && cb()
} },
fail: function () { }
})
},
fail() {
// session_key 已经失效,需要重新执行登录流程
that.getSessionKey(() => that.saveUserInfo(info, cb))
} }
}) })
}, },
globalData: { globalData: {
userInfo: null extAppid: 'wx6e6eaca9cc1c406d', // 当前appid
userInfo: '', //微信user信息
userTel: '', // 手机号
token: '',
backurl: '' // 全局跳转页面路径
} }
}) })
\ No newline at end of file
...@@ -11,7 +11,10 @@ ...@@ -11,7 +11,10 @@
"pages/index/classDetail/classDetail", "pages/index/classDetail/classDetail",
"pages/index/performance/performance", "pages/index/performance/performance",
"pages/index/evaluation/evaluation", "pages/index/evaluation/evaluation",
"pages/team/teamDetail/teamDetail" "pages/team/teamDetail/teamDetail",
"pages/sign/login/login",
"pages/sign/bindTel/bindTel"
], ],
"tabBar":{ "tabBar":{
"custom":false, "custom":false,
......
const app = getApp()
import { Base } from '../../../utils/base.js';
const base = new Base()
Page({
data: {
telphone: ''
},
onLoad: function (options) {
},
getPhoneNumber: function (e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') {
let params = {
url: 'user/switchPhone',
data: {
encryptedData: e.detail.encryptedData,
iv: e.detail.iv
},
type: "POST",
callback: (data) => {
base.toast('授权成功')
app.globalData.userTel = data.phoneNumber
wx.setStorageSync('userTel', data.phoneNumber)
if(app.globalData.backurl) {
if (app.globalData.backurl.indexOf('/pages/tabbar') != -1) {
wx.switchTab({
url: app.globalData.backurl,
})
} else {
wx.redirectTo({
url: app.globalData.backurl
})
}
} else {
wx.switchTab({
url: '/pages/personal/personal',
})
}
},
}
base.newRequest(params)
} else {
base.toast('授权失败,无法查看')
}
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<view class="loginBox">
<view class="logo-view">
<image src="/images/my/login.png"></image>
</view>
<view class="title">豌豆队长</view>
<view class="desc">为保护您的账号资产,我们需要您的手机号授权, 以同步支付的商品信息。</view>
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">同意授权</button>
</view>
\ No newline at end of file
.loginBox {
padding-top: 174rpx;
}
.logo-view {
margin: 0 auto 40rpx auto;
}
.logo-view image {
display: block;
margin: 0 auto;
width: 216rpx;
height: 216rpx;
}
.loginBox .title {
font-weight: bold;
text-align: center;
font-size: 38rpx;
font-weight: bold;
color: #000000;
}
.desc {
width: 540rpx;
margin: 30rpx auto 85rpx auto;
font-size: 24rpx;
color: #999;
text-align: center;
line-height: 2;
}
.loginBox button {
align-items: center;
justify-content: center;
width: 620rpx !important;
height: 82rpx !important;
background: linear-gradient(-70deg, #FFC600 0%, #FFD400 100%);
color: #000000;
border-radius: 41rpx;
margin: 0 auto;
padding: 0 !important;
font-size: 30rpx;
border: none;
outline: none;
}
const app = getApp()
import {
Base
} from '../../../utils/base.js';
const base = new Base()
Page({
/**
* 页面的初始数据
*/
data: {
// telphone: '',
name: '',
headImg: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getInfo()
},
getInfo() {
let params = {
url: 'user/getChildInfo',
type: 'POST',
callback: (data) => {
this.setData({
// telphone: data.tel,
name: data.nickname,
headImg: data.avatarurl
})
}
}
base.newRequest(params)
},
// changeTel(e) {
// this.setData({
// telphone: e.detail.value
// })
// },
changeName(e) {
this.setData({
name: e.detail.value
})
},
changeImg() {
base.initQiniu();
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: (res)=> {
var tempFilePaths = res.tempFilePaths
qiniuUploader.upload(0, tempFilePaths,(res)=>{
this.setData({
headImg: res[0].imageURL
})
})
},
fail() {
base.toast('上传失败,请重试')
}
})
},
saveInfo() {
// const reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
// else if(this.data.telphone == '') {
// base.toast('请输入手机号')
// return
// } else if (!reg.test(this.data.telphone)) {
// base.toast('手机号格式不正确')
// return
// }
if (this.data.name == '') {
base.toast('请输入姓名')
return
} else if (this.data.headImg == '') {
base.toast('请选择头像')
return
}
let params = {
url: '',
data: {
},
callback:(data)=>{
base.toast('修改信息成功')
base.goBack(2)
}
}
base.newRequest(params)
}
})
\ No newline at end of file
{
"usingComponents": {},
"navigationBarTitleText": "账户信息"
}
\ No newline at end of file
<view class="info">
<!-- <view class="onerow flex-h flex-vc flex-hb">
<text>手机号码</text>
<view>
<input type="number" max-length='11' value="{{telphone}}" bindinput="changeTel"/>
</view>
</view> -->
<view class="onerow flex-h flex-vc flex-hb">
<text>账户昵称</text>
<view>
<input type="text" value="{{name}}" bindinput="changeName" />
</view>
</view>
<view class="onerow flex-h flex-vc flex-hb">
<text>账户头像</text>
<view class="flex-h" catchtap="changeImg">
<image src="{{headImg}}"></image>
</view>
</view>
<view class="save" catchtap="saveInfo">保存</view>
</view>
\ No newline at end of file
.info {
padding: 40rpx 30rpx;
}
.onerow {
height: 119rpx;
line-height: 119rpx;
border-bottom: 1px solid #EBEBEB;
font-size: 30rpx;
color: #1A1A1A;
}
.onerow view{
width: 500rpx;
justify-content: flex-end;
}
.onerow view input {
text-align: right;
width: 100%;
line-height: 119rpx;
}
.onerow view image{
width: 94rpx;
height: 94rpx;
border-radius: 50%;
}
.save {
width: 690rpx;
height: 80rpx;
background: linear-gradient(-70deg, #FFC600 0%, #FFD400 100%);
border-radius: 40rpx;
text-align: center;
line-height: 80rpx;
font-size: 30rpx;
color: #000000;
position: fixed;
bottom: 50rpx;
left: 30rpx;
right: 30rpx;
}
\ No newline at end of file
const app = getApp()
import {
Base
} from '../../../utils/base.js';
const base = new Base()
Page({
data: {
die: false,
isBindTel: false
},
onLoad: function (options) {
// this.checkPhone()
},
checkPhone() {
let params = {
// url: 'xcx/v2.0/checkphone',
data: {},
callback: (data) => {
wx.setStorageSync('userTel', data.tel)
this.setData({
isBindTel: true
})
},
errorback: (res) => {
base.toast('')
this.setData({
isBindTel: false
})
}
}
base.newRequest(params)
},
userInfoHandler: function (e) {
if (e.detail.errMsg == 'getUserInfo:ok') {
app.saveUserInfo(e.detail, this.showUserInfo)
} else {
base.toast('请先授权,才能验证身份')
}
},
showUserInfo: function () {
if (this.data.isBindTel) {
base.toast('登录成功')
setTimeout(() => {
if (app.globalData.backurl) {
if (app.globalData.backurl.indexOf('/pages/tabbar') != -1) {
wx.switchTab({
url: app.globalData.backurl,
})
} else {
wx.redirectTo({
url: app.globalData.backurl
})
}
} else {
wx.switchTab({
url: '/pages/tabbar/personal/personal',
})
}
}, 800)
} else {
wx.navigateTo({
url: '../bindTel/bindTel',
})
}
},
checkVisions: function () {
if (wx.canIUse !== undefined && wx.canIUse('button.open-type.getUserInfo')) {
this.setData({
die: false
})
} else {
this.setData({
die: true
})
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法更好体验该功能,请先升级微信到最新版',
showCancel: true
})
}
},
})
\ No newline at end of file
{
"usingComponents": {},
"navigationBarTitleText": "登录"
}
\ No newline at end of file
<view class="loginBox">
<view class="logo-view">
<image src="/images/my/login.png"></image>
</view>
<view class="title">豌豆队长</view>
<button class="flex-h flex-vc flex-hc" open-type="getUserInfo" bindgetuserinfo="userInfoHandler" catchtap="checkVisions">
<image src="/images/my/wx.png"></image>
微信一键注册/登录
</button>
<view class="desc">请登录查看更多内容</view>
</view>
\ No newline at end of file
.loginBox {
padding-top: 174rpx;
}
.logo-view image {
display: block;
margin: 0 auto 41rpx auto;
width: 216rpx;
height: 216rpx;
}
.loginBox .title {
color: #333;
font-weight: bold;
text-align: center;
font-size: 36rpx;
font-weight: bold;
color: #000000;
}
.loginBox button {
width: 620rpx !important;
height: 82rpx !important;
background: linear-gradient(-70deg, #FFC600 0%, #FFD400 100%);
color: #000000;
border-radius: 41rpx;
margin: 184rpx auto 30rpx auto;
font-size: 30rpx;
border: none;
outline: none;
}
.loginBox button image {
width: 45rpx;
height: 36rpx;
margin-right: 14rpx;
}
.desc {
font-size: 24rpx;
color: #999999;
text-align: center;
}
\ No newline at end of file
// pages/class/class.js const app = getApp()
import {
Base
} from '../../../utils/base.js';
const base = new Base()
Page({ Page({
/** /**
...@@ -6,74 +10,46 @@ Page({ ...@@ -6,74 +10,46 @@ Page({
*/ */
data: { data: {
activeIndex: 1, activeIndex: 1,
list: [],
hasMore: true,
page: 1
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.getList()
},
getList(){
let params = {
url: '',
data: {
},
callback:(data)=>{
}
}
base.newRequest(params)
}, },
changeTab(e) { changeTab(e) {
let index = e.currentTarget.dataset.index let index = e.currentTarget.dataset.index
if (this.data.activeIndex != index) { if (this.data.activeIndex != index) {
this.setData({ this.setData({
activeIndex: index activeIndex: index
}) })
} }
}, },
goteamDetail:function(){ goteamDetail: function () {
wx.navigateTo({ wx.navigateTo({
url: '../../team/teamDetail/teamDetail', url: '../../team/teamDetail/teamDetail',
}) })
}, },
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () { onPullDownRefresh: function () {
}, },
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () { onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
} }
}) })
\ No newline at end of file
...@@ -32,9 +32,11 @@ ...@@ -32,9 +32,11 @@
<view class="top"> <view class="top">
<view class="time_title">轮滑课</view> <view class="time_title">轮滑课</view>
<view class="over">已结束</view> <view class="over">已结束</view>
</view> </view>
<view class="time">上课时间:2020-10-21 09:00-10:00 </view> <view class="time">上课时间:2020-10-21 09:00-10:00 </view>
<view class="place">上课地点:新天际众美幼稚园</view> <view class="place">上课地点:新天际众美幼稚园</view>
<view class="manage" catchtap="goclassManagement">查看详情</view>
</view> </view>
</view> </view>
</view> </view>
......
...@@ -5,8 +5,30 @@ Page({ ...@@ -5,8 +5,30 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
showUserInfo: true, //用户信息是否显示
noticeCount: 9, // 家长回复小红点
show:false, show:false,
emailShow: false, emailShow: false,
subjectList:[
{
name: '跳绳'
},
{
name: '篮球'
},
{
name: '足球'
},
{
name: '轮滑'
},
{
name: '平衡车'
},
{
name: '跆拳道'
},
]
}, },
...@@ -14,6 +36,30 @@ Page({ ...@@ -14,6 +36,30 @@ Page({
onLoad: function (options) { onLoad: function (options) {
},
onShow() {
let userInfo = wx.getStorageSync('userInfo');
let userTel = wx.getStorageSync('userTel')
if (userInfo && userTel) {
this.setData({
showUserInfo: true
})
this.getChildInf();
} else {
this.setData({
showUserInfo: false
})
}
},
goLogin() {
wx.navigateTo({ // 登录
url: '/pages/sign/login/login',
})
},
goUserInfo() { // 账户信息修改
wx.navigateTo({
url: '/pages/sign/info/info',
})
}, },
goparents:function(){ goparents:function(){
wx.navigateTo({ wx.navigateTo({
...@@ -31,6 +77,31 @@ Page({ ...@@ -31,6 +77,31 @@ Page({
emailShow: !this.data.emailShow emailShow: !this.data.emailShow
}) })
}, },
chooseOne(e) {
let index = e.currentTarget.dataset.index
let list = this.data.subjectList
if (list[index].isChecked){
list[index].isChecked = false
} else {
list[index].isChecked = true
}
this.setData({
subjectList: list
})
},
confirm(){
var arr = []
for (var i=0; i<this.data.subjectList.length;i++) {
if (this.data.subjectList[i].isChecked == true) {
arr.push(this.data.subjectList[i])
}
}
if (arr.length == 0) {
base.toast('教学科目至少选择一项')
} else {
console.log(arr)
}
},
goCall: function(e){ goCall: function(e){
wx.showModal({ wx.showModal({
content: '确定要拨打电话吗?', content: '确定要拨打电话吗?',
...@@ -42,54 +113,5 @@ Page({ ...@@ -42,54 +113,5 @@ Page({
} }
} }
}) })
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
} }
}) })
\ No newline at end of file
<view class="personInf"> <view class="personInf">
<view class="head flex-h flex-vc flex-hb"> <view class="head flex-h flex-vc flex-hb" wx:if='{{showUserInfo}}' catchtap="goUserInfo">
<view class="headLeft flex-h flex-vc"> <view class="headLeft flex-h flex-vc">
<image src="../../../images/course_login.png"></image> <image src="../../../images/course_login.png"></image>
<view> <view>
<view class="name">王教练</view> <view class="name">王教练</view>
<view class="tel">183****6092</view> <view class="tel">183****6092</view>
</view> </view>
</view> </view>
<text class="iconfont icongengduo"></text> <text class="iconfont icongengduo"></text>
</view> </view>
<view wx:else class="head flex-h flex-vc flex-hb">
<view class="headLeft flex-v">
<view class='head_title'>欢迎来到豌豆成长</view>
<view class="login" catchtap="goLogin">立即登录</view>
</view>
</view>
</view> </view>
<view class="centerNav"> <view class="centerNav">
<view class="every flex-h flex-vc flex-hb" catchtap="goparents"> <view class="every flex-h flex-vc flex-hb" catchtap="goparents">
<view class="row title"> <view class="flex-vc flex-h title">
<image src="../../../images/personal_icon_01.png"></image> <image src="/images/my/per_icon_01.png"></image>
<view>家长回复</view> <view>家长回复</view>
</view> </view>
<!-- <text class="iconfont icongengduo"></text> --> <view class="flex-vc flex-h unreadBox">
<view class="row unreadBox"> <view class="unread" wx:if="{{ noticeCount > 0 }}"></view>
<view class="unread" wx:if="{{ noticeCount > 0 }}">{{noticeCount}}</view> <text class="iconfont icongengduo"></text>
<text class="iconfont icongengduo"></text> </view>
</view> </view>
</view>
</view> </view>
<view class="centerNav"> <view class="centerNav">
<view class="every flex-h flex-vc flex-hb" catchtap="goteachingArea"> <view class="every flex-h flex-vc flex-hb" catchtap="goteachingArea">
<view class="row title"> <view class="row title">
<image src="../../../images/personal_icon_05.png"></image> <image src="../../../images/personal_icon_05.png"></image>
<view>教学区域</view> <view>教学区域</view>
</view>
<text class="iconfont icongengduo"></text>
</view>
<view class="every flex-h flex-vc flex-hb" catchtap="tcHold">
<view class="row title">
<image src="../../../images/personal_icon_02.png"></image>
<view>教学科目</view>
</view>
<view class="row">
<text class="num">5</text>
<text class="iconfont icongengduo"></text>
</view>
</view>
<van-popup show="{{ emailShow }}" closeable round bind:close="tcHold">
<view class="tc">
<view class="top">
<view class="til">请选择教学科目</view>
<view class="select">(可多选)</view>
</view>
<view class="subject flex-h flex-hw flex-ha">
<view class="active">跳绳</view>
<view>篮球</view>
<view>足球</view>
<view>轮滑</view>
<view>平衡车</view>
<view>跆拳道</view>
</view>
<view class="confirm" catchtap="confirm">确定</view>
</view> </view>
</van-popup> <text class="iconfont icongengduo"></text>
</view>
<view class="every flex-h flex-vc flex-hb" catchtap="tcHold">
<view class="row title">
<image src="../../../images/personal_icon_02.png"></image>
<view>教学科目</view>
</view>
<view class="row">
<text class="num">5</text>
<text class="iconfont icongengduo"></text>
</view>
</view>
</view> </view>
<view class="centerNav"> <view class="centerNav">
<view class="every flex-h flex-vc flex-hb" catchtap="goCall"> <view class="every flex-h flex-vc flex-hb" catchtap="goCall">
<view class="row title"> <view class="row title">
<image src="../../../images/personal_icon_02.png"></image> <image src="/images/my/per_icon_03.png"></image>
<view>联系客服</view> <view>联系客服</view>
</view> </view>
<text class="iconfont icongengduo"></text> <text class="iconfont icongengduo"></text>
</view> </view>
</view> </view>
\ No newline at end of file
<van-popup show="{{ emailShow }}" closeable round bind:close="tcHold">
<view class="tc">
<view class="top">
<view class="til">请选择教学科目</view>
<view class="select">(可多选)</view>
</view>
<view class="subject flex-h flex-hw flex-ha">
<block wx:for='{{subjectList}}' wx:key='index'>
<view class="{{item.isChecked ? 'active' : ''}}" catchtap="chooseOne" data-index='{{index}}'>{{item.name}}</view>
</block>
</view>
<view class="confirm" catchtap="confirm">确定</view>
</view>
</van-popup>
\ No newline at end of file
...@@ -39,10 +39,24 @@ page { ...@@ -39,10 +39,24 @@ page {
font-weight: bold; font-weight: bold;
color: #000000; color: #000000;
} }
.head_title {
font-size: 42rpx;
font-weight: bold;
color: #000000;
margin-bottom: 25rpx;
}
.login {
width: 182rpx;
height: 58rpx;
background: #FFFFFF;
border-radius: 29rpx;
text-align: center;
line-height: 58rpx;
font-size: 32rpx;
color: #1A1A1A;
}
.centerNav { .centerNav {
padding: 0 30rpx; padding: 0 30rpx;
position: relative;
background: #fff; background: #fff;
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
...@@ -54,7 +68,6 @@ page { ...@@ -54,7 +68,6 @@ page {
font-size: 30rpx; font-size: 30rpx;
color: #1A1A1A; color: #1A1A1A;
} }
.centerNav .every:last-child { .centerNav .every:last-child {
border-bottom: none; border-bottom: none;
} }
...@@ -80,10 +93,13 @@ page { ...@@ -80,10 +93,13 @@ page {
height: 40rpx; height: 40rpx;
margin-right: 28rpx; margin-right: 28rpx;
} }
.unread {
.centerNav .every .unreadBox { width: 16rpx;
align-items: center; height: 16rpx;
background: #FF0000;
border-radius: 50%;
} }
.centerNav .every .num{ .centerNav .every .num{
color: #B3B3B3; color: #B3B3B3;
font-size: 30rpx; font-size: 30rpx;
...@@ -93,41 +109,38 @@ page { ...@@ -93,41 +109,38 @@ page {
/* 教学科目弹窗样式 */ /* 教学科目弹窗样式 */
.tc{ .tc{
width: 580rpx; width: 580rpx;
height: 500rpx;
background-color: #FFFFFF; background-color: #FFFFFF;
border-radius: 10rpx; border-radius: 10rpx;
padding: 51rpx 0;
} }
.tc .top{ .top .til{
width: 100%;
height: 232rpx;
color: #333333;
font-size: 28rpx;
text-align: center; text-align: center;
padding-top: 15rpx; font-size: 32rpx;
}
.tc .top .til{
color: #03081A;
font-size: 34rpx;
font-weight: bold; font-weight: bold;
color: #1A1A1A;
margin-top: 56rpx; margin-top: 56rpx;
margin-bottom: 22rpx; margin-bottom: 22rpx;
} }
.tc .top .select{ .top .select{
text-align: center;
color: #A6A6A6; color: #A6A6A6;
font-size: 24rpx; font-size: 24rpx;
} }
.tc .subject>view{ .subject {
margin-top: 60rpx;
}
.subject>view{
width: 156rpx; width: 156rpx;
height: 56rpx; height: 56rpx;
text-align: center;
line-height: 56rpx;
background: #FFFFFF; background: #FFFFFF;
border: 1px solid #B4BC4D; border: 1px solid #B4BC4D;
border-radius: 28px; border-radius: 28px;
color: #B4BC4D; color: #B4BC4D;
text-align: center;
line-height: 56rpx;
margin-bottom: 20rpx; margin-bottom: 20rpx;
} }
.tc .subject>view.active{ .subject>view.active{
background: linear-gradient(13deg, #AAB247 0%, #B4BC4D 100%); background: linear-gradient(13deg, #AAB247 0%, #B4BC4D 100%);
color: #FFFFFF; color: #FFFFFF;
} }
...@@ -140,7 +153,7 @@ page { ...@@ -140,7 +153,7 @@ page {
font-size: 28rpx; font-size: 28rpx;
line-height: 68rpx; line-height: 68rpx;
text-align: center; text-align: center;
margin: 30rpx auto 20rpx; margin: 30rpx auto 0;
} }
...@@ -139,6 +139,13 @@ ...@@ -139,6 +139,13 @@
"id": -1, "id": -1,
"name": "pages/index/evaluation/evaluation", "name": "pages/index/evaluation/evaluation",
"pathName": "pages/index/evaluation/evaluation", "pathName": "pages/index/evaluation/evaluation",
"query": "",
"scene": null
},
{
"id": -1,
"name": "个人中心",
"pathName": "pages/tabbar/personal/personal",
"scene": null "scene": null
} }
] ]
......
// 公共函数库
const app = getApp()
class Base {
constructor() {
// this.baseUrl = 'https://wandoutiyu.xueyoubangedu.com/api/' //线上接口
this.baseUrl = 'https://wandoutiyu.test.xueyoubangedu.com/api/' //测试接口
}
newRequest(params, flag = false, tips = true) {
let that = this
if (!params.type) {
params.type = 'GET'
}
var cur_url = that.baseUrl + params.url
// if (flag) {
// params.url = params.url;
// } else {
// params.url = that.baseUrl + params.url;
// }
wx.request({
url: cur_url,
data: params.data,
method: params.type,
header: {
'token': wx.getStorageSync('token')
},
success: function (res) {
console.log(res)
params.ischeckedCallback && params.ischeckedCallback() //防止用户多次点击,请求完成后让用户可点
if (wx.showLoading()) {
wx.hideLoading() //隐藏加载动画
}
if (res.statusCode == 200) {
let rstcode = res.data.meta.code.toString() //接口返回的错误码
if (rstcode == '200') {
params.callback && params.callback(res.data.data)
} else if (rstcode == '400') {
if (!flag) { // 400 token过期
app.getSessionKey(function () {
that.newRequest(params, true)
})
}
} else if (rstcode == '404') {
wx.showModal({
title: '错误',
content: '网络请求失败'
})
} else {
params.confirmback && params.confirmback(res) // 错误回调
if (tips) {
wx.showToast({
title: res.data.meta.msg,
icon: 'none',
duration: 2000
})
}
}
} else {
wx.showModal({
title: '错误',
content: '网络请求失败'
})
}
}
})
}
//富文本
richText(detail) {
if (detail != '' && detail != null && detail != undefined) {
var newDetail = '';
newDetail = detail.replace(/\<[\/]?(section)/g, function (m, m1) {
return m.replace('section', 'div')
});
newDetail = newDetail.replace(/\<[\/]?(ruby)/g, function (m, m1) {
return m.replace('ruby', 'span')
});
newDetail = newDetail.replace(/\<[\/]?(rt)/g, function (m, m1) {
return m.replace('rt', 'span')
});
newDetail = newDetail.replace(/\<[\/]?(rp)/g, function (m, m1) {
return m.replace('rp', 'span')
});
newDetail = newDetail.replace(/\<[\/]?(video)/g, function (m, m1) {
return m.replace('video', 'video')
});
newDetail = newDetail.replace(/(\<img)/g, '$1 class="hellorich"');
newDetail = newDetail.replace(/(\<div)/g, '$1 class="hellorich"');
newDetail = newDetail.replace(/(\<p)/g, '$1 class="hellorich"');
newDetail = newDetail.replace(/(\<video)/g, '$1 class="helloVideo"');
return newDetail;
} else {
return ''
}
}
trimStrSpace(str) {
return str.replace(/(^\s*)|(\s*$)/g, '')
}
/**
* 提示框
* icon [success,loading,none]
*/
toast(
title,
icon = 'none',
duration = 2000,
mask = true,
callback
) {
wx.showToast({
title: title,
icon: icon,
duration: duration,
mask: mask,
success: function () {
callback && callback()
}
})
}
goBack(num) {
var pages = getCurrentPages()
var prevPage = pages[pages.length - parseInt(num)]
prevPage.setData({
isrefresh: true
})
setTimeout(function () {
wx.navigateBack({
delta: parseInt(num-1)
})
}, 800)
}
//七牛上传
initQiniu() {
var options = {
uptokenURL: 'https://fenghexm.xueyoubangedu.com/api/v1.0/upload/token',
domain: 'https://fhxm.xueyoubangedu.com/',
uploadURL: 'https://up-z1.qiniup.com'
};
qiniuUploader.init(options);
}
}
export {
Base
}
\ No newline at end of file
// created by gpake
(function() {
var imgTempUrl = [] //上传图片后临时存放容器
var config = {
qiniuUploadURL: '',
qiniuImageURLPrefix: '',
qiniuUploadToken: '',
qiniuUploadTokenURL: '',
qiniuUploadTokenFunction: null
}
module.exports = {
init: init,
upload: upload,
}
// 在整个程序生命周期中,只需要 init 一次即可
// 如果需要变更参数,再调用 init 即可
function init(options) {
config = {
qiniuUploadURL: '',
qiniuImageURLPrefix: '',
qiniuUploadToken: '',
qiniuUploadTokenURL: '',
qiniuUploadTokenFunction: null
};
updateConfigWithOptions(options);
}
function updateConfigWithOptions(options) {
if (options.uploadURL) {
config.qiniuUploadURL = options.uploadURL;
} else {
console.error('qiniu uploader need uploadURL');
}
if (options.uptoken) {
config.qiniuUploadToken = options.uptoken;
} else if (options.uptokenURL) {
config.qiniuUploadTokenURL = options.uptokenURL;
} else if (options.uptokenFunc) {
config.qiniuUploadTokenFunction = options.uptokenFunc;
}
if (options.domain) {
config.qiniuImageURLPrefix = options.domain;
}
}
function upload(i = 0,filePath, success, fail, options) {
if (null == filePath) {
console.error('qiniu uploader need filePath to upload');
return;
}
if (options) {
init(options);
}
if (config.qiniuUploadToken) {
doUpload(i= 0,filePath, success, fail, options);
} else if (config.qiniuUploadTokenURL) {
getQiniuToken(function() {
upload(i = 0,filePath, success, fail, options);
});
} else if (config.qiniuUploadTokenFunction) {
config.qiniuUploadToken = config.qiniuUploadTokenFunction();
} else {
console.error('qiniu uploader need one of [uptoken, uptokenURL, uptokenFunc]');
return;
}
}
function doUpload(i= 0,filePath, success, fail, options) {
var url = config.qiniuUploadURL;
var fileName = filePath[i].split('//')[1];
if (options && options.key) {
fileName = options.key;
}
var formData = {
'token': config.qiniuUploadToken,
'key': fileName
};
wx.uploadFile({
url: url,
filePath: filePath[i],
name: 'file',
formData: formData,
success: function(res) {
wx.hideLoading();
var dataString = res.data
var dataObject = JSON.parse(dataString);
var imageUrl = config.qiniuImageURLPrefix + dataObject.key;
dataObject.imageURL = imageUrl;
imgTempUrl.push(dataObject)
if (i + 1 < filePath.length) {
doUpload(i + 1, filePath, success)
} else {
wx.hideLoading()
success(imgTempUrl)
imgTempUrl = []
}
},
fail: function(error) {
wx.hideLoading();
fail(error);
}
}).onProgressUpdate(res => {
var progress = '上传中(' + (i + 1) + '/' + filePath.length + ')'
wx.showLoading({
title: progress
})
})
}
function getQiniuToken(callback) {
wx.request({
url: config.qiniuUploadTokenURL,
success: function(res) {
var token = res.data.data.uptoken;
config.qiniuUploadToken = token;
if (callback) {
callback();
}
},
fail: function(error) {
console.log(error);
}
})
}
})();
\ No newline at end of file
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 to comment