Commit e137e193 authored by liubinyu's avatar liubinyu

星座接口

parent 2936e8a4
import http from './interceptor.js' import http from './interceptor.js'
export function list(data) { // 游客选择星座字体查看今日所属星座运势
return http.request({ url: '/system/astrologyForecastDaily/list', method: 'get', data }) export function findConstellation(data) {
return http.request({ url: '/system/chatCompletionsExample/findConstellation', method: 'get', data })
}
// 专属运程(免费)
export function exclusiveItineraryFree(data) {
return http.request({ url: '/system/chatCompletionsExample/exclusiveItineraryFree', method: 'get', data })
} }
/** /**
......
...@@ -32,9 +32,11 @@ ...@@ -32,9 +32,11 @@
this.page = pages[pages.length - 1].route; this.page = pages[pages.length - 1].route;
}, },
methods: { methods: {
// 页面跳转
go(url) { go(url) {
if (url.indexOf(this.page) > -1) return; if (url.indexOf(this.page) > -1) return;
uni.switchTab({ url }) // 用switchTab是为了切换时不刷新页面
uni.switchTab({ url });
}, },
}, },
} }
......
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
this.currentWebview = page.$getAppWebview(); this.currentWebview = page.$getAppWebview();
this.currentWebviewRefresh = !!this.currentWebview.getStyle().pullToRefresh this.currentWebviewRefresh = !!this.currentWebview.getStyle().pullToRefresh
// #endif // #endif
// 移动到第一个 // 初始移动
this.rotate.containerA = this.$g.ConstellationList[0].angle this.rotate.containerA = this.x_xz?.angle || this.$g.ConstellationList[0].angle
this.moveToXZ() this.moveToXZ()
}, },
methods: { methods: {
......
<template> <template>
<view class="page bg2"> <view class="page bg2">
<view class="box"> <view class="box">
<scroll-view scroll-y class="content" scroll-into-view="last"> <scroll-view scroll-y class="content" :scroll-into-view="lastId">
<view class="tips"> <view class="tips">
<view class="line">——</view> <view class="line">——</view>
AI{{ $t('Stargazer') }}-{{ $t('XiaoXi') }} {{ $t('The astrological') }} AI{{ $t('Stargazer') }}-{{ $t('XiaoXi') }} {{ $t('The astrological') }}
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</view> </view>
<view class="msg"> <view class="msg">
<view v-for="(item,index) in recordList" :key="index" class="msg-item" :class="item.user ? 'right' : ''"> <view v-for="(item,index) in recordList" :key="index" class="msg-item" :class="item.user ? 'right' : ''">
<template v-if="item.showAvatar"> <template v-if="showAvatar(item, index)">
<view v-if="item.user" class="avatar"> <view v-if="item.user" class="avatar">
<image class="avatar" src="@/static/avatar-user.png"></image> <image class="avatar" src="@/static/avatar-user.png"></image>
<view class="txt">{{ $t('User') }}</view> <view class="txt">{{ $t('User') }}</view>
...@@ -34,18 +34,59 @@ ...@@ -34,18 +34,59 @@
export default { export default {
data() { data() {
return { return {
recordList: [ lastId: '',
{ content: '2025年2月28日 星期五\n★★★☆☆\n稳健发展 财运平稳 健康良好\n今日金牛座整体运势平稳,财务方面可能有小收获。', showAvatar: true }, recordList: [], // 聊天记录列表
{ content: '如果你想窥探详细的星座运程,你可以告诉我你的生日。' },
{ content: '我的生日是2000年2月24日。', user: true, showAvatar: true },
{ content: '2000年2月24日是双鱼座.....', showAvatar: true },
],
inputText: '', inputText: '',
}; };
}, },
onLoad() {
// this.init()
},
methods: { methods: {
// 初始化
async init() {
this.recordList = []
this.inputText = ''
await this.getInfo()
this.getZSYC()
},
// 获取星座信息
async getInfo() {
const res = await this.$api.findConstellation({
constellation: this.x_xz.constellation,
language: this.$g.languageMap[this.$i18n.locale]
})
if (!res?.data) return
this.addMsg(res.data.content)
},
// 专属运程消息
async getZSYC() {
const res = await this.$api.exclusiveItineraryFree({
language: this.$g.languageMap[this.$i18n.locale]
})
if (!res?.data) return
this.addMsg(res.data)
},
// 是否显示头像,每个用户连续的记录,只显示第一个的头像
showAvatar(item, index) {
if (index === 0) return true
else return !!item.user !== !!this.recordList[index - 1].user
},
confirm() { confirm() {
console.log(123, this.inputText); this.addMsg(this.inputText, true)
this.inputText = ''
},
// 新增记录
addMsg(content, user) {
this.recordList.push({ content, user })
this.scrollToLast()
},
// 滚动到底部
scrollToLast() {
this.lastId = ''
setTimeout(() => {
this.lastId = 'last'
}, 10)
}, },
} }
} }
......
...@@ -3,19 +3,26 @@ ...@@ -3,19 +3,26 @@
<view class="card" :class="{ back: isBack }" <view class="card" :class="{ back: isBack }"
:style="{ transitionDuration: `${duration}s`, transform: `scaleX(${scale})` }" @click="start"> :style="{ transitionDuration: `${duration}s`, transform: `scaleX(${scale})` }" @click="start">
<template v-if="!isBack && info"> <template v-if="!isBack && info">
<view class="title">{{ $t(x_xz.key) }}</view> <view class="title">{{ info.constellation }}</view>
<view class="date">{{ today }}</view> <view class="date">{{ info.date }}</view>
<view class="star-list"> <view class="star-list">
<image v-for="i in Number(info.luckyStar)" class="star" src="@/static/star.png" /> <image v-for="i in Number(info.numberStars)" class="star" src="@/static/star.png" />
<template v-if="Number(info.luckyStar) <= 5"> <template v-if="Number(info.numberStars) <= 5">
<image v-for="i in 5 - Number(info.luckyStar)" class="star" src="@/static/star1.png" /> <image v-for="i in 5 - Number(info.numberStars)" class="star" src="@/static/star1.png" />
</template> </template>
</view> </view>
<view class="word-list"> <view class="word-list">
<view v-for="word in getWordList(info[`keyWord${$i18n.locale}`])" class="word">{{ word }}</view> <view v-for="word in info.keywords" class="word">{{ word }}</view>
</view> </view>
<scroll-view scroll-y class="scroll-wrap"> <scroll-view scroll-y class="scroll-wrap">
<view class="desc">{{ info[`fortune${$i18n.locale}`] }}</view> <view class="desc">{{ info.summaryFortune }}</view>
<view class="suggest">
<view class="tips">{{ $t('Today Advice') }}</view>
<view v-for="(item, index) in info.toDaySuggestion" :key="index" class="item">
<image class="icon" src="/static/icon-dui.svg" />
<text class="txt">{{ item }}</text>
</view>
</view>
</scroll-view> </scroll-view>
</template> </template>
</view> </view>
...@@ -41,11 +48,11 @@ ...@@ -41,11 +48,11 @@
isBack: true, // 是否是背面,也就是无信息的那面 isBack: true, // 是否是背面,也就是无信息的那面
scale: 1, // 收缩状态 scale: 1, // 收缩状态
duration: 0.3, // 动画时间(s) duration: 0.3, // 动画时间(s)
today: '', info: undefined, // 星座信息
info: undefined,
}; };
}, },
onLoad() { onLoad() {
// 如果没选择星座,则跳转星座选择页面
if (!this.x_xz) { if (!this.x_xz) {
uni.reLaunch({ uni.reLaunch({
url: '/pages/index/index' url: '/pages/index/index'
...@@ -53,6 +60,7 @@ ...@@ -53,6 +60,7 @@
} }
}, },
methods: { methods: {
// 开启
start() { start() {
if (!this.isBack) return; if (!this.isBack) return;
this.getInfo() this.getInfo()
...@@ -62,18 +70,13 @@ ...@@ -62,18 +70,13 @@
this.scale = 1 this.scale = 1
}, this.duration * 1000) }, this.duration * 1000)
}, },
// 获取星座信息
async getInfo() { async getInfo() {
const now = new Date() const res = await this.$api.findConstellation({
const res = await this.$api.list({ constellation: this.x_xz.constellation,
zodiacSignId: this.x_xz.zodiacSignId, language: this.$g.languageMap[this.$i18n.locale]
fortuneDate: dateFormat(now), })
pageSize: 20, this.info = res?.data
});
this.info = res?.rows?.[0]
this.today = dateFormat(now, this.$i18n.locale === 'En' ? `${now.toDateString()} e` : 'YYYY年MM月DD日 z')
},
getWordList(word) {
return word?.split(/[,、]/).filter(i => !!i).map(i => i.trim()) || []
}, },
}, },
} }
...@@ -143,6 +146,27 @@ ...@@ -143,6 +146,27 @@
line-height: 40rpx; line-height: 40rpx;
white-space: pre-wrap; white-space: pre-wrap;
} }
.suggest {
width: fit-content;
margin: 80rpx auto 0;
line-height: 50rpx;
.tips {}
.item {
.icon {
width: 24rpx;
height: 24rpx;
margin-right: 10rpx;
}
.txt {
font-size: 30rpx;
color: #666;
}
}
}
} }
.card.back { .card.back {
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
export default { export default {
data() { data() {
return { return {
locales: [], locales: [], // 语言列表
localeIndex: 0, localeIndex: 0, // 当前语言索引
} }
}, },
computed: { computed: {
...@@ -33,18 +33,22 @@ ...@@ -33,18 +33,22 @@
this.getLocales() this.getLocales()
}, },
methods: { methods: {
// 获取语言列表
getLocales() { getLocales() {
this.locales = this.$i18n.availableLocales.map((i, index) => { this.locales = Object.keys(this.$g.languageMap).map((i, index) => {
if (i === this.lang) this.localeIndex = index; if (i === this.lang) this.localeIndex = index;
return this.$t(i) return this.$t(i)
}) })
}, },
// 更改语言
changeLang(e) { changeLang(e) {
const val = this.$i18n.availableLocales[e.detail.value] const val = Object.keys(this.$g.languageMap)[e.detail.value]
this.$i18n.locale = val this.$i18n.locale = val
uni.setStorageSync('locale', val) uni.setStorageSync('locale', val)
this.getLocales() // 重置所有页面
uni.reLaunch({ url: '/pages/user/user' })
}, },
// 页面跳转
go(url) { go(url) {
uni.navigateTo({ url }) uni.navigateTo({ url })
}, },
......
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1749175382298" class="icon" viewBox="0 0 1035 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4431" xmlns:xlink="http://www.w3.org/1999/xlink" width="64.6875" height="64"><path d="M517.613889 1010.377409c-66.653788 0-131.336031-13.065657-192.264544-38.829395-58.812166-24.872645-111.631728-60.482966-156.977244-105.828482S87.427403 767.565592 62.543619 708.742288C36.779881 647.824914 23.714224 583.142671 23.714224 516.477744s13.065657-131.336031 38.829395-192.253404c24.872645-58.823304 60.482966-111.631728 105.828482-156.977244s98.15394-80.944698 156.977244-105.828482c60.917374-25.763738 125.599617-38.829396 192.264544-38.829396s131.336031 13.065657 192.253404 38.829396c58.823304 24.872645 111.631728 60.482966 156.977244 105.828482 45.345516 45.345516 80.944698 98.15394 105.828482 156.977244 25.763738 60.917374 38.829396 125.599617 38.829396 192.253404s-13.065657 131.336031-38.829396 192.264544c-24.872645 58.812166-60.482966 111.631728-105.828482 156.977244-45.345516 45.345516-98.15394 80.944698-156.977244 105.828482-60.917374 25.763738-125.599617 38.829396-192.253404 38.829395z m0-898.678849c-223.196624 0-404.779185 181.582561-404.779185 404.779184s181.582561 404.779185 404.779185 404.779185 404.779185-181.582561 404.779184-404.779185-181.582561-404.779185-404.779184-404.779184z m-19.091677 579.099334l285.617718-285.617717c17.398599-17.398599 17.398599-45.612844 0-63.011444-17.398599-17.398599-45.612844-17.398599-63.011444 0L467.010921 596.286299 314.088152 443.36353c-17.398599-17.398599-45.612844-17.398599-63.011443 0s-17.398599 45.612844 0 63.011443l184.43406 184.43406c8.354001 8.354001 19.693165 13.054519 31.500152 13.054518s23.146152-4.689379 31.500152-13.054518z" p-id="4432" fill="#674bd9"></path></svg>
\ No newline at end of file
...@@ -22,7 +22,7 @@ const saveLifeData = function(key, value) { ...@@ -22,7 +22,7 @@ const saveLifeData = function(key, value) {
const store = new Vuex.Store({ const store = new Vuex.Store({
state: { state: {
x_xz: lifeData.x_xz, x_xz: lifeData.x_xz, // 用户选择的星座
}, },
mutations: { mutations: {
xStore(state, payload) { xStore(state, payload) {
......
...@@ -9,10 +9,7 @@ try { ...@@ -9,10 +9,7 @@ try {
module.exports = { module.exports = {
beforeCreate() { beforeCreate() {
this.vuex = (name, value) => { this.vuex = (name, value) => {
this.$store.commit('xStore', { this.$store.commit('xStore', { name, value })
name,
value
})
} }
}, },
computed: { computed: {
......
// 全局常量 // 全局常量
export default { export default {
baseUrl: 'http://47.243.113.209:8081', // 本地环境
// baseUrl: '/api', // 正式环境 // baseUrl: '/api', // 正式环境
// baseUrl: 'http://47.243.113.209:8081', // 正式环境
baseUrl: 'http://192.168.200.12:8081', // 鸿波
// 星座列表 // 星座列表
ConstellationList: [ ConstellationList: [
{ key: 'Aries', date: ['3.21', '4.19'], zodiacSignId: '1', angle: 330 }, { key: 'Aries', date: ['3.21', '4.19'], zodiacSignId: '1', angle: 330, constellation: '白羊' },
{ key: 'Taurus', date: ['4.20', '5.20'], zodiacSignId: '2', angle: 300 }, { key: 'Taurus', date: ['4.20', '5.20'], zodiacSignId: '2', angle: 300, constellation: '金牛' },
{ key: 'Gemini', date: ['5.21', '6.21'], zodiacSignId: '3', angle: 270 }, { key: 'Gemini', date: ['5.21', '6.21'], zodiacSignId: '3', angle: 270, constellation: '双子' },
{ key: 'Cancer', date: ['6.22', '7.22'], zodiacSignId: '4', angle: 240 }, { key: 'Cancer', date: ['6.22', '7.22'], zodiacSignId: '4', angle: 240, constellation: '巨蟹' },
{ key: 'Leo', date: ['7.23', '8.22'], zodiacSignId: '5', angle: 210 }, { key: 'Leo', date: ['7.23', '8.22'], zodiacSignId: '5', angle: 210, constellation: '狮子' },
{ key: 'Virgo', date: ['8.23', '9.22'], zodiacSignId: '6', angle: 180 }, { key: 'Virgo', date: ['8.23', '9.22'], zodiacSignId: '6', angle: 180, constellation: '处女' },
{ key: 'HLibra', date: ['9.23', '10.23'], zodiacSignId: '7', angle: 150 }, { key: 'HLibra', date: ['9.23', '10.23'], zodiacSignId: '7', angle: 150, constellation: '天秤' },
{ key: 'Scorpio', date: ['10.24', '11.22'], zodiacSignId: '8', angle: 120 }, { key: 'Scorpio', date: ['10.24', '11.22'], zodiacSignId: '8', angle: 120, constellation: '天蝎' },
{ key: 'Sagittarius', date: ['11.23', '12.21'], zodiacSignId: '9', angle: 90 }, { key: 'Sagittarius', date: ['11.23', '12.21'], zodiacSignId: '9', angle: 90, constellation: '射手' },
{ key: 'Capricornus', date: ['12.22', '1.19'], zodiacSignId: '10', angle: 60 }, { key: 'Capricornus', date: ['12.22', '1.19'], zodiacSignId: '10', angle: 60, constellation: '摩羯' },
{ key: 'Aquarius', date: ['1.20', '2.18'], zodiacSignId: '11', angle: 30 }, { key: 'Aquarius', date: ['1.20', '2.18'], zodiacSignId: '11', angle: 30, constellation: '水瓶' },
{ key: 'Pisces', date: ['2.19', '3.20'], zodiacSignId: '12', angle: 0 }, { key: 'Pisces', date: ['2.19', '3.20'], zodiacSignId: '12', angle: 0, constellation: '双鱼' },
] ],
// language映射
languageMap: {
Tc: '中文繁体',
Cn: '中文简体',
En: '英文',
},
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment