|
|
@@ -6,8 +6,9 @@
|
|
|
<label class="mobile-cart-check" :class="{'active': item.$active}">
|
|
|
<input type="checkbox" @change="setActive('store', storeIndex)">
|
|
|
</label>
|
|
|
- <span class="store-tag inline-block">{{baseUtils.storeTypeFilter(item.storeType)}}</span>
|
|
|
+ <span class="store-tag inline-block">{{item.storeType | storeTypeFilter}}</span>
|
|
|
<p class="store-name inline-block text-ellipse">{{item.storeName}}</p>
|
|
|
+ <a class="link" @click="linkSaler(item)"><i class="iconfont icon-kefu1"></i>联系卖家</a>
|
|
|
</div>
|
|
|
<ul class="goods-list">
|
|
|
<li class="goods-item" v-for="(goods, goodsIndex) in item.goods">
|
|
|
@@ -28,7 +29,7 @@
|
|
|
<span class="inline-block" @click="setGoods('add', goods)">+</span>
|
|
|
</div>
|
|
|
<div class="price-line">
|
|
|
- <span>{{goods.currencyName === 'RMB' ? '¥' : '$'}}</span>{{goods.goods.currentPrice}}
|
|
|
+ <span>{{goods.currencyName | currencyFilter}}</span>{{goods.goods.currentPrice}}
|
|
|
</div>
|
|
|
</div>
|
|
|
</li>
|
|
|
@@ -42,16 +43,20 @@
|
|
|
</label>
|
|
|
<div class="fr">
|
|
|
<i class="fare">不含运费</i>
|
|
|
- <span class="title">合计:</span><span class="price"><span>¥</span>{{allPrice}}</span>
|
|
|
+ <span class="title">合计:</span><span class="price"><span v-show="allCount > 0">{{allCurrency | currencyFilter}}</span>{{allPrice}}</span>
|
|
|
<button class="buy-btn" @click="submit">结算({{allCount}})</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
|
|
|
<pull-up :fixId="'mobileFixContent'" :searchMore="fetching" :allPage="allPage" :page="page" @pullUpAction="onPullUpAction"></pull-up>
|
|
|
+ <link-user :infoObj="currentStoreInfo"
|
|
|
+ :showLink="showLink"
|
|
|
+ @closeAction="showLink = false"></link-user>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
import {RemindBox, PullUp} from '~components/mobile/common'
|
|
|
+ import {LinkUser} from '~components/mobile/base'
|
|
|
export default {
|
|
|
layout: 'mobile',
|
|
|
middleware: 'authenticated',
|
|
|
@@ -62,12 +67,16 @@
|
|
|
timeoutCount: '',
|
|
|
isAllChecked: false,
|
|
|
page: 1,
|
|
|
- count: 10
|
|
|
+ count: 10,
|
|
|
+ allCurrency: 'RMB', // 选定币别
|
|
|
+ currentStoreInfo: {},
|
|
|
+ showLink: false
|
|
|
}
|
|
|
},
|
|
|
components: {
|
|
|
RemindBox,
|
|
|
- PullUp
|
|
|
+ PullUp,
|
|
|
+ LinkUser
|
|
|
},
|
|
|
fetch ({ store }) {
|
|
|
return Promise.all([
|
|
|
@@ -78,6 +87,7 @@
|
|
|
'$store.state.userCenter.list.cart.data': {
|
|
|
handler: function (val) {
|
|
|
let tmpVal = this.baseUtils.deepCopy(val)
|
|
|
+// this.cartList = []
|
|
|
tmpVal.content.forEach(item => {
|
|
|
let current = this.cartList.find(objItem => {
|
|
|
return objItem.storeUuid === item.storeUuid
|
|
|
@@ -106,6 +116,7 @@
|
|
|
storeName: item.storeName,
|
|
|
storeType: item.storeType,
|
|
|
storeUuid: item.storeUuid,
|
|
|
+ enterprise: item.storeEnterprise.enterpriseInfo,
|
|
|
goods: [item],
|
|
|
$active: false
|
|
|
})
|
|
|
@@ -113,6 +124,7 @@
|
|
|
current.goods.push(item)
|
|
|
}
|
|
|
})
|
|
|
+ this.checkAll()
|
|
|
},
|
|
|
immediate: true
|
|
|
}
|
|
|
@@ -127,6 +139,7 @@
|
|
|
allPage () {
|
|
|
return this.cartData.totalPages
|
|
|
},
|
|
|
+ // 已选goods
|
|
|
allActiveObj () {
|
|
|
let arr = []
|
|
|
this.cartList.forEach(item => {
|
|
|
@@ -138,6 +151,7 @@
|
|
|
})
|
|
|
return arr
|
|
|
},
|
|
|
+ // 统计价格
|
|
|
allPrice () {
|
|
|
let price = 0
|
|
|
this.allActiveObj.forEach(item => {
|
|
|
@@ -145,6 +159,7 @@
|
|
|
})
|
|
|
return price
|
|
|
},
|
|
|
+ // 统计数量
|
|
|
allCount () {
|
|
|
return this.allActiveObj.length
|
|
|
}
|
|
|
@@ -154,19 +169,36 @@
|
|
|
this.remindText = str
|
|
|
this.timeoutCount++
|
|
|
},
|
|
|
- setActive: function (type, storeIndex, goodsIndex) {
|
|
|
+ checkCurrency: function (currency, callback) {
|
|
|
+ if (currency === this.allCurrency) {
|
|
|
+ callback.call()
|
|
|
+ } else {
|
|
|
+ this.setRemindText('所选产品币别与已选产品不是同一币别')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setActive (type, storeIndex, goodsIndex, goodsCheckFlag) {
|
|
|
if (type === 'store') {
|
|
|
- this.cartList[storeIndex].goods.forEach(item => {
|
|
|
- item.$active = !this.cartList[storeIndex].$active
|
|
|
- })
|
|
|
- this.cartList[storeIndex].$active = !this.cartList[storeIndex].$active
|
|
|
+ let storeActive = this.cartList[storeIndex].$active
|
|
|
+ for (let i = 0; i < this.cartList[storeIndex].goods.length; i++) {
|
|
|
+ this.setActive('goods', storeIndex, i, !storeActive)
|
|
|
+ }
|
|
|
+// this.cartList[storeIndex].goods.forEach(item => {
|
|
|
+// this.checkCurrency(item.goods.currencyName, () => {
|
|
|
+// item.$active = !this.cartList[storeIndex].$active
|
|
|
+// })
|
|
|
+// })
|
|
|
this.checkAll()
|
|
|
} else if (type === 'goods') {
|
|
|
- this.cartList[storeIndex].goods[goodsIndex].$active = !this.cartList[storeIndex].goods[goodsIndex].$active
|
|
|
- this.cartList[storeIndex].$active = !this.cartList[storeIndex].goods.find(item => {
|
|
|
- return !item.$active
|
|
|
+ if (!this.allActiveObj[0]) {
|
|
|
+ this.allCurrency = this.cartList[storeIndex].goods[goodsIndex].currencyName
|
|
|
+ }
|
|
|
+ this.checkCurrency(this.cartList[storeIndex].goods[goodsIndex].currencyName, () => {
|
|
|
+ this.cartList[storeIndex].goods[goodsIndex].$active = typeof goodsCheckFlag === 'undefined' ? !this.cartList[storeIndex].goods[goodsIndex].$active : goodsCheckFlag
|
|
|
+// this.cartList[storeIndex].$active = !this.cartList[storeIndex].goods.find(item => {
|
|
|
+// return !item.$active
|
|
|
+// })
|
|
|
+ this.checkAll()
|
|
|
})
|
|
|
- this.checkAll()
|
|
|
} else if (type === 'all') {
|
|
|
let activeFlag = true
|
|
|
this.cartList.forEach(item => {
|
|
|
@@ -180,18 +212,21 @@
|
|
|
this.cartList[i].$active = activeFlag
|
|
|
this.setActive('store', i)
|
|
|
}
|
|
|
- this.isAllChecked = !activeFlag
|
|
|
+ this.checkAll()
|
|
|
}
|
|
|
},
|
|
|
// 总勾选校验
|
|
|
checkAll: function () {
|
|
|
let activeFlag = true
|
|
|
this.cartList.forEach(item => {
|
|
|
+ let itemActive = true
|
|
|
item.goods.forEach(goodsItem => {
|
|
|
if (!goodsItem.$active) {
|
|
|
activeFlag = false
|
|
|
+ itemActive = false
|
|
|
}
|
|
|
})
|
|
|
+ item.$active = itemActive
|
|
|
})
|
|
|
this.isAllChecked = activeFlag
|
|
|
},
|
|
|
@@ -285,8 +320,8 @@
|
|
|
}
|
|
|
},
|
|
|
onPullUpAction: function () {
|
|
|
-// this.page++
|
|
|
-// this.reloadList()
|
|
|
+ this.page++
|
|
|
+ this.reloadList()
|
|
|
},
|
|
|
reloadList: function () {
|
|
|
this.$store.dispatch('userCenter/loadCartList', {page: this.page, count: this.count})
|
|
|
@@ -296,6 +331,43 @@
|
|
|
this.setRemindText('请勾选要生成订单的批次')
|
|
|
return
|
|
|
}
|
|
|
+ let arrOD = []
|
|
|
+ this.allActiveObj.forEach(item => {
|
|
|
+ arrOD.push({
|
|
|
+ batchCode: item.goods.batchCode,
|
|
|
+ minPackQty: item.goods.minPackQty,
|
|
|
+ number: item.goods.purchaseNumber,
|
|
|
+ storeid: item.storeUuid
|
|
|
+ })
|
|
|
+ })
|
|
|
+ console.log(arrOD)
|
|
|
+ this.$http.post('/trade/order/saveByGroup', {
|
|
|
+ arrOD: arrOD,
|
|
|
+ currency: this.allCurrency
|
|
|
+ }).then(res => {
|
|
|
+ console.log(res.data)
|
|
|
+ if (res.data.code === 1) {
|
|
|
+ if (res.data.message) {
|
|
|
+ this.setRemindText(res.data.message)
|
|
|
+ }
|
|
|
+ this.$router.push(`/mobile/center/user/pay/${this.baseUtils.enidfilter(res.data.data.orderid)}`)
|
|
|
+ } else if (res.data.code === 7) {
|
|
|
+ this.setRemindText('选中的购物车信息已经失效,将为您刷新界面之后重新操作')
|
|
|
+ setTimeout(() => {
|
|
|
+ this.page = 1
|
|
|
+ this.reloadList()
|
|
|
+ }, 1500)
|
|
|
+ } else {
|
|
|
+ this.setRemindText(res.data.message)
|
|
|
+ }
|
|
|
+ }, err => {
|
|
|
+ console.log(err.response.data.data || '系统错误')
|
|
|
+ this.setRemindText(err.response.data.data || '系统错误')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ linkSaler (item) {
|
|
|
+ this.currentStoreInfo = item.enterprise
|
|
|
+ this.showLink = true
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -304,10 +376,10 @@
|
|
|
.mobile-cart {
|
|
|
bottom: 2rem;
|
|
|
.store-list {
|
|
|
- margin: .19rem 0;
|
|
|
- background: #fff;
|
|
|
.store-item {
|
|
|
padding: 0 .25rem;
|
|
|
+ background: #fff;
|
|
|
+ margin: .19rem 0;
|
|
|
.store-info {
|
|
|
height: .9rem;
|
|
|
line-height: .9rem;
|
|
|
@@ -327,6 +399,18 @@
|
|
|
margin-left: .08rem;
|
|
|
max-width: 5.7rem;
|
|
|
}
|
|
|
+ .link {
|
|
|
+ float: right;
|
|
|
+ font-size: .26rem;
|
|
|
+ color: #3f84f6;
|
|
|
+ margin-right: .12rem;
|
|
|
+ i {
|
|
|
+ margin-right: .08rem;
|
|
|
+ position: relative;
|
|
|
+ top: .04rem;
|
|
|
+ font-size: .34rem;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
.goods-list {
|
|
|
.goods-item {
|