|
@@ -123,130 +123,138 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
|
|
|
-//例如:import 《组件名称》 from '《组件路径》';
|
|
|
-import Paging from "@/components/pagination";
|
|
|
+// 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
|
|
|
+// 例如:import 《组件名称》 from '《组件路径》';
|
|
|
+import Paging from '@/components/pagination'
|
|
|
export default {
|
|
|
- name: "collection-type",
|
|
|
- //import引入的组件需要注入到对象中才能使用
|
|
|
+ name: 'collection-type',
|
|
|
+ // import引入的组件需要注入到对象中才能使用
|
|
|
components: {
|
|
|
- Paging,
|
|
|
+ Paging
|
|
|
},
|
|
|
- data() {
|
|
|
- //这里存放数据
|
|
|
+ data () {
|
|
|
+ // 这里存放数据
|
|
|
return {
|
|
|
- collectionType: "boutique",
|
|
|
+ collectionType: 'boutique',
|
|
|
dataList: [],
|
|
|
paging: {
|
|
|
pageSize: 12,
|
|
|
pageNum: 1,
|
|
|
total: 0,
|
|
|
showSize: 12,
|
|
|
- current: 1,
|
|
|
+ current: 1
|
|
|
},
|
|
|
params: {
|
|
|
pageNum: 1,
|
|
|
pageSize: 12,
|
|
|
- type: "",
|
|
|
- goodsAgeId: "",
|
|
|
- goodsTypeId: "",
|
|
|
- searchKey:""
|
|
|
+ type: '',
|
|
|
+ goodsAgeId: '',
|
|
|
+ goodsTypeId: '',
|
|
|
+ searchKey: ''
|
|
|
},
|
|
|
typeChange: {
|
|
|
- boutique: "img",
|
|
|
- threeDimensional: "model",
|
|
|
+ boutique: 'img',
|
|
|
+ threeDimensional: 'model'
|
|
|
},
|
|
|
- getGoodAgeList:[],
|
|
|
- getGoodTypeList:[]
|
|
|
- };
|
|
|
+ getGoodAgeList: [],
|
|
|
+ getGoodTypeList: []
|
|
|
+ }
|
|
|
},
|
|
|
- //监听属性 类似于data概念
|
|
|
+ // 监听属性 类似于data概念
|
|
|
computed: {},
|
|
|
- //监控data中的数据变化
|
|
|
+ // 监控data中的数据变化
|
|
|
watch: {
|
|
|
paging: {
|
|
|
deep: true,
|
|
|
- handler: function () {},
|
|
|
- },
|
|
|
+ handler: function () {}
|
|
|
+ }
|
|
|
},
|
|
|
- //方法集合
|
|
|
+ // 方法集合
|
|
|
methods: {
|
|
|
- async getList(reload=false) {
|
|
|
- if(reload){
|
|
|
- this.dataList = [];
|
|
|
- this.params.pageNum = 1;
|
|
|
+ async getList (reload = false) {
|
|
|
+ if (reload) {
|
|
|
+ this.dataList = []
|
|
|
+ this.params.pageNum = 1
|
|
|
}
|
|
|
let result = await this.$http({
|
|
|
- method: "post",
|
|
|
- url: "/api/web/goods/list",
|
|
|
- data: this.params,
|
|
|
- });
|
|
|
- this.dataList = result.data.list;
|
|
|
- this.paging.total = result.data.total;
|
|
|
+ method: 'post',
|
|
|
+ url: '/api/web/goods/list',
|
|
|
+ data: this.params
|
|
|
+ })
|
|
|
+ this.dataList = result.data.list
|
|
|
+ this.paging.total = result.data.total
|
|
|
},
|
|
|
- switchType(type) {
|
|
|
- this.collectionType = type;
|
|
|
- this.params["type"] = this.typeChange[this.collectionType];
|
|
|
- this.params["pageNum"] = 1;
|
|
|
- this.paging.current = 1;
|
|
|
- this.getList();
|
|
|
+ switchType (type) {
|
|
|
+ this.collectionType = type
|
|
|
+ this.params['type'] = this.typeChange[this.collectionType]
|
|
|
+ this.params['pageNum'] = 1
|
|
|
+ this.paging.current = 1
|
|
|
+ this.getList()
|
|
|
},
|
|
|
- back() {
|
|
|
- this.$router.push({ path: "/collection" });
|
|
|
+ back () {
|
|
|
+ this.$router.push({ path: '/collection' })
|
|
|
},
|
|
|
- pageChange(val) {
|
|
|
- console.log(val);
|
|
|
- this.paging.current = val;
|
|
|
- this.params.pageNum = val;
|
|
|
- this.getList();
|
|
|
+ pageChange (val) {
|
|
|
+ console.log(val)
|
|
|
+ this.paging.current = val
|
|
|
+ this.params.pageNum = val
|
|
|
+ this.getList()
|
|
|
},
|
|
|
- toDetail(item) {
|
|
|
+ toDetail (item) {
|
|
|
+ let classify, myage
|
|
|
+ this.getGoodAgeList.forEach(v => {
|
|
|
+ if (v.id === item.goodsAgeId) myage = v.name
|
|
|
+ })
|
|
|
+ this.getGoodTypeList.forEach(v => {
|
|
|
+ if (v.id === item.goodsTypeId) classify = v.name
|
|
|
+ })
|
|
|
+
|
|
|
this.$router.push({
|
|
|
- path: "/collection-detail",
|
|
|
- query: { ...item, navType: this.collectionType },
|
|
|
- });
|
|
|
+ path: '/collection-detail',
|
|
|
+ query: { ...item, navType: this.collectionType, classify, myage }
|
|
|
+ })
|
|
|
},
|
|
|
- search() {
|
|
|
- console.log(this.params);
|
|
|
- this.getList(true);
|
|
|
+ search () {
|
|
|
+ console.log(this.params)
|
|
|
+ this.getList(true)
|
|
|
},
|
|
|
- async getGoodAge(){
|
|
|
+ async getGoodAge () {
|
|
|
let result = await this.$http({
|
|
|
- method: "get",
|
|
|
- url: "/api/web/goods/age/list",
|
|
|
- data: this.params,
|
|
|
- });
|
|
|
+ method: 'get',
|
|
|
+ url: '/api/web/goods/age/list',
|
|
|
+ data: this.params
|
|
|
+ })
|
|
|
this.getGoodAgeList = result && result['code'] === 0 && result['data']
|
|
|
- console.log('this.getGoodAgeList',this.getGoodAgeList)
|
|
|
+ console.log('this.getGoodAgeList', this.getGoodAgeList)
|
|
|
},
|
|
|
- async getGoodType(){
|
|
|
+ async getGoodType () {
|
|
|
let result = await this.$http({
|
|
|
- method: "get",
|
|
|
- url: "/api/web/goods/type/list",
|
|
|
- data: this.params,
|
|
|
- });
|
|
|
+ method: 'get',
|
|
|
+ url: '/api/web/goods/type/list',
|
|
|
+ data: this.params
|
|
|
+ })
|
|
|
this.getGoodTypeList = result && result['code'] === 0 && result['data']
|
|
|
}
|
|
|
},
|
|
|
- //生命周期 - 创建完成(可以访问当前this实例)
|
|
|
- created() {
|
|
|
+ // 生命周期 - 创建完成(可以访问当前this实例)
|
|
|
+ created () {
|
|
|
this.collectionType =
|
|
|
- (this.$route.query && this.$route.query["type"]) || "boutique";
|
|
|
- this.params["type"] = this.typeChange[this.collectionType];
|
|
|
- this.getList();
|
|
|
+ (this.$route.query && this.$route.query['type']) || 'boutique'
|
|
|
+ this.params['type'] = this.typeChange[this.collectionType]
|
|
|
+ this.getList()
|
|
|
this.getGoodAge()
|
|
|
this.getGoodType()
|
|
|
},
|
|
|
- //生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
- mounted() {},
|
|
|
- beforeCreate() {}, //生命周期 - 创建之前
|
|
|
- beforeMount() {}, //生命周期 - 挂载之前
|
|
|
- beforeUpdate() {}, //生命周期 - 更新之前
|
|
|
- updated() {}, //生命周期 - 更新之后
|
|
|
- beforeDestroy() {}, //生命周期 - 销毁之前
|
|
|
- destroyed() {}, //生命周期 - 销毁完成
|
|
|
- activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
|
|
|
-};
|
|
|
+ // 生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
+ mounted () {},
|
|
|
+ beforeCreate () {}, // 生命周期 - 创建之前
|
|
|
+ beforeMount () {}, // 生命周期 - 挂载之前
|
|
|
+ beforeUpdate () {}, // 生命周期 - 更新之前
|
|
|
+ updated () {}, // 生命周期 - 更新之后
|
|
|
+ beforeDestroy () {}, // 生命周期 - 销毁之前
|
|
|
+ destroyed () {}, // 生命周期 - 销毁完成
|
|
|
+ activated () {} // 如果页面有keep-alive缓存功能,这个函数会触发
|
|
|
+}
|
|
|
</script>
|
|
|
<style lang='less' scoped>
|
|
|
.bg {
|