Browse Source

购物车

lilei 9 months ago
parent
commit
29bbc89fd6

+ 1 - 1
App.vue

@@ -1,7 +1,7 @@
 <script>
 	export default {
 		globalData: {
-			// baseUrl: 'http://192.168.2.10:7002/saas/clz/', // 本地
+			// baseUrl: 'http://192.168.2.113:9110/saas/clz/', // 本地
 			// baseUrl: 'https://md.test.zyucgj.com/saas/clz/', // 预发布
 			baseUrl: 'https://car.zyucgj.com/saas/clz/' // 生产
 		},

+ 54 - 0
api/cart.js

@@ -0,0 +1,54 @@
+import request from './request';
+
+// 获取购物车列表
+export function getCartList(params) {
+	return request({
+	  url: `shopCart/queryList/${params.pageNo}/${params.pageSize}`,
+	  method: 'post',
+	  data: params
+	})
+}
+
+// 添加商品到购物车
+export function addCart(params) {
+	return request({
+	  url: `shopCart/addProduct`,
+	  method: 'post',
+	  data: params
+	})
+}
+
+// 修改购物车商品数量
+export function updateCart(params) {
+	return request({
+	  url: `shopCart/updateProduct`,
+	  method: 'post',
+	  data: params
+	})
+}
+
+// 删除购物车商品
+export function deleteCart(params) {
+	return request({
+	  url: `shopCart/batchDelProduct`,
+	  method: 'post',
+	  data: params
+	})
+}
+
+// 购物车总数
+export function getCartCount(params) {
+	return request({
+	  url: `shopCart/productCount`,
+	  method: 'post',
+	  data: params
+	})
+}
+// 商城是否开启
+export function getShopStatus(params) {
+	return request({
+	  url: `shopCart/findMallParam`,
+	  method: 'post',
+	  data: params
+	})
+}

+ 1 - 1
api/rewardRule.js

@@ -28,4 +28,4 @@ export const getRewardRollList = (params) => {
     data: params,
     method: 'post'
   })
-}
+}

+ 8 - 0
api/user.js

@@ -45,4 +45,12 @@ export const ticketQueryList = params => {
     method: 'post',
     data: params
   })
+}
+// 促销活动优惠券-总数
+export const ticketQueryCount = params => {
+  return request({
+    url: `ticket/getAllTicketPrice`,
+    method: 'post',
+    data: params
+  })
 }

+ 106 - 100
pages/index/index.vue

@@ -157,6 +157,7 @@
 	import { scanVinLogQueryRoll, getScanVinLogList, getScanGetMaxQty }from '@/api/car.js'
 	import { promoTerminalList } from '@/api/video.js'
 	import { getRewardRollList } from '@/api/rewardRule.js'
+	import { getShopStatus } from '@/api/cart.js'
 	import { openWebView } from "@/utils/index.js"
 	export default {
 		components: {
@@ -528,113 +529,118 @@
 					this.status = 'nomore'
 				})
 			},
