|
|
@ -1,6 +1,9 @@ |
|
|
// pages/home/about/index.js
|
|
|
// pages/home/about/index.js
|
|
|
|
|
|
import { getFactoryPrice, getProxyOrderList } from "../../../api/ztb" |
|
|
|
|
|
import { getPreferList, getInformationList } from "../../../api/moment" |
|
|
const storage = require('../../../utils/storage') |
|
|
const storage = require('../../../utils/storage') |
|
|
const util = require('../../../utils/util') |
|
|
const util = require('../../../utils/util') |
|
|
|
|
|
const tdsdk = require('../../../libs/tdweapp.js') |
|
|
const app = getApp() |
|
|
const app = getApp() |
|
|
|
|
|
|
|
|
Page({ |
|
|
Page({ |
|
|
@ -14,10 +17,13 @@ Page({ |
|
|
tabList: [ '交易', '行情', '订单' , '资讯'], |
|
|
tabList: [ '交易', '行情', '订单' , '资讯'], |
|
|
tabIndex: 0, |
|
|
tabIndex: 0, |
|
|
form: { |
|
|
form: { |
|
|
name: '', |
|
|
|
|
|
|
|
|
searchKey: '', |
|
|
pageSize: 10, |
|
|
pageSize: 10, |
|
|
pageNum: 1 |
|
|
pageNum: 1 |
|
|
}, |
|
|
}, |
|
|
|
|
|
loading: true, |
|
|
|
|
|
requesting: false, |
|
|
|
|
|
finished: false, |
|
|
taskList: [] |
|
|
taskList: [] |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
@ -46,7 +52,7 @@ Page({ |
|
|
this.setData({ focus: true }) |
|
|
this.setData({ focus: true }) |
|
|
}, |
|
|
}, |
|
|
onBlurChange: function(){ |
|
|
onBlurChange: function(){ |
|
|
if(util.isEmpty(this.data.form.name)){ |
|
|
|
|
|
|
|
|
if(util.isEmpty(this.data.form.searchKey)){ |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
this.setData({ focus: false }) |
|
|
this.setData({ focus: false }) |
|
|
@ -60,25 +66,99 @@ Page({ |
|
|
wx.navigateTo({ url: '/pages/login/index' }) |
|
|
wx.navigateTo({ url: '/pages/login/index' }) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
this.onSearchList({ detail:{value: this.data.form.name} }) |
|
|
|
|
|
|
|
|
this.onSearchList({ detail:{value: this.data.form.searchKey} }) |
|
|
}, |
|
|
}, |
|
|
onSearchList: function({detail}){ |
|
|
onSearchList: function({detail}){ |
|
|
this.data.form.name = detail.value |
|
|
|
|
|
if(util.isEmpty(this.data.form.name)){ |
|
|
|
|
|
|
|
|
this.data.form.searchKey = detail.value |
|
|
|
|
|
if(util.isEmpty(this.data.form.searchKey)){ |
|
|
util.showToast('请输入要搜索的关键字') |
|
|
util.showToast('请输入要搜索的关键字') |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
var strList = this.data.rearchStringList |
|
|
var strList = this.data.rearchStringList |
|
|
if(!util.isEmpty(this.data.form.name) && strList.indexOf(this.data.form.name) < 0){ |
|
|
|
|
|
strList.splice(0, 0, this.data.form.name) |
|
|
|
|
|
|
|
|
if(!util.isEmpty(this.data.form.searchKey) && strList.indexOf(this.data.form.searchKey) < 0){ |
|
|
|
|
|
strList.splice(0, 0, this.data.form.searchKey) |
|
|
|
|
|
} |
|
|
|
|
|
this.data.form.pageNum = 1 |
|
|
|
|
|
this.setData({ taskList: [], loading: true, finished: false, rearchStringList: strList.slice(0, 24), focus: false, ['form.searchKey']: detail.value }) |
|
|
|
|
|
this.fetchTaskList() |
|
|
|
|
|
}, |
|
|
|
|
|
fetchTaskList: function(){ |
|
|
|
|
|
if (this.data.requesting || this.data.finished) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (this.data.loading) { |
|
|
|
|
|
this.data.requesting = true |
|
|
|
|
|
} else { |
|
|
|
|
|
this.setData({ requesting: true }) |
|
|
|
|
|
} |
|
|
|
|
|
if(this.data.tabIndex == 0){ |
|
|
|
|
|
getFactoryPrice(this.data.form).then(result => { |
|
|
|
|
|
if (result.data.records.length) { |
|
|
|
|
|
this.handRespList(result.data.records) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.setData({ finished: true, requesting: false, loading: false }) |
|
|
|
|
|
} |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
this.setData({ requesting: false, loading: false }) |
|
|
|
|
|
util.showToast(err) |
|
|
|
|
|
}) |
|
|
|
|
|
} else if(this.data.tabIndex == 1){ |
|
|
|
|
|
getInformationList(this.data.form).then(result => { |
|
|
|
|
|
if (result.data.records.length) { |
|
|
|
|
|
this.handRespList(result.data.records) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.setData({ finished: true, requesting: false, loading: false }) |
|
|
|
|
|
} |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
this.setData({ requesting: false, loading: false }) |
|
|
|
|
|
util.showToast(err) |
|
|
|
|
|
}) |
|
|
|
|
|
} else if(this.data.tabIndex == 2){ |
|
|
|
|
|
getProxyOrderList(this.data.form).then(result => { |
|
|
|
|
|
if (result.data.records.length) { |
|
|
|
|
|
this.handRespList(result.data.records) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.setData({ finished: true, requesting: false, loading: false }) |
|
|
|
|
|
} |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
this.setData({ requesting: false, loading: false }) |
|
|
|
|
|
util.showToast(err) |
|
|
|
|
|
}) |
|
|
|
|
|
} else if(this.data.tabIndex == 3){ |
|
|
|
|
|
getPreferList(this.data.form).then(result => { |
|
|
|
|
|
if (result.data.records.length) { |
|
|
|
|
|
this.handRespList(result.data.records) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.setData({ finished: true, requesting: false, loading: false }) |
|
|
|
|
|
} |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
this.setData({ requesting: false, loading: false }) |
|
|
|
|
|
util.showToast(err) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
handRespList: function(respList){ |
|
|
|
|
|
let nowList = `taskList[${this.data.taskList.length}]` |
|
|
|
|
|
var num = this.data.form.pageNum |
|
|
|
|
|
var finished = this.data.form.pageNum >= result.data.pages |
|
|
|
|
|
if (this.data.form.pageNum == 1) { |
|
|
|
|
|
this.setData({ [nowList]: respList, total: result.data.total, ['form.pageNum']: (num + 1), top: 0, finished, requesting: false, loading: false }) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.setData({ [nowList]: respList, total: result.data.total, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false }) |
|
|
} |
|
|
} |
|
|
this.setData({ rearchStringList: strList.slice(0, 24), focus: false, ['form.name']: detail.value }) |
|
|
|
|
|
}, |
|
|
}, |
|
|
tagClick: function(e){ |
|
|
tagClick: function(e){ |
|
|
this.setData({ ['form.name']: this.data.rearchStringList[e.currentTarget.dataset.index] }) |
|
|
|
|
|
this.onSearchList({detail:{value: this.data.form.name}}) |
|
|
|
|
|
|
|
|
this.data.form.searchKey = this.data.rearchStringList[e.currentTarget.dataset.index] |
|
|
|
|
|
this.onSearchList({detail:{value: this.data.form.searchKey}}) |
|
|
|
|
|
}, |
|
|
|
|
|
onShow: function () { |
|
|
|
|
|
tdsdk.Page.onShow() |
|
|
|
|
|
}, |
|
|
|
|
|
onHide: function(){ |
|
|
|
|
|
tdsdk.Page.onHide() |
|
|
}, |
|
|
}, |
|
|
onUnload() { |
|
|
onUnload() { |
|
|
|
|
|
tdsdk.Page.onUnload() |
|
|
if(this.data.rearchStringList.length){ |
|
|
if(this.data.rearchStringList.length){ |
|
|
try { |
|
|
try { |
|
|
wx.setStorageSync('mall-search', this.data.rearchStringList.toString()) |
|
|
wx.setStorageSync('mall-search', this.data.rearchStringList.toString()) |
|
|
|