index.js 10 KB

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