diy
parent
a367337853
commit
abab4c1e35
9
App.vue
9
App.vue
|
|
@ -182,8 +182,13 @@
|
|||
// 商品数据缓存key
|
||||
cache_goods_data_key: 'cache_goods_data_key',
|
||||
|
||||
// 页面设计数据缓存key
|
||||
cache_design_data_key: 'cache_design_data_key',
|
||||
// 页面设计页面数据缓存key
|
||||
cache_design_page_data_key: 'cache_design_page_data_key',
|
||||
|
||||
// diy模块数据缓存key
|
||||
cache_diy_data_key: 'cache_diy_data_key',
|
||||
// diy页面数据缓存key
|
||||
cache_diy_page_data_key: 'cache_diy_page_data_key',
|
||||
|
||||
// 默认用户头像
|
||||
default_user_head_src: '/static/images/common/user.png',
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@
|
|||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
propHomeId: {
|
||||
propDataId: {
|
||||
type: [String, Number],
|
||||
default: '',
|
||||
},
|
||||
|
|
@ -155,7 +155,6 @@
|
|||
// 选项卡数据
|
||||
tabs_data: {},
|
||||
diy_data: [],
|
||||
tabs_home_id: this.propHomeId,
|
||||
// 商品列表
|
||||
goods_list: [],
|
||||
goods_total: 0,
|
||||
|
|
@ -173,6 +172,8 @@
|
|||
// 判断数据是否在加载中
|
||||
data_is_loading: 0,
|
||||
key: '',
|
||||
// 缓存key
|
||||
cache_key: app.globalData.data.cache_diy_data_key
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
|
@ -186,7 +187,6 @@
|
|||
methods: {
|
||||
init() {
|
||||
// tabs选项卡数据过滤
|
||||
// const filter_tabs_list = this.value.tabs_data || [];
|
||||
this.setData({
|
||||
key: get_math(),
|
||||
header_data: this.value.header,
|
||||
|
|
@ -194,7 +194,7 @@
|
|||
diy_data: this.value.diy_data,
|
||||
tabs_data: this.value.tabs_data,
|
||||
});
|
||||
uni.setStorageSync('diy-data-' + this.propId, this.value.diy_data);
|
||||
uni.setStorageSync(this.cache_key + this.propDataId, this.value.diy_data);
|
||||
},
|
||||
footer_height_computer(number) {
|
||||
this.padding_footer_computer = number * 2;
|
||||
|
|
@ -210,7 +210,7 @@
|
|||
id: tabs_id,
|
||||
};
|
||||
if (tabs_id) {
|
||||
new_data = uni.getStorageSync('diy-data-' + tabs_id) || [];
|
||||
new_data = uni.getStorageSync(this.cache_key + tabs_id) || [];
|
||||
if (new_data.length > 0) {
|
||||
// 先使用缓存数据展示
|
||||
this.setData({
|
||||
|
|
@ -231,7 +231,7 @@
|
|||
const data = res.data.data.data;
|
||||
if (res.data.code == 0) {
|
||||
new_data = data?.config.diy_data || [];
|
||||
uni.setStorageSync('diy-data-' + tabs_id, new_data);
|
||||
uni.setStorageSync(this.cache_key + tabs_id, new_data);
|
||||
this.setData({
|
||||
diy_data: new_data,
|
||||
});
|
||||
|
|
@ -248,7 +248,7 @@
|
|||
this.get_goods_list(1);
|
||||
}
|
||||
} else {
|
||||
new_data = uni.getStorageSync('diy-data-' + this.tabs_home_id) || [];
|
||||
new_data = uni.getStorageSync(this.cache_key + this.propDataId) || [];
|
||||
// 先使用缓存数据展示
|
||||
this.setData({
|
||||
diy_data: new_data,
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@
|
|||
// 获取数据
|
||||
get_data(params = {}) {
|
||||
// 还没有数据则读取缓存
|
||||
var cache_key = app.globalData.data.cache_design_data_key;
|
||||
var cache_key = app.globalData.data.cache_design_page_data_key+(this.params.id || 0);
|
||||
if (this.load_status == 0) {
|
||||
// 本地缓存数据
|
||||
var upd_data = uni.getStorageSync(cache_key) || null;
|
||||
|
|
@ -159,7 +159,6 @@
|
|||
load_status: 1,
|
||||
data_list_loding_msg: this.$t('common.internet_error_tips')
|
||||
});
|
||||
app.globalData.showToast(this.$t('common.internet_error_tips'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,150 @@
|
|||
<template>
|
||||
<view>
|
||||
<!-- <componentDiy :value="diy_data"></componentDiy> -->
|
||||
<view :class="theme_view">
|
||||
<view v-if="(data || null) != null">
|
||||
<!-- diy模块 -->
|
||||
<componentDiy :value="data.config" :propDataId="data.id"></componentDiy>
|
||||
|
||||
<!-- 结尾 -->
|
||||
<component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
|
||||
</view>
|
||||
<view v-else>
|
||||
<component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const app = getApp();
|
||||
import componentDiy from '@/components/diy/diy';
|
||||
// import initData from './init_data';
|
||||
import componentNoData from "@/components/no-data/no-data";
|
||||
import componentBottomLine from "@/components/bottom-line/bottom-line";
|
||||
export default {
|
||||
components: {
|
||||
componentDiy,
|
||||
componentNoData,
|
||||
componentBottomLine
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// diy_data: initData,
|
||||
theme_view: app.globalData.get_theme_value_view(),
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 1,
|
||||
data_list_loding_msg: '',
|
||||
load_status: 0,
|
||||
params: null,
|
||||
data: null,
|
||||
// 自定义分享信息
|
||||
share_info: {}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
// console.log(initData);
|
||||
|
||||
onLoad(params) {
|
||||
// 调用公共事件方法
|
||||
app.globalData.page_event_onload_handle(params);
|
||||
|
||||
// 设置参数
|
||||
this.setData({
|
||||
params: params
|
||||
});
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 调用公共事件方法
|
||||
app.globalData.page_event_onshow_handle();
|
||||
|
||||
// 加载数据
|
||||
this.get_data();
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.get_data();
|
||||
},
|
||||
|
||||
methods: {
|
||||
// 获取数据
|
||||
get_data(params = {}) {
|
||||
// 还没有数据则读取缓存
|
||||
var cache_key = app.globalData.data.cache_diy_page_data_key+(this.params.id || 0);
|
||||
if (this.load_status == 0) {
|
||||
// 本地缓存数据
|
||||
var upd_data = uni.getStorageSync(cache_key) || null;
|
||||
if (upd_data != null) {
|
||||
// 先使用缓存数据展示
|
||||
this.setData(upd_data);
|
||||
|
||||
// 已有本地缓存则直接取远程有效数据(默认首次取的是远程缓存数据)
|
||||
params['is_cache'] = 0;
|
||||
}
|
||||
}
|
||||
uni.request({
|
||||
url: app.globalData.get_request_url("index", "diy"),
|
||||
method: 'POST',
|
||||
data: {...this.params, ...params},
|
||||
dataType: 'json',
|
||||
success: res => {
|
||||
uni.stopPullDownRefresh();
|
||||
if (res.data.code == 0) {
|
||||
var upd_data = {
|
||||
data: res.data.data.data || null,
|
||||
data_list_loding_msg: '',
|
||||
data_list_loding_status: 0,
|
||||
data_bottom_line_status: true
|
||||
};
|
||||
this.setData(upd_data);
|
||||
|
||||
// 存储缓存
|
||||
uni.setStorageSync(cache_key, upd_data);
|
||||
|
||||
// 是否需要重新加载数据
|
||||
if (parseInt(data.is_result_data_cache || 0) == 1) {
|
||||
this.get_data({ is_cache: 0 });
|
||||
}
|
||||
|
||||
if ((this.data || null) != null) {
|
||||
// 基础自定义分享
|
||||
this.setData({
|
||||
share_info: {
|
||||
title: this.data.name,
|
||||
desc: this.data.describe,
|
||||
path: '/pages/diy/diy',
|
||||
query: 'id='+this.data.id,
|
||||
img: this.data.logo
|
||||
}
|
||||
});
|
||||
|
||||
// 标题名称
|
||||
uni.setNavigationBarTitle({
|
||||
title: this.data.name
|
||||
});
|
||||
}
|
||||
|
||||
// 分享菜单处理
|
||||
app.globalData.page_share_handle(this.share_info);
|
||||
} else {
|
||||
this.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
data_list_loding_msg: res.data.msg
|
||||
});
|
||||
}
|
||||
|
||||
// 非首次状态
|
||||
this.setData({
|
||||
load_status: 1
|
||||
});
|
||||
},
|
||||
fail: () => {
|
||||
uni.stopPullDownRefresh();
|
||||
this.setData({
|
||||
data_bottom_line_status: false,
|
||||
data_list_loding_status: 2,
|
||||
load_status: 1,
|
||||
data_list_loding_msg: this.$t('common.internet_error_tips')
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
<style></style>
|
||||
Loading…
Reference in New Issue