<template>
|
<view>
|
<view v-if="product">
|
<up-row justify="space-between">
|
<up-col span="12">
|
<up-image :show-loading="true" :src="product.image" mode="widthFix"/>
|
<up-text type="info" :text="`${product.name}`"
|
customStyle="margin-top: 2px;"/>
|
<up-text type="price" :text="`¥${product.sellprice}`"
|
customStyle="margin-top: 2px;color: #8B0000;"/>
|
</up-col>
|
</up-row>
|
<up-row justify="space-between">
|
<up-col span="12">
|
<view v-for="(attribute, i) in attributes">
|
<view>
|
<span> {{attribute.name}}</span>
|
</view>
|
<view v-for="(value, j) in attribute.values">
|
<view>
|
<span> {{value.value}}</span>
|
</view>
|
</view>
|
</view>
|
</up-col>
|
</up-row>
|
</view>
|
<view v-else>
|
<u-empty mode="car" icon="http://cdn.uviewui.com/uview/empty/car.png"/>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import {ref, reactive, toRefs, onMounted, getCurrentInstance} from "vue";
|
import {useBasicInfoStore} from "../../store/basicInfo"
|
import {GetProductDetailByMasterId} from '../../apis/api';
|
import {onLoad} from "@dcloudio/uni-app";
|
|
export default {
|
setup() {
|
const userStore = useBasicInfoStore()
|
const {proxy} = getCurrentInstance();
|
const state = reactive({
|
product: null,
|
attributes: [],
|
})
|
|
onLoad((options) => {
|
const dataStr = decodeURIComponent(options.data);
|
const params = JSON.parse(dataStr);
|
|
console.log(params); // { id: 1, name: 'Test' }
|
})
|
|
onMounted(() => {
|
Init();
|
loadData();
|
});
|
|
const Init = () => {
|
console.log(state.product);
|
}
|
|
const loadData = () => {
|
state.product = {};
|
state.attributes = [];
|
|
GetProductDetailByMasterId(userStore.product.id).then(resp => {
|
if (resp.data) {
|
state.product = resp.data;
|
|
if (state.product) {
|
state.attributes = state.product.keys;
|
}
|
}
|
}).catch(err => {
|
console.error(err);
|
});
|
}
|
|
return {...toRefs(state), userStore, loadData}
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
.swiper {
|
width: 100%;
|
overflow: auto;
|
}
|
</style>
|