浏览代码

呵呵商城v1.3.1优化

yuwenjun1997 2 年之前
父节点
当前提交
3fb2343a97

+ 13 - 3
components/views/cm-floor-template/cm-floor-template.vue

@@ -1,6 +1,10 @@
 <template>
     <view class="floor-template" v-if="floorData">
-        <cm-floor-title :title="floorData.title" @click="$emit('more', floorData)" :sub-title="floorData.detail"></cm-floor-title>
+        <cm-floor-title
+            :title="floorData.title"
+            @click="$emit('more', floorData)"
+            :sub-title="floorData.detail"
+        ></cm-floor-title>
         <!-- banner区域 -->
         <view class="floor-banner-area" :class="'template-' + templateType" v-if="templateType !== '8'">
             <view
@@ -115,9 +119,15 @@ export default {
                     if (key.indexOf('appletsAdsImage') > -1 && linkValue) {
                         const obj = Object.create(null)
                         obj.id = parseInt(key[key.length - 1])
-                        const subKey = 'adsLink' + obj.id
+                        const jumpTypeKey = 'jumpType' + obj.id
+                        const jumpLinkKey = 'adsLink' + obj.id
+                        const jumpProductIdKey = 'productId' + obj.id
+                        const jumpImageKey = 'jumpImage' + obj.id
                         obj.image = linkValue
-                        obj.link = floorContent[subKey]
+                        obj.jumpType = floorContent[jumpTypeKey]
+                        obj.jumpLink = floorContent[jumpLinkKey]
+                        obj.jumpProductId = floorContent[jumpProductIdKey]
+                        obj.jumpImage = floorContent[jumpImageKey]
                         bannerList.push(obj)
                     }
                 }

+ 12 - 0
mixins/global.js

@@ -4,5 +4,17 @@ export default {
             // 静态资源路径
             staticUrl: 'https://static.caimei365.com/app/mini-hehe/icon/'
         }
+    },
+    methods: {
+        jumpAction(data) {
+            const { jumpType, jumpLink, jumpProductId, jumpImage } = data
+            // jumpType 跳转类型:1链接,2商品,3图片
+            const jumpMap = {
+                1: `others/web-view?websit=${encodeURIComponent(jumpLink)}`,
+                2: `goods/goods-detail?productId=${jumpProductId}&jumpState=0`,
+                3: `others/image-view?imageUrl=${encodeURIComponent(jumpImage)}`
+            }
+            this.$router.navigateTo(jumpMap[jumpType])
+        }
     }
 }

+ 6 - 0
pages.json

@@ -246,6 +246,12 @@
                     "navigationBarTitleText": "颜选美学",
                     "enablePullDownRefresh": false
                 }
+            }, {
+                "path": "image-view",
+                "style": {
+                    "navigationBarTitleText": "颜选美学",
+                    "enablePullDownRefresh": false
+                }
             }]
         }
     ],

+ 4 - 6
pages/tabBar/home/home.vue

@@ -133,7 +133,7 @@ export default {
             this.fetchCarousel()
             this.fetchNavbar()
             this.fetchFloorData()
-            this.fetchCouponList()
+            // this.fetchCouponList()
         },
 
         // 搜索
