Commit 1e82cab2 by 程默

api init

parent b969f804
const app = getApp()
console.log(app, 'apppppppppp')
Component({
data: {
selected: 0,
color: "#7A7E83",
selectedColor: "#3cc51f",
list: [{
pagePath: "/pages/home/main",
iconPath: "https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
selectedIconPath: "https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
text: "组件",
//--多主题
condition: "",
icon: "ant-daishouhuo",
iconType: 1, //0 iconfont 1 image
imgUrl: "https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
selectImgUrl: "https://cdn.mayi888.com/public/png/2d084453-2ca3-4d01-95f9-8bed8fc46dc6.png",
link: {
key: "1.1.1.7",
link: "/personalCenter/spokesmanCenter?distributionModel=1",
name: "分销商中心",
type: 1
},
show: true,
title: "分类页",
version: "1.0.0",
visible: 1
}, {
pagePath: "/pages/index/main",
iconPath: "/static/images/bofang.png",
selectedIconPath: "/static/images/bofang.png",
text: "接口",
//--多主题
condition: "",
icon: "ant-daishouhuo",
iconType: 0, //0 iconfont 1 image
imgUrl: "",
selectImgUrl: "",
link: {},
show: true,
title: "分类页",
version: "1.0.0",
visible: 1
}],
componentData:{}
},
attached() {
var appInstance = getApp()
let that=this
if (appInstance.globalData.footerVal) {
that.setData({
componentData:appInstance.globalData.footerVal.componentData,
list: appInstance.globalData.footerVal.componentData.list
})
}else{
appInstance.footerCallBack=function (params) {
that.setData({
componentData:params.componentData,
list: params.componentData.list
})
}
}
},
methods: {
init() {
},
switchTab(e) {
const data = e.currentTarget.dataset
const url = data.path
wx.switchTab({
url
})
this.setData({
selected: data.index
})
}
}
})
{
"component": true
}
\ No newline at end of file
<!--miniprogram/custom-tab-bar/index.wxml-->
<cover-view class="tab-bar">
<cover-view class="tab-bar-border"></cover-view>
<cover-view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}"
bindtap="switchTab">
<cover-view wx:if="{{item.iconType==0||!item.iconType}}">
<cover-view class="antt {{item.icon}}"></cover-view>
</cover-view>
<cover-view wx:elif="{{item.iconType==1}}"
class="img-view"
style="width:{{(index==selected?componentData.selectionIconSize*2:componentData.defaultIconSize*2)+'rpx'}};height:{{(index==selected?componentData.selectionIconSize*2:componentData.defaultIconSize*2)+'rpx'}}">
<cover-image src="{{selected === index ? item.selectImgUrl : item.imgUrl}}"></cover-image>
</cover-view>
<!-- 名称 -->
<cover-view
style="color: {{selected === index ? componentData.selectTextColor : componentData.defaultTextColor}};font-size:{{selected === index ? componentData.selectionTextNum*2 : componentData.defaultTextNum*2}}rpx">
{{item.title}}</cover-view>
</cover-view>
</cover-view>
\ No newline at end of file
<script>
import shop from "@/api/shop";
export default {
created() {
// NODE_ENV
let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
console.log(extConfig,'-----------extConfig')
if (process.env.NODE_ENV == "development" || JSON.stringify(extConfig) == "{}") {
console.log(extConfig, "-----------extConfig");
if (
process.env.NODE_ENV == "development" ||
JSON.stringify(extConfig) == "{}"
) {
extConfig = { mixid: "antgood" };
}
console.log("1444444444", extConfig.mixid);
this.$store.commit("setExtConfig", extConfig.mixid);
// 调用API从本地缓存中获取数据
/*
......@@ -23,24 +29,80 @@ export default {
logs.unshift(Date.now());
mpvue.setStorageSync({
key: "logs",
data: logs
data: logs,
});
} else {
logs = mpvue.getStorageSync("logs") || [];
logs.unshift(Date.now());
mpvue.setStorageSync("logs", logs);
}
// 初始
this.getShopInfo(extConfig);
// 页面配置信息
this.getThemePage();
},
methods: {
//商城配置
getShopInfo(extConfig) {
shop.getShopInfo({ shopMixId: "antgood" }).then((res) => {
if (res.data.code == 200) {
let mpApp = getApp();
// 商城基本数据
mpApp.shopCallBack && mpApp.shopCallBack(res.data.data);
let defaultComponentModel = res.data.data.shopThemeData;
this.mpApp.globalData.shopThemeData = res.data.data.shopThemeData;
// 获取底部栏数据
let val = JSON.parse(defaultComponentModel);
if (val && val.defaultComponentModel) {
// 底部导航数据赋值
let footerVal = val.defaultComponentModel.filter((item, index) => {
return item.componentName == "底部导航";
})[0];
this.mpApp.globalData.footerVal = footerVal;
// app中异步数据回调 底部栏数据
if (mpApp.footerCallBack) {
mpApp.footerCallBack(footerVal);
}
}
}
});
},
getThemePage() {
shop
.themePagesInfo({
shopid: 67,
shopMixId: "antgood",
})
.then((response) => {
if (response.data.code == 200) {
let data = response.data.data;
if (Array.isArray(data) && data.length > 0) {
console.log("90", data);
this.mpApp.globalData.pageList = data;
// app中异步数据回调 底部栏数据
if (this.mpApp.pageCallBack) {
this.mpApp.pageCallBack(data);
}
}
}
})
.catch((err) => {});
},
},
onError(data) {
console.log(data, "js异常捕获");
this.$mpAnalytics.recordError({
data,
keyword:data,
keyword: data,
extendsInfo: {
mixid: this.$store.state.mixid || null
}
mixid: this.$store.state.mixid || null,
},
});
}
},
};
</script>
......@@ -61,7 +123,7 @@ export default {
-webkit-transition: width 2s;
-o-transition: width 2s;
}
/* @import url("../static/nicon/iconfont.css"); */
@import url("../static/font/iconfont.css");
@import url("../static/css/common.scss");
</style>
import {requestPOST,requestGET} from "@/utils/request.js";
import { requestPOST, requestGET } from "@/utils/request.js";
export default {
getShopInfo() {
return requestPOST(`${process.env.OLSHOP_URL}/shop/get_shop_info`);
},
getWxMiniSubscribeMessageConfig() {
return requestPOST(
`${process.env.OLSHOP_URL}/shop/getWxMiniSubscribeMessageConfig`
);
}
};
\ No newline at end of file
export default {
getShopInfo() {
return requestPOST(`${process.env.OLSHOP_URL}/shop/get_shop_info`);
},
getWxMiniSubscribeMessageConfig() {
return requestPOST(
`${process.env.OLSHOP_URL}/shop/getWxMiniSubscribeMessageConfig`
);
},
// 页面数据
themePagesInfo(params) {
return requestPOST(`${process.env.OLSHOP_URL}/cms/get_shop_install_pages`, { params })
}
};
......@@ -9,6 +9,21 @@
"pages/contact/main",
"pages/officialAccount/main"
],
"tabBar": {
"custom": true,
"color": "#7A7E83",
"selectedColor": "#3cc51f",
"borderStyle": "black",
"backgroundColor": "#ffffff",
"list": [{
"pagePath": "pages/home/main",
"text": "组件"
}, {
"pagePath": "pages/index/main",
"text": "接口"
}]
},
"usingComponents": {},
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
......
import Vue from 'vue'
import App from './App'
import Store from './store/index'
import "../static/nicon/iconfont.css"
Vue.config.productionTip = false
App.mpType = 'app'
......@@ -18,3 +19,15 @@ Vue.prototype.$mpAnalytics = mpAnalytics;
const app = new Vue(App)
app.$mount()
// glob挂载到
let mpApp=getApp();
Vue.prototype.mpApp = mpApp
// 定义数据回调函数
// 商城
mpApp.shopCallBack=function() {}
// 多主题页面
mpApp.pageCallBack=function() {}
// 底部栏
mpApp.footerCallBack=function() {}
<template>
<div class="domain">abc
<div class="domain">
<p v-for="item in pageData" :key="item.id">
{{ item.componentCode }}
</p>
<image
src="http://cdn.mayi888.com/public/jpg/33ff0efc-96b5-4044-a65a-07799dfe98e1.jpg?x-oss-process=image/resize,limit_1,w_750"
></image>
<van-button type="primary">按钮</van-button>
<view class="ant-bofang">1</view>
</div>
</template>
<script>
export default {
}
data() {
return {
pageInfo: {},
pageData: {},
};
},
onLoad() {
if (this.mpApp.globalData.pageList) {
that.init(this.mpApp.globalData.pageList);
} else {
let that = this;
this.mpApp.pageCallBack = function (params) {
that.init(params);
};
}
},
methods: {
init(pageList) {
this.pageInfo = pageList.filter((item) => item.pageCode == 1)[0];
this.pageData = JSON.parse(this.pageInfo.pageData);
console.log('36',this.pageData)
},
},
};
</script>
<style>
.domain {
text-align: center;
padding-top: 50%;
/* padding-top: 50%; */
}
</style>
\ No newline at end of file
......@@ -2,6 +2,7 @@ import store from '../store/index'
console.log(store.state.mixid,'store.state')
let shopMixid = store.state.mixid;
// wx.getStore
export async function requestGET(url, options) {
......@@ -11,7 +12,7 @@ export async function requestGET(url, options) {
data: options,
method: "GET",
header: {
"Shop-Mixid": shopMixid,
"Shop-Mixid": store.state.mixid,
"Offline-Shop-Code": store.state.offlineShopCode,
"Authorization": wx.getStorageSync('sessionid') || "",
// "dubbo-tag": "ljx"
......@@ -33,7 +34,7 @@ export async function requestPOST(url, options) {
data: options,
method: "POST",
header: {
"Shop-Mixid": shopMixid,
"Shop-Mixid": store.state.mixid,
"Authorization": wx.getStorageSync('sessionid') || "",
"Offline-Shop-Code": store.state.offlineShopCode,
"openId": wx.getStorageSync("openid") || ''
......@@ -57,7 +58,7 @@ export function requestPOST1(url, options) {
method: "POST",
header: {
"Content-Type": "application/x-www-form-urlencoded",
"Shop-Mixid": shopMixid,
"Shop-Mixid": store.state.mixid,
Authorization: wx.getStorageSync('sessionid') || "",
"Offline-Shop-Code": store.state.offlineShopCode,
// "dubbo-tag": "ljx"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment