zhengjinyi 1 tahun lalu
induk
melakukan
0c8d5b2b41

+ 27 - 19
pages/seller/cart/coupon-share.vue

@@ -159,25 +159,33 @@ export default {
 				this.$util.msg(error.msg, 2000)
 			})
 		},
-		createCouponRecord(){
-			// 生成购买优惠券记录Id
-			this.PayService.WeChatCouponRecord({
-				userId: this.userId,
-				couponId: this.couponId
-			})
-			.then(response => {
-				this.MiniWxPayFor(response.data.couponRecordId)
-			})
-			.catch(error => {
-				if(error.code == -1){//个人机构不能购买
-					this.contentModalText ='该优惠券仅限医美机构购买,请升级为医美机构后再次购买。'
-					this.modal = true
-					
-				}else if(error.code == -2){//会员机构不是医美机构不能购买
-					this.$util.msg('该优惠券仅限医美机构购买', 2000)
-				}
-			})
-		},
+		createCouponRecord(){
+            // 生成购买优惠券记录Id
+           if (!this.hasLogin) {
+               const pages = getCurrentPages()
+               const page = pages[pages.length - 1]
+               uni.setStorageSync('LOGIN_REDIRECT_URL', page.$page.fullPath)
+               this.$api.redirectTo('/pages/login/login')
+             
+           } else {
+              this.PayService.WeChatCouponRecord({
+              	userId: this.userId,
+              	couponId: this.couponId
+              })
+              .then(response => {
+              	this.MiniWxPayFor(response.data.couponRecordId)
+              })
+              .catch(error => {
+              	if(error.code == -1){//个人机构不能购买
+              		this.contentModalText ='该优惠券仅限医美机构购买,请升级为医美机构后再次购买。'
+              		this.modal = true
+              		
+              	}else if(error.code == -2){//会员机构不是医美机构不能购买
+              		this.$util.msg('该优惠券仅限医美机构购买', 2000)
+              	}
+              })
+           }
+		},
 		async MiniWxPayFor(couponRecordId) {
 			const wechatcode = await authorize.getCode('weixin')
 			const params = {

+ 15 - 8
pages/seller/cart/coupon.vue

@@ -39,8 +39,13 @@
                             </view>
                             <view class="list-cell-btn">
                                 <view class="icon-used">
-                                    <button open-type="share" class="icon-used-btn receive" :data-coupon="coupon">
-                                        分享
+                                    <button v-if="coupon.moneyCouponFlag === 1" open-type="share"
+                                        class="icon-used-btn receive" :data-coupon="coupon">
+                                        分享购买
+                                    </button>
+                                    <button v-else open-type="share" class="icon-used-btn share"
+                                        :data-coupon="coupon">
+                                        分享领取
                                     </button>
                                 </view>
                             </view>
@@ -190,9 +195,12 @@
             //分享购买优惠券
             const coupon = res.target.dataset.coupon
             if (res.from === 'button') {
-                const randomIndex = Math.floor(Math.random() * COUPON_TEXT_MAP.length);
+                const randomIndex = Math.floor(Math.random() * COUPON_TEXT_MAP.length)
+                const shareTitle = coupon.moneyCouponFlag === 1 ?
+                    `${coupon.moneyCouponPrice}抵${coupon.couponAmount},限时优惠券等您抢购~` :
+                    COUPON_TEXT_MAP[randomIndex]
                 return {
-                    title: COUPON_TEXT_MAP[randomIndex],
+                    title: shareTitle,
                     path: `pages/user/coupon/coupon-details?couponId=${coupon.couponId}&spId=${this.spId}`,
                     imageUrl: 'https://static.caimei365.com/app/img/icon/icon-shareCoupon@2x.png'
                 }
@@ -353,10 +361,9 @@
                                     background-image: linear-gradient(270deg, #f94b4b 0%, #feb673 100%);
                                     color: #ffffff;
                                 }
-
-                                &.make {
-                                    border: solid 1px #f94b4b;
-                                    color: #f94b4b;
+                                &.share {
+                                    background-image:linear-gradient(315deg,#6772FF 0,#00F9E5 100%);
+                                    color: #ffffff;
                                 }
                             }
                         }

+ 1 - 1
pages/seller/club/club-list.vue

@@ -20,7 +20,7 @@
                         src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AY2ZjAABpmnBICH4247.png"
                         mode="aspectFit"></image>
                     <view class="txt">暂无机构数据</view>
-                </view>
+                </view> 
                 <view v-else class="club-list">
                     <scroll-view scroll-y="true">
                         <view class="list" v-for="(club, index) in clubList" :key="index">

+ 46 - 3
pages/user/coupon/coupon-details.vue

@@ -49,7 +49,9 @@
                     </view>
                 </view>
                 <view class="container-button">
-                    <view class="button" @click="handeleReceiveCoupon(coupon)">领取优惠券</view>
+                    <view v-if="coupon.moneyCouponFlag === 1" class="button" @click="createCouponRecord(coupon)">
+                        ¥{{ coupon.moneyCouponPrice }}购买</view>
+                    <view v-else class="button" @click="handeleReceiveCoupon(coupon)">领取优惠券</view>
                 </view>
             </template>
         </view>
@@ -59,9 +61,11 @@
 <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'
+    import { COUPON_TEXT_MAP } from '@/utils/coupon.share.js'
+    import payMixins from '@/mixins/payMixins.js'
     export default {
+        mixins: [payMixins],
         data() {
             return {
                 StaticUrl: this.$Static,
@@ -130,6 +134,45 @@
                     console.log('初始化优惠券信息异常~')
                 }
             },
+            //购买优惠券
+            createCouponRecord(coupon) {
+                // 生成购买优惠券记录Id
+                if (!this.hasLogin) {
+                    const pages = getCurrentPages()
+                    const page = pages[pages.length - 1]
+                    uni.setStorageSync('LOGIN_REDIRECT_URL', page.$page.fullPath)
+                    this.$api.redirectTo('/pages/login/login')
+
+                } else {
+                    this.WeChatCouponRecord(coupon)
+                }
+            },
+            // 调用查询购买
+            async WeChatCouponRecord(coupon) {
+                try {
+                    const userInfo = await this.$api.getStorage()
+                    const data = await this.PayService.WeChatCouponRecord({ userId: userInfo.userId,
+                        couponId: coupon.couponId })
+                    this.MiniWxPayFor(data.data.couponRecordId)
+                } catch (error) {
+                   this.$util.msg(error.msg, 2000)
+                }
+            },
+            // 购买优惠券支付
+            async MiniWxPayFor(couponRecordId) {
+                const wechatcode = await authorize.getCode('weixin')
+                const userInfo = await this.$api.getStorage()
+                const params = {
+                    userId: userInfo.userId,
+                    couponId: this.param.couponId,
+                    couponRecordId: couponRecordId,
+                    payType: 'XCX',
+                    code: wechatcode,
+                    source: 1 //支付来源 1 小程序 2 WWW
+                }
+                this.weChatMiniCouponWxPay(params, 'Um_Event_shareCouponPay', '分享优惠券', '线上支付优惠券', this.couponId,
+                    this.userId)
+            },
             async handeleReceiveCoupon(coupon) {
                 // 点击优惠券领取按钮,
                 if (this.hasLogin) {
@@ -165,7 +208,7 @@
         onShareAppMessage(res) {
             //分享优惠券
             if (res.from === 'button') {
-            	// 来自页面内转发按钮
+                // 来自页面内转发按钮
             }
             const randomIndex = Math.floor(Math.random() * COUPON_TEXT_MAP.length);
             return {