@@ -165,8 +165,8 @@ export default {
 
         // 商品楼层banner点击事件
         onBannerClick(banner) {
-            if (!banner.link) return
-            this.$router.navigateTo(`others/web-view?websit=${banner.link}`)
+            console.log(banner)
+            this.jumpAction(banner)
         },
 
         // 更多商品
@@ -182,9 +182,7 @@ export default {
 
         // 轮播图跳转
         onSwiperClick(index) {
-            const link = this.bannerData[index].link
-            if (!link) return
-            this.$router.navigateTo(`others/web-view?websit=${link}`)
+            this.jumpAction(this.bannerData[index])
         },
 
         // 获取轮播图列表

+ 3 - 3
pages/views/coupon/config/description.js

@@ -3,7 +3,7 @@ export default [{
     type: 'tip',
     title: '好友邀请券福利来袭啦',
     tip: '好友邀请券获取规则',
-    content: '用户登录颜选美学后,可通过商城首页或商城右上角按钮以及商品详情分享至好友,当好友通过您分享的链接进行注册登录后,您就可以获得一张好友邀请券的领券资格。',
+    content: '用户登录颜选美学后,可通过商城首页或商城右上角按钮以及商品详情分享至好友,当好友通过您分享的链接进行注册登录后,您就可以获得一张#price#好友邀请券的领券资格。',
     styleObj: {
         titleColor: '',
         tipColor: '',
@@ -14,11 +14,11 @@ export default [{
     type: 'tip',
     title: '好友消费券福利来袭啦',
     tip: '好友消费券获取规则',
-    content: '用户登录颜选美学后,可通过商城首页或商城右上角按钮以及商品详情分享至好友,当好友通过您分享的链接进行注册登录后,每消费一笔订单后,您就可以获得一张好友消费券的领券资格。'
+    content: '用户登录颜选美学后,可通过商城首页或商城右上角按钮以及商品详情分享至好友,当好友通过您分享的链接进行注册登录后,每消费一笔订单后,您就可以获得一张#price#好友消费券的领券资格。'
 }, {
     id: 3,
     type: 'tip',
     title: '分享券福利来袭',
     tip: '分享券获取规则',
-    content: '用户登录颜选美学后,每消费一笔订单后在支付完成页面点击分享给微信好友或生成海报分享后,您就可以获得一张消费分享券的领券资格。'
+    content: '用户登录颜选美学后,每消费一笔订单后在支付完成页面点击分享给微信好友或生成海报分享后,您就可以获得一张#price#消费分享券的领券资格。'
 }]

+ 21 - 2
pages/views/coupon/coupon-description.vue

@@ -3,18 +3,21 @@
         <view class="title" v-text="description.title"></view>
         <view class="description">
             <view class="tip" v-text="description.tip"></view>
-            <view class="content" v-text="description.content"></view>
+            <view class="content" v-text="content"></view>
         </view>
     </view>
 </template>
 
 <script>
 import description from './config/description.js'
+import { fetchShareCouponList } from '@/services/api/coupon.js'
 export default {
     data() {
         return {
             entryType: 1,
-            descriptionList: description
+            descriptionList: description,
+            types: ['inviteCouponList', 'consumeCouponList', 'shareCouponList'],
+            content: ''
         }
     },
     computed: {
@@ -27,6 +30,22 @@ export default {
         uni.setNavigationBarTitle({
             title: options.title
         })
+        this.fetchShareCouponList()
+    },
+    methods: {
+        async fetchShareCouponList() {
+            try {
+                const res = await fetchShareCouponList()
+                const key = this.types[this.entryType - 1]
+                const list = res.data[key]
+                if (list && list.length <= 0) return
+                const priceText = list.map(item => item + '元').join(',')
+                this.content = this.description.content.replace('#price#', priceText)
+            } catch (e) {
+                //TODO handle the exception
+                console.log(e)
+            }
+        }
     }
 }
 </script>

+ 2 - 1
pages/views/goods/goods-detail.vue

@@ -208,10 +208,11 @@ export default {
     onLoad(options) {
         this.productId = parseInt(options.productId)
         this.jumpState = parseInt(options.jumpState)
-        this.fetchProductDetail()
+        // this.fetchProductDetail()
     },
     onShow() {
         this.autoplay = true
+        this.fetchProductDetail()
     },
     onHide() {
         this.autoplay = false

+ 4 - 3
pages/views/order/mixins/orderShare.js

@@ -16,7 +16,7 @@ function handleFightShare(shareData, option) {
     return {
         type: 4,
         collageId: shareData.collageId,
-        initiatorId: shareData.buyUserId  
+        initiatorId: shareData.buyUserId
     }
 }
 
@@ -33,10 +33,11 @@ const orderShare = {
         }
         console.log(shareData)
         // 加密参数
-        const scenencodeURIComponent(this.$crypto.encrypt(shareData))
+        const state_str = encodeURIComponent(this.$crypto.encrypt(shareData))
         return {
             title: resultMessage.title,
-            path: `/pages/tabBar/index/index?scenecenscene        imageUrl: resultMessage.imageUrl
+            path: `/pages/tabBar/index/index?state_str=${state_str}`,
+            imageUrl: resultMessage.imageUrl 
         }
     }
 }

+ 54 - 0
pages/views/others/image-view.vue

@@ -0,0 +1,54 @@
+<template>
+    <image
+        class="image"
+        :src="imageUrl"
+        mode="aspectFit"
+        @load="onImageLoad"
+        :style="{ width: styleObj.width, height: styleObj.height }"
+    ></image>
+</template>
+
+<script>
+import { mapGetters } from 'vuex'
+export default {
+    data() {
+        return {
+            imageUrl: '',
+            detail: null
+        }
+    },
+    computed: {
+        ...mapGetters(['systemInfo']),
+        styleObj() {
+            if (!this.detail) return {}
+            const { width, height } = this.detail
+            const { screenWidth } = this.systemInfo
+            let w = width
+            let h = height
+            if (width > screenWidth) {
+                w = screenWidth
+                h = (height * screenWidth) / width
+            }
+            const style = { width: w + 'px', height: h + 'px' }
+            return style
+        }
+    },
+    onLoad(options) {
+        console.log(this.systemInfo)
+        this.imageUrl = options.imageUrl && decodeURIComponent(options.imageUrl)
+    },
+    methods: {
+        onImageLoad(e) {
+            console.log(e)
+            this.detail = e.detail
+        }
+    }
+}
+</script>
+
+<style scoped>
+.image {
+    display: block;
+    margin: 0 auto;
+}
+</style>

+ 9 - 0
services/api/coupon.js

@@ -80,3 +80,12 @@ export function fetchCouponDisplay(params) {
         params
     })
 }
+
+/* 获取优惠券列表 */
+export function fetchShareCouponList(params) {
+    return request({
+        url: '/coupon/share/amount/display',
+        method: 'GET',
+        params
+    })
+}