抖音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.

219 lines
5.2 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 + `?mallTenantId=${tt.getStorageSync('mallTenantId')||""}`
  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}&mallTenantId=${tt.getStorageSync('mallTenantId') || ""}`
  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. mallTenantId: tt.getStorageSync('mallTenantId') || ""
  127. }
  128. }).then(res => {
  129. that.setData({
  130. lists: [{
  131. id: 0,
  132. title: "全部",
  133. type: 1
  134. }].concat(res.data)
  135. });
  136. })
  137. .catch(err => {
  138. tt.showToast({
  139. title: err.errMsg,
  140. icon: 'none',
  141. duration: 2000,
  142. mask: false
  143. });
  144. })
  145. },
  146. getList: function (page, businessId) {
  147. let that = this;
  148. let data;
  149. if (businessId == 0) {
  150. data = {
  151. pageNum: page,
  152. pageSize: 8,
  153. mallTenantId: tt.getStorageSync('mallTenantId') || ""
  154. }
  155. } else {
  156. data = {
  157. pageNum: page,
  158. pageSize: 8,
  159. businessId: businessId,
  160. mallTenantId: tt.getStorageSync('mallTenantId') || ""
  161. }
  162. }
  163. Http.get({
  164. url: config.api.merchantList,
  165. data: data
  166. }).then(res => {
  167. tt.hideLoading();
  168. if (page == 1) {
  169. that.setData({
  170. merchantVoList: [],
  171. })
  172. }
  173. var tmpArr = that.data.merchantVoList;
  174. tmpArr.push.apply(tmpArr, res.data.list);
  175. // console.log(tmpArr)
  176. that.setData({
  177. merchantVoList: tmpArr,
  178. isFirstPage: res.data.isFirstPage,
  179. isLastPage: res.data.isLastPage
  180. })
  181. // console.log(that.data.merchantVoList)
  182. })
  183. .catch(err => {
  184. tt.hideLoading();
  185. tt.showToast({
  186. title: err.errMsg,
  187. icon: 'none',
  188. duration: 2000,
  189. mask: false
  190. });
  191. })
  192. },
  193. phone: function (e) {
  194. let that = this;
  195. if (e.currentTarget.dataset.merchantlinkphone) {
  196. tt.makePhoneCall({
  197. phoneNumber: e.currentTarget.dataset.merchantlinkphone
  198. })
  199. }
  200. },
  201. /**
  202. * 页面上拉触底事件的处理函数
  203. */
  204. onReachBottom: function () {
  205. let that = this;
  206. that.data.page++;
  207. that.setData({
  208. page: that.data.page
  209. });
  210. console.log(that.data.page);
  211. // 如果是最后一页
  212. //就不发送请求
  213. if (!that.data.isLastPage || that.data.isFirstPage && that.data.isLastPage) {
  214. that.getList(that.data.page, that.data.businessId);
  215. }
  216. }
  217. })