Commit f8349bd3 by hank

增加视频编辑

parent d0e2b415
{
"miniprogramRoot": "dist/",
"projectname": "taroDemo",
"description": "",
"appid": "wxc3dfc37466838046",
"setting": {
"urlCheck": false,
"es6": false,
"postcss": false,
"minified": false,
"newFeature": true,
"autoAudits": false,
"checkInvalidKey": true,
"coverView": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
}
},
"compileType": "miniprogram",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {}
}
"miniprogramRoot": "dist/",
"projectname": "taroDemo",
"description": "",
"appid": "wxc3dfc37466838046",
"setting": {
"urlCheck": false,
"es6": false,
"postcss": false,
"minified": false,
"newFeature": true,
"autoAudits": false,
"checkInvalidKey": true,
"coverView": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
}
},
"compileType": "miniprogram",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {}
}
\ No newline at end of file
......@@ -37,7 +37,7 @@
}
&-intro {
font-size: 32px;
font-size: 22px;
color: #666;
margin-bottom: 38px;
}
......
......@@ -43,7 +43,7 @@
width: 100%;
font-size: 28px;
padding-top: 10px;
background-color: white;
// background-color: white;
@include eject(display, block);
@include eject(box-sizing, border-box);
......
import { ComponentClass } from 'react'
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Input, Button } from '@tarojs/components'
import { View, Text, Image, Input, Button, Video } from '@tarojs/components'
import ListItem from '../list_item'
import './index.scss'
import api from '@/api/index'
......@@ -45,9 +45,13 @@ class MenuItem extends Component {
const { setValue, schemaData } = this.props
Taro.chooseImage({ count: 1 }).then(res => {
console.log(res)
Taro.showLoading({
title: '上传中'
})
api.files
.uploadFile(res.tempFilePaths[0])
.then(result => {
Taro.hideLoading()
console.log(JSON.parse(result.data).data)
const url = JSON.parse(result.data).data
let newSchemaData = JSON.parse(JSON.stringify(schemaData))
......@@ -55,6 +59,33 @@ class MenuItem extends Component {
setValue(newSchemaData)
})
.catch(() => {
Taro.hideLoading()
Taro.showToast({
title: '上传失败',
duration: 2000
})
})
})
}
chooseVideo(dataKey) {
const { setValue, schemaData } = this.props
Taro.chooseVideo({}).then(res => {
console.log(res)
Taro.showLoading({
title: '上传中'
})
api.files
.uploadFile(res.tempFilePath)
.then(result => {
console.log(JSON.parse(result.data).data)
const url = JSON.parse(result.data).data
let newSchemaData = JSON.parse(JSON.stringify(schemaData))
newSchemaData[dataKey]['value'] = url
setValue(newSchemaData)
Taro.hideLoading()
})
.catch(() => {
Taro.hideLoading()
Taro.showToast({
title: '上传失败',
duration: 2000
......@@ -117,6 +148,19 @@ class MenuItem extends Component {
</Button>
</View>
)
} else if (item.type === 'video') {
return (
<View>
<Video src={schemaData[item.dataKey].value} />
<Button
onClick={() => {
this.chooseVideo(item.dataKey)
}}
>
上传视频
</Button>
</View>
)
} else if (item.type === 'list') {
return (
<View>
......
......@@ -46,7 +46,7 @@
font-size: 26px;
color: #333;
font-weight: bold;
background-color: white;
// background-color: white;
@include eject(display, block);
@include eject(box-sizing, border-box);
......
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 sign in to comment