提交 72facb1d authored 作者: haodaking's avatar haodaking 提交者: 王鹏飞

feat:分享海报

上级 c26e822d
......@@ -15,3 +15,18 @@ export function getUser() {
export function logout() {
return httpRequest.get('/api/passport/rest/logout')
}
// 获取营销数据
export function getShare(data) {
return httpRequest.get(`/api/lms/v3/activities/share/${data.semester_id}/${data.course_id}/${data.chapter_id}`)
}
// 获取二维码
export function getQrcode(data) {
return httpRequest.get('/api/lms/util/pcode', data)
}
// 获取二维码
export function imageTransfer(data) {
return httpRequest.get('/api/usercenter/tool/transfer-image', data)
}
import * as api from './api/base.js'
import './utils/mtj-wx-sdk'
App({
store: {
pageshow: false,
user: {} // 用户信息
},
onLaunch: function () {},
onLaunch: function () {
// 加载自定义字体
// wx.loadFontFace({
// global: true,
// family: 'my',
// source: 'https://webapp-pub.ezijing.com/weapp/share/my.ttf',
// scopes: ['webview', 'native']
// })
},
onPageNotFound() {
wx.redirectTo({ url: 'pages/login/index' })
},
......
......@@ -16,7 +16,9 @@
"pages/learnSystem/myScore/myScore",
"pages/learnSystem/myDiscuss/myDiscuss",
"pages/learnSystem/discussDetail/discussDetail",
"pages/course/player"
"pages/course/player",
"pages/share/index",
"pages/web/index"
],
"window": {
"navigationBarBackgroundColor": "#fff",
......@@ -60,7 +62,7 @@
},
"plugins": {
"tencentvideo": {
"version": "2.0.5",
"version": "2.0.10",
"provider": "wxa75efa648b60994b"
}
},
......
差异被折叠。
{
"component": true,
"usingComponents": {
"wxml-to-canvas": "wxml-to-canvas",
"van-icon": "@vant/weapp/icon/index"
}
}
<view class="share-page" wx:if="{{ show }}">
<view class="close" bindtap="onClose"></view>
<!-- 分享配置页面 -->
<view class="share-page-body">
<view class="share">
<image
src="{{ controls.bg }}?x-oss-process=image/resize,m_fill,h_1064,w_600"
mode="aspectFill"
class="bg"
></image>
<image
src="https://webapp-pub.ezijing.com/weapp/share/marywood/cover.png?x-oss-process=image/resize,m_fill,h_898,w_507"
mode="aspectFill"
class="cover"
></image>
<view class="main" style="color:{{ controls.color }};">
<view class="title">Zijing-Marywood University</view>
<view class="title">Master of Business Administration (MBA)</view>
<view class="day">
<text class="day-num">{{ share.used_day }}</text>
<text class="day-tips">Learning Days</text>
</view>
<view class="text">{{ controls.text }}</view>
<view class="box">
<view class="course">
<view class="course-en-name">{{ share.english_course_name }}</view>
<view class="course-name">{{ share.course_name }}</view>
</view>
<view class="progress">
<view class="progress-box">
<text class="progress-num">{{ share.current_percent }}</text>
<text class="progress-unit">%</text>
</view>
<text class="progress-completed">completed</text>
</view>
</view>
<view class="box">
<view class="progress">
<view class="progress-box">
<text class="progress-num">{{ share.all_percent }}</text>
<text class="progress-unit">%</text>
</view>
<text class="progress-completed">completed</text>
</view>
<view class="course-mba">MBA Learning Achievement</view>
</view>
<view class="footer">
<image src="{{ qrcode }}" class="qrcode"></image>
<view class="qrcode-tips">Scan to learn with me</view>
</view>
</view>
</view>
</view>
<!-- 控制栏 -->
<view class="controls {{ hasControls ? 'is-show' : '' }}">
<view class="buttons">
<image
src="https://webapp-pub.ezijing.com/weapp/share/controls_up.png"
mode="aspectFill"
class="wx-image"
hidden="{{ hasControls }}"
bindtap="toggleControls"
></image>
<image
src="https://webapp-pub.ezijing.com/weapp/share/controls_down.png"
mode="aspectFill"
class="wx-image"
hidden="{{ !hasControls }}"
bindtap="toggleControls"
></image>
<view class="button">
<text>生成</text><text>海报</text>
<button class="wx-button" open-type="getUserInfo" bindtap="renderToCanvas"></button>
</view>
</view>
<view class="controls-main">
<view class="controls-tabs">
<block wx:for="{{ controlsTabs }}" wx:key="index">
<view
class="controls-tab {{ controls.active === item.index ? 'is-active' : '' }}"
data-index="{{ item.index }}"
bindtap="onTabChange"
>{{ item.text }}</view
>
</block>
</view>
<scroll-view class="controls-scroll" scroll-x="{{ true }}">
<!-- 背景 -->
<view class="controls-content" hidden="{{ controls.active !== '0' }}">
<view
class="controls-bg-item {{ controls.bg === item ? 'is-active' : '' }}"
wx:for="{{ bgList }}"
wx:key="*this"
data-item="{{ item }}"
bindtap="onSelectImage"
>
<image
src="{{ item }}?x-oss-process=image/resize,m_fill,h_162,w_92"
mode="aspectFill"
class="image"
></image>
</view>
</view>
<!-- 金句 -->
<view class="controls-content" hidden="{{ controls.active !== '1' }}">
<!-- 自定义金句 -->
<view class="custom-text-button" bindtap="showCustomText">自定义金句</view>
<view
class="controls-text-item {{ controls.text === item.text ? 'is-active' : '' }}"
wx:for="{{ textList }}"
wx:key="text"
data-item="{{ item }}"
bindtap="onSelectText"
>{{ item.text }}
<view class="custom-text-remove" data-index="{{ index }}" catchtap="onRemoveCustomText">
<van-icon name="clear" size="20" color="#d78c4a" wx:if="{{ item.isCustom }}"></van-icon>
</view>
</view>
</view>
<!-- 头像 -->
<view class="controls-content" hidden="{{ controls.active !== '2' }}">
<view
class="controls-avatar-item {{ controls.avatar === item.url ? 'is-active' : '' }}"
wx:for="{{ avatarList }}"
wx:key="url"
data-item="{{ item }}"
bindtap="onSelectAvatar"
>
<image src="{{ item.url }}" mode="aspectFill" class="image"></image>
<text class="controls-avatar-item__text">{{ item.name }}</text>
</view>
<view class="controls-avatar-item" hidden="{{ wxUserProfile.avatarUrl }}">
<text>微信</text><text>头像</text>
<button class="wx-button" open-type="getUserInfo" bindtap="getUserProfile"></button>
</view>
</view>
<!-- 颜色 -->
<view class="controls-content" hidden="{{ controls.active !== '3' }}">
<view
class="controls-color-item {{ controls.color === item ? 'is-active' : '' }}"
wx:for="{{ colorList }}"
wx:key="*this"
data-item="{{ item }}"
bindtap="onSelectColor"
style="background-color:{{ item }}"
>{{ item }}</view
>
</view>
</scroll-view>
</view>
</view>
</view>
<!-- 自定义金句 -->
<view class="custom-text" wx:if="{{ customTextVisible }}" style="bottom:{{ keyboardHeight }}px;">
<textarea
class="wx-textarea"
placeholder="输入自定义金句"
model:value="{{ customText }}"
maxlength="30"
cursor-spacing="30"
confirm-type="done"
show-confirm-bar="{{ false }}"
auto-focus="{{ true }}"
fixed="{{ true }}"
adjust-position="{{ false }}"
bindconfirm="onCustomTextConfirm"
bindblur="onCustomTextBlur"
bindkeyboardheightchange="onKeyboardheightchange"
></textarea>
</view>
<!-- 预览页面 -->
<view class="share-preivew" wx:if="{{ isPreivew }}">
<view class="close" bindtap="onClosePreview"></view>
<view class="share-preivew-main">
<wxml-to-canvas class="widget" width="300" height="530"></wxml-to-canvas>
</view>
<view class="share-preview-footer">
<view class="button button-default" bindtap="extraImage">保存图片到相册</view>
<view class="tips">分享图片到朋友圈</view>
<view class="tips">最高可获得5000朵紫荆花</view>
</view>
</view>
.share-page {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.8);
z-index: 100;
display: flex;
flex-direction: column;
}
.share-page-body {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
overflow-x: hidden;
overflow-y: auto;
}
.share {
width: 300px;
height: 530px;
position: relative;
overflow: hidden;
}
.bg {
width: 300px;
height: 530px;
}
.cover {
position: absolute;
top: 42px;
left: 24px;
width: 254px;
height: 449px;
}
.main {
position: absolute;
left: 45px;
top: 95px;
width: 210px;
color: #d78c4a;
}
.title {
text-align: center;
font-size: 10px;
font-weight: bold;
line-height: 16px;
white-space: nowrap;
}
.day {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 130px;
height: 130px;
margin: 15px auto 0;
background: url(https://webapp-pub.ezijing.com/weapp/share/marywood/roud_bg.png) no-repeat;
background-size: contain;
}
.day-num {
font-size: 48px;
line-height: 48px;
color: #f1ae2c;
}
.day-tips {
font-size: 14px;
color: #fff;
}
.text {
margin-top: 18px;
margin-bottom: 10px;
font-size: 9px;
line-height: 14px;
word-break: break-word;
overflow: hidden;
border-bottom: 1px solid #f1ae2c;
padding-bottom: 6px;
}
.box {
display: flex;
align-items: center;
}
.course {
flex: 1;
}
.course-en-name {
font-size: 12px;
line-height: 12px;
}
.course-name {
font-size: 11px;
margin-left: -6px;
}
.course-mba {
flex: 1;
font-size: 12px;
text-align: right;
}
.progress {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.progress-box {
text-align: center;
height: 30px;
overflow: hidden;
}
.progress-num {
font-style: italic;
font-size: 30px;
line-height: 1;
}
.progress-unit {
font-size: 16px;
line-height: 1;
}
.progress-completed {
font-size: 11px;
line-height: 1;
}
.footer {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 10px;
padding-top: 9px;
border-top: 1px solid #f1ae2c;
}
.qrcode {
width: 37px;
height: 37px;
border: 1px solid #1d5434;
border-radius: 2px;
}
.qrcode-tips {
margin-top: 3px;
font-size: 8px;
line-height: 10px;
text-align: center;
}
.controls {
position: relative;
padding-bottom: env(safe-area-inset-bottom);
}
.controls-main {
height: 0;
transition: height 0.3s;
overflow: hidden;
}
.controls.is-show {
background-color: #fff;
}
.controls.is-show .controls-main {
height: 130px;
}
.buttons {
position: absolute;
top: -66px;
left: 0;
right: 0;
display: flex;
justify-content: space-between;
padding: 8px 13px;
}
.button {
position: relative;
width: 50px;
height: 50px;
background: #ffffff;
box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.2);
border-radius: 50%;
font-size: 13px;
color: #d78c4a;
line-height: 15px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.wx-image {
width: 50px;
height: 50px;
}
.wx-button {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-color: transparent;
border: 0;
}
button:after {
content: none;
}
button::after {
border: none;
}
.controls-tabs {
display: flex;
height: 30px;
background: #ccc;
}
.controls-tab {
width: 75px;
line-height: 30px;
text-align: center;
background-color: #e6e6e6;
}
.controls-tab.is-active {
color: #d78c4a;
background-color: #fff;
}
.controls-content {
flex: 1;
height: 100px;
padding: 0 10px;
display: flex;
align-items: center;
flex-wrap: nowrap;
}
.controls-content .is-active {
border: 3px solid #d78c4a;
}
.controls-bg-item {
flex: 0 0 46px;
width: 46px;
height: 80px;
margin: 0 15px;
border: 3px solid #fff;
border-radius: 3px;
overflow: hidden;
}
.controls-text-item {
position: relative;
margin: 0 15px;
flex: 0 0 228px;
width: 228px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
border: 3px solid #ccc;
border-radius: 6px;
padding: 10px;
font-size: 13px;
color: #1a1a1a;
line-height: 18px;
box-sizing: border-box;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.controls-avatar-item {
position: relative;
margin: 0 15px;
flex: 0 0 60px;
width: 60px;
height: 60px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border: 3px solid #ccc;
border-radius: 50%;
overflow: hidden;
font-size: 13px;
color: #1a1a1a;
line-height: 18px;
box-sizing: border-box;
}
.controls-avatar-item__text {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: rgba(255, 255, 255, 0.6);
z-index: 1;
text-align: center;
font-size: 12px;
}
.controls-color-item {
margin: 0 15px;
flex: 0 0 68px;
width: 68px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
border: 3px solid #ccc;
border-radius: 6px;
overflow: hidden;
padding: 10px;
font-size: 13px;
color: #fff;
line-height: 18px;
box-sizing: border-box;
}
.image {
width: 100%;
height: 100%;
}
.share-preivew {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.8);
z-index: 200;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 38px 0;
}
.close {
position: absolute;
right: 8px;
top: 8px;
width: 48px;
height: 48px;
background: url('https://webapp-pub.ezijing.com/weapp/share/close.png') no-repeat;
background-size: contain;
z-index: 999;
}
.share-preivew-main {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
overflow-x: hidden;
overflow-y: auto;
}
.share-preivew .button {
width: 250px;
height: 50px;
border-radius: 25px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 18px 0;
font-size: 13px;
font-weight: 400;
color: #d78c4a;
line-height: 15px;
}
.share-preivew .button-default {
color: #d78c4a;
background: #fff;
}
.share-preivew .button-primary {
color: #fff;
background: #d78c4a;
}
.share-preivew .tips {
font-size: 13px;
font-weight: 400;
color: #fff;
line-height: 15px;
text-align: center;
}
.wx-textarea {
padding: 10px;
height: 100%;
}
.custom-text-button {
margin: 0 15px;
flex: 0 0 100px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
border: 3px solid #ccc;
border-radius: 6px;
overflow: hidden;
padding: 10px;
font-size: 13px;
color: #1a1a1a;
line-height: 18px;
box-sizing: border-box;
}
.custom-text {
position: fixed;
left: 0;
right: 0;
bottom: 0;
height: 60px;
background-color: #fff;
z-index: 100;
}
.custom-text-remove {
position: absolute;
right: -20px;
top: -20px;
padding: 10px;
}
.custom-text-remove .van-icon {
background-color: #fff;
}
const wxml = function (data) {
return `
<view class="share">
<image src="${data.controls.bg}?x-oss-process=image/resize,m_fill,h_530,w_300" class="bg"></image>
<image src="https://webapp-pub.ezijing.com/weapp/share/marywood/cover.png" class="cover"></image>
<view class="main">
<text class="title">Zijing-Marywood University</text>
<text class="title">Master of Business Administration (MBA)</text>
<view class="day">
<image src="https://webapp-pub.ezijing.com/weapp/share/marywood/roud_bg.png?x-oss-process=image/resize,m_fill,h_130,w_130" class="day-bg"></image>
<view class="day-inner">
<text class="day-num">${data.share.used_day}</text>
<text class="day-tips">Learning Days</text>
</view>
</view>
<text class="text">${data.controls.text}</text>
<view class="line"></view>
<view class="box">
<view class="course">
<text class="course-en-name">${data.share.english_course_name}</text>
<text class="course-name">${data.share.course_name}</text>
</view>
<view class="progress">
<view class="progress-box">
<text class="progress-num">${data.share.current_percent}</text>
<text class="progress-unit">%</text>
</view>
<text class="progress-completed">completed</text>
</view>
</view>
<view class="box">
<view class="progress">
<view class="progress-box">
<text class="progress-num">${data.share.all_percent}</text>
<text class="progress-unit">%</text>
</view>
<text class="progress-completed">completed</text>
</view>
<text class="course-mba">MBA Learning Achievement</text>
</view>
<view class="line"></view>
<image src="${data.qrcode}" class="qrcode"></image>
<text class="qrcode-tips">Scan to learn with me</text>
</view>
</view>`
}
const style = function (data) {
const numLength = data.share.used_day.toString().length
return {
share: {
position: 'relative',
width: 300,
height: 530
},
bg: {
width: 300,
height: 530
},
cover: {
position: 'absolute',
top: 42,
left: 24,
width: 254,
height: 449
},
main: {
position: 'absolute',
left: 45,
top: 95,
width: 210,
height: 300,
alignItems: 'center',
color: data.controls.color
},
title: {
width: 210,
textAlign: 'center',
fontSize: 10,
lineHeight: 16,
fontWeight: 'bold',
height: 16
},
day: {
position: 'relative',
width: 130,
height: 130,
marginTop: 15
},
dayBg: {
position: 'absolute',
left: 0,
right: 0,
bottom: 0,
top: 0
},
dayInner: {
position: 'absolute',
left: 0,
right: 0,
bottom: 0,
top: 0,
flexDirection: 'column',
justifyContent: 'center',
textAlign: 'center'
},
dayNum: {
height: 48,
fontSize: 48,
lineHeight: 48,
color: '#f1ae2c'
},
dayTips: {
height: 20,
fontSize: 14,
color: '#fff'
},
line: {
marginTop: 8,
width: 210,
height: 1,
backgroundColor: '#F1AE2C'
},
text: {
marginTop: 18,
width: 210,
height: 14,
fontSize: 9,
lineHeight: 14,
textAlign: 'center'
},
box: {
marginTop: 8,
width: 210,
color: data.controls.color,
flexDirection: 'row',
alignItems: 'center'
},
course: {
width: 160,
height: 40
},
courseEnName: {
height: 24,
fontSize: 12,
fontWeight: 500,
lineHeight: 12
},
courseName: {
marginLeft: -5,
marginTop: 5,
height: 11,
fontSize: 11,
fontWeight: 400,
lineHeight: 11
},
courseMba: {
width: 160,
height: 12,
fontSize: 12,
fontWeight: 500,
lineHeight: 12,
textAlign: 'right'
},
progress: {
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
width: 50,
height: 38
},
progressBox: {
flexDirection: 'row',
alignItems: 'flex-end',
width: 50,
height: 28
},
progressNum: {
width: 36,
height: 28,
fontSize: 28,
fontStyle: 'italic',
lineHeight: 28,
textAlign: 'right'
},
progressUnit: {
width: 14,
height: 14,
fontSize: 14,
lineHeight: 14
},
progressCompleted: {
marginTop: -2,
width: 50,
height: 11,
fontSize: 10,
fontWeight: 300,
lineHeight: 10,
textAlign: 'right'
},
qrcode: {
marginTop: 8,
width: 37,
height: 37,
borderRadius: 2,
backgroundColor: data.controls.color
},
qrcodeTips: {
width: 210,
height: 15,
marginTop: 3,
fontSize: 8,
color: data.controls.color,
lineHeight: 8,
textAlign: 'center'
}
}
}
export { wxml, style }
{
"name": "learn-weapp",
"version": "1.0.0",
"lockfileVersion": 1,
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "learn-weapp",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@vant/weapp": "^1.6.5",
"miniprogram-computed": "^2.2.0",
"wxml-to-canvas": "^1.1.1"
}
},
"node_modules/@vant/weapp": {
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/@vant/weapp/-/weapp-1.6.5.tgz",
"integrity": "sha512-7+oNnlLIcHSqcwtzAKSM2LM+feXyfNIEOedHn5yDumPQPyGPDmsY6x5vwZ88i+sZspfj4HmzfeljJQ/rtDT0cg=="
},
"node_modules/eventemitter3": {
"version": "4.0.7",
"resolved": "https://registry.npmmirror.com/eventemitter3/-/eventemitter3-4.0.7.tgz",
"integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw=="
},
"node_modules/fast-deep-equal": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz",
"integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk="
},
"node_modules/miniprogram-computed": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/miniprogram-computed/-/miniprogram-computed-2.2.0.tgz",
"integrity": "sha512-UlPfPh5cvBnwb2jNXToUMxNkWAmi8a7hAjtJlwdA4XF5EbFI5Q5jI9mn1U8AAxbsUfnSf1Vmsc0LhkxGdKlRkg==",
"dependencies": {
"fast-deep-equal": "^2.0.1",
"rfdc": "^1.1.4"
}
},
"node_modules/rfdc": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.2.0.tgz",
"integrity": "sha512-ijLyszTMmUrXvjSooucVQwimGUk84eRcmCuLV8Xghe3UO85mjUtRAHRyoMM6XtyqbECaXuBWx18La3523sXINA=="
},
"node_modules/widget-ui": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/widget-ui/-/widget-ui-1.0.2.tgz",
"integrity": "sha512-gDXosr5mflJdMA1weU1A47aTsTFfMJhfA4EKgO5XFebY3eVklf80KD4GODfrjo8J2WQ+9YjL1Rd9UUmKIzhShw==",
"dependencies": {
"eventemitter3": "^4.0.0"
}
},
"node_modules/wxml-to-canvas": {
"version": "1.1.1",
"resolved": "https://registry.npmmirror.com/wxml-to-canvas/-/wxml-to-canvas-1.1.1.tgz",
"integrity": "sha512-3mDjHzujY/UgdCOXij/MnmwJYerVjwkyQHMBFBE8zh89DK7h7UTzoydWFqEBjIC0rfZM+AXl5kDh9hUcsNpSmg==",
"dependencies": {
"widget-ui": "^1.0.2"
}
}
},
"dependencies": {
"@vant/weapp": {
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/@vant/weapp/-/weapp-1.6.5.tgz",
"integrity": "sha512-7+oNnlLIcHSqcwtzAKSM2LM+feXyfNIEOedHn5yDumPQPyGPDmsY6x5vwZ88i+sZspfj4HmzfeljJQ/rtDT0cg=="
},
"eventemitter3": {
"version": "4.0.7",
"resolved": "https://registry.npmmirror.com/eventemitter3/-/eventemitter3-4.0.7.tgz",
"integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw=="
},
"fast-deep-equal": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz",
......@@ -27,6 +89,22 @@
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.2.0.tgz",
"integrity": "sha512-ijLyszTMmUrXvjSooucVQwimGUk84eRcmCuLV8Xghe3UO85mjUtRAHRyoMM6XtyqbECaXuBWx18La3523sXINA=="
},
"widget-ui": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/widget-ui/-/widget-ui-1.0.2.tgz",
"integrity": "sha512-gDXosr5mflJdMA1weU1A47aTsTFfMJhfA4EKgO5XFebY3eVklf80KD4GODfrjo8J2WQ+9YjL1Rd9UUmKIzhShw==",
"requires": {
"eventemitter3": "^4.0.0"
}
},
"wxml-to-canvas": {
"version": "1.1.1",
"resolved": "https://registry.npmmirror.com/wxml-to-canvas/-/wxml-to-canvas-1.1.1.tgz",
"integrity": "sha512-3mDjHzujY/UgdCOXij/MnmwJYerVjwkyQHMBFBE8zh89DK7h7UTzoydWFqEBjIC0rfZM+AXl5kDh9hUcsNpSmg==",
"requires": {
"widget-ui": "^1.0.2"
}
}
}
}
......@@ -5,9 +5,9 @@
"main": "app.js",
"dependencies": {
"@vant/weapp": "^1.6.5",
"miniprogram-computed": "^2.2.0"
"miniprogram-computed": "^2.2.0",
"wxml-to-canvas": "^1.1.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
......
......@@ -168,6 +168,9 @@ Page({
// 更新chapter
this.updateActiveChapter(this.data.nextChapter)
}
// 分享海报
const share = this.selectComponent('.share')
share.init()
},
// 当前播放时间更新
onTimeupdate(e) {
......
......@@ -3,6 +3,7 @@
"navigationBarTitleText": "",
"usingComponents": {
"player-video": "/components/player/video",
"player-audio": "/components/player/audio"
"player-audio": "/components/player/audio",
"share": "/components/share/index"
}
}
......@@ -71,3 +71,5 @@
</van-tabs>
</view>
</view>
<!-- 分享海报 -->
<share semesterId="{{ semesterId }}" courseId="{{ courseId }}" chapterId="{{ chapterId }}" class="share"></share>
......@@ -29,7 +29,7 @@ Page({
handleRequest(params) {
api.login(params).then(response => {
const { code, msg, data } = response
code === 0 ? this.handleSuccess(data) : wx.showToast({ title: msg, icon: 'none' })
code === 0 ? this.handleSuccess(data) : this.handleError(response)
})
},
// 登录成功
......@@ -37,6 +37,20 @@ Page({
wx.setStorage({ key: 'token', data: data.TGC })
wx.switchTab({ url: '/pages/learnSystem/home/home' })
},
handleError(response) {
if (response.msg === '账号不存在') {
wx.showModal({ title: '账号不存在', content: '是否要成为学员', showCancel: true }).then(res => {
res.confirm &&
wx.navigateTo({
url: `/pages/web/index?url=${encodeURIComponent(
'https://webapp-pub.ezijing.com/pages/marywood/marywood.html?channel_num=96169'
)}`
})
})
} else {
wx.showToast({ title: response.msg, icon: 'none' })
}
},
handlePassword() {
wx.navigateTo({ url: '/pages/login/password' })
}
......
......@@ -63,22 +63,33 @@ Page({
},
// 微信登录
wechatLogin() {
// 获取code
// 获取code
const p1 = this.getCode()
// 获取用户信息
const p2 = this.getUserInfo()
Promise.all([p1, p2]).then(([code, user]) => {
const { encryptedData, iv } = user
api.wechatLogin({ encryptedData, iv, code, identity: 'marywood-mini' }).then(response => {
if (response.code === 0) {
this.handleSuccess(response.data)
} else if (response.code === 2) {
// 绑定手机号
this.setData({ show: true, unionid: response.data.unionid })
api.wechatLogin({ encryptedData, iv, code, identity: 'marywood-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 {
if (response.msg === '账号不存在') {
wx.showModal({ title: '账号不存在', content: '是否要成为学员', showCancel: true }).then(res => {
res.confirm &&
wx.navigateTo({
url: `/pages/web/index?url=${encodeURIComponent(
'https://webapp-pub.ezijing.com/pages/marywood/marywood.html?channel_num=96169'
)}`
})
})
} else {
wx.showToast({ title: response.msg, icon: 'none' })
}
})
}
})
})
},
// 手机号登录
......
......@@ -30,7 +30,7 @@ Page({
handleRequest(params) {
api.login(params).then(response => {
const { code, msg, data } = response
code === 0 ? this.handleSuccess(data) : wx.showToast({ title: msg, icon: 'none' })
code === 0 ? this.handleSuccess(data) : this.handleError(response)
})
},
// 登录成功
......@@ -38,6 +38,20 @@ Page({
wx.setStorage({ key: 'token', data: data.TGC })
wx.switchTab({ url: '/pages/learnSystem/home/home' })
},
handleError(response) {
if (response.msg === '账号不存在') {
wx.showModal({ title: '账号不存在', content: '是否要成为学员', showCancel: true }).then(res => {
res.confirm &&
wx.navigateTo({
url: `/pages/web/index?url=${encodeURIComponent(
'https://webapp-pub.ezijing.com/pages/marywood/marywood.html?channel_num=96169'
)}`
})
})
} else {
wx.showToast({ title: response.msg, icon: 'none' })
}
},
// 发送验证码
handleSendCode() {
if (this.data.disabled) {
......
// pages/share.js
Page({
/**
* 页面的初始数据
*/
data: {},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
// 分享海报
const share = this.selectComponent('.share')
share.init()
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {}
})
{
"usingComponents": {
"share": "/components/share/index"
}
}
<share semesterId="6741976022452797440" courseId="6778237795518382080" chapterId="6347105800455979008" class="share" isNeed="{{ true }}"></share>
/* pages/share.wxss */
\ No newline at end of file
// pages/web/index.js
Page({
/**
* 页面的初始数据
*/
data: {
url: 'https://webapp-pub.ezijing.com/pages/marywood/marywood.html?channel_num=96169'
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
const { url } = options
url && this.setData({ url: decodeURIComponent(url) })
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {}
})
{
"usingComponents": {}
}
\ No newline at end of file
<web-view src="{{ url }}"></web-view>
/* pages/web/index.wxss */
\ No newline at end of file
{
"description": "项目配置文件",
"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"setting": {
"urlCheck": true,
"es6": true,
......@@ -26,20 +26,22 @@
"disablePlugins": [],
"outputPath": ""
},
"bundle": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
"minifyWXSS": true,
"disableUseStrict": false,
"showES6CompileOption": false,
"useCompilerPlugins": false,
"ignoreUploadUnusedFiles": true,
"useStaticServer": true,
"minifyWXML": true
},
"compileType": "miniprogram",
"libVersion": "2.21.3",
"appid": "wx6ca59cfb726d4b14",
"projectname": "learnOnline",
"isGameTourist": false,
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
......@@ -98,5 +100,13 @@
}
]
}
},
"packOptions": {
"ignore": [],
"include": []
},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}
\ No newline at end of file
{
"setting": {},
"condition": {
"plugin": {
"list": []
},
"game": {
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"list": [
{
......@@ -77,8 +68,23 @@
"pathName": "pages/learnSystem/courseContent/courseContent",
"query": "id=6437333026132197376&sid=6552021107166150656",
"scene": null
},
{
"name": "",
"pathName": "pages/course/player",
"query": "semester_id=6828559258263486464&id=6828563846890782720&chapter_id=6828563669006155776",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/share/index",
"query": "semester_id=6828559258263486464&id=6828563846890782720&chapter_id=6828563669006155776",
"launchMode": "default",
"scene": null
}
]
}
}
},
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html"
}
\ No newline at end of file
/**
* @file 百度移动统计配置文件
*/
module.exports = {
/**
* 从百度移动统计获取的AppKey
* @type {string}
*/
appKey: '079cfa4c62',
/**
* 是否使用了插件
* @type {boolean}
*/
hasPlugin: false,
/**
* 是否获取当前的地理位置和速度信息
* @type {boolean}
*/
getLocation: false,
/**
* 是否获取组件滚动信息
* @type {boolean}
*/
getComponentScroll: false,
};
差异被折叠。
......@@ -43,11 +43,21 @@ const requestApi = obj => {
// wx.showToast({ title: JSON.stringify(res.data), icon: 'none' }) // 自己后台封装返回
// }
obj.callback(res)
} else if (res.statusCode === 403 || res.statusCode === 401) {
} else if (res.statusCode === 403) {
/* 未授权登录,跳转首页 */
wx.reLaunch({
url: '/pages/login/index'
})
} else if (res.statusCode === 401) {
wx.showModal({ title: '未授权', content: '是否要成为学员', showCancel: true }).then(res => {
res.confirm &&
wx.redirectTo({
url: `/pages/web/index?url=${encodeURIComponent(
'https://webapp-pub.ezijing.com/pages/marywood/marywood.html?channel_num=96169'
)}`
})
res.cancel && wx.reLaunch({ url: '/pages/login/index' })
})
} else {
wx.showToast({ title: res.errMsg, icon: 'none' }) // 微信封装返回
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论