Commit b4bb3893 by hank

编辑 bug 修复

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