提交 ecd9395a authored 作者: 王鹏飞's avatar 王鹏飞

merge...

*.swp *.swp
.DS_Store
config.js
node_modules node_modules
npm-debug.log npm-debug.log
.idea/ .idea/
.DS_Store
*/.DS_Store
\ No newline at end of file
import httpRequest from '../utils/request.js'
import { appVersion } from '../config.js'
// 获取页面展示状态
export function getPageShowStatus() {
return httpRequest.get(`https://node-server.ezijing.com/get/wx-chart/${appVersion}`)
}
// 获取用户信息
export function getUser() {
return httpRequest.get('/api/lms/user/getinfo')
}
// 退出登录
export function logout() {
return httpRequest.get('/api/passport/rest/logout')
}
...@@ -101,7 +101,7 @@ const getCurrentChapterDetail = (vid, videoType,callback) => { ...@@ -101,7 +101,7 @@ const getCurrentChapterDetail = (vid, videoType,callback) => {
callback: function (res) { callback: function (res) {
let json = { let json = {
video: { video: {
src: videoType == 3 ? res.data.video &&res.data.video.LD : res.data.video[0] && res.data.video[0].playurl, src: videoType == 3 ? res.data.video &&res.data.video.SD : res.data.video[0] && res.data.video[0].playurl,
spareSrc: '' // 正式环境时,需要将 contentVideo 中 spareSrc 改成 src spareSrc: '' // 正式环境时,需要将 contentVideo 中 spareSrc 改成 src
}, },
audio: { audio: {
...@@ -148,7 +148,8 @@ const updateProgress = (obj) => { ...@@ -148,7 +148,8 @@ const updateProgress = (obj) => {
v: obj.vid, v: obj.vid,
_p: obj.pt, // 累计时间 _p: obj.pt, // 累计时间
_m: obj.mpt, // 当前播放最大时间 _m: obj.mpt, // 当前播放最大时间
_c: obj.cpt // 当前播放位置 _c: obj.cpt, // 当前播放位置
ps: obj.ps // 时间点
}, },
callback: function (res) {} callback: function (res) {}
}) })
......
//app.js import * as api from './api/base.js'
App({ App({
onLaunch: function () { store: {
wx.showLoading({ title: '页面启动中...', mask: true }); user: {} // 用户信息
// wx.redirectTo({ url: '/pages/index/index' }); },
onLaunch: function () {},
checkPageshow(callback) {
if (this.store.pageshow) {
callback && callback(true)
return true
}
wx.showNavigationBarLoading()
api.getPageShowStatus().then(response => {
const show = response.code === 1
this.store.pageshow = show
callback && callback(show, response)
wx.hideNavigationBarLoading()
})
},
// 获取用户信息
getUser() {
return api.getUser().then(response => {
this.store.user = response
wx.setStorage({ key: 'uid', data: response.id })
wx.setStorage({ key: 'sid', data: response.student_info.id })
return response
})
},
// 退出登录
logout() {
return api.logout().then(response => {
wx.removeStorageSync('token')
})
} }
}) })
\ No newline at end of file
{ {
"pages": [ "pages": [
"pages/index/index", "pages/login/index",
"pages/login/account",
"pages/login/phone",
"pages/login/password",
"pages/outSite/outSite", "pages/outSite/outSite",
"pages/videoPlayer/show", "pages/videoPlayer/show",
"pages/learnSystem/home/home", "pages/learnSystem/home/home",
...@@ -48,5 +51,9 @@ ...@@ -48,5 +51,9 @@
} }
] ]
}, },
"sitemapLocation": "sitemap.json" "sitemapLocation": "sitemap.json",
} "usingComponents": {
\ No newline at end of file "dialog": "./components/dialog",
"main-page": "./components/main"
}
}
/**app.wxss**/ page {
--main-color: '#f00';
--main-bg-color: '#000';
}
// components/dialog/index.js
Component({
/**
* 组件的属性列表
*/
properties: {
title: { type: String },
show: { type: Boolean, value: false }
},
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
close() {
this.setData({ show: !this.data.show })
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view class="dialog" wx:if="{{ show }}">
<view class="dialog-cover" catchtap="close"></view>
<view class="dialog-main" catchtap="{{ return }}">
<view class="dialog-hd">
<view class="dialog-hd__title">{{ title }}</view>
<image src="../../assets/images/user-close.png" class="dialog-hd__close" bindtap="close"></image>
</view>
<view class="dialog-bd">
<slot></slot>
</view>
</view>
</view>
.dialog {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1000;
}
.dialog-cover {
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
}
.dialog-main {
position: absolute;
left: 50%;
top: 20%;
padding: 40rpx;
width: 600rpx;
margin: 0 auto;
background: #fafafc;
border-radius: 10rpx;
font-size: 28rpx;
transform: translate(-50%, 0);
}
.dialog-hd {
display: flex;
justify-content: space-between;
align-items: center;
}
.dialog-hd__close {
width: 46rpx;
height: 46rpx;
}
const app = getApp()
Component({
/**
* 组件的属性列表
*/
properties: {},
/**
* 组件的初始数据
*/
data: {
show: false,
loaded: false
},
lifetimes: {
attached() {
app.checkPageshow(show => {
this.setData({ show, loaded: true })
})
}
},
/**
* 组件的方法列表
*/
methods: {}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view class="main-page" wx:if="{{ loaded }}">
<view wx:if="{{ show }}">
<slot></slot>
</view>
<web-view
src="https://pages.ezijing.com/gothroughedu/web/edu/index.html"
wx:else
></web-view>
</view>
/* components/page/index.wxss */
\ No newline at end of file
// const env = 'dev'
const env = 'production'
if (env === 'production') {
module.exports = {
appVersion: 'classes_v3.2.0',
apiBaseURL: 'https://wechat-api.ezijing.com', // 接口请求地址
tenant: 'classes'
}
} else {
module.exports = {
appVersion: 'classes_v3.2.0',
apiBaseURL: 'https://wechat-api.ezijing.com', // 接口请求地址
tenant: 'classes'
}
}
const util = require('../../../utils/util.js')
const md5 = require('../../../utils/md5.js')
/* 手机 验证码 相关内容 */
const BindAccount = {
/* 跳转 手机登录 */
phoneLogin: function () { this.setData({ 'bindaccount.isShow': "" }); this.setData({ 'bindphone.isShow': "on" }); },
/* 账号输入 离开 input blur事件监听 */
inputAccount: function (e) { this.setData({ 'bindaccount.account': e.detail.value }); },
/* 密码输入 离开 input blur事件监听 */
inputPwd: function (e) { this.setData({ 'bindaccount.pwd': e.detail.value }); },
/* 点击确定 */
accountConfirm: function (e) {
const _that = this, _bind = _that.data.bindaccount;
/* 调用接口 - 使用账号登录 */
wx.request({
url: util.config.URL_PATH2 + '/user_center/login',
data: {
login_name: _bind.account,
password: md5('uokoaduw' + _bind.pwd.split('').reverse().join('') + 'auhgniq'),
service: 'applet.ezijing.com' }, method: 'POST', header: {
'tenant': util.config.tenant,
'content-type': 'application/x-www-form-urlencoded',
'version':util.config.version,
'apikey': 'lfoWIsuLZQZ72RBKWe2xpYsxGfty8R2s'
},
success: function (res) {
if (res.statusCode && res.statusCode != 200) { wx.showToast({ title: res.data.message, icon: 'none' }); return; }
wx.hideToast();
wx.setStorageSync('userSession', { sessionKey: res.data.ticket });
let _token = wx.getStorageSync('userSession').sessionKey
if (!_token) {
wx.reLaunch({ url: '/pages/index/index' })
return ;
}
/* 获取用户信息 */
wx.request({
url: util.config.URL_PATH1 + '/user/check-access',
data: {}, method: 'GET', header: {
token: _token,
tenant: util.config.tenant,
'version':util.config.version,
'apikey': 'lfoWIsuLZQZ72RBKWe2xpYsxGfty8R2s',
unionid: wx.getStorageSync('union_id')
},
success: res => {
if (res.statusCode != 200 && res.statusCode != 401) { wx.showToast({ title: res.data.message, icon: 'none' }); return; }
if (res.statusCode && res.statusCode == 401) {
// 401特殊处理,这种情况,理解为手机号绑定错误
wx.hideToast();
wx.showModal({
title: '提示',
content: res.data.message,
showCancel:false,
complete (res) {
_that.setData({
'bindaccount.pwd': '',
});
}
})
return ;
}
let _userInfo = {
avatarUrl: res.data.avatar || _that.tempUserInfo.avatarUrl || '无',
nickName: res.data.nickname || _that.tempUserInfo.nickName || '无'
}
wx.setStorageSync('userInfo', _userInfo);
_that.setData({ userInfo: _userInfo, hasUserInfo: true })
_that.popupClose()
_that.goOutSite()
}
})
},
fail: function (res) { wx.hideToast(); wx.showToast({ title: res, icon: 'none' }); }
})
}
}
module.exports = {
BindAccount: BindAccount,
}
\ No newline at end of file
<template name="bindAccount">
<view wx:if="{{bindaccount.isShow}}" class="bind-account {{bindaccount.isShow}}">
<view class="box">
<view class="hdr">
<text>绑定账号</text>
<image src="./icons/user-close.png" bindtap="popupClose"></image>
</view>
<input maxlength="30" type="text" class="input-account" placeholder="输入账号" bindinput="inputAccount" bindblur="inputAccount" value="{{bindaccount.account}}" />
<input maxlength="30" type="text" password="true" class="input-pwd" placeholder="输入密码" bindinput="inputPwd" bindblur="inputPwd" value="{{bindaccount.pwd}}" />
<view class="confirm" bindtap="accountConfirm">确定</view>
<view class="other-login" bindtap="phoneLogin">手机号登录</view>
</view>
</view>
</template>
\ No newline at end of file
.bind-account { opacity: 0; position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: -1; background: rgba(0, 0, 0, 0.6); }
.bind-account.on { opacity: 1; z-index: 999; }
.bind-account .box { position: absolute; left: 50%; top: 50%; padding: 40rpx; width: 630rpx; background: #fafafc; border-radius: 10rpx; font-size: 28rpx; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); }
.bind-account .box .hdr { display: block; width: 100%; height: 46rpx; overflow: hidden; margin-bottom: 40rpx; -webkit-box-sizing: border-box; box-sizing: border-box; }
.bind-account .box .hdr image { float: right; width: 46rpx; height: 46rpx; }
.bind-account .box .input-account { display: block; width: 100%; height: 90rpx; border: 1rpx solid #eee; border-radius: 10rpx; padding: 0 20rpx; -webkit-box-sizing: border-box; box-sizing: border-box; }
.bind-account .box .input-pwd { display: block; width: 100%; height: 90rpx; margin: 20rpx 0 40rpx 0; border: 1rpx solid #eee; border-radius: 10rpx; padding: 0 20rpx; -webkit-box-sizing: border-box; box-sizing: border-box; }
.bind-account .box .confirm { height: 90rpx; width: 100%; background: #4b0; color: #fff; line-height: 90rpx; text-align: center; border-radius: 10rpx; }
.bind-account .box .other-login { margin-top: 40rpx; line-height: 60rpx; text-align: center; color: #576b95; }
\ No newline at end of file
const util = require('../../../utils/util.js')
/* 手机 验证码 相关内容 */
const BindPhone = {
popupShow: function (res) { this.tempUserInfo = res.userInfo; this.setData({ 'bindphone.isShow': "on" }); },
/* 关闭 绑定 弹窗 */
popupClose: function () {
!(wx.getStorageSync('userInfo') || {}).nickName && wx.setStorageSync('userSession', {});
clearInterval(this.timer); // 关闭定时器
let bindphone = { isShow: '', getCode: true, countDown: 60, phone: '', code: '' }
this.setData({ 'bindphone': bindphone })
/* 账号弹框关闭,也用这个方法 */
let bindaccount = { isShow: '', account: '', pwd: '' }
this.setData({ 'bindaccount': bindaccount })
},
/* 跳转 账号登录 */
accountLogin: function () { this.setData({ 'bindphone.isShow': "off" }); this.setData({ 'bindaccount.isShow': "on" }); },
/* 电话输入 离开 input blur事件监听 */
inputPhone: function (e) { this.setData({ 'bindphone.phone': e.detail.value }); },
/* 验证码输入 离开 input blur事件监听 */
inputCode: function (e) { this.setData({ 'bindphone.code': e.detail.value }); },
/* 点击获取验证码 */
getCode: function () {
const _that = this, _bind = _that.data.bindphone;
if (!_bind.phone || !/^1[3-9][0-9]{9}$/.test(_bind.phone)) { wx.showToast({ title: '请填入正确手机号', icon: 'none', duration: 1500 }); return; }
wx.showToast({ title: '验证码请求中', icon: 'none' })
wx.request({
url: util.config.URL_PATH2 + '/user_center/send_login_code',
data: { mobile: _bind.phone, service: 'applet.ezijing.com' }, method: 'POST', header: {
'tenant': util.config.tenant,
'content-type': 'application/x-www-form-urlencoded',
'apikey': 'lfoWIsuLZQZ72RBKWe2xpYsxGfty8R2s'
},
success: function (res) {
if (res.statusCode != 200) { wx.showToast({ title: res.data.message, icon: 'none' }); return ; }
wx.hideToast()
_that.setData({ 'bindphone.getCode': false })
/* 增加定时器 */
_that.timer = setInterval(() => {
if (_bind.countDown == 0) { clearInterval(_that.timer); _that.setData({ 'bindphone.countDown': 60, 'bindphone.getCode': true }); return; }
_that.setData({ 'bindphone.countDown': _bind.countDown - 1 });
}, 1000)
},
fail: function (res) { wx.hideToast(); wx.showToast({ title: res, icon: 'none' }); }
})
},
/* 点击确定 */
codeConfirm: function (e) {
const _that = this, _bind = _that.data.bindphone;
if (!_bind.phone || !/^1[3-9][0-9]{9}$/.test(_bind.phone)) { wx.showToast({ title: '请填入正确手机号', icon: 'none' }); return ; }
if (!_bind.code || !/^\d{4}$/.test(_bind.code)) { wx.showToast({ title: '请填入正确验证码', icon: 'none' }); return ; }
wx.showToast({ title: '验证中', icon: 'none' })
/* 调用接口 - 使用验证码登录 */
wx.request({
url: util.config.URL_PATH2 + '/user_center/code_login',
data: { mobile: _bind.phone, code: _bind.code, service: 'applet.ezijing.com' }, method: 'POST', header: {
'tenant': util.config.tenant,
'content-type': 'application/x-www-form-urlencoded',
'version':util.config.version,
'apikey': 'lfoWIsuLZQZ72RBKWe2xpYsxGfty8R2s'
},
success: function (res) {
if (res.statusCode && res.statusCode != 200) { wx.showToast({ title: res.data.message, icon: 'none' }); return ; }
wx.hideToast();
clearInterval(_that.timer);
wx.setStorageSync('userSession', { sessionKey: res.data.ticket });
let _token = wx.getStorageSync('userSession').sessionKey
if (!_token) {
wx.reLaunch({ url: '/pages/index/index' })
return ;
}
/* 获取用户信息 */
wx.request({
url: util.config.URL_PATH1 + '/user/check-access',
data: {}, method: 'GET', header: {
token: _token,
'tenant': util.config.tenant,
'version':util.config.version,
'apikey': 'lfoWIsuLZQZ72RBKWe2xpYsxGfty8R2s',
unionid: wx.getStorageSync('union_id')
},
success: res => {
if (res.statusCode != 200 && res.statusCode != 401) { wx.showToast({ title: res.data.message, icon: 'none' }); return; }
if (res.statusCode && res.statusCode == 401) {
// 401特殊处理,这种情况,理解为手机号绑定错误
wx.hideToast();
wx.showModal({
title: '提示',
content: res.data.message,
showCancel:false,
complete (res) {
_that.setData({
'bindphone.code': '',
});
}
})
return ;
}
let _userInfo = {
avatarUrl: res.data.avatar || _that.tempUserInfo.avatarUrl || '无',
nickName: res.data.nickname || _that.tempUserInfo.nickName || '无'
}
wx.setStorageSync('userInfo', _userInfo);
_that.setData({ userInfo: _userInfo, hasUserInfo: true })
_that.popupClose()
_that.goOutSite()
}
})
},
fail: function (res) { wx.hideToast(); wx.showToast({ title: res, icon: 'none' }); }
})
}
}
module.exports = {
BindPhone: BindPhone,
}
\ No newline at end of file
<template name="bindPhone">
<view wx:if="{{bindphone.isShow}}" class="bind-phone {{bindphone.isShow}}">
<view class="box">
<view class="hdr">
<text>绑定手机号</text>
<image src="./icons/user-close.png" bindtap="popupClose"></image>
</view>
<input maxlength="11" type="number" class="input-phone" placeholder="输入手机号" bindinput="inputPhone" bindblur="inputPhone" value="{{bindphone.phone}}" />
<view class="box-verify">
<input maxlength="6" type="number" class="code" placeholder="输入验证码" bindinput="inputCode" bindblur="inputCode" value="{{bindphone.code}}" />
<view wx:if="{{bindphone.getCode}}" class="button" bindtap="getCode">获取验证码</view>
<view wx:else class="countdown">已发送({{bindphone.countDown}}s)</view>
</view>
<view class="confirm" bindtap="codeConfirm">确定</view>
<view wx:if="{{isUseAccountLogin}}" class="other-login" bindtap="accountLogin">账号登录</view>
</view>
</view>
</template>
\ No newline at end of file
.bind-phone { opacity: 0; position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: -1; background: rgba(0, 0, 0, 0.6); }
.bind-phone.on { opacity: 1; z-index: 999; }
.bind-phone .box { position: absolute; left: 50%; top: 50%; padding: 40rpx; width: 630rpx; background: #fafafc; border-radius: 10rpx; font-size: 28rpx; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); }
.bind-phone .box .hdr { display: block; width: 100%; height: 46rpx; overflow: hidden; margin-bottom: 40rpx; -webkit-box-sizing: border-box; box-sizing: border-box; }
.bind-phone .box .hdr image { float: right; width: 46rpx; height: 46rpx; }
.bind-phone .box .input-phone { display: block; width: 100%; height: 90rpx; border: 1rpx solid #eee; border-radius: 10rpx; padding: 0 20rpx; -webkit-box-sizing: border-box; box-sizing: border-box; }
.bind-phone .box .box-verify { display: block; height: 90rpx; width: 100%; margin: 20rpx 0 40rpx 0; overflow: hidden; }
.bind-phone .box .box-verify .code { float: left; height: 90rpx; width: 370rpx; border: 1rpx solid #eee; padding: 0 20rpx; border-radius: 10rpx; -webkit-box-sizing: border-box; box-sizing: border-box; }
.bind-phone .box .box-verify .button { float: right; width: 220rpx; height: 90rpx; line-height: 90rpx; text-align: center; border: 1rpx solid #4b0; color: #4b0; border-radius: 10rpx; -webkit-box-sizing: border-box; box-sizing: border-box; }
.bind-phone .box .box-verify .countdown { float: right; width: 220rpx; height: 90rpx; line-height: 90rpx; text-align: center; background: #ccc; color: #fff; border-radius: 10rpx; -webkit-box-sizing: border-box; box-sizing: border-box; }
.bind-phone .box .confirm { height: 90rpx; width: 100%; background: #4b0; color: #fff; line-height: 90rpx; text-align: center; border-radius: 10rpx; }
.bind-phone .box .other-login { margin-top: 40rpx; line-height: 60rpx; text-align: center; color: #576b95; }
\ No newline at end of file
//index.js
//获取应用实例
const app = getApp()
const util = require('../../utils/util.js')
const BindPhone = require('./bindPhone/bindPhone.js')
const BindAccount = require('./bindAccount/bindAccount.js')
const md5 = require('../../utils/md5.js')
Page({
data: {
motto: '点击进入学习系统',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
// 绑定手机号 相关
bindphone: { isShow: '', getCode: true, countDown: 60, phone: '', code: '' },
// 绑定账号 相关
bindaccount: { isShow: '', account: '', pwd: '' },
// 是否 可以使用登录
isUseAccountLogin: false
},
goOutSite: function () {
// wx.navigateTo({
// url: '/pages/outSite/outSite'
// })
wx.switchTab({
url: '/pages/learnSystem/home/home'
})
},
/* 进入页面,先判断是否获取用户信息 */
onReady: function () {
/* 判别 是否显示 账号登录 */
wx.request({
url: util.config.URL_PATH1 + '/switch/lock',
data: {}, method: 'GET', header: { tenant: util.config.tenant, apikey: 'lfoWIsuLZQZ72RBKWe2xpYsxGfty8R2s' }, success: res => {
this.setData({ 'isUseAccountLogin': res.data.switch })
wx.setStorageSync('isUseAccountLogin', res.data.switch)
}
})
wx.hideLoading();
},
// e.detail.userInfo,
/* 按键授权,微信新版 - 获取用户信息 - 授权方式 */
getUserInfo: function (e) { this.getInfo() },
/* 获取用户信息 并 判别是否跟紫荆账号绑定 */
getInfo: function () {
wx.showLoading({ title: '信息获取中...', mask: true })
/* 判别是否登录或者登录过期 */
util.LoginAgainAndJumpPage((loginRes, res) => {
if (loginRes) {
/* 只要调用登录接口,就返回sessionKey, 如果没有绑定 直接 全部 不再使用skey 改为 token */
wx.setStorageSync('userSession', { sessionKey: loginRes.data.ticket })
wx.setStorageSync('userInfo', {})
if (loginRes.data && loginRes.data.code == 80120) {
/* 判别 是否绑定过 紫荆账号 */
this.popupShow(res); wx.hideLoading(); return;
} else if (loginRes.data && loginRes.data.status && loginRes.data.status != 200) {
wx.hideLoading(); wx.showToast({ title: loginRes.data.message, icon: 'none' }); return;
} else if (loginRes.statusCode != 200) {
wx.hideLoading(); wx.showToast({ title: loginRes.data.message, icon: 'none' }); return;
} else {
let _userInfo = {
avatarUrl: loginRes.data.avatar || res.userInfo.avatarUrl || '无',
nickName: loginRes.data.nickname || res.userInfo.nickName || '无'
}
wx.setStorageSync('userInfo', _userInfo);
this.setData({ userInfo: _userInfo, hasUserInfo: true })
wx.hideLoading(); this.goOutSite(); return;
}
// if (res.data.errorCode == 40029) return _that.animteHint("code错误");
} else {
this.setData({ userInfo: wx.getStorageSync('userInfo'), hasUserInfo: true })
wx.hideLoading(); this.goOutSite(); return;
}
})
},
guestLogin: function () {
this.accountConfirms();
// return;
// wx.showModal({
// title: '提示', content: '本账户只适用于“体验学习”,正式学习请点击“登录”按钮',
// success: (res) => {
// if (res.confirm) {
// wx.setStorageSync('userInfo', { "avatarUrl": "https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJv5HunMDDhpdaTz7aVXniaeOUxyQxwa9clFnJCm7Y8eP8gbUkF7I9NHSXSDJ1KssdYw9vAKb0v8fQ/132", "nickName": "游客账号" });
// wx.setStorageSync('userSession', { "sessionKey": "" });
// this.goOutSite();
// }
// }
// });
},
//游客登录
accountConfirms: function (e) {
const _that = this;
/* 调用接口 - 使用账号登录 */
wx.request({
url: util.config.URL_PATH2 + '/user_center/login',
data: {
login_name:'18519690645@163.com',
password: md5('uokoaduw' + '123456'.split('').reverse().join('') + 'auhgniq'),
service: 'applet.ezijing.com'
}, method: 'POST', header: {
'tenant': util.config.tenant,
'content-type': 'application/x-www-form-urlencoded',
'version': util.config.version,
'apikey': 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N'
},
success: function (res) {
if (res.statusCode && res.statusCode != 200) { wx.showToast({ title: res.data.message, icon: 'none' }); return; }
wx.hideToast();
wx.setStorageSync('userSession', { sessionKey: res.data.ticket });
let _token = wx.getStorageSync('userSession').sessionKey
if (!_token) {
wx.reLaunch({ url: '/pages/index/index' })
return;
}
/* 获取用户信息 */
wx.request({
url: util.config.URL_PATH1 + '/user/check-access',
data: {}, method: 'GET', header: {
token: _token,
tenant: util.config.tenant,
'apikey': 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N',
'version': util.config.version,
unionid: wx.getStorageSync('union_id')
},
success: res => {
if (res.statusCode != 200 && res.statusCode != 401) { wx.showToast({ title: res.data.message, icon: 'none' }); return; }
let _userInfo = {
avatarUrl: res.data.avatar || '无',
nickName: res.data.nickname || '游客登录'
}
wx.setStorageSync('userInfo', _userInfo);
_that.setData({ userInfo: _userInfo, hasUserInfo: true })
_that.popupClose()
_that.goOutSite()
}
})
},
fail: function (res) { wx.hideToast(); wx.showToast({ title: res, icon: 'none' }); }
})
},
/* 手机号绑定 方法 */
accountLogin: BindPhone.BindPhone.accountLogin,
timer: BindPhone.BindPhone.timer,
popupShow: BindPhone.BindPhone.popupShow,
popupClose: BindPhone.BindPhone.popupClose,
inputPhone: BindPhone.BindPhone.inputPhone,
inputCode: BindPhone.BindPhone.inputCode,
getCode: BindPhone.BindPhone.getCode,
codeConfirm: BindPhone.BindPhone.codeConfirm,
/* 账号绑定 方法 */
phoneLogin: BindAccount.BindAccount.phoneLogin,
inputAccount: BindAccount.BindAccount.inputAccount,
inputPwd: BindAccount.BindAccount.inputPwd,
accountConfirm: BindAccount.BindAccount.accountConfirm
})
{
"navigationBarTitleText": "清控紫荆课堂",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#414141",
"disableScroll": true
}
\ No newline at end of file
<!--index.wxml-->
<import src='bindPhone/bindPhone.wxml' />
<import src='bindAccount/bindAccount.wxml' />
<view class='container'>
<image class='bg' src='./icons/bg.png' mode='aspectFill'></image>
<image class='logo' src='./icons/hd-logo.png' mode='aspectFit'></image>
<view class='text'>清控紫荆课堂</view>
<button class='btn' open-type='getUserInfo' bindgetuserinfo='getUserInfo'>登录</button>
<view wx-if='{{isUseAccountLogin}}' class='test-id' bindtap='guestLogin'>游客登录</view>
<view class='userinfo'>
<!-- wx:if='{{!hasUserInfo && canIUse}}' -->
<!-- <block wx:else>
<image bindtap='goOutSite' class='userinfo-avatar' src='{{userInfo.avatarUrl}}' background-size='cover'></image>
<text bindtap='goOutSite' class='userinfo-nickname'>{{userInfo.nickName}}</text>
</block> -->
</view>
<template is='bindPhone' data='{{bindphone, isUseAccountLogin}}'></template>
<template is='bindAccount' data='{{bindaccount}}'></template>
</view>
\ No newline at end of file
/**index.wxss**/
@import "bindPhone/bindPhone.wxss";
@import "bindAccount/bindAccount.wxss";
.container { position: fixed; top: 0; left: 0; bottom: 0; right: 0; background: #e5e5e5; }
.container .bg { position: absolute; z-index: 0; top: 0; left: 0; width: 100%; height: 100%; }
.container .logo { position: absolute; z-index: 1; top: 233rpx; left: 50%; width: 344rpx; height: 47rpx; -webkit-transform: translateX(-50%); transform: translateX(-50%); }
.container .text { position: absolute; z-index: 1; top: 303rpx; left: 0; width: 100%; color: #fff; font-size: 54rpx; letter-spacing: 14rpx; line-height: 54rpx; text-align: center; font-weight: 300; }
.container .btn { position: absolute; left: 50%; bottom: 253rpx; width: 500rpx; height: 80rpx; line-height: 80rpx; font-size: 30rpx; font-weight: 300; color: #fff; background: #b49441; -webkit-transform: translateX(-50%); transform: translateX(-50%); }
.test-id { position: absolute; left: 0; bottom: 200rpx; width: 100%; font-size: 28rpx; color: #fff; text-align: center; }
\ No newline at end of file
...@@ -2,12 +2,10 @@ ...@@ -2,12 +2,10 @@
<view class='course-list'> <view class='course-list'>
<block wx:for='{{item.chapterList.course}}' wx:key='{{index}}' wx:for-item='_item'> <block wx:for='{{item.chapterList.course}}' wx:key='{{index}}' wx:for-item='_item'>
<view class='content-group {{!_item.chapters.length ? "no-child" : ""}} {{_item.isUp ? "up" : ""}}'> <view class='content-group {{!_item.chapters.length ? "no-child" : ""}} {{_item.isUp ? "up" : ""}}'>
<form report-submit='true' bindsubmit="formSubmit" > <button form-type="submit" class='title' bindtap='clickJumpOrStatus' data-index='{{index}}' data-status='{{!!_item.chapters.length}}'>{{_item.title}}
<button form-type="submit" class='title' bindtap='clickJumpOrStatus' data-index='{{index}}' data-status='{{!!_item.chapters.length}}'>{{_item.title}} <image class='side' style='{{!_item.chapters.length ? "display: none;" : ""}} {{_item.isUp ? "display: none;" : ""}}' mode='aspectFill' src='../icons/courseContent/up.png'></image>
<image class='side' style='{{!_item.chapters.length ? "display: none;" : ""}} {{_item.isUp ? "display: none;" : ""}}' mode='aspectFill' src='../icons/courseContent/up.png'></image> <image class='side' style='{{!_item.chapters.length ? "display: none;" : ""}} {{_item.isUp ? "" : "display: none;"}}' mode='aspectFill' src='../icons/courseContent/down.png'></image>
<image class='side' style='{{!_item.chapters.length ? "display: none;" : ""}} {{_item.isUp ? "" : "display: none;"}}' mode='aspectFill' src='../icons/courseContent/down.png'></image> </button>
</button>
</form>
<block wx:for='{{_item.chapters}}' wx:key='{{index1}}' wx:for-item='item1' wx:for-index='index1'> <block wx:for='{{_item.chapters}}' wx:key='{{index1}}' wx:for-item='item1' wx:for-index='index1'>
<view class='body {{item1.id === item.chapterList.currentChapterId && "on"}}'> <view class='body {{item1.id === item.chapterList.currentChapterId && "on"}}'>
<view class='name' data-vid='{{item1.vid}}' data-cid='{{item1.cid}}' data-sid='{{item1.sid}}' data-hasVA='{{item1.time}}' data-name='{{item1.name}}' bindtap='jumpToOtherVA' data-index='{{index}}' data-index1='{{index1}}' data-type='{{item1.videoType}}'> <view class='name' data-vid='{{item1.vid}}' data-cid='{{item1.cid}}' data-sid='{{item1.sid}}' data-hasVA='{{item1.time}}' data-name='{{item1.name}}' bindtap='jumpToOtherVA' data-index='{{index}}' data-index1='{{index1}}' data-type='{{item1.videoType}}'>
......
// pages/learnSystem/home/home.js // pages/learnSystem/home/home.js
const CourseApi = require('../../../apiService/CourseApi.js') const CourseApi = require('../../../apiService/CourseApi.js')
const app = getApp()
Page({ Page({
/** /**
...@@ -52,6 +53,8 @@ Page({ ...@@ -52,6 +53,8 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
// 获取用户信息
app.getUser()
wx.showLoading({ title: '页面加载中...', mask: true }) wx.showLoading({ title: '页面加载中...', mask: true })
// CourseApi.getlearnFindList((_) => { // CourseApi.getlearnFindList((_) => {
// this.setData({ 'find[0].arrItem': _ }) // this.setData({ 'find[0].arrItem': _ })
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
.select-find-open { position: absolute; z-index: 1; top: 180rpx; bottom: 0; left: 0; right: 0; background: rgba(0, 0, 0, 0.3); } .select-find-open { position: absolute; z-index: 1; top: 180rpx; bottom: 0; left: 0; right: 0; background: rgba(0, 0, 0, 0.3); }
/* 列表 */ /* 列表 */
.home-scroll { position: fixed; top: 182rpx; bottom: 0; left: 0; right: 0; } .home-scroll { position: fixed; top: 182rpx; bottom: 0; left: 0; right: 0; }
.home-scroll .item-list { padding: 33rpx 25rpx 33rpx 0; border-bottom: 1rpx solid #eeeeee; overflow: hidden; } .home-scroll .item-list { padding: 33rpx 25rpx; border-bottom: 1rpx solid #eeeeee; overflow: hidden; }
.home-scroll .item-list .img { float: left; width: 250rpx; height: 160rpx; } .home-scroll .item-list .img { float: left; width: 250rpx; height: 160rpx; }
.home-scroll .item-list .ctx { position: relative; margin-left: 266rpx; height: 160rpx; } .home-scroll .item-list .ctx { position: relative; margin-left: 266rpx; height: 160rpx; }
.home-scroll .item-list .ctx .top-ctx { position: absolute; top: -2rpx; width: 100%; overflow: hidden; } .home-scroll .item-list .ctx .top-ctx { position: absolute; top: -2rpx; width: 100%; overflow: hidden; }
......
/* pages/learnSystem/message/message.wxss */ /* pages/learnSystem/message/message.wxss */
.msg-scroll { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } .msg-scroll { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }
.msg-scroll .item-msg { position: relative; width: 750rpx; padding: 30rpx 26rpx 30rpx 26rpx; border-bottom: 3rpx dashed #c9c9c9; overflow: hidden; -moz-box-sizing: border-box; box-sizing: border-box; } .msg-scroll .item-msg { position: relative; width: 750rpx; padding: 30rpx 26rpx 30rpx 26rpx; border-bottom: 1rpx solid #eee; overflow: hidden; -moz-box-sizing: border-box; box-sizing: border-box; }
.msg-scroll .item-msg .flag { float: left; margin-bottom: 10rpx; padding: 0 10rpx; font-size: 22rpx; line-height: 40rpx; color: #fff; background: #d50000; border-radius: 4rpx; } .msg-scroll .item-msg .flag { float: left; margin-bottom: 10rpx; padding: 0 10rpx; font-size: 22rpx; line-height: 40rpx; color: #fff; background: #d50000; border-radius: 4rpx; }
.msg-scroll .item-msg .flag.read { background: #a0a0a0; } .msg-scroll .item-msg .flag.read { background: #a0a0a0; }
.msg-scroll .item-msg .text { float: left; width: 100%; color: #535353; font-size: 24rpx; line-height: 34rpx; text-align: justify; } .msg-scroll .item-msg .text { float: left; width: 100%; color: #535353; font-size: 24rpx; line-height: 34rpx; text-align: justify; }
......
const util = require('../../../utils/util.js') const app = getApp()
// pages/learnSystem/my/my.js // pages/learnSystem/my/my.js
Page({ Page({
/* 页面的初始数据 */ /* 页面的初始数据 */
data: { userInfo: { nickName: '用户名', avatarUrl: '../icons/my/default.jpg' }, isUseAccountLogin: true }, data: {
userInfo: null
},
/* 生命周期函数--监听页面加载 */ /* 生命周期函数--监听页面加载 */
onLoad: function (options) { this.setData({ 'userInfo': wx.getStorageSync('userInfo') }); this.setData({ 'isUseAccountLogin': wx.getStorageSync('isUseAccountLogin') }) }, onLoad: function (options) {
/* 生命周期函数--监听页面初次渲染完成 */ this.getUser()
onReady: function () { }, },
// 获取用户信息
getUser() {
app.getUser().then(response => {
this.setData({ userInfo: response })
})
},
/* 我的讨论 */ /* 我的讨论 */
goMyDiscuss: function () { wx.navigateTo({ url: '/pages/learnSystem/myDiscuss/myDiscuss' }) }, goMyDiscuss: function () {
wx.navigateTo({ url: '/pages/learnSystem/myDiscuss/myDiscuss' })
},
/* 我的学分 */ /* 我的学分 */
goMyScore: function () { wx.navigateTo({ url: '/pages/learnSystem/myScore/myScore' }) }, goMyScore: function () {
wx.navigateTo({ url: '/pages/learnSystem/myScore/myScore' })
},
/* 退出系统 */ /* 退出系统 */
outSystem: function () { logout() {
app.logout().then(() => {
let _token = wx.getStorageSync('userSession').sessionKey wx.reLaunch({ url: '/pages/login/index' })
if (!_token) { })
wx.reLaunch({ url: '/pages/index/index' }) }
return ; })
}
util.requestApi({
url: util.config.URL_PATH2 + '/user_center/logout',
method: 'POST',
data: {
token: _token,
service: 'applet.ezijing.com'
}, callback: function (res) {}}); wx.setStorageSync('userInfo', {}); wx.setStorageSync('userSession', {}); wx.reLaunch({ url: '/pages/index/index' }) },
/* 输出信息 */
printMsg: function (detail) { console.log(detail.status) }
})
\ No newline at end of file
<!--pages/learnSystem/my/my.wxml--> <!--pages/learnSystem/my/my.wxml-->
<view class='my'> <view class="my">
<view class='my-info'> <view class="my-info" wx:if="{{ userInfo }}">
<image class='img' src='{{userInfo.avatarUrl}}'></image> <image class="img" mode="aspectFill" src="{{ userInfo.avatar || '../icons/my/default.jpg' }}"></image>
<view class='name'>{{userInfo.nickName}}</view> <view class="name">{{ userInfo.student_info.personal_name }}</view>
</view> </view>
<view class='my-select'> <view class="my-select">
<block wx:if="{{!isUseAccountLogin}}"> <block>
<view class='item' bindtap='goMyDiscuss'> <view class="item" bindtap="goMyDiscuss">
<image class='img' src='../icons/my/my-discuss.png' mode='aspectFit'></image> <image class="img" src="../icons/my/my-discuss.png" mode="aspectFit"></image>
<view class='text'>我的讨论</view> <view class="text">我的讨论</view>
</view> </view>
</block> </block>
<!-- <view class='item' bindtap='goMyScore'> <!-- <view class="item" bindtap="goMyScore">
<image class='img' src='../icons/my/my-credit.png' mode='aspectFit'></image> <image class="img" src="../icons/my/my-credit.png" mode="aspectFit"></image>
<view class='text'>我的学分</view> <view class="text">我的学分</view>
</view> --> </view> -->
<view class='item' bindtap='outSystem'> <view class="item" bindtap="logout">
<image class='img' src='../icons/my/out-system.png' mode='aspectFit'></image> <image class="img" src="../icons/my/out-system.png" mode="aspectFit"></image>
<view class='text'>退出系统</view> <view class="text">退出系统</view>
</view> </view>
<view class='item'> <view class="item">
<image class='img' src='../icons/my/my-waiting.png' mode='aspectFit'></image> <image class="img" src="../icons/my/my-waiting.png" mode="aspectFit"></image>
<view class='text'>敬请期待</view> <view class="text">敬请期待</view>
</view> </view>
</view> </view>
<!-- 增加 关联公众号组件 - 模拟器上不显示,真机没问题 -->
<!-- <view class='relative-account'>
<official-account class='item' bindload='printMsg'></official-account>
</view> -->
</view> </view>
import * as api from './api.js'
Page({
data: {
account: '',
password: ''
},
onLoad: function (options) {},
// 处理提交
handleSubmit(e) {
const { account, password } = this.data
const params = {
account,
password,
type: 1,
service: 'https://h5.ezijing.com'
}
if (!account) {
wx.showToast({ title: '请输入邮箱/手机号', icon: 'none' })
return
}
if (!password) {
wx.showToast({ title: '请输入密码', icon: 'none' })
return
}
this.handleRequest(params)
},
// 请求接口
handleRequest(params) {
api.login(params).then(response => {
const { code, msg, data } = response
code === 0 ? this.handleSuccess(data) : wx.showToast({ title: msg, icon: 'none' })
})
},
// 登录成功
handleSuccess(data) {
wx.setStorage({ key: 'token', data: data.TGC })
wx.switchTab({ url: '/pages/learnSystem/home/home' })
},
handlePassword() {
wx.navigateTo({ url: '/pages/login/password' })
}
})
{
"navigationBarTitleText": "账号密码登录",
"usingComponents": {}
}
<view class="container">
<form catchsubmit="handleSubmit">
<view class="form-item">
<text class="form-label">账号</text>
<input class="form-input" placeholder="请输入邮箱/手机号" model:value="{{ account }}" />
</view>
<view class="form-item">
<text class="form-label">密码</text>
<input password class="form-input" placeholder="请输入密码" model:value="{{ password }}" />
</view>
<view class="form-button" bindtap="handleSubmit">登录</view>
<view class="tips" bindtap="handlePassword">忘记密码?</view>
</form>
</view>
import httpRequest from '../../utils/request.js'
/**
* 登录
*/
export function login(data) {
return httpRequest.post('/api/passport/rest/login', data)
}
/**
* 微信登录
* @param {string} code 小程序登录授权,获取的code
* @param {string} identity 小程序项目识别字符串
*/
export function wechatLogin(data) {
return httpRequest.post('/api/passport/rest/wechat/applets-login', data)
}
// 获取微信unionid
export function getUnionid() {
return httpRequest.get('/api/passport/rest/wechat/get-applets-unionid')
}
// 绑定微信并登录
export function bindWechat(data) {
return httpRequest.post('/api/passport/rest/wechat/bind-unionid', data)
}
// 解除微信绑定
export function destoryUnionid() {
return httpRequest.get('/api/usercenter/user/destory-unionid')
}
// 发送验证码
export function sendCode(data) {
return httpRequest.post('/api/usercenter/user/send-code', data)
}
// 忘记密码
export function updatePassword(data) {
return httpRequest.post('/api/usercenter/user/update-pwd', data)
}
// 获取用户信息
export function getUser() {
return httpRequest.get('/api/lms/user/getinfo')
}
import * as api from '../../api'
Component({
/**
* 组件的属性列表
*/
properties: {
unionid: { type: String }
},
/**
* 组件的初始数据
*/
data: {
account: '',
password: ''
},
/**
* 组件的方法列表
*/
methods: {
// 处理提交
handleSubmit(e) {
const { unionid, account, password } = this.data
const params = { unionid, account, password, type: 1 }
if (!account) {
wx.showToast({ title: '请输入邮箱/手机号', icon: 'none' })
return
}
if (!password) {
wx.showToast({ title: '请输入密码', icon: 'none' })
return
}
this.handleRequest(params)
},
// 请求接口
handleRequest(params) {
api.bindWechat(params).then(response => {
const { code, msg, data } = response
code === 0 ? this.handleSuccess(data) : wx.showToast({ title: msg, icon: 'none' })
})
},
// 登录成功
handleSuccess(data) {
wx.setStorage({ key: 'token', data: data.TGC })
wx.switchTab({ url: '/pages/learnSystem/home/home' })
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view class="container">
<form catchsubmit="handleSubmit">
<view class="form-item">
<text class="form-label">账号</text>
<input class="form-input" placeholder="请输入邮箱/手机号" model:value="{{ account }}" />
</view>
<view class="form-item">
<text class="form-label">密码</text>
<input password class="form-input" placeholder="请输入密码" model:value="{{ password }}" />
</view>
<view class="form-button" bindtap="handleSubmit">绑定</view>
</form>
<slot></slot>
</view>
@import '../../style.wxss';
.container {
margin: 0;
}
import * as api from '../../api'
Component({
/**
* 组件的属性列表
*/
properties: {
unionid: { type: String }
},
/**
* 组件的初始数据
*/
data: {
account: '',
password: '',
disabled: false
},
/**
* 组件的方法列表
*/
methods: {
// 处理提交
handleSubmit(e) {
const { unionid, account, password } = this.data
const params = { unionid, account, code: password, type: 2 }
if (!account) {
wx.showToast({ title: '请输入手机号', icon: 'none' })
return
}
if (!password) {
wx.showToast({ title: '请输入验证码', icon: 'none' })
return
}
this.handleRequest(params)
},
// 请求接口
handleRequest(params) {
api.bindWechat(params).then(response => {
const { code, msg, data } = response
code === 0 ? this.handleSuccess(data) : wx.showToast({ title: msg, icon: 'none' })
})
},
// 登录成功
handleSuccess(data) {
wx.setStorage({ key: 'token', data: data.TGC })
wx.switchTab({ url: '/pages/learnSystem/home/home' })
},
// 发送验证码
handleSendCode() {
if (this.data.disabled) {
return
}
if (!/^1[3-9][0-9]{9}$/.test(this.data.account)) {
wx.showToast({ title: '请输入手机号', icon: 'none' })
return
}
this.handleSendCodeRequest()
},
handleSendCodeRequest() {
this.setData({ disabled: true })
// 开始倒计时
const countdown = this.selectComponent('.countdown')
countdown.start()
api
.sendCode({ account: this.data.account })
.then(response => {
const { code, msg } = response
if (code === 0) {
wx.showToast({ title: '验证码发送成功', icon: 'none' })
} else {
countdown.reset()
this.setData({ disabled: false })
wx.showToast({ title: msg, icon: 'none' })
}
})
.catch(response => {
countdown.reset()
this.setData({ disabled: false })
})
}
}
})
{
"component": true,
"usingComponents": {
"countdown": "../countdown/index"
}
}
<view class="container">
<form catchsubmit="formSubmit">
<view class="form-item">
<text class="form-label">手机号</text>
<input
maxlength="{{ 11 }}"
type="number"
class="form-input"
placeholder="请输入手机号"
model:value="{{ account }}"
/>
</view>
<view class="form-item">
<text class="form-label">验证码</text>
<input maxlength="{{ 4 }}" class="form-input" placeholder="请输入验证码" model:value="{{ password }}" />
<countdown class="countdown" bindtap="handleSendCode"></countdown>
</view>
<view class="form-button" bindtap="handleSubmit">绑定</view>
</form>
<slot></slot>
</view>
@import '../../style.wxss';
.container {
margin: 0;
}
Component({
/**
* 组件的属性列表
*/
properties: {
step: { type: Number, value: 1000 },
seconds: { type: Number, value: 60 }
},
/**
* 组件的初始数据
*/
data: {
disabled: false,
buttonText: '获取验证码',
currentSeconds: 0
},
timer: null,
/**
* 组件的方法列表
*/
methods: {
genTimer() {
this.timer && clearInterval(this.timer)
this.timer = setInterval(() => {
const currentSeconds = ++this.data.currentSeconds
this.setData({ currentSeconds, buttonText: `等待(${this.data.seconds - currentSeconds}S)` })
if (currentSeconds === this.data.seconds) {
this.finish()
}
}, this.data.step)
},
// 开始
start() {
if (this.data.disabled) {
return
}
this.setData({ disabled: true })
this.genTimer()
this.triggerEvent('start')
},
// 重置
reset() {
this.setData({ disabled: false, currentSeconds: 0, buttonText: '获取验证码' })
this.timer && clearInterval(this.timer)
},
// 结束
finish() {
this.reset()
this.triggerEvent('finish')
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view class="countdown {{ disabled ? 'is-disabled' : '' }}">{{ buttonText }}</view>
.countdown {
min-width: 80px;
padding: 0 10px;
text-align: center;
height: 30px;
font-size: 12px;
line-height: 30px;
color: #b49441;
border: 1rpx solid #b49441;
border-radius: 15px;
}
.countdown.is-disabled {
color: #222;
background-color: #f0f0f0;
border-color: #f0f0f0;
}
import * as api from './api'
Page({
/**
* 页面的初始数据
*/
data: {
type: 2, // 1 账号密码登录; 2 验证码登录
show: false, // 绑定状态模态框
unionid: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// 授权过的自动登录
// wx.getSetting({
// success: res => {
// res.authSetting['scope.userInfo'] && this.wechatLogin()
// }
// })
},
// 切换绑定方式
changeType(e) {
const { type } = e.currentTarget.dataset
this.setData({ type })
},
// 获取用户code
getCode(callback) {
wx.login({
success(res) {
if (res.code) {
callback && callback(res.code)
} else {
wx.showToast({ title: `登录失败!${res.errMsg}`, icon: 'none' })
}
},
fail(res) {
wx.showToast({ title: `登录失败!${res.errMsg}`, icon: 'none' })
}
})
},
// 获取用户信息
getUserInfo(callback) {
wx.getUserInfo({
success(res) {
callback && callback(res)
},
fail(res) {
wx.showToast({ title: `获取用户信息失败!`, icon: 'none' })
}
})
},
// 微信登录
wechatLogin() {
// 获取code
this.getCode(code => {
// 获取用户信息
this.getUserInfo(user => {
const { encryptedData, iv } = user
api.wechatLogin({ encryptedData, iv, code, identity: 'classes-mini' }).then(response => {
if (response.code === 0) {
this.handleSuccess(response.data)
} else if (response.code === 2) {
// 绑定手机号
this.setData({ show: true, unionid: response.data.unionid })
} else {
wx.showToast({ title: response.msg, icon: 'none' })
}
})
})
})
},
// 手机号登录
phoneLogin() {
wx.navigateTo({ url: '/pages/login/phone' })
},
// 账号密码登录
accountLogin() {
wx.navigateTo({ url: '/pages/login/account' })
},
// 登录成功
handleSuccess(data) {
wx.setStorage({ key: 'token', data: data.TGC })
wx.switchTab({ url: '/pages/learnSystem/home/home' })
}
})
{
"usingComponents": {
"bind-account": "./components/bindAccount/index",
"bind-phone": "./components/bindPhone/index"
}
}
<main-page>
<view class="container">
<image src="../../assets/images/bg.png" mode="aspectFill" class="bg"></image>
<view class="top">
<image class="logo" src="../../assets/images/hd-logo.png" mode="aspectFit"></image>
<view class="title">清控紫荆课堂</view>
</view>
<view class="login">
<button
type="primary"
hover-class="none"
class="login-button"
open-type="getUserInfo"
bindgetuserinfo="wechatLogin"
>
微信登录
</button>
<view class="login-flex">
<view class="login-text" bindtap="phoneLogin">手机号登录</view>
<view class="login-text" bindtap="accountLogin">账号密码登录</view>
</view>
</view>
</view>
</main-page>
<!-- 绑定相关 -->
<dialog title="{{ type === 1 ? '绑定账号' : '绑定手机号' }}" model:show="{{ show }}">
<!-- 绑定账号 -->
<bind-account unionid="{{ unionid }}" wx:if="{{ type === 1 }}">
<view class="t1" data-type="{{ 2 }}" bindtap="changeType">手机号登录</view>
</bind-account>
<!-- 绑定手机号 -->
<bind-phone unionid="{{ unionid }}" wx:if="{{ type === 2 }}">
<view class="t1" data-type="{{ 1 }}" bindtap="changeType">账号密码登录</view>
</bind-phone>
</dialog>
.bg {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
z-index: 1;
}
.top {
position: fixed;
left: 0;
right: 0;
top: 140rpx;
z-index: 100;
text-align: center;
}
.top .logo {
width: 344rpx;
height: 47rpx;
}
.top .title {
font-size: 54rpx;
letter-spacing: 14rpx;
color: #fff;
text-align: center;
}
.login {
position: fixed;
left: 0;
right: 0;
bottom: 40px;
margin: 30px;
z-index: 100;
}
button.login-button {
font-size: 28rpx;
height: 80rpx;
line-height: 80rpx;
color: #fff;
text-align: center;
background-color: #b49441;
border-radius: 40rpx;
border: 0;
}
.login-flex {
padding: 20px 0;
display: flex;
justify-content: space-between;
}
.login-text {
font-size: 28rpx;
color: #fff;
}
.t1 {
padding-top: 20px;
text-align: center;
font-size: 28rpx;
color: #576b95;
}
import * as api from './api.js'
Page({
data: {
account: '',
code: '',
password: '',
passwordR: '',
disabled: false
},
onLoad: function (options) {},
// 处理提交
handleSubmit(e) {
const { account, code, password, passwordR } = this.data
const params = { account, code, password, passwordR }
if (!account) {
wx.showToast({ title: '请输入邮箱/手机号', icon: 'none' })
return
}
if (!code) {
wx.showToast({ title: '请输入验证码', icon: 'none' })
return
}
if (!password) {
wx.showToast({ title: '请输入密码', icon: 'none' })
return
}
this.handleRequest(params)
},
// 请求接口
handleRequest(params) {
api.updatePassword(params).then(response => {
const { code, msg, data } = response
code === 0 ? this.handleSuccess(data) : wx.showToast({ title: msg, icon: 'none' })
})
},
// 修改成功
handleSuccess(data) {
wx.setStorage({ key: 'token', data: data.TGC })
wx.switchTab({ url: '/pages/learnSystem/home/home' })
},
// 发送验证码
handleSendCode() {
if (this.data.disabled) {
return
}
if (!/^1[3-9][0-9]{9}$/.test(this.data.account)) {
wx.showToast({ title: '请输入手机号', icon: 'none' })
return
}
this.handleSendCodeRequest()
},
handleSendCodeRequest() {
this.setData({ disabled: true })
// 开始倒计时
const countdown = this.selectComponent('.countdown')
countdown.start()
api
.sendCode({ account: this.data.account })
.then(response => {
const { code, msg } = response
if (code === 0) {
wx.showToast({ title: '验证码发送成功', icon: 'none' })
} else {
countdown.reset()
this.setData({ disabled: false })
wx.showToast({ title: msg, icon: 'none' })
}
})
.catch(response => {
countdown.reset()
this.setData({ disabled: false })
})
}
})
{
"navigationBarTitleText": "忘记密码",
"usingComponents": {
"countdown": "./components/countdown/index"
}
}
<view class="container">
<form catchsubmit="formSubmit">
<view class="form-item">
<text class="form-label">账号</text>
<input class="form-input" placeholder="请输入邮箱/手机号" model:value="{{ account }}" />
</view>
<view class="form-item">
<text class="form-label">验证码</text>
<input maxlength="{{ 4 }}" class="form-input" placeholder="请输入验证码" model:value="{{ code }}" />
<countdown class="countdown" bindtap="handleSendCode"></countdown>
</view>
<view class="form-item">
<text class="form-label">新密码</text>
<input password class="form-input" placeholder="请输入新密码" model:value="{{ password }}" />
</view>
<view class="form-item">
<text class="form-label">确认密码</text>
<input password class="form-input" placeholder="请再次输入新密码" model:value="{{ passwordR }}" />
</view>
<view class="form-button" bindtap="handleSubmit">提交</view>
</form>
</view>
@import 'style.wxss';
.form-label {
width: 70px;
}
import * as api from './api.js'
Page({
data: {
account: '',
password: '',
disabled: false
},
onLoad: function (options) {},
// 处理提交
handleSubmit(e) {
const { account, password } = this.data
const params = {
account,
password,
type: 2,
service: 'https://h5.ezijing.com'
}
if (!account) {
wx.showToast({ title: '请输入手机号', icon: 'none' })
return
}
if (!password) {
wx.showToast({ title: '请输入验证码', icon: 'none' })
return
}
this.handleRequest(params)
},
// 请求接口
handleRequest(params) {
api.login(params).then(response => {
const { code, msg, data } = response
code === 0 ? this.handleSuccess(data) : wx.showToast({ title: msg, icon: 'none' })
})
},
// 登录成功
handleSuccess(data) {
wx.setStorage({ key: 'token', data: data.TGC })
wx.switchTab({ url: '/pages/learnSystem/home/home' })
},
// 发送验证码
handleSendCode() {
if (this.data.disabled) {
return
}
if (!/^1[3-9][0-9]{9}$/.test(this.data.account)) {
wx.showToast({ title: '请输入手机号', icon: 'none' })
return
}
this.handleSendCodeRequest()
},
handleSendCodeRequest() {
this.setData({ disabled: true })
// 开始倒计时
const countdown = this.selectComponent('.countdown')
countdown.start()
api
.sendCode({ account: this.data.account })
.then(response => {
const { code, msg } = response
if (code === 0) {
wx.showToast({ title: '验证码发送成功', icon: 'none' })
} else {
countdown.reset()
this.setData({ disabled: false })
wx.showToast({ title: msg, icon: 'none' })
}
})
.catch(response => {
countdown.reset()
this.setData({ disabled: false })
})
}
})
{
"navigationBarTitleText": "手机号登录",
"usingComponents": {
"countdown": "./components/countdown/index"
}
}
<view class="container">
<form catchsubmit="formSubmit">
<view class="form-item">
<text class="form-label">手机号</text>
<input
maxlength="{{ 11 }}"
type="number"
class="form-input"
placeholder="请输入手机号"
model:value="{{ account }}"
/>
</view>
<view class="form-item">
<text class="form-label">验证码</text>
<input maxlength="{{ 4 }}" class="form-input" placeholder="请输入验证码" model:value="{{ password }}" />
<countdown class="countdown" bindtap="handleSendCode"></countdown>
</view>
<view class="form-button" bindtap="handleSubmit">登录</view>
</form>
</view>
.container {
margin: 0 10px;
}
.form-item {
display: flex;
align-items: center;
padding: 10px 0;
border-bottom: 1px solid #f1f1f1;
}
.form-label {
margin-right: 10px;
}
.form-input {
padding: 10px 0;
flex: 1;
}
.form-button {
margin-top: 20px;
padding: 10px;
color: #fff;
text-align: center;
background-color: #b49441;
border-radius: 4px;
}
.tips {
padding: 20px 0;
text-align: right;
}
...@@ -545,6 +545,15 @@ Page({ ...@@ -545,6 +545,15 @@ Page({
break break
} }
} }
// 记录播放时间点,进度上传后会清空
if (!_obj.currentTime) {
return
}
this.realTimeProgress.ps = this.realTimeProgress.ps || []
const hasTimePoint = this.realTimeProgress.ps.includes(_obj.currentTime)
if (!hasTimePoint) {
this.realTimeProgress.ps.push(_obj.currentTime)
}
}, },
/* 增加定时器,每过10000ms,把数据存入localStorage一次 并 提交一次 */ /* 增加定时器,每过10000ms,把数据存入localStorage一次 并 提交一次 */
...@@ -575,7 +584,8 @@ Page({ ...@@ -575,7 +584,8 @@ Page({
_rProgress.pt = parseInt(_rProgress.pt) + (10000 / 1000) * 1.5 _rProgress.pt = parseInt(_rProgress.pt) + (10000 / 1000) * 1.5
_rProgress.cpt = tempTime _rProgress.cpt = tempTime
_rProgress.mpt = tempTime > _rProgress.mpt ? tempTime : _rProgress.mpt _rProgress.mpt = tempTime > _rProgress.mpt ? tempTime : _rProgress.mpt
ChapterApi.updateProgress(_rProgress) ChapterApi.updateProgress(Object.assign({}, _rProgress, { ps: _rProgress.ps.join(',') }))
this.realTimeProgress.ps = []
} }
}, 10000) }, 10000)
} }
......
{ {
"description": "项目配置文件。", "description": "项目配置文件。",
"setting": { "setting": {
"urlCheck": true, "urlCheck": true,
"es6": true, "es6": true,
"postcss": true, "enhance": true,
"minified": true, "postcss": true,
"newFeature": true, "preloadBackgroundData": false,
"coverView": true, "minified": true,
"nodeModules": false, "newFeature": true,
"autoAudits": false, "coverView": true,
"uglifyFileName": true, "nodeModules": false,
"checkInvalidKey": true, "autoAudits": false,
"checkSiteMap": true, "showShadowRootInWxmlPanel": true,
"uploadWithSourceMap": true, "scopeDataCheck": false,
"babelSetting": { "uglifyFileName": true,
"ignore": [], "checkInvalidKey": true,
"disablePlugins": [], "checkSiteMap": true,
"outputPath": "" "uploadWithSourceMap": true,
} "compileHotReLoad": false,
}, "useMultiFrameRuntime": false,
"compileType": "miniprogram", "useApiHook": true,
"libVersion": "2.3.0", "babelSetting": {
"appid": "wx81555c44ed2d7653", "ignore": [],
"projectname": "learnOnline-enterprise", "disablePlugins": [],
"isGameTourist": false, "outputPath": ""
"simulatorType": "wechat", },
"simulatorPluginLibVersion": {}, "useIsolateContext": true,
"condition": { "useCompilerModule": true,
"search": { "userConfirmedUseCompilerModuleSwitch": false,
"current": -1, "packNpmManually": false,
"list": [] "packNpmRelationList": [],
}, "minifyWXSS": true
"conversation": { },
"current": -1, "compileType": "miniprogram",
"list": [] "libVersion": "2.12.2",
}, "appid": "wx81555c44ed2d7653",
"game": { "projectname": "learnOnline-enterprise",
"currentL": -1, "isGameTourist": false,
"list": [] "simulatorType": "wechat",
}, "simulatorPluginLibVersion": {},
"miniprogram": { "condition": {
"current": -1, "search": {
"list": [] "list": []
} },
} "conversation": {
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"list": []
}
}
} }
\ No newline at end of file
import { apiBaseURL, tenant } from '../config.js'
class Request {
constructor(config) {
this.defaults = {
method: 'GET',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
baseURL: ''
}
this.beforeRequest = null
}
request(config) {
const headers = this.mergeOptions(this.defaults.headers, config.headers)
config = this.mergeOptions(this.defaults, config, { headers })
config = this.beforeRequest ? this.beforeRequest(config) : config
return new Promise((resolve, reject) => {
wx.request({
method: config.method,
url: this.getURL(config.url),
dataType: config.dataType,
header: config.headers,
data: config.data,
responseType: config.responseType,
success(res) {
if (res.statusCode === 200) {
resolve(config.success ? config.success(res, config) : res)
} else {
reject(config.fail ? config.fail(res, config) : res)
}
},
fail(res) {
reject(config.fail ? config.fail(res, config) : res)
},
complete(res) {
config.complete && config.complete(res, config)
}
})
})
}
get(url, data = {}, config = {}) {
return this.request(this.mergeOptions(config, { url, data, method: 'GET' }))
}
post(url, data = {}, config = {}) {
return this.request(this.mergeOptions(config, { url, data, method: 'POST' }))
}
put(url, data = {}, config = {}) {
return this.request(this.mergeOptions(config, { url, data, method: 'PUT' }))
}
delete(url, data = {}, config = {}) {
return this.request(this.mergeOptions(config, { url, data, method: 'DELETE' }))
}
mergeOptions(...options) {
return Object.assign({}, ...options)
}
getURL(url) {
return url.includes('://') ? url : this.defaults.baseURL + url
}
}
// 创建实例
const httpRequest = new Request()
httpRequest.defaults.baseURL = apiBaseURL
httpRequest.defaults.headers.tenant = tenant
httpRequest.beforeRequest = function (config) {
config.headers.token = wx.getStorageSync('token')
return config
}
// 成功处理
httpRequest.defaults.success = (res, config) => {
return res.data
}
// 失败处理
httpRequest.defaults.fail = (res, config) => {
if (!res.data) {
wx.showToast({ title: '接口请求失败,请检查网络设置', icon: 'none' })
return res
}
if (res.data.status === 403) {
// 未登录
wx.redirectTo({ url: '/pages/login/index' })
return
}
wx.showToast({ title: res.data.message, icon: 'none' })
}
// 导出
module.exports = httpRequest
...@@ -2,50 +2,43 @@ ...@@ -2,50 +2,43 @@
* 所有相关配置项 * 所有相关配置项
*/ */
const url_test = { const url_test = {
// URL_PATH: 'http://dev.ezijing.com:3000/api', // 本地开发域名 URL_PATH1: 'https://lms-api2.ezijing.com', // 正式域名 - 由于项目变动域名
// outSiteLink: 'https://applets.ezijing.com', // 本地测试外链
// URL_PATH: 'https://api2.ezijing.com', // 测试域名
// outSiteLink: 'https://kelley2.ezijing.com', // 测试外链
URL_PATH: 'https://api.ezijing.com/tenant', // 正式域名 - 由于项目变动域名
URL_PATH1: 'https://ep-api2.ezijing.com', // 正式域名 - 由于项目变动域名
URL_PATH2: 'https://sso2.ezijing.com', // 正式域名 - 由于项目变动域名 URL_PATH2: 'https://sso2.ezijing.com', // 正式域名 - 由于项目变动域名
outSiteLink: 'https://e-learning.ezijing.com', // 正式外链 outSiteLink: 'https://e-learning.ezijing.com', // 正式外链
tenant: 'classes', tenant: 'classes',
version: '3.1.4' version: '3.2.0'
}; }
const url_online = { const url_online = {
URL_PATH: 'https://api.ezijing.com/tenant', // 正式域名 - 由于项目变动域名 URL_PATH1: 'https://wechat-api.ezijing.com/api/lms', // 正式域名 - 由于项目变动域名
URL_PATH1: 'https://ep-api.ezijing.com', // 正式域名 - 由于项目变动域名 URL_PATH2: 'https://wechat-api.ezijing.com/api', // 正式域名 - 由于项目变动域名
URL_PATH2: 'https://sso.ezijing.com', // 正式域名 - 由于项目变动域名
outSiteLink: 'https://e-learning.ezijing.com', // 正式外链 outSiteLink: 'https://e-learning.ezijing.com', // 正式外链
tenant: 'classes', tenant: 'classes',
version: '3.1.4' version: '3.2.0'
} }
let config = url_online; let config = url_online
/* 请求接口统一 重定义 */ /* 请求接口统一 重定义 */
const requestApi = (obj) => { const requestApi = obj => {
let _token = wx.getStorageSync('userSession').sessionKey; const token = wx.getStorageSync('token')
if (!_token) { if (!token) {
wx.reLaunch({ url: '/pages/index/index' }) wx.reLaunch({ url: '/pages/login/index' })
return ; return
} }
wx.request({ wx.request({
url: obj.url, url: obj.url,
data: obj.data || '', // 不必填 data: obj.data || '', // 不必填
header: { header: {
'token': _token, token,
'tenant': config.tenant, tenant: config.tenant,
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
'version': config.version, version: config.version
'apikey': 'lfoWIsuLZQZ72RBKWe2xpYsxGfty8R2s'
}, },
method: obj.method || 'GET', // 不必填,默认 GET method: obj.method || 'GET', // 不必填,默认 GET
dataType: 'json', dataType: 'json',
success: function (res) { success: function (res) {
if (res.statusCode === 200) { if (res.statusCode === 200) {
// if (res.data.status === 200) { // if (res.data.status === 200) {
// obj.callback(res.data) // 直接把数据处理好,然后直接 返回 // obj.callback(res.data) // 直接把数据处理好,然后直接 返回
// } else { // } else {
// wx.showToast({ title: JSON.stringify(res.data), icon: 'none' }) // 自己后台封装返回 // wx.showToast({ title: JSON.stringify(res.data), icon: 'none' }) // 自己后台封装返回
// } // }
...@@ -53,7 +46,7 @@ const requestApi = (obj) => { ...@@ -53,7 +46,7 @@ const requestApi = (obj) => {
} else if (res.statusCode === 403 || res.statusCode === 401) { } else if (res.statusCode === 403 || res.statusCode === 401) {
/* 未授权登录,跳转首页 */ /* 未授权登录,跳转首页 */
wx.reLaunch({ wx.reLaunch({
url: '/pages/index/index' url: '/pages/login/index'
}) })
} else { } else {
wx.showToast({ title: res.errMsg, icon: 'none' }) // 微信封装返回 wx.showToast({ title: res.errMsg, icon: 'none' }) // 微信封装返回
...@@ -63,186 +56,31 @@ const requestApi = (obj) => { ...@@ -63,186 +56,31 @@ const requestApi = (obj) => {
wx.showToast({ title: JSON.stringify(res), icon: 'none' }) wx.showToast({ title: JSON.stringify(res), icon: 'none' })
} }
}) })
}; }
/* 工具方法 - 播放时间 转化 h:m:s */ /* 工具方法 - 播放时间 转化 h:m:s */
const durationToTimeString = (duration) => { const durationToTimeString = duration => {
let h = Math.floor(duration / 3600); let h = Math.floor(duration / 3600)
let m = Math.floor((duration - h * 3600) / 60); let m = Math.floor((duration - h * 3600) / 60)
let s = (duration - h * 3600 - m * 60) % 60; let s = (duration - h * 3600 - m * 60) % 60
function tenify(a) { function tenify(a) {
return a >= 10 ? a : '0' + a; return a >= 10 ? a : '0' + a
} }
let to = { h: tenify(h), m: tenify(m), s: tenify(s) } let to = { h: tenify(h), m: tenify(m), s: tenify(s) }
let format = 'h:m:s'; let format = 'h:m:s'
return format.replace(/h|m|s/g, k => to[k]).replace(/^00\:/, ''); return format.replace(/h|m|s/g, k => to[k]).replace(/^00\:/, '')
};
/**
* 小程序 - 获取用户信息
*/
const miniGetInfo = (callback) => {
// 获取用户凭证code - 使用 login API获取
wx.login({
success: res => {
let obj = {}
obj.code = res.code
// 获取用户授权设置 - 使用 getSetting API获取
wx.getSetting({
success: res1 => {
if (res1.authSetting['scope.userInfo']) {
// 获取用户信息 - 使用 getUserInfo API获取
wx.getUserInfo({
withCredentials: true,
success: res2 => {
obj.encryptedData = res2.encryptedData
obj.iv = res2.iv
obj.userInfo = res2.userInfo
/**
* 这里 调用后台接口 loginApi,传参如下
* obj.code
* obj.encryptedData
* obj.iv
* obj.userInfo
*/
loginApi(obj, (res, obj) => { callback(res, obj); })
},
fail: res2 => { wx.hideLoading(); wx.showToast({ title: '用户信息获取失败,请重试', icon: 'none' }); }
})
} else {
wx.hideLoading(); wx.showToast({ title: '请先点击登录', icon: 'none' });
}
},
fail: res1 => { wx.hideLoading(); wx.showToast({ title: '用户授权设置获取失败,请重试', icon: 'none' }); }
})
},
fail: res => { wx.hideLoading(); wx.showToast({ title: '用户凭证code获取失败,请重试', icon: 'none' }); }
})
};
/**
* 登录api - 获取 openId 、userName等内容
*/
const loginApi = (obj, callback) => {
wx.request({
url: config.URL_PATH1 + '/user/check-unionid',
data: { code: obj.code, encrypted_data: obj.encryptedData, iv: obj.iv, idt: config.tenant }, method: 'POST', header: {
tenant: config.tenant,
'version': config.version,
apikey: 'lfoWIsuLZQZ72RBKWe2xpYsxGfty8R2s'
},
success: res => {
if (res.statusCode == 200) {
wx.setStorageSync('union_id', res.data.union_id);
wx.setStorageSync('openId', res.data.open_id);
wx.request({
url: config.URL_PATH2 + '/user_center/wechat_login',
data: { wechat_unionid: res.data.union_id, service: 'applet.ezijing.com' }, method: 'POST', header: {
'tenant': config.tenant,
'content-type': 'application/x-www-form-urlencoded',
'version': config.version,
'apikey': 'lfoWIsuLZQZ72RBKWe2xpYsxGfty8R2s'
},
success: res1 => {
if (res1.statusCode == 200) {
let _token = res1.data.ticket;
if (!_token) {
wx.reLaunch({ url: '/pages/index/index' })
return ;
}
wx.setStorageSync('userSession', { 'sessionKey': _token });
/* 获取用户信息 */
wx.request({
url: config.URL_PATH1 + '/user/check-access',
data: {}, method: 'GET', header: {
token: _token,
tenant: config.tenant,
'version': config.version,
'apikey': 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N',
unionid: res.data.union_id
},
success: res2 => {
if (res2.statusCode != 200) { wx.showToast({ title: res2.data.message||'获取用户信息失败', icon: 'none' }); return; }
wx.setStorageSync("sid", res2.data.id);
wx.setStorageSync("uid", res1.data.uid);
callback(res1, obj);
}
})
}else{
callback(res1, obj);
}
}
})
} else {
callback(res, obj);
}
}
})
};
/**
* 小程序 - 判断是否需要再次登录 并 跳转页面
*/
const LoginAgainAndJumpPage = (callback) => {
let userSession = wx.getStorageSync('userSession') || {}
let _userInfo = wx.getStorageSync('userInfo') || {}
/* 可能存在,多微信绑定同一个手机问题,所以这里暂时不再做鉴定,永远重新请求 */
// if (userSession.sessionKey && _userInfo.nickName) {
// wx.checkSession({
// success: () => {
// callback()
// }, // session_key 未过期,并且在本生命周期一直有效
// fail: () => {
// // session_key 已经失效,需要重新执行登录流程
// miniGetInfo((res, obj) => { callback(res, obj); })
// }
// })
// } else {
// // session_key 未存本地,则本地数据缺失
// miniGetInfo((res, obj) => { callback(res, obj); })
// }
miniGetInfo((res, obj) => { callback(res, obj); })
};
// 上报formid
const sendformid = (formId) => {
let _token = wx.getStorageSync('userSession').sessionKey;
if (!_token) {
wx.reLaunch({ url: '/pages/index/index' })
return ;
}
wx.request({
url: config.URL_PATH1 + '/v2/education/formid',
data:{
openid: wx.getStorageSync('openId'),
formid: formId
},
header:{
'token': _token,
'tenant': config.tenant,
'content-type': 'application/x-www-form-urlencoded',
'apikey': 'pP5ECUqRDLDzuh4qRuJro0L1LPgjLP0N',
'version': config.version
},
method:'POST'
})
} }
/** /**
* localStorage 中存放的 各种值 * localStorage 中存放的 各种值
* userSession - 调用 login 获取对应的 sessionKey openId等值 * userSession - 调用 login 获取对应的 sessionKey openId等值
* userInfo - 存放用户 头像、昵称等基本信息值 * userInfo - 存放用户 头像、昵称等基本信息值
* *
* videoCacheCtrlBar * videoCacheCtrlBar
* audioCacheCtrlBar * audioCacheCtrlBar
*/ */
module.exports = { module.exports = {
'config': config, config: config,
requestApi: requestApi, requestApi: requestApi,
durationToTimeString: durationToTimeString, durationToTimeString: durationToTimeString
sendformid: sendformid, }
LoginAgainAndJumpPage: LoginAgainAndJumpPage
};
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论