抖音c端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

162 wiersze
3.9 KiB

  1. const Http = require("../../utils/HttpBasics");
  2. var config = require("../../config/config.js");
  3. let app = getApp();
  4. Component({
  5. data: {
  6. selected: null,
  7. "color": "#abb1be",
  8. "selectedColor": "#6c5535",
  9. list: [{
  10. "pagePath": "/index/index",
  11. "text": "首页",
  12. "iconPath": "../../assets/images/home.png",
  13. "selectedIconPath": "../../assets/images/home_a.png"
  14. },
  15. {
  16. "pagePath": "/index/searchbar",
  17. "text": "门店",
  18. "iconPath": "../../assets/images/portal.png",
  19. "selectedIconPath": "../../assets/images/portal_a.png"
  20. },
  21. {
  22. "pagePath": "/pages/order/index/index",
  23. "text": "订单",
  24. "iconPath": "../../assets/images/dindan.png",
  25. "selectedIconPath": "../../assets/images/dindan_a.png"
  26. },
  27. {
  28. "pagePath": "/index/user",
  29. "text": "我的",
  30. "iconPath": "../../assets/images/user.png",
  31. "selectedIconPath": "../../assets/images/user_a.png"
  32. }
  33. ],
  34. },
  35. properties: {
  36. },
  37. lifetimes: {
  38. attached: function () {
  39. // 在组件实例进入页面节点树时执行
  40. console.log(app.globalData.selected, 'selected');
  41. this.setData({
  42. selected: app.globalData.selected,
  43. // templateId:app.globalData.templateId
  44. })
  45. },
  46. detached: function () {
  47. // 在组件实例被从页面节点树移除时执行
  48. },
  49. },
  50. methods: {
  51. navigateTo(e) {
  52. // this.setData({
  53. // list: this.data.home_a_img
  54. // })
  55. // console.log(this.data.home_a_img)
  56. const data = e.currentTarget.dataset;
  57. if (app.globalData.selected == data.index) {
  58. return
  59. }
  60. // tt.hideLoading();
  61. tt.showLoading({
  62. title: "加载中"
  63. });
  64. app.globalData.selected = data.index
  65. console.log(app.globalData.selected);
  66. const url = data.path;
  67. if (data.index == 0 || data.index == 3) {
  68. this.setWxMessage()
  69. }
  70. if (data.index == 2) {
  71. app.globalData.ifshowtab = true
  72. } else {
  73. app.globalData.ifshowtab = false
  74. }
  75. // tt.reLaunch({
  76. // url
  77. // });
  78. tt.reLaunch({
  79. url: url,
  80. success: (res) => {
  81. tt.hideLoading();
  82. },
  83. fail: (res) => {
  84. tt.hideLoading();
  85. },
  86. });
  87. },
  88. // getTemplateId() {
  89. // // console.log("隐藏")
  90. // // tt.hideTabBar()
  91. // Http.get({
  92. // url: config.api.templateId,
  93. // data: {
  94. // pageNum: 1,
  95. // pageSize: 100
  96. // }
  97. // }).then(res => {
  98. // const {
  99. // code,
  100. // data
  101. // } = res
  102. // if (code == 200) {
  103. // this.setData({
  104. // templateId: data.list
  105. // })
  106. // this.setWxMessage()
  107. // } else {
  108. // return
  109. // }
  110. // })
  111. // },
  112. setWxMessage() {
  113. if (app.globalData.templateId && app.globalData.templateId.length < 0) return
  114. console.log(app.globalData.templateId);
  115. let tmplIds = []
  116. app.globalData.templateId.map(res => {
  117. tmplIds.push(res.templateId)
  118. })
  119. tt.requestSubscribeMessage({
  120. tmplIds: tmplIds,
  121. success(res) {
  122. console.log("我重复订阅", res)
  123. let _statue = null
  124. tmplIds.map((item, index) => { //判读用户是否点击了确定
  125. if (res[item] == "accept") {
  126. _statue = 'ok'
  127. }
  128. })
  129. if (_statue == 'ok') {
  130. Http.post({
  131. url: config.api.wxMsg
  132. }).then(res => {
  133. console.log(res)
  134. })
  135. return
  136. }
  137. },
  138. fail(error) {
  139. //订阅失败
  140. console.log("订阅失败, 错误详情: ", error);
  141. // tt.showToast({
  142. // title: "订阅失败",
  143. // icon: "fail",
  144. // });
  145. },
  146. complete() {
  147. }
  148. })
  149. },
  150. }
  151. })