diff --git a/assets/images/arrow.png b/assets/images/arrow.png new file mode 100644 index 0000000..de0feea Binary files /dev/null and b/assets/images/arrow.png differ diff --git a/pages/index/searchbar/index.js b/pages/index/searchbar/index.js index 8b2e101..12c861e 100644 --- a/pages/index/searchbar/index.js +++ b/pages/index/searchbar/index.js @@ -1,7 +1,6 @@ const Http = require("../../../utils/HttpBasics"); const imgurl = require("../../../utils/imgurl"); const config = require("../../../config/config"); -const QR = require("../../../utils/memberqrcode.js"); let app = getApp(); Page({ @@ -9,14 +8,30 @@ Page({ * 页面的初始数据 */ data: { + lists: [], + indexId: 0, teljpgUrl: imgurl.teljpg.url, }, - + // 左侧点击事件 + jumpIndex(e) { + let index = e.currentTarget.dataset.menuindex + let that = this + that.setData({ + indexId: index + }); + }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + var that = this + wx.getSystemInfo({ + success: function (res) { + that.setData({ + winHeight: res.windowHeight + }); + } + }); }, /** @@ -30,33 +45,66 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function () { - // merchantList let that = this; - that.getList(10,1) + that.getBussiness(); + that.getList(1); }, - getList(pageSize,pageNum){ + getBussiness:function(){ + let that = this; + Http.get({ + url: config.api.businessList, + data: { + pageNum: 1, + pageSize: 15, + type: 1 + } + }).then(res => { + console.log(res) + let businessObj = [{ id: 0, title: "全部", type: 1 }]; + that.setData({ + lists: res.data.list.concat(businessObj).sort(compare("id")) + }); + console.log(that.data.lists) + }) + .catch(err => { + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); + }) + }, + getList: function (pageNum) { let that = this; Http.get({ url: config.api.merchantList, data: { pageNum: pageNum, - pageSize: pageSize + pageSize: 15 } }).then(res => { + console.log(res) that.setData({ merchantVoList: res.data.list }) - console.log(res) - }).catch(err => { - console.log(err) + console.log(that.data.merchantVoList) }) + .catch(err => { + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); + }) }, phone: function (e) { let that = this; if (e.currentTarget.dataset.merchantlinkphone) { wx.makePhoneCall({ phoneNumber: e.currentTarget.dataset.merchantlinkphone - }); + }) } }, /** @@ -85,12 +133,18 @@ Page({ */ onReachBottom: function () { - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - } -}) \ No newline at end of file +}) +function compare(pro) { + return function (obj2, obj1) { + var val1 = obj1[pro]; + var val2 = obj2[pro]; + if (val1 < val2) { + return 1; + } else if (val1 > val2) { + return -1; + } else { + return 0; + } + } +} diff --git a/pages/index/searchbar/index.wxml b/pages/index/searchbar/index.wxml index 57e4467..54fc318 100644 --- a/pages/index/searchbar/index.wxml +++ b/pages/index/searchbar/index.wxml @@ -1,12 +1,31 @@ - -