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.

192 regels
5.1 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. this.getType()
  38. if (ifStoreApp == 1) {
  39. this.setData({
  40. list: [{
  41. "pagePath": "/index/index",
  42. "iconPath": "../assets/images/home.png",
  43. "selectedIconPath": "../assets/images/home-a.png",
  44. "text": "首页"
  45. },
  46. {
  47. "pagePath": "/index/user",
  48. "iconPath": "../assets/images/user.png",
  49. "selectedIconPath": "../assets/images/user-a.png",
  50. "text": "我的"
  51. }
  52. ]
  53. })
  54. } else if (ifStoreApp == 2) {
  55. this.setData({
  56. list: [{
  57. "pagePath": "/index/index",
  58. "iconPath": "../assets/images/home.png",
  59. "selectedIconPath": "../assets/images/home-a.png",
  60. "text": "首页"
  61. },
  62. {
  63. "pagePath": "/index/searchbar",
  64. "iconPath": "../assets/images/mendian.png",
  65. "selectedIconPath": "../assets/images/mendian-a.png",
  66. "text": "门店"
  67. },
  68. {
  69. "pagePath": "/index/user",
  70. "iconPath": "../assets/images/user.png",
  71. "selectedIconPath": "../assets/images/user-a.png",
  72. "text": "我的"
  73. }
  74. ]
  75. })
  76. }
  77. },
  78. methods: {
  79. switchTab(e) {
  80. const data = e.currentTarget.dataset;
  81. const url = data.path;
  82. if (data.index == 0 || data.index == 3) {
  83. this.getTemplateId()
  84. }
  85. wx.switchTab({
  86. url
  87. });
  88. this.setData({
  89. selected: data.index
  90. })
  91. },
  92. /**
  93. * 获取全局样式
  94. */
  95. getType() {
  96. Http.get({
  97. url: config.api.setType,
  98. data: {}
  99. }).then(res => {
  100. const {
  101. code,
  102. data
  103. } = res
  104. if (code == 200) {
  105. this.setData({
  106. list: [{
  107. "pagePath": "/index/index",
  108. "iconPath": `${data.t_in.icon}`,
  109. "selectedIconPath": `${data.t_in_std.icon}`,
  110. "text": "首页"
  111. },
  112. {
  113. "pagePath": "/index/searchbar",
  114. "iconPath": `${data.t_md.icon}`,
  115. "selectedIconPath": `${data.t_md_std.icon}`,
  116. "text": "门店"
  117. },
  118. {
  119. "pagePath": "/index/passCar",
  120. "iconPath": `${data.t_tc.icon}`,
  121. "selectedIconPath": `${data.t_tc_std.icon}`,
  122. "text": "停车"
  123. },
  124. {
  125. "pagePath": "/index/user",
  126. "iconPath": `${data.t_uc.icon}`,
  127. "selectedIconPath": `${data.t_uc_std.icon}`,
  128. "text": "我的"
  129. }
  130. ],
  131. selectedColor: `${data.t_uc_std.styleClass}`,
  132. })
  133. }
  134. })
  135. },
  136. getTemplateId() {
  137. Http.get({
  138. url: config.api.templateId,
  139. data: {
  140. pageNum: 1,
  141. pageSize: 100
  142. }
  143. }).then(res => {
  144. const {
  145. code,
  146. data
  147. } = res
  148. if (code == 200) {
  149. this.setData({
  150. templateId: data.list
  151. })
  152. this.setWxMessage()
  153. } else {
  154. return
  155. }
  156. })
  157. },
  158. setWxMessage() {
  159. let tmplIds = []
  160. this.data.templateId.map(res => {
  161. tmplIds.push(res.templateId)
  162. })
  163. console.log(tmplIds[0], "?|?|?|", this.data.templateId)
  164. wx.requestSubscribeMessage({
  165. tmplIds: tmplIds,
  166. success(res) {
  167. let _statue = null
  168. tmplIds.map((item, index) => { //判读用户是否点击了确定
  169. if (res[item] == "accept") {
  170. _statue = 'ok'
  171. }
  172. })
  173. if (_statue == 'ok') {
  174. Http.post({
  175. url: config.api.wxMsg
  176. }).then(res => {
  177. console.log(res)
  178. })
  179. return
  180. }
  181. // for (let i = 0; i < tmplIds.length;i++){
  182. // if (res.tmplIds[i] == 'accept'){
  183. // console.log("发送")
  184. // }
  185. // }
  186. }
  187. })
  188. },
  189. }
  190. })