C端小程序
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

151 рядки
2.8 KiB

  1. const Http = require("../../../utils/HttpBasics");
  2. const imgurl = require("../../../utils/imgurl");
  3. const config = require("../../../config/config");
  4. let app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. lists: [],
  11. indexId: 0,
  12. teljpgUrl: imgurl.teljpg.url,
  13. },
  14. // 左侧点击事件
  15. jumpIndex(e) {
  16. let index = e.currentTarget.dataset.menuindex
  17. let that = this
  18. that.setData({
  19. indexId: index
  20. });
  21. },
  22. /**
  23. * 生命周期函数--监听页面加载
  24. */
  25. onLoad: function (options) {
  26. var that = this
  27. wx.getSystemInfo({
  28. success: function (res) {
  29. that.setData({
  30. winHeight: res.windowHeight
  31. });
  32. }
  33. });
  34. },
  35. /**
  36. * 生命周期函数--监听页面初次渲染完成
  37. */
  38. onReady: function () {
  39. },
  40. /**
  41. * 生命周期函数--监听页面显示
  42. */
  43. onShow: function () {
  44. let that = this;
  45. that.getBussiness();
  46. that.getList(1);
  47. },
  48. getBussiness:function(){
  49. let that = this;
  50. Http.get({
  51. url: config.api.businessList,
  52. data: {
  53. pageNum: 1,
  54. pageSize: 15,
  55. type: 1
  56. }
  57. }).then(res => {
  58. console.log(res)
  59. let businessObj = [{ id: 0, title: "全部", type: 1 }];
  60. that.setData({
  61. lists: res.data.list.concat(businessObj).sort(compare("id"))
  62. });
  63. console.log(that.data.lists)
  64. })
  65. .catch(err => {
  66. wx.showToast({
  67. title: err.errMsg,
  68. icon: 'none',
  69. duration: 2000,
  70. mask: false
  71. });
  72. })
  73. },
  74. getList: function (pageNum) {
  75. let that = this;
  76. Http.get({
  77. url: config.api.merchantList,
  78. data: {
  79. pageNum: pageNum,
  80. pageSize: 15
  81. }
  82. }).then(res => {
  83. console.log(res)
  84. that.setData({
  85. merchantVoList: res.data.list
  86. })
  87. console.log(that.data.merchantVoList)
  88. })
  89. .catch(err => {
  90. wx.showToast({
  91. title: err.errMsg,
  92. icon: 'none',
  93. duration: 2000,
  94. mask: false
  95. });
  96. })
  97. },
  98. phone: function (e) {
  99. let that = this;
  100. if (e.currentTarget.dataset.merchantlinkphone) {
  101. wx.makePhoneCall({
  102. phoneNumber: e.currentTarget.dataset.merchantlinkphone
  103. })
  104. }
  105. },
  106. /**
  107. * 生命周期函数--监听页面隐藏
  108. */
  109. onHide: function () {
  110. },
  111. /**
  112. * 生命周期函数--监听页面卸载
  113. */
  114. onUnload: function () {
  115. },
  116. /**
  117. * 页面相关事件处理函数--监听用户下拉动作
  118. */
  119. onPullDownRefresh: function () {
  120. },
  121. /**
  122. * 页面上拉触底事件的处理函数
  123. */
  124. onReachBottom: function () {
  125. }
  126. })
  127. function compare(pro) {
  128. return function (obj2, obj1) {
  129. var val1 = obj1[pro];
  130. var val2 = obj2[pro];
  131. if (val1 < val2) {
  132. return 1;
  133. } else if (val1 > val2) {
  134. return -1;
  135. } else {
  136. return 0;
  137. }
  138. }
  139. }