Commit 6c0dac39 by hank

优化加载提示

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