123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- import {
- ApiModel
- } from "../../utils/api"
- const _Http = new ApiModel();
- import {
- TestVerify
- } from "../../utils/verify";
- const _Verify = new TestVerify();
- const processingData = require("../../utils/processingData");
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- tabsActive: 0, //tabs选中项
- annunciateList: [], //通告列表
- sadClassify: [], //供需分类
- sadList: [], //供需列表
- brandSelect: 0, //品牌关注榜选择
- brandList0: [],
- brandList1: [],
- recruitName: "", //招商用户名
- recruitPhone: "", //招商手机号
- region: [], //地址
- recruitExplain: "", //备注
- newProductIndex1: 0,
- newProductIndex2: 0,
- repetitionSubmit: false, //是否重复提交招商表单
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- //获取管理端发布通告
- _Http.basic({
- "classname": "publicmethod.homepage.homepage",
- "method": "getNewestNoticeList",
- "content": {
- "pageSize": 3
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- processingData.imageType(res.data, 'cover');
- this.setData({
- annunciateList: res.data
- })
- });
- //获取供需分类
- _Http.basic({
- "classname": "publicmethod.homepage.homepage",
- "method": "query_typeselectList",
- "content": {
- "siteid": "BWJ"
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- this.setData({
- sadClassify: res.data
- })
- });
- //获取全部供需列表
- this.query_supplyanddemandList('')
- //新发布商品
- this.getHotProductsList();
- // 获取品牌关注榜
- this.getHotAgentsList('沙发布')
- //获取轮播图
- setTimeout(() => {
- this.getBanner()
- }, 300)
- },
- /* 获取轮播图 */
- getBanner() {
- let imgList = wx.getStorageSync('bannerDataList');
- if (imgList != "") {
- const bannerList = imgList.filter(value => value.flocation == 'portal_head');
- const portal_middle_1 = imgList.filter(value => value.flocation == 'portal_middle_1');
- const portal_middle_2 = imgList.filter(value => value.flocation == 'portal_middle_2');
- const portal_middle_3 = imgList.filter(value => value.flocation == 'portal_middle_3');
- const portal_middle_4 = imgList.filter(value => value.flocation == 'portal_middle_4');
- this.setData({
- swiperBannerList: bannerList[0].banner,
- portal_middle_1: portal_middle_1[0].banner,
- portal_middle_2: portal_middle_2[0].banner,
- portal_middle_3: portal_middle_3[0].banner,
- portal_middle_4: portal_middle_4[0].banner,
- });
- } else {
- setTimeout(() => {
- this.getBanner()
- }, 500)
- }
- },
- //跳转通过详情页
- toAnnunciateDetails(e) {
- const {
- index
- } = e.currentTarget.dataset;
- wx.navigateTo({
- url: '/pages/annunciate/details?id=' + this.data.annunciateList[index].tnoticeid + '&type=2',
- })
- },
- //表单提交
- submitForm() {
- if (this.data.repetitionSubmit) {
- wx.showModal({
- title: "提示",
- content: "已提交过信息,是否继续",
- success: (res) => {
- if (!res.confirm) return;
- this.insertBusiness()
- }
- })
- } else {
- this.insertBusiness();
- }
- },
- insertBusiness() {
- let add = {
- "province": "",
- "city": "",
- "county": "",
- }
- if (this.data.region.length > 0) {
- const a1 = this.data.region;
- add.province = a1[0]
- add.city = a1[1]
- add.county = a1[2]
- }
- _Http.basic({
- "classname": "publicmethod.homepage.homepage",
- "method": "insertBusiness",
- "content": {
- "province": add.province,
- "city": add.city,
- "county": add.county,
- "fname": this.data.recruitName,
- "fphone": this.data.recruitPhone,
- "fnote": this.data.recruitExplain
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- wx.showToast({
- title: "提交成功"
- });
- this.setData({
- repetitionSubmit: true,
- recruitExplain: '',
- recruitName: "",
- recruitPhone: "",
- region: []
- })
- })
- },
- //手机号码
- phoneNumber(e) {
- if (!_Verify.phoneNumber(e.detail.value)) return wx.showToast({
- title: '请输入11位手机号码',
- icon: "none"
- });
- this.setData({
- recruitPhone: e.detail.value
- })
- },
- //招商表单输入
- recruitInput(e) {
- const {
- name
- } = e.currentTarget.dataset;
- this.setData({
- [name]: _Verify.Eliminate(e.detail.value)
- })
- },
- //省市区选择器
- bindRegionChange: function (e) {
- console.log('picker发送选择改变,携带值为', e.detail.value)
- this.setData({
- region: e.detail.value
- })
- },
- //新发布商品
- getHotProductsList() {
- let arr = ["窗帘布", "沙发布"];
- for (let i = 0; i < arr.length; i++) {
- _Http.basic({
- "classname": "publicmethod.homepage.homepage",
- "method": "getHotProductsList",
- "content": {
- "getdatafromdbanyway": true,
- "pageNumber": 1,
- "pageSize": 5,
- "ftype": arr[i]
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- if (i == 0) {
- this.setData({
- newProduct1: res.data
- })
- } else {
- this.setData({
- newProduct2: res.data
- })
- }
- })
- };
- },
- /* 获取品牌关注榜 */
- getHotAgentsList(ftype) {
- _Http.basic({
- "classname": "publicmethod.homepage.homepage",
- "method": "getHotAgentsList",
- "content": {
- "ftype": ftype
- }
- }, false).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- if (ftype == '沙发布') {
- this.setData({
- brandList0: res.data
- })
- } else if (ftype == '窗帘布') {
- this.setData({
- brandList1: res.data
- })
- }
- })
- if (ftype == '沙发布') this.getHotAgentsList('窗帘布')
- },
- /* 品牌关注榜选项 */
- selectOption(e) {
- let index = null;
- if (e.target.dataset.index) {
- index = e.target.dataset.index;
- } else {
- index = e.detail.current;
- }
- if (index == this.data.brandSelect) return;
- this.setData({
- brandSelect: index
- })
- },
- /* 跳转供需详情 */
- toDetails(e) {
- const {
- index
- } = e.currentTarget.dataset;
- const data = this.data.sadList[index];
- wx.navigateTo({
- url: './details?tagentsid=' + data.tagentsid + '&tsupplyanddemandid=' + data.tsupplyanddemandid,
- })
- },
- /* 供需分类切换 */
- tabsOnChange(e) {
- const {
- title,
- index
- } = e.detail;
- (title == '全部供需') ? this.query_supplyanddemandList(''): this.query_supplyanddemandList(title);
- },
- /* 拉取供需分类列表 */
- query_supplyanddemandList(type) {
- _Http.basic({
- "classname": "publicmethod.homepage.homepage",
- "method": "query_supplyanddemandList",
- "content": {
- "getdatafromdbanyway": true,
- "pageNumber": 1,
- "pageSize": 20,
- "siteid": "BWJ",
- "where": {
- "ftype": type
- }
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- this.setData({
- sadList: processingData.annunciateCheckdate(res.data)
- })
- })
- },
- /* 新品轮播图 */
- newProduct1(e) {
- this.setData({
- newProductIndex1: e.detail.current
- })
- },
- newProduct2(e) {
- this.setData({
- newProductIndex2: e.detail.current
- })
- },
- /* 跳转登录 */
- toLogin() {
- wx.navigateTo({
- url: '/pages/login/index',
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|