Skip to content

Commit

Permalink
feat: The function of joining the group is realized
Browse files Browse the repository at this point in the history
  • Loading branch information
webyang-male committed Nov 12, 2022
1 parent 20cdd4c commit c2c0a63
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 37 deletions.
59 changes: 47 additions & 12 deletions components/Detail/GroupWorks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,85 @@
<span class="ml-2">{{ item.users[0].nickname ? item.users[0].nickname :
item.users[0].username
}}</span>

<div class="ml-auto">
<p>还差 <span class="text-rose-500">{{ item.total - item.num }}人</span>拼成</p>
<div class="text-xs text-gray-500 mt-1 flex items-center">剩余
<Seckill :time="item.end_time" @end="handleTimeUp(index)" />
</div>
</div>
<n-button type="primary" size="small" class="ml-2">去拼团</n-button>
<n-button type="primary" size="small" class="ml-2" @click="handleGroup(item)"
:loading="item.loading">去拼团</n-button>
</div>

</n-scrollbar>
</n-card>

</div>
</template>

<script setup>
import { NCard, NScrollbar, NButton, NAvatar } from "naive-ui"
import {
NCard,
NScrollbar,
NButton,
NAvatar,
createDiscreteApi
} from "naive-ui"

const props = defineProps({
group_id: {
type: Number,
default: 0
}
});
})

let {
data, error
} = useGetGroupWorkListApi(props.group_id)
data,
error
} = await useGetGroupWorkListApi(props.group_id)

const rows = ref([])
if (!error.value) {
rows.value = data.value.rows.map(o => {
o.end_time = (new Date(o.created_time)).getTime() + 24 * 60 * 60 * 1000;
o.loading = false;
return o;
o.end_time = (new Date(o.created_time)).getTime() + 24 * 60 * 60 * 1000
o.loading = false
return o
})
}

//移除事件
function handleTimeUp(index) {
rows.value.splice(index, 1)
data.value.count--;
data.value.count--
}

//拼团事件
//没有拼团展示就扫码支付一个最便宜的拼团就行了,注意新注册账号体验
function handleGroup(item) {
useHasAuth(() => {
const { dialog } = createDiscreteApi(["dialog"])
dialog.success({
title: "提示",
content: "是否要参与此次拼单?",
positiveText: "确定",
negativeText: "取消",
onPositiveClick() {
item.loading = true
useCreateOrderApi({
group_id: props.group_id,
group_work_id: item.id
}, "group")
.then(res => {
if (!res.error.value) {
navigateTo(`/pay?no=${res.data.value.no}`)
}
})
.finally(() => {
item.loading = false
})
}
})
})
}

</script>

<style>
Expand Down
18 changes: 0 additions & 18 deletions components/NavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
Search
} from "@vicons/ionicons5"
import Darkmode from 'darkmode-js';
const user = useUser()
Expand Down Expand Up @@ -167,23 +166,6 @@ const handleSelect = (k) => {
}
}
//白夜模式
const options = {
bottom: '92%', // default: '32px'
right: '2.5rem', // default: '32px'
left: 'unset', // default: 'unset'
time: '0.5s', // default: '0.3s'
mixColor: '#fff', // default: '#fff'
backgroundColor: '#fff', // default: '#fff'
buttonColorDark: '#100f2c', // default: '#100f2c'
buttonColorLight: '#fff', // default: '#fff'
saveInCookies: false, // default: true,
label: '🌓', // default: ''
autoMatchOsTheme: true // default: true
}
const darkmode = new Darkmode(options);
// darkmode.showWidget();
let goHome = () => {
navigateTo({
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"dependencies": {
"@css-render/vue3-ssr": "^0.15.10",
"aplayer": "^1.10.1",
"darkmode-js": "^1.5.7",
"qrcode": "^1.5.1",
"sass": "^1.55.0"
}
Expand Down
2 changes: 1 addition & 1 deletion pages/detail/[type]/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<n-grid :x-gap="20">
<n-grid-item :span="18">
<!-- 拼团组件 -->
<DetailGroupWorks v-if="data.isbuy && data.group" :group_id="data.group.id" />
<DetailGroupworks v-if="!data.isbuy && data.group" :group_id="data.group.id"/>

<section class="detail-bottom">
<UiTab class="border-b">
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1585,11 +1585,6 @@ cuint@^0.2.2:
resolved "https://registry.npmmirror.com/cuint/-/cuint-0.2.2.tgz#408086d409550c2631155619e9fa7bcadc3b991b"
integrity sha512-d4ZVpCW31eWwCMe1YT3ur7mUDnTXbgwyzaL320DrcRT45rfjYxkt5QWLrmOJ+/UEAI2+fQgKe/fCjR8l4TpRgw==

darkmode-js@^1.5.7:
version "1.5.7"
resolved "https://registry.npmmirror.com/darkmode-js/-/darkmode-js-1.5.7.tgz#b260ff671d67e021446ac8bade458e08338f6410"
integrity sha512-gM1KhV/yy/84ZUpES9/oeOn0CVtuOi2HBd+Kccr4CJz+rFccQo2gUuPbjfyPXUx7t800Zf408G6kZb5rkTgjFA==

data-uri-to-buffer@^4.0.0:
version "4.0.0"
resolved "https://registry.npmmirror.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz#b5db46aea50f6176428ac05b73be39a57701a64b"
Expand Down

0 comments on commit c2c0a63

Please sign in to comment.