368 lines
6.7 KiB
Vue
368 lines
6.7 KiB
Vue
<template>
|
||
<view>
|
||
<!-- 消息列表 -->
|
||
<view class="shop-list" v-if="msg">
|
||
<view class="item" v-for="(item,index) in msg.choices" :key="index">
|
||
<!-- <image :src="item.logo" mode="aspectFit"></image> -->
|
||
<view class="info">
|
||
<!-- <text class="title">{{item.merchantName}}</text> -->
|
||
<text class="desc">{{ item.message.content }}</text>
|
||
<!-- <view class="tag">
|
||
<view class="mr12">
|
||
<u-tag size="mini" plain text="租车站"></u-tag>
|
||
</view>
|
||
<view class="mr12">
|
||
<u-tag size="mini" type="warning" plain text="换点站"></u-tag>
|
||
</view>
|
||
<view class="mr12">
|
||
<u-tag size="mini" type="success" plain text="买车站"></u-tag>
|
||
</view>
|
||
</view> -->
|
||
<!-- <text class="distance">距离4.2km</text> -->
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<!-- 定位按钮 -->
|
||
<!-- <view v-if="!isAuthor" class="widget-location dis-flex flex-x-center flex-y-center" @click="onAuthorize()">
|
||
<text class="iconfont icon-locate"></text>
|
||
</view> -->
|
||
<!-- <empty v-if="list.length == 0" :isLoading="isLoading" tips="亲,暂无消息" /> -->
|
||
<!-- <view v-if="msg">
|
||
<view v-for="(item,index) in msg.choices" :key="index">
|
||
{{ item.message }}
|
||
</view>
|
||
</view> -->
|
||
<view class="footer">
|
||
<view class="send-box">
|
||
<input class="input" type="text" v-model="text" />
|
||
<button @click="onSubmit" class="submit-text">提交</button>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import store from '@/store/index.js'
|
||
import storage from '../../utils/storage'
|
||
import {
|
||
ACCESS_TOKEN,
|
||
USER_ID
|
||
} from '@/store/mutation-types'
|
||
import {
|
||
pageMerchant
|
||
} from '@/websoft/api/merchant.js'
|
||
import { chat } from '@/websoft/api/chatgpt.js'
|
||
import Empty from '@/components/empty'
|
||
import {
|
||
userId
|
||
} from '../../config'
|
||
import login from '../../websoft/api/login'
|
||
|
||
export default {
|
||
components: {
|
||
// Search,
|
||
Empty
|
||
},
|
||
data() {
|
||
return {
|
||
title: '国内馆',
|
||
// 正在加载中
|
||
isLoading: false,
|
||
// 是否授权了定位权限
|
||
isAuthor: true,
|
||
// 当前选择的门店ID
|
||
selectedId: null,
|
||
// 订单列表数据
|
||
list: [],
|
||
text: '',
|
||
msg: null
|
||
}
|
||
},
|
||
onLoad() {
|
||
const app = this
|
||
if (!store.getters.userId) {
|
||
console.log("未登录1: ");
|
||
return false;
|
||
}
|
||
// 获取用户坐标
|
||
app.getLocation(res => {
|
||
app.getShopList(res.longitude, res.latitude)
|
||
})
|
||
},
|
||
onShow() {
|
||
const app = this
|
||
if (app.list.length == 0) {
|
||
app.getShopList(app.longitude, app.latitude)
|
||
}
|
||
},
|
||
methods: {
|
||
// 获取门店列表
|
||
getShopList(longitude, latitude) {
|
||
const app = this
|
||
},
|
||
|
||
// 获取用户坐标
|
||
// 参考文档:https://uniapp.dcloud.io/api/location/location?id=getlocation
|
||
getLocation(callback) {
|
||
const app = this
|
||
uni.getLocation({
|
||
success: callback,
|
||
fail() {
|
||
app.$toast('获取定位失败,请点击右下角按钮重新尝试定位')
|
||
app.isAuthor = false
|
||
}
|
||
})
|
||
},
|
||
|
||
// 授权启用定位权限
|
||
onAuthorize() {
|
||
const app = this
|
||
// #ifdef MP
|
||
uni.openSetting({
|
||
success(res) {
|
||
if (res.authSetting['scope.userLocation']) {
|
||
console.log('定位权限授权成功')
|
||
app.isAuthor = true
|
||
setTimeout(() => {
|
||
// 获取用户坐标
|
||
app.getLocation((res) => {
|
||
app.getShopList(res.longitude, res.latitude)
|
||
})
|
||
}, 1000)
|
||
}
|
||
}
|
||
})
|
||
// #endif
|
||
// #ifdef H5
|
||
// 获取用户坐标
|
||
app.getLocation((res) => {
|
||
app.getShopList(res.longitude, res.latitude)
|
||
})
|
||
// #endif
|
||
},
|
||
|
||
navTo(merchantId) {
|
||
const navTo = uni.$u.route()
|
||
navTo('pages/merchant/detail', {
|
||
merchantId
|
||
})
|
||
},
|
||
|
||
/**
|
||
* 选择门店
|
||
*/
|
||
onSelectedShop(merchantId, merchantCode) {
|
||
uni.$u.route('pages/merchant/detail', {
|
||
merchantId,
|
||
merchantCode
|
||
})
|
||
},
|
||
|
||
changeCity() {
|
||
this.$toast('切换区域')
|
||
},
|
||
|
||
onSubmit() {
|
||
const app = this
|
||
chat({
|
||
tenantId: 6,
|
||
content: app.text
|
||
}).then(res => {
|
||
console.log("res: ",res);
|
||
app.msg = res.data
|
||
}).catch(err => {
|
||
if(err.code == 1){
|
||
app.$error("您的免费额度已用完")
|
||
}
|
||
console.log("err: ",err);
|
||
})
|
||
pageMerchant({}).then(res => {
|
||
console.log("res: ",res);
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.bg {
|
||
background-color: #F5F5F8
|
||
}
|
||
|
||
.shop-list {
|
||
.item {
|
||
padding: 20rpx;
|
||
margin: 20rpx auto;
|
||
background-color: #ffffff;
|
||
width: 660rpx;
|
||
border-radius: 20rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
|
||
image {
|
||
width: 180rpx;
|
||
height: 180rpx;
|
||
margin-right: 40rpx;
|
||
background-color: #f9f9f9;
|
||
}
|
||
|
||
.info {
|
||
display: flex;
|
||
flex-direction: column;
|
||
|
||
.title {
|
||
font-size: 38rpx;
|
||
font-weight: bold;
|
||
margin-bottom: 10rpx;
|
||
}
|
||
|
||
.desc {
|
||
font-size: 28rpx;
|
||
}
|
||
|
||
.tag {
|
||
font-size: 28rpx;
|
||
display: flex;
|
||
|
||
.mr12 {
|
||
margin-right: 12rpx;
|
||
}
|
||
}
|
||
|
||
.distance {
|
||
font-size: 28rpx;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
.header-box {
|
||
padding: 20rpx 36rpx 0 36rpx;
|
||
display: flex;
|
||
justify-content: space-between;
|
||
|
||
.location {
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
color: #999999;
|
||
|
||
image {
|
||
width: 60rpx;
|
||
height: 60rpx
|
||
}
|
||
}
|
||
|
||
.u-subsection {
|
||
width: 260rpx;
|
||
margin-top: 7rpx
|
||
}
|
||
}
|
||
|
||
.search-wrapper {
|
||
display: flex;
|
||
width: 80%;
|
||
height: 64rpx
|
||
}
|
||
|
||
// 搜索输入框
|
||
.search-input {
|
||
width: 90%;
|
||
background: #fff;
|
||
border-radius: 10rpx 0 0 10rpx;
|
||
box-sizing: border-box;
|
||
overflow: hidden;
|
||
|
||
.search-input-wrapper {
|
||
display: flex;
|
||
|
||
.left {
|
||
display: flex;
|
||
width: 60rpx;
|
||
justify-content: center;
|
||
align-items: center;
|
||
|
||
.search-icon {
|
||
display: block;
|
||
color: #b4b4b4;
|
||
font-size: 28rpx
|
||
}
|
||
}
|
||
|
||
.right {
|
||
flex: 1;
|
||
|
||
input {
|
||
font-size: 28rpx;
|
||
height: 64rpx;
|
||
display: flex;
|
||
|
||
.input-placeholder {
|
||
color: #aba9a9
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
.shop-avatar {
|
||
width: 200rpx;
|
||
margin-right: 24rpx
|
||
}
|
||
|
||
// 搜索按钮
|
||
.search-button {
|
||
width: 25%;
|
||
box-sizing: border-box;
|
||
|
||
.button {
|
||
height: 64rpx;
|
||
font-size: 28rpx;
|
||
border-radius: 0 5px 5px 0;
|
||
background: #2C71C7
|
||
}
|
||
}
|
||
|
||
.shop-info {
|
||
width: 100%;
|
||
margin-left: 20rpx;
|
||
|
||
.title {
|
||
font-size: 38rpx;
|
||
font-weight: bold;
|
||
padding-bottom: 10rpx;
|
||
}
|
||
|
||
.about {
|
||
display: flex;
|
||
|
||
.mr12 {
|
||
margin-right: 12rpx;
|
||
}
|
||
}
|
||
}
|
||
|
||
.u-body-item {
|
||
align-items: stretch !important
|
||
}
|
||
|
||
.footer {
|
||
width: 750rpx;
|
||
position: absolute;
|
||
bottom: 100rpx;
|
||
.send-box {
|
||
width: 700rpx;
|
||
margin: auto;
|
||
height: 90rpx;
|
||
display: flex;
|
||
justify-content: space-around;
|
||
border-radius: 20rpx;
|
||
.submit-text{ padding: 0 30rpx;}
|
||
.input{
|
||
width: 512rpx;
|
||
height: 82rpx;
|
||
}
|
||
}
|
||
}
|
||
</style>
|