master
gongfuxiang 2024-09-25 10:58:02 +08:00
parent a367337853
commit abab4c1e35
4 changed files with 149 additions and 21 deletions

View File

@ -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',
// diykey
cache_diy_data_key: 'cache_diy_data_key',
// diykey
cache_diy_page_data_key: 'cache_diy_page_data_key',
//
default_user_head_src: '/static/images/common/user.png',

View File

@ -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,

View File

@ -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'));
}
});
}

View File

@ -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>