designerlist.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. const app = getApp();
  2. var utils = require("../../../utils/http"),
  3. page = 1;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. canIUseGetUserProfile: false,
  10. shareobj: {},
  11. employeeflag: false, //false是用户,true是员工
  12. top: app.globalData.statusBarHeight,
  13. hgt: app.globalData.titleBarHeight,
  14. companyobj: {},
  15. datashow: false,
  16. sourceflag: false,
  17. houseflag: false,
  18. likestyle: '',
  19. likehouse: '',
  20. stylearr: [],
  21. housearr: [],
  22. designlist: [],
  23. phoneFlag: app.globalData.phone, //true是有手机号,false是没有手机号
  24. type: '',
  25. orgarr: [],
  26. orgobj: {},
  27. noworg: {
  28. id: '',
  29. name: ''
  30. },
  31. orgName:'',
  32. orgId:'',
  33. orgshow: false,
  34. levelIds: ['1'],
  35. },
  36. /**
  37. * 生命周期函数--监听页面加载
  38. */
  39. onLoad: function (options) {
  40. wx.showLoading({
  41. title: '加载中...',
  42. })
  43. if (options.type) {
  44. this.setData({
  45. type: options.type
  46. })
  47. }
  48. this.setData({
  49. phoneFlag: app.globalData.phone
  50. })
  51. this.houseinfofun();
  52. this.orgfun();
  53. },
  54. dothis(){},
  55. orgfun() {
  56. const that = this;
  57. utils.$post({
  58. url: app.globalData.webUrl + 'client/designer/designer_org',
  59. header: {
  60. 'Authorization': 'bearer ' + app.globalData.token
  61. },
  62. data: {},
  63. success: function (res) {
  64. if (res.data.code == "0") {
  65. that.setData({
  66. orgobj: res.data.data,
  67. orgarr: res.data.data
  68. })
  69. }
  70. }
  71. })
  72. },
  73. handleLevel(e) {
  74. let id = e.currentTarget.dataset.id;
  75. this.setDepartData(this.data.orgobj, id);
  76. },
  77. setDepartData(list, id, level) {
  78. list.forEach(item => {
  79. if (id == item.id) {
  80. if (!item.children || !item.children.length) {
  81. wx.showToast({
  82. title: '没有下级部门了',
  83. icon: 'none',
  84. duration: 1000
  85. })
  86. } else {
  87. if (level) {
  88. this.setData({
  89. orgarr: item.children,
  90. levelIds: this.data.levelIds,
  91. })
  92. } else {
  93. this.data.levelIds.push(id);
  94. this.setData({
  95. orgarr: item.children,
  96. levelIds: this.data.levelIds,
  97. })
  98. }
  99. }
  100. return;
  101. } else {
  102. if (item.children && item.children.length) {
  103. this.setDepartData(item.children, id, level);
  104. }
  105. }
  106. })
  107. },
  108. lastLevel() {
  109. if (this.data.levelIds.length == 2) {
  110. this.setData({
  111. orgarr: this.data.orgobj,
  112. levelIds: ['1'],
  113. })
  114. } else {
  115. this.data.levelIds.splice(this.data.levelIds.length - 1, 1);
  116. this.setDepartData(this.data.orgobj, this.data.levelIds[this.data.levelIds.length - 1], 'lastlevel');
  117. }
  118. },
  119. radioChange(e) {
  120. let data = e.detail.value.split('~');
  121. let obj = {
  122. name: data[1],
  123. id: data[0]
  124. };
  125. this.setData({
  126. noworg: obj
  127. })
  128. },
  129. showorgtap(){
  130. this.setData({
  131. orgshow:true
  132. })
  133. },
  134. closeMask() {
  135. this.setData({
  136. orgshow: false,
  137. levelIds: ['1'],
  138. noworg: {
  139. id: '',
  140. name: ''
  141. },
  142. orgarr:this.data.orgobj
  143. })
  144. },
  145. confirmDepart() {
  146. this.setData({
  147. orgName: this.data.noworg.name,
  148. orgId: this.data.noworg.id,
  149. orgshow: false,
  150. levelIds: ['1'],
  151. noworg: {
  152. id: '',
  153. name: ''
  154. },
  155. orgarr:this.data.orgobj
  156. });
  157. this.designlistfun();
  158. },
  159. /**
  160. * 生命周期函数--监听页面初次渲染完成
  161. */
  162. onReady: function () {
  163. },
  164. showstyletap() {
  165. this.setData({
  166. sourceflag: true
  167. })
  168. },
  169. housetap() {
  170. this.setData({
  171. houseflag: true
  172. })
  173. },
  174. setsourcetap(e) {
  175. if (!e.detail) {
  176. this.setData({
  177. sourceflag: false
  178. })
  179. return false;
  180. }
  181. this.setData({
  182. likestyle: e.detail,
  183. sourceflag: false
  184. })
  185. this.designlistfun();
  186. },
  187. sethousetap(e) {
  188. if (!e.detail) {
  189. this.setData({
  190. houseflag: false
  191. })
  192. return false;
  193. }
  194. this.setData({
  195. likehouse: e.detail,
  196. houseflag: false
  197. })
  198. this.designlistfun();
  199. },
  200. setinitap() {
  201. this.setData({
  202. likehouse: '',
  203. likestyle: '',
  204. orgName:'',
  205. orgId:'',
  206. })
  207. this.designlistfun();
  208. },
  209. houseinfofun() {
  210. this.designlistfun();
  211. const that = this;
  212. utils.$post({
  213. url: app.globalData.webUrl + 'api/designer/select',
  214. header: {
  215. 'Authorization': 'bearer ' + app.globalData.token
  216. },
  217. data: {},
  218. success: function (res) {
  219. wx.hideLoading()
  220. let stylearr = [],
  221. housearr = [];
  222. if (res.data.code == "0") {
  223. for (let i in res.data.data.decostyles) {
  224. stylearr.push(res.data.data.decostyles[i].name);
  225. }
  226. for (let i in res.data.data.housetype) {
  227. housearr.push(res.data.data.housetype[i].name);
  228. }
  229. that.setData({
  230. stylearr: stylearr,
  231. housearr: housearr
  232. })
  233. }
  234. }
  235. })
  236. },
  237. designlistfun() {
  238. const that = this;
  239. page = 1;
  240. utils.$post({
  241. url: app.globalData.webUrl + 'client/designer/index',
  242. header: {
  243. 'Authorization': 'bearer ' + app.globalData.token
  244. },
  245. data: {
  246. at: that.data.likestyle,
  247. house: that.data.likehouse,
  248. limit: 10,
  249. page: 1,
  250. org_id:this.data.orgId
  251. },
  252. success: function (res) {
  253. if (res.data.code == "0") {
  254. that.setData({
  255. datashow: true,
  256. designlist: res.data.data
  257. })
  258. }
  259. wx.hideLoading()
  260. }
  261. })
  262. },
  263. apointap: function (e) {
  264. const that = this;
  265. let item = this.data.designlist[e.currentTarget.dataset.idx];
  266. utils.$post({
  267. url: app.globalData.webUrl + 'client/designer/designer_make',
  268. header: {
  269. 'Authorization': 'bearer ' + app.globalData.token
  270. },
  271. data: {
  272. designer_id: item.designer_id,
  273. designer_name: item.name,
  274. share_uid: app.globalData.shareuserid
  275. },
  276. success: function (res) {
  277. if (res.data.code == "0") {
  278. wx.showToast({
  279. title: res.data.msg,
  280. icon: 'none',
  281. duration: 2000
  282. })
  283. }
  284. }
  285. })
  286. },
  287. getPhoneNumberTap: function (res) {
  288. var that = this;
  289. console.log(res)
  290. if (res.detail.errMsg == 'getPhoneNumber:ok') {
  291. utils.$post({
  292. url: app.globalData.webUrl + 'api/users/setUserMobile',
  293. data: {
  294. encryptedData: res.detail.encryptedData,
  295. iv: res.detail.iv
  296. },
  297. header: {
  298. 'Authorization': 'bearer ' + app.globalData.token
  299. },
  300. success: function (r) {
  301. if (r.data.code == '0') {
  302. // wx.showLoading({
  303. // title: '加载中',
  304. // })
  305. app.globalData.phone = true;
  306. that.setData({
  307. phoneFlag: false
  308. })
  309. that.apointap(res);
  310. } else {
  311. that.setData({
  312. errorText: r.data.msg,
  313. errorflag: true
  314. })
  315. }
  316. }
  317. })
  318. }
  319. },
  320. designertap: function (e) {
  321. let item = this.data.designlist[e.currentTarget.dataset.idx];
  322. wx.navigateTo({
  323. url: '/customer/pages/designermsg/designermsg?did=' + item.id + "&sid=" + item.id + '&type=' + this.data.type
  324. })
  325. },
  326. /**
  327. * 生命周期函数--监听页面显示
  328. */
  329. onShow: function () {
  330. },
  331. golastap: function () {
  332. wx.reLaunch({
  333. url: '/pages/index/index?state=1',
  334. })
  335. },
  336. goindextap: function () {
  337. wx.reLaunch({
  338. url: '/pages/index/index?state=1',
  339. })
  340. },
  341. /**
  342. * 生命周期函数--监听页面隐藏
  343. */
  344. onHide: function () {
  345. },
  346. dothis() {},
  347. /**
  348. * 生命周期函数--监听页面卸载
  349. */
  350. onUnload: function () {
  351. },
  352. /**
  353. * 页面相关事件处理函数--监听用户下拉动作
  354. */
  355. onPullDownRefresh: function () {
  356. this.designlistfun();
  357. wx.stopPullDownRefresh();
  358. },
  359. /**
  360. * 页面上拉触底事件的处理函数
  361. */
  362. onReachBottom: function () {
  363. const that = this;
  364. page = page * 1 + 1;
  365. utils.$post({
  366. url: app.globalData.webUrl + 'client/designer/index',
  367. header: {
  368. 'Authorization': 'bearer ' + app.globalData.token
  369. },
  370. data: {
  371. at: that.data.likestyle,
  372. house: that.data.likehouse,
  373. limit: 10,
  374. page: page,
  375. org_id:this.data.orgId
  376. },
  377. success: function (res) {
  378. if (res.data.code == "0") {
  379. let designlist = that.data.designlist;
  380. designlist = designlist.concat(res.data.data);
  381. that.setData({
  382. designlist: designlist
  383. })
  384. }
  385. }
  386. })
  387. },
  388. onShareAppMessage: function (e) {
  389. // 公司名设计师:设计师名
  390. let that = this;
  391. let title = "设计大师-" + app.globalData.companyobj.company_name,
  392. img = app.globalData.imgUrl + "/xcx/designerlisticon.jpg",
  393. 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;
  394. if (!!e.target && e.target.dataset.type == 'designermsg') {
  395. let idx = e.target.dataset.idx;
  396. title = (this.data.designlist[idx].name ? this.data.designlist[idx].name : this.data.designlist[idx].opt_name) + '-' + app.globalData.companyobj.company_name;
  397. if (this.data.designlist[idx].headimgurl) {
  398. img = this.data.designlist[idx].headimgurl;
  399. }
  400. 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;
  401. }
  402. return {
  403. title: title,
  404. imageUrl: img,
  405. path: pathurl
  406. }
  407. }
  408. })