Commit 6c0dac39 by hank

优化加载提示

parent d65d1f52
import Taro from '@tarojs/taro'
import api from '@/api/index' import api from '@/api/index'
import { setTempList, setDeviceList, setFilmData, setShopData } from './counter' import { setTempList, setDeviceList, setFilmData, setShopData } from './counter'
/** 获取 模板市场 数据列表 */ /** 获取 模板市场 数据列表 */
...@@ -5,7 +6,9 @@ export function getTempList(page: number) { ...@@ -5,7 +6,9 @@ export function getTempList(page: number) {
return async (dispatch, state) => { return async (dispatch, state) => {
const oldState = state().counter const oldState = state().counter
try { try {
Taro.showLoading({ title: '数据加载中' })
let { list, count } = await api.common.getTempList(page) let { list, count } = await api.common.getTempList(page)
Taro.hideLoading()
if (page !== 1 && oldState.tempData) { if (page !== 1 && oldState.tempData) {
list = [...oldState.tempData.list, ...list] list = [...oldState.tempData.list, ...list]
} }
...@@ -21,7 +24,9 @@ export function getDeviceList(page: number, showTemplate: string = '') { ...@@ -21,7 +24,9 @@ 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 {
Taro.showLoading({ title: '数据加载中' })
let { list, count } = await api.common.getMyFilmsList(page, showTemplate) let { list, count } = await api.common.getMyFilmsList(page, showTemplate)
Taro.hideLoading()
if (page !== 1 && oldState.deviceData) { if (page !== 1 && oldState.deviceData) {
list = [...oldState.deviceData.list, ...list] list = [...oldState.deviceData.list, ...list]
} }
...@@ -37,7 +42,9 @@ export function getFilmList(page: number) { ...@@ -37,7 +42,9 @@ export function getFilmList(page: number) {
return async (dispatch, state) => { return async (dispatch, state) => {
const oldState = state().counter const oldState = state().counter
try { try {
Taro.showLoading({ title: '数据加载中' })
let { list, count } = await api.common.getMyDeviceList(page) let { list, count } = await api.common.getMyDeviceList(page)
Taro.hideLoading()
if (page !== 1 && oldState.filmData) { if (page !== 1 && oldState.filmData) {
list = [...oldState.filmData.list, ...list] list = [...oldState.filmData.list, ...list]
} }
......
...@@ -94,9 +94,14 @@ class Films extends Component { ...@@ -94,9 +94,14 @@ class Films extends Component {
{ {
showTemplate: value showTemplate: value
}, },
() => { async () => {
Taro.showLoading({title: '数据加载中'})
this.page = 1 this.page = 1
this.getData() this.getData()
let time = setTimeout(() => {
Taro.hideLoading()
clearTimeout(time)
}, 500)
} }
) )
} }
......
...@@ -75,16 +75,10 @@ class Films extends Component { ...@@ -75,16 +75,10 @@ class Films extends Component {
async componentWillMount() { async componentWillMount() {
Taro.getStorage({ key: 'schedule-add-films' }) Taro.getStorage({ key: 'schedule-add-films' })
.then(res => { .then(res => {
console.log(res.data, 'schedule-add-films')
let data = JSON.parse(res.data) let data = JSON.parse(res.data)
let arr = data.map(item => { let arr = data.map(item => {
return item.filmId return item.filmId
}) })
// this.setState({
// oldFilms: data,
// oldArr: arr
// })
console.log(arr, data)
this.setState( this.setState(
{ {
oldFilms: data, oldFilms: data,
...@@ -271,7 +265,7 @@ class Films extends Component { ...@@ -271,7 +265,7 @@ class Films extends Component {
checked={checked.has(item.filmId)} checked={checked.has(item.filmId)}
/> />
<View className="films-bind-item-info"> <View className="films-bind-item-info">
<FilmListItem isisChoose={true} key={item.filmId} {...item} /> <FilmListItem isChoose={true} key={item.filmId} {...item} />
</View> </View>
</Label> </Label>
</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