index.js 9.9 KB

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