lhl 3 years ago
parent
commit
c9b71f3176
11 changed files with 1337 additions and 1232 deletions
  1. 263 263
      App.vue
  2. 42 43
      main.js
  3. 4 2
      pages/cart/cart.vue
  4. 4 2
      pages/category/category.vue
  5. 32 1
      pages/index/index.vue
  6. 3 1
      pages/product/list.vue
  7. 694 632
      pages/product/product.vue
  8. 2 0
      pages/store/storeDetail.vue
  9. 46 43
      pages/user/shareQrCode.vue
  10. 2 0
      pages/user/user.vue
  11. 245 245
      utils/wxAuthorized.js

+ 263 - 263
App.vue

@@ -1,263 +1,263 @@
-<script>
-/**
- * vuex管理登陆状态,具体可以参考官方登陆模板示例
- */
-import { mapMutations } from 'vuex';
-// #ifdef H5
-import { weixindata, setRouter } from './utils/wxAuthorized';
-// #endif
-// #ifdef APP-PLUS
-import { getUpApp } from './utils/upApp.js';
-// #endif
-export default {
-	data() {
-		return {
-			/* 保存微信信息 */
-			appData: {}
-		};
-	},
-	methods: {
-		...mapMutations('user', ['setUserInfo', 'login', 'hasLogin'])
-	},
-	onLaunch: function(urlObj) {
-		let obj = this;
-		// 加载缓存中的用户信息
-		let userInfo = uni.getStorageSync('userInfo') || '';
-		// 判断是否拥有用户信息
-		if (userInfo.uid) {
-			//更新登陆状态
-			uni.getStorage({
-				key: 'userInfo',
-				success: res => {
-					obj.setUserInfo(res.data);
-					obj.login(res.data);
-				}
-			});
-		}
-		// #ifdef H5
-		// 保存路由对象
-		setRouter(this.$router);
-		//判断是否已经缓存浏览器
-		let bool = uni.getStorageSync('weichatBrowser') || '';
-		if (bool === '') {
-			//判断是否为微信浏览
-			bool = navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger';
-			// 保存当前是否为微信内核浏览器
-			uni.setStorageSync('weichatBrowser', bool);
-		}
-		if (bool) {
-			// 加载微信信息
-			weixindata();
-		}
-		// #endif
-		// #ifdef APP-PLUS
-		// 判断是否升级
-		getUpApp();
-		// 获取当前运行系统
-		let system = uni.getStorageSync('platform') || '';
-		if (!system) {
-			uni.setStorage({
-				key: 'platform',
-				data: uni.getSystemInfoSync().platform
-			});
-		}
-		// #endif
-	},
-	onShow: function() {
-		// 加载拦截
-		// console.log('App Show');
-	},
-	onHide: function() {
-		// console.log('App Hide');
-	}
-};
-</script>
-
-<style lang="scss">
-/*全局公共样式和字体图标*/
-@import '/static/css/cmy.css';
-view,
-scroll-view,
-swiper,
-swiper-item,
-cover-view,
-cover-image,
-icon,
-text,
-rich-text,
-progress,
-button,
-checkbox,
-form,
-input,
-label,
-radio,
-slider,
-switch,
-textarea,
-navigator,
-audio,
-camera,
-image,
-video {
-	box-sizing: border-box;
-}
-/* 骨架屏替代方案 */
-.Skeleton {
-	background: #f3f3f3;
-	padding: 20rpx 0;
-	border-radius: 8rpx;
-}
-
-/* 图片载入替代方案 */
-.image-wrapper {
-	font-size: 0;
-	background: #f3f3f3;
-	border-radius: 4px;
-	image {
-		width: 100%;
-		height: 100%;
-		transition: 0.6s;
-		opacity: 0;
-		&.loaded {
-			opacity: 1;
-		}
-	}
-}
-
-// 设置富文本中图片最大宽度
-uni-rich-text img {
-	max-width: 100% !important;
-}
-/*边框*/
-.b-b:after,
-.b-t:after {
-	position: absolute;
-	z-index: 3;
-	left: 0;
-	right: 0;
-	height: 0;
-	content: '';
-	transform: scaleY(0.5);
-	border-bottom: 1px solid $border-color-base;
-}
-
-.b-b:after {
-	bottom: 0;
-}
-
-.b-t:after {
-	top: 0;
-}
-
-/* button样式改写 */
-uni-button,
-button {
-	height: 80rpx;
-	line-height: 80rpx;
-	font-size: $font-lg + 2rpx;
-	font-weight: normal;
-
-	&.no-border:before,
-	&.no-border:after {
-		border: 0;
-	}
-}
-
-uni-button[type='default'],
-button[type='default'] {
-	color: $font-color-dark;
-}
-
-/* input 样式 */
-.input-placeholder {
-	color: #999999;
-}
-
-.placeholder {
-	color: #999999;
-}
-// 边距样式
-@for $i from 1 to 4 {
-	.margin-l-#{$i * 10} {
-		margin-left: $i * 10rpx !important;
-	}
-	.margin-r-#{$i * 10} {
-		margin-right: $i * 10rpx !important;
-	}
-	.margin-t-#{$i * 10} {
-		margin-top: $i * 10rpx !important;
-	}
-	.margin-b-#{$i * 10} {
-		margin-bottom: $i * 10rpx !important;
-	}
-	.margin-#{$i * 10} {
-		margin: $i * 10rpx !important;
-	}
-	.margin-v-#{$i * 10} {
-		margin-top: $i * 10rpx !important;
-		margin-bottom: $i * 10rpx !important;
-	}
-	.margin-c-#{$i * 10} {
-		margin-left: $i * 10rpx !important;
-		margin-right: $i * 10rpx !important;
-	}
-	.padding-l-#{$i * 10} {
-		padding-left: $i * 10rpx !important;
-	}
-	.padding-r-#{$i * 10} {
-		padding-right: $i * 10rpx !important;
-	}
-	.padding-t-#{$i * 10} {
-		padding-top: $i * 10rpx !important;
-	}
-	.padding-b-#{$i * 10} {
-		padding-bottom: $i * 10rpx !important;
-	}
-	.padding-#{$i * 10} {
-		padding: $i * 10rpx !important;
-	}
-	.padding-v-#{$i * 10} {
-		padding-top: $i * 10rpx !important;
-		padding-bottom: $i * 10rpx !important;
-	}
-	.padding-c-#{$i * 10} {
-		padding-left: $i * 10rpx !important;
-		padding-right: $i * 10rpx !important;
-	}
-}
-// 字体大小
-.font-size-sm {
-	font-size: $font-sm;
-}
-.font-size-base {
-	font-size: $font-base;
-}
-.font-size-lg {
-	font-size: $font-lg;
-}
-// 字体颜色
-.font-color-yellow {
-	color: $color-yellow;
-}
-.font-color-gray {
-	color: $color-gray;
-}
-.font-color-red {
-	color: $color-red;
-}
-// 边框颜色
-.border-color-yellow {
-	border: 1rpx solid $color-yellow;
-}
-
-// 修改默认背景颜色
-uni-page-wrapper {
-	background-color: $page-color-base;
-}
-page {
-	background-color: $page-color-base;
-	// 设置默认字体
-	font-family: PingFang SC, STHeitiSC-Light, Helvetica-Light, arial, sans-serif, Droid Sans Fallback;
-}
-</style>
+<script>
+/**
+ * vuex管理登陆状态,具体可以参考官方登陆模板示例
+ */
+import { mapMutations } from 'vuex';
+// #ifdef H5
+import { weixindata, setRouter } from './utils/wxAuthorized';
+// #endif
+// #ifdef APP-PLUS
+import { getUpApp } from './utils/upApp.js';
+// #endif
+export default {
+	data() {
+		return {
+			/* 保存微信信息 */
+			appData: {}
+		};
+	},
+	methods: {
+		...mapMutations('user', ['setUserInfo', 'login', 'hasLogin'])
+	},
+	onLaunch: function(urlObj) {
+		let obj = this;
+		// 加载缓存中的用户信息
+		let userInfo = uni.getStorageSync('userInfo') || '';
+		// 判断是否拥有用户信息
+		if (userInfo.uid) {
+			//更新登陆状态
+			uni.getStorage({
+				key: 'userInfo',
+				success: res => {
+					obj.setUserInfo(res.data);
+					obj.login(res.data);
+				}
+			});
+		}
+		// #ifdef H5
+		// 保存路由对象
+		setRouter(this.$router);
+		//判断是否已经缓存浏览器
+		let bool = uni.getStorageSync('weichatBrowser') || '';
+		if (bool === '') {
+			//判断是否为微信浏览
+			bool = navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger';
+			// 保存当前是否为微信内核浏览器
+			uni.setStorageSync('weichatBrowser', bool);
+		}
+		if (bool) {
+			// 加载微信信息
+			weixindata();
+		}
+		// #endif
+		// #ifdef APP-PLUS
+		// 判断是否升级
+		getUpApp();
+		// 获取当前运行系统
+		let system = uni.getStorageSync('platform') || '';
+		if (!system) {
+			uni.setStorage({
+				key: 'platform',
+				data: uni.getSystemInfoSync().platform
+			});
+		}
+		// #endif
+	},
+	onShow: function() {
+		// 加载拦截
+		// console.log('App Show');
+	},
+	onHide: function() {
+		// console.log('App Hide');
+	}
+};
+</script>
+
+<style lang="scss">
+/*全局公共样式和字体图标*/
+@import '/static/css/cmy.css';
+view,
+scroll-view,
+swiper,
+swiper-item,
+cover-view,
+cover-image,
+icon,
+text,
+rich-text,
+progress,
+button,
+checkbox,
+form,
+input,
+label,
+radio,
+slider,
+switch,
+textarea,
+navigator,
+audio,
+camera,
+image,
+video {
+	box-sizing: border-box;
+}
+/* 骨架屏替代方案 */
+.Skeleton {
+	background: #f3f3f3;
+	padding: 20rpx 0;
+	border-radius: 8rpx;
+}
+
+/* 图片载入替代方案 */
+.image-wrapper {
+	font-size: 0;
+	background: #f3f3f3;
+	border-radius: 4px;
+	image {
+		width: 100%;
+		height: 100%;
+		transition: 0.6s;
+		opacity: 0;
+		&.loaded {
+			opacity: 1;
+		}
+	}
+}
+
+// 设置富文本中图片最大宽度
+uni-rich-text img {
+	max-width: 100% !important;
+}
+/*边框*/
+.b-b:after,
+.b-t:after {
+	position: absolute;
+	z-index: 3;
+	left: 0;
+	right: 0;
+	height: 0;
+	content: '';
+	transform: scaleY(0.5);
+	border-bottom: 1px solid $border-color-base;
+}
+
+.b-b:after {
+	bottom: 0;
+}
+
+.b-t:after {
+	top: 0;
+}
+
+/* button样式改写 */
+uni-button,
+button {
+	height: 80rpx;
+	line-height: 80rpx;
+	font-size: $font-lg + 2rpx;
+	font-weight: normal;
+
+	&.no-border:before,
+	&.no-border:after {
+		border: 0;
+	}
+}
+
+uni-button[type='default'],
+button[type='default'] {
+	color: $font-color-dark;
+}
+
+/* input 样式 */
+.input-placeholder {
+	color: #999999;
+}
+
+.placeholder {
+	color: #999999;
+}
+// 边距样式
+@for $i from 1 to 4 {
+	.margin-l-#{$i * 10} {
+		margin-left: $i * 10rpx !important;
+	}
+	.margin-r-#{$i * 10} {
+		margin-right: $i * 10rpx !important;
+	}
+	.margin-t-#{$i * 10} {
+		margin-top: $i * 10rpx !important;
+	}
+	.margin-b-#{$i * 10} {
+		margin-bottom: $i * 10rpx !important;
+	}
+	.margin-#{$i * 10} {
+		margin: $i * 10rpx !important;
+	}
+	.margin-v-#{$i * 10} {
+		margin-top: $i * 10rpx !important;
+		margin-bottom: $i * 10rpx !important;
+	}
+	.margin-c-#{$i * 10} {
+		margin-left: $i * 10rpx !important;
+		margin-right: $i * 10rpx !important;
+	}
+	.padding-l-#{$i * 10} {
+		padding-left: $i * 10rpx !important;
+	}
+	.padding-r-#{$i * 10} {
+		padding-right: $i * 10rpx !important;
+	}
+	.padding-t-#{$i * 10} {
+		padding-top: $i * 10rpx !important;
+	}
+	.padding-b-#{$i * 10} {
+		padding-bottom: $i * 10rpx !important;
+	}
+	.padding-#{$i * 10} {
+		padding: $i * 10rpx !important;
+	}
+	.padding-v-#{$i * 10} {
+		padding-top: $i * 10rpx !important;
+		padding-bottom: $i * 10rpx !important;
+	}
+	.padding-c-#{$i * 10} {
+		padding-left: $i * 10rpx !important;
+		padding-right: $i * 10rpx !important;
+	}
+}
+// 字体大小
+.font-size-sm {
+	font-size: $font-sm;
+}
+.font-size-base {
+	font-size: $font-base;
+}
+.font-size-lg {
+	font-size: $font-lg;
+}
+// 字体颜色
+.font-color-yellow {
+	color: $color-yellow;
+}
+.font-color-gray {
+	color: $color-gray;
+}
+.font-color-red {
+	color: $color-red;
+}
+// 边框颜色
+.border-color-yellow {
+	border: 1rpx solid $color-yellow;
+}
+
+// 修改默认背景颜色
+uni-page-wrapper {
+	background-color: $page-color-base;
+}
+page {
+	background-color: $page-color-base;
+	// 设置默认字体
+	font-family: PingFang SC, STHeitiSC-Light, Helvetica-Light, arial, sans-serif, Droid Sans Fallback;
+}
+</style>

