添加分享配置
Some checks are pending
Auto Merge Main to Other Branches / Merge main into i18n (push) Waiting to run
Auto Merge Main to Other Branches / Merge main into base-sard-ui (push) Waiting to run

This commit is contained in:
lewis 2025-09-11 16:03:03 +08:00
parent 4a3c488019
commit c1ffa7606b
6 changed files with 302 additions and 271 deletions

View File

@ -3,7 +3,7 @@
"type": "commonjs", "type": "commonjs",
"version": "3.0.0", "version": "3.0.0",
"description": "unibest - 最好的 uniapp 开发模板", "description": "unibest - 最好的 uniapp 开发模板",
"update-time": "2025-09-08", "update-time": "2025-09-11",
"author": { "author": {
"name": "feige996", "name": "feige996",
"zhName": "菲鸽", "zhName": "菲鸽",
@ -104,6 +104,7 @@
"qs": "6.5.3", "qs": "6.5.3",
"uview-ui": "2.0.38", "uview-ui": "2.0.38",
"vue": "^3.4.21", "vue": "^3.4.21",
"weixin-js-sdk": "^1.6.5",
"wot-design-uni": "^1.9.1", "wot-design-uni": "^1.9.1",
"z-paging": "2.8.7" "z-paging": "2.8.7"
}, },

8
pnpm-lock.yaml generated
View File

@ -100,6 +100,9 @@ importers:
vue: vue:
specifier: ^3.4.21 specifier: ^3.4.21
version: 3.5.15(typescript@5.7.2) version: 3.5.15(typescript@5.7.2)
weixin-js-sdk:
specifier: ^1.6.5
version: 1.6.5
wot-design-uni: wot-design-uni:
specifier: ^1.9.1 specifier: ^1.9.1
version: 1.9.1(vue@3.5.15(typescript@5.7.2)) version: 1.9.1(vue@3.5.15(typescript@5.7.2))
@ -6252,6 +6255,9 @@ packages:
webpack-virtual-modules@0.6.2: webpack-virtual-modules@0.6.2:
resolution: {integrity: sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==} 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: whatwg-encoding@1.0.5:
resolution: {integrity: sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==} resolution: {integrity: sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==}
@ -14061,6 +14067,8 @@ snapshots:
webpack-virtual-modules@0.6.2: {} webpack-virtual-modules@0.6.2: {}
weixin-js-sdk@1.6.5: {}
whatwg-encoding@1.0.5: whatwg-encoding@1.0.5:
dependencies: dependencies:
iconv-lite: 0.4.24 iconv-lite: 0.4.24

View File

