123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- // pages/find/find.js
- var utils = require('../../utils/util.js');
- var app = getApp();
- Page({
- data: {
- tabArr: {
- curHdIndex: 0,
- curBdIndex: 0
- },
- jobArr: [],
- moneyArr: [],
- timeArr: [],
- obj:{ amount: 0, is_hot: 0, is_new: 0, search: 1, term: 0, user_title: "不限" },
- hasNext: false,
- page: 1,
- tab0:'职业身份',
- tab1:'贷款金额',
- tab2:'贷款期限'
- },
- tab: function(e){
- //获取触发事件组件的dataset属性
- var that = this, _datasetId = e.target.dataset.id, _rank = e.target.dataset.rank;
- // console.log("----" + _datasetId + "----");
- var _obj = {}, obj_app = this.data.obj;
- _obj.curHdIndex = _datasetId;
- _obj.curBdIndex = _datasetId;
- obj_app['ranking_list'] = _rank;
- that.data.page = 1;
- that.setData({
- tabArr: _obj,
- obj: obj_app
- });
- utils.initList(that, that.data.obj);
- },
- ajaxFilter: function (event) {
- var that = this;
- wx.request({
- url: app.globalData.HOST + '/user/wx/filter',
- method: "POST",
- data: app.globalData.common,
- success: function (res) {
- var data = res.data.rst;
- if (res.data.errno == '0') {
- that.setData({
- jobArr: data.userlist,
- moneyArr: data.list,
- timeArr: data.month
- })
- }
- },
- complete: function () {
- that.setData({ hidden:true});//加载成功
- wx.stopPullDownRefresh() //停止下拉刷新
- }
- });
- },
- showSheet: function(event){
- var tab = '';
- var that = this, currentTarget = event.currentTarget, arr = [], index = 0, arrData = [];
- var obj = {};
- that.data.page = 1;
- if(currentTarget.id == '0'){
- arr = that.data.jobArr.map((item) => item.v);
- arrData = that.data.jobArr.map((item) => item.k);
- }else if(currentTarget.id == '1'){
- arr = that.data.moneyArr.map((item) => item.v);
- arrData = that.data.moneyArr.map((item) => item.k);
- }else{
- arr = that.data.timeArr.map((item) => item.v);
- arrData = that.data.timeArr.map((item) => item.k);
- }
- wx.showActionSheet({
- itemList: arr,
- success: function (res) {
- index = res.tapIndex;
- tab = arrData[index];
- if(currentTarget.id == '0'){
- that.data.obj['user_title'] = tab;
- that.setData({tab0: that.data.jobArr[index].v})
- }else if(currentTarget.id == '1'){
- that.data.obj['amount'] = tab;
- that.setData({tab1: that.data.moneyArr[index].v})
- }else{
- that.data.obj['term'] = tab;
- that.setData({tab2: that.data.timeArr[index].v})
- }
- utils.initList(that, that.data.obj, that.data.page);
- },
- fail: function (res) {
- console.log(res.errMsg)
- }
- })
- },
- onLoad: function (options) {
- var that = this;
- utils.initList(that, that.data.obj);
- that.ajaxFilter();
- },
- onShow () {
- wx.stopPullDownRefresh()
- },
- onPullDownRefresh: function () {
- //下拉
- var that = this;
- that.data.page = 1;
- setTimeout(() => {
- utils.initList(that, that.data.obj, that.data.page);
- }, 500)
- },
- onReachBottom: function () {
- //上拉
- var that = this;
- if (that.data.hasNext) {
- utils.initList(that, that.data.obj, ++that.data.page);
- }
- },
- onReady: function () {
- },
- onHide: function () {
- },
- onUnload: function () {
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.title,
- imageUrl: app.globalData.img,
- path: '/pages/index/index',
- success: function(res) {
- app.noticeModal('分享成功')
- },
- fail: function(res) {
- app.noticeModal('您取消了分享')
- }
- }
- },
- //FormId
- formSubmit(e) {
- var formId = e.detail.formId;
- var id = e.target.dataset.id;
- this.getFromid(formId, id);
- console.log(formId + "formID发现")
- },
- getFromid(formId, ids) {
- wx.request({
- url: app.globalData.HOST + '/user/wx/getFromid',
- method: "POST",
- data: Object.assign({}, app.globalData.common, { from_id: formId }),
- success: function (res) {
- wx.navigateTo({
- url: '/pages/details/details?id=' + ids
- })
- },
- complete: function () {
- }
- });
- }
- })
|