业务交流通
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

index.js 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. // index.js
  2. // 获取应用实例
  3. const app = getApp()
  4. const $request = require('../../utils/request.js');
  5. const $util = require('../../utils/util.js');
  6. Page({
  7. data: {
  8. currentIndex: 0,
  9. keyword: "",
  10. // tab
  11. tabData: [
  12. {
  13. text: "全部",
  14. value: "all"
  15. },
  16. {
  17. text: "我关注的",
  18. value: "my1"
  19. },
  20. {
  21. text: "工商类",
  22. value: "工商类"
  23. },
  24. {
  25. text: "财税类",
  26. value: "财税类"
  27. },
  28. {
  29. text: "资质类",
  30. value: "资质类"
  31. },
  32. ],
  33. currentTab: "all",
  34. // 更多tab
  35. moreTabOption: [
  36. {
  37. text: "公司转让",
  38. value: "公司转让"
  39. },
  40. {
  41. text: "知识产权",
  42. value: "知识产权"
  43. },
  44. {
  45. text: "银行服务",
  46. value: "银行服务"
  47. },
  48. {
  49. text: "法律服务",
  50. value: "法律服务"
  51. },
  52. {
  53. text: "其他",
  54. value: "其他"
  55. },
  56. ],
  57. moreTab: "gengduo",
  58. moreTitle: "更多",
  59. // list数据加载
  60. // list块加载
  61. listLoading: true,
  62. // item行加载
  63. itemLoading: false,
  64. // 数据是否加载完成
  65. isFinished: false,
  66. listData: [],
  67. page: 1,
  68. size: 10,
  69. total: 0,
  70. // 是否加载数据,true加载,false不加载
  71. onRefresh: true,
  72. },
  73. onLoad() {
  74. this.getListData();
  75. },
  76. toggleMore() {
  77. this.selectComponent('#item').toggle();
  78. },
  79. // 搜索框输入同步值
  80. bindKeyInput: function (e) {
  81. this.setData({
  82. keyword: e.detail.value
  83. })
  84. },
  85. // 点击搜索
  86. toSearch(e) {
  87. console.log(this.data.keyword)
  88. this.setData({
  89. listData: [],
  90. onRefresh: true,
  91. isFinished: false,
  92. listLoading: true,
  93. page: 1,
  94. })
  95. this.getListData();
  96. },
  97. // tab切换
  98. tabChange(e) {
  99. let dataset = e.currentTarget.dataset;
  100. // if(dataset.value == 'my1'){
  101. // console.log(this.selectComponent('#shouquan'));
  102. // return
  103. // }
  104. // 如果实在加载中点击无效
  105. if (this.data.listLoading) {
  106. return
  107. }
  108. // 如果当前tab是选中直接点击无效
  109. if (this.data.currentTab == dataset.value) {
  110. return
  111. }
  112. this.setData({
  113. currentTab: dataset.value,
  114. moreTitle: "更多",
  115. moreTab: "gengduo"
  116. })
  117. this.toSearch();
  118. },
  119. // 更多tab切换
  120. moreTabChange(e) {
  121. // 如果实在加载中点击无效
  122. if (this.data.listLoading) {
  123. return
  124. }
  125. // 如果当前tab是选中直接点击无效
  126. if (this.data.moreTab == e.detail) {
  127. return
  128. }
  129. let moreTitle = "";
  130. this.data.moreTabOption.forEach(el => {
  131. if (el.value == e.detail) {
  132. moreTitle = el.text;
  133. }
  134. })
  135. this.setData({
  136. currentTab: "more",
  137. moreTab: e.detail,
  138. moreTitle
  139. })
  140. this.toSearch();
  141. },
  142. // 进入详情
  143. goDetails(e) {
  144. wx.navigateTo({
  145. url: '/pages/index/components/listDetails/Details',
  146. success: function (res) {
  147. // 通过eventChannel向被打开页面传送数据
  148. res.eventChannel.emit('acceptDataFromOpenerPage', { listDetail: e.detail })
  149. }
  150. })
  151. },
  152. // 获取tab数据
  153. getAllType() {
  154. $request.get('/businessCommunicationType/getAllType.action').then(res => {
  155. if (res.status == 0) {
  156. let { tabData, moreTabOption } = this.data;
  157. let datas = res.data;
  158. datas.forEach(el => {
  159. if (tabData.length < 5) {
  160. tabData.push({
  161. text: el.typeName,
  162. value: el.typeName
  163. })
  164. } else {
  165. moreTabOption.push({
  166. text: el.typeName,
  167. value: el.typeName
  168. })
  169. }
  170. })
  171. this.setData({
  172. tabData,
  173. moreTabOption
  174. })
  175. this.getListData();
  176. }
  177. }).catch(error => {
  178. console.log(error, 'error appletLogin')
  179. })
  180. },
  181. // 获取list数据
  182. getListData() {
  183. let { page, size, keyword, currentTab, moreTab } = this.data;
  184. let type = currentTab;
  185. if (currentTab == 'more') {
  186. type = moreTab;
  187. }
  188. if (type == 'all') {
  189. type = "";
  190. }
  191. $request.get('/businessCommunicationDemand/getDemandByKeywordOrType.action',
  192. { page, size, keyword, type, isInterest: 0 }
  193. ).then(res => {
  194. // console.log(res);
  195. this.setData({
  196. listLoading: false
  197. })
  198. let tempListData = this.data.listData;
  199. if (res.status == 0) {
  200. let datas = res.data;
  201. // 先push数据
  202. tempListData.push(...datas.demandList);
  203. tempListData.forEach(el => {
  204. el.createdOn = $util.formatTime(new Date(el.createdOn), true);
  205. if (typeof el.type == 'string') {
  206. el.type = el.type.split(',');
  207. }
  208. })
  209. // 设置总数
  210. this.setData({
  211. listData: tempListData,
  212. total: res.data.total,
  213. })
  214. // 如果数据大于了返回的总数
  215. if (tempListData.length >= this.data.total) {
  216. // 停止累加数据
  217. this.setData({
  218. onRefresh: false,
  219. itemLoading: false,
  220. isFinished: true,
  221. })
  222. } else {
  223. this.setData({
  224. onRefresh: true,
  225. itemLoading: false,
  226. isFinished: false,
  227. page: page + 1
  228. })
  229. }
  230. }
  231. }).catch(error => {
  232. console.log(error, 'error appletLogin')
  233. })
  234. },
  235. /**
  236. * 页面上拉触底事件的处理函数
  237. */
  238. onReachBottom() {
  239. if (this.data.onRefresh) {
  240. this.setData({
  241. itemLoading: true
  242. })
  243. this.getListData();
  244. }
  245. },
  246. setAttention() {
  247. if(!app.globalData.customerId){
  248. app.goLogin();
  249. return
  250. }
  251. let customerid = app.globalData.customerId;
  252. wx.navigateTo({
  253. url:"/pages/myModule/components/myAttention/myAttention",
  254. success: function (res) {
  255. // 通过eventChannel向被打开页面传送数据
  256. res.eventChannel.emit('customerid', { customerid })
  257. }
  258. })
  259. },
  260. })