diff --git a/App.vue b/App.vue index 06bc6d5..14cb274 100644 --- a/App.vue +++ b/App.vue @@ -1,15 +1,79 @@ - \ No newline at end of file diff --git a/pages/index/components/advertisement.vue b/pages/index/components/advertisement.vue index 5210af0..0a7269a 100644 --- a/pages/index/components/advertisement.vue +++ b/pages/index/components/advertisement.vue @@ -32,7 +32,10 @@ \ No newline at end of file diff --git a/pages/index/coupons/index.vue b/pages/index/coupons/index.vue new file mode 100644 index 0000000..3c31449 --- /dev/null +++ b/pages/index/coupons/index.vue @@ -0,0 +1,655 @@ + + + + + + \ No newline at end of file diff --git a/pages/index/drinks.vue b/pages/index/drinks.vue new file mode 100644 index 0000000..80a8b20 --- /dev/null +++ b/pages/index/drinks.vue @@ -0,0 +1,673 @@ + + + + + \ No newline at end of file diff --git a/pages/index/freedaily.vue b/pages/index/freedaily.vue new file mode 100644 index 0000000..2cffa2c --- /dev/null +++ b/pages/index/freedaily.vue @@ -0,0 +1,377 @@ + + + + + \ No newline at end of file diff --git a/pages/index/index.vue b/pages/index/index.vue index 2bdd403..6cfdfcd 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -5,7 +5,8 @@ - + + @@ -22,16 +23,20 @@ - + :class="!item.isChild && viewHistoryindex == index ? 'fourcontent_itemactev':''"> {{item.name}} - + + + + + @@ -129,10 +134,9 @@ - - + @@ -141,7 +145,10 @@ ref, computed, onMounted, - reactive + reactive, + onBeforeUnmount, + watch, + getCurrentInstance } from "vue"; import { onLoad, @@ -150,21 +157,27 @@ onReachBottom, onPageScroll } from '@dcloudio/uni-app' + // 获取全局属性 + const { + proxy + } = getCurrentInstance(); import swipers from './components/swiper.vue' //引入轮播 import advertisement from './components/advertisement.vue' //广告 import diamond from './components/diamond.vue' //金刚区 import todaylist from './components/todaylist.vue' //今日上线 - // import popupad from '@/components/popupad.vue' - // import productlist from './components/productlist.vue' - // import category from '@/components/qiyue-category/qiyue-category.vue'; - // import indexs from './indexs.vue'; + import indexs from './indexs.vue'; + import AreaSelect from './components/AreaSelect.vue'; //城市联动 + import grouping from './components/grouping.vue'; //其他 import Nav from '@/components/indexnav.vue'; //导航栏 - import API from "@/common/js/api.js" + import { + APIhomehomePageUp, + APIhome, + APIshopUserInfo + } from "@/common/api/index/index.js" import { useNavbarStore } from '@/stores/navbarStore'; const store = useNavbarStore(); - // 动态更新导航栏配置 store.updateNavbarConfig({ showBack: true, //左边返回键 @@ -178,8 +191,8 @@ const showindex = ref('index') //计算广告图片的重合尺寸是位移 const getStyle = (e) => { - if (e > hometoplist.bannerVO.counponsInfo.length / 2) { - var right = hometoplist.bannerVO.counponsInfo.length - e + if (e > hometoplist.bannervo.counponsInfo.length / 2) { + var right = hometoplist.bannervo.counponsInfo.length - e return { transform: 'scale(' + (1) + ') translate(-' + (right * 20) + '%,0px)', zIndex: 9999 - right, @@ -193,20 +206,22 @@ } } } - const advertisementStyle = ref([{ - transform: 'scale(' + (1) + ') translate(-' + (0 * 20) + '%,0px)', - zIndex: 9999, - opacity: 1 - }]) + const advertisementStyle = ref([]) + const refbannervo = ref(null); //数据 - const hometoplist = reactive({}) + const hometoplist = reactive({ + bannervo: { + counponsInfo: [], + coupons: '' + } + }) // 首页上面数据 const hometop = async () => { try { - let res = await API.homehomePageUp() + let res = await APIhomehomePageUp() Object.assign(hometoplist, res.data) - if (hometoplist.bannerVO.counponsInfo) { - hometoplist.bannerVO.counponsInfo.forEach((item, index) => { + if (hometoplist.bannervo.counponsInfo) { + hometoplist.bannervo.counponsInfo.forEach((item, index) => { advertisementStyle.value.push(getStyle(index)) }) } @@ -232,7 +247,7 @@ const homelist = ref([]) //接收数据 const onLoadhome = async () => { try { - let res = await API.home(formhomelist) + let res = await APIhome(formhomelist) var dates = new Date().getTime(); res.data.list.forEach((item, index) => { var leftTime = item.endTime - dates; //计算两日期之间相差的毫秒数 @@ -288,16 +303,21 @@ }) onLoadhome() } - const updateCity = async (data) => { - console.log(data) - // this.list[data].end_times = 0; - } + // 弹出层处理 + const showproductlist = ref(false); + // 定义方法 + const openproductlist = (e) => { + hometoplist.menu[viewHistoryindex.value].name = e //下标更改name + showproductlist.value = !showproductlist.value + } // 存储每个元素距离顶部的距离 const elementTop = ref(0); // 存储是否吸顶的状态 const isSticky = ref(true); + //下标 + const viewHistoryindex = ref(null) // 点击滑动元素 const viewHistory = async (item, index) => { if (isSticky) { @@ -306,7 +326,12 @@ duration: 300 }); } - + // 是否有弹出层 + if (item.isChild) { + showproductlist.value = showproductlist.value ? viewHistoryindex.value == index ? false : true : ! + showproductlist.value + } + viewHistoryindex.value = index } // 滑动 onPageScroll((res) => { @@ -315,86 +340,71 @@ }); onShow(() => {}) onMounted(async () => { - // 获取初始定位高度 - setTimeout(() => { - const query = uni.createSelectorQuery().select('#fourcontent'); - query.boundingClientRect((rect) => { - console.log(rect.top, 111) - elementTop.value = rect.top - store.height - }).exec(); - }, 500) - // 查询是否有无内存 + await proxy.$onLaunched; + console.log(uni.cache.get('shopId')) if (uni.cache.get('shopId') && uni.cache.get('token')) { showindex.value = 'shopIndex' - uni.cache.set('types', 'index'); - let res = await API.shopUserInfo({ + let res = await APIshopUserInfo({ "shopId": uni.cache.get('shopId'), - "userId": uni.cache.get('userInfo').id, + "userId": uni.getStorageSync('userInfo').id, }) if (res.code == 0) { - shopUserInfo = res.data - // uni.cache.set('shopUserInfo', this.shopUserInfo) + //商家信息 + uni.cache.set('shopUserInfo', res.data) } - if (uni.cache.get('forceUpdate') == 1) { - // this.forceUpdate = !this.forceUpdate; - } - // this.getShopExtend() } else { - uni.getLocation({ - type: 'wgs84', - success: async (res) => { - // console.log(res) - let successres = await API.geocodelocation({ - lng: res.longitude, - lat: res.latitude, - }) - if (successres.code == 0) { - let datastorage = { - country: successres.data.addressComponent.country, // "中国" - province: successres.data.addressComponent - .province, //province: "陕西省" - address: successres.data.addressComponent.city, //district: "西安市" - district: successres.data.addressComponent - .district, //district: "未央区" - lng: res.longitude, - lat: res.latitude, - } - uni.cache.set('getLocationstorage', datastorage); - } - }, - fail: async (err) => { - showindex.value = 'index' - } - }); + hometop() + init_fn() + showindex.value = 'index' + // 获取初始定位高度 + setTimeout(() => { + const query = uni.createSelectorQuery().select('#fourcontent'); + query.boundingClientRect((rect) => { + elementTop.value = rect.top - store.height + }).exec(); + }, 500) } - hometop() - init_fn() - - }); + onReachBottom(() => { onLoadhome() }) - onLoad(() => { - }) + // 页面离开时清除定时器 + // onBeforeUnmount(() => { + // if (refbannervo.value) { + // refbannervo.value.clearTimer(); + // } + // }); - \ No newline at end of file diff --git a/pages/index/tothestore.vue b/pages/index/tothestore.vue new file mode 100644 index 0000000..3360fe3 --- /dev/null +++ b/pages/index/tothestore.vue @@ -0,0 +1,335 @@ + + + + + \ No newline at end of file diff --git a/pages/product/index.vue b/pages/product/index.vue new file mode 100644 index 0000000..c0921fa --- /dev/null +++ b/pages/product/index.vue @@ -0,0 +1,47 @@ + + + + + \ No newline at end of file diff --git a/pages/user/address/edit.vue b/pages/user/address/edit.vue new file mode 100644 index 0000000..a4bad07 --- /dev/null +++ b/pages/user/address/edit.vue @@ -0,0 +1,321 @@ + + + + \ No newline at end of file diff --git a/pages/user/address/index.vue b/pages/user/address/index.vue new file mode 100644 index 0000000..b30cfc4 --- /dev/null +++ b/pages/user/address/index.vue @@ -0,0 +1,244 @@ + + + + + \ No newline at end of file diff --git a/pages/user/coupon.vue b/pages/user/coupon.vue new file mode 100644 index 0000000..b91d16d --- /dev/null +++ b/pages/user/coupon.vue @@ -0,0 +1,659 @@ + + + + + \ No newline at end of file diff --git a/pages/user/my_info.vue b/pages/user/my_info.vue new file mode 100644 index 0000000..112123e --- /dev/null +++ b/pages/user/my_info.vue @@ -0,0 +1,453 @@ + + + + + diff --git a/pages/user/repairpassword.vue b/pages/user/repairpassword.vue new file mode 100644 index 0000000..18c4187 --- /dev/null +++ b/pages/user/repairpassword.vue @@ -0,0 +1,254 @@ + + + + \ No newline at end of file diff --git a/pages/user/repairpasswordtwo.vue b/pages/user/repairpasswordtwo.vue new file mode 100644 index 0000000..aa857be --- /dev/null +++ b/pages/user/repairpasswordtwo.vue @@ -0,0 +1,223 @@ + + + + \ No newline at end of file diff --git a/pages/user/shop/confirm.vue b/pages/user/shop/confirm.vue new file mode 100644 index 0000000..2f3c94b --- /dev/null +++ b/pages/user/shop/confirm.vue @@ -0,0 +1,692 @@ + + + + + \ No newline at end of file diff --git a/pages/user/shop/detail.vue b/pages/user/shop/detail.vue new file mode 100644 index 0000000..8374a9f --- /dev/null +++ b/pages/user/shop/detail.vue @@ -0,0 +1,341 @@ + + + + + \ No newline at end of file diff --git a/pages/user/shop/index.vue b/pages/user/shop/index.vue new file mode 100644 index 0000000..22e5f99 --- /dev/null +++ b/pages/user/shop/index.vue @@ -0,0 +1,418 @@ + + + + + \ No newline at end of file diff --git a/pages/user/shop/shopinfo.vue b/pages/user/shop/shopinfo.vue new file mode 100644 index 0000000..c84bfb5 --- /dev/null +++ b/pages/user/shop/shopinfo.vue @@ -0,0 +1,560 @@ + + + + + \ No newline at end of file diff --git a/pages/user/user.vue b/pages/user/user.vue new file mode 100644 index 0000000..4a66e6d --- /dev/null +++ b/pages/user/user.vue @@ -0,0 +1,276 @@ + + + + + \ No newline at end of file diff --git a/static/tabbar/1-1.png b/static/tabbar/1-1.png new file mode 100644 index 0000000..f956a5e Binary files /dev/null and b/static/tabbar/1-1.png differ diff --git a/static/tabbar/1.png b/static/tabbar/1.png new file mode 100644 index 0000000..335b742 Binary files /dev/null and b/static/tabbar/1.png differ diff --git a/static/tabbar/2-1.png b/static/tabbar/2-1.png new file mode 100644 index 0000000..6d77998 Binary files /dev/null and b/static/tabbar/2-1.png differ diff --git a/static/tabbar/2.png b/static/tabbar/2.png new file mode 100644 index 0000000..63973d1 Binary files /dev/null and b/static/tabbar/2.png differ diff --git a/static/tabbar/3-1.png b/static/tabbar/3-1.png new file mode 100644 index 0000000..5e14362 Binary files /dev/null and b/static/tabbar/3-1.png differ diff --git a/static/tabbar/3.png b/static/tabbar/3.png new file mode 100644 index 0000000..1f0b10a Binary files /dev/null and b/static/tabbar/3.png differ diff --git a/static/tabbar/4-1.png b/static/tabbar/4-1.png new file mode 100644 index 0000000..e0e5ad2 Binary files /dev/null and b/static/tabbar/4-1.png differ diff --git a/static/tabbar/4.png b/static/tabbar/4.png new file mode 100644 index 0000000..9a197fe Binary files /dev/null and b/static/tabbar/4.png differ diff --git a/stores/navbarStore.js b/stores/navbarStore.js index 357246e..2180679 100644 --- a/stores/navbarStore.js +++ b/stores/navbarStore.js @@ -1,45 +1,50 @@ -import { defineStore } from 'pinia'; - +import { + defineStore +} from 'pinia'; +import { + ref +} from 'vue'; export const useNavbarStore = defineStore('navbar', { - state: () => ({ - showBack: true, - rightText: '', - showSearch: false, - title: '', - isTransparent: false, - height: 0, - hasPlaceholder: true, + state: () => ({ + showBack: true, + rightText: '', + showSearch: false, + title: '', + isTransparent: false, + height: 0, + hasPlaceholder: true, scrollTop: 0 //滚动高度 - }), - actions: { - updateNavbarConfig(config) { - Object.assign(this, config); - }, - initNavbarHeight() { - uni.getSystemInfo({ - success: (res) => { - const statusBarHeight = res.statusBarHeight; - let navBarHeight; + }), + actions: { + updateNavbarConfig(config) { + Object.assign(this, config); + }, + initNavbarHeight() { + uni.getSystemInfo({ + success: (res) => { + const statusBarHeight = res.statusBarHeight; + let navBarHeight; - // 微信小程序的特殊处理 - if (res.platform === 'weapp') { - const menuButtonInfo = uni.getMenuButtonBoundingClientRect(); - const topGap = menuButtonInfo.top - statusBarHeight; - const bottomGap = statusBarHeight + menuButtonInfo.height + topGap * 2 - (menuButtonInfo.top + menuButtonInfo.height); - navBarHeight = menuButtonInfo.height + topGap + bottomGap; - } else if (uni.getSystemInfoSync().platform === 'ios') { - navBarHeight = 44; - } else { - navBarHeight = 48; - } + // 微信小程序的特殊处理 + if (res.platform === 'weapp') { + const menuButtonInfo = uni.getMenuButtonBoundingClientRect(); + const topGap = menuButtonInfo.top - statusBarHeight; + const bottomGap = statusBarHeight + menuButtonInfo.height + topGap * 2 - ( + menuButtonInfo.top + menuButtonInfo.height); + navBarHeight = menuButtonInfo.height + topGap + bottomGap; + } else if (uni.getSystemInfoSync().platform === 'ios') { + navBarHeight = 44; + } else { + navBarHeight = 48; + } - this.height = statusBarHeight + navBarHeight; - }, - fail: (err) => { - console.error('获取系统信息失败:', err); - this.height = 64; // 失败时设置一个默认高度 - } - }); - } - } + this.height = statusBarHeight + navBarHeight; + }, + fail: (err) => { + console.error('获取系统信息失败:', err); + this.height = 64; // 失败时设置一个默认高度 + } + }); + } + } }); \ No newline at end of file diff --git a/stores/share.js b/stores/share.js new file mode 100644 index 0000000..4446941 --- /dev/null +++ b/stores/share.js @@ -0,0 +1,88 @@ +import { + defineStore +} from 'pinia'; +import { + ref +} from 'vue'; +import { + APIcustomlogin +} from '@/common/api/api.js' + +export const Storelogin = defineStore('login', { + state: () => ({ + token: '', + miniAppOpenId: '', + userInfo: '' + }), + actions: { + actionslogin() { + return new Promise((resolve, reject) => { + // #ifdef MP-WEIXIN + uni.login({ + provider: 'weixin', + success: (data) => { + // 微信小程序环境 + uni.getUserInfo({ + provider: 'weixin', + success: async (infoRes) => { + let res = await APIcustomlogin({ + code: data.code, //临时登录凭证 + rawData: infoRes.rawData, + source: 'wechat' + }) + if (res.code == 0) { + this.token = res.data.token + this.miniAppOpenId = res.data.userInfo + .miniAppOpenId + this.userInfo = res.data.userInfo + uni.cache.set('token', res.data.token); + uni.cache.set('miniAppOpenId', res.data + .userInfo + .miniAppOpenId) + uni.cache.set('userInfo', res.data + .userInfo); + } + resolve(true); + }, + fail: (err) => { + reject(false); + } + }); + } + }); + // #endif + // #ifdef MP-ALIPAY + my.getAuthCode({ + scopes: 'auth_base', + success: async (data) => { + console.log(data) + // 支付宝小程序环境 + // my.getAuthUserInfo({ + // success: async (infoRes) => { + let res = await APIcustomlogin({ + code: data.authCode, //临时登录凭证 + // rawData: JSON.stringify(infoRes), + source: 'alipay' + }) + if (res.code == 0) { + this.token = res.data.token + this.miniAppOpenId = res.data.userInfo.miniAppOpenId + this.userInfo = res.data.userInfo + uni.cache.set('token', res.data.token); + uni.cache.set('miniAppOpenId', res.data.userInfo + .miniAppOpenId) + uni.cache.set('userInfo', res.data.userInfo); + resolve(true); + } + }, + fail: (err) => { + reject(false); + } + }); + } + }); + // #endif + }).catch((e) => {}); +} +} +}); \ No newline at end of file