From c6ff84ca5d60e2ec020ea1e0ec4806205de51fec Mon Sep 17 00:00:00 2001 From: modendeveloper Date: Thu, 16 Jan 2025 00:33:42 +0800 Subject: [PATCH] =?UTF-8?q?Task=EF=BC=9A=E6=8C=87=E5=BC=95=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/FunctionGuide.vue | 186 +++++++++++++++++++++++++++++++++++ mixins/GuideMixins.js | 37 +++++++ pages/home/index.vue | 121 +++++++++++++++++++---- 3 files changed, 323 insertions(+), 21 deletions(-) create mode 100644 components/FunctionGuide.vue create mode 100644 mixins/GuideMixins.js diff --git a/components/FunctionGuide.vue b/components/FunctionGuide.vue new file mode 100644 index 0000000..82c66e6 --- /dev/null +++ b/components/FunctionGuide.vue @@ -0,0 +1,186 @@ + + + + + \ No newline at end of file diff --git a/mixins/GuideMixins.js b/mixins/GuideMixins.js new file mode 100644 index 0000000..25596e9 --- /dev/null +++ b/mixins/GuideMixins.js @@ -0,0 +1,37 @@ +export default { + data() { + return { + scrollView: '', + functionGuideData: { + step: 0, + tips: '', + tipsPosition: '', + btnGroupPosition: '', + position: {} + }, + screenWidth: 0, + scrollLeft: 0, + } + }, + onLoad() { + this.$refs.FunctionGuide.init() + }, + methods: { + setFunctionGuideData(data) { + this.functionGuideData = { + ...this.functionGuideData, + ...data + } + this.showFunctionGuide() + }, + getElementData(el, cb) { + const query = uni.createSelectorQuery().in(this) + query.select(el).boundingClientRect().exec((res)=> { + if(res[0]) { + cb(res[0]) + } + }) + }, + + } +} \ No newline at end of file diff --git a/pages/home/index.vue b/pages/home/index.vue index f7afb0a..55a5f3c 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -44,27 +44,30 @@ - + - - - - - {{ item.name }} + + + + + + {{ item.name }} + - + + + @@ -334,6 +338,7 @@ @ok="handleOk" paddingBottom="200rpx" /> + @@ -347,6 +352,8 @@ import { sharpBannar } from '@/api/goods' import { pageListenMixins } from '@/mixins/pageListenMixins' import ProductWindow from '@/components/ProductWindow' import goCartMixin from '@/mixins/goCartMixins' +import FunctionGuide from '@/components/FunctionGuide' +import GuideMixins from '@/mixins/GuideMixins' import { getCurAddress, getLocationPromise, @@ -358,9 +365,10 @@ export default { components: { XddTabbar, XddProductItem, - ProductWindow + ProductWindow, + FunctionGuide }, - mixins: [pageListenMixins, goCartMixin], + mixins: [pageListenMixins, goCartMixin, GuideMixins], data() { return { webUrl: this.$VUE_APP_RESOURCES_URL, @@ -433,6 +441,77 @@ export default { this.scrollTop = e.scrollTop }, methods: { + showFunctionGuide() { + if(this._step == this.functionGuideData.step) return + this._step = this.functionGuideData.step + if(this.functionGuideData.step == 1) { + this.getElementData('#step1', res=>{ + console.log(res); + this.screenWidth = res.width - 20 + this.setFunctionGuideData({ + tips: '介绍模块1,简述一下模块功能', + btnGroupPosition: '-120rpx', + tipsPosition: '420rpx', + position: { + top: 265 + 'px', + left: res.left + 10 + 'px', + width: `${res.width - 20}px`, + height: `${80 + 114 + 8 + 252 + 8}px`, + } + }) + }) + + }else { + this.getElementData(`#box-item${this.functionGuideData.step}`, res=>{ + console.log(res); + this.setFunctionGuideData({ + tips: '介绍模块2,简述一下模块功能', + btnGroupPosition: '', + tipsPosition: '', + position: { + top: res.top + 'px', + left: res.left + 'px', + width: `${res.width}px`, + height: `${res.height}px`, + } + }) + this.$nextTick(()=> { + this.scrollView = `box-item${this.functionGuideData.step}` + }) + }) + } + + // if(this.functionGuideData.step == 2) { + // this.getElementData('#box-item0', res=>{ + // this.setFunctionGuideData({ + // tips: '介绍模块2,简述一下模块功能', + // btnGroupPosition: '', + // tipsPosition: '', + // position: { + // top: res.top + 'px', + // left: res.left - 10 + 'px', + // width: `${res.height}px`, + // height: `${res.height}px` + // } + // }) + // }) + // }else if(this.functionGuideData.step == 3) { + // this.getElementData('#box-item1', res=>{ + // this.setFunctionGuideData({ + // tips: '介绍模块6,模块处于底部,需滚动页面', + // tipsPosition: '', + // position: { + // top: res.top + 'px', + // left: res.left - 10 + 'px', + // width: `${res.height}px`, + // height: `${res.height}px` + // } + // }) + // }) + // }else if(this.functionGuideData.step == 'jump') { + // this.intoView = 'top' + // } + }, played() { this.isPlay = !this.isPlay if(this.isPlay) { @@ -771,15 +850,15 @@ export default { display: flex; flex-shrink: 0; padding: 12rpx 24rpx; - margin: -120rpx 0 0 0; border-radius: 16rpx; background-color: #fff; overflow-x: auto; .item + .item { - margin: 0 0 0 36rpx; + // margin: 0 0 0 36rpx; } .item { width: 150rpx; + padding: 10rpx 20rpx; .img { width: 86rpx; height: 86rpx;