抖音小程序试水
This commit is contained in:
parent
3f1abfa35f
commit
5857e62e49
@ -6,6 +6,10 @@
|
||||
{
|
||||
"launchtype" : "local"
|
||||
},
|
||||
"mp-toutiao" :
|
||||
{
|
||||
"launchtype" : "local"
|
||||
},
|
||||
"mp-weixin" :
|
||||
{
|
||||
"launchtype" : "local"
|
||||
|
@ -61,7 +61,6 @@
|
||||
"@dcloudio/uni-ui": "^1.5.6",
|
||||
"crypto-js": "^3.3.0",
|
||||
"destr": "^2.0.3",
|
||||
"moment": "^2.30.1",
|
||||
"pinia": "^2.2.4",
|
||||
"pinia-plugin-persistedstate": "^3.2.1",
|
||||
"qs": "6.7.0",
|
||||
|
9774
pnpm-lock.yaml
9774
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
17
src/App.vue
17
src/App.vue
@ -31,6 +31,23 @@ export default {
|
||||
}
|
||||
});
|
||||
//#endif
|
||||
|
||||
// #ifdef MP-TOUTIAO
|
||||
uni.login({
|
||||
provider: 'toutiao', //使用抖音登录
|
||||
onlyAuthorize: false, //只授权,不弹出授权页面
|
||||
success(loginRes){
|
||||
console.log("登录信息", loginRes)
|
||||
|
||||
uni.getUserInfo({
|
||||
provider: 'toutiao',
|
||||
success(userInfoRes){
|
||||
console.log("用户信息", userInfoRes)
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
onShow: function () {
|
||||
console.log('App Show')
|
||||
|
@ -20,7 +20,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import moment from 'moment'
|
||||
// import moment from 'moment'
|
||||
import NavBar from "./components/nav-bar/index.vue"
|
||||
import Banner from "./components/banner/index.vue"
|
||||
import HotPanel from "./components/hot-panel/index.vue"
|
||||
@ -35,8 +35,8 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
now: moment().format('YYYY-MM-DD HH:mm:ss'),
|
||||
now: new Date().toTimeString(),
|
||||
// now: moment().format('YYYY-MM-DD HH:mm:ss'),
|
||||
title: 'Hello',
|
||||
}
|
||||
},
|
||||
@ -50,7 +50,8 @@ export default {
|
||||
}
|
||||
|
||||
timer = setInterval(() => {
|
||||
this.now = new moment().format('YYYY-MM-DD HH:mm:ss')
|
||||
// this.now = new moment().format('YYYY-MM-DD HH:mm:ss')
|
||||
this.now = new Date().toTimeString()
|
||||
}, 1000)
|
||||
|
||||
},
|
||||
|
@ -8,6 +8,8 @@
|
||||
<image class="avatar" :src="ctx.avatarUrl"></image>
|
||||
</button>
|
||||
<input class="uni-input" placeholder="请输入昵称" />
|
||||
|
||||
<button type="primary" @tap="getUserProfile" data-eventsync="true">获取用户信息</button>
|
||||
</view>
|
||||
|
||||
<view class="warp">
|
||||
@ -27,11 +29,22 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {reactive, watchEffect} from "vue"
|
||||
import {useI18n} from "vue-i18n"
|
||||
import {onReady} from "@dcloudio/uni-app";
|
||||
const {t, locale} = useI18n()
|
||||
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
|
||||
import {
|
||||
reactive,
|
||||
watchEffect
|
||||
} from "vue"
|
||||
import {
|
||||
useI18n
|
||||
} from "vue-i18n"
|
||||
import {
|
||||
onReady
|
||||
} from "@dcloudio/uni-app";
|
||||
const {
|
||||
t,
|
||||
locale
|
||||
} = useI18n()
|
||||
const defaultAvatarUrl =
|
||||
'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
|
||||
|
||||
const ctx = reactive({
|
||||
lang: {
|
||||
@ -41,7 +54,9 @@ const ctx = reactive({
|
||||
})
|
||||
|
||||
function onChooseAvatar(e) {
|
||||
const { avatarUrl } = e.detail
|
||||
const {
|
||||
avatarUrl
|
||||
} = e.detail
|
||||
ctx.avatarUrl = avatarUrl
|
||||
}
|
||||
|
||||
@ -107,12 +122,26 @@ function getLocation(){
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getUserProfile() {
|
||||
uni.getUserProfile({
|
||||
desc: '获取你的昵称、头像、地区及性别',
|
||||
success(profileRes) {
|
||||
console.log("用户资料", profileRes)
|
||||
ctx.avatarUrl = profileRes.userInfo.avatarUrl
|
||||
},
|
||||
fail(res) {
|
||||
console.error("用户资料获取失败", res)
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.warp {
|
||||
padding: 5rpx;
|
||||
}
|
||||
|
||||
.button {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
@ -1,8 +1,15 @@
|
||||
import path from "path";
|
||||
import {fileURLToPath, URL} from 'node:url'
|
||||
import { defineConfig } from 'vite'
|
||||
import {
|
||||
fileURLToPath,
|
||||
URL
|
||||
} from 'node:url'
|
||||
import {
|
||||
defineConfig
|
||||
} from 'vite'
|
||||
import uni from '@dcloudio/vite-plugin-uni'
|
||||
import { UnifiedViteWeappTailwindcssPlugin as uvwt } from "weapp-tailwindcss/vite";
|
||||
import {
|
||||
UnifiedViteWeappTailwindcssPlugin as uvwt
|
||||
} from "weapp-tailwindcss/vite";
|
||||
// 注意: 打包成 h5 和 app 都不需要开启插件配置
|
||||
const isH5 = process.env.UNI_PLATFORM === "h5";
|
||||
const isApp = process.env.UNI_PLATFORM === "app";
|
||||
@ -22,6 +29,11 @@ export default defineConfig({
|
||||
disabled: weAppTailwindcssDisabled
|
||||
})
|
||||
],
|
||||
define: {
|
||||
__VUE_I18N_FULL_INSTALL__: JSON.stringify(true),
|
||||
__VUE_I18N_LEGACY_API__: JSON.stringify(false),
|
||||
__INTLIFY_PROD_DEVTOOLS__: JSON.stringify(false),
|
||||
},
|
||||
css: {
|
||||
postcss: {
|
||||
plugins: [
|
||||
|
Loading…
Reference in New Issue
Block a user