index.js 12 KB

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