Ver Fonte

修改优惠券

zhengjinyi há 1 ano atrás
pai
commit
c17041e561
4 ficheiros alterados com 734 adições e 657 exclusões
  1. 371 352
      pages/seller/cart/coupon.vue
  2. 350 304
      pages/user/coupon/coupon-details.vue
  3. 12 0
      utils/coupon.share.js
  4. 1 1
      utils/router.config.js

+ 371 - 352
pages/seller/cart/coupon.vue

@@ -1,358 +1,377 @@
-<template>
-	<view class="container clearfix">
+<template>
+    <view class="container clearfix">
         <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading="true"
-            :loadingType="5" />
-		<view class="container-list" v-else>
-			<template v-if="coupinList.length > 0">
-				<view v-for="(coupon, index) in coupinList" :key="index" :id="coupon.id" class="coupon-list">
-					<view class="list-cell-le">
-						<view class="coupon-maxMoney"> <text class="small">¥</text> {{ coupon.couponAmount }} </view>
-						<view class="coupon-minMoney"> 满{{ coupon.touchPrice }}可用 </view>
-					</view>
-					<view class="list-cell-ri">
-						<view class="list-cell-top">
-							<view class="list-cell-type">
-								<view class="list-cell-tags">
-									<template v-if="coupon.moneyCouponFlag == 1">
-										<text class="tags" v-if="coupon.moneyCouponType == 1"
-											>意向{{ coupon.couponType | TypeFormat }}</text
-										>
-										<text class="tags" v-else>定向{{ coupon.couponType | TypeFormat }}</text>
-									</template>
-									<template v-else>
-										<text class="tags">{{ coupon.couponType | TypeFormat }}</text>
-									</template>
-								</view>
-								<view class="list-cell-texts">
-									<text v-if="coupon.couponType == 0">
-										{{
-											coupon.productType && coupon.productType == 1
-												? '全商城商品通用'
-												: '仅可购买指定商品'
-										}}
-									</text>
-									<text v-if="coupon.couponType == 1">
-										{{ coupon.categoryType == 1 ? '仅限购买产品类商品' : '仅限购买仪器类商品' }}
-									</text>
-									<text v-if="coupon.couponType == 3"
-										>仅限购买店铺【{{ coupon.shopName }}】的商品</text
-									>
-									<text v-if="coupon.couponType == 4 || coupon.couponType == 2">全商城商品通用</text>
-								</view>
-							</view>
-							<view class="list-cell-btn">
-								<view class="icon-used">
-									<button open-type="share" class="icon-used-btn receive" :data-coupon="coupon">
-										分享
-									</button>
-								</view>
-							</view>
-						</view>
-						<view class="list-cell-time">{{ coupon.startDate }} - {{ coupon.endDate }}</view>
-					</view>
-				</view>
-				<!--加载loadding-->
-				<tui-loadmore :visible="loadding" :index="3" type="black" />
-				<tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText" />
-				<!--加载loadding-->
-			</template>
+            :loadingType="5" />
+        <view class="container-list" v-else>
+            <template v-if="coupinList.length > 0">
+                <view v-for="(coupon, index) in coupinList" :key="index" :id="coupon.id" class="coupon-list">
+                    <view class="list-cell-le">
+                        <view class="coupon-maxMoney"> <text class="small">¥</text> {{ coupon.couponAmount }} </view>
+                        <view class="coupon-minMoney"> 满{{ coupon.touchPrice }}可用 </view>
+                    </view>
+                    <view class="list-cell-ri">
+                        <view class="list-cell-top">
+                            <view class="list-cell-type">
+                                <view class="list-cell-tags">
+                                    <template v-if="coupon.moneyCouponFlag == 1">
+                                        <text class="tags"
+                                            v-if="coupon.moneyCouponType == 1">意向{{ coupon.couponType | TypeFormat }}</text>
+                                        <text class="tags" v-else>定向{{ coupon.couponType | TypeFormat }}</text>
+                                    </template>
+                                    <template v-else>
+                                        <text class="tags">{{ coupon.couponType | TypeFormat }}</text>
+                                    </template>
+                                </view>
+                                <view class="list-cell-texts">
+                                    <text v-if="coupon.couponType == 0">
+                                        {{
+											coupon.productType && coupon.productType == 1
+												? '全商城商品通用'
+												: '仅可购买指定商品'
+										}}
+                                    </text>
+                                    <text v-if="coupon.couponType == 1">
+                                        {{ coupon.categoryType == 1 ? '仅限购买产品类商品' : '仅限购买仪器类商品' }}
+                                    </text>
+                                    <text v-if="coupon.couponType == 3">仅限购买店铺【{{ coupon.shopName }}】的商品</text>
+                                    <text v-if="coupon.couponType == 4 || coupon.couponType == 2">全商城商品通用</text>
+                                </view>
+                            </view>
+                            <view class="list-cell-btn">
+                                <view class="icon-used">
+                                    <button open-type="share" class="icon-used-btn receive" :data-coupon="coupon">
+                                        分享
+                                    </button>
+                                </view>
+                            </view>
+                        </view>
+                        <view class="list-cell-time">{{ coupon.startDate }} - {{ coupon.endDate }}</view>
+                    </view>
+                </view>
+                <!--加载loadding-->
+                <tui-loadmore :visible="loadding" :index="3" type="black" />
+                <tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText" />
+                <!--加载loadding-->
+            </template>
             <view class="empty-container" v-else>
