index.js 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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. "pageNumber": 1,
  188. "pageSize": 5,
  189. "ftype": arr[i]
  190. }
  191. }).then(res => {
  192. if (res.msg != '成功') return wx.showToast({
  193. title: res.data,
  194. icon: "none"
  195. });
  196. if (i == 0) {
  197. this.setData({
  198. newProduct1: res.data
  199. })
  200. } else {
  201. this.setData({
  202. newProduct2: res.data
  203. })
  204. }
  205. })
  206. };
  207. },
  208. /* 获取品牌关注榜 */
  209. getHotAgentsList(ftype) {
  210. _Http.basic({
  211. "classname": "publicmethod.homepage.homepage",
  212. "method": "getHotAgentsList",
  213. "content": {
  214. "ftype": ftype
  215. }
  216. }, false).then(res => {
  217. if (res.msg != '成功') return wx.showToast({
  218. title: res.data,
  219. icon: "none"
  220. });
  221. if (ftype == '沙发布') {
  222. this.setData({
  223. brandList0: res.data
  224. })
  225. } else if (ftype == '窗帘布') {
  226. this.setData({
  227. brandList1: res.data
  228. })
  229. }
  230. })
  231. if (ftype == '沙发布') this.getHotAgentsList('窗帘布')
  232. },
  233. /* 品牌关注榜选项 */
  234. selectOption(e) {
  235. let index = null;
  236. if (e.target.dataset.index) {
  237. index = e.target.dataset.index;
  238. } else {
  239. index = e.detail.current;
  240. }
  241. if (index == this.data.brandSelect) return;
  242. this.setData({
  243. brandSelect: index
  244. })
  245. },
  246. /* 跳转供需详情 */
  247. toDetails(e) {
  248. const {
  249. index
  250. } = e.currentTarget.dataset;
  251. const data = this.data.sadList[index];
  252. wx.navigateTo({
  253. url: './details?tagentsid=' + data.tagentsid + '&tsupplyanddemandid=' + data.tsupplyanddemandid,
  254. })
  255. },
  256. /* 供需分类切换 */
  257. tabsOnChange(e) {
  258. const {
  259. title,
  260. index
  261. } = e.detail;
  262. (title == '全部供需') ? this.query_supplyanddemandList(''): this.query_supplyanddemandList(title);
  263. },
  264. /* 拉取供需分类列表 */
  265. query_supplyanddemandList(type) {
  266. _Http.basic({
  267. "classname": "publicmethod.homepage.homepage",
  268. "method": "query_supplyanddemandList",
  269. "content": {
  270. "getdatafromdbanyway": true,
  271. "pageNumber": 1,
  272. "pageSize": 20,
  273. "siteid": "BWJ",
  274. "where": {
  275. "ftype": type
  276. }
  277. }
  278. }).then(res => {
  279. if (res.msg != '成功') return wx.showToast({
  280. title: res.data,
  281. icon: "none"
  282. });
  283. this.setData({
  284. sadList: processingData.annunciateCheckdate(res.data)
  285. })
  286. })
  287. },
  288. /* 新品轮播图 */
  289. newProduct1(e) {
  290. this.setData({
  291. newProductIndex1: e.detail.current
  292. })
  293. },
  294. newProduct2(e) {
  295. this.setData({
  296. newProductIndex2: e.detail.current
  297. })
  298. },
  299. /* 跳转登录 */
  300. toLogin() {
  301. wx.navigateTo({
  302. url: '/pages/login/index',
  303. })
  304. },
  305. /**
  306. * 生命周期函数--监听页面初次渲染完成
  307. */
  308. onReady: function () {
  309. },
  310. /**
  311. * 生命周期函数--监听页面显示
  312. */
  313. onShow: function () {
  314. },
  315. /**
  316. * 生命周期函数--监听页面隐藏
  317. */
  318. onHide: function () {
  319. },
  320. /**
  321. * 生命周期函数--监听页面卸载
  322. */
  323. onUnload: function () {
  324. },
  325. /**
  326. * 页面相关事件处理函数--监听用户下拉动作
  327. */
  328. onPullDownRefresh: function () {
  329. },
  330. /**
  331. * 页面上拉触底事件的处理函数
  332. */
  333. onReachBottom: function () {
  334. },
  335. /**
  336. * 用户点击右上角分享
  337. */
  338. onShareAppMessage: function () {
  339. }
  340. })