@ -1,39 +1,57 @@
<script setup lang="ts"> <script setup lang="ts">
import { onHide, onLaunch, onShow } from '@dcloudio/uni-app' import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
import wx from 'weixin-js-sdk'
import { usePageAuth } from '@/hooks/usePageAuth' 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 { useUserStore } from '@/store'
import { getInfoAPI } from '@/service/crmeb/product.ts' import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
usePageAuth() usePageAuth()
onLaunch(() => { onLaunch(() => {
// main.jsApp.vue initWxShare()
// 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')
}) })
onShow(async () => { onShow(async () => {
// const res = await getInfoAPI()
// if (!uni.getStorageSync('token')) {
// uni.redirectTo({ url: '/pages/login/login' });
// } else {
// this.fetchData(); //
// }
console.log('App Show') console.log('App Show')
}) })
onHide(() => { onHide(() => {
console.log('App Hide') 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> </script>
<style lang="scss"> <style lang="scss">

View File

@ -10,6 +10,151 @@
} }
</route> </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> <template>
<view class=""> <view class="">
<view class="background_home"> <view class="background_home">
@ -27,7 +172,7 @@
:indicator="{ type: 'dots-bar' }" :indicator="{ type: 'dots-bar' }"
@change="onChange" @change="onChange"
@click="handleClick" @click="handleClick"
></wd-swiper> />
</view> </view>
<!-- <view <!-- <view
class="m-2 p-2 absolute bottom-0 text-center left-0 right-0 text-white bg-black bg-opacity-40" 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-card>
<wd-grid :gutter="2" :column="5"> <wd-grid :gutter="2" :column="5">
<view <view
@click="more(item)"
v-for="item in [ v-for="item in [
{ {
name: '名优特产', name: '名优特产',
@ -84,11 +228,12 @@
color: 'red', color: 'red',
}, },
]" ]"
@click="more(item)"
> >
<wd-grid-item use-slot> <wd-grid-item use-slot>
<view class="p-2 pt-4"> <view class="p-2 pt-4">
<wd-img radius="20rpx" :width="'60rpx'" :height="'60rpx'" :src="item.icon" /> <wd-img radius="20rpx" width="60rpx" height="60rpx" :src="item.icon" />
<view class="py-2 text-center font-size-3 font-blod color-black"> <view class="font-blod py-2 text-center font-size-3 color-black">
{{ item.name }} {{ item.name }}
</view> </view>
</view> </view>
@ -104,8 +249,8 @@
<template #title> <template #title>
<view class="title"> <view class="title">
<view> <view>
<text class="text-xl text-sm font-size-5 font-bold color-black">当季产品</text> <text class="text-sm text-xl font-size-5 color-black font-bold">当季产品</text>
<text class="ps-2 text-xl text-sm font-size-3 color-gary"> <text class="color-gary ps-2 text-sm text-xl font-size-3">
好物上新季特产抢先购 好物上新季特产抢先购
</text> </text>
</view> </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> </wd-button>
</view> </view>
</template> </template>
@ -128,6 +273,7 @@
<view class="p-1"> <view class="p-1">
<scroll-view scroll-x="true" class="scroll-view-container"> <scroll-view scroll-x="true" class="scroll-view-container">
<view <view
v-for="item in product_30"
class="p-1" class="p-1"
style="display: inline-block; width: 300rpx" style="display: inline-block; width: 300rpx"
@click=" @click="
@ -136,29 +282,28 @@
url: `/pages/goods_details/index?id=${item.product_id}`, url: `/pages/goods_details/index?id=${item.product_id}`,
}) })
" "
v-for="item in product_30"
> >
<view class="py-2"> <view class="py-2">
<wd-card custom-class="card-content"> <wd-card custom-class="card-content">
<view style="height: 300rpx; width: 300rpx"> <view style="height: 300rpx; width: 300rpx">
<wd-img <wd-img
radius="20rpx" radius="20rpx"
:width="'100%'" width="100%"
:height="'100%'" height="100%"
mode="aspectFill" mode="aspectFill"
:src="item.image" :src="item.image"
/> />
</view> </view>
<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 }} {{ item.store_name }}
</view> </view>
</view> </view>
<!-- <view> <!-- <view>
<view class="ps-2 pt-1 font-size-3 ellipsis">{{ item.store_info }}</view> <view class="ps-2 pt-1 font-size-3 ellipsis">{{ item.store_info }}</view>
</view> --> </view> -->
<view class="ps-2 pb-2"> <view class="pb-2 ps-2">
<view class="text-sm text-gray-500 text-left"> <view class="text-left text-sm text-gray-500">
<wd-text size="32rpx" color="red" :text="item.price" mode="price" prefix="¥" /> <wd-text size="32rpx" color="red" :text="item.price" mode="price" prefix="¥" />
<!-- <wd-text size="20rpx" color="red" text="券后价" mode="text" prefix=" " /> <!-- <wd-text size="20rpx" color="red" text="券后价" mode="text" prefix=" " />
<wd-text <wd-text
@ -182,11 +327,11 @@
<template #title> <template #title>
<view class="title"> <view class="title">
<view> <view>
<text class="text-xl text-sm font-size-5 font-bold color-black">美丽乡村</text> <text class="text-sm text-xl font-size-5 color-black font-bold">美丽乡村</text>
<text class="ps-2 text-xl text-sm font-size-3 color-gary">美丽乡村风貌展示厅</text> <text class="color-gary ps-2 text-sm text-xl font-size-3">美丽乡村风貌展示厅</text>
</view> </view>
<wd-button type="success" size="small" @click="switchTab(eat_id)"> <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> </wd-button>
</view> </view>
</template> </template>
@ -197,15 +342,15 @@
<view class=" " style=""> <view class=" " style="">
<wd-card custom-class="card-content"> <wd-card custom-class="card-content">
<view class="relative" style="height: 380rpx" @click="goPage(current_item)"> <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 <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" 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 }} {{ current_item.title }}
</text> </text>
<view class="font-size-3 text-left ellipsis-2"> <view class="ellipsis-2 text-left font-size-3">
{{ current_item.description }} {{ current_item.description }}
</view> </view>
</view> </view>
@ -220,8 +365,8 @@
v-for="item in index_eat" v-for="item in index_eat"
:type="item.id === currentTab ? 'primary' : 'warning'" :type="item.id === currentTab ? 'primary' : 'warning'"
size="large" size="large"
@click="changeTab(item)"
:custom-style="`background-image: url('${item.cover}'); background-size: cover;border-radius: 10rpx;`" :custom-style="`background-image: url('${item.cover}'); background-size: cover;border-radius: 10rpx;`"
@click="changeTab(item)"
> >
{{ item.title }} {{ item.title }}
</wd-button> </wd-button>
@ -233,11 +378,11 @@
<template #title> <template #title>
<view class="title"> <view class="title">
<view> <view>
<text class="text-xl text-sm font-size-5 font-bold color-black">特产好物</text> <text class="text-sm text-xl font-size-5 color-black font-bold">特产好物</text>
<text class="ps-2 text-xl text-sm font-size-3 color-gary">精选好物不容错过</text> <text class="color-gary ps-2 text-sm text-xl font-size-3">精选好物不容错过</text>
</view> </view>
<wd-button type="success" size="small" @click="switchTab(live_id)"> <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> </wd-button>
</view> </view>
</template> </template>
@ -245,26 +390,26 @@
</view> </view>
<view class="p-1"> <view class="p-1">
<wd-row class=" "> <wd-row class=" ">
<wd-col :span="12" v-for="(item, index) in index_live"> <wd-col v-for="(item, index) in index_live" :span="12">
<view class="p-1" style="" @click="goPage(item)" v-if="index < 4"> <view v-if="index < 4" class="p-1" style="" @click="goPage(item)">
<view class="py-2"> <view class="py-2">
<wd-card custom-class="card-content"> <wd-card custom-class="card-content">
<view style="height: 300rpx"> <view style="height: 300rpx">
<wd-img <wd-img
radius="20rpx" radius="20rpx"
:width="'100%'" width="100%"
mode="widthFix" mode="widthFix"
:height="'100%'" height="100%"
:src="item.cover" :src="item.cover"
/> />
</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.title }} {{ item.title }}
</view> </view>
<view class="ps-2 pt-2 font-size-3 ellipsis"> <view class="ellipsis ps-2 pt-2 font-size-3">
{{ item.description }} {{ item.description }}
</view> </view>
<view class="ps-2 pt-2 pb-2"></view> <view class="pb-2 ps-2 pt-2" />
</wd-card> </wd-card>
</view> </view>
</view> </view>
@ -277,13 +422,13 @@
<template #title> <template #title>
<view class="title"> <view class="title">
<view> <view>
<text class="text-xl text-sm font-size-5 font-bold color-black">热门咨询</text> <text class="text-sm text-xl font-size-5 color-black font-bold">热门咨询</text>
<text class="ps-2 text-xl text-sm font-size-3 color-gary"> <text class="color-gary ps-2 text-sm text-xl font-size-3">
热门咨询一键掌握新鲜事 热门咨询一键掌握新鲜事
</text> </text>
</view> </view>
<wd-button type="success" size="small" @click="switchTab(play_id)"> <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> </wd-button>
</view> </view>
</template> </template>
@ -291,26 +436,28 @@
</view> </view>
<view class="p-2"> <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"> <view v-if="index < 4">
<wd-card custom-class="card-content"> <wd-card custom-class="card-content">
<view class="content p-2" style="align-items: normal"> <view class="content p-2" style="align-items: normal">
<view style="width: 280rpx; height: 200rpx"> <view style="width: 280rpx; height: 200rpx">
<wd-img <wd-img
:width="'100%'" width="100%"
:height="'100%'" height="100%"
radius="20rpx" radius="20rpx"
mode="aspectFill" mode="aspectFill"
:src="item.cover" :src="item.cover"
alt="joy" alt="joy"
/> />
</view> </view>
<view class="ps-2 flex-content-column"> <view class="flex-content-column ps-2">
<view class="ps-1 font-size-3 font-bold ellipsis-2 color-black"> <view class="ellipsis-2 ps-1 font-size-3 color-black font-bold">
{{ item.title }} {{ item.title }}
</view> </view>
<view class="px-1 font-size-3 ellipsis-2 color-gary">{{ item.description }}</view> <view class="ellipsis-2 color-gary px-1 font-size-3">
<view class="p-1 font-size-3 color-gary" style="align-items: end"> {{ 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> <text class="pe-2 font-size-3">2025-8-23</text>
<!-- <wd-tag custom-class="space font-size-3" type="danger" round> <!-- <wd-tag custom-class="space font-size-3" type="danger" round>
{{ item.category_name }} {{ item.category_name }}
@ -328,11 +475,11 @@
<template #title> <template #title>
<view class="title"> <view class="title">
<view> <view>
<text class="text-xl text-sm font-size-5 font-bold color-black">景区旅游</text> <text class="text-sm text-xl font-size-5 color-black font-bold">景区旅游</text>
<text class="ps-2 text-xl text-sm font-size-3 color-gary">好玩儿路线一网打尽</text> <text class="color-gary ps-2 text-sm text-xl font-size-3">好玩儿路线一网打尽</text>
</view> </view>
<wd-button type="success" size="small" @click="switchTab(purchase_id)"> <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> </wd-button>
</view> </view>
</template> </template>
@ -365,11 +512,11 @@
</wd-row> </wd-row>
</view> --> </view> -->
<view class="p-2" v-for="(item, index) in index_purchase"> <view v-for="(item, index) in index_purchase" class="p-2">
<view class="" style="" @click="goPage(item)" v-if="index < 4"> <view v-if="index < 4" class="" style="" @click="goPage(item)">
<wd-card custom-class="card-content"> <wd-card custom-class="card-content">
<view class="relative" style="height: 360rpx"> <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"> <!-- <view style="position: absolute; top: -20rpx; right: 40rpx">
<wd-img <wd-img
:width="'120rpx'" :width="'120rpx'"
@ -397,11 +544,13 @@
</view> --> </view> -->
<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" style="backdrop-filter: blur(1px); border-radius: 10rpx"
> >
<text class="block font-size-5 text-left ellipsis">{{ item.title }}</text> <text class="ellipsis block text-left font-size-5">
<text class="font-size-3 text-left ellipsis-2"> {{ item.title }}
</text>
<text class="ellipsis-2 text-left font-size-3">
{{ item.description }} {{ item.description }}
</text> </text>
</view> </view>
@ -411,149 +560,10 @@
</view> </view>
<fly-login v-model="show" /> <fly-login v-model="show" />
<view class="p-1"></view> <view class="p-1" />
</view> </view>
</template> </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> <style lang="scss" scoped>
.section { .section {
width: 100%; width: 100%;

View File

@ -126,3 +126,7 @@ export function getCodeAPI(data: any) {
export function bindPhoneApi(data: any) { export function bindPhoneApi(data: any) {
return http.post('/api/user/checkPhone', data) return http.post('/api/user/checkPhone', data)
} }
export function getShareParamsApi(data: any) {
return http.get('/api/index/getShareParams', data)
}

View File

@ -1,7 +1,9 @@
import { pages, subPackages } from '@/pages.json' import { pages, subPackages } from '@/pages.json'
import { isMpWeixin } from './platform'
import { getInfoAPI } from '@/service/crmeb/product.ts' import { getInfoAPI } from '@/service/crmeb/product.ts'
import { useUserStore } from '@/store'
import { http } from '@/utils/http' import { http } from '@/utils/http'
import { isMpWeixin } from './platform'
export function getLastPage() { export function getLastPage() {
// getCurrentPages() 至少有1个元素所以不再额外判断 // getCurrentPages() 至少有1个元素所以不再额外判断
// const lastPage = getCurrentPages().at(-1) // const lastPage = getCurrentPages().at(-1)
@ -170,7 +172,7 @@ export function getUrlCrmebLogin() {
let baseUrl = import.meta.env.VITE_CRMEB_SERVER_BASEURL_LOGIN let baseUrl = import.meta.env.VITE_CRMEB_SERVER_BASEURL_LOGIN
return baseUrl return baseUrl
} else { } else {
let baseUrl = import.meta.env.VITE_CRMEB_SERVER_BASEURL let baseUrl = import.meta.env.VITE_CRMEB_SERVER_BASEURL_LOGIN
return baseUrl return baseUrl
} }
} }
@ -192,81 +194,56 @@ export function getUrlCrmebProxy() {
return baseUrl return baseUrl
} }
//模块跳转 // 模块跳转
export function getUrl(url) { export function getUrl(url) {
console.log('c123', url) console.log('c123', url)
return uni.navigateTo({ return uni.navigateTo({
url: url, url,
}) })
} }
// 代登录跳转 // 代登录跳转
export function getWebUrl(url) { export function getWebUrl(target) {
console.log('传递参数', url) target = encodeURIComponent(target)
const target = encodeURIComponent(url) const userId = computed(() => useUserStore().userInfo?.id)
return uni.navigateTo({ const village_id = computed(() => useUserStore().userInfo?.village_id)
url: `/pages/web_view/index?target=${target}`, 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) { export function getShopWebUrl(target) {
console.log('传递参数', url) target = encodeURIComponent(target)
const target = encodeURIComponent(url) const userId = computed(() => useUserStore().userInfo?.id)
return uni.navigateTo({ const village_id = computed(() => useUserStore().userInfo?.village_id)
url: `/pages/web_view/h5?target=${target}`, 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() // const userStore = useUserStore()
// 代登录跳转 // 代登录跳转
export async function hasLogin() { export async function hasLogin() {
const res = await getInfoAPI() const res = await getInfoAPI()
// const res = await http.get('/api/user/info', {}) // 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) console.log('village_id', useUserStore().userInfo.village_id)
if (res.code === 401) { if (res.code === 401) {
const hasLogin = false return 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
} else { } else {
const hasLogin = true if (res.data.village === 0 || res.data.village === null || res.data.village === '') {
//强制跳转设置村庄
if (hasLogin && useUserStore().userInfo.village_id === 0) {
// if (!this.phone) {
// uni.showToast({
// title: '请填写手机号',
// icon: 'none',
// })
// return
// }
uni.showModal({ uni.showModal({
title: '温馨提示', title: '温馨提示',
content: ' 您尚未完善个人信息,是否前往设置你的个人地址?', content: ' 您尚未完善个人信息,是否前往设置个人地址?',
success: function (res) { success(res) {
if (res.confirm) { if (res.confirm) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/my/setting?type=1', url: '/pages/my/setting?type=1',
@ -276,7 +253,20 @@ export async function hasLogin() {
}) })
return return
} }
//返回是否登录 if (res.data.phone === 0 || res.data.phone === null || res.data.phone === '') {
return hasLogin uni.showModal({
title: '温馨提示',
content: ' 您尚未完善个人信息,是否前往设置手机号?',
success(res) {
if (res.confirm) {
uni.navigateTo({
url: '/pages/my/setting?type=1',
})
}
},
})
return
}
return true
} }
} }