Commit e792dd3f by hank

bug

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