+ 42 - 43
main.js

@@ -1,44 +1,43 @@
-import Vue from 'vue'
-import store from './store'
-import App from './App'
-/**
- *  所有测试用数据均存放于根目录json.js
- *  
- *  css部分使用了App.vue下的全局样式和iconfont图标,有需要图标库的可以留言。
- *  示例使用了uni.scss下的变量, 除变量外已尽量移除特有语法,可直接替换为其他预处理器使用
- */
-const msg = (title, duration=1500, mask=false, icon='none')=>{
-	//统一提示方便全局修改
-	if(Boolean(title) === false){
-		return;
-	}
-	uni.showToast({
-		title,
-		duration,
-		mask,
-		icon
-	});
-}
-
-const prePage = ()=>{
-	// 获取当前页面
-	let pages = getCurrentPages();
-	let prePage = pages[pages.length - 2];
-	// #ifdef H5
-	return prePage;
-	// #endif
-	return prePage.$vm;
-}
-
-
-Vue.config.productionTip = false
-Vue.prototype.$fire = new Vue();
-Vue.prototype.$store = store;
-Vue.prototype.$api = {msg, prePage};
-
-App.mpType = 'app'
-
-const app = new Vue({
-    ...App
-})
+import Vue from 'vue'
+import store from './store'
+import App from './App'
+/**
+ *  所有测试用数据均存放于根目录json.js
+ *  
+ *  css部分使用了App.vue下的全局样式和iconfont图标,有需要图标库的可以留言。
+ *  示例使用了uni.scss下的变量, 除变量外已尽量移除特有语法,可直接替换为其他预处理器使用
+ */
+const msg = (title, duration=1500, mask=false, icon='none')=>{
+	//统一提示方便全局修改
+	if(Boolean(title) === false){
+		return;
+	}
+	uni.showToast({
+		title,
+		duration,
+		mask,
+		icon
+	});
+}
+
+const prePage = ()=>{
+	// 获取当前页面
+	let pages = getCurrentPages();
+	let prePage = pages[pages.length - 2];
+	// #ifdef H5
+	return prePage;
+	// #endif
+	return prePage.$vm;
+}
+
+Vue.config.productionTip = false
+Vue.prototype.$fire = new Vue();
+Vue.prototype.$store = store;
+Vue.prototype.$api = {msg, prePage};
+
+App.mpType = 'app'
+
+const app = new Vue({
+    ...App
+})
 app.$mount()

+ 4 - 2
pages/cart/cart.vue

@@ -81,7 +81,8 @@
 	</view>
 </template>
 
-<script>
+<script>
+	import weixinObj from "@/plugin/jweixin-module/index.js";
 import { getCartList, getCartNum, cartDel } from '@/api/user.js';
 import { mapState } from 'vuex';
 import uniNumberBox from '@/components/uni-number-box.vue';
