123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- // customer/pages/brokerindex/brokerindex.js
- var App = getApp();
- var utils = require("../../../utils/http");
- var page = 1;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- loading: false,
- name: '',
- phone: '',
- community_name: '',
- type: '',
- brokerRanklist: [],
- swiperData: []
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- page = 1;
- if (!!options.type) {
- this.setData({
- type: options.type
- })
- }
- this.getBrokerRank();
- wx.hideHomeButton();
- },
- jumpMinePage:function(e) {
- wx.reLaunch({
- url: '/customer/pages/broker/broker',
- })
- },
- nameInput(e) {
- console.log(e)
- this.setData({
- name: e.detail.value
- })
- },
- phoneInput(e) {
- this.setData({
- phone: e.detail.value
- })
- },
- communityNameInput(e) {
- this.setData({
- community_name: e.detail.value
- })
- },
- //手机号正则验证
- isPhoneNum: function (phone) {
- var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8})$/;
- if (!myreg.test(phone)) {
- return false;
- }
- return true;
- },
- /**
- * 添加客户
- */
- addCustomer: function () {
- var that = this;
- if (!that.data.phone) {
- wx.showToast({
- title: '请填写手机号',
- icon: 'none',
- });
- return false;
- }
- if (!this.isPhoneNum(that.data.phone)) {
- wx.showToast({
- title: '手机号格式错误',
- icon: 'none',
- });
- return false;
- }
- wx.showLoading({
- title: '提交中...'
- });
- that.setData({
- loading: true,
- })
- utils.$post({
- url: App.globalData.webUrl + 'api/agents_work/add_customer',
- header: {
- 'Authorization': 'bearer ' + App.globalData.token
- },
- data: {
- name: that.data.name,
- phone: that.data.phone,
- community_name: that.data.community_name
- },
- success: function (res) {
- wx.hideLoading();
- if (res.data.code == '0') {
- wx.showToast({
- title: '添加成功',
- icon: 'none',
- duration: 1500
- })
- that.setData({
- loading: false,
- name: '',
- phone: '',
- community_name: ''
- })
- } else {
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 1500
- })
- }
- }
- })
- },
- /**
- * 经纪人排名列表
- */
- getBrokerRank() {
- let that = this;
- utils.$post({
- url: App.globalData.webUrl + 'api/agents_work/agent_rank_list',
- header: {
- 'Authorization': 'bearer ' + App.globalData.token
- },
- data: {
- page: page,
- limit: 10,
- },
- success: function (res) {
- if (res.data.code == '0') {
- that.setData({
- datashow: true,
- brokerRanklist: res.data.data
- })
- if (that.data.brokerRanklist.length) {
- if (that.data.brokerRanklist.length > 6) {
- that.setData({
- swiperData: that.data.brokerRanklist.slice(0,6)
- })
- } else {
- that.setData({
- swiperData: that.data.brokerRanklist
- })
- }
- }
- if (that.data.type == 'rank') {
- wx.pageScrollTo({scrollTop: 750})
- }
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- if (this.data.type == 'rank') {
- page++;
- let that = this;
- utils.$post({
- url: App.globalData.webUrl + 'api/agents_work/agent_rank_list',
- header: {
- 'Authorization': 'bearer ' + App.globalData.token
- },
- data: {
- page: page,
- limit: 10,
- },
- success: function (res) {
- if (res.data.code == '0') {
- let arr = that.data.brokerRanklist.concat(res.data.data);
- that.setData({
- datashow: true,
- brokerRanklist: arr
- })
- }
- }
- })
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|