抖音小程序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.

80 lines
1.7 KiB

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