index.js 10 KB

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