diff --git a/src/pages/cart/cart.vue b/src/pages/cart/cart.vue index 21f4b19..4612a9d 100644 --- a/src/pages/cart/cart.vue +++ b/src/pages/cart/cart.vue @@ -8,7 +8,7 @@ <view class="cardHeader"> <view v-bind:class="pIsoPen? 'partentChecked' : 'partentCheck'" - @click="pClick" + @click="pClick" > <span class="correct"></span> </view> @@ -26,7 +26,7 @@ > <view v-bind:class="cartList[index].isChecked? 'partentChecked':'partentCheck'" - @click="childClick(cartList[index],index)" + @click="childClick(cartList[index],index)" > <span class="correct"></span> </view> @@ -46,18 +46,25 @@ class="goodName" @tap="toGoods(item.pid,item.sk_id)" >{{item.p_name}}</view> - <view class="describ" @click="showBottom(3,item.pid,item.sk_id,item.mp_id,item.cart_id,index)"> - <view class="desL"> - <view class="people"> - 使用人:{{item.peopleName}} - </view> - <view class="skuInfo"> - {{item.sku_name}} - </view> - </view> - <view class="desR"> - <image src="../../static/right.png" mode="aspectFit" style="width: 18rpx;height: 18rpx;"></image> - </view> + <view + class="describ" + @click="showBottom(3,item.pid,item.sk_id,item.mp_id,item.cart_id,index)" + > + <view class="desL"> + <view class="people"> + 使用人:{{item.peopleName}} + </view> + <view class="skuInfo"> + {{item.sku_name}} + </view> + </view> + <view class="desR"> + <image + src="../../static/right.png" + mode="aspectFit" + style="width: 18rpx;height: 18rpx;" + ></image> + </view> </view> <view class="priceBox"> <view class="price">¥{{item.nowPrice*item.num}}</view> @@ -86,87 +93,101 @@ <view class="footer"> <view class="footerLeft">实付金额:<text>¥{{totalPrice}}</text></view> <view class="footerRight"> - <view class="paybtn" @click="toComfirmOrder">立即结算</view> + <view + class="paybtn" + @click="toComfirmOrder" + >立即结算</view> </view> </view> - <BottomSheet v-if="isShowBottom" :isCart="isCart" @addCart="addCart" :sk_id="sk_id" :propMpId="mp_id" @chooseCartModi="chooseCartModi" :cart_id="cart_id" - :index="cartIndex" - :pid="pid" :goodInfo="goodInfo" :isShowBottom="isShowBottom" @closeBottom="closeBottom"></BottomSheet> + <BottomSheet + v-if="isShowBottom" + :isCart="isCart" + @addCart="addCart" + :sk_id="sk_id" + :propMpId="mp_id" + @chooseCartModi="chooseCartModi" + :cart_id="cart_id" + :index="cartIndex" + :pid="pid" + :goodInfo="goodInfo" + :isShowBottom="isShowBottom" + @closeBottom="closeBottom" + ></BottomSheet> </view> </template> <script> import store from '@/store' -import BottomSheet from '../../components/BottomSheet/BottomSheet.vue'; -export default { - components:{ - BottomSheet, - }, +import BottomSheet from '../../components/BottomSheet/BottomSheet.vue' +export default { + components: { + BottomSheet, + }, data() { return { - pid:Number, - isCart:Number, - sk_id:String, - mp_id:String, - isShowBottom : false, //底部弹窗开关 - cart_id:Number, - maxCount: 20, - cartIndex:Number, - cartList:[] + pid: Number, + isCart: Number, + sk_id: String, + mp_id: String, + isShowBottom: false, // 底部弹窗开关 + cart_id: Number, + maxCount: 20, + cartIndex: Number, + cartList: [], } }, computed: { - pIsoPen (){ - if (this.cartList.length > 0){ - return this.cartList.find(item => !item.isChecked) ? false : true; - } - return false - }, - goodInfo () { + pIsoPen () { + if (this.cartList.length > 0) { + return !this.cartList.find(item => !item.isChecked) + } + return false + }, + goodInfo () { return this.$store.state.read.goodInfo - }, - totalPrice() { - let totalPrice = 0 - this.cartList.forEach((item)=>{ - if(item.isChecked){ - totalPrice += item.nowPrice * item.num; + }, + totalPrice() { + let totalPrice = 0 + this.cartList.forEach((item) => { + if (item.isChecked) { + totalPrice += item.nowPrice * item.num } - }) - return totalPrice - } - }, + }) + return totalPrice + }, + }, onShow() { - this.cartList = this.$store.state.cart.cartList; + this.cartList = this.$store.state.cart.cartList }, onLoad: async function() { await this.$store.dispatch('cart/getCartList', { uid: this.$store.state.user.userInfo.uid, // 用户id }) - - this.cartList = this.$store.state.cart.cartList; - this.cartList.forEach((item)=>{ + + this.cartList = this.$store.state.cart.cartList + this.cartList.forEach((item) => { item.isChecked = false - }) + }) }, methods: { - //全选按钮 - pClick(){ - let pStatus = this.cartList.find(item => !item.isChecked) ? false : true - let oldList = this.cartList; - oldList.forEach((item, index)=>{ + // 全选按钮 + pClick() { + const pStatus = !this.cartList.find(item => !item.isChecked) + const oldList = this.cartList + oldList.forEach((item, index) => { item.isChecked = !pStatus - this.cartList.splice(index,1, item) + this.cartList.splice(index, 1, item) }) }, - //单选按钮 - childClick(type,index){ + // 单选按钮 + childClick(type, index) { this.cartList[index].isChecked = !this.cartList[index].isChecked - //vue没有办法监听数组内部值的变化,所以需要通过这个方法去触发 - this.cartList.splice(index,1, this.cartList[index]) + // vue没有办法监听数组内部值的变化,所以需要通过这个方法去触发 + this.cartList.splice(index, 1, this.cartList[index]) }, - //修改购物车 - chooseCartModi(mp_id,sk_id,price,pid,num,cart_id,index){ + // 修改购物车 + chooseCartModi(mp_id, sk_id, price, pid, num, cart_id, index) { // console.log('modi',mp_id,sk_id,price,pid,num,cart_id) store.dispatch('cart/modiCart', { uid: this.$store.state.user.userInfo.uid, @@ -177,57 +198,57 @@ export default { pid: pid, num: num, cart_id: cart_id, - args: { + args: { index: index, - }, - }) - this.$nextTick(function(){ - store.dispatch('cart/getCartList', { - uid: this.$store.state.user.userInfo.uid, // 用户id - }).then(()=>{ - this.cartList = this.$store.state.cart.cartList; - }) + }, + }) + this.$nextTick(function() { + store.dispatch('cart/getCartList', { + uid: this.$store.state.user.userInfo.uid, // 用户id + }).then(() => { + this.cartList = this.$store.state.cart.cartList + }) }) }, - //底部弹窗开关 - showBottom(isCart,pid,skId,mp_id,cart_id,index){ + // 底部弹窗开关 + showBottom(isCart, pid, skId, mp_id, cart_id, index) { store.dispatch('read/fetch', { - pid, - sk_id: skId, - }).then(()=>{ + pid, + sk_id: skId, + }).then(() => { this.cartIndex = index - this.sk_id = skId; - this.pid = pid; - this.mp_id = mp_id; - this.isCart = isCart; - this.cart_id = cart_id; - this.isShowBottom = true; + this.sk_id = skId + this.pid = pid + this.mp_id = mp_id + this.isCart = isCart + this.cart_id = cart_id + this.isShowBottom = true }) }, - closeBottom(){ - this.isShowBottom = false; + closeBottom() { + this.isShowBottom = false }, - toGoods(id, sk_id) { + toGoods(id, skId) { uni.navigateTo({ - url: '../frameDetail/frameDetail?pid=' + id + '&sk_id=' + sk_id, + url: '../details/details?pid=' + id + '&sk_id=' + skId, success: res => {}, fail: () => {}, complete: () => {}, }) }, - toComfirmOrder(){ - this.$store.state.cart.checkedCartLst = this.cartList.filter(item => item.isChecked) - if(this.$store.state.cart.checkedCartLst.length>0){ - uni.navigateTo({ - url:`../confirmOrder/confirmOrder?isCart=true`, - }) - }else{ - uni.showToast({ - title:'您还没有选择宝贝哦~', - icon:'none' - }) - } - }, + toComfirmOrder() { + this.$store.state.cart.checkedCartLst = this.cartList.filter(item => item.isChecked) + if (this.$store.state.cart.checkedCartLst.length > 0) { + uni.navigateTo({ + url: '../confirmOrder/confirmOrder?isCart=true', + }) + } else { + uni.showToast({ + title: '您还没有选择宝贝哦~', + icon: 'none', + }) + } + }, counter(index, isadd, item) { // console.log('item=====>', item) // console.log('num=====>', item.num) @@ -258,7 +279,7 @@ export default { this.desDisabled = true } else { this.desDisabled = false - + store.dispatch('cart/modiCart', { uid: this.$store.state.user.userInfo.uid, openid: this.$store.state.user.userInfo.openid, @@ -276,14 +297,13 @@ export default { this.desDisabled = true } } - }, delCart(cart_id, index) { cart_id = parseInt(cart_id) uni.showModal({ title: '是否删除该商品', success: function (res) { - if (res.confirm) { + if (res.confirm) { store.dispatch('cart/delCart', { uid: this.$store.state.user.userInfo.uid, openid: this.$store.state.user.userInfo.openid, @@ -292,7 +312,7 @@ export default { }) } }.bind(this), - }) + }) // this.cartList.splice(index,1) }, }, @@ -407,7 +427,7 @@ export default { align-items: flex-start; justify-content: space-between; min-height: 240rpx; - width: 100%; + width: 100%; .goodName { display: -webkit-box; -webkit-box-orient: vertical; @@ -420,23 +440,21 @@ export default { .describ { width: 100%; min-height: 80rpx; - background: #F9F9F9; - border-radius: 2px; + background: #f9f9f9; + border-radius: 2px; box-sizing: border-box; padding: 10rpx; font-size: 20rpx; letter-spacing: -0.23px; color: #999999; - display: flex; - justify-content: space-between; - align-items: center; - .desL{ - - view{ - margin: 10rpx 0 10rpx 0 ; - } - } - + display: flex; + justify-content: space-between; + align-items: center; + .desL { + view { + margin: 10rpx 0 10rpx 0; + } + } } .priceBox { display: flex; @@ -519,9 +537,9 @@ export default { } } /* 隐藏滚动条 */ - ::-webkit-scrollbar { - width: 0; - height: 0; - color: transparent; - } -</style> \ No newline at end of file +::-webkit-scrollbar { + width: 0; + height: 0; + color: transparent; +} +</style> diff --git a/src/pages/details/details.vue b/src/pages/details/details.vue index 752993d..b754f32 100644 --- a/src/pages/details/details.vue +++ b/src/pages/details/details.vue @@ -371,10 +371,9 @@ export default { } else { myName = '【' + myName + '】' } - const uid = uni.getStorageSync('uid') return { title: 'Hi,' + myName + '送你300元来试戴最新潮流眼镜!', // 默认是小程序的名称(可以写slogan等) - path: '/pages/index/detail/index?uid=' + uid + '&sid=0&pid=' + this.pid, + path: '/pages/details/details?sid=0&pid=' + this.pid, imageUrl: this.skuList[0].pic, // 不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4 success: function (res) { if (res.errMsg === 'shareAppMessage:ok') { @@ -461,6 +460,7 @@ export default { .swiperImage { width: 684rpx; height: 480rpx; + text-align: center; image { max-width: 100%; max-height: 100%; diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 7d4dab4..2c2443c 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -198,6 +198,32 @@ export default { showDrawer(e) { this.$refs[e].open() }, + // 朋友圈设置页面 + onShareAppMessage() { + let myName = this.$store.state.user.userInfo.nickName + if (myName === '' || myName.length < 1 || myName === '匿名用户' || typeof myName === 'undefined') { + myName = '【神秘人】' + } else { + myName = '【' + myName + '】' + } + return { + title: 'Hi,' + myName + '送你300元来试戴最新潮流眼镜!', // 默认是小程序的名称(可以写slogan等) + path: '/pages/index/index', + // imageUrl: '/static/img/details/d1.png', // 不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4 + success: function (res) { + if (res.errMsg === 'shareAppMessage:ok') { + console.log('分享成功!', res) + } + }, + fail: function (res) { + if (res.errMsg === 'shareAppMessage:fail cancel') { + console.log('fail', '放弃分享') + } else if (res.errMsg === 'shareAppMessage:fail') { + console.log('fail', '分享失败') + } + }, + } + }, getList() { store.dispatch('index/list') this.isLoading = false // TODO:::这里不知道怎么改,请同学帮忙写一下。 diff --git a/src/pages/user/user.vue b/src/pages/user/user.vue index 1304db0..13ffa64 100644 --- a/src/pages/user/user.vue +++ b/src/pages/user/user.vue @@ -36,16 +36,16 @@ <button @tap="chatOur(2)">客服2</button> </view> </uni-popup> -<!-- <scroll-view + <!-- <scroll-view enable-flex @scrolltolower="handleScrolltolower" scroll-y style="height: 1000px;" > --> - <view - v-if="isAuth" - class="content" - > + <view + v-if="isAuth" + class="content" + > <view class="userInfo"> <view class="info"> <image @@ -135,13 +135,16 @@ </view> <image src="../../static/right.png" mode="aspectFit"></image> </view> --> - <view class="item"> + <view + @tap="toAddress" + class="item" + > <image src="../../static/address-icon.png" mode="aspectFit" ></image> <view class="left"> - <text @tap="toAddress">地址管理</text> + <text>地址管理</text> <image class="image2" src="../../static/right.png" @@ -150,26 +153,32 @@ </view> </view> - <view class="item"> + <view + @tap="introduce" + class="item" + > <image src="../../static/img/user/introduce.png" mode="aspectFit" ></image> <view class="left"> - <text @tap="introduce">系统介绍</text> + <text>系统介绍</text> <image src="../../static/right.png" mode="aspectFit" ></image> </view> </view> - <view class="item"> + <view + @tap="joinUs" + class="item" + > <image src="../../static/img/user/joinUs.png" mode="aspectFit" ></image> <view class="left"> - <text @tap="joinUs">加入我们</text> + <text>加入我们</text> <image src="../../static/right.png" mode="aspectFit" @@ -198,26 +207,30 @@ </view> <!-- 商品列表 --> <view class="goods-list"> -<!-- <scroll-view + <!-- <scroll-view enable-flex @scrolltolower="handleScrolltolower" scroll-y class="product-list" > --> - <view class="product-list"> + <view class="product-list"> <view class="product" v-for="(item, index) in userRecommandList" :key="index" > - <Card :goods="item" :scrollTop="scrollTop" :viewHeight="viewHeight"></Card> + <Card + :goods="item" + :scrollTop="scrollTop" + :viewHeight="viewHeight" + ></Card> </view> - </view> + </view> <!-- </scroll-view> --> <view class="loading-text">{{loadingText}}</view> </view> </view> - </view> + </view> <view v-else class="auth" @@ -232,7 +245,7 @@ @getuserinfo="onGotUserInfo" >授权登陆</button> </view> - <!-- </scroll-view> --> + <!-- </scroll-view> --> </view> </template> @@ -244,21 +257,21 @@ import UniPopup from '@/components/UniPopup/uni-popup.vue' export default { components: { Card, - UniPopup + UniPopup, }, data() { return { isAuth: true, // 是否显示授权页面, pagesnum: 1, // 分页请求初始值 - whichTap: 0 ,// 弹窗渲染选择条件 + whichTap: 0, // 弹窗渲染选择条件 loadingText: '到底了', scrollTop: 0, viewHeight: uni.getSystemInfoSync().windowHeight, } }, - onPageScroll({scrollTop}) { + onPageScroll({ scrollTop }) { // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件 - this.scrollTop = scrollTop; + this.scrollTop = scrollTop }, onLoad() { // 判断是否授权 @@ -270,12 +283,12 @@ export default { } else { this.isAuth = false } - } + }, }) store.dispatch('userRecommand/getRecommandList', { uid: this.$store.state.user.userInfo.uid, openid: this.$store.state.user.userInfo.openid, - page: this.pagesnum + page: this.pagesnum, }) }, onReachBottom() { @@ -284,7 +297,7 @@ export default { store.dispatch('userRecommand/getRecommandList', { uid: this.$store.state.user.userInfo.uid, openid: this.$store.state.user.userInfo.openid, - page: this.pagesnum + page: this.pagesnum, }) }, computed: { @@ -295,9 +308,9 @@ export default { return this.$store.state.user.userInfo.headerphoto }, userRecommandList() { - console.log('userRecommandList=====>',this.$store.state.userRecommand.recommandList) + console.log('userRecommandList=====>', this.$store.state.userRecommand.recommandList) return this.$store.state.userRecommand.recommandList - } + }, }, methods: { // 弹窗 @@ -308,11 +321,11 @@ export default { chatOur(item) { if (item === 1) { uni.makePhoneCall({ - phoneNumber: 13376189297 // 客服1 电话 + phoneNumber: 13376189297, // 客服1 电话 }) } else { uni.makePhoneCall({ - phoneNumber: 18014995101 // 客服2 电话 + phoneNumber: 18014995101, // 客服2 电话 }) } }, @@ -330,19 +343,19 @@ export default { url: '../address/addressList', success: res => {}, fail: () => {}, - complete: () => {} + complete: () => {}, }) }, introduce() { uni.showModal({ content: '这是一款眼镜及周边产品的销售平台,我们将帮您进行建立全球销售网络,欢迎入住。', - showCancel: false + showCancel: false, }) }, joinUs() { uni.showModal({ content: '本平台欢迎全国各地的眼镜工厂、品牌、眼镜店加入。请联系我们申请注册账号', - showCancel: false + showCancel: false, }) }, toMyOrder(status) { @@ -350,15 +363,15 @@ export default { url: `../myOrder/myOrder?status=${status}`, success: res => {}, fail: () => {}, - complete: () => {} + complete: () => {}, }) }, toOpticsData() { uni.navigateTo({ - url: '../addOpticsData/addOpticsData' + url: '../addOpticsData/addOpticsData', }) - } - } + }, + }, } </script> @@ -376,7 +389,7 @@ export default { background-color: #f2f2f2; } .userInfo { - background-image: linear-gradient(270deg, #f79067 0%, #FF5F3B 66%); + background-image: linear-gradient(270deg, #f79067 0%, #ff5f3b 66%); width: 100%; height: 240rpx; color: #ffffff; @@ -472,7 +485,7 @@ export default { flex-direction: row; justify-content: space-between; align-items: center; - border-bottom: 1px solid #F5F5F5; + border-bottom: 1px solid #f5f5f5; font-weight: bold; font-size: 18px; color: #333333; @@ -538,7 +551,7 @@ export default { align-items: center; justify-content: space-between; height: 72rpx; - border-bottom: 1px solid #F2F2F2; + border-bottom: 1px solid #f2f2f2; image { margin-right: 0; height: 16px; @@ -550,9 +563,9 @@ export default { width: 40rpx; height: 44rpx; } - .lastLeft{ - border-bottom: none; - } + .lastLeft { + border-bottom: none; + } } } .recommend {