瀏覽代碼

页面bug修改

yuwenjun1997 3 年之前
父節點
當前提交
d6b607da82

+ 0 - 1
components/views/cm-coupon/cm-coupon.vue

@@ -171,7 +171,6 @@ export default {
         },
         // 领取优惠券
         async clickReceive() {
-            if (!this.userId) return this.$router.navigateTo('authorize/login-custom')
             try {
                 await this.receiveCoupon(this.couponData)
                 this.$emit('click', this.couponData)

+ 5 - 1
components/views/cm-floor-template/cm-floor-template.vue

@@ -51,7 +51,11 @@
         <!-- banner区域 -->
         <view class="floor-banner-area template-8" v-if="templateType === '8'">
             <view class="banner-item banner-item-1">
-                <image :src="item.image" class="banner" @click="$emit('onBannerClick', item)"></image>
+                <image
+                    :src="bannerList[0] && bannerList[0].image"
+                    class="banner"
+                    @click="$emit('onBannerClick', item)"
+                ></image>
             </view>
         </view>
     </view>

+ 199 - 208
components/views/cm-search/cm-search.vue

@@ -1,220 +1,211 @@
 <template>
-	<view class="cm-search">
-		<view class="search-control" @click.stop="handleClick">
-			<view class="search-input">
-				<text class="search-icon iconfont icon-sousuo"></text>
-				<input
-					type="text"
-					confirm-type="search"
-					:placeholder="placeholder"
-					v-model="inputValue"
-					:focus="false"
-					@focus="$emit('focus')"
-					@confirm="handleSearch(inputValue)"
-				/>
-				<text v-if="clearable && inputValue" class="clearable iconfont icon-quxiao" @click="clearValue"></text>
-			</view>
-			<view class="search-btn" @click="handleSearch(inputValue)">搜索</view>
-		</view>
-
-		<template v-if="keywordVisible && keywordList.length > 0">
-			<view class="hot-keyword">
-				<view class="title">
-					<text>搜索历史</text>
-					<text class="clear iconfont icon-shanchu" @click="$emit('remove')"></text>
-				</view>
-				<view class="keyword-list">
-					<view
-						class="keyword"
-						@click="handleSearch(keyword)"
-						v-for="(keyword, index) in keywordList"
-						:key="index"
-						v-text="keyword"
-					></view>
-				</view>
-			</view>
-			<view class="mask"></view>
-		</template>
-	</view>
+    <view class="cm-search">
+        <view class="search-control" @click.stop="handleClick">
+            <view class="search-input">
+                <text class="search-icon iconfont icon-sousuo"></text>
+                <input
+                    type="text"
+                    confirm-type="search"
+                    :placeholder="placeholder"
+                    :focus="false"
+                    :value="value"
+                    @input="e => $emit('input', e.target.value)"
+                    @focus="$emit('focus')"
+                    @confirm="handleSearch"
+                />
+                <text v-if="clearable && value" class="clearable iconfont icon-quxiao" @click="clearValue"></text>
+            </view>
+            <view class="search-btn" @click="handleSearch(value)">搜索</view>
+        </view>
+
+        <template v-if="keywordVisible && keywordList.length > 0">
+            <view class="hot-keyword">
+                <view class="title">
+                    <text>搜索历史</text>
+                    <text class="clear iconfont icon-shanchu" @click="$emit('remove')"></text>
+                </view>
+                <view class="keyword-list">
+                    <view
+                        class="keyword"
+                        v-for="(keyword, index) in keywordList"
+                        v-text="keyword"
+                        :key="index"
+                        @click="handleSearch(keyword)"
+                    ></view>
+                </view>
+            </view>
+            <view class="mask"></view>
+        </template>
+    </view>
 </template>
 
 <script>
 export default {
-	name: 'cm-search',
-	model: {
-		prop: 'value',
-		event: 'input'
-	},
-	props: {
-		value: {
-			typs: String,
-			default: ''
-		},
-		// 占位字符
-		placeholder: {
-			type: String,
-			default: '请输入搜索关键字'
-		},
-		clearable: {
-			type: Boolean,
-			default: true
-		},
-
-		disabled: {
-			type: Boolean,
-			default: false
-		},
-
-		keywordList: {
-			type: Array,
-			default: () => []
-		},
-
-		keywordVisible: {
-			type: Boolean,
-			default: true
-		}
-	},
-	watch: {
-		inputValue(nVal) {
-			this.$emit('input', nVal)
-		}
-	},
-	data() {
-		return {
-			inputValue: ''
-		}
-	},
-	created() {
-		this.inputValue = this.value
-	},
-	methods: {
-		clearValue() {
-			this.inputValue = ''
-			this.$emit('clear')
-		},
-		handleClick() {
-			if (!this.disabled) return
-			this.$emit('goSearch')
-		},
-		handleSearch(keyword) {
-			if (this.disabled) return
-			this.inputValue = keyword
-			this.$emit('search')
-		}
-	}
+    name: 'cm-search',
+    model: {
+        prop: 'value',
+        event: 'input'
+    },
+    props: {
+        value: {
+            typs: String,
+            default: ''
+        },
+        // 占位字符
+        placeholder: {
+            type: String,
+            default: '请输入搜索关键字'
+        },
+        clearable: {
+            type: Boolean,
+            default: true
+        },
+
+        disabled: {
+            type: Boolean,
+            default: false
+        },
+
+        keywordList: {
+            type: Array,
+            default: () => []
+        },
+
+        keywordVisible: {
+            type: Boolean,
+            default: true
+        }
+    },
+    methods: {
+        // 清空
+        clearValue() {
+            this.$emit('input', '')
+            this.$emit('clear')
+        },
+        // 搜索
+        handleClick() {
+            if (!this.disabled) return
+            this.$emit('goSearch')
+        },
+        // 关键词搜索
+        handleSearch(keyword) {
+            if (this.disabled) return
+            this.$emit('input', keyword)
+            this.$emit('search')
+        }
+    }
 }
 </script>
 
 <style lang="scss" scoped>
 .cm-search {
-	position: relative;
-
-	.hot-keyword {
-		position: relative;
-		z-index: 999;
-		width: 100%;
-		background: #fff;
-
-		box-sizing: border-box;
-		padding: 0 24rpx 32rpx;
-
-		.title {
-			position: relative;
-			font-size: 26rpx;
-			padding: 24rpx 0;
-			color: #333;
-			font-weight: bold;
-
-			.clear {
-				position: absolute;
-				font-weight: normal;
-				right: 0;
-				top: 50%;
-				transform: translateY(-50%);
-			}
-		}
-
-		.keyword {
-			display: inline-block;
-			margin-right: 18rpx;
-			font-size: 24rpx;
-			line-height: 40rpx;
-			padding: 0 16rpx;
-			border-radius: 20rpx;
-			background: #eee;
-			color: #333;
-		}
-	}
-
-	.mask {
-		position: fixed;
-		width: 100vw;
-		height: 100vh;
-		top: 0;
-		left: 0;
-		z-index: 998;
-		background: #f7f7f7;
-	}
-
-	.search-control {
-		position: relative;
-		z-index: 999;
-
-		border-bottom: 1rpx solid #f7f7f7;
-
-		display: flex;
-		justify-content: space-between;
-		align-items: center;
-		height: 90rpx;
-		background: #fff;
-
-		box-sizing: border-box;
-
-		padding: 0 24rpx;
-
-		.search-input {
-			flex: 1;
-			height: 60rpx;
-			line-height: 60rpx;
-			display: flex;
-			align-items: center;
-			position: relative;
-			padding-left: 74rpx;
-			font-size: 26rpx;
-			border-radius: 30rpx;
-			background: #f7f7f7;
-
-			input {
-				width: 100%;
-			}
-
-			.search-icon,
-			.clearable {
-				position: absolute;
-				top: 50%;
-				transform: translateY(-50%);
-				z-index: 9;
-			}
-
-			.search-icon {
-				left: 24rpx;
-			}
-
-			.clearable {
-				right: 24rpx;
-				color: #ccc;
-			}
-		}
-
-		.search-btn {
-			text-align: center;
-			width: 60rpx;
-			height: 60rpx;
-			line-height: 60rpx;
-			margin-left: 16rpx;
-			font-size: 26rpx;
-		}
-	}
+    position: relative;
+
+    .hot-keyword {
+        position: relative;
+        z-index: 999;
+        width: 100%;
+        background: #fff;
+
+        box-sizing: border-box;
+        padding: 0 24rpx 32rpx;
+
+        .title {
+            position: relative;
+            font-size: 26rpx;
+            padding: 24rpx 0;
+            color: #333;
+            font-weight: bold;
+
+            .clear {
+                position: absolute;
+                font-weight: normal;
+                right: 0;
+                top: 50%;
+                transform: translateY(-50%);
+            }
+        }
+
+        .keyword {
+            display: inline-block;
+            margin-right: 18rpx;
+            font-size: 24rpx;
+            line-height: 40rpx;
+            padding: 0 16rpx;
+            border-radius: 20rpx;
+            background: #eee;
+            color: #333;
+        }
+    }
+
+    .mask {
+        position: fixed;
+        width: 100vw;
+        height: 100vh;
+        top: 0;
+        left: 0;
+        z-index: 998;
+        background: #f7f7f7;
+    }
+
+    .search-control {
+        position: relative;
+        z-index: 999;
+
+        border-bottom: 1rpx solid #f7f7f7;
+
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        height: 90rpx;
+        background: #fff;
+
+        box-sizing: border-box;
+
+        padding: 0 24rpx;
+
+        .search-input {
+            flex: 1;
+            height: 60rpx;
+            line-height: 60rpx;
+            display: flex;
+            align-items: center;
+            position: relative;
+            padding-left: 74rpx;
+            font-size: 26rpx;
+            border-radius: 30rpx;
+            background: #f7f7f7;
+
+            input {
+                width: 100%;
+            }
+
+            .search-icon,
+            .clearable {
+                position: absolute;
+                top: 50%;
+                transform: translateY(-50%);
+                z-index: 9;
+            }
+
+            .search-icon {
+                left: 24rpx;
+            }
+
+            .clearable {
+                right: 24rpx;
+                color: #ccc;
+            }
+        }
+
+        .search-btn {
+            text-align: center;
+            width: 60rpx;
+            height: 60rpx;
+            line-height: 60rpx;
+            margin-left: 16rpx;
+            font-size: 26rpx;
+        }
+    }
 }
 </style>

+ 1 - 1
pages.json

@@ -36,7 +36,7 @@
     }, {
         "path": "pages/authorize/login-auth",
         "style": {
-            "navigationBarTitleText": "微信授权",
+            "navigationBarTitleText": "登录成功",
             "enablePullDownRefresh": false
         }
     }, {

+ 19 - 4
pages/authorize/login-auth.vue

@@ -1,9 +1,24 @@
 <template>
-	<view class=""></view>
+    <view></view>
 </template>
 
 <script>
-export default {};
+export default {
+    onLoad() {
+        this.$toast('登录成功')
+        const url = uni.getStorageSync('LOGIN_REDIRECT_URL')
+        if (url) {
+            if (url.indexOf('tabBar') > -1) {
+                uni.switchTab({ url })
+            } else {
+                uni.redirectTo({ url })
+            }
+        } else {
+            uni.switchTab({ url: '/pages/tabBar/user/user' })
+        }
+    },
+    beforeDestroy() {
+        uni.removeStorageSync('LOGIN_REDIRECT_URL')
+    }
+}
 </script>
-
-<style lang="scss"></style>

+ 6 - 8
pages/authorize/login-custom.vue

@@ -18,7 +18,8 @@
                         maxlength="6"
                     />
                     <view class="validate-code" @click="sendVerificationCode">
-                        <text v-if="!countDownStatus">获取验证码</text> <text v-else v-text="countDownTip"></text>
+                        <text v-if="!countDownStatus">获取验证码</text>
+                        <text v-else v-text="countDownTip"></text>
                     </view>
                 </view>
                 <tui-divider :height="dividerHeight"></tui-divider>
@@ -43,6 +44,7 @@
 import { getUserProfile } from '@/common/auth.js'
 import { validMobile } from '@/common/validation.js'
 import { sendMobileVerification } from '@/services/api/common.js'
+import { mapGetters } from 'vuex'
 export default {
     data() {
         return {
@@ -50,7 +52,6 @@ export default {
             tipMsg: '',
             countDownStatus: 0,
             // 用户注册登录信息
-            openId: '', //微信openId
             mobile: '', // 注册/绑定手机号
             headImgUrl: '', //微信头像
             nickName: '', //微信昵称
@@ -77,6 +78,7 @@ export default {
         }
     },
     computed: {
+        ...mapGetters(['openId']),
         tipMessage() {
             return this.tipMsg || '未注册的手机号验证后自动创建呵呵商城账户'
         },
@@ -118,12 +120,8 @@ export default {
             }
             try {
                 await this.$store.dispatch('user/register', params)
-                const url = uni.getStorageSync('LOGIN_REDIRECT_URL')
-                if (url) {
-                    this.$router.redirectTo(url)
-                } else {
-                    this.$router.switchTab('user')
-                }
+                // 登录成功处理
+                uni.redirectTo({ url: '/pages/authorize/login-auth' })
             } catch (e) {
                 this.submitStatus = false
             }

+ 19 - 18
pages/index/index.vue

@@ -18,7 +18,7 @@ export default {
     onLoad(options) {
         this.scene = options.scene
         this.state_str = options.state_str
-        this.init()
+        this.initUserInfo()
     },
     methods: {
         ...mapMutations('user', ['SET_USER_INFO']),
@@ -26,32 +26,33 @@ export default {
         ...mapActions('coupon', ['initCouponCount']),
         ...mapActions('cart', ['fetchCartKindCount']),
 
-        async init() {
-            await this.getAccessToken()
-            await this.initUserInfo()
-            await this.initCouponCount()
-            await this.fetchCartKindCount()
+        // 初始化页面数据
+        initPageData() {
+            this.getAccessToken()
+            this.initCouponCount()
+            this.fetchCartKindCount()
         },
 
         // 初始化用户信息
         async initUserInfo() {
-            this.$setStorage('ENTRY_MARK_TYPE', 'YES')
-            const user = this.$getStorage('USER_INFO')
-            if (user) {
-                // 用户已登录
-                this.SET_USER_INFO(user)
-                this.redirectToEntry()
-                return Promise.resolve()
-            }
             try {
-                // 微信登录
-                this.wxAutoLogin()
-                this.redirectToEntry()
-                return Promise.resolve()
+                const user = this.$getStorage('USER_INFO')
+                if (user) {
+                    // 用户已登录
+                    this.SET_USER_INFO(user)
+                } else {
+                    // 微信登录
+                    await this.wxAutoLogin()
+                }
             } catch (e) {
+                console.log('初始化用户信息时出现了错误')
                 console.log(e)
+            } finally {
+                this.initPageData()
+                this.redirectToEntry()
             }
         },
+
         // 跳转入口页面
         redirectToEntry() {
             if (this.scene) {

+ 1 - 1
pages/tabBar/cart/cart.vue

@@ -166,6 +166,7 @@ export default {
     onShow() {
         this.resetData()
         this.fetchCartInfo()
+        this.fetchCartKindCount()
     },
     methods: {
         ...mapActions('cart', ['removeFromCart', 'fetchCartKindCount']),
@@ -244,7 +245,6 @@ export default {
         // 获取购物车信息
         async fetchCartInfo() {
             try {
-                this.fetchCartKindCount()
                 const res = await fetchCartInfo({ userId: this.userId })
                 this.expiredProducts = res.data.products
                 this.shopList = res.data.shopList

+ 54 - 54
pages/tabBar/user/config.js

@@ -1,61 +1,61 @@
 // 订单导航
 export const navbarList = [{
-    id: 1,
-    name: '待付款',
-    icon: 'icon-order-1@2x.png',
-    badge: 0
-},
-{
-    id: 3,
-    name: '待发货',
-    icon: 'icon-order-2@2x.png',
-    badge: 0
-},
-{
-    id: 4,
-    name: '已发货',
-    icon: 'icon-order-3@2x.png',
-    badge: 0
-},
-{
-    id: 5,
-    name: '退货/款',
-    icon: 'icon-order-4@2x.png',
-    badge: 0
-}
+        id: 1,
+        name: '待付款',
+        icon: 'icon-order-1@2x.png',
+        badge: 0
+    },
+    {
+        id: 3,
+        name: '待发货',
+        icon: 'icon-order-2@2x.png',
+        badge: 0
+    },
+    {
+        id: 4,
+        name: '已发货',
+        icon: 'icon-order-3@2x.png',
+        badge: 0
+    },
+    {
+        id: 5,
+        name: '退货/款',
+        icon: 'icon-order-4@2x.png',
+        badge: 0
+    }
 ]
 
 // 操作菜单
 export const menusList = [{
-    id: 1,
-    name: '优惠券',
-    icon: 'icon-coupon.png',
-    count: '',
-    userIdentity: [1, 2],
-    hidden: false
-},
-{
-    id: 2,
-    name: '活动专区',
-    icon: 'icon-user-h@2x.png',
-    count: '',
-    userIdentity: [2],
-    hidden: false
-},
-{
-    id: 3,
-    name: '收货地址',
-    icon: 'icon-user-d@2x.png',
-    count: '',
-    userIdentity: [1, 2],
-    hidden: false
-},
-{
-    id: 4,
-    name: '在线客服',
-    icon: 'icon-user-c@2x.png',
-    count: '',
-    userIdentity: [1, 2],
-    hidden: false
-}
+        id: 1,
+        name: '优惠券',
+        icon: 'icon-coupon.png',
+        count: '',
+        userIdentity: [1, 2],
+        hidden: false
+    },
+    {
+        id: 2,
+        name: '活动专区',
+        icon: 'icon-user-h@2x.png',
+        count: '',
+        userIdentity: [2],
+        hidden: false
+    },
+    {
+        id: 3,
+        name: '收货地址',
+        icon: 'icon-user-d@2x.png',
+        count: '',
+        userIdentity: [-1, 1, 2],
+        hidden: false
+    },
+    {
+        id: 4,
+        name: '在线客服',
+        icon: 'icon-user-c@2x.png',
+        count: '',
+        userIdentity: [-1, 1, 2],
+        hidden: false
+    }
 ]

+ 12 - 1
pages/tabBar/user/user.vue

@@ -5,7 +5,7 @@
         <view class="info">
             <image class="avatar" :src="avatar" mode="widthFix"></image>
             <view class="name" v-if="nickName" v-text="nickName"></view>
-            <view class="login" hover-class="hover-class" hover-stay-time="100" v-else>登录</view>
+            <view class="login" hover-class="hover-class" hover-stay-time="100" v-else @click="onLogin">登录</view>
         </view>
         <!-- 订单信息 -->
         <view class="order">
@@ -100,6 +100,9 @@ export default {
         ...mapActions('coupon', ['initCouponCount']),
         // 订单跳转
         handleOrderClick(id = 0) {
+            if (!this.userId) {
+                return this.onLogin()
+            }
             this.$router.navigateTo(`order/order-list?current=${id}`)
         },
         // 菜单跳转
@@ -112,6 +115,7 @@ export default {
                     this.$router.navigateTo('activity/activity-area')
                     break
                 case 3:
+                    if (!this.userId) return this.onLogin()
                     this.$router.navigateTo('address/address-list')
                     break
                 default:
@@ -159,6 +163,13 @@ export default {
                 if (item.id === 1) item.count = this.unusedNum
                 return item.userIdentity.indexOf(this.userIdentity) > -1
             })
+        },
+        // 去登录
+        onLogin() {
+            const pages = getCurrentPages()
+            const page = pages[pages.length - 1]
+            uni.setStorageSync('LOGIN_REDIRECT_URL', page.$page.fullPath)
+            uni.redirectTo({ url: '/pages/authorize/login-custom' })
         }
     }
 }

+ 38 - 8
pages/views/goods/components/goods-price/goods-price.vue

@@ -3,7 +3,7 @@
         <view class="row">
             <view class="price">
                 <text class="amount">{{ productData.price | priceFormat }}</text>
-                <text class="delete">{{ productData.normalPrice | priceFormat }}</text>
+                <text class="delete" v-if="priceType !== 'normal'">{{ productData.normalPrice | priceFormat }}</text>
             </view>
             <view class="price-tags">
                 <template v-if="priceType !== 'normal'">
@@ -12,9 +12,13 @@
                     <view class="tag-xs" v-else>限时特价</view>
                 </template>
             </view>
-        </view>
-        <view class="row" v-if="hasCouponPrice">
             <!-- 券后价 -->
+            <view class="tag-qh" v-if="priceType === 'normal'">
+                券后价¥{{ productData.couponPrice | priceFormat }}
+            </view>
+        </view>
+        <!-- 券后价 -->
+        <view class="row" v-if="hasCouponPrice && priceType !== 'normal'">
             <view class="tag-qh">券后价¥{{ productData.couponPrice | priceFormat }}</view>
         </view>
 
@@ -23,19 +27,20 @@
             <view class="tip">距离结束</view>
             <view class="time">
                 <!-- 时 -->
-                <text class="hh">72</text>
+                <text class="hh" v-text="countDownTime.ddhh"></text>
                 :
                 <!-- 分 -->
-                <text class="mm">48</text>
+                <text class="mm" v-text="countDownTime.mm"></text>
                 :
                 <!-- 秒 -->
-                <text class="ss">33</text>
+                <text class="ss" v-text="countDownTime.ss"></text>
             </view>
         </view>
     </view>
 </template>
 
 <script>
+import { countDown } from '@/common/utils.js'
 export default {
     name: 'goods-price',
     props: {
@@ -44,8 +49,14 @@ export default {
             default: () => null
         }
     },
+    data() {
+        return {
+            timer: null,
+            countDownTime: {}
+        }
+    },
     computed: {
-        /* 商品价格类型 normal: 普通价 | group: 拼团价 | activity: 活动价 | time-limit: 限时特价 | */
+        /* 商品价格类型 normal: 普通价 | group: 拼团价 | activity: 活动价 | time-limit: 限时特价 | coupon: 券后价 */
         priceType() {
             let type
             if (this.productData.activeStatus > 0) {
@@ -61,7 +72,26 @@ export default {
         },
         // 有可使用优惠券
         hasCouponPrice() {
-            return this.couponStatus > 0
+            return this.productData.couponStatus > 0
+        }
+    },
+    watch: {
+        priceType(nVal) {
+            if (nVal === 'time-limit') {
+                this.countDown()
+            }
+        }
+    },
+    methods: {
+        // 倒计时
+        countDown() {
+            const startTime = Date.now()
+            const endTime = new Date(this.productData.discountEndTime).getTime()
+            this.timer && clearTimeout(this.timer)
+            countDown(endTime, startTime, {}, item => {
+                this.countDownTime = item.conttainer
+                this.timer = item.t
+            })
         }
     }
 }

+ 2 - 2
pages/views/goods/components/goods-receive-buy-popup/goods-receive-buy-popup.vue

@@ -12,7 +12,6 @@
                             <view class="count">
                                 <view class="label">数量</view>
                                 <cm-number-box class="number-box" v-model="count" :max="limitedNum"></cm-number-box>
-                                {{ limitedNum }}
                             </view>
                             <view
                                 class="clickable"
@@ -41,7 +40,8 @@
                     </template>
                 </view>
                 <tui-button type="base" width="600rpx" height="90rpx" shape="circle" @click="$emit('submit', count)">
-                    {{ navbarType === 'buy' ? (productData.couponStatus > 0 ? '领券购买' : '立即购买') : '加入购物车' }}
+                    <!-- {{ navbarType === 'buy' ? (productData.couponStatus > 0 ? '领券购买' : '立即购买') : '加入购物车' }} -->
+                    {{ navbarType === 'buy' ? (productData.couponStatus > 0 ? '领券购买' : '确认') : '确认' }}
                 </tui-button>
             </view>
         </uni-popup>

+ 8 - 2
pages/views/goods/config/config.js

@@ -5,7 +5,7 @@ export const navbarButtonGroup = {
         left: ['单独购买', '¥1000.00'],
         right: ['拼团购买', '¥1000.00']
     },
-    
+
     // 拼团 + 优惠券
     groupWithCoupon: {
         left: ['领券单独购买', '¥1000.00'],
@@ -17,7 +17,13 @@ export const navbarButtonGroup = {
         left: ['加入购物车'],
         right: ['领券购买', '¥1000.00']
     },
-    
+
+    // 限时活动 / 活动价 + 优惠券
+    normalWithCoupon: {
+        left: ['加入购物车'],
+        right: ['领券购买', '¥1000.00']
+    },
+
     // 普通方式 不使用优惠券
     normal: {
         left: ['加入购物车'],

+ 28 - 3
pages/views/goods/goods-detail.vue

@@ -39,7 +39,11 @@
         <!-- 商品详情 -->
         <view class="section detail">
             <view class="title">商品详情</view>
-            <view v-if="productDetail && productDetail.detailInfo" v-html="productDetail.detailInfo"></view>
+            <view
+                v-if="productDetail && productDetail.detailInfo"
+                v-html="productDetail.detailInfo"
+                style="overflow-x: hidden;"
+            ></view>
             <!-- 空 -->
             <view class="section-empty" v-else>暂无商品详情</view>
         </view>
@@ -195,6 +199,14 @@ export default {
 
             // 立即购买(提交商品信息)
             if (this.navbarTypeFlag === 'buy') {
+                if (!this.userId) {
+                    const pages = getCurrentPages()
+                    const page = pages[pages.length - 1]
+                    uni.setStorageSync('LOGIN_REDIRECT_URL', page.$page.fullPath)
+                    uni.redirectTo({ url: '/pages/authorize/login-custom' })
+                    return
+                }
+
                 const submitData = {
                     productId: this.productInfo.productId, // 产品id
                     productCount: count, // 产品购买数量
@@ -266,6 +278,8 @@ export default {
                 navbarButton.right[1] = `¥${this.productInfo.price.toFixed(2)}`
             } else if (this.navbarType === 'activityWithCoupon') {
                 navbarButton.right[1] = `¥${this.productInfo.couponPrice.toFixed(2)}`
+            } else if (this.navbarType === 'normalWithCoupon') {
+                navbarButton.right[1] = `¥${this.productInfo.couponPrice.toFixed(2)}`
             } else {
                 navbarButton.right[1] = ''
             }
@@ -285,6 +299,13 @@ export default {
                 this.$router.switchTab('home')
             }
             if (index === 2) {
+                if (!this.userId) {
+                    const pages = getCurrentPages()
+                    const page = pages[pages.length - 1]
+                    uni.setStorageSync('LOGIN_REDIRECT_URL', page.$page.fullPath)
+                    uni.redirectTo({ url: '/pages/authorize/login-custom' })
+                    return
+                }
                 this.$router.navigateTo('cart/cart')
             }
         },
@@ -354,8 +375,12 @@ export default {
                     return 'group'
                 }
             } else {
-                // 无优惠券
-                return 'normal'
+                if (couponStatus > 0) {
+                    return 'normalWithCoupon'
+                } else {
+                    // 无优惠券
+                    return 'normal'
+                }
             }
         },
 

+ 6 - 0
pages/views/goods/goods-list.vue

@@ -13,6 +13,12 @@
                 <cm-product :data="product"></cm-product>
             </view>
         </view>
+        <!-- 商品列表为空 -->
+        <template v-if="productList.length <= 0 && !isLoading">
+            <tui-no-data :imgUrl="staticUrl + 'icon-empty-address.png'" :imgHeight="230" :imgWidth="290">
+                <view class="empty-tip">暂无商品~~</view>
+            </tui-no-data>
+        </template>
         <!-- 加载更多 -->
         <cm-loadmore :hasNextPage="hasNextPage" :isLoading="isLoading" :visiable="!hideLoadmore"></cm-loadmore>
         <!-- 回到顶部 -->

+ 29 - 13
pages/views/goods/goods-search.vue

@@ -4,13 +4,13 @@
         <view class="order-top sticky-top">
             <cm-search
                 v-model="listQuery.name"
-                @search="handleSearch"
                 placeholder="请输入搜索关键字"
                 :keywordVisible="keywordVisible"
                 :keywordList="keywordList"
                 @focus="keywordVisible = true"
                 @clear="keywordVisible = true"
                 @remove="removeKeywordModal = true"
+                @search="handleSearch"
             ></cm-search>
         </view>
         <!-- 订单列表为空 -->
@@ -26,17 +26,24 @@
                     <view class="title">{{ product.name }}</view>
                     <view class="unit">规格:{{ product.unit }}</view>
                     <view class="tags">
-                        <view class="tag pt" v-if="product.collageStatus === 1">拼团价</view>
-                        <view class="tag hd" v-if="product.activeStatus == 1 && product.collageStatus === 0">
-                            活动价
-                        </view>
-                        <view class="tag hd" v-if="product.couponsLogo">优惠券</view>
+                        <!-- 拼团价  活动价  限时特价  券后价   -->
+                        <!-- 该商品参与了商城活动 -->
+                        <template v-if="isActivityProduct(product)">
+                            <view class="tag pt" v-if="product.collageStatus > 0">拼团价</view>
+                            <view class="tag hd" v-else-if="product.activeStatus > 0">活动价</view>
+                            <view class="tag other" v-else-if="product.discountStatus > 0">限时特价</view>
+                        </template>
+                        <!-- 该商品未参与商城活动 -->
+                        <template v-else>
+                            <view class="tag other" v-if="product.couponStatus > 1">{{ product.couponInfo }}</view>
+                            <view class="tag other" v-else-if="product.couponStatus > 0">券后价</view>
+                        </template>
                     </view>
                     <!-- 底部 -->
                     <view class="footer">
                         <!-- 价格 -->
                         <view class="price">
-                            <text>¥{{ product.price | priceFormat }}</text>
+                            <text>¥{{ showPrice(product) | priceFormat }}</text>
                             <text class="deleted" v-if="product.normalPrice">
                                 ¥{{ product.normalPrice | priceFormat }}
                             </text>
@@ -61,7 +68,7 @@
         <!-- 操作弹窗 -->
         <tui-modal :show="removeKeywordModal" content="确认清空搜索历史记录?" @click="clearAllHistory"></tui-modal>
         <!-- 安全区域 -->
-        <cm-safe-area-bottom v-if="!visiable"></cm-safe-area-bottom>
+        <cm-safe-area-bottom v-if="visiable"></cm-safe-area-bottom>
     </view>
 </template>
 
@@ -118,6 +125,14 @@ export default {
         }
     },
     methods: {
+        isActivityProduct(product) {
+            return product.collageStatus > 0 || product.activeStatus > 0 || product.discountStatus > 0
+        },
+
+        showPrice(product) {
+            return product.couponStatus === 1 && !this.isActivityProduct(product) ? product.couponPrice : product.price
+        },
+
         toDetail(row) {
             this.$router.navigateTo(`goods/goods-detail?jumpState=1?productId=${row.productId}`)
         },
@@ -138,11 +153,12 @@ export default {
         fetchList: debounce(async function() {
             this.listQuery.userId = this.userId
             try {
-                const res = await fetchProductList(this.listQuery)
-                this.total = res.data.total
-                this.hasNextPage = res.data.hasNextPage
-                this.list = [...this.list, ...res.data.list]
+                const { data } = await fetchProductList(this.listQuery)
+                this.total = data.pageInfo.totalRecord
+                this.hasNextPage = data.pageInfo.hasNextPage
+                this.list = [...this.list, ...data.pageInfo.results]
                 this.listQuery.pageNum++
+                this.isLoading = false
             } catch (e) {
                 console.log(e)
             }
@@ -151,7 +167,7 @@ export default {
         async fetchHistoryList() {
             try {
                 const res = await fetchProductSearchHistory({ userId: this.userId })
-                this.keywordList = res.data
+                this.keywordList = res.data.map(item => item.searchWord)
                 this.isLoading = false
             } catch (e) {
                 console.log(e)

+ 1 - 1
pages/views/order/order-list.vue

@@ -16,7 +16,7 @@
             @change="tabChange"
         ></tui-tabs>
         <!-- 协销订单筛选 -->
-        <order-dealer-filter @change="onFilterChange"></order-dealer-filter>
+        <order-dealer-filter @change="onFilterChange" v-if="isDealer"></order-dealer-filter>
         <!-- 页面轮播 -->
         <swiper
             :indicator-dots="false"

+ 4 - 3
pages/views/share-buy/share-buy-entry.vue

@@ -119,9 +119,10 @@ export default {
         onSubmit() {
             // 用户未登录
             if (!this.userId) {
-                const url = `share-buy/share-buy-entry?collageId=${this.collageId}`
-                uni.setStorageSync('LOGIN_REDIRECT_URL', url)
-                uni.navigateTo({ url: '/pages/authorize/login-custom' })
+                const pages = getCurrentPages()
+                const page = pages[pages.length - 1]
+                uni.setStorageSync('LOGIN_REDIRECT_URL', page.$page.fullPath)
+                uni.redirectTo({ url: '/pages/authorize/login-custom' })
                 return
             }
             // 提交订单信息

+ 8 - 7
services/http.interceptor.js

@@ -32,16 +32,17 @@ http.interceptors.request.use((config) => {
 http.interceptors.response.use((response) => {
     /* 对响应成功做点什么 可使用async await 做异步操作*/
     const code = response.data.code
-    // 未登录
-    if (code === -99) {
-        console.log('未登录/登录已失效')
-        return Promise.reject(response)
-    }
     // 服务端返回的状态码不等于-1,则reject()
-    if (code != 0) {
-        toast(response.data.msg || '网络异常')
+    if (code === -1) {
+        toast(response.data.msg || '系统错误')
         return Promise.reject(response.data)
     }
+    
+    // 用户未注册
+    if (code === -2) {
+        console.log('用户未注册')
+    }
+
     console.log(response.data)
     uni.hideLoading()
     return Promise.resolve(response.data)

+ 1 - 0
store/getters.js

@@ -6,6 +6,7 @@ const getters = {
     nickName: state => state.user.nickName,
     userIdentity: state => state.user.userIdentity,
     userId: state => state.user.userId,
+    openId: state => state.user.openId,
     accessToken: state => state.user.accessToken,
     unusedNum: state => state.coupon.unusedNum,
     expiredNum: state => state.coupon.expiredNum,

+ 10 - 1
store/modules/cart.js

@@ -22,13 +22,22 @@ const mutations = {
         if (num > 0) {
             return uni.setTabBarBadge({ index: 2, text: num.toString() })
         }
-        uni.setTabBarBadge({ index: 2, text: undefined })
+        uni.removeTabBarBadge({ index: 2 })
     },
 }
 
 const actions = {
     // 加入购物车
     async addToCart({ dispatch, rootGetters }, { productId, productCount = 1, heUserId = 0 }) {
+
+        if (!rootGetters.userId) {
+            const pages = getCurrentPages()
+            const page = pages[pages.length - 1]
+            uni.setStorageSync('LOGIN_REDIRECT_URL', page.$page.fullPath)
+            uni.redirectTo({ url: '/pages/authorize/login-custom' })
+            return Promise.reject('用户未登录')
+        }
+
         try {
             const res = await shoppingAddCart({ productId, userId: rootGetters.userId, productCount, heUserId })
             uni.showToast({ icon: 'success', title: '加入购物车成功' })

+ 9 - 0
store/modules/coupon.js

@@ -30,6 +30,15 @@ const mutations = {
 const actions = {
     // 领取优惠券
     async receiveCoupon({ rootGetters, dispatch }, { couponId, couponShareId }) {
+
+        if (!rootGetters.userId) {
+            const pages = getCurrentPages()
+            const page = pages[pages.length - 1]
+            uni.setStorageSync('LOGIN_REDIRECT_URL', page.$page.fullPath)
+            uni.redirectTo({ url: '/pages/authorize/login-custom' })
+            return Promise.reject('用户未登录')
+        }
+
         try {
             const res = await receiveCoupon({ couponId, couponShareId, userId: rootGetters.userId })
             uni.showToast({

+ 8 - 10
store/modules/user.js

@@ -8,11 +8,11 @@ const state = {
     headImgUrl: '',
     mobile: '',
     nickName: '',
-    openId: 'oFFip5SgfBKMHxgZLInIBTHdPGuk',
+    openId: '',
     userId: 0,
     userIdentity: -1, // 用户类型
     inviteUserId: '', // 分享者用户ID
-    accessToken: ''
+    accessToken: '' // token
 }
 
 const mutations = {
@@ -31,14 +31,13 @@ const actions = {
     // 微信自动登录
     async wxAutoLogin({ commit }) {
         try {
-            const code = await wxLogin()
-            const res = await wechatAuthLogin({ code })
+            const code = await wxLogin() // 获取微信code
+            const res = await wechatAuthLogin({ code }) // 微信自动登录
             const data = JSON.parse(res.data)
             commit('SET_USER_INFO', data)
             setStorage('USER_INFO', data)
             return Promise.resolve(data)
         } catch (e) {
-            console.log(e)
             return Promise.reject(e)
         }
     },
@@ -46,10 +45,11 @@ const actions = {
     async register({ commit }, resigterData) {
         try {
             const res = await mobileLogin(resigterData)
-            // return Promise.resolve(data) TODO
-            console.log(res)
+            const data = JSON.parse(res.data)
+            commit('SET_USER_INFO', data)
+            setStorage('USER_INFO', data)
+            return Promise.resolve(data)
         } catch (e) {
-            console.log(e)
             return Promise.reject(e)
         }
     },
@@ -60,8 +60,6 @@ const actions = {
             commit('SET_ACCESS_TOKEN', data)
             return Promise.resolve(data)
         } catch (e) {
-            console.log(e)
-            console.log('获取accessToken失败')
             return Promise.reject(e)
         }
     }