+			// 商品分类
+			getGoodType(){
+				const list = [
+					{
+						id:'0',
+						sn:'0',
+						name:'轮胎',
+						icon:'/static/temp/t1.jpeg',
+						url: 'ptypeNav',
+						target: 'fun'
+					},
+					{
+						id:'1',
+						sn:'1',
+						name:'滤清器',
+						icon:'/static/temp/t2.jpeg',
+						url: 'ptypeNav',
+						target: 'fun'
+					},
+					{
+						id:'2',
+						sn:'3',
+						name:'刹车片',
+						icon:'/static/temp/t4.jpg',
+						url: 'ptypeNav',
+						target: 'fun'
+					},{
+						id:'4',
+						sn:'4',
+						name:'油品',
+						icon:'/static/temp/t5.png',
+						url: 'ptypeNav',
+						target: 'fun'
+					},{
+						id:'5',
+						sn:'5',
+						name:'雨刮',
+						icon:'/static/temp/t11.jpg',
+						url: 'ptypeNav',
+						target: 'fun'
+					},{
+						id:'6',
+						sn:'6',
+						name:'火花塞',
+						icon:'/static/temp/t6.jpeg',
+						url: 'ptypeNav',
+						target: 'fun'
+					},{
+						id:'7',
+						sn:'7',
+						name:'电火线圈',
+						icon:'/static/temp/t7.jpg',
+						url: 'ptypeNav',
+						target: 'fun'
+					},{
+						id:'8',
+						sn:'8',
+						name:'照明系列',
+						icon:'/static/temp/t9.jpg',
+						url: 'ptypeNav',
+						target: 'fun'
+					},{
+						id:'9',
+						sn:'9',
+						name:'空气滤',
+						icon:'/static/temp/t10.jpg',
+						url: 'ptypeNav',
+						target: 'fun'
+					},{
+						id:'10',
+						sn:'10',
+						name:'机油率',
+						icon:'/static/temp/t3.jpg',
+						url: 'ptypeNav',
+						target: 'fun'
+					},{
+						id:'11',
+						sn:'11',
+						name:'电瓶电池',
+						icon:'/static/temp/t8.jpg',
+						url: 'ptypeNav',
+						target: 'fun'
+					},{
+						id:'12',
+						sn:'12',
+						name:'洗美养护',
+						icon:'/static/temp/t12.jpg',
+						url: 'ptypeNav',
+						target: 'fun'
+					}
+				]
+				// 转成二维数组
+				for(let i=0;i<list.length;i=i+8){
+					this.productTypeList.push({
+						id: 'swiper-item-'+i,
+						list: list.slice(i,(i+8)>list.length?list.length:(i+8))
+					})
+				}
+			},
 			// 商城信息, flag: true 再次刷新,false 首次加载
 			getHasShopping(flag){
 				if(!flag){
-					setTimeout(()=>{
-						this.hasShopiing = true
+					getShopStatus().then(res => {
+						this.hasShopiing = res.data && res.data.paramValue == 1
 						// 有商城
 						if(this.hasShopiing){
 							// 隐藏tab 视频,显示购物车tab
 							this.showCatTab()
 							// 商品分类
-							const list = [
-								{
-									id:'0',
-									sn:'0',
-									name:'轮胎',
-									icon:'/static/temp/t1.jpeg',
-									url: 'ptypeNav',
-									target: 'fun'
-								},
-								{
-									id:'1',
-									sn:'1',
-									name:'滤清器',
-									icon:'/static/temp/t2.jpeg',
-									url: 'ptypeNav',
-									target: 'fun'
-								},
-								{
-									id:'2',
-									sn:'3',
-									name:'刹车片',
-									icon:'/static/temp/t4.jpg',
-									url: 'ptypeNav',
-									target: 'fun'
-								},{
-									id:'4',
-									sn:'4',
-									name:'油品',
-									icon:'/static/temp/t5.png',
-									url: 'ptypeNav',
-									target: 'fun'
-								},{
-									id:'5',
-									sn:'5',
-									name:'雨刮',
-									icon:'/static/temp/t11.jpg',
-									url: 'ptypeNav',
-									target: 'fun'
-								},{
-									id:'6',
-									sn:'6',
-									name:'火花塞',
-									icon:'/static/temp/t6.jpeg',
-									url: 'ptypeNav',
-									target: 'fun'
-								},{
-									id:'7',
-									sn:'7',
-									name:'电火线圈',
-									icon:'/static/temp/t7.jpg',
-									url: 'ptypeNav',
-									target: 'fun'
-								},{
-									id:'8',
-									sn:'8',
-									name:'照明系列',
-									icon:'/static/temp/t9.jpg',
-									url: 'ptypeNav',
-									target: 'fun'
-								},{
-									id:'9',
-									sn:'9',
-									name:'空气滤',
-									icon:'/static/temp/t10.jpg',
-									url: 'ptypeNav',
-									target: 'fun'
-								},{
-									id:'10',
-									sn:'10',
-									name:'机油率',
-									icon:'/static/temp/t3.jpg',
-									url: 'ptypeNav',
-									target: 'fun'
-								},{
-									id:'11',
-									sn:'11',
-									name:'电瓶电池',
-									icon:'/static/temp/t8.jpg',
-									url: 'ptypeNav',
-									target: 'fun'
-								},{
-									id:'12',
-									sn:'12',
-									name:'洗美养护',
-									icon:'/static/temp/t12.jpg',
-									url: 'ptypeNav',
-									target: 'fun'
-								}
-							]
-							// 转成二维数组
-							for(let i=0;i<list.length;i=i+8){
-								this.productTypeList.push({
-									id: 'swiper-item-'+i,
-									list: list.slice(i,(i+8)>list.length?list.length:(i+8))
-								})
-							}
-						}else{ // 没有商城
+							this.getGoodType()
+						}else{ 
+							// 没有商城
 							// 滚动扫描记录
 							this.getScrollLog()
 							// 获取扫描记录
@@ -642,7 +648,7 @@
 						}
 						// 查询是否有数字货架
 						this.getStoreShelf(flag)
-					},150)
+					})
 				}else{
 					if(!this.hasShopiing){
 						// 滚动扫描记录

+ 27 - 1
pages/morePage/morePage.vue

@@ -44,6 +44,7 @@
 				<view class="list-title flex align_center justify_between" @click="toPage('/pagesB/redPacket')">
 					<view><u-icon size="34" color="#f10000" name="red-packet-fill"></u-icon> <text style="color: #ff0000;margin-left: 10rpx;">红包奖励</text></view>
 					<view>
+						<u-badge :absolute="false" :count="redPackCount"></u-badge>
 						<u-icon size="28" color="#969799" name="arrow-right"></u-icon>
 					</view>
 				</view>
@@ -52,6 +53,7 @@
 				<view class="list-title flex align_center justify_between" @click="toPage('/pagesB/coupon')">
 					<view><u-icon size="34" color="#ff7d0b" name="gift-fill"></u-icon> <text style="color: #ff7d0b;margin-left: 10rpx;">我的优惠券</text></view>
 					<view>
+						<u-badge :absolute="false" :count="couponCount"></u-badge>
 						<u-icon size="28" color="#969799" name="arrow-right"></u-icon>
 					</view>
 				</view>
@@ -103,6 +105,8 @@
 	} from 'vuex'
 	import UniStatusBar from '@/components/uni-status-bar/uni-status-bar.vue'
 	import { queryQplsConfig,getProductfindByScanCode } from '@/api/shelf.js'
+	import { findUserReward } from '@/api/rewardRule.js'
+	import { ticketQueryCount } from '@/api/user.js'
 	export default {
 		components: {
 			UniStatusBar // 状态栏组件
@@ -114,7 +118,9 @@
 				showPriceSet: false,
 				shelfSn: null,
 				avatarUrl:'', // 用户图像
-				navHeight: 44
+				navHeight: 44,
+				couponCount: 0,
+				redPackCount: 0
 			}
 		},
 		computed: {
@@ -313,12 +319,32 @@
 			if(this.shelfSn){
 				this.getPriceCofig()
 			}
+			// 获取优惠券总数
+			if(this.hasLogin&&this.$hasPermissions('M_couponList_mini')){
+				this.getCouponCount()
+			}
+			// 红包总金额
+			if(this.hasRedPacket&&this.hasShelf){
+				this.getUserReward()
+			}
 		},
 		// 页面卸载
 		onUnload() {
 			uni.$off('refashProm')
 		},
 		methods: {
+			// 获取优惠券数量
+			getCouponCount(){
+				ticketQueryCount().then(res => {
+					this.couponCount = res.data ? res.data.ticketValue : 0
+				})
+			},
+			// 红包总金额
+			getUserReward(){
+				findUserReward().then(res => {
+					this.redPackCount = res.data ? res.data.rewardAmount : 0
+				})
+			},
 			// 查看用户信息
 			toUser(){
 				if(this.hasLogin){

+ 79 - 78
pagesB/cart/index.vue

@@ -32,12 +32,12 @@
 					</sticky-header>
 					<productItem
 					v-for="(item, index) in list"
-					:key="item.id"  
+					:key="index"  
 					:index="index"
 					:list="item" 
 					@changeQty="changeQty" 
 					@check="chooseItem"
-					@remove="removeChoose">
+					@remove="removeCart">
 					</productItem>
 					<!-- loading -->
 					<view class="loading-bar" v-if="list.length==0 && status!='loading'">{{noDataText}}</view>
@@ -68,9 +68,9 @@
 									<text>¥{{totalAmount}}</text>
 								</view>
 							</view>
-							<view class="cart-head-btton red" v-if="editFlag" @click="clearAll">
+							<!-- <view class="cart-head-btton red" v-if="editFlag" @click="clearAll">
 								<text>清空购物车</text>
-							</view>
+							</view> -->
 							<view class="cart-footer-right-button">
 								<button class="btns" v-if="!editFlag" type="warn" size="mini" @click="settlement">去结算</button>
 								<button v-else class="btns" type="warn" plain size="mini" @click="batchRemove">删除</button>
@@ -89,6 +89,8 @@
 	    mapMutations,
 	} from 'vuex'
 	import productItem from '@/pagesB/cart/productitem.vue'
+	import { getCartList, updateCart, deleteCart } from '@/api/cart.js'
+	
 	export default {
 		components:{
 			productItem
@@ -99,11 +101,7 @@
 			this.screenWidth = uni.getSystemInfoSync().windowWidth
 			this.screenHeight = uni.getSystemInfoSync().windowHeight
 			this.safeAreaBottom = uni.getSystemInfoSync().safeAreaInsets.bottom
-			
-			this.cacheList = this.getCacheList()
-			this.cacheList.forEach(key => {
-				this.total += key.length // 总款数
-			})
+			// 获取列表数据
 			this.pageInit()
 		},
 		data() {
@@ -116,14 +114,13 @@
 				},
 				// 查询条件
 				pageNo: 1,
-				pageSize: 3,
+				pageSize: 5,
 				list: [],
 				total: 0,
 				totalAmount: 0,
 				totalNum: 0,
 				editFlag: false,
 				allChecked: false,
-				cacheList: [],
 				screenWidth: 325,
 				screenHeight: 0,
 				statusBarHeight: 44,
@@ -140,11 +137,6 @@
 			goBack(){
 				uni.navigateBack()
 			},
-			// 从缓存获取数据
-			getCacheList(){
-				const cacheList = this.$store.state.vuex_cartList.find(k => k.sn == '693459699332595712')
-				return cacheList ? JSON.parse(JSON.stringify(cacheList.list)) : []
-			},
 			pageInit(){
 				this.pageNo = 1
 				this.list = []
@@ -161,34 +153,22 @@
 			    pageSize: this.pageSize,
 				queryWord: this.queryWord
 			  }
-			  const storeShelf = this.$store.state.vuex_storeShelf
 			  this.status = "loading"
-			  setTimeout(()=>{
-				  let list = this.cacheList.slice(this.list.length,this.pageNo*this.pageSize)||[]
+			  getCartList(params).then(res => {
+				if (res.status == 200) {
+				  const list = res.data.list
 				  list.forEach(key => {
-					  key.forEach(s => {
-						   s.checked = this.allChecked
-					  })
+				  		key.checked = this.allChecked
 				  })
-				  this.list = this.list.concat(list)
-				  this.status = this.total>=this.list.length ? "nomore" : 'loadmore'
+				  _this.list.push(list)
+				  _this.total = res.data.count || 0
+				} else {
+				  _this.list = []
+				  _this.total = 0
+				  _this.noDataText = res.message
+				}
+				_this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
 			  })
-			 //  promoTerminalListByPage(params).then(res => {
-				// if (res.code == 200 || res.status == 204 || res.status == 200) {
-				//   const list = res.data.list
-				//   if(_this.pageNo>1){
-				// 	  _this.list = _this.list.concat(list)
-				//   }else{
-				// 	  _this.list = list
-				//   }
-				//   _this.total = res.data.count || 0
-				// } else {
-				//   _this.list = []
-				//   _this.total = 0
-				//   _this.noDataText = res.message
-				// }
-				// _this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
-			 //  })
 			},
 			// scroll-view到底部加载更多
 			onreachBottom() {
@@ -199,25 +179,32 @@
 					this.status = "nomore"
 				}
 			},
-			// 根据id查找
-			getItemById(id){
-				const a = this.list.findIndex(k => k.find(s=> s.id == id))
-				const b = a>=0 ? this.list[a].findIndex(s=> s.id == id) : -1
+			// 根据cartSn查找
+			getItemById(cartSn){
+				const a = this.list.findIndex(k => k.find(s=> s.cartSn == cartSn))
+				const b = a>=0 ? this.list[a].findIndex(s=> s.cartSn == cartSn) : -1
 				return {p:a,s:b}
 			},
 			// 已选产品变更数量
-			changeQty(val,id){
-				const crow = this.getItemById(id)
-				if(crow.p>=0&&crow.s>=0){
-					this.list[crow.p][crow.s].qty = val
-					this.list[crow.p].splice()
-					// 合计
-					this.getChooseHeji()
-				}
+			changeQty(val,cartSn){
+				updateCart({
+					cartSn: cartSn,
+					qty: val
+				}).then(res => {
+					if(res.status == 200){
+						const crow = this.getItemById(cartSn)
+						if(crow.p>=0&&crow.s>=0){
+							this.list[crow.p][crow.s].qty = val
+							this.list[crow.p].splice()
+							// 合计
+							this.getChooseHeji()
+						}
+					}
+				})
 			},
 			// 选择
-			chooseItem(id){
-				const crow = this.getItemById(id)
+			chooseItem(cartSn){
+				const crow = this.getItemById(cartSn)
 				if(crow.p>=0&&crow.s>=0){
 					this.list[crow.p][crow.s].checked = !this.list[crow.p][crow.s].checked
 					// 合计
@@ -248,15 +235,11 @@
 					confirmText: '确定',
 					success(res) {
 						if(res.confirm){
-							// uni.showLoading({
-							// 	title: '正在清空...',
-							// 	mask: true
-							// })
-							_this.list = []
-							_this.cacheList = []
-							_this.allChecked = false
-							_this.editFlag = false
-							_this.getChooseHeji()
+							uni.showLoading({
+								title: '正在清空...',
+								mask: true
+							})
+							
 						}
 					}
 				})
@@ -273,9 +256,9 @@
 				this.getChooseHeji()
 			},
 			//单个删除
-			removeChoose(id,isBatch){
+			removeChoose(cartSn,isBatch){
 				// 删除项
-				const crow = this.getItemById(id)
+				const crow = this.getItemById(cartSn)
 				if(crow.p>=0&&crow.s>=0){
 					this.list[crow.p].splice(crow.s, 1);
 					this.total = this.total - 1
@@ -301,24 +284,42 @@
 					confirmText: '确定',
 					success(res) {
 						if(res.confirm){
-							 // 如果是全选
-							 if(_this.allChecked){
-							 	_this.list = []
-								_this.cacheList = []
-							 	_this.allChecked = false
-							 }else{
-							 	_this.list.forEach(item => {
-							 		item.filter(k=>k.checked).forEach(s=>{
-							 			_this.removeChoose(s.id,true)
-							 		})
+							const snList = []
+							 _this.list.forEach(item => {
+							 	item.filter(k=>k.checked).forEach(s=>{
+							 		snList.push(s.cartSns)
 							 	})
-							 }
-							 // 合计
-							 _this.getChooseHeji()
+							 })
+							 // 删除购物车
+							 this.removeCart(snList)
 						}
 					}
 				})
 			},
+			// 删除商品
+			removeCart(snList){
+				const _this = this
+				deleteCart({cartSns:snList}).then(ret => {
+					 if(ret.status == 200){
+						 uni.showToast({
+							 title: '删除成功',
+							 icon: 'none'
+						 })
+						 // 如果全选
+						 if(_this.allChecked){
+							 _this.list = []
+							 _this.allChecked = false
+						 }
+						 snList.forEach(sn => {
+							 _this.removeChoose(sn,snList.length>1)
+						 })
+						 // 合计
+						 if(snList.length>1){
+							 _this.getChooseHeji()
+						 }
+					 }
+				})
+			},
 			// 去结算
 			settlement(){
 				if(this.totalAmount>0){

+ 12 - 12
pagesB/cart/productitem.vue

@@ -2,9 +2,9 @@
 	<block>
 		<view class="choose-product-item"
 		v-for="(item, dix) in list"
-		:key="item.id" 
+		:key="item.cartSn" 
 		>
-			<view class="choose-product-item-check" @click="checkItem(item.id)">
+			<view class="choose-product-item-check" @click="checkItem(item.cartSn)">
 				<image style="width: 24px;height: 24px;" mode="aspectFill" :src="'../static/'+(item.checked?'round_check_fill':'round')+'.png'"></image>
 			</view>
 			 <view>
@@ -25,14 +25,14 @@
 						<view>
 							<view :style="{opacity:!item.edit?1:0,width:!item.edit?'auto':0}">
 								<view class="flex align_center qty-box">
-									<view class="qty-btn" @click="changeQty(item.qty-1,item.id,1)" :class="(item.qty <= 1)?'qty-disabled':''">-</view>
-									<view class="qty-num"><input type="number" @blur="changeQty(item.qty,item.id,0)" v-model="item.qty"/></view>
-									<view class="qty-btn" @click="changeQty(item.qty+1,item.id,1)" :class="(item.qty >= 999999)?'qty-disabled':''">+</view>
+									<view class="qty-btn" @click="changeQty(item.qty-1,item.cartSn,1)" :class="(item.qty <= 1)?'qty-disabled':''">-</view>
+									<view class="qty-num"><input type="number" @blur="changeQty(item.qty,item.cartSn,0)" v-model="item.qty"/></view>
+									<view class="qty-btn" @click="changeQty(item.qty+1,item.cartSn,1)" :class="(item.qty >= 999999)?'qty-disabled':''">+</view>
 								</view>
 							</view>
 							<view v-if="item.edit" class="edit-qty">
 								X <text>{{item.qty}}</text>
-								<image style="width: 24px;height: 24px;" mode="aspectFill" :src="'../static/ashbin.png'" @click="remove(item.id)"></image>
+								<image style="width: 24px;height: 24px;" mode="aspectFill" :src="'../static/ashbin.png'" @click="remove(item.cartSn)"></image>
 							</view>
 						</view>
 					</view>
@@ -60,17 +60,17 @@
 			}
 		},
 		methods: {
-			changeQty(e, id) {
+			changeQty(e, cartSn) {
 				if(e<=0 || e>=999999){
 					return
 				}
-				this.$emit('changeQty', e, id)
+				this.$emit('changeQty', e, cartSn)
 			},
-			remove(id){
-				this.$emit('remove', id, false)
+			remove(cartSn){
+				this.$emit('remove', [cartSn])
 			},
-			checkItem(id){
-				this.$emit('check',id)
+			checkItem(cartSn){
+				this.$emit('check',cartSn)
 			}
 		}
 	}

+ 74 - 19
pagesB/shopiing/productDetail.vue

@@ -23,7 +23,9 @@
 							¥<text class="price-red">45.8</text>
 						</view>
 						<view class="product-info-nums">
-							<view @click="share"><u-icon :size='24' name="zhuanfa"></u-icon> 分享</view>
+							<view class="share">
+								<button open-type="share"><u-icon :size='24' name="zhuanfa"></u-icon> 分享</button>
+							</view>
 						</view>
 					</view>
 				</view>
@@ -100,6 +102,7 @@
 </template>
 
 <script>
+	import { addCart, getCartCount } from '@/api/cart.js'
 	export default {
 		data() {
 			return {
@@ -113,39 +116,72 @@
 					'https://cdn.uviewui.com/uview/swiper/1.jpg',
 					'https://cdn.uviewui.com/uview/swiper/2.jpg',
 				],
-				totalNum: 0 // 购物车总数
+				totalNum: 0 ,// 购物车总数
+				productSn: null,
+				detail: null
 			}
 		},
-		onLoad() {
+		onLoad(option) {
 			// 计算安全区域
 			this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
 			this.safeAreaBottom = uni.getSystemInfoSync().safeAreaInsets.bottom
+			this.productSn = option.sn
+			// 购物车数量
+			this.cartCount()
+			// 获取产品详情
+			this.getDetail()
+		},
+		// 分享
+		onShareAppMessage(e){
+			return {
+			  title: '产品标题',
+			  path: '/pagesB/shopiing/productDetail?sn='+this.productSn,
+			  imageUrl:'https://cdn.uviewui.com/uview/swiper/1.jpg',
+			  type: '1',
+			}
 		},
-		onShareAppMessage() {},
 		methods: {
 			// 返回
 			goBack(){
 				uni.navigateBack()
 			},
-			// 分享
-			share(){
-				uni.share({
-					provider: "weixin",
-					title:"产品标题",
-					scene: "WXSceneSession",
-					type: 0,
-					imageUrl: "https://cdn.uviewui.com/uview/swiper/1.jpg",
-					success: function (res) {
-						console.log("success:" + JSON.stringify(res));
-					},
-					fail: function (err) {
-						console.log("fail:" + JSON.stringify(err));
+			// 产品详情
+			getDetail(){
+				uni.showLoading({
+					title: '加载中'
+				})
+				// 获取产品详情
+				getDetail({
+					productSn: this.productSn
+				}).then(res => {
+					if(res.status == 200){
+						uni.hideLoading()
 					}
-				});
+				})
 			},
+			// 购物车数量
+			cartCount(){
+				getCartCount({}).then(res => {
+					if(res.status == 200){
+						this.totalNum = res.data?res.data.qty:0
+					}
+				})
+	        },
 			// 加入购物车
 			addCart(){
-				
+				addCart({
+					qty:19,
+					price: 10,
+					productSn:13
+				}).then(res => {
+					if(res.status == 200){
+						this.cartCount()
+						uni.showToast({
+							title: '加入成功',
+							icon: 'success'
+						})
+					}
+				})
 			},
 			// 打开购物车
 			toCart(){
@@ -245,6 +281,25 @@
 									display: flex;
 									align-items: center;
 								}
+								.share{
+									button{
+										width: auto;
+										padding: 0;
+										border: 0;
+										background: none;
+										line-height: normal;
+										margin: 0;
+										display: inline;
+										font-size: 12px;
+										color: #999;
+										&::after{
+											border:none;
+										}
+										/deep/ .u-icon{
+											margin-right: 3px;
+										}
+									}
+								}
 							}
 						}
 					}

+ 1 - 1
pagesB/shopiing/searchProduct.vue

@@ -188,7 +188,7 @@
 					pageNo: this.pageNo,
 					pageSize: this.pageSize,
 					queryWord: this.queryWord,
-					promoActiveSn: '693459699332595712'
+					promoActiveSn: '692378329129918464'
 				}).then(res => {
 					this.loading = false
 					if(res.status == 200){