-            	<image class="empty-container-image" :src="StaticUrl + '/icon/icon-coupon-empty@2x.png'"></image>
-            	<text class="error-text">暂无优惠券~</text>
+                <image class="empty-container-image" :src="StaticUrl + '/icon/icon-coupon-empty@2x.png'"></image>
+                <text class="error-text">暂无优惠券~</text>
             </view>
-        </view>
-	</view>
-</template>
-
-<script>
-import { mapState, mapMutations } from 'vuex'
-import couponTabs from '@/components/cm-module/coupon/tui-tabs.vue'
-export default {
-	components: {
-		couponTabs
-	},
-	data() {
-		return {
-			StaticUrl: this.$Static,
-			isIphoneX: this.$store.state.isIphoneX,
-			listQuery: {
-				userId:0,
-				pageNum: 1,
-				pageSize: 10
-			},
-			coupinList: [],
-			skeletonShow: true,
-			nomoreText: '上拉显示更多',
-			hasNextPage: false,
-			loadding: false,
-			pullUpOn: true,
-			pullFlag: true,
-			isReceiveLoading: false, //领券操作状态
-		}
-	},
-	onLoad() {
-		uni.hideShareMenu()
-		this.initGetStotage()
-	},
-	filters: {
-		TypeFormat(value) {
-			switch (value) {
-				case 0:
-					return '活动券'
-					break
-				case 1:
-					return '品类券'
-					break
-				case 2:
-					return '用户专享券'
-					break
-				case 3:
-					return '店铺券'
-					break
-				case 4:
-					return '新用户券'
-					break
-			}
-		}
-	},
-	computed: {
-		...mapState(['hasLogin', 'userInfo', 'identity', 'isActivity'])
-	},
-	methods: {
-        async initGetStotage() {
-            const userInfo = await this.$api.getStorage()
-            this.spId = userInfo.serviceProviderId 
-            this.QueryCouponList()
-            setTimeout(()=>{
-              this.skeletonShow = false
-            },500)
+        </view>
+    </view>
+</template>
+
+<script>
+    import { mapState, mapMutations } from 'vuex'
+    import { COUPON_TEXT_MAP } from '@/utils/coupon.share.js'
+    import couponTabs from '@/components/cm-module/coupon/tui-tabs.vue'
+    export default {
+        components: {
+            couponTabs
         },
-		async QueryCouponList() {
-			// 初始化查询优惠券列表
-            try{
-                this.coupinList = []
-                this.listQuery.pageNum = 1
-                const res = await this.ProductService.QueryCouponCollarList(this.listQuery)
-                const data = res.data
-                if (data.list && data.list.length > 0) {
-                	this.hasNextPage = data.hasNextPage
-                	this.coupinList = data.list
-                	this.pullFlag = false
-                	setTimeout(() => {
-                		this.pullFlag = true
-                	}, 500)
-                	if (this.hasNextPage) {
-                		this.pullUpOn = false
-                		this.nomoreText = '上拉显示更多'
-                	} else {
-                		if (this.coupinList.length < 8) {
-                			this.pullUpOn = true
-                		} else {
-                			this.pullUpOn = false
-                			this.loadding = false
-                			this.nomoreText = '已至底部'
-                		}
-                	}
+        data() {
+            return {
+                StaticUrl: this.$Static,
+                isIphoneX: this.$store.state.isIphoneX,
+                listQuery: {
+                    userId: 0,
+                    pageNum: 1,
+                    pageSize: 10
+                },
+                coupinList: [],
+                skeletonShow: true,
+                nomoreText: '上拉显示更多',
+                hasNextPage: false,
+                loadding: false,
+                pullUpOn: true,
+                pullFlag: true,
+                isReceiveLoading: false, //领券操作状态
+            }
+        },
+        onLoad() {
+            uni.hideShareMenu()
+            this.initGetStotage()
+        },
+        filters: {
+            TypeFormat(value) {
+                switch (value) {
+                    case 0:
+                        return '活动券'
+                        break
+                    case 1:
+                        return '品类券'
+                        break
+                    case 2:
+                        return '用户专享券'
+                        break
+                    case 3:
+                        return '店铺券'
+                        break
+                    case 4:
+                        return '新用户券'
+                        break
+                }
+            }
+        },
+        computed: {
+            ...mapState(['hasLogin', 'userInfo', 'identity', 'isActivity'])
+        },
+        methods: {
+            async initGetStotage() {
+                const userInfo = await this.$api.getStorage()
+                this.spId = userInfo.serviceProviderId
+                this.QueryCouponList()
+                setTimeout(() => {
+                    this.skeletonShow = false
+                }, 500)
+            },
+            async QueryCouponList() {
+                // 初始化查询优惠券列表
+                try {
+                    this.coupinList = []
+                    this.listQuery.pageNum = 1
+                    const res = await this.ProductService.QueryCouponCollarList(this.listQuery)
+                    const data = res.data
+                    if (data.list && data.list.length > 0) {
+                        this.hasNextPage = data.hasNextPage
+                        this.coupinList = data.list
+                        this.pullFlag = false
+                        setTimeout(() => {
+                            this.pullFlag = true
+                        }, 500)
+                        if (this.hasNextPage) {
+                            this.pullUpOn = false
+                            this.nomoreText = '上拉显示更多'
+                        } else {
+                            if (this.coupinList.length < 8) {
+                                this.pullUpOn = true
+                            } else {
+                                this.pullUpOn = false
+                                this.loadding = false
+                                this.nomoreText = '已至底部'
+                            }
+                        }
+                    }
+                } catch (error) {
+                    this.$util.msg(error.msg, 2000)
+                }
+            },
+            async getOnReachBottomData() {
+                // 上滑加载分页
+                try {
+                    this.listQuery.pageNum += 1
+                    const res = await this.ProductService.QueryCouponCollarList(this.listQuery)
+                    const data = res.data
+                    if (data.list && data.list.length > 0) {
+                        this.hasNextPage = data.hasNextPage
+                        this.coupinList = this.coupinList.concat(data.list)
+                        this.pullFlag = false // 防上拉暴滑
+                        setTimeout(() => {
+                            this.pullFlag = true
+                        }, 500)
+                        if (this.hasNextPage) {
+                            this.pullUpOn = false
+                            this.nomoreText = '上拉显示更多'
+                        } else {
+                            this.pullUpOn = false
+                            this.loadding = false
+                            this.nomoreText = '已至底部'
+                        }
+                    }
+                } catch (error) {
+                    this.$util.msg(error.msg, 2000)
+                }
+            },
+            navigator(url) {
+                this.$api.navigateTo(url)
+            }
+        },
+        onShareAppMessage(res) {
+            //分享购买优惠券
+            const coupon = res.target.dataset.coupon
+            if (res.from === 'button') {
+                const randomIndex = Math.floor(Math.random() * COUPON_TEXT_MAP.length);
+                return {
+                    title: COUPON_TEXT_MAP[randomIndex],
+                    path: `pages/user/coupon/coupon-details?couponId=${coupon.couponId}&spId=${this.spId}`,
+                    imageUrl: 'https://static.caimei365.com/app/img/icon/icon-shareCoupon@2x.png'
+                }
+            }
+        },
+        onPullDownRefresh() {
+            setTimeout(() => {
+                this.QueryCouponList()
+                uni.stopPullDownRefresh()
+            }, 200)
+        },
+        onReachBottom() {
+            if (this.hasNextPage) {
+                this.loadding = true
+                this.pullUpOn = true
+                this.getOnReachBottomData()
+            }
+        },
+        onShow() {}
+    }
+</script>
+
+<style lang="scss">
+    page {
+        background-color: #f7f7f7;
+    }
+
+    .container {
+        width: 100%;
+        height: auto;
+    }
+
+    .container-list {
+        box-sizing: border-box;
+        padding: 24rpx;
+
+        .empty-container-image {
+            width: 260rpx;
+            height: 260rpx;
+            margin-top: -300rpx;
+        }
+
+        .toIndexPage {
+            bottom: 390rpx;
+        }
+
+        .coupon-list {
+            width: 100%;
+            height: 200rpx;
+            margin-bottom: 24rpx;
+            box-sizing: border-box;
+            background: url(https://static.caimei365.com/app/img/icon/icon-coupon-uesb@2x.png);
+            background-size: cover;
+            position: relative;
+
+            .list-cell-le {
+                width: 224rpx;
+                height: 100%;
+                box-sizing: border-box;
+                padding: 37rpx 0;
+                float: left;
+
+                .coupon-maxMoney {
+                    width: 100%;
+                    height: 78rpx;
+                    line-height: 78rpx;
+                    font-size: 56rpx;
+                    color: #ffffff;
+                    text-align: center;
+
+                    .small {
+                        font-size: $font-size-24;
+                    }
+                }
+
+                .coupon-minMoney {
+                    width: 100%;
+                    height: 33rpx;
+                    line-height: 33rpx;
+                    font-size: $font-size-24;
+                    color: #ffffff;
+                    text-align: center;
+                }
+            }
+
+            .list-cell-ri {
+                width: 478rpx;
+                height: 100%;
+                box-sizing: border-box;
+                padding: 20rpx 24rpx 0 24rpx;
+                float: right;
+
+                .list-cell-top {
+                    width: 100%;
+                    height: 121rpx;
+                    float: left;
+                    border-bottom: 1px solid #e1e1e1;
+
+                    .list-cell-type {
+                        width: 286rpx;
+                        height: 100%;
+                        float: left;
+
+                        .list-cell-tags {
+                            width: 100%;
+                            height: 32rpx;
+                            margin-bottom: 7rpx;
+
+                            .tags {
+                                display: inline-block;
+                                padding: 0 10rpx;
+                                height: 32rpx;
+                                line-height: 32rpx;
+                                background-color: #ffdcce;
+                                color: #f94b4b;
+                                font-size: $font-size-20;
+                                border-radius: 8rpx;
+                                text-align: center;
+                                float: left;
+                            }
+                        }
+
+                        .list-cell-texts {
+                            width: 100%;
+                            height: auto;
+                            line-height: 35rpx;
+                            text-overflow: ellipsis;
+                            display: -webkit-box;
+                            word-break: break-all;
+                            -webkit-box-orient: vertical;
+                            -webkit-line-clamp: 2;
+                            overflow: hidden;
+                            font-size: 26rpx;
+                            color: #333333;
+                        }
+                    }
+
+                    .list-cell-btn {
+                        width: 128rpx;
+                        height: 100%;
+                        float: right;
+
+                        .icon-used {
+                            width: 100%;
+                            height: 100%;
+                            box-sizing: border-box;
+                            padding-top: 57rpx;
+
+                            .icon-used-btn {
+                                width: 128rpx;
+                                height: 48rpx;
+                                border-radius: 28rpx;
+                                line-height: 48rpx;
+                                font-size: $font-size-24;
+                                text-align: center;
+
+                                &.receive {
+                                    background-image: linear-gradient(270deg, #f94b4b 0%, #feb673 100%);
+                                    color: #ffffff;
+                                }
+
+                                &.make {
+                                    border: solid 1px #f94b4b;
+                                    color: #f94b4b;
+                                }
+                            }
+                        }
+                    }
                 }
-            }catch(error){
-                this.$util.msg(error.msg, 2000)
-            }
-		},
-		async getOnReachBottomData() {
-			// 上滑加载分页
-            try{
-                this.listQuery.pageNum += 1
-                const res = await this.ProductService.QueryCouponCollarList(this.listQuery)
-                const data = res.data
-                if (data.list && data.list.length > 0) {
-                	this.hasNextPage = data.hasNextPage
-                	this.coupinList = this.coupinList.concat(data.list)
-                	this.pullFlag = false // 防上拉暴滑
-                	setTimeout(() => {
-                		this.pullFlag = true
-                	}, 500)
-                	if (this.hasNextPage) {
-                		this.pullUpOn = false
-                		this.nomoreText = '上拉显示更多'
-                	} else {
-                		this.pullUpOn = false
-                		this.loadding = false
-                		this.nomoreText = '已至底部'
-                	}
+
+                .list-cell-time {
+                    width: 100%;
+                    height: 58rpx;
+                    line-height: 58rpx;
+                    text-align: left;
+                    font-size: $font-size-20;
+                    color: #999999;
                 }
-            }catch(error){
-                this.$util.msg(error.msg, 2000)
-            }
-		},
-		navigator(url) {
-			this.$api.navigateTo(url)
-		}
-	},
-	onShareAppMessage(res) {
-		//分享购买优惠券
-		const coupon = res.target.dataset.coupon
-		if (res.from === 'button') {
-			// console.log('来自页面内转发按钮')
-			return {
-				title: '送您一张优惠券~',
-				path: `pages/user/coupon/coupon-details?couponId=${coupon.couponId}&spId=${this.spId}`,
-				imageUrl: 'https://static.caimei365.com/app/img/icon/icon-shareCoupon@2x.png'
-			}
-		}
-	},
-	onPullDownRefresh() {
-		setTimeout(() => {
-			this.QueryCouponList()
-			uni.stopPullDownRefresh()
-		}, 200)
-	},
-	onReachBottom() {
-		if (this.hasNextPage) {
-			this.loadding = true
-			this.pullUpOn = true
-			this.getOnReachBottomData()
-		}
-	},
-	onShow() {}
-}
-</script>
-
-<style lang="scss">
-page {
-	background-color: #f7f7f7;
-}
-.container {
-	width: 100%;
-	height: auto;
-}
-.container-list {
-	box-sizing: border-box;
-	padding: 24rpx;
-	.empty-container-image {
-		width: 260rpx;
-		height: 260rpx;
-		margin-top: -300rpx;
-	}
-	.toIndexPage {
-		bottom: 390rpx;
-	}
-	.coupon-list {
-		width: 100%;
-		height: 200rpx;
-		margin-bottom: 24rpx;
-		box-sizing: border-box;
-		background: url(https://static.caimei365.com/app/img/icon/icon-coupon-uesb@2x.png);
-		background-size: cover;
-		position: relative;
-		.list-cell-le {
-			width: 224rpx;
-			height: 100%;
-			box-sizing: border-box;
-			padding: 37rpx 0;
-			float: left;
-			.coupon-maxMoney {
-				width: 100%;
-				height: 78rpx;
-				line-height: 78rpx;
-				font-size: 56rpx;
-				color: #ffffff;
-				text-align: center;
-				.small {
-					font-size: $font-size-24;
-				}
-			}
-			.coupon-minMoney {
-				width: 100%;
-				height: 33rpx;
-				line-height: 33rpx;
-				font-size: $font-size-24;
-				color: #ffffff;
-				text-align: center;
-			}
-		}
-		.list-cell-ri {
-			width: 478rpx;
-			height: 100%;
-			box-sizing: border-box;
-			padding: 20rpx 24rpx 0 24rpx;
-			float: right;
-			.list-cell-top {
-				width: 100%;
-				height: 121rpx;
-				float: left;
-				border-bottom: 1px solid #e1e1e1;
-				.list-cell-type {
-					width: 286rpx;
-					height: 100%;
-					float: left;
-					.list-cell-tags {
-						width: 100%;
-						height: 32rpx;
-						margin-bottom: 7rpx;
-						.tags {
-							display: inline-block;
-							padding: 0 10rpx;
-							height: 32rpx;
-							line-height: 32rpx;
-							background-color: #ffdcce;
-							color: #f94b4b;
-							font-size: $font-size-20;
-							border-radius: 8rpx;
-							text-align: center;
-							float: left;
-						}
-					}
-					.list-cell-texts {
-						width: 100%;
-						height: auto;
-						line-height: 35rpx;
-						text-overflow: ellipsis;
-						display: -webkit-box;
-						word-break: break-all;
-						-webkit-box-orient: vertical;
-						-webkit-line-clamp: 2;
-						overflow: hidden;
-						font-size: 26rpx;
-						color: #333333;
-					}
-				}
-				.list-cell-btn {
-					width: 128rpx;
-					height: 100%;
-					float: right;
-					.icon-used {
-						width: 100%;
-						height: 100%;
-						box-sizing: border-box;
-						padding-top: 57rpx;
-						.icon-used-btn {
-							width: 128rpx;
-							height: 48rpx;
-							border-radius: 28rpx;
-							line-height: 48rpx;
-							font-size: $font-size-24;
-							text-align: center;
-							&.receive {
-								background-image: linear-gradient(270deg, #f94b4b 0%, #feb673 100%);
-								color: #ffffff;
-							}
-							&.make {
-								border: solid 1px #f94b4b;
-								color: #f94b4b;
-							}
-						}
-					}
-				}
-			}
-			.list-cell-time {
-				width: 100%;
-				height: 58rpx;
-				line-height: 58rpx;
-				text-align: left;
-				font-size: $font-size-20;
-				color: #999999;
-			}
-		}
-	}
-}
-</style>
+            }
+        }
+    }
+</style>

+ 350 - 304
pages/user/coupon/coupon-details.vue

@@ -1,318 +1,364 @@
-<template>
-	<view class="container clearfix" >
-		<tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading	="true" :loadingType="5" />
-		<view class="container-content tui-skeleton" v-else>
+<template>
+    <view class="container clearfix">
+        <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading="true"
+            :loadingType="5" />
+        <view class="container-content tui-skeleton" v-else>
             <view class="empty-container" v-if="!coupon">
-            	<image class="empty-container-image" :src="StaticUrl + '/icon/icon-coupon-empty@2x.png'"></image>
-            	<text class="error-text">暂无优惠券~</text>
+                <image class="empty-container-image" :src="StaticUrl + '/icon/icon-coupon-empty@2x.png'"></image>
+                <text class="error-text">暂无优惠券~</text>
             </view>
             <template v-else>
                 <view class="container-list">
-                	<view class="coupon-list">
-                		<view class="list-cell-le">
-                			<view class="coupon-maxMoney"> <text class="small">¥</text> {{ coupon.couponAmount }} </view>
-                			<view class="coupon-minMoney"> 满{{ coupon.touchPrice }}可用 </view>
-                		</view>
-                		<view class="list-cell-ri">
-                			<view class="list-cell-top">
-                				<view class="list-cell-type">
-                					<view class="list-cell-tags">
-                						<template v-if="coupon.moneyCouponFlag == 1">
-                							<text class="tags" v-if="coupon.moneyCouponType == 1"
-                								>意向{{ coupon.couponType | TypeFormat }}</text
-                							>
-                							<text class="tags" v-else>定向{{ coupon.couponType | TypeFormat }}</text>
-                						</template>
-                						<template v-else>
-                							<text class="tags">{{ coupon.couponType | TypeFormat }}</text>
-                						</template>
-                					</view>
-                					<view class="list-cell-texts">
-                						<text v-if="coupon.couponType == 0">
-                							{{
+                    <view class="coupon-list">
+                        <view class="list-cell-le">
+                            <view class="coupon-maxMoney"> <text class="small">¥</text> {{ coupon.couponAmount }}
+                            </view>
+                            <view class="coupon-minMoney"> 满{{ coupon.touchPrice }}可用 </view>
+                        </view>
+                        <view class="list-cell-ri">
+                            <view class="list-cell-top">
+                                <view class="list-cell-type">
+                                    <view class="list-cell-tags">
+                                        <template v-if="coupon.moneyCouponFlag == 1">
+                                            <text class="tags"
+                                                v-if="coupon.moneyCouponType == 1">意向{{ coupon.couponType | TypeFormat }}</text>
+                                            <text class="tags" v-else>定向{{ coupon.couponType | TypeFormat }}</text>
+                                        </template>
+                                        <template v-else>
+                                            <text class="tags">{{ coupon.couponType | TypeFormat }}</text>
+                                        </template>
+                                    </view>
+                                    <view class="list-cell-texts">
+                                        <text v-if="coupon.couponType == 0">
+                                            {{
                 								coupon.productType && coupon.productType == 1
                 									? '全商城商品通用'
                 									: '仅可购买指定商品'
                 							}}
-                						</text>
-                						<text v-if="coupon.couponType == 1">
-                							{{ coupon.categoryType == 1 ? '仅限购买产品类商品' : '仅限购买仪器类商品' }}
-                						</text>
-                						<text v-if="coupon.couponType == 3"
-                							>仅限购买店铺【{{ coupon.shopName }}】的商品</text
-                						>
-                						<text v-if="coupon.couponType == 4 || coupon.couponType == 2">全商城商品通用</text>
-                					</view>
-                				</view>
-                			</view>
-                			<view class="list-cell-time">{{ coupon.startDate }} - {{ coupon.endDate }}</view>
-                		</view>
-                	</view>
+                                        </text>
+                                        <text v-if="coupon.couponType == 1">
+                                            {{ coupon.categoryType == 1 ? '仅限购买产品类商品' : '仅限购买仪器类商品' }}
+                                        </text>
+                                        <text v-if="coupon.couponType == 3">仅限购买店铺【{{ coupon.shopName }}】的商品</text>
+                                        <text v-if="coupon.couponType == 4 || coupon.couponType == 2">全商城商品通用</text>
+                                    </view>
+                                </view>
+                            </view>
+                            <view class="list-cell-time">{{ coupon.startDate }} - {{ coupon.endDate }}</view>
+                        </view>
+                    </view>
                 </view>
                 <view class="container-button">
-                	<view class="button" @click="handeleReceiveCoupon(coupon)">领取优惠券</view>
+                    <view class="button" @click="handeleReceiveCoupon(coupon)">领取优惠券</view>
                 </view>
-            </template>
-		</view>
-	</view>
-</template>
-
-<script>
-import { mapState, mapMutations } from 'vuex'
-import wxLogin from '@/common/config/wxLogin.js'
-import authorize from '@/common/config/authorize.js'
-export default {
-	data() {
-		return {
-			StaticUrl: this.$Static,
-			isIphoneX: this.$store.state.isIphoneX,
-			coupon: {},
-			coupinList: [],
-			payAmount: 100 ,//支付金额
-			skeletonShow:true,
-            isReceiveLoading: false ,//领券操作状态
-            param:{
-                spId:0,
-                userId:0,
-                couponId:0,
-                source: 1
-            }
-		}
-	},
-	onLoad(option) {
-        wxLogin.wxLoginAuthorize()
-		this.param.spId = option.spId
-		this.param.couponId = option.couponId
-		this.initCouponDetail(this.param.couponId)
-	},
-	filters: {
-		TypeFormat(value) {
-			switch (value) {
-				case 0:
-					return '活动券'
-					break
-				case 1:
-					return '品类券'
-					break
-				case 2:
-					return '用户专享券'
-					break
-				case 3:
-					return '店铺券'
-					break
-				case 4:
-					return '新用户券'
-					break
-			}
-		}
-	},
-	computed: {
-		...mapState(['hasLogin', 'userInfo',])
-	},
-	methods: {
-		async initCouponDetail(couponId) {
-			// 初始化优惠券信息
-            try{
-                const res = await this.ProductService.QueryCouponDetail({ couponId: couponId })
-                this.coupon = res.data
-                setTimeout(()=>{
-                     this.skeletonShow = false
-                },500)
-               
-            }catch(e){
-               console.log('初始化优惠券信息异常~')
-            }
-		},
-        async handeleReceiveCoupon(coupon){
-            // 点击优惠券领取按钮,
-            if (this.hasLogin) {
-            	if (this.isReceiveLoading) {
-            		return
-            	}
-                const userInfo = await this.$api.getStorage()
-                this.param.userId = userInfo.userId
-                this.getRceiveCoupon(this.param)
-            } else {
-                const pages = getCurrentPages()
-                const page = pages[pages.length - 1]
-                uni.setStorageSync('LOGIN_REDIRECT_URL', page.$page.fullPath)
-                this.$api.redirectTo('/pages/login/login')
+            </template>
+        </view>
+    </view>
+</template>
+
+<script>
+    import { mapState, mapMutations } from 'vuex'
+    import wxLogin from '@/common/config/wxLogin.js'
+    import { COUPON_TEXT_MAP } from '@/utils/coupon.share.js'
+    import authorize from '@/common/config/authorize.js'
+    export default {
+        data() {
+            return {
+                StaticUrl: this.$Static,
+                isIphoneX: this.$store.state.isIphoneX,
+                coupon: {},
+                coupinList: [],
+                payAmount: 100, //支付金额
+                skeletonShow: true,
+                isReceiveLoading: false, //领券操作状态
+                param: {
+                    spId: 0,
+                    userId: 0,
+                    couponId: 0,
+                    source: 1
+                }
             }
         },
-        // 执行领取优惠券
-        async getRceiveCoupon(params){
-            try{
-                await this.ProductService.ReceiveCoupon(params)
-                this.isReceiveLoading = true
-                this.$util.msg('领取成功', 1500, true, 'success')
-                setTimeout(() => {
-                	this.isReceiveLoading = false
-                    this.$api.reLaunch('/pages/user/coupon/coupon')
-                }, 1500)
-            }catch(error){
-               this.$util.msg(error.msg, 2000)
-               this.isReceiveLoading = false
+        onLoad(option) {
+            wxLogin.wxLoginAuthorize()
+            this.param.spId = option.spId
+            this.param.couponId = option.couponId
+            // #ifdef MP-WEIXIN
+            // 绑定分享参数
+            console.log('绑定分享参数', { query: `couponId=${option.couponId}&spId=${option.spId}` })
+            wx.onCopyUrl(() => {
+                return { query: `couponId=${option.couponId}&spId=${option.spId}` }
+            });
+            // #endif
+            this.initCouponDetail(this.param.couponId)
+        },
+        filters: {
+            TypeFormat(value) {
+                switch (value) {
+                    case 0:
+                        return '活动券'
+                        break
+                    case 1:
+                        return '品类券'
+                        break
+                    case 2:
+                        return '用户专享券'
+                        break
+                    case 3:
+                        return '店铺券'
+                        break
+                    case 4:
+                        return '新用户券'
+                        break
+                }
+            }
+        },
+        computed: {
+            ...mapState(['hasLogin', 'userInfo', ])
+        },
+        methods: {
+            async initCouponDetail(couponId) {
+                // 初始化优惠券信息
+                try {
+                    const res = await this.ProductService.QueryCouponDetail({ couponId: couponId })
+                    this.coupon = res.data
+                    setTimeout(() => {
+                        this.skeletonShow = false
+                    }, 500)
+
+                } catch (e) {
+                    console.log('初始化优惠券信息异常~')
+                }
+            },
+            async handeleReceiveCoupon(coupon) {
+                // 点击优惠券领取按钮,
+                if (this.hasLogin) {
+                    if (this.isReceiveLoading) {
+                        return
+                    }
+                    const userInfo = await this.$api.getStorage()
+                    this.param.userId = userInfo.userId
+                    this.getRceiveCoupon(this.param)
+                } else {
+                    const pages = getCurrentPages()
+                    const page = pages[pages.length - 1]
+                    uni.setStorageSync('LOGIN_REDIRECT_URL', page.$page.fullPath)
+                    this.$api.redirectTo('/pages/login/login')
+                }
+            },
+            // 执行领取优惠券
+            async getRceiveCoupon(params) {
+                try {
+                    await this.ProductService.ReceiveCoupon(params)
+                    this.isReceiveLoading = true
+                    this.$util.msg('领取成功', 1500, true, 'success')
+                    setTimeout(() => {
+                        this.isReceiveLoading = false
+                        this.$api.reLaunch('/pages/user/coupon/coupon')
+                    }, 1500)
+                } catch (error) {
+                    this.$util.msg(error.msg, 2000)
+                    this.isReceiveLoading = false
+                }
+            }
+        },
+        onShareAppMessage(res) {
+            //分享优惠券
+            if (res.from === 'button') {
+            	// 来自页面内转发按钮
+            }
+            const randomIndex = Math.floor(Math.random() * COUPON_TEXT_MAP.length);
+            return {
+                title: COUPON_TEXT_MAP[randomIndex],
+                path: `pages/user/coupon/coupon-details?couponId=${this.param.couponId}&spId=${this.param.spId}`,
+                imageUrl: 'https://static.caimei365.com/app/img/icon/icon-shareCoupon@2x.png'
+            }
+        },
+        onHide() {
+            // 取消绑定分享参数
+            wx.offCopyUrl()
+        },
+        onShow() {
+
+        }
+    }
+</script>
+
+<style lang="scss">
+    page {
+        background-color: #FFFFFF;
+    }
+
+    .container {
+        width: 100%;
+        height: auto;
+    }
+
+    .empty-container-image {
+        width: 260rpx;
+        height: 260rpx;
+        margin-top: -300rpx;
+    }
+
+    .container-list {
+        box-sizing: border-box;
+        padding: 24rpx;
+
+        .toIndexPage {
+            bottom: 390rpx;
+        }
+
+        .coupon-list {
+            width: 100%;
+            height: 200rpx;
+            margin-bottom: 24rpx;
+            box-sizing: border-box;
+            background: url(https://static.caimei365.com/app/img/icon/icon-coupon-uesb@2x.png);
+            background-size: cover;
+            position: relative;
+
+            .list-cell-le {
+                width: 224rpx;
+                height: 100%;
+                box-sizing: border-box;
+                padding: 37rpx 0;
+                float: left;
+
+                .coupon-maxMoney {
+                    width: 100%;
+                    height: 78rpx;
+                    line-height: 78rpx;
+                    font-size: 56rpx;
+                    color: #ffffff;
+                    text-align: center;
+
+                    .small {
+                        font-size: $font-size-24;
+                    }
+                }
+
+                .coupon-minMoney {
+                    width: 100%;
+                    height: 33rpx;
+                    line-height: 33rpx;
+                    font-size: $font-size-24;
+                    color: #ffffff;
+                    text-align: center;
+                }
+            }
+
+            .list-cell-ri {
+                width: 478rpx;
+                height: 100%;
+                box-sizing: border-box;
+                padding: 20rpx 24rpx 0 24rpx;
+                float: right;
+
+                .list-cell-top {
+                    width: 100%;
+                    height: 121rpx;
+                    float: left;
+                    border-bottom: 1px solid #e1e1e1;
+
+                    .list-cell-type {
+                        width: 286rpx;
+                        height: 100%;
+                        float: left;
+
+                        .list-cell-tags {
+                            width: 100%;
+                            height: 32rpx;
+                            margin-bottom: 7rpx;
+
+                            .tags {
+                                display: inline-block;
+                                padding: 0 10rpx;
+                                height: 32rpx;
+                                line-height: 32rpx;
+                                background-color: #ffdcce;
+                                color: #f94b4b;
+                                font-size: $font-size-20;
+                                border-radius: 8rpx;
+                                text-align: center;
+                                float: left;
+                            }
+                        }
+
+                        .list-cell-texts {
+                            width: 100%;
+                            height: auto;
+                            line-height: 35rpx;
+                            text-overflow: ellipsis;
+                            display: -webkit-box;
+                            word-break: break-all;
+                            -webkit-box-orient: vertical;
+                            -webkit-line-clamp: 2;
+                            overflow: hidden;
+                            font-size: 26rpx;
+                            color: #333333;
+                        }
+                    }
+
+                    .list-cell-btn {
+                        width: 128rpx;
+                        height: 100%;
+                        float: right;
+
+                        .icon-used {
+                            width: 100%;
+                            height: 100%;
+                            box-sizing: border-box;
+                            padding-top: 57rpx;
+
+                            .icon-used-btn {
+                                width: 128rpx;
+                                height: 48rpx;
+                                border-radius: 28rpx;
+                                line-height: 48rpx;
+                                font-size: $font-size-24;
+                                text-align: center;
+
+                                &.receive {
+                                    background-image: linear-gradient(270deg, #f94b4b 0%, #feb673 100%);
+                                    color: #ffffff;
+                                }
+
+                                &.make {
+                                    border: solid 1px #f94b4b;
+                                    color: #f94b4b;
+                                }
+                            }
+                        }
+                    }
+                }
+
+                .list-cell-time {
+                    width: 100%;
+                    height: 58rpx;
+                    line-height: 58rpx;
+                    text-align: left;
+                    font-size: $font-size-20;
+                    color: #999999;
+                }
             }
-        }
-	},
-	onShow() {
-       
-    }
-}
-</script>
-
-<style lang="scss">
-page {
-	background-color: #FFFFFF;
-}
-.container {
-	width: 100%;
-	height: auto;
-}
-.empty-container-image {
-		width: 260rpx;
-		height: 260rpx;
-		margin-top: -300rpx;
-	}
-.container-list {
-	box-sizing: border-box;
-	padding: 24rpx;
-	.toIndexPage {
-		bottom: 390rpx;
-	}
-	.coupon-list {
-		width: 100%;
-		height: 200rpx;
-		margin-bottom: 24rpx;
-		box-sizing: border-box;
-		background: url(https://static.caimei365.com/app/img/icon/icon-coupon-uesb@2x.png);
-		background-size: cover;
-		position: relative;
-		.list-cell-le {
-			width: 224rpx;
-			height: 100%;
-			box-sizing: border-box;
-			padding: 37rpx 0;
-			float: left;
-			.coupon-maxMoney {
-				width: 100%;
-				height: 78rpx;
-				line-height: 78rpx;
-				font-size: 56rpx;
-				color: #ffffff;
-				text-align: center;
-				.small {
-					font-size: $font-size-24;
-				}
-			}
-			.coupon-minMoney {
-				width: 100%;
-				height: 33rpx;
-				line-height: 33rpx;
-				font-size: $font-size-24;
-				color: #ffffff;
-				text-align: center;
-			}
-		}
-		.list-cell-ri {
-			width: 478rpx;
-			height: 100%;
-			box-sizing: border-box;
-			padding: 20rpx 24rpx 0 24rpx;
-			float: right;
-			.list-cell-top {
-				width: 100%;
-				height: 121rpx;
-				float: left;
-				border-bottom: 1px solid #e1e1e1;
-				.list-cell-type {
-					width: 286rpx;
-					height: 100%;
-					float: left;
-					.list-cell-tags {
-						width: 100%;
-						height: 32rpx;
-						margin-bottom: 7rpx;
-						.tags {
-							display: inline-block;
-							padding: 0 10rpx;
-							height: 32rpx;
-							line-height: 32rpx;
-							background-color: #ffdcce;
-							color: #f94b4b;
-							font-size: $font-size-20;
-							border-radius: 8rpx;
-							text-align: center;
-							float: left;
-						}
-					}
-					.list-cell-texts {
-						width: 100%;
-						height: auto;
-						line-height: 35rpx;
-						text-overflow: ellipsis;
-						display: -webkit-box;
-						word-break: break-all;
-						-webkit-box-orient: vertical;
-						-webkit-line-clamp: 2;
-						overflow: hidden;
-						font-size: 26rpx;
-						color: #333333;
-					}
-				}
-				.list-cell-btn {
-					width: 128rpx;
-					height: 100%;
-					float: right;
-					.icon-used {
-						width: 100%;
-						height: 100%;
-						box-sizing: border-box;
-						padding-top: 57rpx;
-						.icon-used-btn {
-							width: 128rpx;
-							height: 48rpx;
-							border-radius: 28rpx;
-							line-height: 48rpx;
-							font-size: $font-size-24;
-							text-align: center;
-							&.receive {
-								background-image: linear-gradient(270deg, #f94b4b 0%, #feb673 100%);
-								color: #ffffff;
-							}
-							&.make {
-								border: solid 1px #f94b4b;
-								color: #f94b4b;
-							}
-						}
-					}
-				}
-			}
-			.list-cell-time {
-				width: 100%;
-				height: 58rpx;
-				line-height: 58rpx;
-				text-align: left;
-				font-size: $font-size-20;
-				color: #999999;
-			}
-		}
-	}
-}
-.container-button {
-	width: 100%;
-	height: 90rpx;
-	margin-top: 190rpx;
-	.button {
-		width: 600rpx;
-		height: 90rpx;
-		text-align: center;
-		background: $btn-confirm;
-		line-height: 90rpx;
-		font-size: $font-size-30;
-		color: #ffffff;
-		margin: 0 auto;
-		border-radius: 45rpx;
-	}
-}
-</style>
+        }
+    }
+
+    .container-button {
+        width: 100%;
+        height: 90rpx;
+        margin-top: 190rpx;
+
+        .button {
+            width: 600rpx;
+            height: 90rpx;
+            text-align: center;
+            background: $btn-confirm;
+            line-height: 90rpx;
+            font-size: $font-size-30;
+            color: #ffffff;
+            margin: 0 auto;
+            border-radius: 45rpx;
+        }
+    }
+</style>

+ 12 - 0
utils/coupon.share.js

@@ -0,0 +1,12 @@
+export const COUPON_TEXT_MAP = [
+    '恭喜你被好运砸中!速领!',
+    '商城特价,社群专属!',
+    '限时疯抢,优惠券助力更省钱!',
+    '今日特价,用券更优惠!',
+    '采购更实惠,用券立减!',
+    '一券在手,省钱我有!',
+    '抢购正当时,优惠券帮你省钱!',
+    '今天还没领到优惠券?',
+    '下单前记得先抢100元红包!',
+    '社群专享福利请查收'
+]

+ 1 - 1
utils/router.config.js

@@ -51,4 +51,4 @@ export const includeList = [
     {title:'发货记录', url:'/pages/supplier/deliver/deliver-record',pageLabel:'发货记录', pageType:52 },
     {title:'重置密码', url:'/pages/supplier/user/setting/password',pageLabel:'重置密码', pageType:66 },
     {title:'更换手机号', url:'/pages/supplier/user/setting/phone',pageLabel:'更换手机号', pageType:67 },
-]
+]