123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 |
- const app = getApp();
- var utils = require("../../../utils/http"),
- page = 1;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- canIUseGetUserProfile: false,
- shareobj: {},
- employeeflag: false, //false是用户,true是员工
- top: app.globalData.statusBarHeight,
- hgt: app.globalData.titleBarHeight,
- companyobj: {},
- datashow: false,
- sourceflag: false,
- houseflag: false,
- likestyle: '',
- likehouse: '',
- stylearr: [],
- housearr: [],
- designlist: [],
- phoneFlag: app.globalData.phone, //true是有手机号,false是没有手机号
- type: '',
- orgarr: [],
- orgobj: {},
- noworg: {
- id: '',
- name: ''
- },
- orgName:'',
- orgId:'',
- orgshow: false,
- levelIds: ['1'],
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- wx.showLoading({
- title: '加载中...',
- })
- if (options.type) {
- this.setData({
- type: options.type
- })
- }
- this.setData({
- phoneFlag: app.globalData.phone
- })
- this.houseinfofun();
- this.orgfun();
- },
- dothis(){},
- orgfun() {
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'client/designer/designer_org',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {},
- success: function (res) {
-
- if (res.data.code == "0") {
- that.setData({
- orgobj: res.data.data,
- orgarr: res.data.data
- })
- }
- }
- })
- },
- handleLevel(e) {
- let id = e.currentTarget.dataset.id;
- this.setDepartData(this.data.orgobj, id);
- },
- setDepartData(list, id, level) {
- list.forEach(item => {
- if (id == item.id) {
- if (!item.children || !item.children.length) {
- wx.showToast({
- title: '没有下级部门了',
- icon: 'none',
- duration: 1000
- })
- } else {
- if (level) {
- this.setData({
- orgarr: item.children,
- levelIds: this.data.levelIds,
- })
- } else {
- this.data.levelIds.push(id);
- this.setData({
- orgarr: item.children,
- levelIds: this.data.levelIds,
- })
- }
- }
- return;
- } else {
- if (item.children && item.children.length) {
- this.setDepartData(item.children, id, level);
- }
- }
- })
- },
- lastLevel() {
- if (this.data.levelIds.length == 2) {
- this.setData({
- orgarr: this.data.orgobj,
- levelIds: ['1'],
- })
- } else {
- this.data.levelIds.splice(this.data.levelIds.length - 1, 1);
- this.setDepartData(this.data.orgobj, this.data.levelIds[this.data.levelIds.length - 1], 'lastlevel');
- }
- },
- radioChange(e) {
- let data = e.detail.value.split('~');
- let obj = {
- name: data[1],
- id: data[0]
- };
- this.setData({
- noworg: obj
- })
- },
- showorgtap(){
- this.setData({
- orgshow:true
- })
- },
- closeMask() {
- this.setData({
- orgshow: false,
- levelIds: ['1'],
- noworg: {
- id: '',
- name: ''
- },
- orgarr:this.data.orgobj
- })
- },
- confirmDepart() {
- this.setData({
- orgName: this.data.noworg.name,
- orgId: this.data.noworg.id,
- orgshow: false,
- levelIds: ['1'],
- noworg: {
- id: '',
- name: ''
- },
- orgarr:this.data.orgobj
- });
- this.designlistfun();
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- showstyletap() {
- this.setData({
- sourceflag: true
- })
- },
- housetap() {
- this.setData({
- houseflag: true
- })
- },
- setsourcetap(e) {
- if (!e.detail) {
- this.setData({
- sourceflag: false
- })
- return false;
- }
- this.setData({
- likestyle: e.detail,
- sourceflag: false
- })
- this.designlistfun();
- },
- sethousetap(e) {
- if (!e.detail) {
- this.setData({
- houseflag: false
- })
- return false;
- }
- this.setData({
- likehouse: e.detail,
- houseflag: false
- })
- this.designlistfun();
- },
- setinitap() {
- this.setData({
- likehouse: '',
- likestyle: '',
- orgName:'',
- orgId:'',
- })
- this.designlistfun();
- },
- houseinfofun() {
- this.designlistfun();
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/designer/select',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {},
- success: function (res) {
- wx.hideLoading()
- let stylearr = [],
- housearr = [];
- if (res.data.code == "0") {
- for (let i in res.data.data.decostyles) {
- stylearr.push(res.data.data.decostyles[i].name);
- }
- for (let i in res.data.data.housetype) {
- housearr.push(res.data.data.housetype[i].name);
- }
- that.setData({
- stylearr: stylearr,
- housearr: housearr
- })
- }
- }
- })
- },
- designlistfun() {
- const that = this;
- page = 1;
- wx.showLoading({
- title: '加载中...',
- })
- utils.$post({
- url: app.globalData.webUrl + 'client/designer/index',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- at: that.data.likestyle,
- house: that.data.likehouse,
- limit: 10,
- page: 1,
- org_id:this.data.orgId
- },
- success: function (res) {
- if (res.data.code == "0") {
- that.setData({
- datashow: true,
- designlist: res.data.data
- })
- }
- wx.hideLoading()
- }
- })
- },
- apointap: function (e) {
- const that = this;
- let item = this.data.designlist[e.currentTarget.dataset.idx];
- utils.$post({
- url: app.globalData.webUrl + 'client/designer/designer_make',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- designer_id: item.designer_id,
- designer_name: item.name,
- share_uid: app.globalData.shareuserid
- },
- success: function (res) {
- if (res.data.code == "0") {
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 2000
- })
- }
- }
- })
- },
- getPhoneNumberTap: function (res) {
- var that = this;
- console.log(res)
- if (res.detail.errMsg == 'getPhoneNumber:ok') {
- utils.$post({
- url: app.globalData.webUrl + 'api/users/setUserMobile',
- data: {
- encryptedData: res.detail.encryptedData,
- iv: res.detail.iv
- },
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- success: function (r) {
- if (r.data.code == '0') {
- // wx.showLoading({
- // title: '加载中',
- // })
- app.globalData.phone = true;
- that.setData({
- phoneFlag: false
- })
- that.apointap(res);
- } else {
- that.setData({
- errorText: r.data.msg,
- errorflag: true
- })
- }
- }
- })
- }
- },
- designertap: function (e) {
- let item = this.data.designlist[e.currentTarget.dataset.idx];
- wx.navigateTo({
- url: '/customer/pages/designermsg/designermsg?did=' + item.id + "&sid=" + item.id + '&type=' + this.data.type
- })
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- golastap: function () {
- wx.reLaunch({
- url: '/pages/index/index?state=1',
- })
- },
- goindextap: function () {
- wx.reLaunch({
- url: '/pages/index/index?state=1',
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- dothis() {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- this.designlistfun();
- wx.stopPullDownRefresh();
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- const that = this;
- page = page * 1 + 1;
- wx.showLoading({
- title: '加载中...',
- })
- utils.$post({
- url: app.globalData.webUrl + 'client/designer/index',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- at: that.data.likestyle,
- house: that.data.likehouse,
- limit: 10,
- page: page,
- org_id:this.data.orgId
- },
- success: function (res) {
- wx.hideLoading();
- if (res.data.code == "0") {
- let designlist = that.data.designlist;
- designlist = designlist.concat(res.data.data);
- that.setData({
- designlist: designlist
- })
- }
- }
- })
- },
- onShareAppMessage: function (e) {
- // 公司名设计师:设计师名
- let that = this;
- let title = "设计大师-" + app.globalData.companyobj.company_name,
- img = app.globalData.imgUrl + "/xcx/designerlisticon.jpg",
- pathurl = '/share/pages/designerlist/designerlist?uid=' + (app.globalData.sharepersonobj&&app.globalData.sharepersonobj.id?app.globalData.sharepersonobj.id:app.globalData.personMsg.id) + '&ctp=' + app.globalData.clientype;
- if (!!e.target && e.target.dataset.type == 'designermsg') {
- let idx = e.target.dataset.idx;
- title = (this.data.designlist[idx].name ? this.data.designlist[idx].name : this.data.designlist[idx].opt_name) + '-' + app.globalData.companyobj.company_name;
- if (this.data.designlist[idx].headimgurl) {
- img = this.data.designlist[idx].headimgurl;
- }
- pathurl = '/share/pages/designermsg/designermsg?uid=' + (app.globalData.sharepersonobj&&app.globalData.sharepersonobj.id?app.globalData.sharepersonobj.id:app.globalData.personMsg.id) + '&did=' + this.data.designlist[idx].id + '&ctp=' + app.globalData.clientype;
- }
- return {
- title: title,
- imageUrl: img,
- path: pathurl
- }
- }
- })
|