Commit 1184ae28 authored by jyx's avatar jyx

代码优化

parent 02933f38
<script> <script>
import checkUpdate from './utils/update.js'; import checkUpdate from './utils/update.js';
// #ifdef MP-WEIXIN
const playletPlugin = requirePlugin('playlet-plugin')
const PlayerManager = require('@/common/util/playManager.js')
// #endif
export default { export default {
onLoad() {
// #ifdef MP-WEIXIN
playletPlugin.onPageLoad(this._onPlayerLoad.bind(this))
playletPlugin.getShareParams().then(res => {
//关于extParam的处理,需要先做decodeURIComponent之后才能得到原值
const extParam = decodeURIComponent(res.extParam)
// 如果设置了withShareTicket为true,可通过文档的方法获取更多信息
// https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html
const enterOptions = wx.getEnterOptionsSync()
}).catch(err => {
console.log('getLaunch options query err-app-vue', err)
})
// #endif
},
onLaunch: function(options) { onLaunch: function(options) {
// #ifdef APP-PLUS // #ifdef APP-PLUS
//设置2.4秒后主动关闭,最多设置6秒 //设置2.4秒后主动关闭,最多设置6秒
...@@ -42,21 +62,12 @@ ...@@ -42,21 +62,12 @@
} }
// checkUpdate(this); // checkUpdate(this);
},
// #ifdef H5 _onPlayerLoad(info) {
if (window.location.host === 'www.baosheji.cn') { console.log('App-onPlayerLoad', info.playerId, info)
var icp = document.createElement('div'); // #ifdef MP-WEIXIN
icp.innerText = '京ICP备18032652号'; const playerManager = new PlayerManager()
icp.style.color = 'white'; playerManager._onPlayerLoad(info)
icp.style.textAlign = 'center';
icp.style.position = 'fixed';
icp.style.bottom = '0';
icp.style.left = '0';
icp.style.right = '0';
icp.style.zIndex = '100';
document.body.appendChild(icp);
}
// #endif // #endif
}, },
onShow: function(options) { onShow: function(options) {
...@@ -77,8 +88,6 @@ ...@@ -77,8 +88,6 @@
bottomSafePadding: 12, bottomSafePadding: 12,
h5Url: 'https://api.mints-id.com/index.html', h5Url: 'https://api.mints-id.com/index.html',
baseUrl: 'https://api.mints-tech.cn/camera-api/miniApi', baseUrl: 'https://api.mints-tech.cn/camera-api/miniApi',
// baseUrl: 'http://test.mints-id.com/camera-api/miniApi',
// baseUrl: 'http://192.168.110.71:8301/miniApi',
titleButtonWidth: 38, titleButtonWidth: 38,
token: '', token: '',
userId: 0, userId: 0,
......
{
"version" : "1",
"prompt" : "template",
"title" : "服务协议和隐私政策",
"message" : "请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了更好的向你提供服务,我们需要收集你的设备标识、操作日志等信息用于分析、优化应用性能。<br/>  你可阅读<a href=\"https://shimo.im/docs/dPkpKL1EVNIBbXqO\">《用户协议》</a>和<a href=\"https://shimo.im/docs/aBAYVY4mNXfgLm3j\">《隐私政策》</a>了解详细信息。如果你同意,请点击下面按钮开始接受我们的服务。",
"buttonAccept" : "同意并接受",
"buttonRefuse" : "暂不同意",
"second" : {
"title" : "确认提示",
"message" : "进入应用前,你需先同意<a href=\"https://shimo.im/docs/dPkpKL1EVNIBbXqO\">《用户协议》</a>和<a href=\"https://shimo.im/docs/aBAYVY4mNXfgLm3j\">《隐私政策》</a>,否则将退出应用。",
"buttonAccept" : "同意并继续",
"buttonRefuse" : "退出应用"
},
"styles" : {
"backgroundColor" : "#ffffff",
"borderRadius" : "5px",
"title" : {
"color" : "#008cfb"
},
"buttonAccept" : {
"color" : "#008cfb"
},
"buttonRefuse" : {
"color" : "#c0c0c0"
}
}
}
var plugin = requirePlugin("playlet-plugin");
// 点击按钮触发此函数跳转到播放器页面
function navigateToPlayer(obj) {
// 下面的${dramaId}变量,需要替换成小程序管理后台的媒资管理上传的剧目的dramaId,变量${srcAppid}是提审方appid,变量${serialNo}是某一集,变量${extParam}是扩展字段,可通过
const {
extParam,
dramaId,
srcAppid,
serialNo
} = obj
wx.navigateTo({
url: `plugin-private://wx94a6522b1d640c3b/pages/playlet/playlet?dramaId=${dramaId}&srcAppid=${srcAppid}&serialNo=${serialNo}&extParam=${extParam || ''}`
})
}
const proto = {
_onPlayerLoad(info) {
const pm = plugin.PlayletManager.getPageManager(info.playerId)
this.pm = pm
// encryptedData是经过开发者后台加密后(不要在前端加密)的数据,具体实现见下面的加密章节
this.getEncryptData({
serialNo: info.serialNo
}).then(res => {
// encryptedData是后台加密后的数据,具体实现见下面的加密章节
pm.setCanPlaySerialList({
data: res.encryptedData,
freeList: [{
start_serial_no: 1,
end_serial_no: 10
}], // 1~10集是免费剧集
})
})
pm.onCheckIsCanPlay(this.onCheckIsCanPlay)
// 关于分享的处理
// 开启分享以及withShareTicket
pm.setDramaFlag({
share: true,
withShareTicket: true
})
// 获取分享参数,页面栈只有短剧播放器一个页面的时候可获取到此参数
// 例如从分享卡片进入、从投流广告直接跳转到播放器页面,从二维码直接进入播放器页面等情况
plugin.getShareParams().then(res => {
console.log('getLaunch options query res', res)
// 关于extParam的处理,需要先做decodeURIComponent之后才能得到原值
const extParam = decodeURIComponent(res.extParam)
console.log('getLaunch options extParam', extParam)
// 如果设置了withShareTicket为true,可通过文档的方法获取更多信息
// https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html
const enterOptions = wx.getEnterOptionsSync()
console.log('getLaunch options shareTicket', enterOptions.shareTicket)
}).catch(err => {
console.log('getLaunch options query err', err)
})
// extParam除了可以通过在path传参,还可以通过下面的接口设置
pm.setExtParam('hellotest')
// 分享部分end
},
onCheckIsCanPlay(param) {
// TODO: 碰到不可以解锁的剧集,会触发此事件,这里可以进行扣币解锁逻辑,如果用户无足够的币,可调用下面的this.isCanPlay设置
console.log('onCheckIsCanPlay param', param)
var serialNo = param.serialNo
this.getEncryptData({
serialNo: serialNo
}).then(res => {
// encryptedData是后台加密后的数据,具体实现见下面的加密章节
this.pm.isCanPlay({
data: res.encryptedData,
serialNo: serialNo,
})
})
},
getEncryptData(obj) {
const {
serialNo
} = obj
// TODO: 此接口请求后台,返回下面的setCanPlaySerialList接口需要的加密参数
const {
srcAppid,
dramaId
} = this.pm.getInfo()
console.log('getEncryptData start', srcAppid, dramaId, serialNo)
return new Promise((resolve, reject) => {
resolve({
encryptedData: '' // TODO: 此参数需从后台接口获取到
})
})
},
}
function PlayerManager() {
var newProto = Object.assign({}, proto)
for (const k in newProto) {
if (typeof newProto[k] === 'function') {
this[k] = newProto[k].bind(this)
}
}
}
PlayerManager.navigateToPlayer = navigateToPlayer
module.exports = PlayerManager
\ No newline at end of file
<template>
<view class="divider flex"><slot></slot></view>
</template>
<script>
export default {
name: 'Divider'
};
</script>
<style lang="scss">
@import '@/scss/uni.scss';
.divider {
font-size: 24rpx;
color: #868686;
&::before,
&::after {
content: '';
background-color: #868686;
height: 1rpx;
flex: 1;
}
&::before {
margin-right: 28rpx;
}
&::after {
margin-left: 28rpx;
}
}
</style>
<template>
<view class="number-box">
<view @click="_calcValue('minus')" class="number-box-btns" :class="{ 'number-box-disabled': inputValue <= min || disabled }">
<icons icon="minus" :color="inputValue <= min || disabled ? '#868686' : '#299FEF'" size="40" />
</view>
<input :disabled="disabled" @focus="_onFocus" @blur="_onBlur" class="number-box-input" type="number" v-model="inputValue" />
<view @click="_calcValue('plus')" class="number-box-btns"><icons icon="plus" :color="inputValue >= max || disabled ? '#868686' : '#299FEF'" size="40" /></view>
</view>
</template>
<script>
/**
* NumberBox 数字输入框
* @description 带加减按钮的数字输入框
* @tutorial https://ext.dcloud.net.cn/plugin?id=31
* @property {Number} value 输入框当前值
* @property {Number} min 最小值
* @property {Number} max 最大值
* @property {Number} step 每次点击改变的间隔大小
* @property {String} color 字体颜色(前景色)
* @property {Boolean} disabled = [true|false] 是否为禁用状态
* @event {Function} change 输入框值改变时触发的事件,参数为输入框当前的 value
* @event {Function} focus 输入框聚焦时触发的事件,参数为 event 对象
* @event {Function} blur 输入框失焦时触发的事件,参数为 event 对象
*/
export default {
name: 'NumberBox',
emits: ['change', 'input', 'update:modelValue', 'blur', 'focus'],
props: {
value: {
type: [Number, String],
default: 1
},
modelValue: {
type: [Number, String],
default: 1
},
min: {
type: Number,
default: 0
},
max: {
type: Number,
default: 100
},
step: {
type: Number,
default: 1
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
inputValue: 0
};
},
watch: {
value(val) {
this.inputValue = +val;
},
modelValue(val) {
this.inputValue = +val;
}
},
created() {
if (this.value === 1) {
this.inputValue = +this.modelValue;
}
if (this.modelValue === 1) {
this.inputValue = +this.value;
}
},
methods: {
_calcValue(type) {
if (this.disabled) {
return;
}
const scale = this._getDecimalScale();
let value = this.inputValue * scale;
let step = this.step * scale;
if (type === 'minus') {
value -= step;
if (value < this.min * scale) {
return;
}
if (value > this.max * scale) {
value = this.max * scale;
}
}
if (type === 'plus') {
value += step;
if (value > this.max * scale) {
return;
}
if (value < this.min * scale) {
value = this.min * scale;
}
}
this.inputValue = (value / scale).toFixed(String(scale).length - 1);
this.$emit('change', +this.inputValue);
// TODO vue2 兼容
this.$emit('input', +this.inputValue);
// TODO vue3 兼容
this.$emit('update:modelValue', +this.inputValue);
},
_getDecimalScale() {
let scale = 1;
// 浮点型
if (~~this.step !== this.step) {
scale = Math.pow(10, String(this.step).split('.')[1].length);
}
return scale;
},
_onBlur(event) {
this.$emit('blur', event);
let value = event.detail.value;
if (!value) {
// this.inputValue = 0;
return;
}
value = +value;
if (value > this.max) {
value = this.max;
} else if (value < this.min) {
value = this.min;
}
const scale = this._getDecimalScale();
this.inputValue = value.toFixed(String(scale).length - 1);
this.$emit('change', +this.inputValue);
this.$emit('input', +this.inputValue);
},
_onFocus(event) {
this.$emit('focus', event);
}
}
};
</script>
<style lang="scss">
.number-box {
display: inline-flex;
align-items: center;
margin-right: -16rpx;
&-btns {
line-height: 1;
vertical-align: bottom;
display: inline-block;
padding: 16rpx;
cursor: pointer;
}
&-input {
margin: 0 4rpx;
width: 50rpx;
text-align: center;
color: black;
}
}
</style>
<template>
<view>
<button
class="reset-button button"
@click="onClick"
hover-class="button-hover"
:class="[shape == 'circle' ? 'round-circle' : '']"
>
<slot></slot>
</button>
</view>
</template>
<script>
/**
* m-field button 按钮组件
* @description 常用按钮组件。
* @tutorial https://ui.ymeoo.cn
* @property {String} color 按钮主题色
* @property {String} shape 设置为circle,则按钮两边为半圆形
* @event {Function} click 组件自定义点击事件
* @example <u-form-item label="姓名"><u-input v-model="form.name" /></u-form-item>
*/
export default {
name: 'q-button',
props: {
shape: {
type: String,
default: 'circle'
}
},
data() {
return {};
},
methods: {
onClick() {
this.$emit('click', '');
}
}
};
</script>
<style lang="scss" scoped>
// 去除button的所有默认样式
.reset-button {
padding: 0;
font-size: inherit;
line-height: inherit;
background-color: transparent;
color: inherit;
}
.reset-button::after {
border: none;
}
// button样式
.button {
display: block;
padding: 20rpx;
margin: 20rpx;
background-image: -moz-linear-gradient(135deg, rgb(0, 255, 255), rgb(29, 147, 251));
background-image: -webkit-linear-gradient(135deg, rgb(0, 255, 255), rgb(29, 147, 251));
background-image: linear-gradient(135deg, rgb(0, 255, 255), rgb(29, 147, 251));
color: #fff;
}
.button-hover {
background-color: #f5f5f5 !important;
}
.round-circle {
border-radius: 100rpx;
}
</style>
This diff is collapsed.
{ {
"uni-app": { "uni-app": {
"scripts": { "scripts": {}
"mp-dingtalk": {
"title": "钉钉小程序",
"env": {
"UNI_PLATFORM": "mp-alipay"
},
"define": {
"MP-DINGTALK": true
}
},
"mp-weixin-test": {
"title": "本地测试版本",
"env": {
"UNI_PLATFORM": "mp-weixin"
},
"define": {
"MP-APP-TEST": true
}
},
"mp-app-test": {
"title": "App 本地测试版本",
"env": {
"UNI_PLATFORM": "mp-weixin"
},
"define": {
"MP-APP-TEST": true
}
}
}
}, },
"dependencies": { "dependencies": {
"uview": "^0.1.0" "uview": "^0.1.0"
......
...@@ -10,124 +10,53 @@ ...@@ -10,124 +10,53 @@
"pages": [ "pages": [
// #ifndef APP-PLUS // #ifndef APP-PLUS
{ {
"path": "pages/loading", "path": "pages/loading"
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black" //用于配置状态栏的字体颜色
}
}, },
// #endif // #endif
{ {
"path": "pages/home", "path": "pages/home"
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
}
}, { }, {
"path": "pages/index/index", "path": "pages/index/index"
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/my/my",
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black" //用于配置状态栏的字体颜色
}
}, { }, {
"path": "pages/brower/brower", "path": "pages/my/my"
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
}
}, { }, {
"path": "pages/recommend/recommend", "path": "pages/brower/brower"
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
}
}, { }, {
"path": "pages/recommend/follow", "path": "pages/recommend/recommend"
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
}
}, { }, {
"path": "pages/recommend/recommendVideo", "path": "pages/recommend/follow"
"style": { }, {
"navigationStyle": "custom", "path": "pages/recommend/recommendVideo"
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
}
} }
], ],
// 分包配置 // 分包配置
"subPackages": [{ "subPackages": [{
"root": "pagesA", "root": "pagesA",
"pages": [{ "pages": [{
"path": "vipPay/vipPay", "path": "vipPay/vipPay"
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
}
}] }]
}, { }, {
"root": "pagesC", "root": "pagesC",
"pages": [{ "pages": [{
"path": "video/videoDetail", "path": "video/newVideoDetail"
"style": { },
"navigationStyle": "custom", {
"navigationBarBackgroundColor": "#2196f3", "path" : "playlet/playlet",
"navigationBarTextStyle": "black" "style" :
} {
}, { "navigationBarTitleText" : ""
"path": "video/newVideoDetail",
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
} }
}] }]
}, { }, {
"root": "pagesD", "root": "pagesD",
"pages": [{ "pages": [{
"path": "watchRecord/watchRecord", "path": "watchRecord/watchRecord"
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black" //用于配置状态栏的字体颜色
}
}, { }, {
"path": "payRecord/payRecord", "path": "payRecord/payRecord"
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
}
}, { }, {
"path": "dotRecord/dotRecord", "path": "dotRecord/dotRecord"
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
}
}, { }, {
"path": "useDotRecord/useDotRecord", "path": "useDotRecord/useDotRecord"
"style": {
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
}
}] }]
}], }],
// 分包预载配置 // 分包预载配置
...@@ -149,6 +78,9 @@ ...@@ -149,6 +78,9 @@
"globalStyle": { "globalStyle": {
"backgroundColor": "#232325", "backgroundColor": "#232325",
"navigationStyle": "custom", "navigationStyle": "custom",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black", //用于配置状态栏的字体颜色
"navigationStyle": "custom",
"app-plus": { "app-plus": {
"bounce": "none", "bounce": "none",
"scrollIndicator": "none" "scrollIndicator": "none"
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment