|
- const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
- let ifStoreApp = extConfig.attr.ifStoreApp;
- const Http = require("../utils/HttpBasics");
- var config = require("../config/config.js");
- Component({
- data: {
- selected: 0,
- "color": "#abb1be",
- "selectedColor": "#FD782D",
- "list": [{
- "pagePath": "/index/index",
- "iconPath": "../assets/images/home.png",
- "selectedIconPath": "../assets/images/home-a.png",
- "text": "首页"
- },
- {
- "pagePath": "/index/searchbar",
- "iconPath": "../assets/images/mendian.png",
- "selectedIconPath": "../assets/images/mendian-a.png",
- "text": "门店"
- },
- {
- "pagePath": "/index/passCar",
- "iconPath": "../assets/images/park.png",
- "selectedIconPath": "../assets/images/park-a.png",
- "text": "停车"
- },
- {
- "pagePath": "/index/user",
- "iconPath": "../assets/images/user.png",
- "selectedIconPath": "../assets/images/user-a.png",
- "text": "我的"
- }
- ]
- },
- attached() {
- if (ifStoreApp == 1) {
- this.setData({
- list: [{
- "pagePath": "/index/index",
- "iconPath": "../assets/images/home.png",
- "selectedIconPath": "../assets/images/home-a.png",
- "text": "首页"
- },
- {
- "pagePath": "/index/user",
- "iconPath": "../assets/images/user.png",
- "selectedIconPath": "../assets/images/user-a.png",
- "text": "我的"
- }
- ]
- })
- } else if (ifStoreApp == 2) {
- this.setData({
- list: [{
- "pagePath": "/index/index",
- "iconPath": "../assets/images/home.png",
- "selectedIconPath": "../assets/images/home-a.png",
- "text": "首页"
- },
- {
- "pagePath": "/index/searchbar",
- "iconPath": "../assets/images/mendian.png",
- "selectedIconPath": "../assets/images/mendian-a.png",
- "text": "门店"
- },
- {
- "pagePath": "/index/user",
- "iconPath": "../assets/images/user.png",
- "selectedIconPath": "../assets/images/user-a.png",
- "text": "我的"
- }
- ]
- })
- }
- },
- methods: {
- switchTab(e) {
- const data = e.currentTarget.dataset;
- const url = data.path;
- if(data.index==0||data.index==3){
- this.getTemplateId()
- }
- wx.switchTab({url});
- this.setData({
- selected: data.index
- })
- },
- getTemplateId() {
- Http.get({
- url: config.api.templateId,
- data: {
- pageNum: 1,
- pageSize: 100
- }
- }).then(res => {
- const {
- code,
- data
- } = res
- if (code == 200) {
- this.setData({
- templateId: data.list
- })
- this.setWxMessage()
- } else {
- return
- }
- })
- },
- setWxMessage() {
- let tmplIds = []
- this.data.templateId.map(res => {
- tmplIds.push(res.templateId)
- })
- console.log(tmplIds[0], "?|?|?|", this.data.templateId)
- wx.requestSubscribeMessage({
- tmplIds: tmplIds,
- success(res) {
- let _statue = null
- tmplIds.map((item,index)=>{//判读用户是否点击了确定
- if(res[item]=="accept"){
- _statue = 'ok'
- }
- })
- if (_statue == 'ok') {
- Http.post({
- url: config.api.wxMsg
- }).then(res => {
- console.log(res)
- })
- return
- }
- // for (let i = 0; i < tmplIds.length;i++){
- // if (res.tmplIds[i] == 'accept'){
- // console.log("发送")
- // }
- // }
- }
- })
- },
-
- }
- })
|