Commit b4bb3893 by hank

编辑 bug 修复

parent c61947f5
......@@ -4,14 +4,14 @@
"description": "",
"appid": "wxc3dfc37466838046",
"setting": {
"urlCheck": true,
"urlCheck": false,
"es6": false,
"postcss": false,
"minified": false,
"newFeature": true,
"coverView": true,
"autoAudits": false,
"checkInvalidKey": true,
"coverView": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"babelSetting": {
......
......@@ -68,13 +68,19 @@ $axios.interceptors.response.use(
FetchSet.delete(config.config.FetchKey)
// token过期处理
const { data } = config
const { code } = data
const { code, msg } = data
if (code === LOGIN_0003) {
// 用户信息失效
token.reset()
Taro.navigateTo({ url: '/pages/login/index' })
}
if (!!code && code !== '0') return Promise.reject(config.data)
if (!!code && code !== '0') {
Taro.showToast({
title: msg,
duration: 2000
})
return Promise.reject(config.data)
}
return data
},
async (error: any) => {
......
......@@ -16,6 +16,13 @@ export interface IUpdateDeviceInfo {
equipmentStyle: 'CROSSWISE' | 'LENGTHWAYS'
}
export interface IUpdateFilmInfo {
filmId: string
filmData: string
filmName: string
filmDescribe: string
}
class UsersApi extends ApiClient {
/** 过去模板列表数据 */
getTempList(page: number) {
......@@ -64,6 +71,10 @@ class UsersApi extends ApiClient {
url: `/myequipment/get/details/info/${equipmentId}`
})
}
/** 更新影片数据 */
updateFilmInfo(data: IUpdateFilmInfo) {
return this.request({ url: `/template/update/film/info`, data })
}
/** 更新设备详情信息 */
updateDeviceInfo(data: IUpdateDeviceInfo) {
......@@ -95,7 +106,7 @@ class UsersApi extends ApiClient {
})
}
/** 删除设备 */
/** 删除视片 */
removeFilm(filmId: string) {
return this.request({
method: 'GET',
......
import { BASE_URL, FETCH_TIME_OUT } from '@/common'
import Taro from '@tarojs/taro'
class Files {
uploadFile(filePath) {
const params = {
url: BASE_URL + '/common/upload/resource',
name: 'resource',
filePath: filePath
}
return Taro.uploadFile(params)
}
downloadFile(params) {
return Taro.downloadFile(params)
}
}
export default new Files()
import user from './users'
import common from './common'
import files from './files'
export default {
user,
common
common,
files
}
......@@ -2,10 +2,12 @@ import { ComponentClass } from 'react'
import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import { AtAccordion, AtList } from 'taro-ui'
import MenuItem from '../menu-item'
import MenuItem from '../menu_item'
import './index.scss'
type PageStateProps = {}
type PageStateProps = {
activeIndex: number
}
type PageDispatchProps = {}
......@@ -18,7 +20,9 @@ type PageOwnProps = {
setValue: () => void
}
type PageState = {}
type PageState = {
activeIndex: number
}
type IProps = PageStateProps & PageDispatchProps & PageOwnProps
......@@ -38,9 +42,10 @@ class EditMenu extends Component {
this.handleClick = this.handleClick.bind(this)
}
handleClick(value) {
console.log(arguments)
const { activeIndex } = this.state
console.log(value, activeIndex)
this.setState({
activeIndex: value
activeIndex: value === activeIndex ? -1 : value
})
}
render() {
......@@ -48,7 +53,7 @@ class EditMenu extends Component {
const activeIndex = this.state.activeIndex
return (
<View className="edit-container">
<View className="temp-top-info">{itemList}</View>
{/* <View className="temp-top-info">{itemList}</View> */}
{itemList.map((item, index) => {
return (
<AtAccordion
......
import { ComponentClass } from 'react'
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Input, Button } from '@tarojs/components'
import api from '@/api/index'
import './index.scss'
type PageStateProps = {}
type PageDispatchProps = {}
type PageOwnProps = {
item: any
objItem: any
schemaData: object
index: number
setValue: () => void
}
type PageState = {}
type IProps = PageStateProps & PageDispatchProps & PageOwnProps
interface ListItem {
props: IProps
state: PageState
}
class ListItem extends Component {
constructor() {
super(...arguments)
this.setState({
isList: false
})
this.isSchemaIndex = this.isSchemaIndex.bind(this)
this.checkType = this.checkType.bind(this)
this.chooseImg = this.chooseImg.bind(this)
// this.inputValueChage = this.inputValueChage.bind(this)
}
isSchemaIndex(item) {
return item['schemaIndex'] ? item['schemaIndex'] : 0
}
checkType(item2, key) {
const { item } = this.props
return item.modelSchema[this.isSchemaIndex(item2)][key].type
}
chooseImg(key) {
const { setValue, schemaData, index, item } = this.props
let { objItem } = this.props
Taro.chooseImage({ count: 1 }).then(res => {
console.log(res)
api.files
.uploadFile(res.tempFilePaths[0])
.then(result => {
console.log(JSON.parse(result.data).data)
const url = JSON.parse(result.data).data
let currentSchemaData = JSON.parse(JSON.stringify(schemaData))
currentSchemaData[item.dataKey][index][key] = url
currentSchemaData.changeTime = Date.now()
objItem[key] = url
setValue(currentSchemaData)
console.log(currentSchemaData)
})
.catch(() => {
Taro.showToast({
title: '上传失败',
duration: 2000
})
})
})
}
inputValueChage(dataKey, e) {
const { setValue, schemaData } = this.props
const newSchemaData = JSON.parse(JSON.stringify(schemaData))
newSchemaData[dataKey] = e.target.value
setValue(newSchemaData)
console.log(arguments, 'inputValueChage')
}
render() {
let { objItem } = this.props
objItem = objItem || {}
console.log('list_item render')
return (
<View>
{Object.keys(objItem).map(key => {
let ele: any = null
if (key !== 'schemaIndex' && key !== 'index') {
if (this.checkType(objItem, key) === 'image') {
ele = (
<View>
<Image src={objItem[key]} />
<Button
onClick={() => {
this.chooseImg(key)
}}
>
更换图片
</Button>
</View>
)
}
if (this.checkType(objItem, key) === 'text') {
ele = (
<Input
className="menu-item-input"
value={objItem[key]}
onInput={this.inputValueChage.bind(this, key)}
/>
)
}
// ele = (
// <View>
// <View>
// 序号
// {index}
// {key}
// <Button>删除</Button>
// </View>
// </View>
// )
}
return <View key={key}>{ele}</View>
})}
</View>
)
}
}
export default ListItem as ComponentClass<PageOwnProps, PageState>
@import '@styles/var.scss';
.menu-item {
&-input {
border: 1px solid #999;
height: 40px;
margin: 10px 5px;
}
}
import { ComponentClass } from 'react'
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Input, Button } from '@tarojs/components'
import ListItem from '../list_item'
import './index.scss'
type PageStateProps = {}
......@@ -45,12 +45,13 @@ class MenuItem extends Component {
inputValueChage(dataKey, e) {
const { setValue, schemaData } = this.props
const newSchemaData = JSON.parse(JSON.stringify(schemaData))
newSchemaData[dataKey] = e.target.value
newSchemaData[dataKey]['value'] = e.target.value
setValue(newSchemaData)
console.log(arguments, 'inputValueChage')
}
render() {
const { item, schemaData } = this.props
const { schemaData, setValue } = this.props
let { item } = this.props
item = item || {
type: ''
}
......@@ -73,45 +74,16 @@ class MenuItem extends Component {
return (
<View>
{schemaData[item.dataKey].map((item2, index) => {
const item2Back = item2
// const item2Back = item2
return (
<View key={index + 123}>
{Object.keys(item2).map(key => {
// const newKey = key
return key !== 'schemaIndex' && key !== 'index' ? (
<View key={key}>
<View>
序号
{index}
{key}
<Button>删除</Button>
</View>
{/* <View>{this.checkType(item2Back, newKey)}</View> */}
{/* <View>
{item.modelSchema[this.isSchemaIndex(item2)][key].type === 'text' ? (
<Input className="menu-item-input" value={item2[key]} />
) : null}
</View> */}
{/* item.modelSchema[this.isSchemaIndex(item2)][key].type ? (
<View>
<Image src={item2[key]} />
<Button>上传图片</Button>
</View>
) : null */}
{/* <MenuItem
item={item.modelSchema[this.isSchemaIndex(item2)][key]}
schemaData={schemaData}
isList={false}
/> */}
</View>
) : (
''
)
// if () {
// } else {
// return <View key={key}>121321</View>
// }
})}
<View key={item.dataKey}>
<ListItem
item={item}
objItem={item2}
schemaData={schemaData}
setValue={setValue}
index={index}
/>
</View>
)
})}
......
import { ComponentClass } from 'react'
import Taro, { Component, Config } from '@tarojs/taro'
import { View, Text, ScrollView, Button, Image } from '@tarojs/components'
import { View, Text, ScrollView, Button, Image, Input } from '@tarojs/components'
import EditMenu from './conpoments/edit_menu'
import './scss/film_edit.scss'
......@@ -16,9 +16,10 @@ type PageState = {
page: number
count: number
filmInfo: any
pageIndex: any
filmId: string
filmData: any
pageIndex: number
pageInfo: {}
}
type IProps = PageStateProps & PageDispatchProps & PageOwnProps
......@@ -34,17 +35,21 @@ class FilmDetail extends Component {
}
constructor() {
super()
super(...arguments)
const filmId = this.$router.params.filmId || '32263ed8295746c99ab66282c26fbc65'
this.state = {
filmId,
page: 1,
page: 0,
count: 0,
pageIndex: 0,
filmInfo: {},
filmData: {}
filmData: {},
pageInfo: {
pageIndex: 0
}
}
this.setValue = this.setValue.bind(this)
this.updateFilm = this.updateFilm.bind(this)
}
componentWillMount() {
......@@ -58,9 +63,9 @@ class FilmDetail extends Component {
console.log({ filmInfo })
const { list, count } = filmInfo
const filmData =
JSON.parse(filmInfo.filmData) && JSON.parse(filmInfo.filmData).pageList
? JSON.parse(filmInfo.filmData).pageList
: []
JSON.parse(filmInfo.filmData) && JSON.parse(filmInfo.filmData)
? JSON.parse(filmInfo.filmData)
: {}
this.setState({
count,
filmInfo,
......@@ -71,26 +76,70 @@ class FilmDetail extends Component {
}
}
changePage(index) {
console.log(index, 'changePage')
const pageIndex = index
this.setState({
pageIndex: index
filmInfo: {
filmName: this.state.filmInfo.filmName,
filmDescribe: this.state.filmInfo.filmDescribe
},
pageIndex: pageIndex
})
}
updateFilm() {
const { filmDescribe, filmId, filmName } = this.state.filmInfo
console.log(filmId, 'filmId', this.state.filmInfo)
let filmDatas = JSON.parse(JSON.stringify(this.state.filmData))
// filmDatas.pageList = this.state.filmData.pageList
api.common
.updateFilmInfo({
filmDescribe,
filmId: this.$router.params.filmId,
filmName,
filmData: JSON.stringify(filmDatas)
})
.then(() => {
Taro.showToast({
title: '成功',
icon: 'success',
duration: 1000
})
Taro.navigateBack()
})
}
setValue(schemaData) {
const currentData = this.state.filmData
currentData[this.state.pageIndex] = schemaData
let currentData = JSON.parse(JSON.stringify(this.state.filmData))
JSON.parse(JSON.stringify(this.state.filmData))
currentData.pageList[this.state.pageIndex].schemaData = schemaData
console.log(schemaData)
this.setState({
filmData: currentData
filmData: currentData,
filmInfo: {
filmName: this.state.filmInfo.filmName,
filmDescribe: this.state.filmInfo.filmDescribe
}
})
}
changeFilmName = ({ target }) => {
const { value } = target
this.setState({ createFilmName: value })
console.log(this.state.filmData)
this.setState({
filmInfo: {
filmName: value,
filmDescribe: this.state.filmInfo.filmDescribe
}
})
}
changeDescribeName = ({ target }) => {
const { value } = target
this.setState({ createFilmDescribe: value })
this.setState({
filmInfo: {
filmDescribe: value,
filmName: this.state.filmInfo.filmName
}
})
}
shouldComponentUpdate(_nextProps: IProps, _nextState: PageState) {
const { filmInfo } = this.state
......@@ -102,6 +151,8 @@ class FilmDetail extends Component {
const { filmInfo, filmData, pageIndex } = this.state
filmInfo.templateName = filmInfo.filmName
filmInfo.templateDescribe = filmInfo.filmDescribe
const pageList = filmData.pageList
console.log('film-edit render')
return (
<View className="film-detail">
<View className="film-detail-scroll">
......@@ -117,16 +168,22 @@ class FilmDetail extends Component {
<Input
placeholder="请输入视片描述"
className="film-info-input"
value={filmInfo.filmName}
value={filmInfo.filmDescribe}
onInput={this.changeDescribeName}
/>
</View>
<ScrollView className="film-detail-scroll-view" scrollX>
<View className="page-container">
{filmData.map((item, index) => {
{pageList.map((item, index) => {
// const name = item.name
return (
<View key={index} className="page-item">
<View
key={index + item.name}
className="page-item"
onClick={() => {
this.changePage(index)
}}
>
<Image src={item.thumb} className="page-thumb" />
<View>{item.name}</View>
</View>
......@@ -134,14 +191,15 @@ class FilmDetail extends Component {
})}
</View>
</ScrollView>
{filmData[pageIndex]}
<EditMenu {...filmData[pageIndex]} setValue={this.setValue} />
{/* {filmData[pageIndex]} */}
{pageIndex}
<EditMenu {...pageList[pageIndex]} setValue={this.setValue} />
</View>
<View className="film-detail-bottom-bar">
<Button type="primary" className="film-detail-bottom-bar-btn">
预览视片
</Button>
<Button type="primary" className="film-detail-bottom-bar-btn">
<Button type="primary" className="film-detail-bottom-bar-btn" onClick={this.updateFilm}>
更改并同步到设备
</Button>
</View>
......
......@@ -4,6 +4,8 @@ import Modal from '@/conpoments/modal'
import { ComponentClass } from 'react'
import Taro, { Component, Config } from '@tarojs/taro'
import { View, Text, ScrollView, Input, Button } from '@tarojs/components'
import { connect } from '@tarojs/redux'
import { getFilmList } from '@/actions/asyncCounter'
import './index.scss'
import { showMyToast } from '@/common/utils'
......@@ -15,9 +17,14 @@ export interface IWifiListItem {
type: 'OPEN' | 'WPA' | 'WPA_EAP'
}
type PageStateProps = {}
type PageStateProps = {
list: any[]
count: number
}
type PageDispatchProps = {}
type PageDispatchProps = {
getFilmListData: (page: number) => void
}
type PageOwnProps = {}
......@@ -33,6 +40,17 @@ interface WifiList {
state: PageState
}
@connect(
({ counter }) => {
const { list, count } = counter.filmData
return { list, count }
},
dispacth => ({
getFilmListData(page: number) {
dispacth(getFilmList(page))
}
})
)
class WifiList extends Component {
config: Config = {
navigationBarTitleText: 'WLAN'
......@@ -116,6 +134,7 @@ class WifiList extends Component {
equipmentWifiIdentity: '',
equipmentWifiPassword: password
})
console.log(this.props.getFilmListData(1), this.props)
showMyToast({ title: '设备添加成功~' })
Taro.redirectTo({ url: `/pages/home/device/device_detail/index?equipmentId=${equipmentId}` })
} catch (error) {
......
{
"extends": ["tslint:recommended", "tslint-react"],
"rules": {
"prefer-const": false,
"arrow-parens": false,
"arrow-return-shorthand": [false],
"comment-format": [true, "check-space"],
......
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