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

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