Commit e792dd3f by hank

bug

parent daec53ea
...@@ -21,7 +21,7 @@ export function getDeviceList(page: number, showTemplate: string = '') { ...@@ -21,7 +21,7 @@ export function getDeviceList(page: number, showTemplate: string = '') {
return async (dispatch, state) => { return async (dispatch, state) => {
const oldState = state().counter const oldState = state().counter
try { try {
let { list, count } = await api.common.getMyFilmsList(page) let { list, count } = await api.common.getMyFilmsList(page, showTemplate)
if (page !== 1 && oldState.deviceData) { if (page !== 1 && oldState.deviceData) {
list = [...oldState.deviceData.list, ...list] list = [...oldState.deviceData.list, ...list]
} }
......
...@@ -25,6 +25,14 @@ export interface IUpdateFilmInfo { ...@@ -25,6 +25,14 @@ export interface IUpdateFilmInfo {
filmName: string filmName: string
filmDescribe: string filmDescribe: string
} }
export interface IUpdateScheduleInfo {
calendarName?: string
filmInfos: any[]
equipmentsIds: any[]
equipmentTopicList: any[]
calendarType?: string
calendarId?: string
}
class UsersApi extends ApiClient { class UsersApi extends ApiClient {
/** 过去模板列表数据 */ /** 过去模板列表数据 */
...@@ -69,8 +77,11 @@ class UsersApi extends ApiClient { ...@@ -69,8 +77,11 @@ class UsersApi extends ApiClient {
} }
/** 获取我的视片列表 */ /** 获取我的视片列表 */
getMyFilmsList(page: number) { getMyFilmsList(page: number, templateShow: string) {
return this.request({ url: `/myfilm/get/list?p=${page}&c=10`, data: { p: page, c: 10 } }) return this.request({
url: `/myfilm/get/list?p=${page}&c=10`,
data: { p: page, c: 10, templateShow }
})
} }
/** 获取我商城设备列表 */ /** 获取我商城设备列表 */
...@@ -180,10 +191,43 @@ class UsersApi extends ApiClient { ...@@ -180,10 +191,43 @@ class UsersApi extends ApiClient {
}) })
} }
/** 获取日程列表 */ /** 获取日程列表 */
getScheduleList(page: number = 1, limit: number = 10) { getScheduleList(page: number = 1, limit: number = 10, calendarType: string = 'CUSTOME') {
return this.request({
method: 'post',
url: `/calendar/get/list?p=${page}&c=${limit}`,
data: {
calendarType: calendarType
}
})
}
/** 创建日程 */
createSchedule(data: IUpdateScheduleInfo) {
return this.request({
method: 'post',
url: `/calendar/add/info`,
data
})
}
/** 更新日程 */
updateSchedule(data: IUpdateScheduleInfo) {
return this.request({
method: 'post',
url: `/calendar/update/info`,
data
})
}
// 获取日程详情
getScheduleDetail(id) {
return this.request({
method: 'get',
url: `/calendar/get/info/${id}`
})
}
deleteSchedule(id) {
return this.request({ return this.request({
method: 'post', method: 'post',
url: `/myfilm/get/list?p=${page}&c=${limit}` url: `/calendar/del/info/${id}`
}) })
} }
} }
......
...@@ -17,7 +17,7 @@ type PageStateProps = { ...@@ -17,7 +17,7 @@ type PageStateProps = {
} }
type PageDispatchProps = { type PageDispatchProps = {
getDeviceListData: (page: number) => void getDeviceListData: (page: number, showTemplate: string) => void
} }
type PageOwnProps = { type PageOwnProps = {
...@@ -32,7 +32,7 @@ export interface IMilmListItme { ...@@ -32,7 +32,7 @@ export interface IMilmListItme {
} }
interface PageState { interface PageState {
showTempalte: string showTemplate: string
} }
type IProps = PageStateProps & PageDispatchProps & PageOwnProps type IProps = PageStateProps & PageDispatchProps & PageOwnProps
...@@ -48,8 +48,8 @@ interface Films { ...@@ -48,8 +48,8 @@ interface Films {
return { list, count } return { list, count }
}, },
dispacth => ({ dispacth => ({
getDeviceListData(page: number) { getDeviceListData(page: number, showTemplate: string) {
dispacth(getDeviceList(page)) dispacth(getDeviceList(page, showTemplate))
} }
}) })
) )
...@@ -63,7 +63,8 @@ class Films extends Component { ...@@ -63,7 +63,8 @@ class Films extends Component {
this.getData() this.getData()
} }
async getData() { async getData() {
this.props.getDeviceListData(this.page) const { showTemplate } = this.state
this.props.getDeviceListData(this.page, showTemplate)
} }
async handleItem({ filmId }: IMilmListItme) { async handleItem({ filmId }: IMilmListItme) {
...@@ -81,9 +82,15 @@ class Films extends Component { ...@@ -81,9 +82,15 @@ class Films extends Component {
}) })
} }
typeChange(value) { typeChange(value) {
this.setState({ this.setState(
showTempalte: value {
}) showTemplate: value
},
() => {
this.page = 1
this.getData()
}
)
} }
goDetail({ filmId }: IMilmListItme) { goDetail({ filmId }: IMilmListItme) {
...@@ -106,15 +113,15 @@ class Films extends Component { ...@@ -106,15 +113,15 @@ class Films extends Component {
shouldComponentUpdate(nextProps: IProps) { shouldComponentUpdate(nextProps: IProps) {
const { list } = this.props const { list } = this.props
const { showTempalte } = this.state const { showTemplate } = this.state
const { list: _list } = nextProps const { list: _list } = nextProps
return list !== _list || !!showTempalte return list !== _list || !!showTemplate
} }
render() { render() {
const { list, height, count } = this.props const { list, height, count } = this.props
let { showTempalte } = this.state let { showTemplate } = this.state
showTempalte = showTempalte || 'HORIZONTAL' showTemplate = showTemplate || 'HORIZONTAL'
return ( return (
<View className="films"> <View className="films">
<View className="film-search-bar"> <View className="film-search-bar">
...@@ -124,7 +131,7 @@ class Films extends Component { ...@@ -124,7 +131,7 @@ class Films extends Component {
this.typeChange('HORIZONTAL') this.typeChange('HORIZONTAL')
}} }}
className={ className={
showTempalte === 'HORIZONTAL' showTemplate === 'HORIZONTAL'
? 'type-tab-item type-tab-item-active' ? 'type-tab-item type-tab-item-active'
: 'type-tab-item' : 'type-tab-item'
} }
...@@ -136,7 +143,7 @@ class Films extends Component { ...@@ -136,7 +143,7 @@ class Films extends Component {
this.typeChange('VERTICAL') this.typeChange('VERTICAL')
}} }}
className={ className={
showTempalte === 'VERTICAL' ? 'type-tab-item type-tab-item-active' : 'type-tab-item' showTemplate === 'VERTICAL' ? 'type-tab-item type-tab-item-active' : 'type-tab-item'
} }
> >
竖版 竖版
...@@ -146,7 +153,7 @@ class Films extends Component { ...@@ -146,7 +153,7 @@ class Films extends Component {
this.typeChange('OTHER') this.typeChange('OTHER')
}} }}
className={ className={
showTempalte === 'OTHER' ? 'type-tab-item type-tab-item-active' : 'type-tab-item' showTemplate === 'OTHER' ? 'type-tab-item type-tab-item-active' : 'type-tab-item'
} }
> >
异形屏 异形屏
......
...@@ -5,6 +5,8 @@ import { AtTabs, AtTabsPane } from 'taro-ui' ...@@ -5,6 +5,8 @@ import { AtTabs, AtTabsPane } from 'taro-ui'
import Taro, { Component, Config } from '@tarojs/taro' import Taro, { Component, Config } from '@tarojs/taro'
import './index.scss' import './index.scss'
import 'taro-ui/dist/style/components/list.scss'
import 'taro-ui/dist/style/components/icon.scss'
import { View } from '@tarojs/components' import { View } from '@tarojs/components'
type PageStateProps = {} type PageStateProps = {}
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
} }
.enter { .enter {
position: absolute; position: fixed;
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
...@@ -58,6 +58,6 @@ ...@@ -58,6 +58,6 @@
} }
.scroll-view { .scroll-view {
height: 100%; height: 90%;
} }
} }
...@@ -16,7 +16,7 @@ type PageStateProps = { ...@@ -16,7 +16,7 @@ type PageStateProps = {
} }
type PageDispatchProps = { type PageDispatchProps = {
getDeviceListData: (page: number) => void getDeviceListData: (page: number, showTemplate: string) => void
} }
type PageOwnProps = { type PageOwnProps = {
...@@ -32,7 +32,7 @@ export interface IMilmListItme { ...@@ -32,7 +32,7 @@ export interface IMilmListItme {
interface PageState { interface PageState {
checked: Set<string> checked: Set<string>
showTempalte: string showTemplate: string
} }
type IProps = PageStateProps & PageDispatchProps & PageOwnProps type IProps = PageStateProps & PageDispatchProps & PageOwnProps
...@@ -48,8 +48,8 @@ interface Films { ...@@ -48,8 +48,8 @@ interface Films {
return { list, count } return { list, count }
}, },
dispacth => ({ dispacth => ({
getDeviceListData(page: number) { getDeviceListData(page: number, showTemplate: string) {
dispacth(getDeviceList(page)) dispacth(getDeviceList(page, showTemplate))
} }
}) })
) )
...@@ -64,7 +64,7 @@ class Films extends Component { ...@@ -64,7 +64,7 @@ class Films extends Component {
// 判断缓存数据是否存在 // 判断缓存数据是否存在
this.setState({ this.setState({
checked: new Set(), checked: new Set(),
showTempalte: 'HORIZONTAL' showTemplate: 'HORIZONTAL'
}) })
Taro.getStorage({ key: 'schedule-add-films' }) Taro.getStorage({ key: 'schedule-add-films' })
.then(res => { .then(res => {
...@@ -72,16 +72,22 @@ class Films extends Component { ...@@ -72,16 +72,22 @@ class Films extends Component {
let arr = JSON.parse(res.data).map(item => { let arr = JSON.parse(res.data).map(item => {
return item.filmId return item.filmId
}) })
this.setState({ this.setState(
checked: new Set(arr), {
showTempalte: 'HORIZONTAL' checked: new Set(arr),
}) showTemplate: JSON.parse(res.data)[0]['templateShow'] || 'HORIZONTAL'
},
() => {
this.page = 1
this.getData()
}
)
}) })
.catch(() => { .catch(() => {
console.log('nodata') console.log('nodata')
this.setState({ this.setState({
checked: new Set(), checked: new Set(),
showTempalte: 'HORIZONTAL' showTemplate: 'HORIZONTAL'
}) })
}) })
} }
...@@ -93,7 +99,8 @@ class Films extends Component { ...@@ -93,7 +99,8 @@ class Films extends Component {
this.getData() this.getData()
} }
async getData() { async getData() {
this.props.getDeviceListData(this.page) const { showTemplate } = this.state
this.props.getDeviceListData(this.page, showTemplate)
} }
async handleItem({ filmId }: IMilmListItme) { async handleItem({ filmId }: IMilmListItme) {
...@@ -131,18 +138,25 @@ class Films extends Component { ...@@ -131,18 +138,25 @@ class Films extends Component {
shouldComponentUpdate(nextProps: IProps) { shouldComponentUpdate(nextProps: IProps) {
const { list } = this.props const { list } = this.props
const { showTemplate } = this.state
const { list: _list } = nextProps const { list: _list } = nextProps
return list !== _list return list !== _list || !!showTemplate
} }
typeChange(state) { typeChange(state) {
const newSet = this.state.checked
if (newSet.size) {
showMyToast({ title: '不可选择不同版型的视片~' })
return
}
this.setState( this.setState(
{ {
showTempalte: state showTemplate: state
}, },
async () => { () => {
console.log(123)
this.page = 1 this.page = 1
await this.getData() this.getData()
} }
) )
} }
...@@ -178,8 +192,8 @@ class Films extends Component { ...@@ -178,8 +192,8 @@ class Films extends Component {
render() { render() {
const { list, height, count } = this.props const { list, height, count } = this.props
const { checked, showTempalte } = this.state const { checked, showTemplate } = this.state
let myHeight = height && height - 40 let myHeight = height && height - 100
return ( return (
<View className="films"> <View className="films">
<View className="film-search-bar"> <View className="film-search-bar">
...@@ -189,7 +203,7 @@ class Films extends Component { ...@@ -189,7 +203,7 @@ class Films extends Component {
this.typeChange('HORIZONTAL') this.typeChange('HORIZONTAL')
}} }}
className={ className={
showTempalte === 'HORIZONTAL' showTemplate === 'HORIZONTAL'
? 'type-tab-item type-tab-item-active' ? 'type-tab-item type-tab-item-active'
: 'type-tab-item' : 'type-tab-item'
} }
...@@ -201,7 +215,7 @@ class Films extends Component { ...@@ -201,7 +215,7 @@ class Films extends Component {
this.typeChange('VERTICAL') this.typeChange('VERTICAL')
}} }}
className={ className={
showTempalte === 'VERTICAL' ? 'type-tab-item type-tab-item-active' : 'type-tab-item' showTemplate === 'VERTICAL' ? 'type-tab-item type-tab-item-active' : 'type-tab-item'
} }
> >
竖版 竖版
...@@ -211,7 +225,7 @@ class Films extends Component { ...@@ -211,7 +225,7 @@ class Films extends Component {
this.typeChange('OTHER') this.typeChange('OTHER')
}} }}
className={ className={
showTempalte === 'OTHER' ? 'type-tab-item type-tab-item-active' : 'type-tab-item' showTemplate === 'OTHER' ? 'type-tab-item type-tab-item-active' : 'type-tab-item'
} }
> >
异形屏 异形屏
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
.schedule-add { .schedule-add {
width: 100%; width: 100%;
padding: 20px; padding: 20px;
min-height: 100vh;
box-sizing: border-box;
position: relative;
padding-bottom: 100px;
&-title { &-title {
font-size: 30px; font-size: 30px;
...@@ -17,4 +21,22 @@ ...@@ -17,4 +21,22 @@
padding: 5px; padding: 5px;
border-radius: 4px; border-radius: 4px;
} }
.bottom-btn {
left: 0;
right: 0;
position: fixed;
bottom: 0;
display: flex;
.bottom-btn-item {
width: 50%;
height: 80px;
line-height: 80px;
border: 1px solid #eee;
text-align: center;
color: white;
background: green;
}
}
} }
...@@ -26,6 +26,7 @@ interface PageState { ...@@ -26,6 +26,7 @@ interface PageState {
deviceList: [] deviceList: []
filmList: any[] filmList: any[]
scheduleName: string scheduleName: string
id: string
} }
type IProps = PageStateProps & PageDispatchProps & PageOwnProps type IProps = PageStateProps & PageDispatchProps & PageOwnProps
...@@ -42,15 +43,26 @@ class ScheduleAdd extends Component { ...@@ -42,15 +43,26 @@ class ScheduleAdd extends Component {
protected page = 1 protected page = 1
constructor() { constructor() {
super(...arguments) super(...arguments)
const { id } = this.$router.params
if (id) {
Taro.setNavigationBarTitle({
title: '日程'
})
}
this.setState({ this.setState({
deviceList: [], deviceList: [],
filmList: [], filmList: [],
scheduleName: '' scheduleName: '',
id
}) })
this.onTimeChange = this.onTimeChange.bind(this) this.onTimeChange = this.onTimeChange.bind(this)
} }
async componentWillMount() { async componentWillMount() {
console.log('componentWillMount') try {
Taro.removeStorage({ key: 'schedule-add-films' })
Taro.removeStorage({ key: 'schedule-add-device' })
} catch (err) {}
this.getDetail()
} }
componentWillUnmount() { componentWillUnmount() {
try { try {
...@@ -72,6 +84,31 @@ class ScheduleAdd extends Component { ...@@ -72,6 +84,31 @@ class ScheduleAdd extends Component {
}) })
} }
getDetail() {
const { id } = this.$router.params
console.log(id)
id &&
api.common.getScheduleDetail(id).then(res => {
console.log(res)
const { equipmentInfos, calendarName, filmInfos } = res
this.setState({
filmList: filmInfos,
deviceList: equipmentInfos,
scheduleName: calendarName
})
// Taro.removeStorage({ key: 'schedule-add-films' })
// Taro.removeStorage({ key: 'schedule-add-device' })
Taro.setStorage({
key: 'schedule-add-films',
data: JSON.stringify(filmInfos)
})
Taro.setStorage({
key: 'schedule-add-device',
data: JSON.stringify(equipmentInfos)
})
})
}
goDetail({ filmId }: IMilmListItme) { goDetail({ filmId }: IMilmListItme) {
Taro.navigateTo({ url: `/pages/home/tempaltes/film_detail` }) Taro.navigateTo({ url: `/pages/home/tempaltes/film_detail` })
} }
...@@ -81,11 +118,13 @@ class ScheduleAdd extends Component { ...@@ -81,11 +118,13 @@ class ScheduleAdd extends Component {
url: `/pages/home/film/schedule_add/components/films/index` url: `/pages/home/film/schedule_add/components/films/index`
}) })
} }
chooseDevice() { chooseDevice() {
Taro.navigateTo({ Taro.navigateTo({
url: `/pages/home/film/schedule_add/components/device/index` url: `/pages/home/film/schedule_add/components/device/index`
}) })
} }
// 日程名字改变 // 日程名字改变
scheduleNameChange(e) { scheduleNameChange(e) {
const value = e.target.value const value = e.target.value
...@@ -102,10 +141,64 @@ class ScheduleAdd extends Component { ...@@ -102,10 +141,64 @@ class ScheduleAdd extends Component {
filmList: myFilmList filmList: myFilmList
}) })
} }
deleteAction() {
const { id } = this.$router.params
api.common.deleteSchedule(id).then(() => {
showMyToast({
title: '删除成功'
})
Taro.navigateBack()
})
}
enter() {
const { deviceList, filmList, scheduleName, id } = this.state
let equipmentsIds: any = []
let equipmentTopicList: any = []
let filmInfos: any = []
if (!scheduleName.trim()) {
showMyToast({
title: '任务名称为必填项'
})
return
}
if (!filmList.length) {
showMyToast({
title: '影片为必选项'
})
return
}
deviceList.map((item: any) => {
equipmentsIds.push(item.equipmentsId)
equipmentTopicList.push(item.equipmentTopic)
})
filmList.map((item: any) => {
filmInfos.push({
filmId: item.filmId,
time: item.time || '00:00'
})
})
let data = {
calendarName: scheduleName,
filmInfos: filmInfos,
equipmentsIds: equipmentsIds,
equipmentTopicList: equipmentTopicList,
calendarType: 'CUSTOME'
}
if (id) {
api.common.updateSchedule({ ...data, calendarId: id }).then(() => {
Taro.navigateBack()
})
} else {
api.common.createSchedule(data).then(() => {
Taro.navigateBack()
})
}
}
render() { render() {
const { list, height, count } = this.props const { list, height, count } = this.props
const { deviceList, filmList, scheduleName } = this.state const { deviceList, filmList, scheduleName, id } = this.state
return ( return (
<View className="schedule-add"> <View className="schedule-add">
<View className="schedule-add-title">任务名称</View> <View className="schedule-add-title">任务名称</View>
...@@ -136,6 +229,20 @@ class ScheduleAdd extends Component { ...@@ -136,6 +229,20 @@ class ScheduleAdd extends Component {
<Button size="mini" onClick={this.chooseDevice}> <Button size="mini" onClick={this.chooseDevice}>
选择设备 选择设备
</Button> </Button>
{id ? (
<View className="bottom-btn">
<View className="bottom-btn-item" onClick={this.deleteAction}>
删除
</View>
<View className="bottom-btn-item" onClick={this.enter}>
修改
</View>
</View>
) : (
<Button type="primary" onClick={this.enter} className="bottom-btn">
完成且同步到设备
</Button>
)}
</View> </View>
) )
} }
......
...@@ -6,6 +6,7 @@ import ListView from '@/conpoments/list_view' ...@@ -6,6 +6,7 @@ import ListView from '@/conpoments/list_view'
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { getDeviceList } from '@/actions/asyncCounter' import { getDeviceList } from '@/actions/asyncCounter'
import FilmListItem from '@/conpoments/film_list_item' import FilmListItem from '@/conpoments/film_list_item'
import { AtList, AtListItem } from 'taro-ui'
import './index.scss' import './index.scss'
...@@ -89,23 +90,8 @@ class Schedule extends Component { ...@@ -89,23 +90,8 @@ class Schedule extends Component {
}) })
} }
async handleItem({ filmId }: IMilmListItme) { goDetail(id: string) {
Taro.showModal({ content: '确定要删除?' }).then(async ({ confirm }) => { Taro.navigateTo({ url: `/pages/home/film/schedule_add/index?id=${id}` })
if (confirm) {
try {
await api.common.removeFilm(filmId)
this.getData()
showMyToast({ title: '删除成功~' })
} catch (error) {
console.error(error)
showMyToast({ title: '失败成功~' })
}
}
})
}
goDetail({ filmId }: IMilmListItme) {
Taro.navigateTo({ url: `/pages/home/tempaltes/film_detail?filmId=${filmId}` })
} }
async onDownRefresh(done: any) { async onDownRefresh(done: any) {
...@@ -151,7 +137,20 @@ class Schedule extends Component { ...@@ -151,7 +137,20 @@ class Schedule extends Component {
pullingUp={done => this.onScrollToLower(done)} pullingUp={done => this.onScrollToLower(done)}
pullingDown={done => this.onDownRefresh(done)} pullingDown={done => this.onDownRefresh(done)}
> >
{list.map((item, index) => ( <AtList>
{list.map((item, index) => (
<AtListItem
key={item.calendarId}
title={item.calendarName}
note={item.updateTime}
arrow="right"
onClick={() => {
this.goDetail(item.calendarId)
}}
/>
))}
</AtList>
{/* {list.map((item, index) => (
<View <View
key={item.filmId} key={item.filmId}
className={ className={
...@@ -177,10 +176,7 @@ class Schedule extends Component { ...@@ -177,10 +176,7 @@ class Schedule extends Component {
<FilmListItem {...item} /> <FilmListItem {...item} />
</View> </View>
</View> </View>
))} ))} */}
<View className="schedule-list-item">121323</View>
<View className="schedule-list-item">121323</View>
<View className="schedule-list-item">121323</View>
</ListView> </ListView>
<View className="schedule-list-add-btn"> <View className="schedule-list-add-btn">
<Text className="icon" onClick={this.addSchedule}> <Text className="icon" onClick={this.addSchedule}>
......
...@@ -20,12 +20,12 @@ export default function TempDetailContent(props: IProps) { ...@@ -20,12 +20,12 @@ export default function TempDetailContent(props: IProps) {
<View className="temp-detail"> <View className="temp-detail">
<DetailTop {...Object.assign(detailData, { templateId })} templateId2={templateId} /> <DetailTop {...Object.assign(detailData, { templateId })} templateId2={templateId} />
{/* <View className="temp-detail-list"> <View className="temp-detail-list">
<Text className="temp-detail-list-title">我的视片({filmDataList.length})</Text> <Text className="temp-detail-list-title">我的视片({filmDataList.length})</Text>
<View className="temp-detail-list-content"> <View className="temp-detail-list-content">
{filmDataList && filmDataList.map(item => <TempItem {...item} key={item.templateId} />)} {filmDataList && filmDataList.map(item => <TempItem {...item} key={item.templateId} />)}
</View> </View>
</View> */} </View>
</View> </View>
) )
} }
...@@ -52,10 +52,9 @@ class TempItem extends Component { ...@@ -52,10 +52,9 @@ class TempItem extends Component {
<Text className="temp-name">{templateName || filmName}</Text> <Text className="temp-name">{templateName || filmName}</Text>
{templateName !== undefined ? <Text className="temp-film-count">{filmCount}</Text> : null} {templateName !== undefined ? <Text className="temp-film-count">{filmCount}</Text> : null}
</View> </View>
{/* {equipmentCount !== undefined ? (
{equipmentCount !== undefined ? (
<Text className="equipment-count">播放设备:{equipmentCount}台</Text> <Text className="equipment-count">播放设备:{equipmentCount}台</Text>
) : null} ) : null} */}
</View> </View>
) )
} }
......
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