抖音c端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

216 lines
4.9 KiB

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