C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

75 行
1.7 KiB

  1. const imgurl = require("../../utils/imgurl");
  2. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
  3. Page({
  4. /**
  5. * 组件的初始数据
  6. */
  7. data: {
  8. navigationBarHeight,
  9. teljpgUrl: imgurl.teljpg.url,
  10. showMore: true,
  11. more: "点击查看更多",
  12. hidden: "hidden",
  13. height: "",
  14. merchantVoList:[]
  15. },
  16. /**
  17. * 跳转到门店列表的详情页面
  18. */
  19. gotoDetail(e) {
  20. wx.navigateTo({
  21. url: `/pages/index/searchbar/detail/index?id=${e.currentTarget.dataset.id}`
  22. })
  23. },
  24. // 点击查看更多
  25. more: function () {
  26. let that = this;
  27. if (that.data.more == '点击查看更多') {
  28. this.setData({
  29. hidden: "",
  30. height: 'auto!important',
  31. more: "点击收起",
  32. showMore: true
  33. })
  34. } else {
  35. that.setData({
  36. hidden: "hidden",
  37. height: 4 * 140 + 'rpx',
  38. more: "点击查看更多",
  39. showMore: true
  40. })
  41. }
  42. },
  43. phone: function (e) {
  44. let that = this;
  45. wx.makePhoneCall({
  46. phoneNumber: e.target.dataset.merchantlinkphone
  47. });
  48. },
  49. /**
  50. * 生命周期函数--监听页面加载
  51. */
  52. onLoad: function (options) {
  53. if (options.merchantVoList){
  54. this.setData({
  55. merchantVoList: JSON.parse(options.merchantVoList)
  56. })
  57. let merchantVoList = this.data.merchantVoList;
  58. if (merchantVoList.length > 0) {
  59. if (merchantVoList.length <= 4) {
  60. this.setData({
  61. height: merchantVoList.length * 140 + 'rpx',
  62. showMore: false,
  63. hidden: "hidden"
  64. })
  65. } else if (merchantVoList && merchantVoList.length > 4) {
  66. this.setData({
  67. height: 4 * 140 + 'rpx'
  68. })
  69. }
  70. }
  71. }
  72. }
  73. })