@@ -102,7 +103,8 @@ export default {
 		// 只有登录时才加载数据
 		if (this.hasLogin) {
 			this.loadData();
-		}
+		}
+		weixinObj.hideAllNonBaseMenuItem();
 	},
 	watch: {
 		//显示空白页

+ 4 - 2
pages/category/category.vue

@@ -17,7 +17,8 @@
 	</view>
 </template>
 
-<script>
+<script>
+import weixinObj from "@/plugin/jweixin-module/index.js";
 import { getCategoryList } from '@/api/product.js';
 export default {
 	data() {
@@ -29,7 +30,8 @@ export default {
 		};
 	},
 	onLoad() {
-		this.loadData();
+		this.loadData();
+		weixinObj.hideAllNonBaseMenuItem();
 	},
 	// 监听导航栏输入框点击事件
 	onNavigationBarSearchInputClicked(e) {

+ 32 - 1
pages/index/index.vue

@@ -111,6 +111,7 @@
 </template>
 
 <script>
+	// import weixinObj from "@/plugin/jweixin-module/index.js";
 import { timeComputed, space, openMap } from '@/utils/rocessor.js';
 import { loadIndexs, getStoreList } from '@/api/index.js';
 import { getUserInfo } from '@/api/user.js';
@@ -118,6 +119,9 @@ import { setCoupons } from '@/api/functionalUnit.js';
 import { getBargainList, getProducts } from '@/api/product.js';
 import { interceptor } from '@/utils/loginUtils';
 import { mapState, mapMutations } from 'vuex';
+	// #ifdef H5
+	import { weixindata, weixinlocation,shareLoad } from '@/utils/wxAuthorized';
+	// #endif
 
 export default {
 	components: {
@@ -187,7 +191,7 @@ export default {
 		};
 	},
 	computed: {
-		...mapState(['loginInterceptor']),
+		...mapState(['loginInterceptor','weichatObj', 'baseURL', 'urlFile']),
 		...mapState('user', ['hasLogin', 'userInfo']),
 		...mapState('latlon', ['lat', 'lon'])
 	},
@@ -207,6 +211,7 @@ export default {
 			});
 		}
 		// #endif
+		// weixinObj.showAllNonBaseMenuItem();
 		this.getaddress();
 	},
 	onShow: function() {
@@ -215,8 +220,10 @@ export default {
 		// 	// 登录拦截
 		// 	interceptor();
 		// }
+		
 		this.loadData();
 		this.getBargainList();
+		this.IndexShare()
 		// this.getProducts()
 	},
 	//下拉刷新
@@ -250,6 +257,30 @@ export default {
 	},
 	// #endif
 	methods: {
+		// #ifdef H5
+		IndexShare() {
+			let obj = this;
+			let pages = getCurrentPages();
+			// 获取当前页面
+			let page = pages[pages.length - 1];
+			let path = '/#/pages/index/index' + '?';
+			// 保存传值
+			for (let i in page.options) {
+				path += i + '=' + page.options[i] + '&';
+			}
+			console.log(obj.Path)
+			// 保存邀请人
+			path += 'spread=' + this.userInfo.uid;
+			let data = {
+				link: this.baseURL + path,
+				title: this.userInfo.nickname + '邀请您进入Xingwang鑫旺',
+				desc:'欢迎加入Xingwang鑫旺',
+				imgUrl: 'http://xw.liuniu946.com/static/img/logo.png'
+			};
+			console.log(data,'分享数据');
+			shareLoad(data);
+		},
+		// #endif
 		openewm() {
 			this.$refs.popup.open()
 		},

+ 3 - 1
pages/product/list.vue

@@ -46,7 +46,7 @@
 </template>
 
 <script>
-		
+		import weixinObj from "@/plugin/jweixin-module/index.js";
 import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
 import { getProducts } from '@/api/product.js';
 import { getCategoryList } from '@/api/product.js';
@@ -79,6 +79,8 @@ export default {
 		this.cateId = options.tid;
 		this.loadCateList(options.fid, options.sid);
 		this.loadData();
+		weixinObj.hideAllNonBaseMenuItem();
+		
 	},
 	onPageScroll(e) {
 		//兼容iOS端下拉时顶部漂移

+ 694 - 632
pages/product/product.vue

@@ -10,7 +10,8 @@
 		<!-- 猜你喜欢 -->
 		<!-- <guess-like @Addcar='Addcar' @clickNavTo='navToDetailPage' :goodList = 'good_list||[]'></guess-like> -->
 		<!-- 评价 -->
-		<estimate @navTo="navTo('/pages/product/reply?id=' + goodsid)" v-if="reply" :reply="reply" :list="list"></estimate>
+		<estimate @navTo="navTo('/pages/product/reply?id=' + goodsid)" v-if="reply" :reply="reply" :list="list">
+		</estimate>
 		<!-- 规格信息 -->
 		<fresh-detail :goodsObjact="goodsObjact"></fresh-detail>
 		<!-- 图文详情 -->
@@ -18,7 +19,8 @@
 		<!-- 底部高度撑开 -->
 		<view class="contentBottomHeight"></view>
 		<!-- 底部操作菜单 -->
-		<product-bottom @buy="buy" :goodsObjact="goodsObjact" :goodsid="goodsid" @specOPne="specOPne" :showAdd="showAdd"></product-bottom>
+		<product-bottom @buy="buy" :goodsObjact="goodsObjact" :goodsid="goodsid" @specOPne="specOPne"
+			:showAdd="showAdd"></product-bottom>
 		<!-- 规格-模态层弹窗 -->
 		<view class="popup spec" :class="specClass" @touchmove.stop.prevent="stopPrevent" @click="toggleSpec">
 			<!-- 遮罩层 -->
@@ -38,13 +40,8 @@
 				<view v-for="(item, index) in specList" :key="index" class="attr-list">
 					<text>选择{{ item.attr_name }}分类</text>
 					<view class="item-list">
-						<text
-							v-for="(childItem, childIndex) in item.attr_value"
-							:key="childIndex"
-							class="tit"
-							:class="{ selected: childItem.check }"
-							@click="selectSpec(childItem, item, index)"
-						>
+						<text v-for="(childItem, childIndex) in item.attr_value" :key="childIndex" class="tit"
+							:class="{ selected: childItem.check }" @click="selectSpec(childItem, item, index)">
 							{{ childItem.attr }}
 						</text>
 					</view>
@@ -57,290 +54,335 @@
 				<view class="mun-box">
 					<text>购买数量</text>
 					<view class="num">
-						<uni-number-box class="step" :isMin="true" :value="goodsNumber" :min="1" :max="goodsNumberMax" @eventChange="numberChange"></uni-number-box>
+						<uni-number-box class="step" :isMin="true" :value="goodsNumber" :min="1" :max="goodsNumberMax"
+							@eventChange="numberChange"></uni-number-box>
 					</view>
 				</view>
 				<button class="btn" @click.stop="buy" v-show="buys_show">完成</button>
 				<button class="btn" style="background-color: #999999;" v-show="buys_shows">售罄</button>
 			</view>
 		</view>
-		<view class="mask" v-if="show"><image @click="onTap" src="../../static/img/shareimg.png"></image></view>
+		<view class="mask" v-if="show">
+			<image @click="onTap" src="../../static/img/shareimg.png"></image>
+		</view>
 	</view>
 </template>
 
 <script>
-import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
-import { goodsDetail, cartAdd, seckillGoods } from '@/api/product.js';
-import { mapState } from 'vuex';
-import store from '@/store/index.js';
-import { saveUrl } from '@/utils/loginUtils.js';
-// #ifdef H5
-import { weixindata } from '@/utils/wxAuthorized';
-// #endif
-// 头部轮播图
-import topSwiper from './common/topSwiper.vue';
-// 标题
-import productContent from './common/productContent.vue';
-// 到货时间及优惠
-import discounts from './common/discounts.vue';
-// 规格信息
-import freshDetail from './common/freshDetail.vue';
-// 图文详情
-import contentText from './common/contentText.vue';
-// 底部按钮
-import productBottom from './common/productBottom.vue';
-// 猜你喜欢
-import guessLike from './common/guessLike.vue';
-// 评价
-import estimate from './common/estimate.vue';
-//增减数量
-import uniNumberBox from '@/components/uni-number-box.vue';
-export default {
-	components: {
-		guessLike,
-		topSwiper,
-		productContent,
-		discounts,
-		freshDetail,
-		contentText,
-		productBottom,
-		estimate,
-		uniNumberBox
-	},
-	data() {
-		return {
-			show: false,
-			showAdd: true,
-			isShare: false,
-			goodsStore: 0, //选中库存
-			specList: [],
-			buys_show: true,
-			buys_shows: false,
-			specSelected: [], //选中的分类
-			specClass: 'none', //显示隐藏弹窗
-			many: 1, //1是单规格  2是多规格
-			reply: '', //评论
-			list: '', //商品详情的数据
-			type: 1, //默认支付方式add为
-			goodsType: 0,
-			goodsNumber: 1, //购买数量
-			goodsid: '', //商品id
-			description: '', //商品描述
-			goodsObjact: {
-				percent: 1
-			}, //保存商品数据
-			//图片循环
-			imgList: [],
-			// 对比对象
-			actionPrice: 0, //默认选中商品价格
-			actionImage: '', //默认选中图片
-			good_list: '', //猜你喜欢列表
-			goodsNumberMax: 0, //最大可购买数量
-			// 倒计时数据保存
-			seckillObj: {
-				stopTime: 0, //结束时间
-				stop: false, //是否结束
-				stopTimeH: 0, //小时
-				stopTimeM: 0, //分钟
-				stopTimeS: 0, //秒钟
-				stopTimeD: 0, //天
-				upTime: 0 //更新组件内部组件用
-			},
-			// 拼团数据保存
-			pink: {
-				id: '', //拼团编号
-				uid: '', //用户编号
-				people: '', //拼团人数
-				price: '', //拼团价格
-				stop_time: '', //拼团结束时间
-				nickname: '', //团长昵称
-				avatar: '', //团长头像
-				count: '', //拼团剩余人数
-				h: '', //时
-				i: '', //分
-				s: '' //秒
-			},
-			userInfo: '',
-			is_drop: false, //是否上门安装
-			showDrop: false //商品是否具有安装属性
-		};
-	},
-	filters: {
-		parseIntTo(percent) {
-			percent = +percent * 100;
-			if (percent % 1 === 0) {
-				return percent;
-			} else {
-				percent = percent.toFixed(1);
-				return percent;
-			}
-		}
-	},
-	async onLoad(options) {
-		let obj = this;
-		obj.userInfo = uni.getStorageSync('userInfo');
-		//保存商品id
-		this.goodsid = options.id;
-		if (options.type) {
-			this.goodsType = options.type;
-		}
-		// 判断有无人邀请
-		if (options.spread) {
-			// 存储邀请人
-			uni.setStorageSync('spread', options.spread);
-		}
-		saveUrl();
-		this.goodsDetail();
-		// 注册邀请信息
-		// #ifdef H5
-		let bool = uni.getStorageSync('weichatBrowser') || '';
-		if (bool) {
-			weixindata();
-		}
-		// #endif
-	},
-	computed: {
-		...mapState(['weichatObj', 'baseURL', 'urlFile'])
-	},
-	// 分享
-	onShareAppMessage(options) {
-		// 设置菜单中的转发按钮触发转发事件时的转发内容
-		let pages = getCurrentPages(); //获取加载的页面
-		let currentPage = pages[pages.length - 1]; //获取当前页面的对象
-		let url = currentPage.route; //当前页面url
-		let item = currentPage.options; //如果要获取url中所带的参数可以查看options
-		let shareObj = {
-			title: this.goodsObjact.store_name + '   价格:' + this.goodsObjact.price, // 默认是小程序的名称(可以写slogan等)
-			path: url + '?id=' + item.id + '&spread=' + this.userInfo.uid, // 默认是当前页面,必须是以‘/’开头的完整路径
-			imageUrl: this.goodsObjact.image,
-			success: function(res) {
-				// 转发成功之后的回调
-				if (res.errMsg == 'shareAppMessage:ok') {
-				}
-			},
-			fail: function() {
-				// 转发失败之后的回调
-				if (res.errMsg == 'shareAppMessage:fail cancel') {
-					// 用户取消转发
-				} else if (res.errMsg == 'shareAppMessage:fail') {
-					// 转发失败,其中 detail message 为详细失败信息
-				}
-			}
-		};
-
-		return shareObj;
-	},
-	methods: {
-		//选择是否上门安装
-		dropClick(val) {
-			if (val == 1) {
-				this.is_drop = true;
-			} else {
-				this.is_drop = false;
-			}
+
+	import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
+	import {
+		goodsDetail,
+		cartAdd,
+		seckillGoods
+	} from '@/api/product.js';
+	import {
+		mapState
+	} from 'vuex';
+	import store from '@/store/index.js';
+	import {
+		saveUrl
+	} from '@/utils/loginUtils.js';
+	// #ifdef H5
+	import { weixindata, weixinlocation,shareLoad } from '@/utils/wxAuthorized';
+	// #endif
+	// 头部轮播图
+	import topSwiper from './common/topSwiper.vue';
+	// 标题
+	import productContent from './common/productContent.vue';
+	// 到货时间及优惠
+	import discounts from './common/discounts.vue';
+	// 规格信息
+	import freshDetail from './common/freshDetail.vue';
+	// 图文详情
+	import contentText from './common/contentText.vue';
+	// 底部按钮
+	import productBottom from './common/productBottom.vue';
+	// 猜你喜欢
+	import guessLike from './common/guessLike.vue';
+	// 评价
+	import estimate from './common/estimate.vue';
+	//增减数量
+	import uniNumberBox from '@/components/uni-number-box.vue';
+	export default {
+		components: {
+			guessLike,
+			topSwiper,
+			productContent,
+			discounts,
+			freshDetail,
+			contentText,
+			productBottom,
+			estimate,
+			uniNumberBox
 		},
-		//选择数量
-		numberChange(e) {
-			console.log(e);
-			this.goodsNumber = e.number;
+		data() {
+			return {
+				show: false,
+				showAdd: true,
+				isShare: false,
+				goodsStore: 0, //选中库存
+				specList: [],
+				buys_show: true,
+				buys_shows: false,
+				specSelected: [], //选中的分类
+				specClass: 'none', //显示隐藏弹窗
+				many: 1, //1是单规格  2是多规格
+				reply: '', //评论
+				list: '', //商品详情的数据
+				type: 1, //默认支付方式add为
+				goodsType: 0,
+				goodsNumber: 1, //购买数量
+				goodsid: '', //商品id
+				description: '', //商品描述
+				goodsObjact: {
+					percent: 1
+				}, //保存商品数据
+				//图片循环
+				imgList: [],
+				// 对比对象
+				actionPrice: 0, //默认选中商品价格
+				actionImage: '', //默认选中图片
+				good_list: '', //猜你喜欢列表
+				goodsNumberMax: 0, //最大可购买数量
+				// 倒计时数据保存
+				seckillObj: {
+					stopTime: 0, //结束时间
+					stop: false, //是否结束
+					stopTimeH: 0, //小时
+					stopTimeM: 0, //分钟
+					stopTimeS: 0, //秒钟
+					stopTimeD: 0, //天
+					upTime: 0 //更新组件内部组件用
+				},
+				// 拼团数据保存
+				pink: {
+					id: '', //拼团编号
+					uid: '', //用户编号
+					people: '', //拼团人数
+					price: '', //拼团价格
+					stop_time: '', //拼团结束时间
+					nickname: '', //团长昵称
+					avatar: '', //团长头像
+					count: '', //拼团剩余人数
+					h: '', //时
+					i: '', //分
+					s: '' //秒
+				},
+				userInfo: '',
+				is_drop: false, //是否上门安装
+				showDrop: false //商品是否具有安装属性
+			};
 		},
-		close() {
-			this.specClass = 'none';
+		filters: {
+			parseIntTo(percent) {
+				percent = +percent * 100;
+				if (percent % 1 === 0) {
+					return percent;
+				} else {
+					percent = percent.toFixed(1);
+					return percent;
+				}
+			}
 		},
-		//选择规格
-		selectSpec(item, arr, ind) {
-			arr.attr_value.forEach(function(e) {
-				e.check = false;
-			});
-			item.check = true;
+		async onLoad(options) {
 			let obj = this;
-			obj.specSelected[ind] = item.attr;
-			let str = obj.specSelected.join(',');
-			// 获取当前选中的对象
-			if (obj.productValue[str]) {
-				obj.buys_show = true;
-				obj.buys_shows = false;
-				obj.actionPrice = obj.productValue[str].price;
-				obj.goodsNumberMax = obj.productValue[str].stock;
-				obj.actionImage = obj.productValue[str].image;
-				obj.uniqueId = obj.productValue[str].unique;
-				obj.goodsStore = obj.productValue[str].stock;
-			} else {
-				(obj.buys_show = false), (obj.buys_shows = true);
+			obj.userInfo = uni.getStorageSync('userInfo');
+			//保存商品id
+			this.goodsid = options.id;
+			if (options.type) {
+				this.goodsType = options.type;
 			}
-			if (obj.goodsStore == 0) {
-				obj.buys_show = false;
-				obj.buys_shows = true;
+			// 判断有无人邀请
+			if (options.spread) {
+				// 存储邀请人
+				uni.setStorageSync('spread', options.spread);
 			}
-			obj.specSelected[ind] = item.attr;
-		},
-		// 打開彈窗
-		specOPne(type = 1) {
-			let obj = this;
-			obj.specClass = 'show';
-			obj.type = type;
-		},
-		//规格弹窗开关
-		toggleSpec(str) {
-			if (this.specClass === 'show') {
-				this.specClass = 'hide';
-				setTimeout(() => {
-					this.specClass = 'none';
-				}, 250);
-			} else if (this.specClass === 'none') {
-				this.specClass = 'show';
+			saveUrl();
+			this.goodsDetail();
+			// 注册邀请信息
+			// #ifdef H5
+			let bool = uni.getStorageSync('weichatBrowser') || '';
+			if (bool) {
+				weixindata();
 			}
-			// 保存当前购买类型
-			this.type = str;
-		},
-		//领取优惠券
-		Getcoupon() {
-			uni.navigateTo({
-				url: '/pages/coupon/getcoupon'
-			});
-		},
-		//详情页
-		navToDetailPage(item) {
-			let id = item.id;
-			uni.navigateTo({
-				url: '/pages/product/product?id=' + id
-			});
+			// #endif
 		},
-		// 跳转页面
-		navTo(url) {
-			uni.navigateTo({
-				url: '/pages/product/reply?id=' + this.goodsid
-			});
+		computed: {
+			...mapState(['weichatObj', 'baseURL', 'urlFile'])
 		},
-		//加入购物车
-		Addcar(item) {
-			let obj = this;
-			cartAdd({
-				cartNum: '1', //商品数量
-				uniqueId: '', //商品标签
-				new: 0, //商品是否新增加到购物车1为不加入0为加入
-				mer_id: '',
-				productId: item.id //商品编号
-			})
-				.then(function(e) {
-					uni.showToast({
-						title: '成功加入购物车',
-						type: 'top',
-						duration: 500,
-						icon: 'none'
-					});
-
-					obj.goodsDetail();
-				})
-				.catch(e => {
-					console.log(e);
+		// 分享
+		// onShareAppMessage(options) {
+		// 	// 设置菜单中的转发按钮触发转发事件时的转发内容
+		// 	let pages = getCurrentPages(); //获取加载的页面
+		// 	let currentPage = pages[pages.length - 1]; //获取当前页面的对象
+		// 	let url = currentPage.route; //当前页面url
+		// 	let item = currentPage.options; //如果要获取url中所带的参数可以查看options
+		// 	let shareObj = {
+		// 		title: this.goodsObjact.store_name + '   价格:' + this.goodsObjact.price, // 默认是小程序的名称(可以写slogan等)
+		// 		path: url + '?id=' + item.id + '&spread=' + this.userInfo.uid, // 默认是当前页面,必须是以‘/’开头的完整路径
+		// 		imageUrl: this.goodsObjact.image,
+		// 		success: function(res) {
+		// 			// 转发成功之后的回调
+		// 			if (res.errMsg == 'shareAppMessage:ok') {}
+		// 		},
+		// 		fail: function() {
+		// 			// 转发失败之后的回调
+		// 			if (res.errMsg == 'shareAppMessage:fail cancel') {
+		// 				// 用户取消转发
+		// 			} else if (res.errMsg == 'shareAppMessage:fail') {
+		// 				// 转发失败,其中 detail message 为详细失败信息
+		// 			}
+		// 		}
+		// 	};
+
+		// 	return shareObj;
+		// },
+		methods: {
+			// #ifdef H5
+			IndexShare() {
+				let obj = this
+				// console.log('dddddddffffffffffffff')
+				// 设置菜单中的转发按钮触发转发事件时的转发内容
+				let pages = getCurrentPages(); //获取加载的页面
+				let currentPage = pages[pages.length - 1]; //获取当前页面的对象
+				let url = '/#/' + currentPage.route; //当前页面url
+				let item = currentPage.options; //如果要获取url中所带的参数可以查看options
+				let shareObj = {
+					title: obj.goodsObjact.store_name, // 默认是小程序的名称(可以写slogan等)
+					link: obj.baseURL + url + '?id=' + item.id + '&spread=' + obj.userInfo.uid, // 默认是当前页面,必须是以‘/’开头的完整路径
+					desc: obj.goodsObjact.store_name + '   价格:' + obj.goodsObjact.price,
+					imgUrl: obj.goodsObjact.image,
+					success: function(res) {
+						// 转发成功之后的回调
+						if (res.errMsg == 'shareAppMessage:ok') {
+						}
+					},
+					fail: function() {
+						// 转发失败之后的回调
+						if (res.errMsg == 'shareAppMessage:fail cancel') {
+							// 用户取消转发
+						} else if (res.errMsg == 'shareAppMessage:fail') {
+							// 转发失败,其中 detail message 为详细失败信息
+						}
+					}
+				};
+				console.log(shareObj, '8888888888888888888');
+				shareLoad(shareObj);
+			},
+			// #endif
+			//选择是否上门安装
+			dropClick(val) {
+				if (val == 1) {
+					this.is_drop = true;
+				} else {
+					this.is_drop = false;
+				}
+			},
+			//选择数量
+			numberChange(e) {
+				console.log(e);
+				this.goodsNumber = e.number;
+			},
+			close() {
+				this.specClass = 'none';
+			},
+			//选择规格
+			selectSpec(item, arr, ind) {
+				arr.attr_value.forEach(function(e) {
+					e.check = false;
 				});
-		},
-		goodsDetail() {
-			let obj = this;
-			// 获取普通商品信息
-			if (obj.goodsType == 0) {
-				goodsDetail({}, this.goodsid).then(function({ data }) {
+				item.check = true;
+				let obj = this;
+				obj.specSelected[ind] = item.attr;
+				let str = obj.specSelected.join(',');
+				// 获取当前选中的对象
+				if (obj.productValue[str]) {
+					obj.buys_show = true;
+					obj.buys_shows = false;
+					obj.actionPrice = obj.productValue[str].price;
+					obj.goodsNumberMax = obj.productValue[str].stock;
+					obj.actionImage = obj.productValue[str].image;
+					obj.uniqueId = obj.productValue[str].unique;
+					obj.goodsStore = obj.productValue[str].stock;
+				} else {
+					(obj.buys_show = false), (obj.buys_shows = true);
+				}
+				if (obj.goodsStore == 0) {
+					obj.buys_show = false;
+					obj.buys_shows = true;
+				}
+				obj.specSelected[ind] = item.attr;
+			},
+			// 打開彈窗
+			specOPne(type = 1) {
+				let obj = this;
+				obj.specClass = 'show';
+				obj.type = type;
+			},
+			//规格弹窗开关
+			toggleSpec(str) {
+				if (this.specClass === 'show') {
+					this.specClass = 'hide';
+					setTimeout(() => {
+						this.specClass = 'none';
+					}, 250);
+				} else if (this.specClass === 'none') {
+					this.specClass = 'show';
+				}
+				// 保存当前购买类型
+				this.type = str;
+			},
+			//领取优惠券
+			Getcoupon() {
+				uni.navigateTo({
+					url: '/pages/coupon/getcoupon'
+				});
+			},
+			//详情页
+			navToDetailPage(item) {
+				let id = item.id;
+				uni.navigateTo({
+					url: '/pages/product/product?id=' + id
+				});
+			},
+			// 跳转页面
+			navTo(url) {
+				uni.navigateTo({
+					url: '/pages/product/reply?id=' + this.goodsid
+				});
+			},
+			//加入购物车
+			Addcar(item) {
+				let obj = this;
+				cartAdd({
+						cartNum: '1', //商品数量
+						uniqueId: '', //商品标签
+						new: 0, //商品是否新增加到购物车1为不加入0为加入
+						mer_id: '',
+						productId: item.id //商品编号
+					})
+					.then(function(e) {
+						uni.showToast({
+							title: '成功加入购物车',
+							type: 'top',
+							duration: 500,
+							icon: 'none'
+						});
+
+						obj.goodsDetail();
+					})
+					.catch(e => {
+						console.log(e);
+					});
+			},
+			goodsDetail() {
+				let obj = this;
+				// 获取普通商品信息
+				if (obj.goodsType == 0) {
+					goodsDetail({}, this.goodsid).then(function({
+						data
+					}) {
 						obj.list = data;
 						console.log(obj.list, '普通商品数据');
 						obj.good_list = data.good_list; //保存猜你喜欢列表
@@ -352,424 +394,444 @@ export default {
 							obj.is_drop = true;
 						}
 						obj.goodsObjact = goods;
+						obj.IndexShare()
 						if (obj.goodsObjact.description != null) {
-							obj.description = obj.goodsObjact.description.replace(/\<img/gi, '<img class="rich-img"');
+							obj.description = obj.goodsObjact.description.replace(/\<img/gi,
+								'<img class="rich-img"');
 						} //小程序商品详情图超出屏幕问题
-					obj.imgList = goods.slider_image; //保存轮播图
-					obj.specList = data.productAttr; //保存分类列表
-					if (Array.isArray(data.productValue) != true) {
-						console.log('开始处理数据');
-						obj.many = 2;
-						obj.specList = data.productAttr; //保存产品属性
-						obj.productValue = data.productValue; //保存属性值
-						obj.specSelected = []; //初始化默认选择对象
-						for (let i = 0; i < obj.specList.length; i++) {
-							console.log('数据处理');
-							// 设置默认数据
-							const ls = obj.specList[i].attr_value;
-							ls[0].check = true;
-							obj.specSelected.push(ls[0].attr);
-							// console.log('数据处理对象',ls);
-							// for (let s = 0; s < ls.length; s++) {
-							// 	console.log(s);
-							// 	console.log('数据处理对象2',ls[s]);
-							// 	if (ls[s].check) {
-							// 	}
-							// }
+						obj.imgList = goods.slider_image; //保存轮播图
+						obj.specList = data.productAttr; //保存分类列表
+						if (Array.isArray(data.productValue) != true) {
+							console.log('开始处理数据');
+							obj.many = 2;
+							obj.specList = data.productAttr; //保存产品属性
+							obj.productValue = data.productValue; //保存属性值
+							obj.specSelected = []; //初始化默认选择对象
+							for (let i = 0; i < obj.specList.length; i++) {
+								console.log('数据处理');
+								// 设置默认数据
+								const ls = obj.specList[i].attr_value;
+								ls[0].check = true;
+								obj.specSelected.push(ls[0].attr);
+								// console.log('数据处理对象',ls);
+								// for (let s = 0; s < ls.length; s++) {
+								// 	console.log(s);
+								// 	console.log('数据处理对象2',ls[s]);
+								// 	if (ls[s].check) {
+								// 	}
+								// }
+							}
+							const str = obj.specSelected.join(','); //保存当前选中的默认对象
+							console.log(str, 'str');
+							// 设置默认值
+							obj.actionPrice = obj.productValue[str].price;
+							obj.goodsNumberMax = obj.productValue[str].stock;
+							obj.actionImage = obj.productValue[str].image;
+							obj.uniqueId = obj.productValue[str].unique;
+							obj.goodsStore = obj.productValue[str].stock;
+						} else {
+							obj.many = 1;
+							obj.productValue = data.productValue; //保存分类查询数据
+							obj.actionPrice = goods.price; //保存默认选中商品价格
+							obj.actionImage = goods.image_base; //保存默认选中商品图片
+							obj.goodsNumberMax = goods.stock; //保存默认选中最大可购买商品数量
 						}
-						const str = obj.specSelected.join(','); //保存当前选中的默认对象
-						console.log(str, 'str');
-						// 设置默认值
-						obj.actionPrice = obj.productValue[str].price;
-						obj.goodsNumberMax = obj.productValue[str].stock;
-						obj.actionImage = obj.productValue[str].image;
-						obj.uniqueId = obj.productValue[str].unique;
-						obj.goodsStore = obj.productValue[str].stock;
-					} else {
-						obj.many = 1;
-						obj.productValue = data.productValue; //保存分类查询数据
-						obj.actionPrice = goods.price; //保存默认选中商品价格
-						obj.actionImage = goods.image_base; //保存默认选中商品图片
-						obj.goodsNumberMax = goods.stock; //保存默认选中最大可购买商品数量
-					}
-					obj.shopId = data.mer_id; //保存商店id
-					console.log('数据处理完毕');
-				});
-			}
-			// 获取秒杀商品信息
-			if (obj.goodsType == 1) {
-				obj.showAdd = false;
-				seckillGoods({}, this.goodsid).then(function({ data }) {
-					obj.list = data;
-					console.log(obj.list, '秒杀商品数据++++++++++');
-					obj.reply = data.reply; //保存评论列表
-					let goods = data.storeInfo;
-					if (goods.is_drop == 1) {
-						obj.showDrop = true;
-					}
-					obj.goodsNumberMax = goods.num;
-					console.log(obj.seckillObj, '数据');
-					obj.goodsObjact = goods;
-					if (obj.goodsObjact.description != null) {
-						obj.description = obj.goodsObjact.description.replace(/\<img/gi, '<img class="rich-img"');
-					} //小程序商品详情图超出屏幕问题
-					obj.imgList = goods.images; //保存轮播图
-					obj.specList = data.productAttr; //保存分类列表
-					if (Array.isArray(data.productValue) != true) {
-						console.log('多规格+++++++++++++');
-						obj.many = 2;
-						obj.specList = data.productAttr; //保存产品属性
-						obj.productValue = data.productValue; //保存属性值
-						obj.specSelected = []; //初始化默认选择对象
-						for (let i = 0; i < obj.specList.length; i++) {
-							// 设置默认数据
-							let attrValue = obj.specList[i].attr_value[0];
-							attrValue.check = true;
-							obj.specSelected.push(attrValue.attr);
-						}
-						let str = obj.specSelected.join(',');
-						console.log(str, 'str');
-						// 设置默认值
-						obj.actionPrice = obj.productValue[str].price;
-						// obj.goodsNumberMax = obj.productValue[str].quota;
-						// console.log(obj.goodsNumberMax,'obj.goodsNumberMax++++++++++++')
-						obj.actionImage = obj.productValue[str].image;
-						obj.uniqueId = obj.productValue[str].unique;
-						obj.goodsStore = obj.productValue[str].stock;
-					} else {
-						console.log('单规格+++++++++++++');
-						obj.many = 1;
-						obj.productValue = data.productValue; //保存分类查询数据
-						obj.actionPrice = goods.price; //保存默认选中商品价格
-						obj.actionImage = goods.image_base; //保存默认选中商品图片
-						// obj.goodsNumberMax = goods.quota; //保存默认选中最大可购买商品数量
-						console.log(obj.goodsNumberMax, 'obj.goodsNumberMax---------------');
 						obj.shopId = data.mer_id; //保存商店id
-					}
-				});
-			}
-		},
-		// 立即购买
-		buy() {
-			let obj = this;
-			// 创建传值对象
-			let data = {
-				cartNum: obj.goodsNumber, //商品数量
-				new: 1,
-				productId: obj.goodsid, //商品编号
-				uniqueId: obj.uniqueId,
-				is_drop: obj.is_drop ? 1 : 0
-			};
+						console.log('数据处理完毕');
+					});
+				}
+				// 获取秒杀商品信息
+				if (obj.goodsType == 1) {
+					obj.showAdd = false;
+					seckillGoods({}, this.goodsid).then(function({
+						data
+					}) {
+						obj.list = data;
+						console.log(obj.list, '秒杀商品数据++++++++++');
+						obj.reply = data.reply; //保存评论列表
+						let goods = data.storeInfo;
+						if (goods.is_drop == 1) {
+							obj.showDrop = true;
+						}
+						obj.goodsNumberMax = goods.num;
+						console.log(obj.seckillObj, '数据');
+						obj.goodsObjact = goods;
+						obj.IndexShare()
+						if (obj.goodsObjact.description != null) {
+							obj.description = obj.goodsObjact.description.replace(/\<img/gi,
+								'<img class="rich-img"');
+						} //小程序商品详情图超出屏幕问题
+						obj.imgList = goods.images; //保存轮播图
+						obj.specList = data.productAttr; //保存分类列表
+						if (Array.isArray(data.productValue) != true) {
+							console.log('多规格+++++++++++++');
+							obj.many = 2;
+							obj.specList = data.productAttr; //保存产品属性
+							obj.productValue = data.productValue; //保存属性值
+							obj.specSelected = []; //初始化默认选择对象
+							for (let i = 0; i < obj.specList.length; i++) {
+								// 设置默认数据
+								let attrValue = obj.specList[i].attr_value[0];
+								attrValue.check = true;
+								obj.specSelected.push(attrValue.attr);
+							}
+							let str = obj.specSelected.join(',');
+							console.log(str, 'str');
+							// 设置默认值
+							obj.actionPrice = obj.productValue[str].price;
+							// obj.goodsNumberMax = obj.productValue[str].quota;
+							// console.log(obj.goodsNumberMax,'obj.goodsNumberMax++++++++++++')
+							obj.actionImage = obj.productValue[str].image;
+							obj.uniqueId = obj.productValue[str].unique;
+							obj.goodsStore = obj.productValue[str].stock;
+						} else {
+							console.log('单规格+++++++++++++');
+							obj.many = 1;
+							obj.productValue = data.productValue; //保存分类查询数据
+							obj.actionPrice = goods.price; //保存默认选中商品价格
+							obj.actionImage = goods.image_base; //保存默认选中商品图片
+							// obj.goodsNumberMax = goods.quota; //保存默认选中最大可购买商品数量
+							console.log(obj.goodsNumberMax, 'obj.goodsNumberMax---------------');
+							obj.shopId = data.mer_id; //保存商店id
+						}
+					});
+				}
+			},
+			// 立即购买
+			buy() {
+				let obj = this;
+				// 创建传值对象
+				let data = {
+					cartNum: obj.goodsNumber, //商品数量
+					new: 1,
+					productId: obj.goodsid, //商品编号
+					uniqueId: obj.uniqueId,
+					is_drop: obj.is_drop ? 1 : 0
+				};
+
+				if (obj.type == 2) {
+					data.new = 0;
+				}
+				cartAdd(data)
+					.then(function(e) {
+						let da = e.data;
+						if (obj.type == 1) {
+							// 跳转到支付页
+							let a = obj.is_drop ? 1 : 0;
+							console.log(a);
+							uni.navigateTo({
+								url: '/pages/order/createOrder?id=' + da.cartId + '&isdrop=' + a
+							});
+						}
+						if (obj.type == 2) {
+							uni.showToast({
+								title: '成功加入购物车',
+								type: 'top',
+								duration: 2000,
+								icon: 'none'
+							});
+							obj.goodsDetail();
+						}
+						obj.toggleSpec();
+					})
+					.catch(e => {
+						console.log(e);
+					});
+			},
+			// 阻止触发上级事件
+			stopPrevent() {},
+			callf() {
+				console.log('dianj');
+				this.show = true;
+			},
+			onTap() {
+				console.log(this.callf);
 
-			if (obj.type == 2) {
-				data.new = 0;
+				if (!this.callf) return;
+				this.closess();
+			},
+			closess() {
+				this.show = false;
 			}
-			cartAdd(data)
-				.then(function(e) {
-					let da = e.data;
-					if (obj.type == 1) {
-						// 跳转到支付页
-						let a = obj.is_drop ? 1 : 0;
-						console.log(a);
-						uni.navigateTo({
-							url: '/pages/order/createOrder?id=' + da.cartId + '&isdrop=' + a
-						});
-					}
-					if (obj.type == 2) {
-						uni.showToast({
-							title: '成功加入购物车',
-							type: 'top',
-							duration: 2000,
-							icon: 'none'
-						});
-						obj.goodsDetail();
-					}
-					obj.toggleSpec();
-				})
-				.catch(e => {
-					console.log(e);
-				});
-		},
-		// 阻止触发上级事件
-		stopPrevent() {},
-		callf() {
-			console.log('dianj');
-			this.show = true;
-		},
-		onTap() {
-			console.log(this.callf);
-
-			if (!this.callf) return;
-			this.closess();
-		},
-		closess() {
-			this.show = false;
 		}
-	}
-};
+	};
 </script>
 
 <style lang="scss">
-/*  弹出层 */
-.popup {
-	position: fixed;
-	left: 0;
-	top: 0;
-	right: 0;
-	bottom: 0;
-	z-index: 99;
-	&.show {
-		display: block;
+	/*  弹出层 */
+	.popup {
+		position: fixed;
+		left: 0;
+		top: 0;
+		right: 0;
+		bottom: 0;
+		z-index: 99;
 
-		.mask {
-			animation: showPopup 0.2s linear both;
+		&.show {
+			display: block;
+
+			.mask {
+				animation: showPopup 0.2s linear both;
+			}
+
+			.layer {
+				animation: showLayer 0.2s linear both;
+			}
 		}
 
-		.layer {
-			animation: showLayer 0.2s linear both;
+		&.hide {
+			.mask {
+				animation: hidePopup 0.2s linear both;
+			}
+
+			.layer {
+				animation: hideLayer 0.2s linear both;
+			}
+		}
+
+		&.none {
+			display: none;
 		}
-	}
 
-	&.hide {
 		.mask {
-			animation: hidePopup 0.2s linear both;
+			position: fixed;
+			top: 0;
+			width: 100%;
+			height: 100%;
+			z-index: 1;
+			background-color: rgba(0, 0, 0, 0.4);
 		}
 
 		.layer {
-			animation: hideLayer 0.2s linear both;
+			position: fixed;
+			z-index: 99;
+			bottom: 0;
+			width: 100%;
+			min-height: 20vh;
+			border-radius: 10rpx 10rpx 0 0;
+			background-color: #fff;
+
+			.btn {
+				height: 66rpx;
+				line-height: 66rpx;
+				border-radius: 100rpx;
+				background: $uni-color-primary;
+				font-size: $font-base + 2rpx;
+				color: #fff;
+				margin: 30rpx auto 20rpx;
+			}
 		}
-	}
 
-	&.none {
-		display: none;
-	}
-
-	.mask {
-		position: fixed;
-		top: 0;
-		width: 100%;
-		height: 100%;
-		z-index: 1;
-		background-color: rgba(0, 0, 0, 0.4);
-	}
+		@keyframes showPopup {
+			0% {
+				opacity: 0;
+			}
 
-	.layer {
-		position: fixed;
-		z-index: 99;
-		bottom: 0;
-		width: 100%;
-		min-height: 20vh;
-		border-radius: 10rpx 10rpx 0 0;
-		background-color: #fff;
-
-		.btn {
-			height: 66rpx;
-			line-height: 66rpx;
-			border-radius: 100rpx;
-			background: $uni-color-primary;
-			font-size: $font-base + 2rpx;
-			color: #fff;
-			margin: 30rpx auto 20rpx;
+			100% {
+				opacity: 1;
+			}
 		}
-	}
 
-	@keyframes showPopup {
-		0% {
-			opacity: 0;
-		}
+		@keyframes hidePopup {
+			0% {
+				opacity: 1;
+			}
 
-		100% {
-			opacity: 1;
+			100% {
+				opacity: 0;
+			}
 		}
-	}
 
-	@keyframes hidePopup {
-		0% {
-			opacity: 1;
-		}
+		@keyframes showLayer {
+			0% {
+				transform: translateY(120%);
+			}
 
-		100% {
-			opacity: 0;
+			100% {
+				transform: translateY(0%);
+			}
 		}
-	}
 
-	@keyframes showLayer {
-		0% {
-			transform: translateY(120%);
-		}
+		@keyframes hideLayer {
+			0% {
+				transform: translateY(0);
+			}
 
-		100% {
-			transform: translateY(0%);
+			100% {
+				transform: translateY(120%);
+			}
 		}
 	}
 
-	@keyframes hideLayer {
-		0% {
-			transform: translateY(0);
-		}
+	/* 规格选择弹窗 */
+	.attr-content {
+		padding: 25rpx 30rpx;
 
-		100% {
-			transform: translateY(120%);
-		}
-	}
-}
-/* 规格选择弹窗 */
-.attr-content {
-	padding: 25rpx 30rpx;
+		.a-t {
+			display: flex;
 
-	.a-t {
-		display: flex;
+			image {
+				width: 170rpx;
+				height: 170rpx;
+				flex-shrink: 0;
+				border-radius: 8rpx;
+			}
 
-		image {
-			width: 170rpx;
-			height: 170rpx;
-			flex-shrink: 0;
-			border-radius: 8rpx;
+			.right {
+				display: flex;
+				flex-direction: column;
+				padding-left: 24rpx;
+				font-size: $font-sm + 2rpx;
+				color: $font-color-base;
+				line-height: 42rpx;
+				width: 75%;
+				position: relative;
+
+				.right-img {
+					width: 37rpx;
+					height: 37rpx;
+					position: absolute;
+					right: 0;
+					top: 20rpx;
+					// background-color: red;
+				}
+
+				.price {
+					position: absolute;
+					bottom: 0;
+					font-size: $font-lg;
+					color: $uni-color-primary;
+					margin: 10rpx 0rpx;
+					font-size: 60rpx;
+					font-family: PingFang SC;
+					font-weight: bold;
+					color: #ef041f;
+
+					text {
+						font-size: 30rpx;
+					}
+				}
+
+				.name {
+					width: 350rpx;
+					font-size: 32rpx;
+					color: $font-color-dark;
+					height: 50rpx;
+					overflow: hidden;
+					text-overflow: ellipsis;
+					white-space: nowrap;
+					display: block;
+					font-size: 30rpx;
+					font-family: PingFang SC;
+					font-weight: bold;
+					color: #1d2023;
+				}
+
+				.selected-text {
+					margin-right: 10rpx;
+				}
+			}
 		}
 
-		.right {
+		.attr-list {
 			display: flex;
 			flex-direction: column;
-			padding-left: 24rpx;
-			font-size: $font-sm + 2rpx;
+			font-size: $font-base + 2rpx;
 			color: $font-color-base;
-			line-height: 42rpx;
-			width: 75%;
-			position: relative;
-			.right-img {
-				width: 37rpx;
-				height: 37rpx;
-				position: absolute;
-				right: 0;
-				top: 20rpx;
-				// background-color: red;
-			}
-			.price {
-				position: absolute;
-				bottom: 0;
-				font-size: $font-lg;
-				color: $uni-color-primary;
-				margin: 10rpx 0rpx;
-				font-size: 60rpx;
-				font-family: PingFang SC;
-				font-weight: bold;
-				color: #ef041f;
-				text {
-					font-size: 30rpx;
-				}
-			}
+			padding-top: 30rpx;
+			padding-left: 10rpx;
+		}
 
-			.name {
-				width: 350rpx;
-				font-size: 32rpx;
+		.item-list {
+			padding: 20rpx 0 0;
+			display: flex;
+			flex-wrap: wrap;
+
+			text {
+				display: flex;
+				align-items: center;
+				justify-content: center;
+				background: #eee;
+				margin-right: 20rpx;
+				margin-bottom: 20rpx;
+				border-radius: 10rpx;
+				min-width: 60rpx;
+				height: 60rpx;
+				padding: 0 20rpx;
+				font-size: $font-base;
 				color: $font-color-dark;
-				height: 50rpx;
-				overflow: hidden;
-				text-overflow: ellipsis;
-				white-space: nowrap;
-				display: block;
-				font-size: 30rpx;
-				font-family: PingFang SC;
-				font-weight: bold;
-				color: #1d2023;
 			}
 
-			.selected-text {
-				margin-right: 10rpx;
+			.selected {
+				background: #fceff1;
+				color: #f35768;
+				border: 1px solid #f35768;
 			}
 		}
 	}
 
-	.attr-list {
-		display: flex;
-		flex-direction: column;
+	//默认商品底部高度
+	.goodsBottom {
+		height: 160rpx;
+	}
+
+	page {
+		background: #f0f0f0;
+	}
+
+	//秒杀、拼团底部高度
+	.contentBottomHeight {
+		background-color: #f8f8f8;
+		height: 130rpx;
+	}
+
+	//默认商品底部高度
+	.goodsBottom {
+		height: 160rpx;
+	}
+
+	/deep/ .iconenter {
 		font-size: $font-base + 2rpx;
-		color: $font-color-base;
-		padding-top: 30rpx;
-		padding-left: 10rpx;
+		color: #888;
 	}
 
-	.item-list {
-		padding: 20rpx 0 0;
-		display: flex;
-		flex-wrap: wrap;
+	/deep/ .con_image {
+		width: 130rpx;
+		height: 130rpx;
+		display: inline-block;
+		padding: 15rpx;
 
-		text {
-			display: flex;
-			align-items: center;
-			justify-content: center;
-			background: #eee;
-			margin-right: 20rpx;
-			margin-bottom: 20rpx;
-			border-radius: 10rpx;
-			min-width: 60rpx;
-			height: 60rpx;
-			padding: 0 20rpx;
-			font-size: $font-base;
-			color: $font-color-dark;
+		image {
+			width: 100%;
+			height: 100%;
 		}
+	}
 
-		.selected {
-			background: #fceff1;
-			color: #f35768;
-			border: 1px solid #f35768;
-		}
+	/* 商品详情中限制图片大小 */
+	/deep/ .rich-img {
+		width: 100% !important;
+		height: auto;
 	}
-}
-
-//默认商品底部高度
-.goodsBottom {
-	height: 160rpx;
-}
-page {
-	background: #f0f0f0;
-}
-//秒杀、拼团底部高度
-.contentBottomHeight {
-	background-color: #f8f8f8;
-	height: 130rpx;
-}
-//默认商品底部高度
-.goodsBottom {
-	height: 160rpx;
-}
-/deep/ .iconenter {
-	font-size: $font-base + 2rpx;
-	color: #888;
-}
-/deep/ .con_image {
-	width: 130rpx;
-	height: 130rpx;
-	display: inline-block;
-	padding: 15rpx;
-	image {
-		width: 100%;
-		height: 100%;
+
+	.mun-box {
+		display: flex;
+		justify-content: space-between;
+		align-items: center;
 	}
-}
-/* 商品详情中限制图片大小 */
-/deep/ .rich-img {
-	width: 100% !important;
-	height: auto;
-}
-.mun-box {
-	display: flex;
-	justify-content: space-between;
-	align-items: center;
-}
-
-.mask {
-	position: fixed;
-	top: 0;
-	left: 0;
-	width: 100%;
-	height: 100%;
-	z-index: 999;
-	background-color: rgba(0, 0, 0, 0.4);
-	image {
+
+	.mask {
+		position: fixed;
+		top: 0;
+		left: 0;
 		width: 100%;
 		height: 100%;
-		opacity: 0.8;
+		z-index: 999;
+		background-color: rgba(0, 0, 0, 0.4);
+
+		image {
+			width: 100%;
+			height: 100%;
+			opacity: 0.8;
+		}
 	}
-}
 </style>

+ 2 - 0
pages/store/storeDetail.vue

@@ -35,6 +35,7 @@
 </template>
 
 <script>
+		import weixinObj from "@/plugin/jweixin-module/index.js";
 import empty from '@/components/empty';
 import { getStoreInfo } from '@/api/index.js';
 import { orderData, getUserInfo, getMyStore } from '@/api/user.js';
@@ -56,6 +57,7 @@ export default {
 		} else {
 			this.getMyStore();
 		}
+		weixinObj.hideAllNonBaseMenuItem();
 	},
 	methods: {
 		navTo(url) {

+ 46 - 43
pages/user/shareQrCode.vue

@@ -17,11 +17,12 @@
 	</view>
 </template>
 <script>
+	// import weixinObj from "@/plugin/jweixin-module/index.js";
 import { mapState } from 'vuex';
 import { spreadBanner } from '@/api/user.js';
 import { interceptor, saveUrl } from '@/utils/loginUtils';
 // #ifdef H5
-import { weixindata } from '@/utils/wxAuthorized';
+import { weixindata, weixinlocation,shareLoad } from '@/utils/wxAuthorized';
 // #endif
 export default {
 	data() {
@@ -44,6 +45,26 @@ export default {
 			complete() {}
 		});
 		// #endif
+		// #ifdef H5
+		
+		// weixinObj.showAllNonBaseMenuItem();
+		this.IndexShare()
+		// wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
+		// let path = '/#/pages/index/index' + '?';
+		// console.log(obj.Path)
+		// // 保存邀请人
+		// path += 'spread=' + this.userInfo.uid;
+		//   wx.updateAppMessageShareData({ 
+		//     title: this.userInfo.nickname + '邀请您进入Xingwang鑫旺', // 分享标题
+		//     desc: '欢迎加入Xingwang鑫旺', // 分享描述
+		//     link: this.baseURL + path, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
+		//     imgUrl: '../../static/img/logo.png', // 分享图标
+		//     success: function () {
+		//       // 设置成功
+		//     }
+		//   })
+		// });
+		// #endif
 	},
 	onShow() {
 		if (this.loginInterceptor && !this.hasLogin) {
@@ -144,48 +165,30 @@ export default {
 		currentChange(e) {
 			this.current = e.detail.current;
 		},
-		// onShareAppMessage(options){
-		// 	console.log(options,'options')
-		// 	let userInfo = uni.getStorageSync('userInfo');
-		// 	console.log(userInfo)
-		//   let obj = this;
-		//   // 设置菜单中的转发按钮触发转发事件时的转发内容
-		//   let shareObj = {
-		//     title: "邀请好友领券",        // 默认是小程序的名称(可以写slogan等)
-		//     path: '/pages/index/index?spread='+userInfo.uid,        // 默认是当前页面,必须是以‘/’开头的完整路径
-		//     imageUrl: obj.imgSrc,
-		//     success: function(res){
-		//       // 转发成功之后的回调
-		//       if(res.errMsg == 'shareAppMessage:ok'){
-		//       }
-		//     },
-		//     fail: function(){
-		//       // 转发失败之后的回调
-		//       if(res.errMsg == 'shareAppMessage:fail cancel'){
-		//         // 用户取消转发
-		//       }else if(res.errMsg == 'shareAppMessage:fail'){
-		//         // 转发失败,其中 detail message 为详细失败信息
-		//       }
-		//     }
-		//   };
-		//   // 来自页面内的按钮的转发
-		//   if( options.from == 'button' ){
-		//     // 此处可以修改 shareObj 中的内容
-		//     shareObj.path = '/pages/index/index?spread='+userInfo.uid;
-		//         console.log(shareObj.path,'shareObj.path')
-		//   }
-		//   // 返回shareObj
-		//   return shareObj;
-		// },
-		// scClick() {
-		// 	let self = this;
-		// 	// #ifdef H5
-		// 	self.imgSrc = self.rwmListArr[self.current].wap_poster;
-		// 	// #endif
-		// 	// #ifdef MP-WEIXIN
-		// 	self.imgSrc = self.rwmListArr[self.current].poster;
-		// 	// #endif
-		// },
+		// #ifdef H5
+		IndexShare() {
+			let obj = this;
+			let pages = getCurrentPages();
+			// 获取当前页面
+			let page = pages[pages.length - 1];
+			let path = '/#/pages/index/index' + '?';
+			// 保存传值
+			for (let i in page.options) {
+				path += i + '=' + page.options[i] + '&';
+			}
+			console.log(obj.Path)
+			// 保存邀请人
+			path += 'spread=' + this.userInfo.uid;
+			let data = {
+				link: this.baseURL + path,
+				title: this.userInfo.nickname + '邀请您进入Xingwang鑫旺',
+				desc:'欢迎加入Xingwang鑫旺',
+				imgUrl: ''
+			};
+			console.log(data,'分享数据');
+			shareLoad(data);
+		},
+		// #endif
 		// #ifdef MP-WEIXIN
 		seav() {
 			uni.getImageInfo({

+ 2 - 0
pages/user/user.vue

@@ -163,6 +163,7 @@
 	</view>
 </template>
 <script>
+	import weixinObj from "@/plugin/jweixin-module/index.js";
 import { mapState, mapMutations } from 'vuex';
 import uniList from '@/components/uni-list/uni-list.vue';
 import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
@@ -194,6 +195,7 @@ export default {
 			this.loadBaseData();
 			this.getMyStore();
 		}
+		weixinObj.hideAllNonBaseMenuItem();
 	},
 	onReady() {
 		// 初始化获取页面宽度

+ 245 - 245
utils/wxAuthorized.js

@@ -1,245 +1,245 @@
-import {
-	wechatConfig,
-	share
-} from '@/api/wx';
-// 加载日志
-import * as log from './log.js'
-import {
-	isAndroid
-} from './platform.js'
-import store from '../store';
-// 保存wx对象
-import weixinObj from "@/plugin/jweixin-module/index.js";
-// 保存分享数据
-let shareData = '';
-// 保存注册返回appId数据
-let appId = '';
-//保存路由对象
-let router = '';
-//微信登录
-/**
- * @param {string} 当前页面地址信息
- */
-export function loginWinxin() {
-	console.log('1');
-	let pages, page, path;
-	try {
-		pages = getCurrentPages();
-		// 获取跳转前页面
-		page = pages[pages.length - 1];
-		// 获取跳转前路由地址
-		path = page.route;
-	} catch (e) {
-		console.log(e);
-		//TODO handle the exception
-	}
-	// 判断是否在登录页
-	if (path != 'pages/redirect/redirect') {
-		log.addLog('开始注册微信')
-		weixindata().then(() => {
-			console.log('2');
-			// 调用
-			try {
-				weixinSq();
-			} catch (e) {
-				console.log(e);
-				//TODO handle the exception
-			}
-		});
-	}
-};
-// 微信授权登录
-function weixinSq() {
-	// 微信授权后跳转页面
-	try {
-		// 判断是否真实路由模式
-		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=' +
-			appId +
-			'&redirect_uri=' +
-			ul +
-			'&response_type=code&scope=snsapi_userinfo&state=' +
-			new Date().getTime() +
-			'#wechat_redirect';
-		window.location.href = url;
-	} catch (e) {
-		console.log(e);
-		//TODO handle the exception
-	}
-};
-
-// 微信注册
-export function weixindata(config) {
-	let url;
-	try {
-		if (router.mode === "history") {
-			// 在ios中时候注册为微信刚进入时候的页面
-			if (window.entryUrl === '') {
-				window.entryUrl = location.href.split('#')[0]
-			}
-			url = isAndroid() ? location.href.split('#')[0] : window.entryUrl;
-		}
-		if (router.mode === "hash") {
-			url = location.href.split('#')[0];
-		}
-		log.addLog('注册开始', url)
-		console.log('开始注册', url);
-
-	} catch (e) {
-		console.log('错误', e);
-	}
-	return new Promise((ok, error) => {
-		try {
-			//注册微信信息
-			wechatConfig({
-					url
-				})
-				.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
-		}
-	})
-}
-
-// 判断分享调用方法
-export function shareLoad(config) {
-	console.log('开始调用分享')
-	try {
-		weixindata().then((e) => {
-			// 判断有无自定义数据
-			if (config) {
-				shareFun(config)
-			} else {
-				// 判断是否已经缓存了默认数据
-				if (shareData) {
-					shareFun()
-				} else {
-					// 请求获取默认数据
-					share({}).then(({
-						data
-					}) => {
-						shareData = data.data
-						shareFun()
-					});
-				}
-			}
-		})
-	} catch (e) {
-		console.log('报错', e)
-		//TODO handle the exception
-	}
-}
-// 配置分享数据
-function shareFun(config) {
-	try {
-		console.log('再付分享内容', config);
-		// uni.showModal({
-		// 	title: '链接',
-		// 	content: config.link,
-		// 	showCancel: false,
-		// 	cancelText: '',
-		// 	confirmText: '',
-		// 	success: res => {},
-		// 	fail: () => {},
-		// 	complete: () => {}
-		// });
-		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: () => {}
-					// });
-				}
-			}
-		}
-		// uni.showModal({
-		// 	title:"提示",
-		// 	content:JSON.stringify(mess)
-		// })
-		console.log(mess,'data')
-		// 获取仓库数据
-		// 分享好友
-		weixinObj.updateAppMessageShareData(mess);
-		// weixinObj.onMenuShareAppMessage(mess);// 即将废弃
-
-		// 分享朋友圈
-		weixinObj.updateTimelineShareData(mess)
-		// weixinObj.onMenuShareTimeline(mess);// 即将废弃
-	} catch (e) {
-		console.log(e);
-		//TODO handle the exception
-	}
-}
-
-// 保存路由对象
-export function setRouter(route) {
-	router = route
-}
-
-export default {
-	weixinObj,
-	shareData,
-	appId,
-	setRouter,
-	shareLoad
-}
+import {
+	wechatConfig,
+	share
+} from '@/api/wx';
+// 加载日志
+import * as log from './log.js'
+import {
+	isAndroid
+} from './platform.js'
+import store from '../store';
+// 保存wx对象
+import weixinObj from "@/plugin/jweixin-module/index.js";
+// 保存分享数据
+let shareData = '';
+// 保存注册返回appId数据
+let appId = '';
+//保存路由对象
+let router = '';
+//微信登录
+/**
+ * @param {string} 当前页面地址信息
+ */
+export function loginWinxin() {
+	console.log('1');
+	let pages, page, path;
+	try {
+		pages = getCurrentPages();
+		// 获取跳转前页面
+		page = pages[pages.length - 1];
+		// 获取跳转前路由地址
+		path = page.route;
+	} catch (e) {
+		console.log(e);
+		//TODO handle the exception
+	}
+	// 判断是否在登录页
+	if (path != 'pages/redirect/redirect') {
+		log.addLog('开始注册微信')
+		weixindata().then(() => {
+			console.log('2');
+			// 调用
+			try {
+				weixinSq();
+			} catch (e) {
+				console.log(e);
+				//TODO handle the exception
+			}
+		});
+	}
+};
+// 微信授权登录
+function weixinSq() {
+	// 微信授权后跳转页面
+	try {
+		// 判断是否真实路由模式
+		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=' +
+			appId +
+			'&redirect_uri=' +
+			ul +
+			'&response_type=code&scope=snsapi_userinfo&state=' +
+			new Date().getTime() +
+			'#wechat_redirect';
+		window.location.href = url;
+	} catch (e) {
+		console.log(e);
+		//TODO handle the exception
+	}
+};
+
+// 微信注册
+export function weixindata(config) {
+	let url;
+	try {
+		if (router.mode === "history") {
+			// 在ios中时候注册为微信刚进入时候的页面
+			if (window.entryUrl === '') {
+				window.entryUrl = location.href.split('#')[0]
+			}
+			url = isAndroid() ? location.href.split('#')[0] : window.entryUrl;
+		}
+		if (router.mode === "hash") {
+			url = location.href.split('#')[0];
+		}
+		log.addLog('注册开始', url)
+		console.log('开始注册', url);
+
+	} catch (e) {
+		console.log('错误', e);
+	}
+	return new Promise((ok, error) => {
+		try {
+			//注册微信信息
+			wechatConfig({
+					url
+				})
+				.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
+		}
+	})
+}
+
+// 判断分享调用方法
+export function shareLoad(config) {
+	console.log('开始调用分享')
+	try {
+		weixindata().then((e) => {
+			// 判断有无自定义数据
+			if (config) {
+				shareFun(config)
+			} else {
+				// 判断是否已经缓存了默认数据
+				if (shareData) {
+					shareFun()
+				} else {
+					// 请求获取默认数据
+					share({}).then(({
+						data
+					}) => {
+						shareData = data.data
+						shareFun()
+					});
+				}
+			}
+		})
+	} catch (e) {
+		console.log('报错', e)
+		//TODO handle the exception
+	}
+}
+// 配置分享数据
+function shareFun(config) {
+	try {
+		console.log('再付分享内容', config);
+		// uni.showModal({
+		// 	title: '链接',
+		// 	content: config.link,
+		// 	showCancel: false,
+		// 	cancelText: '',
+		// 	confirmText: '',
+		// 	success: res => {},
+		// 	fail: () => {},
+		// 	complete: () => {}
+		// });
+		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: () => {}
+					// });
+				}
+			}
+		}
+		// uni.showModal({
+		// 	title:"提示",
+		// 	content:JSON.stringify(mess)
+		// })
+		console.log(mess,'data')
+		// 获取仓库数据
+		// 分享好友
+		weixinObj.updateAppMessageShareData(mess);
+		// weixinObj.onMenuShareAppMessage(mess);// 即将废弃
+
+		// 分享朋友圈
+		weixinObj.updateTimelineShareData(mess)
+		// weixinObj.onMenuShareTimeline(mess);// 即将废弃
+	} catch (e) {
+		console.log(e);
+		//TODO handle the exception
+	}
+}
+
+// 保存路由对象
+export function setRouter(route) {
+	router = route
+}
+
+export default {
+	weixinObj,
+	shareData,
+	appId,
+	setRouter,
+	shareLoad
+}