C端小程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

235 líneas
6.3 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. let app = getApp();
  6. Component({
  7. data: {
  8. home_a_img:[],
  9. selected: 0,
  10. "color": "#abb1be",
  11. "selectedColor": "#FD782D",
  12. "list": [{
  13. "pagePath": "/index/index",
  14. "iconPath": "../assets/images/home.png",
  15. "selectedIconPath": "../assets/images/home-a.png",
  16. "text": "首页"
  17. },
  18. {
  19. "pagePath": "/index/searchbar",
  20. "iconPath": "../assets/images/mendian.png",
  21. "selectedIconPath": "../assets/images/mendian-a.png",
  22. "text": "门店"
  23. },
  24. {
  25. "pagePath": "/index/passCar",
  26. "iconPath": "../assets/images/park.png",
  27. "selectedIconPath": "../assets/images/park-a.png",
  28. "text": "停车"
  29. },
  30. {
  31. "pagePath": "/index/user",
  32. "iconPath": "../assets/images/user.png",
  33. "selectedIconPath": "../assets/images/user-a.png",
  34. "text": "我的"
  35. }
  36. ]
  37. },
  38. created(){
  39. this.getType()
  40. },
  41. // lifetimes: {
  42. // attached: function () {
  43. // // 在组件实例进入页面节点树时执行
  44. // },
  45. // },
  46. attached() {
  47. if (ifStoreApp == 1) {
  48. this.setData({
  49. list: [{
  50. "pagePath": "/index/index",
  51. "iconPath": "../assets/images/home.png",
  52. "selectedIconPath": "../assets/images/home-a.png",
  53. "text": "首页"
  54. },
  55. {
  56. "pagePath": "/index/user",
  57. "iconPath": "../assets/images/user.png",
  58. "selectedIconPath": "../assets/images/user-a.png",
  59. "text": "我的"
  60. }
  61. ]
  62. })
  63. } else if (ifStoreApp == 2) {
  64. this.setData({
  65. list: [{
  66. "pagePath": "/index/index",
  67. "iconPath": "../assets/images/home.png",
  68. "selectedIconPath": "../assets/images/home-a.png",
  69. "text": "首页"
  70. },
  71. {
  72. "pagePath": "/index/searchbar",
  73. "iconPath": "../assets/images/mendian.png",
  74. "selectedIconPath": "../assets/images/mendian-a.png",
  75. "text": "门店"
  76. },
  77. {
  78. "pagePath": "/index/user",
  79. "iconPath": "../assets/images/user.png",
  80. "selectedIconPath": "../assets/images/user-a.png",
  81. "text": "我的"
  82. }
  83. ]
  84. })
  85. }
  86. },
  87. methods: {
  88. switchTab(e) {
  89. // this.setData({
  90. // list: this.data.home_a_img
  91. // })
  92. // console.log(this.data.home_a_img)
  93. const data = e.currentTarget.dataset;
  94. const url = data.path;
  95. if (data.index == 0 || data.index == 3) {
  96. this.getTemplateId()
  97. }
  98. wx.switchTab({
  99. url
  100. });
  101. this.setData({
  102. selected: data.index
  103. })
  104. },
  105. /**
  106. * 获取全局样式
  107. */
  108. getType() {
  109. Http.get({
  110. url: config.api.setType,
  111. data: {}
  112. }).then(res => {
  113. const {
  114. code,
  115. data
  116. } = res
  117. if (code == 200) {
  118. this.setData({
  119. list: [{
  120. "pagePath": "/index/index",
  121. "iconPath": `${data.t_in.icon}`,
  122. "selectedIconPath": `${data.t_in_std.icon}`,
  123. "text": "首页"
  124. },
  125. {
  126. "pagePath": "/index/searchbar",
  127. "iconPath": `${data.t_md.icon}`,
  128. "selectedIconPath": `${data.t_md_std.icon}`,
  129. "text": "门店"
  130. },
  131. {
  132. "pagePath": "/index/passCar",
  133. "iconPath": `${data.t_tc.icon}`,
  134. "selectedIconPath": `${data.t_tc_std.icon}`,
  135. "text": "停车"
  136. },
  137. {
  138. "pagePath": "/index/user",
  139. "iconPath": `${data.t_uc.icon}`,
  140. "selectedIconPath": `${data.t_uc_std.icon}`,
  141. "text": "我的"
  142. }
  143. ],
  144. selectedColor: `${data.t_uc_std.styleClass}`,
  145. home_a_img: [{
  146. "pagePath": "/index/index",
  147. "iconPath": `${data.t_in.icon}`,
  148. "selectedIconPath": `${data.t_in_std.icon}`,
  149. "text": "首页"
  150. },
  151. {
  152. "pagePath": "/index/searchbar",
  153. "iconPath": `${data.t_md.icon}`,
  154. "selectedIconPath": `${data.t_md_std.icon}`,
  155. "text": "门店"
  156. },
  157. {
  158. "pagePath": "/index/passCar",
  159. "iconPath": `${data.t_tc.icon}`,
  160. "selectedIconPath": `${data.t_tc_std.icon}`,
  161. "text": "停车"
  162. },
  163. {
  164. "pagePath": "/index/user",
  165. "iconPath": `${data.t_uc.icon}`,
  166. "selectedIconPath": `${data.t_uc_std.icon}`,
  167. "text": "我的"
  168. }
  169. ],
  170. })
  171. }
  172. // console.log(this.data.list[0].selectedIconPath, '99999999999999999999999999999999999999999')
  173. })
  174. },
  175. getTemplateId() {
  176. Http.get({
  177. url: config.api.templateId,
  178. data: {
  179. pageNum: 1,
  180. pageSize: 100
  181. }
  182. }).then(res => {
  183. const {
  184. code,
  185. data
  186. } = res
  187. if (code == 200) {
  188. this.setData({
  189. templateId: data.list
  190. })
  191. this.setWxMessage()
  192. } else {
  193. return
  194. }
  195. })
  196. },
  197. setWxMessage() {
  198. let tmplIds = []
  199. this.data.templateId.map(res => {
  200. tmplIds.push(res.templateId)
  201. })
  202. // console.log(tmplIds[0], "?|?|?|", this.data.templateId)
  203. wx.requestSubscribeMessage({
  204. tmplIds: tmplIds,
  205. success(res) {
  206. let _statue = null
  207. tmplIds.map((item, index) => { //判读用户是否点击了确定
  208. if (res[item] == "accept") {
  209. _statue = 'ok'
  210. }
  211. })
  212. if (_statue == 'ok') {
  213. Http.post({
  214. url: config.api.wxMsg
  215. }).then(res => {
  216. console.log(res)
  217. })
  218. return
  219. }
  220. // for (let i = 0; i < tmplIds.length;i++){
  221. // if (res.tmplIds[i] == 'accept'){
  222. // console.log("发送")
  223. // }
  224. // }
  225. }
  226. })
  227. },
  228. }
  229. })