C端小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

207 Zeilen
4.6 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 44) + "px"
  2. const Http = require("../utils/HttpBasics");
  3. const imgurl = require("../utils/imgurl");
  4. const config = require("../config/config");
  5. let app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. navigationBarHeight,
  12. lists: [],
  13. merchantVoList: [],
  14. indexId: 0,
  15. businessId: 0,
  16. windowHeight: "",
  17. page: 1,
  18. isFirstPage: false,
  19. isLastPage: false,
  20. teljpgUrl: imgurl.teljpg.url,
  21. map: imgurl.map.url, //商场地图
  22. mapUrl: '/pages/marketAtlas/marketAtlas', //跳转地图的路径
  23. },
  24. getFemgMap() { //判断时候对接封了地图
  25. Http.get({
  26. url: config.api.ifFengMap
  27. }).then(res => {
  28. if (res.data) { //
  29. let initMpa = {
  30. appName: res.data.appName,
  31. key: res.data.appKey,
  32. defaultThemeName: res.data.themeId,
  33. tenantId: res.data.tenantId,
  34. mapId: res.data.mapId
  35. }
  36. console.log(initMpa, "initMpa")
  37. this.setData({
  38. mapUrl: `/pages2/fengMap/fengMap?initMap=${JSON.stringify(initMpa)}`
  39. })
  40. } else {
  41. this.setData({
  42. mapUrl: "/pages/marketAtlas/marketAtlas"
  43. })
  44. }
  45. }).catch(err => {
  46. this.setData({
  47. mapUrl: "/pages/marketAtlas/marketAtlas"
  48. })
  49. })
  50. },
  51. //跳转到地图
  52. goMap() {
  53. wx.navigateTo({
  54. url: this.data.mapUrl,
  55. })
  56. },
  57. // 左侧点击事件
  58. jumpIndex(e) {
  59. let that = this;
  60. let index = e.currentTarget.dataset.menuindex;
  61. that.setData({
  62. indexId: index,
  63. businessId: index
  64. });
  65. that.setData({
  66. page: 1
  67. })
  68. that.getList(1, that.data.businessId);
  69. },
  70. goSearchBar() {
  71. wx.navigateTo({
  72. url: '/pages/searchbar/searchbar',
  73. })
  74. },
  75. /**
  76. * 跳转到门店列表的详情页面
  77. */
  78. gotoDetail(e) {
  79. wx.navigateTo({
  80. url: `/pages/index/searchbar/detail/index?id=${e.currentTarget.dataset.id}`
  81. })
  82. },
  83. /**
  84. * 生命周期函数--监听页面加载
  85. */
  86. onLoad: function(options) {
  87. let that = this;
  88. that.getBussiness();
  89. that.getList(1, 0);
  90. wx.showLoading({
  91. title: '加载中...',
  92. })
  93. },
  94. onShow() {
  95. this.getFemgMap()
  96. let that = this;
  97. if (typeof this.getTabBar === 'function' &&
  98. that.getTabBar()) {
  99. that.getTabBar().setData({
  100. selected: 1
  101. })
  102. };
  103. wx.getSystemInfo({
  104. success: function(res) {
  105. that.setData({
  106. windowHeight: res.windowHeight
  107. })
  108. },
  109. })
  110. },
  111. getBussiness: function() {
  112. let that = this;
  113. Http.get({
  114. url: config.api.businessList,
  115. data: {
  116. filter: 1
  117. }
  118. }).then(res => {
  119. that.setData({
  120. lists: [{
  121. id: 0,
  122. title: "全部",
  123. type: 1
  124. }].concat(res.data)
  125. });
  126. })
  127. .catch(err => {
  128. wx.showToast({
  129. title: err.errMsg,
  130. icon: 'none',
  131. duration: 2000,
  132. mask: false
  133. });
  134. })
  135. },
  136. getList: function(page, businessId) {
  137. let that = this;
  138. let data;
  139. if (businessId == 0) {
  140. data = {
  141. pageNum: page,
  142. pageSize: 8
  143. }
  144. } else {
  145. data = {
  146. pageNum: page,
  147. pageSize: 8,
  148. businessId: businessId
  149. }
  150. }
  151. Http.get({
  152. url: config.api.merchantList,
  153. data: data
  154. }).then(res => {
  155. wx.hideLoading();
  156. if (page == 1) {
  157. that.setData({
  158. merchantVoList: [],
  159. })
  160. }
  161. var tmpArr = that.data.merchantVoList;
  162. tmpArr.push.apply(tmpArr, res.data.list);
  163. // console.log(tmpArr)
  164. that.setData({
  165. merchantVoList: tmpArr,
  166. isFirstPage: res.data.isFirstPage,
  167. isLastPage: res.data.isLastPage
  168. })
  169. // console.log(that.data.merchantVoList)
  170. })
  171. .catch(err => {
  172. wx.hideLoading();
  173. wx.showToast({
  174. title: err.errMsg,
  175. icon: 'none',
  176. duration: 2000,
  177. mask: false
  178. });
  179. })
  180. },
  181. phone: function(e) {
  182. let that = this;
  183. if (e.currentTarget.dataset.merchantlinkphone) {
  184. wx.makePhoneCall({
  185. phoneNumber: e.currentTarget.dataset.merchantlinkphone
  186. })
  187. }
  188. },
  189. /**
  190. * 页面上拉触底事件的处理函数
  191. */
  192. onReachBottom: function() {
  193. let that = this;
  194. that.data.page++;
  195. that.setData({
  196. page: that.data.page
  197. });
  198. console.log(that.data.page);
  199. // 如果是最后一页
  200. //就不发送请求
  201. if (!that.data.isLastPage || that.data.isFirstPage && that.data.isLastPage) {
  202. that.getList(that.data.page, that.data.businessId);
  203. }
  204. }
  205. })