Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentWillMount () {
console.log('doingWillMount')
this.props.dispatch({
type: 'doing/save',
payload: {
lastsign: Taro.getStorageSync('lastsign'),
days: Taro.getStorageSync('days'),
healthPercent: parseInt(Taro.getStorageSync('unitamount') / 20 * Taro.getStorageSync('days')),
moneyPercent: parseInt(Taro.getStorageSync('unitprice') / Taro.getStorageSync('unitamount') * Taro.getStorageSync('amount') * Taro.getStorageSync('days') / 10),
rewardPercent: Taro.getStorageSync('days') / 10
},
})
// if(Date.parse(new Date()) - Taro.getStorageSync('lastsign')>= 864000000){
// this.props.dispatch({
// type: 'doing/allowSign'
// };
// }
}
}).then((result: apiData) => {
Taro.hideLoading();
console.log('获取最新节点', result);
this.props.dispatch({
type: LATEST_TOPIC_LIST,
data: result.data
});
const isRefresh = Taro.getStorageSync('IS_LATEST_DATA_REFRESH')
if(isRefresh){
showToast({
title:'刷新成功',
icon:'success'
});
Taro.setStorageSync('IS_LATEST_DATA_REFRESH',false)
}
}).catch((error) => {
showToast(error.message)
searchList(){
let cityId = Taro.getStorageSync('cities').geoCity.id;
let keyWord = this.state.keyWord;
let self = this;
Taro.request({
url:`https://m.maoyan.com/ajax/search?kw=${keyWord}&cityId=${cityId}&stype=-1`,
method:'GET'
}).then(res=>{
if(res.statusCode == 200){
let data = res.data;
let list = data.movies?data.movies.list:[];
list.map(item=>{
let arr = item["img"].split("w.h");
item["img"] = arr[0]+'120.180'+arr[1];
})
self.setState({
cinemasList:data.cinemas?data.cinemas.list:[],
movieList:data.movies?data.movies.list:[]
import Taro from '@tarojs/taro';
export default {
namespace: 'common',
state: {
access_token: Taro.getStorageSync('access_token'),
mobile: Taro.getStorageSync('user_info')
? Taro.getStorageSync('user_info').mobile
: '',
nickname: Taro.getStorageSync('user_info')
? Taro.getStorageSync('user_info').nickname
: '',
new_user: Taro.getStorageSync('user_info')
? Taro.getStorageSync('user_info').new_user
: '',
is_has_buy_card: Taro.getStorageSync('user_info')
? Taro.getStorageSync('user_info').is_has_buy_card
: '',
erroMessage: Taro.getStorageSync('user_info')
? Taro.getStorageSync('user_info').erroMessage
: '',
},
effects: {},
reducers: {
save(state, { payload }) {
return { ...state, ...payload };
},
},
getStorageData(){
let self = this;
let cityData = Taro.getStorageSync('cities');
this.setState({
cityData:cityData.geoCity
},()=>{
self.filterCinemasList();
self.getCinemasList();
});
}
filterCinemasList(){
constructor (props) {
super(props)
this.state = {
userId: Taro.getStorageSync('userId'),
userList: [],
hasMore: true
}
}
getData() {
const { currentTab } = this.state
const userId = Taro.getStorageSync('userId')
api.get('/user/record', {
uid: userId,
type: currentTab === 0 ? 1 : 0
}).then((res) => {
const dataType = currentTab === 0 ? 'weekData' : 'allData'
if (res.data && res.data[dataType] && res.data[dataType].length > 0) {
this.setState({
list: res.data[dataType]
})
}
})
}
navigateToURL(url,item){
let cityId = Taro.getStorageSync('cities').geoCity.id;
url = url+`?title=${item.nm}&id=${item.id}&cityId=${cityId}`
Taro.navigateTo({
url:url
});
}
navigateToCinema(url,item){
baseOptions(params, method = "GET") {
let { url, data } = params;
const BASE_URL = getBaseUrl(url);
let contentType = "application/json";
contentType = params.contentType || contentType;
const option = {
url: BASE_URL + url,
data: data,
method: method,
header: {
'content-type': contentType,
'Authorization': Taro.getStorageSync('Authorization')
}
};
return Taro.request(option);
}