index.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. import {
  2. ApiModel
  3. } from "../../utils/api"
  4. const _Http = new ApiModel();
  5. import {
  6. TestVerify
  7. } from "../../utils/verify";
  8. const _Verify = new TestVerify();
  9. const processingData = require("../../utils/processingData");
  10. Page({
  11. /**
  12. * 页面的初始数据
  13. */
  14. data: {
  15. tabsActive: 0, //tabs选中项
  16. annunciateList: [], //通告列表
  17. sadClassify: [], //供需分类
  18. sadList: [], //供需列表
  19. brandSelect: 0, //品牌关注榜选择
  20. brandList0: [],
  21. brandList1: [],
  22. recruitName: "", //招商用户名
  23. recruitPhone: "", //招商手机号
  24. region: [], //地址
  25. recruitExplain: "", //备注
  26. newProductIndex1: 0,
  27. newProductIndex2: 0,
  28. repetitionSubmit: false, //是否重复提交招商表单
  29. tiveList: [], //直播列表
  30. portal_middle_1: '',
  31. },
  32. /**
  33. * 生命周期函数--监听页面加载
  34. */
  35. onLoad: function (options) {
  36. //获取管理端发布通告
  37. _Http.basic({
  38. "classname": "publicmethod.homepage.homepage",
  39. "method": "getNewestNoticeList",
  40. "content": {}
  41. }).then(res => {
  42. console.log(res)
  43. if (res.msg != '成功') {
  44. wx.showToast({
  45. title: res.data,
  46. icon: "none"
  47. });
  48. } else {
  49. processingData.imageType(res.data, 'cover');
  50. let list = [];
  51. if (res.data.length > 3) {
  52. list = res.data.slice(0, 3)
  53. } else {
  54. list = res.data;
  55. }
  56. this.setData({
  57. annunciateList: list
  58. })
  59. }
  60. });
  61. //获取供需分类
  62. _Http.basic({
  63. "classname": "publicmethod.homepage.homepage",
  64. "method": "query_typeselectList",
  65. "content": {
  66. "siteid": "BWJ"
  67. }
  68. }).then(res => {
  69. if (res.msg != '成功') {
  70. wx.showToast({
  71. title: res.data,
  72. icon: "none"
  73. });
  74. } else {
  75. res.data.unshift({
  76. ftype: "全部"
  77. })
  78. // return console.log(res.data)
  79. this.setData({
  80. sadClassify: res.data
  81. })
  82. }
  83. });
  84. //获取全部供需列表
  85. this.query_supplyanddemandList('');
  86. //获取直播列表
  87. _Http.basic({
  88. "classname": "publicmethod.live.live",
  89. "method": "getHomeLive",
  90. "content": {
  91. "getdatafromdbanyway": true,
  92. "livestatus": "live"
  93. }
  94. }, false).then(res => {
  95. console.log("直播列表", res)
  96. if (res.msg != '成功') {
  97. wx.showToast({
  98. title: res.data,
  99. icon: "none"
  100. });
  101. } else {
  102. this.setData({
  103. tiveList: res.data
  104. })
  105. }
  106. })
  107. //获取轮播图
  108. setTimeout(() => {
  109. this.getBanner()
  110. }, 300)
  111. //新发布商品
  112. this.getHotProductsList();
  113. // 获取品牌关注榜
  114. this.getHotAgentsList('沙发布')
  115. },
  116. /* 品牌关注榜切换 */
  117. concernsChange(e) {
  118. const {
  119. index
  120. } = e.target.dataset;
  121. this.setData({
  122. brandSelect: index
  123. })
  124. },
  125. /* 去报名展会 */
  126. toApply() {
  127. const data = this.data.portal_middle_1;
  128. wx.navigateTo({
  129. url: '/pages/scanQRCodes/register?id=' + data[0].fdataid,
  130. })
  131. },
  132. /* 获取轮播图 */
  133. getBanner() {
  134. let imgList = wx.getStorageSync('bannerDataList');
  135. console.log("imgList", imgList)
  136. if (imgList != "") {
  137. const bannerList = imgList.filter(value => value.flocation == 'portal_head');
  138. const portal_middle_1 = imgList.filter(value => value.flocation == 'portal_middle_1');
  139. /* const portal_middle_2 = imgList.filter(value => value.flocation == 'portal_middle_2');
  140. const portal_middle_3 = imgList.filter(value => value.flocation == 'portal_middle_3');
  141. const portal_middle_4 = imgList.filter(value => value.flocation == 'portal_middle_4'); */
  142. console.log(portal_middle_1)
  143. this.setData({
  144. swiperBannerList: bannerList[0].banner,
  145. portal_middle_1: portal_middle_1[0].banner
  146. });
  147. /* portal_middle_2: portal_middle_2[0].banner,
  148. portal_middle_3: portal_middle_3[0].banner,
  149. portal_middle_4: portal_middle_4[0].banner, */
  150. } else {
  151. setTimeout(() => {
  152. this.getBanner()
  153. }, 500)
  154. }
  155. },
  156. //跳转通过详情页
  157. toAnnunciateDetails(e) {
  158. const {
  159. index
  160. } = e.currentTarget.dataset;
  161. wx.navigateTo({
  162. url: '/pages/annunciate/details?id=' + this.data.annunciateList[index].tnoticeid + '&type=2',
  163. })
  164. },
  165. //表单提交
  166. submitForm() {
  167. if (this.data.repetitionSubmit) {
  168. wx.showModal({
  169. title: "提示",
  170. content: "已提交过信息,是否继续",
  171. success: (res) => {
  172. if (!res.confirm) return;
  173. this.insertBusiness()
  174. }
  175. })
  176. } else {
  177. this.insertBusiness();
  178. }
  179. },
  180. insertBusiness() {
  181. let add = {
  182. "province": "",
  183. "city": "",
  184. "county": "",
  185. }
  186. if (this.data.region.length > 0) {
  187. const a1 = this.data.region;
  188. add.province = a1[0]
  189. add.city = a1[1]
  190. add.county = a1[2]
  191. }
  192. _Http.basic({
  193. "classname": "publicmethod.homepage.homepage",
  194. "method": "insertBusiness",
  195. "content": {
  196. "province": add.province,
  197. "city": add.city,
  198. "county": add.county,
  199. "fname": this.data.recruitName,
  200. "fphone": this.data.recruitPhone,
  201. "fnote": this.data.recruitExplain
  202. }
  203. }).then(res => {
  204. if (res.msg != '成功') return wx.showToast({
  205. title: res.data,
  206. icon: "none"
  207. });
  208. wx.showToast({
  209. title: "提交成功"
  210. });
  211. this.setData({
  212. repetitionSubmit: true,
  213. recruitExplain: '',
  214. recruitName: "",
  215. recruitPhone: "",
  216. region: []
  217. })
  218. })
  219. },
  220. //手机号码
  221. phoneNumber(e) {
  222. if (!_Verify.phoneNumber(e.detail.value)) return wx.showToast({
  223. title: '请输入11位手机号码',
  224. icon: "none"
  225. });
  226. this.setData({
  227. recruitPhone: e.detail.value
  228. })
  229. },
  230. //招商表单输入
  231. recruitInput(e) {
  232. const {
  233. name
  234. } = e.currentTarget.dataset;
  235. this.setData({
  236. [name]: _Verify.Eliminate(e.detail.value)
  237. })
  238. },
  239. //省市区选择器
  240. bindRegionChange: function (e) {
  241. console.log('picker发送选择改变,携带值为', e.detail.value)
  242. this.setData({
  243. region: e.detail.value
  244. })
  245. },
  246. //新发布商品
  247. getHotProductsList() {
  248. let arr = ["窗帘", "沙发布"];
  249. for (let i = 0; i < arr.length; i++) {
  250. _Http.basic({
  251. "classname": "publicmethod.homepage.homepage",
  252. "method": "getNewProduct",
  253. "content": {
  254. "getdatafromdbanyway": true,
  255. "fprodclassname": arr[i],
  256. }
  257. }).then(res => {
  258. if (res.msg != '成功') return wx.showToast({
  259. title: res.data,
  260. icon: "none"
  261. });
  262. if (i == 0) {
  263. this.setData({
  264. newProduct1: res.data
  265. })
  266. } else {
  267. this.setData({
  268. newProduct2: res.data
  269. })
  270. }
  271. })
  272. };
  273. },
  274. /* 获取品牌关注榜 */
  275. getHotAgentsList(ftype) {
  276. _Http.basic({
  277. "classname": "publicmethod.homepage.homepage",
  278. "method": "getHotAgentsList",
  279. "content": {
  280. "ftype": ftype
  281. }
  282. }, false).then(res => {
  283. console.log("获取品牌关注榜", res)
  284. if (res.msg != '成功') return wx.showToast({
  285. title: res.data,
  286. icon: "none"
  287. });
  288. if (ftype == '沙发布') {
  289. this.setData({
  290. brandList0: res.data
  291. })
  292. } else if (ftype == '窗帘布') {
  293. this.setData({
  294. brandList1: res.data
  295. })
  296. }
  297. })
  298. if (ftype == '沙发布') this.getHotAgentsList('窗帘布')
  299. },
  300. /* 跳转供需详情 */
  301. toDetails(e) {
  302. const {
  303. index
  304. } = e.currentTarget.dataset;
  305. const data = this.data.sadList[index];
  306. wx.navigateTo({
  307. url: './details?tagentsid=' + data.tagentsid + '&tsupplyanddemandid=' + data.tsupplyanddemandid,
  308. })
  309. },
  310. /* 搜索 */
  311. toSearch() {
  312. wx.navigateTo({
  313. url: './search',
  314. })
  315. },
  316. /* 供需分类切换 */
  317. tabsOnChange(e) {
  318. const {
  319. title,
  320. index
  321. } = e.detail;
  322. this.setData({
  323. tabsActive: index
  324. })
  325. console.log(title)
  326. if (title == '全部') {
  327. this.query_supplyanddemandList('')
  328. } else {
  329. this.query_supplyanddemandList(title);
  330. }
  331. },
  332. /* 拉取供需分类列表 */
  333. query_supplyanddemandList(type) {
  334. _Http.basic({
  335. "classname": "publicmethod.homepage.homepage",
  336. "method": "query_supplyanddemandList",
  337. "content": {
  338. "getdatafromdbanyway": true,
  339. "pageNumber": 1,
  340. "pageSize": 20,
  341. "siteid": "BWJ",
  342. "where": {
  343. "ftype": type
  344. }
  345. }
  346. }, false).then(res => {
  347. if (res.msg != '成功') return wx.showToast({
  348. title: res.data,
  349. icon: "none"
  350. });
  351. this.setData({
  352. sadList: processingData.annunciateCheckdate(res.data)
  353. })
  354. })
  355. },
  356. /* 新品轮播图 */
  357. newProduct1(e) {
  358. this.setData({
  359. newProductIndex1: e.detail.current
  360. })
  361. },
  362. newProduct2(e) {
  363. this.setData({
  364. newProductIndex2: e.detail.current
  365. })
  366. },
  367. /* 跳转登录 */
  368. toLogin() {
  369. _Http.basic({
  370. "accesstoken": wx.getStorageSync('userData').token,
  371. "classname": "customer.usercenter.usermsg.usermsg",
  372. "method": "query_usermsg",
  373. "content": {}
  374. }).then(res=>{
  375. console.log("个人信息",res)
  376. if(res.msg=='失败'){
  377. wx.navigateTo({
  378. url: '/pages/login/index',
  379. })
  380. }else{
  381. wx.switchTab({
  382. url: '/pages/tabbar-pages/home/index',
  383. })
  384. // getApp().initSocket();
  385. }
  386. })
  387. /* */
  388. // getApp().getUserProfile();
  389. },
  390. /**
  391. * 生命周期函数--监听页面初次渲染完成
  392. */
  393. onReady: function () {
  394. },
  395. /**
  396. * 生命周期函数--监听页面显示
  397. */
  398. onShow: function () {
  399. },
  400. /**
  401. * 生命周期函数--监听页面隐藏
  402. */
  403. onHide: function () {
  404. },
  405. /**
  406. * 生命周期函数--监听页面卸载
  407. */
  408. onUnload: function () {
  409. },
  410. /**
  411. * 页面相关事件处理函数--监听用户下拉动作
  412. */
  413. onPullDownRefresh: function () {
  414. },
  415. /**
  416. * 页面上拉触底事件的处理函数
  417. */
  418. onReachBottom: function () {
  419. },
  420. /**
  421. * 用户点击右上角分享
  422. */
  423. onShareAppMessage: function () {
  424. }
  425. })