|
@@ -43,7 +43,7 @@
|
|
<van-divider :style="{ border: '.5rem solid #ebedf0' }" />
|
|
<van-divider :style="{ border: '.5rem solid #ebedf0' }" />
|
|
|
|
|
|
<!-- 类别 -->
|
|
<!-- 类别 -->
|
|
- <div class="prod-categray" v-if="skuList.length > 0" @click="skuSelect">
|
|
|
|
|
|
+ <div class="prod-categray" v-if="skuList.length > 0" @click="openSkuPlan">
|
|
<span class="left">已选 </span> {{ skuList[0].skuName }} <span class="right">...</span>
|
|
<span class="left">已选 </span> {{ skuList[0].skuName }} <span class="right">...</span>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@@ -82,7 +82,7 @@
|
|
<div style="text-align: left;">
|
|
<div style="text-align: left;">
|
|
{{ idx }}
|
|
{{ idx }}
|
|
</div>
|
|
</div>
|
|
- <van-tag @click="selectTag(t, idx)" :plain="selectedTag[t] ? false : true" v-for="(t, index) in tag"
|
|
|
|
|
|
+ <van-tag @click="selectTag(idx, t)" :class="{ 'prop-selected' : selectedTag[idx] === t ? true : false }" plain v-for="(t, index) in tag"
|
|
:key="index" type="danger">{{ t }}</van-tag>
|
|
:key="index" type="danger">{{ t }}</van-tag>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@@ -145,6 +145,9 @@ export default {
|
|
distributionCardNo: ""
|
|
distributionCardNo: ""
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+
|
|
},
|
|
},
|
|
async created() {
|
|
async created() {
|
|
this.prodId = this.$route.query.prodId
|
|
this.prodId = this.$route.query.prodId
|
|
@@ -155,8 +158,38 @@ export default {
|
|
this.prodData = prod
|
|
this.prodData = prod
|
|
this.commData = await prodCommData({ prodId: this.prodId })
|
|
this.commData = await prodCommData({ prodId: this.prodId })
|
|
this.isCollection = await isCollection({ prodId: this.prodId })
|
|
this.isCollection = await isCollection({ prodId: this.prodId })
|
|
|
|
+ this.init(this.skuList)
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ init(sku){
|
|
|
|
+ const properties = []
|
|
|
|
+ const propObject = {}
|
|
|
|
+ let defaultArr = []
|
|
|
|
+ for ( let i = 0; i < sku.length; i++ ) {
|
|
|
|
+ properties.push( sku[i].properties )
|
|
|
|
+ }
|
|
|
|
+ for (let i = 0; i < properties.length; i++) {
|
|
|
|
+ const propStr = properties[i]
|
|
|
|
+ const propArr = propStr.split(";")
|
|
|
|
+ if ( defaultArr.length === 0 ) {
|
|
|
|
+ defaultArr = propArr
|
|
|
|
+ }
|
|
|
|
+ for (let n = 0; n < propArr.length; n++) {
|
|
|
|
+ const valueStr = propArr[n];
|
|
|
|
+ const valueArr = valueStr.split(":")
|
|
|
|
+ if ( !propObject[valueArr[0]] ) {
|
|
|
|
+ propObject[valueArr[0]] = new Set()
|
|
|
|
+ }
|
|
|
|
+ propObject[valueArr[0]].add(valueArr[1])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.tags = propObject
|
|
|
|
+ for ( let i = defaultArr.length - 1; i >= 0; i-- ) {
|
|
|
|
+ const valueStr = defaultArr[i];
|
|
|
|
+ const valueArr = valueStr.split(":")
|
|
|
|
+ this.$set(this.selectedTag, valueArr[0], valueArr[1])
|
|
|
|
+ }
|
|
|
|
+ },
|
|
onClickButton() {
|
|
onClickButton() {
|
|
// this.confirm.orderItem.prodId = this.prodData.prodId
|
|
// this.confirm.orderItem.prodId = this.prodData.prodId
|
|
// this.confirm.orderItem.prodCount = 1
|
|
// this.confirm.orderItem.prodCount = 1
|
|
@@ -178,49 +211,23 @@ export default {
|
|
handclick() {
|
|
handclick() {
|
|
this.show = !this.show
|
|
this.show = !this.show
|
|
},
|
|
},
|
|
- selectTag(value, tagname) {
|
|
|
|
- for (const key in this.selectedTag) {
|
|
|
|
- if (this.selectedTag[key] === tagname) {
|
|
|
|
- delete this.selectedTag[key]
|
|
|
|
- }
|
|
|
|
|
|
+ selectTag(propTitle, Propvalue) {
|
|
|
|
+ //当用户选择一个属性的时候, 我们存储他的选择
|
|
|
|
+ this.$set( this.selectedTag, propTitle, Propvalue )
|
|
|
|
+ //然后我们判断 用户选择的属性时候能找到对应的prop
|
|
|
|
+ let str = ""
|
|
|
|
+ for ( let item in this.selectedTag ) {
|
|
|
|
+ str = item + ":" + this.selectedTag[item] + ";" + str
|
|
}
|
|
}
|
|
- this.$set(this.selectedTag, value, tagname)
|
|
|
|
-
|
|
|
|
- //new RegExp("41(.*?)浅灰").
|
|
|
|
- let skuId = 0
|
|
|
|
- for (const items in this.skuList) {
|
|
|
|
- skuId = 0
|
|
|
|
- for (const key in this.selectedTag) {
|
|
|
|
- if (new RegExp(key).test(this.skuList[items].skuName)) {
|
|
|
|
- skuId = this.skuList[items].skuId
|
|
|
|
- } else {
|
|
|
|
- skuId = 0
|
|
|
|
- }
|
|
|
|
|
|
+ str = str.substring(0, str.length -1 )
|
|
|
|
+ for ( let i = 0; i < this.skuList.length; i++ ) {
|
|
|
|
+ if (this.skuList[i].properties === str) {
|
|
|
|
+ console.log(this.skuList[i].skuId )
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- this.confirm.orderItem.skuId = skuId
|
|
|
|
},
|
|
},
|
|
- skuSelect() {
|
|
|
|
- if (this.skuSelected === null) {
|
|
|
|
- this.skuSelected = this.skuList[0]
|
|
|
|
- const skuList = this.skuList
|
|
|
|
- const tags = {}
|
|
|
|
- for (const items in skuList) {
|
|
|
|
- if (Object.hasOwnProperty.call(skuList, items)) {
|
|
|
|
- const element = skuList[items].properties.split(";")
|
|
|
|
- for (let i = 0; i < element.length; i++) {
|
|
|
|
- const temp = element[i].split(":")
|
|
|
|
- if (/\//.test(temp[1])) {
|
|
|
|
- tags[temp[0]] = temp[1].split("/")
|
|
|
|
- } else {
|
|
|
|
- if (!tags[temp[0]]) { tags[temp[0]] = [] }
|
|
|
|
- tags[temp[0]].push(temp[1])
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- this.tags = tags
|
|
|
|
- }
|
|
|
|
|
|
+ openSkuPlan() {
|
|
this.show = !this.show
|
|
this.show = !this.show
|
|
},
|
|
},
|
|
formatHtml(t) {
|
|
formatHtml(t) {
|
|
@@ -230,6 +237,12 @@ export default {
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
<style scoped lang="less">
|
|
<style scoped lang="less">
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+.prop-selected {
|
|
|
|
+ color: #FFF !important;
|
|
|
|
+ background-color: red !important;
|
|
|
|
+}
|
|
.prod-info /deep/ .van-tag {
|
|
.prod-info /deep/ .van-tag {
|
|
color: #ee0a24;
|
|
color: #ee0a24;
|
|
margin-left: 1rem;
|
|
margin-left: 1rem;
|