cmy 5 лет назад
Родитель
Сommit
7be916b20c

+ 11 - 0
.hbuilderx/launch.json

@@ -0,0 +1,11 @@
+{ // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
+  // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
+    "version": "0.0",
+    "configurations": [{
+            "type": "uniCloud",
+            "default": {
+                "launchtype": "remote"
+            }
+        }
+    ]
+}

+ 8 - 2
pages/product/groupBooking/productCollage.vue

@@ -25,7 +25,7 @@
 			<view class="title" >{{goodsObjact.title}}</view>
 			<view class="bot-row flex1">
 				<view>快递:¥ {{goodsObjact.postage}}</view>
-				<view>剩余:{{ goodsObjact.quota}}件</view>
+				<view>剩余:{{ goodsObjact.allStock}}件</view>
 				<view>销量:{{ goodsObjact.sales }}</view>
 			</view>
 		</view>
@@ -380,7 +380,8 @@ export default {
 			option: '', //保存传值
 			opt: '', //保存小程序传值
 			uniquetype:false,//判断是否是从拼团详情界面跳回的 false 不是  true 是 
-			shop:''//返回的拼团订单id
+			shop:'',//返回的拼团订单id
+			allStock:0//商品总库存
 		};
 	},
 	onLoad(option) {
@@ -443,6 +444,11 @@ export default {
 			let goods = data.storeInfo;
 			obj.imgList = goods.images;//拼团轮播图
 			obj.goodsObjact = goods;//拼团拼团产品信息
+			// 保存商品总库存
+			obj.allStock = 0;
+			for(let key in 	data.productValue){
+				obj.allStock +=data.productValue[key].stock
+			}
 			obj.pinkTlist = data.pink;//进行中的拼团的信息
 			obj.showlist = obj.pinkTlist.slice(0, 2);//截取拼团信息的前两组
 			obj.replyCount = data.replyCount;//评价总数

+ 6 - 5
pages/product/groupBooking/productGroup.vue

@@ -338,11 +338,12 @@
 					obj.goodsNumberMax = obj.productValue[str].stock;
 					obj.actionImage = obj.productValue[str].image;
 					obj.uniqueId = obj.productValue[str].unique;
-					if (obj.goodsType == 2) {
-						obj.goodsStore = obj.productValue[str].quota;
-					} else {
-						obj.goodsStore = obj.productValue[str].product_stock;
-					}
+					obj.goodsStore = obj.productValue[str].stock;
+					// if (obj.goodsType == 2) {
+					// 	obj.goodsStore = obj.productValue[str].quota;
+					// } else {
+					// 	obj.goodsStore = obj.productValue[str].product_stock;
+					// }
 				} else {
 					(obj.buys_show = false), (obj.buys_shows = true);
 				}

+ 39 - 0
utils/log.js

@@ -0,0 +1,39 @@
+
+const logLength=100;//缓存存储上限
+const name = 'log';//缓存名字
+export function addLog (data,content='') {
+	let log = uni.getStorageSync(name)||[];
+	log.unshift({
+		title:data,
+		content:content
+	});
+	uni.setStorageSync(name,log);
+	initLog(log);
+}
+
+
+export function delLog () {
+	return uni.setStorageSync(name,'');
+}
+
+export function getLog () {
+	return uni.getStorageSync(name);
+}
+
+export function initLog (log) {
+	if(log.length>logLength){
+		const newarr = log.slice(log.length-logLength);
+		uni.setStorageSync(name,newarr);
+	}
+}
+export function showLog (log) {
+	
+	let str = '';
+	uni.getStorageSync(name).forEach((e) => {
+		str+=e.title+':'+JSON.stringify(e.content)
+	})
+	uni.showModal({
+		title:"日志",
+		content:str
+	})
+}

+ 127 - 90
utils/wxAuthorized.js

@@ -3,7 +3,7 @@ import {
 	share
 } from '@/api/wx';
 // 加载日志
-import * as log from '@/libs/log.js'
+import * as log from './log.js'
 import {
 	isAndroid
 } from './platform.js'
@@ -52,7 +52,9 @@ export function loginWinxin() {
 function weixinSq() {
 	// 微信授权后跳转页面
 	try {
-		let ul = encodeURIComponent(store.state.baseURL + store.state.urlFile + '/pages/redirect/redirect');
+		// 判断是否真实路由模式
+		const type = router.mode === "history"?'':'/#'
+		let ul = encodeURIComponent(store.state.baseURL + store.state.urlFile +type+ '/pages/redirect/redirect');
 		// 打开微信授权页面
 		let url =
 			'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
@@ -72,110 +74,144 @@ function weixinSq() {
 // 微信注册
 export function weixindata(config) {
 	let url;
-	if (router.mode === "history") {
-		if (window.entryUrl === '') {
-			window.entryUrl = location.href.split('#')[0]
+	try {
+		if (router.mode === "history") {
+			// 在ios中时候注册为微信刚进入时候的页面
+			if (window.entryUrl === '') {
+				window.entryUrl = location.href.split('#')[0]
+			}
+			url = isAndroid() ? location.href.split('#')[0] : window.entryUrl;
 		}
-		url = isAndroid() ? location.href.split('#')[0] : window.entryUrl;
-	}
-	if (router.mode === "hash") {
-		url = location.href.split('#')[0];
+		if (router.mode === "hash") {
+			url = location.href.split('#')[0];
+		}
+		log.addLog('注册开始', url)
+		console.log('开始注册', url);
+
+	} catch (e) {
+		console.log('错误', e);
 	}
-	log.addLog('注册开始',url)
 	return new Promise((ok, error) => {
-		//注册微信信息
-		wechatConfig({
-				url
-			})
-			.then(({
-				data
-			}) => {
-				// 保存appId
-				appId = data.appId
-				// 微信信息配置
-				weixinObj.config({
-					debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-					appId: data.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
-					timestamp: data.timestamp, // 必填,生成签名的时间戳
-					nonceStr: data.nonceStr, // 必填,生成签名的随机串
-					signature: data.signature, // 必填,签名,见附录1
-					jsApiList: data.jsApiList // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
-				});
-				weixinObj.ready((e) => {
-					ok(data)
+		try {
+			//注册微信信息
+			wechatConfig({
+					url
 				})
-
-			})
-			.catch(e => {
-				error(e);
-				console.log(e);
-			});
+				.then(({
+					data
+				}) => {
+					try {
+						// 保存appId
+						appId = data.appId
+						// 微信信息配置
+						weixinObj.config({
+							debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+							appId: data.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
+							timestamp: data.timestamp, // 必填,生成签名的时间戳
+							nonceStr: data.nonceStr, // 必填,生成签名的随机串
+							signature: data.signature, // 必填,签名,见附录1
+							jsApiList: data.jsApiList // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
+						});
+						weixinObj.ready((e) => {
+							log.addLog("注册完毕", data)
+							console.log('注册完毕');
+							ok(data)
+						})
+					} catch (e) {
+						console.log(e)
+					}
+				})
+				.catch(e => {
+					error(e);
+					console.log(e);
+				});
+		} catch (e) {
+			console.log(e);
+			//TODO handle the exception
+		}
 	})
 }
 
 // 判断分享调用方法
-function shareLoad(config) {
-	weixindata().then((e) => {
-		// 判断有无自定义数据
-		if (config) {
-			shareFun(config)
-		} else {
-			// 判断是否已经缓存了默认数据
-			if (shareData) {
-				shareFun()
+export function shareLoad(config) {
+	console.log('开始调用分享')
+	try {
+		weixindata().then((e) => {
+			// 判断有无自定义数据
+			if (config) {
+				shareFun(config)
 			} else {
-				// 请求获取默认数据
-				share({}).then(({
-					data
-				}) => {
-					shareData = data.data
+				// 判断是否已经缓存了默认数据
+				if (shareData) {
 					shareFun()
-				});
+				} else {
+					// 请求获取默认数据
+					share({}).then(({
+						data
+					}) => {
+						shareData = data.data
+						shareFun()
+					});
+				}
 			}
-		}
-	})
+		})
+	} catch (e) {
+		console.log('报错', e)
+		//TODO handle the exception
+	}
 }
 // 配置分享数据
 function shareFun(config) {
-	let mess;
-	if (config) {
-		mess = {
-			link: config.link, // 分享链接
-			imgUrl: config.imgUrl,
-			desc: config.desc,
-			title: config.title,
-			success: config.success,
-			fail: config.fail
-		}
-	} else {
-		const userInfo = uni.getStorageSync('userInfo')
-		console.log(userInfo);
-		const url = window.location.href + '?spread=' + userInfo.uid;
-		url = url.replace(/[\?,&]{0,1}from=singlemessage/g, '');
-		mess = {
-			title: shareData.title,
-			link: url, // 分享链接
-			imgUrl: shareData.img, // 分享图标
-			desc: shareData.synopsis,
-			success: function() {
-				// uni.showModal({
-				// 	title: '分享',
-				// 	content: '分享成功',
-				// 	showCancel: false,
-				// 	success: res => {
-				//    console.log('分享成功回调接口');
-				// 	},
-				// 	fail: () => {},
-				// 	complete: () => {}
-				// });
+	try {
+		console.log('再付分享内容', config);
+		let mess;
+		if (config) {
+			mess = {
+				link: config.link, // 分享链接
+				imgUrl: config.imgUrl,
+				desc: config.desc,
+				title: config.title,
+				success: config.success || function(e) {
+					console.log(e);
+				},
+				fail: config.fail || function(e) {
+					console.log(e);
+				}
+			}
+		} else {
+			const userInfo = uni.getStorageSync('userInfo')
+			console.log(userInfo);
+			const url = window.location.href + '?spread=' + userInfo.uid;
+			url = url.replace(/[\?,&]{0,1}from=singlemessage/g, '');
+			mess = {
+				title: shareData.title,
+				link: url, // 分享链接
+				imgUrl: shareData.img, // 分享图标
+				desc: shareData.synopsis,
+				success: function() {
+					// uni.showModal({
+					// 	title: '分享',
+					// 	content: '分享成功',
+					// 	showCancel: false,
+					// 	success: res => {
+					//    console.log('分享成功回调接口');
+					// 	},
+					// 	fail: () => {},
+					// 	complete: () => {}
+					// });
+				}
 			}
 		}
+		// 获取仓库数据
+		// 分享好友
+		weixinObj.updateAppMessageShareData(mess);
+
+		// 分享朋友圈
+		weixinObj.updateTimelineShareData(mess)
+	} catch (e) {
+		console.log(e);
+		//TODO handle the exception
 	}
-	// 获取仓库数据
-	// 分享好友
-	weixinObj.updateAppMessageShareData(mess);
-	// 分享朋友圈
-	weixinObj.updateTimelineShareData(mess)
 }
 
 // 保存路由对象
@@ -187,5 +223,6 @@ export default {
 	weixinObj,
 	shareData,
 	appId,
-	setRouter
+	setRouter,
+	shareLoad
 }