|
@@ -12,7 +12,7 @@
|
|
|
// eslint-disable-next-line unused-imports/no-unused-imports
|
|
|
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
|
|
|
import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging.js'
|
|
|
-import { preOrder as _preOrder, joinPink } from '@/api/order'
|
|
|
+import { preOrder as _preOrder } from '@/api/order'
|
|
|
import { getDetail, pinkList } from '@/api/product'
|
|
|
import { formatNumber } from '@/utils/index'
|
|
|
import { getPageParams, goBack, toPage } from '@/utils/page'
|
|
@@ -49,7 +49,8 @@ onPageScroll((e) => {
|
|
|
navBgColor.value = 'transparent'
|
|
|
}
|
|
|
})
|
|
|
-const id = ref('')
|
|
|
+const productId = ref('') // 商品id
|
|
|
+const id = ref('') // 数据id
|
|
|
const detail = ref<any>({
|
|
|
sliderImage: '',
|
|
|
flatPattern: '',
|
|
@@ -84,28 +85,20 @@ function onChange(e) {
|
|
|
// console.log(e)
|
|
|
}
|
|
|
|
|
|
-// 添加头像列表数据
|
|
|
-const avatarList = ref([
|
|
|
- '/static/images/avatar.jpg',
|
|
|
- '/static/images/avatar.jpg',
|
|
|
- '/static/images/avatar.jpg',
|
|
|
- '/static/images/avatar.jpg',
|
|
|
- '/static/images/avatar.jpg',
|
|
|
- '/static/images/avatar.jpg',
|
|
|
- '/static/images/avatar.jpg',
|
|
|
-])
|
|
|
-
|
|
|
// 拼团类型 join-加团 open-开团
|
|
|
const groupType = ref('open')
|
|
|
const pinkId = ref('') // 拼团id
|
|
|
+const joinOrderId = ref('') // 加团的拼团-订单id
|
|
|
|
|
|
// sku 逻辑
|
|
|
const showSku = ref(false)
|
|
|
-function openSku(type: string, id?: string) {
|
|
|
+function openSku(type: string, id?: string, pinkOrderId?: string) {
|
|
|
showSku.value = true
|
|
|
groupType.value = type
|
|
|
if (id)
|
|
|
pinkId.value = id
|
|
|
+ if (pinkOrderId)
|
|
|
+ joinOrderId.value = pinkOrderId
|
|
|
}
|
|
|
const formData = ref({
|
|
|
productNum: 1,
|
|
@@ -200,7 +193,7 @@ function findMatchingAttrValue(selectedSpecs) {
|
|
|
}
|
|
|
// 查询商品详情
|
|
|
async function queryDetail() {
|
|
|
- const res = await getDetail({ id: id.value })
|
|
|
+ const res = await getDetail({ id: productId.value })
|
|
|
console.log(res)
|
|
|
detail.value = res.data
|
|
|
// 默认选择第一个规格
|
|
@@ -210,7 +203,7 @@ async function queryDetail() {
|
|
|
|
|
|
// 查询商品拼团信息
|
|
|
async function queryPinkInfo() {
|
|
|
- const res = await pinkList({ id: id.value })
|
|
|
+ const res = await pinkList({ cid: id.value })
|
|
|
console.log(res)
|
|
|
pinkInfo.value = res.data.list
|
|
|
}
|
|
@@ -253,17 +246,11 @@ async function preOrder() {
|
|
|
if (!requireLogin()) {
|
|
|
return
|
|
|
}
|
|
|
- if (groupType.value === 'join') {
|
|
|
- await joinPink({
|
|
|
- cid: id.value,
|
|
|
- pinkId: pinkId.value,
|
|
|
- userId: userInfo.value.userId,
|
|
|
- })
|
|
|
- }
|
|
|
const data = {
|
|
|
orderDetails: {
|
|
|
attrValueId: matchedAttrValue.value.id,
|
|
|
- productId: id.value,
|
|
|
+ productId: productId.value,
|
|
|
+ cid: id.value,
|
|
|
productNum: formData.value.productNum,
|
|
|
},
|
|
|
preOrderType: 'buyNow',
|
|
@@ -272,7 +259,16 @@ async function preOrder() {
|
|
|
const res = await _preOrder(data)
|
|
|
if (res.code === '200') {
|
|
|
showSku.value = false
|
|
|
- toPage('/pages/productDetail/checkOut', { orderId: res.data })
|
|
|
+ toPage(
|
|
|
+ '/pages/productDetail/checkOut',
|
|
|
+ {
|
|
|
+ preOrderId: res.data,
|
|
|
+ joinOrderId: joinOrderId.value,
|
|
|
+ pinkId: pinkId.value,
|
|
|
+ cid: id.value,
|
|
|
+ groupType: groupType.value,
|
|
|
+ },
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -281,6 +277,7 @@ onLoad((options) => {
|
|
|
console.log(options)
|
|
|
const params = getPageParams(options)
|
|
|
id.value = params.id
|
|
|
+ productId.value = params.productId
|
|
|
})
|
|
|
onShow(() => {
|
|
|
queryDetail()
|
|
@@ -406,7 +403,7 @@ onShow(() => {
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <wd-button size="small" @click="openSku('join', item.id)">
|
|
|
+ <wd-button size="small" @click="openSku('join', item.id, item.orderId)">
|
|
|
Join Group
|
|
|
</wd-button>
|
|
|
</view>
|