瀏覽代碼

新增盲票分享

hwb0 3 年之前
父節點
當前提交
10e2ff42fc
共有 1 個文件被更改,包括 84 次插入7 次删除
  1. 84 7
      pages/ticketBox/detail.vue

+ 84 - 7
pages/ticketBox/detail.vue

@@ -1,6 +1,17 @@
 <template>
 	<view>
-		<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="盲票详情"></u-navbar>
+		<view v-if="pagesNum > 1">
+			<u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="盲票详情"></u-navbar>
+		</view>
+		<view v-else>
+			<u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" title="盲票详情">
+				<view class="nav-left flex" slot="left" @click="toIndex">
+					<u-icon name="home" size="20" color="#333"></u-icon>
+					<view class="nav-left__code">首页</view>
+				</view>
+			</u-navbar>
+		</view>
+
 		<view class="detail">
 			<view class="detail-top">
 				<u-swiper :list="picUrlArr" height="320" radius="0" :indicator="true" :circular="true"></u-swiper>
@@ -46,6 +57,9 @@
 		<view class="footer-fixed">
 			<view class="flex btn">
 				<button type="default" @click="exchange">{{ info.salePrice / 100 }}元 立即开刮</button>
+				<view class="share" @click="toShare">
+					<u-icon name="share-square" color="#E96737" size="30"></u-icon>
+				</view>
 			</view>
 		</view>
 
@@ -69,19 +83,48 @@
 				prizeList: [],
 
 				payShow: false,
-				payInfo: {}
+				payInfo: {},
+				pagesNum: null,
+				sceneArr: null
 			};
 		},
+
 		onLoad(opthios) {
-			this.getDetail(opthios.id)
+			if (opthios.scene) {
+				let sceneStr = decodeURIComponent(opthios.scene)
+				this.sceneArr = sceneStr.split('&')
+				this.boxId = this.sceneArr[0]
+				uni.setStorageSync('shareUid', this.sceneArr[1])
+				uni.setStorageSync('shareType', this.sceneArr[2])
+			}
+
+			if (opthios.boxId) {
+				this.boxId = opthios.boxId
+			}
+			
+			if(opthios.userId){
+				uni.setStorageSync('shareUid', opthios.userId)
+			}
+			
+			if(opthios.type){
+				uni.setStorageSync('shareType', opthios.type)
+			}
 		},
+
+		onShow() {
+			this.pagesNum = getCurrentPages().length
+			if (this.boxId) {
+				this.getDetail()
+			}
+		},
+
 		methods: {
-			getDetail(id) {
+			getDetail() {
 				uni.showLoading({
 					title: '加载中'
 				});
 				$http.post('/api/v1/mp/user/mall/ticket/detail', {
-					boxId: id,
+					boxId: this.boxId,
 					noToken: true
 				}).then(res => {
 					uni.hideLoading();
@@ -103,6 +146,10 @@
 				})
 			},
 
+			getPageNum() {
+				let pages = getCurrentPages();
+			},
+
 			close() {
 				this.payShow = false
 			},
@@ -134,11 +181,35 @@
 					}
 				})
 			},
+
+			toShare() {
+				if (!uni.getStorageSync('token')) {
+					uni.navigateTo({
+						url: "/pages/login/index"
+					})
+					return
+				}
+				uni.navigateTo({
+					url: `/pages/share/index?boxId=${ this.info.boxId }`
+				})
+			},
+
+			toIndex() {
+				uni.switchTab({
+					url: '/pages/index/index'
+				})
+			}
 		}
 	}
 </script>
 
 <style lang="scss" scoped>
+	.nav-left {
+		&__code {
+			margin-left: 10rpx;
+		}
+	}
+
 	.detail {
 		padding-bottom: 100rpx;
 
@@ -300,10 +371,11 @@
 		padding-bottom: env(safe-area-inset-bottom);
 
 		.btn {
-			padding: 20rpx 0;
+			position: relative;
+			padding: 20rpx 20rpx;
 
 			/deep/ button {
-				width: 640rpx;
+				width: 440rpx;
 				height: 90rpx;
 				line-height: 90rpx;
 				font-size: 36rpx;
@@ -312,6 +384,11 @@
 				border: none;
 				border-radius: 20rpx;
 			}
+
+			.share {
+				position: absolute;
+				left: 40rpx;
+			}
 		}
 	}
 </style>