C端小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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