unibest/src/pages/index/index.vue

94 lines
2.4 KiB
Vue
Raw Normal View History

2023-12-21 15:52:49 +08:00
<template>
<view class="content">
<image class="logo" src="/static/logo.png" />
<view class="text-area">
<text class="title">{{ title }}</text>
</view>
2023-12-23 11:27:00 +08:00
<button @click="setUserInfo">设置UserInfo</button>
<button @click="clearUserInfo">清除UserInfo</button>
2023-12-23 11:39:46 +08:00
2023-12-23 11:47:37 +08:00
<button @click="handleRequest">请求</button>
2023-12-23 09:53:15 +08:00
<view class="flex justify-center items-center text-blue-500">
2023-12-22 15:12:44 +08:00
Demo Count: {{ countStore.count }}
2023-12-23 09:53:15 +08:00
<button class="ml-2" @click="countStore.increment">新增</button>
2023-12-22 15:12:44 +08:00
</view>
2024-01-03 17:09:44 +08:00
<uni-icons type="contact" size="30" color="red"></uni-icons>
2023-12-23 13:42:31 +08:00
<uni-badge text="1"></uni-badge>
<!-- Sun in light mode, Moon in dark mode, from Carbon -->
2024-01-03 17:09:44 +08:00
<button class="i-carbon-sun dark:i-carbon-moon text-green-300" />
2023-12-23 14:32:19 +08:00
<fly-header></fly-header>
2023-12-21 15:52:49 +08:00
</view>
</template>
2023-12-21 16:50:50 +08:00
<script setup lang="ts" name="TestIndex">
2023-12-21 15:52:49 +08:00
import { ref } from 'vue'
2023-12-23 11:27:00 +08:00
import { useCountStore, useUserStore } from '@/store'
2023-12-23 11:39:46 +08:00
import { http } from '@/utils/http'
2023-12-23 11:47:37 +08:00
import { UserItem } from '@/typings'
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
2023-12-21 16:50:50 +08:00
2023-12-22 15:12:44 +08:00
const countStore = useCountStore()
2023-12-21 15:52:49 +08:00
const title = ref('Hello')
const uniLayout = ref()
console.log(uniLayout)
2023-12-23 11:27:00 +08:00
const userStore = useUserStore()
const setUserInfo = () => {
userStore.setUserInfo({ username: 'fly', token: 'abcdef' })
}
const clearUserInfo = () => {
userStore.clearUserInfo()
}
2023-12-23 11:47:37 +08:00
const handleRequest = () => {
const res = http<UserItem[]>({
2023-12-23 11:39:46 +08:00
url: '/getUserList',
method: 'GET',
})
console.log(res)
}
/** 激活“分享给好友” */
2024-01-03 11:46:01 +08:00
onShareAppMessage((options: Page.ShareAppMessageOption): Page.CustomShareContent => {
console.log('options:', options)
return {
title: '自定义分享标题',
path: '/pages/index/index?id=xxx',
imageUrl:
'https://cip-shopping-page-0eysug01066a9e-1302818703.tcloudbaseapp.com/pretty-girl.png',
}
})
/** 激活“分享到朋友圈”, 注意:需要先激活“分享给好友” */
onShareTimeline((): Page.ShareTimelineContent => {
return {
title: '自定义分享标题',
query: 'a=1&b=2',
}
})
2023-12-21 15:52:49 +08:00
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
width: 200rpx;
height: 200rpx;
margin: 200rpx auto 50rpx;
2023-12-21 15:52:49 +08:00
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>