1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- const app = getApp();
- const util = require("../../../util/util.js")
- Page({
- data: {
- StatusBar: app.globalData.StatusBar,
- CustomBar: app.globalData.CustomBar,
- loadModal:false,
- userInfo:{},
- name:'',
- from:0,
- size:6,
- list:[
- ]
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function ( ) {
- app.checkLogin( ()=>{
- this.loadData()
- this.getuserInfo()
- } )
- },
- search(e){
- let {name} = e.detail.value;
- this.setData({name})
- this.getTaskList( 0 )
- },
- getuserInfo( cb ){
- app.getMakerInfo( (userInfo)=>{
- this.setData({userInfo})
- } )
- },
- onReachBottom: function () {
- var that = this
- let newFrom = that.data.from
- if (newFrom == -1) {
- wx.stopPullDownRefresh();
- return;
- }
- this.getTaskList(newFrom, wx.stopPullDownRefresh);
- },
- bidTask: function( e ){
- let index = e.currentTarget.dataset.index;
- let item = this.data.list[index]
- util.http("/wx/applyWxB2B", {id:item.id}, (err, res) =>{
- if( err != 0) return;
- item.target_id = this.data.userInfo.ID
- this.setData({ list: this.data.list})
- util.showSuccess("抢单子成功");
- })
- },
- goDetail(e){
- let id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: `/pages/task/info/b2bInfo?id=${id}`,
- })
- },
- getTaskList: function( newFrom, cb){
- let param = { from: newFrom, size:this.data.size,name: this.data.name }
- let list = this.data.list
- let that = this
- util.http("/wx/getDemandCenter", param, function (err, res) {
- if( err != 0) return;
- if (newFrom == 0) list = [];
- let newlist = res.list.map( item =>{
- item.bid_end_at = item.bid_end_at.substr(0,10);
- return item
- });
- that.setData({
- from: res.from || -1,
- list: list.concat(newlist)
- })
- cb && cb()
- });
- },
- loadData :function( ){
- this.getTaskList(0)
- },
- })
|