C端小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

144 rindas
3.8 KiB

  1. const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
  2. let ifStoreApp = extConfig.attr.ifStoreApp;
  3. const Http = require("../utils/HttpBasics");
  4. var config = require("../config/config.js");
  5. Component({
  6. data: {
  7. selected: 0,
  8. "color": "#abb1be",
  9. "selectedColor": "#FD782D",
  10. "list": [{
  11. "pagePath": "/index/index",
  12. "iconPath": "../assets/images/home.png",
  13. "selectedIconPath": "../assets/images/home-a.png",
  14. "text": "首页"
  15. },
  16. {
  17. "pagePath": "/index/searchbar",
  18. "iconPath": "../assets/images/mendian.png",
  19. "selectedIconPath": "../assets/images/mendian-a.png",
  20. "text": "门店"
  21. },
  22. {
  23. "pagePath": "/index/passCar",
  24. "iconPath": "../assets/images/park.png",
  25. "selectedIconPath": "../assets/images/park-a.png",
  26. "text": "停车"
  27. },
  28. {
  29. "pagePath": "/index/user",
  30. "iconPath": "../assets/images/user.png",
  31. "selectedIconPath": "../assets/images/user-a.png",
  32. "text": "我的"
  33. }
  34. ]
  35. },
  36. attached() {
  37. if (ifStoreApp == 1) {
  38. this.setData({
  39. list: [{
  40. "pagePath": "/index/index",
  41. "iconPath": "../assets/images/home.png",
  42. "selectedIconPath": "../assets/images/home-a.png",
  43. "text": "首页"
  44. },
  45. {
  46. "pagePath": "/index/user",
  47. "iconPath": "../assets/images/user.png",
  48. "selectedIconPath": "../assets/images/user-a.png",
  49. "text": "我的"
  50. }
  51. ]
  52. })
  53. } else if (ifStoreApp == 2) {
  54. this.setData({
  55. list: [{
  56. "pagePath": "/index/index",
  57. "iconPath": "../assets/images/home.png",
  58. "selectedIconPath": "../assets/images/home-a.png",
  59. "text": "首页"
  60. },
  61. {
  62. "pagePath": "/index/searchbar",
  63. "iconPath": "../assets/images/mendian.png",
  64. "selectedIconPath": "../assets/images/mendian-a.png",
  65. "text": "门店"
  66. },
  67. {
  68. "pagePath": "/index/user",
  69. "iconPath": "../assets/images/user.png",
  70. "selectedIconPath": "../assets/images/user-a.png",
  71. "text": "我的"
  72. }
  73. ]
  74. })
  75. }
  76. },
  77. methods: {
  78. switchTab(e) {
  79. const data = e.currentTarget.dataset;
  80. const url = data.path;
  81. if(data.index==0||data.index==3){
  82. this.getTemplateId()
  83. }
  84. wx.switchTab({url});
  85. this.setData({
  86. selected: data.index
  87. })
  88. },
  89. getTemplateId() {
  90. Http.get({
  91. url: config.api.templateId,
  92. data: {
  93. pageNum: 1,
  94. pageSize: 100
  95. }
  96. }).then(res => {
  97. const {
  98. code,
  99. data
  100. } = res
  101. if (code == 200) {
  102. this.setData({
  103. templateId: data.list
  104. })
  105. this.setWxMessage()
  106. } else {
  107. return
  108. }
  109. })
  110. },
  111. setWxMessage() {
  112. let tmplIds = []
  113. this.data.templateId.map(res => {
  114. tmplIds.push(res.templateId)
  115. })
  116. console.log(tmplIds[0], "?|?|?|", this.data.templateId)
  117. wx.requestSubscribeMessage({
  118. tmplIds: tmplIds,
  119. success(res) {
  120. let _statue = null
  121. tmplIds.map((item,index)=>{//判读用户是否点击了确定
  122. if(res[item]=="accept"){
  123. _statue = 'ok'
  124. }
  125. })
  126. if (_statue == 'ok') {
  127. Http.post({
  128. url: config.api.wxMsg
  129. }).then(res => {
  130. console.log(res)
  131. })
  132. return
  133. }
  134. // for (let i = 0; i < tmplIds.length;i++){
  135. // if (res.tmplIds[i] == 'accept'){
  136. // console.log("发送")
  137. // }
  138. // }
  139. }
  140. })
  141. },
  142. }
  143. })