完善功能

This commit is contained in:
wangxiaowei
2026-04-17 21:52:51 +08:00
parent c3639526d1
commit 7f8f15b809
12 changed files with 1364 additions and 426 deletions

View File

@ -130,4 +130,4 @@ export function getPayway(params) {
// 小程序码
export function apiMnpQrCode(params) {
return request.get('share/getMnQrcode', { params })
}
}

View File

@ -89,4 +89,9 @@ export function apiInvoiceDetail(params) {
// 订单发票详情
export function apiOrderInvoiceDetail(params) {
return request.get("order/invoice", { params })
}
// 获取城市下对应的店铺
export function getCityShops(params) {
return request.get("shop/getShopCityInfo", { params })
}

View File

@ -197,4 +197,8 @@ export function getCityLists() {
// 逆解析定位地址
export function getGeocoder(params) {
return request.get("index/geocoder", {params})
}
export function getHotCityLists() {
return request.get("index/hotCity")
}

View File

@ -99,8 +99,9 @@ export function setUserInfo(data) {
}
// 获取手机号
export function getWxMnpMobile(data) {
return request.post('user/getMobile', data)
export function getWxMnpMobile(data, token) {
const config = token ? { header: { token } } : undefined
return request.post('user/getMobile', data, config)
}
//更新微信信息
@ -293,3 +294,10 @@ export const apibindOa = (params) => request.post('account/oaAuthLogin', params)
export function withdrawReceive(data) {
return request.post('withdraw/receive', data)
}
// 分销推广扫码进入的提交申请
export function scanSubmit(data) {
return request.post('distribution/wxCodeApply', data)
}

View File

@ -48,10 +48,10 @@
label="现住省份:" :border-bottom="false" placeholder="请选择省、市、区">
</u-field>
</view>
<view class="form-item">
<!-- <view class="form-item">
<u-field v-model="reason" :label-width="150" type="textarea" label="申请原因:"
placeholder="(必填)" :field-style="{ height: '250rpx'}" />
</view>
</view> -->
</view>
</view>
<button class="apply-btn bg-primary white md m-t-20 flex row-center br60" @tap="formSubmit">
@ -218,12 +218,15 @@
applyDetail,
getSuperiorInfo,
getDistribution,
veryfiyDistribute
veryfiyDistribute,
scanSubmit
} from "@/api/user";
import area from '@/utils/area'
import {
copy
copy,
strToParams
} from '@/utils/tools'
export default {
data() {
return {
@ -255,10 +258,24 @@
inviteStatus: false,
showRegion: false,
regionLists: area,
distributionInfo: {}
distributionInfo: {},
isScanEntry: false
};
},
onLoad(options) {
onLoad() {
this.isScanEntry = false
console.log("🚀 ~ this.$Route.query:", this.$Route.query)
if (this.$Route.query && this.$Route.query.scene) {
console.log("🚀 ~ this.$Route.query:", this.$Route.query.scene)
const query = this.parseScanQuery(this.$Route.query.scene)
console.log("🚀 ~ query:", query)
if (query.type == 1 || query.type == '1') {
// 页面扫码进入
this.isScanEntry = true
}
}
// 获取上级及个人信息
this.getSuperiorInfoFun()
// 判断是否是分销会员
@ -267,6 +284,40 @@
methods: {
parseScanQuery(scene) {
if (!scene || typeof scene !== 'string') return {}
let parsed = {}
let decodedScene = scene
try {
decodedScene = decodeURIComponent(scene)
} catch (error) {
decodedScene = scene
}
try {
parsed = strToParams(decodedScene)
} catch (error) {
parsed = {}
}
if (!Object.keys(parsed).length && decodedScene.includes('=')) {
const [key, value = ''] = decodedScene.split('=')
parsed = {
[key]: value
}
}
const keys = Object.keys(parsed)
if (keys.length === 1 && keys[0].includes('%3D')) {
try {
parsed = strToParams(decodeURIComponent(keys[0]))
} catch (error) {}
}
return parsed
},
// 分销会员信息
async getDistributionFun() {
const {
@ -281,20 +332,26 @@
veryfiyDistributeFun() {
veryfiyDistribute().then(res => {
console.log("🚀 ~ res.code:", res.code)
console.log("🚀 ~ res.code:", this.isScanEntry)
if (res.code == 10001) {
// 分销会员
this.vipState = 2
this.getDistributionFun()
} else if (res.code == 20001) {
} else if (res.code == 20001 && this.isScanEntry == true) {
// 非分销会员
this.vipState = 0;
this.applyDetailFun()
} else if (res.code == 0) {
} else {
this.$toast({
title: "请先扫码"
});
// 返回上一页
setTimeout(() => {
uni.navigateBack()
}, 500)
}
}
})
},
@ -307,8 +364,7 @@
if (code == 1) {
this.showLoading = false
switch (data.status) {
case 0:
// 待审核
case 0: // 待审核
case 2:
// 审核不通过
this.vipState = 1;
@ -359,23 +415,23 @@
province: provinceId,
city: cityId,
district: districtId,
reason: reason,
// reason: reason,
mobile
};
const {
data,
code,
msg
} = await applyDistribute(params)
} = await scanSubmit(params)
if (code == 1) {
this.$toast({
title: msg
});
this.veryfiyDistributeFun();
this.applyDetailFun();
}
},
// 填写邀请码
bindSuperiorFun() {
bindSuperior({

View File

@ -63,7 +63,7 @@
<script>
import { mapActions, mapMutations, mapGetters } from 'vuex'
import { getCityLists } from "@/api/store.js"
import { getCityLists, getHotCityLists } from "@/api/store.js"
import { currentPage, toast } from "@/utils/tools.js"
import cache from "@/utils/cache"
@ -75,24 +75,31 @@
labelList: [],
historyList: [],
hotList: [
{ name: '北京市', gcj02_lat: "39.929986", gcj02_lng: "116.395645", id: 110100 },
{ name: '上海市', gcj02_lat: "31.249162", gcj02_lng: "121.487899", id: 310100 },
{ name: '广州市', gcj02_lat: "23.120049", gcj02_lng: "113.30765", id: 440100 },
{ name: '深圳市', gcj02_lat: "22.546054", gcj02_lng: "114.025974", id: 440300 },
{ name: '重庆市', gcj02_lat: "29.544606", gcj02_lng: "106.530635", id: 110100 },
{ name: '成都市', gcj02_lat: "30.679943", gcj02_lng: "104.067923", id: 510100 },
{ name: '杭州市', gcj02_lat: "30.259244", gcj02_lng: "120.219375", id: 110100 },
{ name: '苏州市', gcj02_lat: "31.317987", gcj02_lng: "120.619907", id: 320500 },
{ name: '武汉市', gcj02_lat: "30.581084", gcj02_lng: "114.3162", id: 420100 },
{ name: '沈阳市', gcj02_lat: "41.808645", gcj02_lng: "123.432791", id: 210100 }
// { name: '上海市', gcj02_lat: "31.231706", gcj02_lng: "121.472644", id: 310100 },
// { name: '北京市', gcj02_lat: "39.904989", gcj02_lng: "116.405285", id: 110100 },
// { name: '广州市', gcj02_lat: "23.125178", gcj02_lng: "113.280637", id: 440100 },
// { name: '深圳市', gcj02_lat: "22.546054", gcj02_lng: "114.025974", id: 440300 },
// { name: '杭州市', gcj02_lat: "30.259244", gcj02_lng: "120.219375", id: 110100 },
// { name: '嘉兴市', gcj02_lat: "30.259244", gcj02_lng: "120.219375", id: 110100 },
// { name: '泉州市', gcj02_lat: "30.259244", gcj02_lng: "120.219375", id: 110100 },
// { name: '漳州市', gcj02_lat: "30.259244", gcj02_lng: "120.219375", id: 110100 },
// { name: '西安市', gcj02_lat: "30.259244", gcj02_lng: "120.219375", id: 110100 },
// { name: '苏州市', gcj02_lat: "31.317987", gcj02_lng: "120.619907", id: 320500 },
// { name: '哈尔滨市', gcj02_lat: "31.317987", gcj02_lng: "120.619907", id: 320500 },
// { name: '菏泽市', gcj02_lat: "31.317987", gcj02_lng: "120.619907", id: 320500 },
// { name: '惠州市', gcj02_lat: "31.317987", gcj02_lng: "120.619907", id: 320500 },
// { name: '厦门市', gcj02_lat: "31.317987", gcj02_lng: "120.619907", id: 320500 },
// { name: '济宁市', gcj02_lat: "31.317987", gcj02_lng: "120.619907", id: 320500 },
// { name: '威海市', gcj02_lat: "31.317987", gcj02_lng: "120.619907", id: 320500 },
// { name: '福州市', gcj02_lat: "31.317987", gcj02_lng: "120.619907", id: 320500 },
],
isFirstLoading: true,
touchmove: false,
touchmoveIndex: 0,
}
},
onLoad() {
this.getHotCityListsFunc()
this.getCityListsFunc()
this.historyList = cache.get('HISTORY') || []
},
@ -105,6 +112,13 @@
methods: {
...mapActions(['initLocationFunc']),
...mapMutations(['setCityInfo']),
async getHotCityListsFunc() {
const { code, data } = await getHotCityLists()
if (code == 1) {
this.hotList = data;
}
},
async reLocationFunc() {
this.isLoading = true;

View File

@ -1,88 +1,153 @@
<template>
<view class="goods-cate">
<router-link to="/pages/goods_search/goods_search">
<router-link :to="{ path: '/bundle/pages/shop_search/shop_search', query: { id: shopId, is_recommend: 0 } }">
<view class="header">
<u-search bg-color="#F4F4F4" :disabled="true"></u-search>
<u-search bg-color="#F4F4F4" :disabled="true" placeholder="搜索店内商品"></u-search>
</view>
</router-link>
<view class="content" v-if="appConfig.cate_style == 1 || appConfig.cate_style == 4">
<cate-two :cate-list="cateList"></cate-two>
</view>
<view class="content bg-body" v-if="appConfig.cate_style == 3 || appConfig.cate_style == 2">
<cate-one :cate-list="cateList" :selecttab="selecttab"></cate-one>
<view class="category">
<view class="goods-display bg-body" style="display: flex; border-radius: 20rpx">
<view class="category-aside">
<scroll-view
:scroll-y="true"
:style="{ height: aslideH + 'px', padding: '10rpx' }"
>
<view
class="aside-item flex row-center"
:class="{ active: active == -1 }"
@click="changeActive(-1)"
>
<view
class="xs text-center"
style="width: 60rpx"
:class="{ primary: active == -1 }"
>全部商品</view>
</view>
<view
class="aside-item flex row-center"
:class="{ active: active == index }"
v-for="(item, index) in category"
:key="index"
@click="changeActive(index)"
>
<view
class="xs text-center"
style="width: 60rpx"
:class="{ primary: active == index }"
>{{ item.name }}</view>
</view>
</scroll-view>
</view>
<view class="category-row flex-1">
<mescroll-body
ref="mescrollRef"
@init="mescrollInit"
:height="meScrollH"
@down="downCallback"
@up="upCallback"
:up="upOption"
:down="{ use: false }"
>
<view class="bg-white">
<goods-list :list="goodsList" type="one"></goods-list>
</view>
</mescroll-body>
</view>
</view>
</view>
<tabbar></tabbar>
</view>
</template>
<script>
import {
getLevelOneList,
getGoodsList,
getListByLevelOne
} from '@/api/store';
import {
getRect,
trottle,
arraySlice
} from '@/utils/tools';
import {
mapGetters,
mapActions
} from 'vuex'
import Cache from '@/utils/cache'
import { mapGetters, mapActions } from 'vuex'
import { getShopGoodsCategory } from '@/api/shop'
import { getGoodsList } from '@/api/store'
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js'
export default {
mixins: [MescrollMixin],
data() {
return {
cateList: [],
cateTwoList: [],
selectIndex: 0,
category_id:'',
selecttab:0,
shopId: 1,
category: [],
active: -1,
upOption: {
auto: false,
empty: {
icon: '/static/images/goods_null.png',
tip: '暂无商品'
}
},
goodsList: [],
sys: {}
};
},
async onLoad(options) {
this.getLevelOneListFun();
// this.getListByLevelOneFun()
async onLoad() {
this.sys = uni.getSystemInfoSync()
await this.getShopGoodsCategoryFun()
this.mescroll.resetUpScroll()
uni.$on('refreshhome', this.onCityChange)
},
onUnload() {
uni.$off('refreshhome', this.onCityChange)
},
onShow() {
if(uni.getStorageSync('category_id')!=''&&uni.getStorageSync('category_id')!=null){
this.category_id=uni.getStorageSync('category_id')
if(this.cateList.length!=0){
this.cateList.forEach((item,index)=>{
if(item.id==this.category_id){
this.selecttab=index
}
})
}
uni.removeStorageSync('category_id')
}
this.getCartNum()
},
methods: {
...mapActions(['getCartNum']),
async getLevelOneListFun() {
const {
code,
data
} = await getLevelOneList();
onCityChange() {
this.active = -1
this.goodsList = []
this.getShopGoodsCategoryFun()
this.mescroll.resetUpScroll()
},
async getShopGoodsCategoryFun() {
const { data, code } = await getShopGoodsCategory({
shop_id: this.shopId
})
if (code == 1) {
this.cateList = data
if(this.category_id!=''){
this.cateList.forEach((item,index)=>{
if(item.id==this.category_id){
this.selecttab=index
}
})
}
this.category = data
}
},
changeActive(index) {
this.active = index
this.goodsList = []
this.mescroll.resetUpScroll()
},
upCallback(page) {
const { active, category } = this
const pageNum = page.num
const pageSize = page.size
const cateId = active == -1 ? '' : category[active].id
getGoodsList({
page_size: pageSize,
page_no: pageNum,
shop_id: this.shopId,
shop_cate_id: cateId
}).then(({ data }) => {
let curPageData = data.lists
let curPageLen = curPageData.length
let hasNext = !!data.more
if (page.num == 1) this.goodsList = []
this.goodsList = this.goodsList.concat(curPageData)
this.mescroll.endSuccess(curPageLen, hasNext)
})
}
},
computed: {
...mapGetters(['inviteCode', 'appConfig']),
...mapGetters(['sysInfo', 'cityInfo']),
aslideH() {
const { windowHeight, safeArea } = this.sys
if (!safeArea) return 0
// 减去头部搜索栏(94rpx)、底部tabbar(50px)、安全区域
return windowHeight - uni.upx2px(94) - 50
},
meScrollH() {
return this.aslideH + 'px'
}
}
};
</script>
@ -92,26 +157,47 @@
page {
background-color: #fff;
height: 100%;
.goods-cate {
height: 100%;
.header {
box-sizing: border-box;
height: $header-height;
border-bottom: $-solid-border;
}
.search {
flex: 1;
height: 60rpx;
.goods-cate {
height: 100%;
input {
flex: 1;
height: 100%;
.header {
box-sizing: border-box;
height: $header-height;
border-bottom: $-solid-border;
}
.category {
background-color: white;
border-radius: 20rpx;
.category-aside {
width: 150rpx;
align-self: flex-start;
.aside-item {
width: 120rpx;
padding: 20rpx 0;
&.active {
position: relative;
background-color: $-color-white;
&::before {
content: '';
width: 3rpx;
height: 80rpx;
background-color: $-color-primary;
position: absolute;
left: 0;
}
}
}
}
.content {
height: calc(100vh - #{$header-height} - var(--window-top) - var(--window-bottom) - 50px - env(safe-area-inset-bottom));
.category-row {
align-self: flex-start;
}
}
}

View File

@ -0,0 +1,118 @@
<template>
<view class="goods-cate">
<router-link to="/pages/goods_search/goods_search">
<view class="header">
<u-search bg-color="#F4F4F4" :disabled="true"></u-search>
</view>
</router-link>
<view class="content" v-if="appConfig.cate_style == 1 || appConfig.cate_style == 4">
<cate-two :cate-list="cateList"></cate-two>
</view>
<view class="content bg-body" v-if="appConfig.cate_style == 3 || appConfig.cate_style == 2">
<cate-one :cate-list="cateList" :selecttab="selecttab"></cate-one>
</view>
<tabbar></tabbar>
</view>
</template>
<script>
import {
getLevelOneList,
getGoodsList,
getListByLevelOne
} from '@/api/store';
import {
getRect,
trottle,
arraySlice
} from '@/utils/tools';
import {
mapGetters,
mapActions
} from 'vuex'
import Cache from '@/utils/cache'
export default {
data() {
return {
cateList: [],
cateTwoList: [],
selectIndex: 0,
category_id:'',
selecttab:0,
};
},
async onLoad(options) {
this.getLevelOneListFun();
// this.getListByLevelOneFun()
},
onShow() {
if(uni.getStorageSync('category_id')!=''&&uni.getStorageSync('category_id')!=null){
this.category_id=uni.getStorageSync('category_id')
if(this.cateList.length!=0){
this.cateList.forEach((item,index)=>{
if(item.id==this.category_id){
this.selecttab=index
}
})
}
uni.removeStorageSync('category_id')
}
this.getCartNum()
},
methods: {
...mapActions(['getCartNum']),
async getLevelOneListFun() {
const {
code,
data
} = await getLevelOneList();
if (code == 1) {
this.cateList = data
if(this.category_id!=''){
this.cateList.forEach((item,index)=>{
if(item.id==this.category_id){
this.selecttab=index
}
})
}
}
},
},
computed: {
...mapGetters(['inviteCode', 'appConfig']),
}
};
</script>
<style lang="scss" scoped>
$header-height: 94rpx;
page {
background-color: #fff;
height: 100%;
.goods-cate {
height: 100%;
.header {
box-sizing: border-box;
height: $header-height;
border-bottom: $-solid-border;
.search {
flex: 1;
height: 60rpx;
input {
flex: 1;
height: 100%;
}
}
}
.content {
height: calc(100vh - #{$header-height} - var(--window-top) - var(--window-bottom) - 50px - env(safe-area-inset-bottom));
}
}
}
</style>

View File

@ -397,12 +397,12 @@
<!-- <view class="con flex row-center muted" v-else>暂无评价</view> -->
</view>
<view
<!-- <view
class="goods-shop m-t-20 bg-white round-box m-x-20"
v-if="appConfig.shop_hide_goods == 1"
>
<goods-shop :shop="shop"></goods-shop>
</view>
</view> -->
<view class="details m-t-20 bg-white round-box m-x-20" id="details">
<view class="title lg">商品详情</view>
<view class="content">

View File

@ -1,332 +1,464 @@
<template>
<view>
<mescroll-body
ref="mescrollRef"
@init="mescrollInit"
@down="downCallback"
@up="upCallback"
:up="{
use: false,
toTop: {
bottom: '300rpx'
}
}"
>
<view class="index index-bg" :style="[headerStyle]">
<u-sticky offset-top="0" h5-nav-height="0" bg-color="transparent">
<view class="index-bg" :style="[headerStyle]">
<u-navbar
:is-fixed="false"
:border-bottom="false"
:background="{ background: 'transparent' }"
:is-back="false"
<view v-if="shopInfo.is_freeze === 1 || shopInfo.is_expire === 1 || shopInfo.is_run === 0">
<shop-stop
:is_freeze="shopInfo.is_freeze"
:is_expire="shopInfo.is_expire"
:is_run="shopInfo.is_run"
></shop-stop>
</view>
<view class="store-index" v-else>
<view
class="store-header"
:style="{
'background-image': `url(${
shopInfo.background
? shopInfo.background
: $getImageUri('/static/common/image/default/shopindex.png')
})`
}"
>
<u-navbar
:border-bottom="false"
:background="{
'background-image': `url(${shopInfo.background})`,
'background-repeat': 'no-repeat',
'background-size': '100% auto'
}"
:back-bg="'rgba(255, 255, 255, 0.45)'"
:back-icon-color="'rgb(255,255,255)'"
:is-fixed="true"
:is-back="false"
>
<view class="flex-1 flex">
<!-- 城市 -->
<router-link
v-if="appConfig.is_open_nearby"
class="m-l-16 flex white row-center flex-none"
to="/bundle_b/pages/city/city"
>
<view class="flex-1 flex row" style="position: relative">
<!-- 城市 -->
<router-link
v-if="appConfig.is_open_nearby"
class="m-l-16 flex white row-center"
to="/bundle_b/pages/city/city"
>
<text class="m-r-6">{{ cityInfo.name || '选择' }}</text>
<u-icon name="arrow-down" size="24" color="#FFFFFF"></u-icon>
<!-- <image class="icon-md m-l-30" src="/static/images/icon_news.png">
</image> -->
</router-link>
<view class="flex-1">
<router-link to="/pages/goods_search/goods_search">
<u-search
wrap-bg-color="transparent"
bg-color="#fff"
:disabled="true"
:height="62"
>
</u-search>
</router-link>
</view>
<!-- #ifdef MP -->
<view class="capsule-tips flex row-between" v-if="offPrompt">
<text class="m-r-10">添加到”我的小程序”,红包、优惠不错过</text>
<u-icon
name="close"
color="#FFFFFF"
@click="clearIntervalFunc"
></u-icon>
</view>
<!-- #endif -->
</view>
</u-navbar>
<view class="flex">
<view class="flex-1" style="min-width: 600rpx">
<u-tabs
active-color="#fff"
inactive-color="#fff"
:current="active"
:list="cateList"
bg-color="transparent"
:active-item-style="{ fontSize: '32rpx' }"
:bar-width="64"
:bold="false"
:barStyle="{
background:
'linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, #FFFFFF 49%, rgba(255, 255, 255, 0) 100%)'
}"
@change="changeActive"
>
</u-tabs>
</view>
<router-link to="/pages/goods_cate/goods_cate" navType="pushTab">
<view class="white flex cate-btn m-l-10">
<image
class="icon-xs m-r-4"
src="/static/images/icon_cate.png"
alt=""
/>
分类
</view>
</router-link>
<text class="m-r-6">{{ cityInfo.name || '选择' }}</text>
<u-icon name="arrow-down" size="24" color="#FFFFFF"></u-icon>
</router-link>
<view class="store-search flex-1" @click="handleSerach">
<u-search
v-model="keyword"
bg-color="white"
shape="round"
placeholder="搜索店内商品"
wrap-bg-color="transparent"
@search="refresh"
>
</u-search>
</view>
</view>
</u-sticky>
<view class="tab-con">
<scroll-view class="index_css" scroll-y="true" v-show="active == 0" :style="[positionTop]" >
<index-home
ref="indexHome"
:top="cateTop"
:home-data="homeData"
:nav-list="navList"
:live-list="liveLists"
>
</index-home>
<goods-column ref="mescrollItem" :autoGetData="false"></goods-column>
</scroll-view>
<template v-for="(item, index) in cateList">
<view
v-if="index > 0"
class="tab-item"
v-show="active == index"
:key="index"
>
<view>
<cate-home
v-if="showCateList[index]"
:top="cateTop"
ref="cateItem"
:i="index"
:index="active"
:cate="item"
</u-navbar>
<view
class="store-info m-t-20"
:style="{ 'padding-bottom': '200rpx' }"
>
<view class="flex row-between">
<view class="flex">
<u-image
width="100rpx"
height="100rpx"
border-radius="50%"
:src="shopInfo.logo"
/>
<view class="m-l-20 flex-col col-top">
<router-link
:to="{
path: '/pages/store_detail/store_detail',
query: { id: shopInfo.id }
}"
>
</cate-home>
<view class="lg white line-1 bold" style="width: 420rpx">
{{ shopInfo.name }}
<u-icon name="arrow-right"></u-icon>
</view>
</router-link>
<view class="flex m-t-10">
<view class="store-tag xxs white" v-if="shopInfo.type == 1">
自营
</view>
<view class="white xs m-l-5">
{{ shopInfo.visited_num }}人进店
</view>
</view>
</view>
</view>
</template>
<view
class="flex row-center white br60 sm flex-none subscribe-btn"
:class="{ gray: shopInfo.shop_follow_status === 1 }"
@tap="changeShopFollowFun"
>
{{ shopInfo.shop_follow_status === 1 ? '已关注' : '+ 关注' }}
</view>
</view>
<view class="p-t-20 p-b-20">
<u-tabs
:current="tabcurrent"
:list="[{ name: '精选' }, { name: '商品' }, { name: '领券' }]"
:is-scroll="false"
@change="tabChange"
bg-color="transparent"
active-color="white"
inactive-color="white"
></u-tabs>
</view>
</view>
</view>
<!-- #ifdef APP-PLUS -->
<lyg-popup
v-if="appConfig.app_agreement"
title="用户使用及隐私保护政策提示"
protocolPath="/bundle/pages/server_explan/server_explan?type=0"
policyPath="/bundle/pages/server_explan/server_explan?type=1"
policyStorageKey="has_read_privacy"
>
</lyg-popup>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<!-- 用户隐私协议弹框 -->
<privacy-popup v-model="showPrivacyPopup"></privacy-popup>
<!-- #endif -->
</mescroll-body>
<!-- #ifdef H5 -->
<view class="record_number">
<a :href="appConfig.icp_link" style="color: #495770; text-decoration: none">
{{ appConfig.icp_number }}
</a>
<!-- 精选商城 -->
<view class="content" v-if="tabcurrent == 0">
<view v-if="shopInfo.ad.mobile.length">
<u-swiper
:list="shopInfo.ad.mobile"
height="700"
@click="handleAdclick"
></u-swiper>
</view>
<view class="content-wrap" v-if="shopInfo.goods_list.length">
<view class="store-hot-goods bg-white m-t-20">
<view class="store-hot-header flex">
<view class="column-line m-r-20" />
<view class="md" style="font-weight: 500"> 店铺推荐 </view>
<view class="md" style="margin-left: auto" @click="handlemore">
更多</view
>
</view>
<view class="store-hot-content">
<scroll-view :scroll-x="true">
<view class="goods p-l-20 p-r-20">
<goods-list :list="shopInfo.goods_list" type="row"></goods-list>
</view>
</scroll-view>
</view>
</view>
</view>
<view class="goods-display flex bg-body">
<view class="category-row flex-1">
<u-sticky
bg-color="rgba(255, 255, 255, 0)"
:enable="enableFix"
:offset-top="navHeight"
:h5-nav-height="0"
>
<sort-nav
v-model="sortConfig"
:show-type="false"
:showCreate="true"
></sort-nav>
</u-sticky>
<mescroll-body
ref="mescrollRef"
@init="mescrollInit"
:height="meScrollH"
@down="downCallback"
@up="upCallback"
:up="upOption"
:down="{ use: false }"
>
<view class="bg-white">
<goods-list :list="goodsList" width="315rpx"></goods-list>
</view>
</mescroll-body>
</view>
</view>
</view>
<!-- 商城商品 -->
<view v-if="tabcurrent == 1" style="margin-top: -200rpx">
<view class="goods-display flex bg-body">
<view class="category-row flex-1">
<u-sticky
bg-color="rgba(255, 255, 255, 0)"
:enable="enableFix"
:offset-top="navHeight"
:h5-nav-height="0"
>
<sort-nav v-model="sortConfig" :show-type="false"></sort-nav>
</u-sticky>
<mescroll-body
ref="mescrollRef"
@init="mescrollInit"
:height="meScrollH"
@down="downCallback"
@up="upCallback"
:up="upOption"
:down="{ use: false }"
>
<view class="bg-white">
<goods-list :list="goodsList"></goods-list>
</view>
</mescroll-body>
</view>
</view>
</view>
<!-- 优惠券 -->
<view v-if="tabcurrent == 2" style="margin-top: -200rpx">
<coupon-list
:list="couponlists"
@refresh="getGoodsCouponFun"
:btn-type="3"
v-if="couponlists.length"
></coupon-list>
<view class="coupon-container" v-else>
<view style="font-weight: 500">优惠券</view>
<view class="muted coupon"> 当前暂无可领取的优惠券 </view>
</view>
</view>
<loading-view v-if="isFirstLoading"></loading-view>
</view>
<!-- #endif -->
<tabbar></tabbar>
<!-- 无网络提示 -->
<u-no-network z-index="1200" @retry="handleRetry"></u-no-network>
</view>
</template>
<script>
import MescrollCompMixin from '@/components/mescroll-uni/mixins/mescroll-comp'
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
import { mapGetters, mapMutations, mapActions } from 'vuex'
import { getMenu, getHome, getHotGoods, getLevelOneList } from '@/api/store'
import { getConfig } from '@/api/app'
import { getLiveLists } from '@/api/live'
import { getRect } from '@/utils/tools'
const app = getApp()
const homeItem = {
name: '首页'
}
import { mapActions, mapGetters } from 'vuex'
import { getShopInfo, getShopGoodsCategory, changeShopFollow, getCityShops } from '@/api/shop'
import { getShopLive } from '@/api/live'
import { getGoodsList } from '@/api/store'
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js'
import { getCouponList } from '@/api/activity'
export default {
mixins: [MescrollMixin, MescrollCompMixin],
mixins: [MescrollMixin], // 使用mixin
data() {
return {
offPrompt: true,
active: 0,
navBg: 0,
goodsList: [],
homeData: {},
navList: [],
enable: true,
cateList: [homeItem],
showCateList: [],
liveLists: [],
showPrivacyPopup: false //微信用户隐私协议
}
},
async onLoad(options) {
// #ifdef MP-WEIXIN
wx.getPrivacySetting({
success: (res) => {
console.log(res, '------') // 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' }
if (res.needAuthorization) {
// 需要弹出隐私协议
this.showPrivacyPopup = true
tabcurrent: 0,
isFirstLoading: true,
navOpacity: 0,
shopInfo: {
goods_list: [],
ad: {
mobile: []
}
},
fail: (err) => {
console.log(err)
}
})
// #endif
category: [],
active: -1,
upOption: {
auto: false,
empty: {
icon: '/static/images/goods_null.png',
tip: '暂无商品'
}
},
goodsList: [],
categoodsList: [],
sortConfig: {
priceSort: '',
saleSort: '',
sort_by_create: ''
},
couponlists: [],
keyword: '',
sys: {},
enableFix: true,
id: '',
shopLive: {},
// 选择城市后是否刷新
if (options?.refresh) await this.getHomeFun()
// 监听是否刷新页面,目前秒杀时会用到
uni.$on('refreshhome', () => {
this.getHomeFun()
})
}
},
async onLoad() {
// this.id = this.$Route.query.id
this.sys = uni.getSystemInfoSync()
await this.getShopInfoFun()
await this.getShopGoodsCategoryFun()
// #ifdef MP-WEIXIN
this.getLiveListsFun()
this.getShopLiveFun()
// #endif
},
onUnload() {
uni.$off('refreshhome')
},
onShow() {
this.enable = this.active == 0 ? true : false
this.getCartNum()
this.isFirstLoading = false
this.mescroll.resetUpScroll()
},
onHide() {
// #ifdef H5
this.enable = false
this.enableFix = false
// #endif
},
onReady() {
// #ifdef MP
// 关闭胶囊提示
this.offPromptFunc()
onShow() {
this.getCurrentCity()
// #ifdef H5
this.enableFix = true
// #endif
},
onShareAppMessage() {
return {
title: this.shopInfo.name,
path: `pages/store_index/store_index?invite_code=${this.inviteCode}&id=${this.id}`
}
},
methods: {
...mapActions(['getCartNum', 'getUser', 'initLocationFunc']),
...mapMutations(['setConfig']),
// 网络重试刷新网络请求解决在ios中首次进入时需要授权蜂窝加载空白页面问题
async handleRetry() {
console.log('网络重试刷')
const { code, data } = await getConfig()
if (code == 1) {
this.setConfig(data)
if (data.is_open_nearby) {
// 获取定位
this.initLocationFunc()
}
}
this.getUser()
...mapActions(['initLocationFunc']),
getCurrentCity() {
if (!this.appConfig.is_open_nearby) return
this.initLocationFunc()
},
// #ifdef MP
offPromptFunc() {
let time = 8
this.offPrompt = setInterval(() => {
time -= 1
if (time <= 0) this.clearIntervalFunc()
}, 1000)
},
clearIntervalFunc() {
clearInterval(this.offPrompt)
this.offPrompt = false
},
// #endif
// 获取1级分类
async getLevelOneListFun() {
const { code, data } = await getLevelOneList()
if (code == 1) {
this.cateList = [homeItem, ...data]
this.showCateList = []
}
},
// 获取菜单
async getMenuFun() {
const { code, data } = await getMenu({
type: 1
handleAdclick(index) {
const { link, link_query } = this.shopInfo.ad.mobile[index]
console.log(link)
this.$Router.push({
path: link,
query: link_query
})
},
async getGoodsCouponFun() {
console.log(this.goodsId)
const { data, code } = await getCouponList({
shop_id: this.id,
city_id: (this.cityInfo && this.cityInfo.id) || 0,
})
console.log(data)
if (code == 1) {
this.navList = data
this.couponlists = data.lists
}
},
// 获取首页数据
async getHomeFun() {
const { code, data } = await getHome({ city_id: this.cityInfo.id })
if (code == 1) {
this.homeData = data
tabChange(value) {
this.tabcurrent = value
if (value == 2) {
this.getGoodsCouponFun()
}
},
// #ifdef MP-WEIXIN
async getLiveListsFun() {
const { code, data } = await getLiveLists({ page_size: 6, page_no: 1 })
async getShopLiveFun() {
const { data, code } = await getShopLive({
shop_id: this.id,
city_id: (this.cityInfo && this.cityInfo.id) || 0,
})
if (code == 1) {
this.liveLists = data.list
this.shopLive = data
}
},
//#endif
async changeShopFollowFun() {
if (!this.isLogin) return this.$Router.push('/pages/login/login')
const { code, msg } = await changeShopFollow({
shop_id: this.id,
city_id: (this.cityInfo && this.cityInfo.id) || 0,
})
if (code == 1) {
this.$toast({
title: msg
})
this.getShopInfoFun()
}
},
async getShopInfoFun() {
const { data, code } = await getCityShops({
city_id: (this.cityInfo && this.cityInfo.id) || 0
})
if (code == 1) {
this.shopInfo = data
}
},
async getShopGoodsCategoryFun() {
const { data, code } = await getShopGoodsCategory({
shop_id: this.id,
city_id: (this.cityInfo && this.cityInfo.id) || 0
})
if (code == 1) {
this.category = data
}
},
// #endif
changeActive(index) {
this.active = index
this.enable = index == 0
this.mescroll.optDown.use = index == 0
this.showCateList[index] = true
this.refresh()
},
async downCallback() {
await this.getLevelOneListFun()
await this.getMenuFun()
await this.getHomeFun()
// #ifdef MP-WEIXIN
this.getLiveListsFun()
// #endif
this.$refs.mescrollItem.getData()
this.mescroll.endSuccess(0, false)
refresh() {
this.goodsList = []
if (
!(
this.shopInfo.is_freeze === 1 ||
this.shopInfo.is_expire === 1 ||
this.shopInfo.is_run === 0
)
) {
this.mescroll.resetUpScroll()
}
},
handleSerach() {
this.$Router.push({
path: '/bundle/pages/shop_search/shop_search',
query: { id: this.id, is_recommend: 0 }
})
},
handlemore() {
this.$Router.push({
path: '/bundle/pages/shop_search/shop_search',
query: { id: this.id, is_recommend: 1 }
})
},
/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
upCallback(page) {
//联网加载数据
let {
goodsList,
keyword,
sortConfig: { priceSort, saleSort, sort_by_create },
active,
category
} = this
const pageNum = page.num // 页码, 默认从1开始
const pageSize = page.size // 页长, 默认每页10条
const cateId = active == -1 ? '' : category[active].id
setTimeout(() => {
getGoodsList({
page_size: pageSize,
page_no: pageNum,
shop_id: this.id,
sort_by_price: priceSort,
sort_by_sales: saleSort,
sort_by_create: sort_by_create,
keyword,
city_id: (this.cityInfo && this.cityInfo.id) || 0,
}).then(({ data }) => {
let curPageData = data.lists
let curPageLen = curPageData.length
let hasNext = !!data.more
if (page.num == 1) this.goodsList = []
this.goodsList = this.goodsList.concat(curPageData)
this.mescroll.endSuccess(curPageLen, hasNext)
})
}, 100)
}
},
computed: {
...mapGetters(['sysInfo', 'inviteCode', 'appConfig', 'cityInfo']),
navH() {
...mapGetters(['sysInfo', 'appConfig', 'cityInfo']),
navHeight() {
return this.sysInfo.navHeight + 'px'
},
positionTop() {
return { 'height': `calc(100vh - 100rpx - ${this.cateTop})` }
},
// 分类栏悬浮高度
cateTop() {
return this.sysInfo.navHeight + uni.upx2px(80) + 'px'
aslideH() {
const { windowHeight, navHeight, safeArea } = this.sys
if (!safeArea) return 0
console.log(this.sysInfo)
return windowHeight - this.sysInfo.navHeight - 100
},
headerStyle() {
const { active, cateList, appConfig } = this
let bg = cateList[active].bg_image
if (active == 0) {
bg = appConfig.index_setting.top_bg_image
meScrollH() {
return this.aslideH - uni.upx2px(80) + 'px'
},
// 获取图片域名
$getImageUri() {
return (url) => this.$store.state.app.config.base_domain + url
}
},
watch: {
'cityInfo.id': {
async handler(val, oldVal) {
if (val && val !== oldVal) {
await this.getShopInfoFun()
await this.getShopGoodsCategoryFun()
// #ifdef MP-WEIXIN
this.getShopLiveFun()
// #endif
this.mescroll.resetUpScroll()
}
}
},
sortConfig: {
deep: true,
handler(val) {
console.log(val)
this.refresh()
}
return bg
? {
'background-image': `url(${bg})`
}
: {}
}
}
}
@ -336,57 +468,115 @@ export default {
page {
padding: 0;
}
.index_css{
overflow: auto;
padding-bottom: env(safe-area-inset-bottom);
}
.index-bg {
background-image: url('../../static/images/index_bg.png');
background-size: 100% auto;
background-repeat: no-repeat;
}
.index {
min-height: calc(100vh - var(--window-bottom));
.store-index {
.store-header {
// padding-bottom: 60rpx;
background-repeat: no-repeat;
background-size: 100% auto;
.store-info {
padding-right: 30rpx;
padding-left: 24rpx;
.u-navbar {
::v-deep .u-search {
padding: 0 30rpx;
.store-tag {
background: linear-gradient(267deg, #ff2c3c 0%, #f52e99 100%);
border-radius: 6rpx;
padding: 4rpx 9rpx;
}
.subscribe-btn {
background: linear-gradient(97deg, #ff5784 0%, #ff2c3c 100%);
height: 52rpx;
width: 128rpx;
&.gray {
background: #ccc;
}
}
}
}
// 胶囊提示
.capsule-tips {
width: 584rpx;
color: #ffffff;
padding: 12rpx 18rpx;
border-radius: 14rpx;
background: rgba(0, 0, 0, 0.7);
position: relative;
position: absolute;
z-index: 9999;
bottom: -80rpx;
right: -150rpx;
}
.capsule-tips::after {
content: '';
border-bottom: 14rpx solid rgba(0, 0, 0, 0.7);
border-right: 14rpx solid transparent;
border-left: 14rpx solid transparent;
position: absolute;
top: -14rpx;
right: 88rpx;
}
.content {
margin-top: -200rpx;
margin-left: 20rpx;
margin-right: 20rpx;
.content-wrap {
// margin-top: 30rpx;
border-radius: 20rpx;
overflow: hidden;
margin-bottom: 30rpx;
}
.store-hot-goods {
overflow: hidden;
.store-hot-header {
padding: 20rpx;
.cate-btn {
padding: 12rpx 16rpx 12rpx 20rpx;
border-radius: 60rpx 0 0 60rpx;
background-color: rgba(256, 256, 256, 0.4);
.column-line {
width: 6rpx;
height: 32rpx;
background-color: $-color-primary;
}
}
.store-hot-content {
.goods {
display: inline-block;
}
.hot-goods-item {
width: 200rpx;
.hot-goods-info {
.hot-goods-price {
margin-top: 5rpx;
}
}
}
}
}
.goods-display {
.category-row {
align-self: flex-start;
width: 630rpx;
.sort-tool-bar {
.sort-item {
flex: 1;
height: 80rpx;
}
}
.goods-lists {
padding: 20rpx;
.item {
width: 285rpx;
border-radius: 10rpx;
overflow: hidden;
&:nth-of-type(2n) {
margin-left: 20rpx;
}
.goods-info {
padding: 10rpx;
}
}
}
}
}
}
}
.record_number {
text-align: center;
padding: 30rpx;
font-size: 24rpx;
.coupon-container {
background-color: white;
height: 1000rpx;
margin: 0 20rpx;
border-radius: 20rpx;
padding: 20rpx;
.coupon {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
}
</style>

392
pages/index/index_bck.vue Normal file
View File

@ -0,0 +1,392 @@
<template>
<view>
<mescroll-body
ref="mescrollRef"
@init="mescrollInit"
@down="downCallback"
@up="upCallback"
:up="{
use: false,
toTop: {
bottom: '300rpx'
}
}"
>
<view class="index index-bg" :style="[headerStyle]">
<u-sticky offset-top="0" h5-nav-height="0" bg-color="transparent">
<view class="index-bg" :style="[headerStyle]">
<u-navbar
:is-fixed="false"
:border-bottom="false"
:background="{ background: 'transparent' }"
:is-back="false"
>
<view class="flex-1 flex row" style="position: relative">
<!-- 城市 -->
<router-link
v-if="appConfig.is_open_nearby"
class="m-l-16 flex white row-center"
to="/bundle_b/pages/city/city"
>
<text class="m-r-6">{{ cityInfo.name || '选择' }}</text>
<u-icon name="arrow-down" size="24" color="#FFFFFF"></u-icon>
<!-- <image class="icon-md m-l-30" src="/static/images/icon_news.png">
</image> -->
</router-link>
<view class="flex-1">
<router-link to="/pages/goods_search/goods_search">
<u-search
wrap-bg-color="transparent"
bg-color="#fff"
:disabled="true"
:height="62"
>
</u-search>
</router-link>
</view>
<!-- #ifdef MP -->
<view class="capsule-tips flex row-between" v-if="offPrompt">
<text class="m-r-10">添加到”我的小程序”,红包、优惠不错过</text>
<u-icon
name="close"
color="#FFFFFF"
@click="clearIntervalFunc"
></u-icon>
</view>
<!-- #endif -->
</view>
</u-navbar>
<view class="flex">
<view class="flex-1" style="min-width: 600rpx">
<u-tabs
active-color="#fff"
inactive-color="#fff"
:current="active"
:list="cateList"
bg-color="transparent"
:active-item-style="{ fontSize: '32rpx' }"
:bar-width="64"
:bold="false"
:barStyle="{
background:
'linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, #FFFFFF 49%, rgba(255, 255, 255, 0) 100%)'
}"
@change="changeActive"
>
</u-tabs>
</view>
<router-link to="/pages/goods_cate/goods_cate" navType="pushTab">
<view class="white flex cate-btn m-l-10">
<image
class="icon-xs m-r-4"
src="/static/images/icon_cate.png"
alt=""
/>
分类
</view>
</router-link>
</view>
</view>
</u-sticky>
<view class="tab-con">
<scroll-view class="index_css" scroll-y="true" v-show="active == 0" :style="[positionTop]" >
<index-home
ref="indexHome"
:top="cateTop"
:home-data="homeData"
:nav-list="navList"
:live-list="liveLists"
>
</index-home>
<goods-column ref="mescrollItem" :autoGetData="false"></goods-column>
</scroll-view>
<template v-for="(item, index) in cateList">
<view
v-if="index > 0"
class="tab-item"
v-show="active == index"
:key="index"
>
<view>
<cate-home
v-if="showCateList[index]"
:top="cateTop"
ref="cateItem"
:i="index"
:index="active"
:cate="item"
>
</cate-home>
</view>
</view>
</template>
</view>
</view>
<!-- #ifdef APP-PLUS -->
<lyg-popup
v-if="appConfig.app_agreement"
title="用户使用及隐私保护政策提示"
protocolPath="/bundle/pages/server_explan/server_explan?type=0"
policyPath="/bundle/pages/server_explan/server_explan?type=1"
policyStorageKey="has_read_privacy"
>
</lyg-popup>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<!-- 用户隐私协议弹框 -->
<privacy-popup v-model="showPrivacyPopup"></privacy-popup>
<!-- #endif -->
</mescroll-body>
<!-- #ifdef H5 -->
<view class="record_number">
<a :href="appConfig.icp_link" style="color: #495770; text-decoration: none">
{{ appConfig.icp_number }}
</a>
</view>
<!-- #endif -->
<tabbar></tabbar>
<!-- 无网络提示 -->
<u-no-network z-index="1200" @retry="handleRetry"></u-no-network>
</view>
</template>
<script>
import MescrollCompMixin from '@/components/mescroll-uni/mixins/mescroll-comp'
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
import { mapGetters, mapMutations, mapActions } from 'vuex'
import { getMenu, getHome, getHotGoods, getLevelOneList } from '@/api/store'
import { getConfig } from '@/api/app'
import { getLiveLists } from '@/api/live'
import { getRect } from '@/utils/tools'
const app = getApp()
const homeItem = {
name: '首页'
}
export default {
mixins: [MescrollMixin, MescrollCompMixin],
data() {
return {
offPrompt: true,
active: 0,
navBg: 0,
goodsList: [],
homeData: {},
navList: [],
enable: true,
cateList: [homeItem],
showCateList: [],
liveLists: [],
showPrivacyPopup: false //微信用户隐私协议
}
},
async onLoad(options) {
// #ifdef MP-WEIXIN
wx.getPrivacySetting({
success: (res) => {
console.log(res, '------') // 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' }
if (res.needAuthorization) {
// 需要弹出隐私协议
this.showPrivacyPopup = true
}
},
fail: (err) => {
console.log(err)
}
})
// #endif
// 选择城市后是否刷新
if (options?.refresh) await this.getHomeFun()
// 监听是否刷新页面,目前秒杀时会用到
uni.$on('refreshhome', () => {
this.getHomeFun()
})
// #ifdef MP-WEIXIN
this.getLiveListsFun()
// #endif
},
onUnload() {
uni.$off('refreshhome')
},
onShow() {
this.enable = this.active == 0 ? true : false
this.getCartNum()
},
onHide() {
// #ifdef H5
this.enable = false
// #endif
},
onReady() {
// #ifdef MP
// 关闭胶囊提示
this.offPromptFunc()
// #endif
},
methods: {
...mapActions(['getCartNum', 'getUser', 'initLocationFunc']),
...mapMutations(['setConfig']),
// 网络重试刷新网络请求解决在ios中首次进入时需要授权蜂窝加载空白页面问题
async handleRetry() {
console.log('网络重试刷')
const { code, data } = await getConfig()
if (code == 1) {
this.setConfig(data)
if (data.is_open_nearby) {
// 获取定位
this.initLocationFunc()
}
}
this.getUser()
},
// #ifdef MP
offPromptFunc() {
let time = 8
this.offPrompt = setInterval(() => {
time -= 1
if (time <= 0) this.clearIntervalFunc()
}, 1000)
},
clearIntervalFunc() {
clearInterval(this.offPrompt)
this.offPrompt = false
},
// #endif
// 获取1级分类
async getLevelOneListFun() {
const { code, data } = await getLevelOneList()
if (code == 1) {
this.cateList = [homeItem, ...data]
this.showCateList = []
}
},
// 获取菜单
async getMenuFun() {
const { code, data } = await getMenu({
type: 1
})
if (code == 1) {
this.navList = data
}
},
// 获取首页数据
async getHomeFun() {
const { code, data } = await getHome({ city_id: this.cityInfo.id })
if (code == 1) {
this.homeData = data
}
},
// #ifdef MP-WEIXIN
async getLiveListsFun() {
const { code, data } = await getLiveLists({ page_size: 6, page_no: 1 })
if (code == 1) {
this.liveLists = data.list
}
},
// #endif
changeActive(index) {
this.active = index
this.enable = index == 0
this.mescroll.optDown.use = index == 0
this.showCateList[index] = true
},
async downCallback() {
await this.getLevelOneListFun()
await this.getMenuFun()
await this.getHomeFun()
// #ifdef MP-WEIXIN
this.getLiveListsFun()
// #endif
this.$refs.mescrollItem.getData()
this.mescroll.endSuccess(0, false)
}
},
computed: {
...mapGetters(['sysInfo', 'inviteCode', 'appConfig', 'cityInfo']),
navH() {
return this.sysInfo.navHeight + 'px'
},
positionTop() {
return { 'height': `calc(100vh - 100rpx - ${this.cateTop})` }
},
// 分类栏悬浮高度
cateTop() {
return this.sysInfo.navHeight + uni.upx2px(80) + 'px'
},
headerStyle() {
const { active, cateList, appConfig } = this
let bg = cateList[active].bg_image
if (active == 0) {
bg = appConfig.index_setting.top_bg_image
}
return bg
? {
'background-image': `url(${bg})`
}
: {}
}
}
}
</script>
<style lang="scss">
page {
padding: 0;
}
.index_css{
overflow: auto;
padding-bottom: env(safe-area-inset-bottom);
}
.index-bg {
background-image: url('../../static/images/index_bg.png');
background-size: 100% auto;
background-repeat: no-repeat;
}
.index {
min-height: calc(100vh - var(--window-bottom));
.u-navbar {
::v-deep .u-search {
padding: 0 30rpx;
}
}
// 胶囊提示
.capsule-tips {
width: 584rpx;
color: #ffffff;
padding: 12rpx 18rpx;
border-radius: 14rpx;
background: rgba(0, 0, 0, 0.7);
position: relative;
position: absolute;
z-index: 9999;
bottom: -80rpx;
right: -150rpx;
}
.capsule-tips::after {
content: '';
border-bottom: 14rpx solid rgba(0, 0, 0, 0.7);
border-right: 14rpx solid transparent;
border-left: 14rpx solid transparent;
position: absolute;
top: -14rpx;
right: 88rpx;
}
.cate-btn {
padding: 12rpx 16rpx 12rpx 20rpx;
border-radius: 60rpx 0 0 60rpx;
background-color: rgba(256, 256, 256, 0.4);
}
}
.record_number {
text-align: center;
padding: 30rpx;
font-size: 24rpx;
}
</style>

View File

@ -230,11 +230,12 @@ import {
smsCodeLogin,
opLogin,
authLogin,
updateUser
updateUser,
scanLogin
} from '@/api/app'
import { bindSuperior } from '@/api/user'
import wechath5 from '@/utils/wechath5'
import { isWeixinClient, currentPage, client, trottle } from '@/utils/tools'
import { isWeixinClient, currentPage, client, trottle, strToParams } from '@/utils/tools'
import { SMSType } from '@/utils/type'
import Cache from '@/utils/cache'
import { BACK_URL, INVITE_CODE } from '@/config/cachekey'
@ -259,11 +260,14 @@ export default {
showLoginPop: false,
loginData: {},
showModel: false,
phoneLogin: false
phoneLogin: false,
scanParams: {},
isScanEntry: false
}
},
async onLoad(option) {
async onLoad(args) {
// this.initScanParams()
this.mnpLoginFun = trottle(this.mnpLoginFun)
this.appWxLogin = trottle(this.appWxLogin)
this.getCodeUrl = trottle(this.getCodeUrl)
@ -276,6 +280,64 @@ export default {
methods: {
...mapMutations(['login']),
...mapActions(['getUser']),
initScanParams() {
const backUrl = Cache.get(BACK_URL)
console.log("🚀 ~ backUrl:", backUrl)
if (!backUrl || typeof backUrl !== 'string') {
this.isScanEntry = false
return
}
const href = backUrl.includes('?') ? backUrl.split('?')[0] : ''
const queryString = backUrl.includes('?') ? backUrl.split('?')[1] : ''
if (!queryString) {
this.isScanEntry = false
return
}
if (!queryString && !href && href != '/bundle/pages/user_spread/user_spread') {
this.isScanEntry = false
return
}
let scanQuery = {}
try {
scanQuery = strToParams(queryString)
} catch (error) {
scanQuery = {}
}
// scene 里可能还包了一层参数,如 scene=type%3Dxx%26id%3D1
if (scanQuery.scene && typeof scanQuery.scene === 'string') {
try {
const sceneQuery = strToParams(decodeURIComponent(scanQuery.scene))
scanQuery = {
...scanQuery,
...sceneQuery
}
} catch (error) {}
}
console.log("🚀 ~ Object.keys(scanQuery):", Object.keys(scanQuery).length)
console.log("🚀 ~ href:", href)
console.log(scanQuery.type)
if (href && href == '/bundle/pages/user_spread/user_spread' && Object.keys(scanQuery).length > 0 && scanQuery.type) {
this.isScanEntry = true
} else {
this.isScanEntry = false
}
},
async handleScanLogin() {
if (!this.isScanEntry) return true
const { code, msg } = await scanLogin(this.scanParams)
if (code != 1) {
this.$toast({
title: msg || '扫码登录处理失败'
})
return false
}
return true
},
// 开启小程序微信授权
isOaWxAuth() {
const { h5_wechat_auth } = this.appConfig
@ -337,6 +399,7 @@ export default {
nickname: nickName,
headimgurl: avatarUrl
})
console.log("🚀 ~ data:", data)
if (code == 1) {
if (data.is_new_user) {
uni.hideLoading()
@ -407,6 +470,8 @@ export default {
async loginHandle(data) {
this.login(data)
uni.hideLoading()
const scanSuccess = await this.handleScanLogin()
if (!scanSuccess) return
// 绑定邀请码
const inviteCode = Cache.get(INVITE_CODE)
if (inviteCode) {