添加分享配置
This commit is contained in:
parent
4a3c488019
commit
c1ffa7606b
@ -3,7 +3,7 @@
|
||||
"type": "commonjs",
|
||||
"version": "3.0.0",
|
||||
"description": "unibest - 最好的 uniapp 开发模板",
|
||||
"update-time": "2025-09-08",
|
||||
"update-time": "2025-09-11",
|
||||
"author": {
|
||||
"name": "feige996",
|
||||
"zhName": "菲鸽",
|
||||
@ -104,6 +104,7 @@
|
||||
"qs": "6.5.3",
|
||||
"uview-ui": "2.0.38",
|
||||
"vue": "^3.4.21",
|
||||
"weixin-js-sdk": "^1.6.5",
|
||||
"wot-design-uni": "^1.9.1",
|
||||
"z-paging": "2.8.7"
|
||||
},
|
||||
|
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
@ -100,6 +100,9 @@ importers:
|
||||
vue:
|
||||
specifier: ^3.4.21
|
||||
version: 3.5.15(typescript@5.7.2)
|
||||
weixin-js-sdk:
|
||||
specifier: ^1.6.5
|
||||
version: 1.6.5
|
||||
wot-design-uni:
|
||||
specifier: ^1.9.1
|
||||
version: 1.9.1(vue@3.5.15(typescript@5.7.2))
|
||||
@ -6252,6 +6255,9 @@ packages:
|
||||
webpack-virtual-modules@0.6.2:
|
||||
resolution: {integrity: sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==}
|
||||
|
||||
weixin-js-sdk@1.6.5:
|
||||
resolution: {integrity: sha512-Gph1WAWB2YN/lMOFB/ymb+hbU/wYazzJgu6PMMktCy9cSCeW5wA6Zwt0dpahJbJ+RJEwtTv2x9iIu0U4enuVSQ==}
|
||||
|
||||
whatwg-encoding@1.0.5:
|
||||
resolution: {integrity: sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==}
|
||||
|
||||
@ -14061,6 +14067,8 @@ snapshots:
|
||||
|
||||
webpack-virtual-modules@0.6.2: {}
|
||||
|
||||
weixin-js-sdk@1.6.5: {}
|
||||
|
||||
whatwg-encoding@1.0.5:
|
||||
dependencies:
|
||||
iconv-lite: 0.4.24
|
||||
|
62
src/App.vue
62
src/App.vue
@ -1,39 +1,57 @@
|
||||
<script setup lang="ts">
|
||||
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
|
||||
import wx from 'weixin-js-sdk'
|
||||
import { usePageAuth } from '@/hooks/usePageAuth'
|
||||
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
|
||||
import { getInfoAPI, getShareParamsApi } from '@/service/crmeb/product.ts'
|
||||
import { useUserStore } from '@/store'
|
||||
import { getInfoAPI } from '@/service/crmeb/product.ts'
|
||||
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
|
||||
|
||||
usePageAuth()
|
||||
|
||||
onLaunch(() => {
|
||||
// 在main.js或App.vue中
|
||||
// uni.addInterceptor('switchTab', {
|
||||
// async invoke(args) {
|
||||
// console.log('拦截到tab切换', args.url)
|
||||
// // await useUserStore().getUserInfo
|
||||
// const res = await getInfoAPI()
|
||||
// },
|
||||
// fail(err) {
|
||||
// console.error(err)
|
||||
// },
|
||||
// })
|
||||
|
||||
console.log('App Launch')
|
||||
initWxShare()
|
||||
})
|
||||
onShow(async () => {
|
||||
// const res = await getInfoAPI()
|
||||
// if (!uni.getStorageSync('token')) {
|
||||
// uni.redirectTo({ url: '/pages/login/login' });
|
||||
// } else {
|
||||
// this.fetchData(); // 发起请求
|
||||
// }
|
||||
|
||||
console.log('App Show')
|
||||
})
|
||||
onHide(() => {
|
||||
console.log('App Hide')
|
||||
})
|
||||
async function initWxShare() {
|
||||
const url = 'https://h5.lihaink.cn'
|
||||
const res = await getShareParamsApi({ url })
|
||||
wx.config({
|
||||
debug: false,
|
||||
appId: res.data.appId,
|
||||
timestamp: res.data.timestamp,
|
||||
nonceStr: res.data.nonceStr,
|
||||
signature: res.data.signature,
|
||||
jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'],
|
||||
})
|
||||
wx.ready(() => {
|
||||
console.log('微信 JS-SDK 初始化成功')
|
||||
// 默认分享给好友
|
||||
wx.updateAppMessageShareData({
|
||||
title: '城市名片',
|
||||
desc: '城市名片',
|
||||
link: 'https://h5.lihaink.cn',
|
||||
imgUrl: 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/8f0f9202509111541209186.jpg',
|
||||
success: () => {
|
||||
console.log('分享好友配置成功')
|
||||
},
|
||||
})
|
||||
|
||||
// 默认分享到朋友圈
|
||||
wx.updateTimelineShareData({
|
||||
title: '城市名片',
|
||||
link: 'https://h5.lihaink.cn',
|
||||
imgUrl: 'https://lihai001.oss-cn-chengdu.aliyuncs.com/def/8f0f9202509111541209186.jpg',
|
||||
success: () => {
|
||||
console.log('分享朋友圈配置成功')
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
@ -10,6 +10,151 @@
|
||||
}
|
||||
</route>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
// import { toLogin } from '@/libs/login.js'
|
||||
import { getBannerAPI, getProductAPI } from '@/service/crmeb/product.ts'
|
||||
|
||||
import {
|
||||
getArticleCategoryAPI,
|
||||
getArticleDetailAPI,
|
||||
getArticleIndexAPI,
|
||||
} from '@/service/crmeb/product.ts'
|
||||
import {
|
||||
getEnvBaseUrl,
|
||||
getShopWebUrl,
|
||||
getUrl,
|
||||
getUrlCrmeb,
|
||||
getUrlCrmebProxy,
|
||||
getWebUrl,
|
||||
hasLogin,
|
||||
} from '@/utils'
|
||||
|
||||
export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
show: false,
|
||||
product_30: {},
|
||||
swiperList: [],
|
||||
index_eat: {},
|
||||
index_live: {},
|
||||
index_play: {},
|
||||
index_purchase: {},
|
||||
eat_id: 1,
|
||||
live_id: 7,
|
||||
play_id: 8,
|
||||
purchase_id: 6,
|
||||
|
||||
current_item: {},
|
||||
currentTab: 1,
|
||||
city: '',
|
||||
title: '',
|
||||
}
|
||||
},
|
||||
async onLoad(option) {
|
||||
this.getBanner()
|
||||
this.getProduct(1)
|
||||
this.getArticle()
|
||||
},
|
||||
methods: {
|
||||
handleClick(e) {
|
||||
console.log(e.item)
|
||||
// 连接为空不跳转
|
||||
if (e.item.link) {
|
||||
// 如果是村集体域名,就跳转内页
|
||||
if (e.item.link.startsWith(getUrlCrmeb())) {
|
||||
let new_url = e.item.link.replace(getUrlCrmeb(), '/')
|
||||
|
||||
var new_data = { type: 2, url: new_url }
|
||||
} else {
|
||||
var new_data = { type: 1, url: e.item.link }
|
||||
}
|
||||
console.log(new_data)
|
||||
this.more(new_data)
|
||||
}
|
||||
},
|
||||
async getBanner() {
|
||||
const res = await getBannerAPI([])
|
||||
// 使用正确的 map 方法返回新数组
|
||||
this.swiperList = res.data.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
url: item.image,
|
||||
}
|
||||
})
|
||||
this.city = this.swiperList[0].city
|
||||
this.title = this.swiperList[0].title
|
||||
},
|
||||
async getProduct(id) {
|
||||
const res = await getProductAPI(id)
|
||||
this.product_30 = res.data.list
|
||||
// console.log(product_30.value)
|
||||
},
|
||||
|
||||
onChange(e) {
|
||||
// // console.log(e)
|
||||
// this.city = this.swiperList[e.current].city
|
||||
// this.title = this.swiperList[e.current].title
|
||||
},
|
||||
|
||||
changeTab(e) {
|
||||
// console.log(e)
|
||||
this.current_item = e
|
||||
},
|
||||
|
||||
async getArticle() {
|
||||
this.index_eat = await this.getIndex(this.eat_id)
|
||||
this.current_item = this.index_eat[0] || {}
|
||||
this.index_live = await this.getIndex(this.live_id)
|
||||
|
||||
this.index_play = await this.getIndex(this.play_id)
|
||||
this.index_purchase = await this.getIndex(this.purchase_id)
|
||||
},
|
||||
async getIndex(category_id) {
|
||||
const res = await getArticleIndexAPI({ category_id })
|
||||
return res.data
|
||||
},
|
||||
goPage(item) {
|
||||
getUrl(`/pages/about/detail?id=${item.id}`)
|
||||
},
|
||||
moreVillage() {
|
||||
console.log('查看乡村')
|
||||
uni.navigateTo({
|
||||
url: '/pages-village-sub/home/index',
|
||||
})
|
||||
},
|
||||
|
||||
moreTourism() {
|
||||
console.log('查看旅游')
|
||||
uni.navigateTo({
|
||||
url: '/pages-tourism-sub/home/index',
|
||||
})
|
||||
},
|
||||
|
||||
switchTab(index) {
|
||||
uni.switchTab({
|
||||
url: `/pages/about/index?category_id=${index}`,
|
||||
})
|
||||
},
|
||||
async more(item) {
|
||||
const islogin = await hasLogin()
|
||||
if (islogin === true) {
|
||||
if (item.type == 1) {
|
||||
getUrl(item.url)
|
||||
} else if (item.type == 2) {
|
||||
// await hasLogin()
|
||||
getWebUrl(item.url)
|
||||
} else if (item.type == 3) {
|
||||
// await hasLogin()
|
||||
getShopWebUrl(item.url)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="">
|
||||
<view class="background_home">
|
||||
@ -27,7 +172,7 @@
|
||||
:indicator="{ type: 'dots-bar' }"
|
||||
@change="onChange"
|
||||
@click="handleClick"
|
||||
></wd-swiper>
|
||||
/>
|
||||
</view>
|
||||
<!-- <view
|
||||
class="m-2 p-2 absolute bottom-0 text-center left-0 right-0 text-white bg-black bg-opacity-40"
|
||||
@ -46,7 +191,6 @@
|
||||
<wd-card>
|
||||
<wd-grid :gutter="2" :column="5">
|
||||
<view
|
||||
@click="more(item)"
|
||||
v-for="item in [
|
||||
{
|
||||
name: '名优特产',
|
||||
@ -84,11 +228,12 @@
|
||||
color: 'red',
|
||||
},
|
||||
]"
|
||||
@click="more(item)"
|
||||
>
|
||||
<wd-grid-item use-slot>
|
||||
<view class="p-2 pt-4">
|
||||
<wd-img radius="20rpx" :width="'60rpx'" :height="'60rpx'" :src="item.icon" />
|
||||
<view class="py-2 text-center font-size-3 font-blod color-black">
|
||||
<wd-img radius="20rpx" width="60rpx" height="60rpx" :src="item.icon" />
|
||||
<view class="font-blod py-2 text-center font-size-3 color-black">
|
||||
{{ item.name }}
|
||||
</view>
|
||||
</view>
|
||||
@ -104,8 +249,8 @@
|
||||
<template #title>
|
||||
<view class="title">
|
||||
<view>
|
||||
<text class="text-xl text-sm font-size-5 font-bold color-black">当季产品</text>
|
||||
<text class="ps-2 text-xl text-sm font-size-3 color-gary">
|
||||
<text class="text-sm text-xl font-size-5 color-black font-bold">当季产品</text>
|
||||
<text class="color-gary ps-2 text-sm text-xl font-size-3">
|
||||
好物上新季,特产抢先购
|
||||
</text>
|
||||
</view>
|
||||
@ -119,7 +264,7 @@
|
||||
})
|
||||
"
|
||||
>
|
||||
<wd-text text="更多" bold color="#4AC242FF" size="28rpx"></wd-text>
|
||||
<wd-text text="更多" bold color="#4AC242FF" size="28rpx" />
|
||||
</wd-button>
|
||||
</view>
|
||||
</template>
|
||||
@ -128,6 +273,7 @@
|
||||
<view class="p-1">
|
||||
<scroll-view scroll-x="true" class="scroll-view-container">
|
||||
<view
|
||||
v-for="item in product_30"
|
||||
class="p-1"
|
||||
style="display: inline-block; width: 300rpx"
|
||||
@click="
|
||||
@ -136,29 +282,28 @@
|
||||
url: `/pages/goods_details/index?id=${item.product_id}`,
|
||||
})
|
||||
"
|
||||
v-for="item in product_30"
|
||||
>
|
||||
<view class="py-2">
|
||||
<wd-card custom-class="card-content">
|
||||
<view style="height: 300rpx; width: 300rpx">
|
||||
<wd-img
|
||||
radius="20rpx"
|
||||
:width="'100%'"
|
||||
:height="'100%'"
|
||||
width="100%"
|
||||
height="100%"
|
||||
mode="aspectFill"
|
||||
:src="item.image"
|
||||
/>
|
||||
</view>
|
||||
<view>
|
||||
<view class="ps-2 pt-2 font-size-5 font-bold color-black ellipsis">
|
||||
<view class="ellipsis ps-2 pt-2 font-size-5 color-black font-bold">
|
||||
{{ item.store_name }}
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view>
|
||||
<view class="ps-2 pt-1 font-size-3 ellipsis">{{ item.store_info }}</view>
|
||||
</view> -->
|
||||
<view class="ps-2 pb-2">
|
||||
<view class="text-sm text-gray-500 text-left">
|
||||
<view class="pb-2 ps-2">
|
||||
<view class="text-left text-sm text-gray-500">
|
||||
<wd-text size="32rpx" color="red" :text="item.price" mode="price" prefix="¥" />
|
||||
<!-- <wd-text size="20rpx" color="red" text="券后价" mode="text" prefix=" " />
|
||||
<wd-text
|
||||
@ -182,11 +327,11 @@
|
||||
<template #title>
|
||||
<view class="title">
|
||||
<view>
|
||||
<text class="text-xl text-sm font-size-5 font-bold color-black">美丽乡村</text>
|
||||
<text class="ps-2 text-xl text-sm font-size-3 color-gary">美丽乡村风貌展示厅</text>
|
||||
<text class="text-sm text-xl font-size-5 color-black font-bold">美丽乡村</text>
|
||||
<text class="color-gary ps-2 text-sm text-xl font-size-3">美丽乡村风貌展示厅</text>
|
||||
</view>
|
||||
<wd-button type="success" size="small" @click="switchTab(eat_id)">
|
||||
<wd-text text="更多" bold color="#4AC242FF" size="28rpx"></wd-text>
|
||||
<wd-text text="更多" bold color="#4AC242FF" size="28rpx" />
|
||||
</wd-button>
|
||||
</view>
|
||||
</template>
|
||||
@ -197,15 +342,15 @@
|
||||
<view class=" " style="">
|
||||
<wd-card custom-class="card-content">
|
||||
<view class="relative" style="height: 380rpx" @click="goPage(current_item)">
|
||||
<wd-img radius="20rpx" :width="'100%'" :height="'100%'" :src="current_item.cover" />
|
||||
<wd-img radius="20rpx" width="100%" height="100%" :src="current_item.cover" />
|
||||
<view
|
||||
class="m-2 p-2 absolute bottom-0 text-center left-0 right-0 text-white bg-gray-300 bg-opacity-5"
|
||||
class="absolute bottom-0 left-0 right-0 m-2 bg-gray-300 bg-opacity-5 p-2 text-center text-white"
|
||||
style="backdrop-filter: blur(2rpx); border-radius: 10rpx"
|
||||
>
|
||||
<text class="block font-size-5 text-left ellipsis-2">
|
||||
<text class="ellipsis-2 block text-left font-size-5">
|
||||
{{ current_item.title }}
|
||||
</text>
|
||||
<view class="font-size-3 text-left ellipsis-2">
|
||||
<view class="ellipsis-2 text-left font-size-3">
|
||||
{{ current_item.description }}
|
||||
</view>
|
||||
</view>
|
||||
@ -220,8 +365,8 @@
|
||||
v-for="item in index_eat"
|
||||
:type="item.id === currentTab ? 'primary' : 'warning'"
|
||||
size="large"
|
||||
@click="changeTab(item)"
|
||||
:custom-style="`background-image: url('${item.cover}'); background-size: cover;border-radius: 10rpx;`"
|
||||
@click="changeTab(item)"
|
||||
>
|
||||
{{ item.title }}
|
||||
</wd-button>
|
||||
@ -233,11 +378,11 @@
|
||||
<template #title>
|
||||
<view class="title">
|
||||
<view>
|
||||
<text class="text-xl text-sm font-size-5 font-bold color-black">特产好物</text>
|
||||
<text class="ps-2 text-xl text-sm font-size-3 color-gary">精选好物,不容错过</text>
|
||||
<text class="text-sm text-xl font-size-5 color-black font-bold">特产好物</text>
|
||||
<text class="color-gary ps-2 text-sm text-xl font-size-3">精选好物,不容错过</text>
|
||||
</view>
|
||||
<wd-button type="success" size="small" @click="switchTab(live_id)">
|
||||
<wd-text text="更多" bold color="#4AC242FF" size="28rpx"></wd-text>
|
||||
<wd-text text="更多" bold color="#4AC242FF" size="28rpx" />
|
||||
</wd-button>
|
||||
</view>
|
||||
</template>
|
||||
@ -245,26 +390,26 @@
|
||||
</view>
|
||||
<view class="p-1">
|
||||
<wd-row class=" ">
|
||||
<wd-col :span="12" v-for="(item, index) in index_live">
|
||||
<view class="p-1" style="" @click="goPage(item)" v-if="index < 4">
|
||||
<wd-col v-for="(item, index) in index_live" :span="12">
|
||||
<view v-if="index < 4" class="p-1" style="" @click="goPage(item)">
|
||||
<view class="py-2">
|
||||
<wd-card custom-class="card-content">
|
||||
<view style="height: 300rpx">
|
||||
<wd-img
|
||||
radius="20rpx"
|
||||
:width="'100%'"
|
||||
width="100%"
|
||||
mode="widthFix"
|
||||
:height="'100%'"
|
||||
height="100%"
|
||||
:src="item.cover"
|
||||
/>
|
||||
</view>
|
||||
<view class="ps-2 pt-2 font-size-5 font-bold color-black ellipsis">
|
||||
<view class="ellipsis ps-2 pt-2 font-size-5 color-black font-bold">
|
||||
{{ item.title }}
|
||||
</view>
|
||||
<view class="ps-2 pt-2 font-size-3 ellipsis">
|
||||
<view class="ellipsis ps-2 pt-2 font-size-3">
|
||||
{{ item.description }}
|
||||
</view>
|
||||
<view class="ps-2 pt-2 pb-2"></view>
|
||||
<view class="pb-2 ps-2 pt-2" />
|
||||
</wd-card>
|
||||
</view>
|
||||
</view>
|
||||
@ -277,13 +422,13 @@
|
||||
<template #title>
|
||||
<view class="title">
|
||||
<view>
|
||||
<text class="text-xl text-sm font-size-5 font-bold color-black">热门咨询</text>
|
||||
<text class="ps-2 text-xl text-sm font-size-3 color-gary">
|
||||
<text class="text-sm text-xl font-size-5 color-black font-bold">热门咨询</text>
|
||||
<text class="color-gary ps-2 text-sm text-xl font-size-3">
|
||||
热门咨询,一键掌握新鲜事
|
||||
</text>
|
||||
</view>
|
||||
<wd-button type="success" size="small" @click="switchTab(play_id)">
|
||||
<wd-text text="更多" bold color="#4AC242FF" size="28rpx"></wd-text>
|
||||
<wd-text text="更多" bold color="#4AC242FF" size="28rpx" />
|
||||
</wd-button>
|
||||
</view>
|
||||
</template>
|
||||
@ -291,26 +436,28 @@
|
||||
</view>
|
||||
|
||||
<view class="p-2">
|
||||
<view class="py-2" v-for="(item, index) in index_play" @click="goPage(item)">
|
||||
<view v-for="(item, index) in index_play" class="py-2" @click="goPage(item)">
|
||||
<view v-if="index < 4">
|
||||
<wd-card custom-class="card-content">
|
||||
<view class="content p-2" style="align-items: normal">
|
||||
<view style="width: 280rpx; height: 200rpx">
|
||||
<wd-img
|
||||
:width="'100%'"
|
||||
:height="'100%'"
|
||||
width="100%"
|
||||
height="100%"
|
||||
radius="20rpx"
|
||||
mode="aspectFill"
|
||||
:src="item.cover"
|
||||
alt="joy"
|
||||
/>
|
||||
</view>
|
||||
<view class="ps-2 flex-content-column">
|
||||
<view class="ps-1 font-size-3 font-bold ellipsis-2 color-black">
|
||||
<view class="flex-content-column ps-2">
|
||||
<view class="ellipsis-2 ps-1 font-size-3 color-black font-bold">
|
||||
{{ item.title }}
|
||||
</view>
|
||||
<view class="px-1 font-size-3 ellipsis-2 color-gary">{{ item.description }}</view>
|
||||
<view class="p-1 font-size-3 color-gary" style="align-items: end">
|
||||
<view class="ellipsis-2 color-gary px-1 font-size-3">
|
||||
{{ item.description }}
|
||||
</view>
|
||||
<view class="color-gary p-1 font-size-3" style="align-items: end">
|
||||
<text class="pe-2 font-size-3">2025-8-23</text>
|
||||
<!-- <wd-tag custom-class="space font-size-3" type="danger" round>
|
||||
{{ item.category_name }}
|
||||
@ -328,11 +475,11 @@
|
||||
<template #title>
|
||||
<view class="title">
|
||||
<view>
|
||||
<text class="text-xl text-sm font-size-5 font-bold color-black">景区旅游</text>
|
||||
<text class="ps-2 text-xl text-sm font-size-3 color-gary">好玩儿路线一网打尽</text>
|
||||
<text class="text-sm text-xl font-size-5 color-black font-bold">景区旅游</text>
|
||||
<text class="color-gary ps-2 text-sm text-xl font-size-3">好玩儿路线一网打尽</text>
|
||||
</view>
|
||||
<wd-button type="success" size="small" @click="switchTab(purchase_id)">
|
||||
<wd-text text="更多" bold color="#4AC242FF" size="28rpx"></wd-text>
|
||||
<wd-text text="更多" bold color="#4AC242FF" size="28rpx" />
|
||||
</wd-button>
|
||||
</view>
|
||||
</template>
|
||||
@ -365,11 +512,11 @@
|
||||
</wd-row>
|
||||
</view> -->
|
||||
|
||||
<view class="p-2" v-for="(item, index) in index_purchase">
|
||||
<view class="" style="" @click="goPage(item)" v-if="index < 4">
|
||||
<view v-for="(item, index) in index_purchase" class="p-2">
|
||||
<view v-if="index < 4" class="" style="" @click="goPage(item)">
|
||||
<wd-card custom-class="card-content">
|
||||
<view class="relative" style="height: 360rpx">
|
||||
<wd-img radius="20rpx" :width="'100%'" :height="'100%'" :src="item.cover" />
|
||||
<wd-img radius="20rpx" width="100%" height="100%" :src="item.cover" />
|
||||
<!-- <view style="position: absolute; top: -20rpx; right: 40rpx">
|
||||
<wd-img
|
||||
:width="'120rpx'"
|
||||
@ -397,11 +544,13 @@
|
||||
</view> -->
|
||||
|
||||
<view
|
||||
class="m-4 p-2 absolute bottom-0 text-center left-0 right-0 text-white bg-gray-300 bg-opacity-20"
|
||||
class="absolute bottom-0 left-0 right-0 m-4 bg-gray-300 bg-opacity-20 p-2 text-center text-white"
|
||||
style="backdrop-filter: blur(1px); border-radius: 10rpx"
|
||||
>
|
||||
<text class="block font-size-5 text-left ellipsis">{{ item.title }}</text>
|
||||
<text class="font-size-3 text-left ellipsis-2">
|
||||
<text class="ellipsis block text-left font-size-5">
|
||||
{{ item.title }}
|
||||
</text>
|
||||
<text class="ellipsis-2 text-left font-size-3">
|
||||
{{ item.description }}
|
||||
</text>
|
||||
</view>
|
||||
@ -411,149 +560,10 @@
|
||||
</view>
|
||||
|
||||
<fly-login v-model="show" />
|
||||
<view class="p-1"></view>
|
||||
<view class="p-1" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
// import { toLogin } from '@/libs/login.js'
|
||||
import { getProductAPI, getBannerAPI } from '@/service/crmeb/product.ts'
|
||||
|
||||
import { getUrl, getWebUrl, getShopWebUrl, hasLogin } from '@/utils'
|
||||
|
||||
import { getEnvBaseUrl, getUrlCrmeb, getUrlCrmebProxy } from '@/utils'
|
||||
import {
|
||||
getArticleCategoryAPI,
|
||||
getArticleIndexAPI,
|
||||
getArticleDetailAPI,
|
||||
} from '@/service/crmeb/product.ts'
|
||||
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
show: false,
|
||||
product_30: {},
|
||||
swiperList: [],
|
||||
index_eat: {},
|
||||
index_live: {},
|
||||
index_play: {},
|
||||
index_purchase: {},
|
||||
eat_id: 1,
|
||||
live_id: 7,
|
||||
play_id: 8,
|
||||
purchase_id: 6,
|
||||
|
||||
current_item: {},
|
||||
currentTab: 1,
|
||||
city: '',
|
||||
title: '',
|
||||
}
|
||||
},
|
||||
async onLoad(option) {
|
||||
this.getBanner()
|
||||
this.getProduct(1)
|
||||
this.getArticle()
|
||||
},
|
||||
methods: {
|
||||
handleClick(e) {
|
||||
console.log(e.item)
|
||||
//连接为空不跳转
|
||||
if (e.item.link) {
|
||||
//如果是村集体域名,就跳转内页
|
||||
if (e.item.link.startsWith(getUrlCrmeb())) {
|
||||
var new_url = e.item.link.replace(getUrlCrmeb(), '/')
|
||||
|
||||
var new_data = { type: 2, url: new_url }
|
||||
} else {
|
||||
var new_data = { type: 1, url: e.item.link }
|
||||
}
|
||||
console.log(new_data)
|
||||
this.more(new_data)
|
||||
}
|
||||
},
|
||||
async getBanner() {
|
||||
const res = await getBannerAPI([])
|
||||
// 使用正确的 map 方法返回新数组
|
||||
this.swiperList = res.data.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
url: item.image,
|
||||
}
|
||||
})
|
||||
this.city = this.swiperList[0].city
|
||||
this.title = this.swiperList[0].title
|
||||
},
|
||||
async getProduct(id) {
|
||||
const res = await getProductAPI(id)
|
||||
this.product_30 = res.data['list']
|
||||
// console.log(product_30.value)
|
||||
},
|
||||
|
||||
onChange(e) {
|
||||
// // console.log(e)
|
||||
// this.city = this.swiperList[e.current].city
|
||||
// this.title = this.swiperList[e.current].title
|
||||
},
|
||||
|
||||
changeTab(e) {
|
||||
// console.log(e)
|
||||
this.current_item = e
|
||||
},
|
||||
|
||||
async getArticle() {
|
||||
this.index_eat = await this.getIndex(this.eat_id)
|
||||
this.current_item = this.index_eat[0] || {}
|
||||
this.index_live = await this.getIndex(this.live_id)
|
||||
|
||||
this.index_play = await this.getIndex(this.play_id)
|
||||
this.index_purchase = await this.getIndex(this.purchase_id)
|
||||
},
|
||||
async getIndex(category_id) {
|
||||
const res = await getArticleIndexAPI({ category_id: category_id })
|
||||
return res.data
|
||||
},
|
||||
goPage(item) {
|
||||
getUrl('/pages/about/detail?id=' + item.id)
|
||||
},
|
||||
moreVillage() {
|
||||
console.log('查看乡村')
|
||||
uni.navigateTo({
|
||||
url: '/pages-village-sub/home/index',
|
||||
})
|
||||
},
|
||||
|
||||
moreTourism() {
|
||||
console.log('查看旅游')
|
||||
uni.navigateTo({
|
||||
url: '/pages-tourism-sub/home/index',
|
||||
})
|
||||
},
|
||||
|
||||
switchTab(index) {
|
||||
uni.switchTab({
|
||||
url: '/pages/about/index?category_id=' + index,
|
||||
})
|
||||
},
|
||||
async more(item) {
|
||||
const islogin = await hasLogin()
|
||||
if (islogin === true) {
|
||||
if (item.type == 1) {
|
||||
getUrl(item.url)
|
||||
} else if (item.type == 2) {
|
||||
// await hasLogin()
|
||||
getWebUrl(item.url)
|
||||
} else if (item.type == 3) {
|
||||
// await hasLogin()
|
||||
getShopWebUrl(item.url)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.section {
|
||||
width: 100%;
|
||||
|
@ -126,3 +126,7 @@ export function getCodeAPI(data: any) {
|
||||
export function bindPhoneApi(data: any) {
|
||||
return http.post('/api/user/checkPhone', data)
|
||||
}
|
||||
|
||||
export function getShareParamsApi(data: any) {
|
||||
return http.get('/api/index/getShareParams', data)
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { pages, subPackages } from '@/pages.json'
|
||||
import { isMpWeixin } from './platform'
|
||||
import { getInfoAPI } from '@/service/crmeb/product.ts'
|
||||
import { useUserStore } from '@/store'
|
||||
import { http } from '@/utils/http'
|
||||
import { isMpWeixin } from './platform'
|
||||
|
||||
export function getLastPage() {
|
||||
// getCurrentPages() 至少有1个元素,所以不再额外判断
|
||||
// const lastPage = getCurrentPages().at(-1)
|
||||
@ -170,7 +172,7 @@ export function getUrlCrmebLogin() {
|
||||
let baseUrl = import.meta.env.VITE_CRMEB_SERVER_BASEURL_LOGIN
|
||||
return baseUrl
|
||||
} else {
|
||||
let baseUrl = import.meta.env.VITE_CRMEB_SERVER_BASEURL
|
||||
let baseUrl = import.meta.env.VITE_CRMEB_SERVER_BASEURL_LOGIN
|
||||
return baseUrl
|
||||
}
|
||||
}
|
||||
@ -192,81 +194,56 @@ export function getUrlCrmebProxy() {
|
||||
return baseUrl
|
||||
}
|
||||
|
||||
//模块跳转
|
||||
// 模块跳转
|
||||
export function getUrl(url) {
|
||||
console.log('c123', url)
|
||||
return uni.navigateTo({
|
||||
url: url,
|
||||
url,
|
||||
})
|
||||
}
|
||||
|
||||
// 代登录跳转
|
||||
export function getWebUrl(url) {
|
||||
console.log('传递参数', url)
|
||||
const target = encodeURIComponent(url)
|
||||
return uni.navigateTo({
|
||||
url: `/pages/web_view/index?target=${target}`,
|
||||
})
|
||||
export function getWebUrl(target) {
|
||||
target = encodeURIComponent(target)
|
||||
const userId = computed(() => useUserStore().userInfo?.id)
|
||||
const village_id = computed(() => useUserStore().userInfo?.village_id)
|
||||
const url = `${getUrlCrmebLogin()}?target=${target}&user_id=${userId.value}&village_id=${village_id.value}`
|
||||
window.open(url, '_self')
|
||||
// 微信小程序使用webview
|
||||
// const target = encodeURIComponent(url)
|
||||
// return uni.navigateTo({
|
||||
// url: `/pages/web_view/index?target=${target}`,
|
||||
// })
|
||||
}
|
||||
|
||||
// 代登录跳转
|
||||
export function getShopWebUrl(url) {
|
||||
console.log('传递参数', url)
|
||||
const target = encodeURIComponent(url)
|
||||
return uni.navigateTo({
|
||||
url: `/pages/web_view/h5?target=${target}`,
|
||||
})
|
||||
export function getShopWebUrl(target) {
|
||||
target = encodeURIComponent(target)
|
||||
const userId = computed(() => useUserStore().userInfo?.id)
|
||||
const village_id = computed(() => useUserStore().userInfo?.village_id)
|
||||
const url = `${getUrlCrmebLogin()}?target=${target}&user_id=${userId.value}&village_id=${village_id.value}`
|
||||
window.open(url, '_self')
|
||||
// 微信小程序使用webview
|
||||
// const target = encodeURIComponent(url)
|
||||
// return uni.navigateTo({
|
||||
// url: `/pages/web_view/h5?target=${target}`,
|
||||
// })
|
||||
}
|
||||
import { useUserStore } from '@/store'
|
||||
// const userStore = useUserStore()
|
||||
// 代登录跳转
|
||||
export async function hasLogin() {
|
||||
const res = await getInfoAPI()
|
||||
// const res = await http.get('/api/user/info', {})
|
||||
// console.log('hasLogin', res)
|
||||
console.log('hasLogin', res.data)
|
||||
console.log('village_id', useUserStore().userInfo.village_id)
|
||||
if (res.code === 401) {
|
||||
const hasLogin = false
|
||||
//强制跳转设置村庄
|
||||
|
||||
if (hasLogin && useUserStore().userInfo.village_id === 0) {
|
||||
// if (!this.phone) {
|
||||
// uni.showToast({
|
||||
// title: '请填写手机号',
|
||||
// icon: 'none',
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
uni.showModal({
|
||||
title: '温馨提示',
|
||||
content: ' 您尚未完善个人信息,是否前往设置你的个人地址?',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/my/setting?type=1',
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
//返回是否登录
|
||||
return hasLogin
|
||||
return false
|
||||
} else {
|
||||
const hasLogin = true
|
||||
//强制跳转设置村庄
|
||||
if (hasLogin && useUserStore().userInfo.village_id === 0) {
|
||||
// if (!this.phone) {
|
||||
// uni.showToast({
|
||||
// title: '请填写手机号',
|
||||
// icon: 'none',
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
if (res.data.village === 0 || res.data.village === null || res.data.village === '') {
|
||||
uni.showModal({
|
||||
title: '温馨提示',
|
||||
content: ' 您尚未完善个人信息,是否前往设置你的个人地址?',
|
||||
success: function (res) {
|
||||
content: ' 您尚未完善个人信息,是否前往设置个人地址?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/my/setting?type=1',
|
||||
@ -276,7 +253,20 @@ export async function hasLogin() {
|
||||
})
|
||||
return
|
||||
}
|
||||
//返回是否登录
|
||||
return hasLogin
|
||||
if (res.data.phone === 0 || res.data.phone === null || res.data.phone === '') {
|
||||
uni.showModal({
|
||||
title: '温馨提示',
|
||||
content: ' 您尚未完善个人信息,是否前往设置手机号?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/my/setting?type=1',
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user