Commit 0bace7fd authored by June's avatar June

feat:首页,详情页,分类,登录,店铺详情添加分享;fixed:商品详情页顶部滚动渐变优化

parent 996d6872
...@@ -12,7 +12,6 @@ export default { ...@@ -12,7 +12,6 @@ export default {
const token = this.$getStorage('token') const token = this.$getStorage('token')
this.$store.state.user.token = token this.$store.state.user.token = token
this.getStoreInfo() // 这个接口一定要先获取,因为如果店铺过期 this.getStoreInfo() // 这个接口一定要先获取,因为如果店铺过期
// wx.login // wx.login
login_wx() login_wx()
...@@ -29,7 +28,14 @@ export default { ...@@ -29,7 +28,14 @@ export default {
}) })
}, },
onShow() { globalData: {
backHome: false // 根据分享进入场景,自定义返回是否是返回首页
},
onShow(ops) {
if([1007, 1008, 1154, 1155].includes(ops.scene)) {
this.globalData.backHome = true
}
if(!this.$store.state.systemInfo.menuCalcInfo) { if(!this.$store.state.systemInfo.menuCalcInfo) {
this.setMobileData() this.setMobileData()
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<script> <script>
import { mapState } from 'vuex' import { mapState } from 'vuex'
const app = getApp()
export default { export default {
props: { props: {
color: { color: {
...@@ -54,8 +55,17 @@ export default { ...@@ -54,8 +55,17 @@ export default {
}, },
methods: { methods: {
handleBack() { handleBack() {
uni.navigateBack() const { backHome } = app.globalData
if(backHome) {
uni.switchTab({
url: '/pages/home/index'
})
} else {
uni.navigateBack()
}
} }
} }
} }
......
import { getURLwithArgs } from '@/utils/common.js'
import { mapState } from 'vuex'
import { baseUrl } from '@/config/index.js'
const common_share = {
computed: {
...mapState({
storeInfo: state => state.user.storeInfo
}),
judgePages() {
const path = getURLwithArgs()
let imageUrl = ''
let title = this.storeInfo.shop_name
if(path && path.startsWith('pages/goods/detail')) {
imageUrl = (this.detail && this.detail.goods_thumb) ? `${baseUrl}/${this.detail.goods_thumb}` : ''
title = this.detail ? this.detail.goods_name : ''
}
return {
path, imageUrl, title
}
}
},
onShareAppMessage() {
return this.judgePages
},
onShareTimeline() {
return this.judgePages
}
}
export default common_share
\ No newline at end of file
...@@ -74,73 +74,88 @@ ...@@ -74,73 +74,88 @@
} }
} }
], ],
"subPackages": [{ "subPackages": [
"root": "subPages", {
"pages": [ "root": "subPages",
{ "pages": [
"path": "resetPwd/index", {
"style": { "path": "resetPwd/index",
"navigationBarTitleText": "重置密码" "style": {
} "navigationBarTitleText": "重置密码"
}, }
{ },
"path": "userManage/index", {
"style": { "path": "userManage/index",
"navigationBarTitleText": "账号管理" "style": {
} "navigationBarTitleText": "账号管理"
}, }
{ },
"path": "collection/index", {
"style": { "path": "collection/index",
"navigationBarTitleText": "收藏历史" "style": {
} "navigationBarTitleText": "收藏历史"
}, }
{ },
"path": "address/index", {
"style": { "path": "address/index",
"navigationBarTitleText": "地址列表", "style": {
"enablePullDownRefresh": true, "navigationBarTitleText": "地址列表",
"onReachBottomDistance": 50 "enablePullDownRefresh": true,
} "onReachBottomDistance": 50
}, }
{ },
"path": "address/edit", {
"style": { "path": "address/edit",
"navigationBarTitleText": "添加地址" "style": {
} "navigationBarTitleText": "添加地址"
}, }
{ },
"path": "web-view/index", {
"style": { "path": "web-view/index",
"navigationBarTitleText": " " "style": {
} "navigationBarTitleText": " "
}, }
{ },
"path": "storeInfo/index", {
"style": { "path": "storeInfo/index",
"navigationBarTitleText": "店铺详情" "style": {
} "navigationBarTitleText": "店铺详情"
}, }
{ },
"path": "afterSales/apply", {
"style": { "path": "afterSales/apply",
"navigationBarTitleText": "申请售后" "style": {
} "navigationBarTitleText": "申请售后"
}, }
{ },
"path": "afterSales/detail", {
"style": { "path": "afterSales/detail",
"navigationBarTitleText": "申请退款/退货" "style": {
"navigationBarTitleText": "申请退款/退货"
}
},
{
"path": "pay_status/index",
"style": {
"navigationBarTitleText": "支付结果"
}
} }
}, ]
{ },
"path": "pay_status/index", {
"style": { "root": "testA",
"navigationBarTitleText": "支付结果" "pages":[
{
"path": "pageA/index",
"style": {
"navigationBarTitleText": "收藏历史",
"navigationStyle":"custom"
},
"independent": true
} }
} ]
] }
}], ],
"preloadRule": { "preloadRule": {
"pages/home/index": { "pages/home/index": {
"network": "all", "network": "all",
......
...@@ -136,6 +136,7 @@ import price from '@/components/price/index.vue' ...@@ -136,6 +136,7 @@ import price from '@/components/price/index.vue'
import { getCatetories, cateGoodsList } from '@/apis/category.js' import { getCatetories, cateGoodsList } from '@/apis/category.js'
import { searchGoods, goodsSku } from '@/apis/goods.js' import { searchGoods, goodsSku } from '@/apis/goods.js'
import { baseUrl } from '@/config/index.js' import { baseUrl } from '@/config/index.js'
import common_share from '@/mixins/setting_share.js'
import { mapState, mapActions } from 'vuex' import { mapState, mapActions } from 'vuex'
let cat_id = 0 let cat_id = 0
...@@ -161,8 +162,7 @@ export default { ...@@ -161,8 +162,7 @@ export default {
computed: { computed: {
...mapState({ ...mapState({
token: state => state.user.token, token: state => state.user.token,
isOverdue: state => state.user.isOverdue, isOverdue: state => state.user.isOverdue
storeInfo: state => state.user.storeInfo
}) })
}, },
// async created() { // async created() {
...@@ -177,11 +177,7 @@ export default { ...@@ -177,11 +177,7 @@ export default {
} }
uni.hideLoading() uni.hideLoading()
}, },
onShareAppMessage() { mixins: [common_share],
return {
title: this.storeInfo.shop_name || ''
}
},
methods: { methods: {
...mapActions('cart', ['setCount']), ...mapActions('cart', ['setCount']),
async getCate() { async getCate() {
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
<view <view
class="wrapper w-100" class="wrapper w-100"
> >
<c-nav_bar <c-nav_bar
showBack showBack
title="商品详情" title="商品详情"
:bg="navBg" :bg="navBg"
/> />
<!-- <left-menu-button /> -->
<!-- <left-menu-button /> -->
<view class="swiper-wrap"> <view class="swiper-wrap">
<swiper <swiper
...@@ -153,7 +153,7 @@ ...@@ -153,7 +153,7 @@
</template> </template>
<script> <script>
// import leftMenuButton from './components/left-menuButton.vue' import leftMenuButton from './components/left-menuButton.vue'
import uParse from '@/components/parse/parse.vue' import uParse from '@/components/parse/parse.vue'
import price from '@/components/price/index.vue' import price from '@/components/price/index.vue'
...@@ -162,6 +162,8 @@ import { goodDetail, goodsSku, collectGoods } from '@/apis/goods.js' ...@@ -162,6 +162,8 @@ import { goodDetail, goodsSku, collectGoods } from '@/apis/goods.js'
import { baseUrl } from '@/config/index.js' import { baseUrl } from '@/config/index.js'
import { makePhoneCall, throttle } from '@/utils/common.js' import { makePhoneCall, throttle } from '@/utils/common.js'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import common_share from '@/mixins/setting_share.js'
let goods_id = null let goods_id = null
export default { export default {
data() { data() {
...@@ -170,6 +172,7 @@ export default { ...@@ -170,6 +172,7 @@ export default {
mode: 'widthFix', mode: 'widthFix',
lazyLoad: true lazyLoad: true
}, },
showHome: false,
baseUrl, baseUrl,
detail: null, detail: null,
swiperCurrent: 0, swiperCurrent: 0,
...@@ -181,8 +184,9 @@ export default { ...@@ -181,8 +184,9 @@ export default {
navBg: "rgba(255, 255, 255, 0)" navBg: "rgba(255, 255, 255, 0)"
} }
}, },
mixins: [common_share],
components: { components: {
// leftMenuButton, leftMenuButton,
uParse, uParse,
price, price,
goodsPopup goodsPopup
...@@ -195,8 +199,7 @@ export default { ...@@ -195,8 +199,7 @@ export default {
computed: { computed: {
...mapState({ ...mapState({
cart_count: state => state.cart.cart_count, cart_count: state => state.cart.cart_count
storeInfo: state => state.user.storeInfo
}), }),
logisticsTab() { logisticsTab() {
...@@ -221,20 +224,28 @@ export default { ...@@ -221,20 +224,28 @@ export default {
}, },
}, },
onShareAppMessage() { // onShareAppMessage() {
const goods_thumb = this.detail.goods_thumb // const goods_thumb = this.detail.goods_thumb
const goods_name = this.detail.goods_name // const goods_name = this.detail.goods_name
return { // return {
title: goods_name || '', // title: goods_name || '',
image: goods_thumb ? `${this.baseUrl}/${goods_thumb}` : '' // image: goods_thumb ? `${this.baseUrl}/${goods_thumb}` : ''
} // }
}, // },
onPageScroll: throttle(function(e) { // onPageScroll: throttle(function(e) {
// const scrollTop = e.scrollTop
// if(scrollTop > 500) return
// const opacity = (scrollTop / 375).toFixed(1)
// this.navBg = `rgba(255, 255, 255, ${opacity})`
// }, 250),
onPageScroll(e) {
const scrollTop = e.scrollTop const scrollTop = e.scrollTop
if(scrollTop > 500) return
const opacity = (scrollTop / 375).toFixed(1) const opacity = (scrollTop / 375).toFixed(1)
if(opacity > 1.2) return
this.navBg = `rgba(255, 255, 255, ${opacity})` this.navBg = `rgba(255, 255, 255, ${opacity})`
}, 250), },
methods: { methods: {
// 富文本预览事件 // 富文本预览事件
preview(src, e) { preview(src, e) {
......
...@@ -192,7 +192,7 @@ import { baseUrl } from '@/config/index.js' ...@@ -192,7 +192,7 @@ import { baseUrl } from '@/config/index.js'
import { makePhoneCall, throttle } from '@/utils/common.js' import { makePhoneCall, throttle } from '@/utils/common.js'
import { goodsSku } from '@/apis/goods.js' import { goodsSku } from '@/apis/goods.js'
import { mapState, mapActions } from 'vuex' import { mapState, mapActions } from 'vuex'
import common_share from '@/mixins/setting_share.js'
export default { export default {
data() { data() {
return { return {
...@@ -217,10 +217,11 @@ export default { ...@@ -217,10 +217,11 @@ export default {
...mapState(['systemInfo']), ...mapState(['systemInfo']),
...mapState({ ...mapState({
isOverdue: state => state.user.isOverdue, isOverdue: state => state.user.isOverdue,
token: state => state.user.token, token: state => state.user.token
storeInfo: state => state.user.storeInfo
}) })
}, },
mixins: [common_share],
created() { created() {
// 实例化分页方法 // 实例化分页方法
...@@ -281,13 +282,7 @@ export default { ...@@ -281,13 +282,7 @@ export default {
this.navColor = '#fff' this.navColor = '#fff'
this.navBg = 'rgba(255, 255, 255, 0)' this.navBg = 'rgba(255, 255, 255, 0)'
} }
}, 300), }, 300),
onShareAppMessage() {
return {
title: this.storeInfo.shop_name || ''
}
},
onReachBottom() { onReachBottom() {
console.log('触底') console.log('触底')
......
...@@ -90,6 +90,7 @@ import { timerFn } from '@/utils/common.js' ...@@ -90,6 +90,7 @@ import { timerFn } from '@/utils/common.js'
import { loginSms } from '@/apis/user.js' import { loginSms } from '@/apis/user.js'
import { mapState, mapActions } from 'vuex' import { mapState, mapActions } from 'vuex'
import md5 from 'md5' import md5 from 'md5'
import common_share from '@/mixins/setting_share.js'
const userPlachelderStr = { const userPlachelderStr = {
1: '', 1: '',
2: '请输入手机号码', 2: '请输入手机号码',
...@@ -112,18 +113,13 @@ export default { ...@@ -112,18 +113,13 @@ export default {
computed: { computed: {
...mapState({ ...mapState({
session_key: state => state.user.session_key, session_key: state => state.user.session_key,
openid: state => state.user.openid, openid: state => state.user.openid
storeInfo: state => state.user.storeInfo
}), }),
userPlachelder() { userPlachelder() {
return userPlachelderStr[this.form.lgtype] return userPlachelderStr[this.form.lgtype]
} }
}, },
onShareAppMessage() { mixins: [common_share],
return {
title: this.storeInfo.shop_name || ''
}
},
methods: { methods: {
...common, ...common,
...mapActions('user', ['login']), ...mapActions('user', ['login']),
......
...@@ -50,10 +50,11 @@ ...@@ -50,10 +50,11 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex'
import { baseUrl } from '@/config/index.js' import { baseUrl } from '@/config/index.js'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { weeks } from '@/config/global.js' import { weeks } from '@/config/global.js'
// 引用了common_share 就不需要再在页面上引用vuex的storeInfo
import common_share from '@/mixins/setting_share.js'
export default { export default {
data() { data() {
return { return {
...@@ -61,9 +62,6 @@ export default { ...@@ -61,9 +62,6 @@ export default {
} }
}, },
computed: { computed: {
...mapState({
storeInfo: state => state.user.storeInfo
}),
startT() { startT() {
return weeks[this.storeInfo.business_week_start] || '' return weeks[this.storeInfo.business_week_start] || ''
}, },
...@@ -74,12 +72,7 @@ export default { ...@@ -74,12 +72,7 @@ export default {
return dayjs(this.storeInfo.add_time * 1000).format('YYYY-MM-DD') || '' return dayjs(this.storeInfo.add_time * 1000).format('YYYY-MM-DD') || ''
} }
}, },
onShareAppMessage() { mixins: [common_share]
const storeInfo = this.storeInfo
return {
title: storeInfo.shop_name || ''
}
},
} }
</script> </script>
......
<template>
<view>测试</view>
</template>
<script>
</script>
<style>
</style>
...@@ -89,3 +89,18 @@ export function makePhoneCall() { ...@@ -89,3 +89,18 @@ export function makePhoneCall() {
}) })
} }
} }
export function getURLwithArgs(){
const pages = getCurrentPages()
const currentPage = pages[pages.length-1]
const url = currentPage.route
const options = currentPage.options
//拼接url的参数
let urlWithArgs = `${url}?`
for(let key in options){
const value = options[key]
urlWithArgs += `${key}=${value}&`
}
urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length-1)
return urlWithArgs
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment