uniapp綜合應用 滾動搜索 tab切換 上拉刷新 下拉加載 微信掃一掃

<template>
	<view class="pageov">

		<!-- 搜索 start -->
		<view class="tui-header">
			<view class="tui-rolling-search">
				<!-- #ifdef APP-PLUS || MP -->
				<icon type="search" :size='13' color='#999'></icon>
				<!-- #endif -->
				<text class="iconfont yqGrowthsousuox"></text>
				<swiper :class="ifhide?'hide':''" @click="showInputClick" vertical autoplay circular interval="5000" class="tui-swiper">
					<swiper-item v-for="(item,index) in hotSearch" :key="index" class="tui-swiper-item" @tap="search">
						<view class="tui-hot-item">{{item}}</view>
					</swiper-item>
				</swiper>
				<input @confirm="searchClick" @blur="noInputClick" :focus="ifshow" :class="ifshow?'':'hide'" class="tui-swiper" />
			</view>
			<!-- <view class="ov-texts" @click="typeClick">
				<text>訂單類型</text>
				<text class="iconfont yqGrowthxialajiantoux"></text>
			</view> -->
		</view>
		<!-- 搜索 end -->

		<!-- 訂單類型彈出層 start -->
		<view class="ov-menu-type" :class="typeShow?'':'hide'">
			<view class="ov-menu-type-sanj"></view>
			<view class="ov-menu-type-list">
				<veiw class="ov-menu-type-item">個人訂單</veiw>
				<view class="ov-menu-type-line"></view>
				<view class="ov-menu-type-item">團購訂單</view>
			</view>
		</view>
		<!-- 訂單類型彈出層 end -->

		<!-- 選擇 start -->
		<view class="ov-menus-box">
			<view @click="menuClick(index)" :class="item.menuSelected?'ov-menu-selected':'ov-menu-item'" v-for="(item, index) in menuList"
			 :key="index">
				<view class="ov-menu">{{ item.name }}</view>
				<view :class="item.menuSelected?'ov-menu-show':'ov-menu-hide'" class="ov-menu-line"></view>
			</view>

		</view>
		<!-- 選擇 end -->

		<!-- 列表 start -->
		<view class="ov-list-box">
			<view @click="itemClick(item)" class="ov-order-list-item" v-for="(item, index) in orderList" :key="index">
				<view class="ov-list-item-natelimg">
					<view class="ov-list-item-nateldes">
						<view class="ov-list-item-nametel">
							<view class="ov-list-item-name">{{ item.name }}</view>
							<view class="ov-list-item-tel">{{ item.mobile }}</view>
						</view>
						<view class="ov-list-item-desc">{{ item.storeProductName }}</view>
					</view>
					<view class="ov-list-item-img" :style="'background: url('+item.imgUrl+');'"></view>
				</view>
				<view class="ov-list-item-tista">
					<view class="ov-list-item-time">{{ item.createdTime }}</view>
					<view class="ov-list-item-statusb">
						<text class="ov-list-item-statuss" v-if="item.verifyStatus == 1">已完成</text>
						<text class="ov-list-item-status" v-if="item.verifyStatus == 2">未覈銷</text>
						<text class="iconfont yqGrowthqianwangjiantoux"></text>
					</view>
				</view>
			</view>
		</view>
		<!-- 列表 end -->

		<!-- 底部佔位 start -->
		<view class="ov-placed"></view>
		<!-- 底部佔位 end -->

		<!-- 底部操作按鈕 start -->
		<view class="ov-bottom-btns">
			<view class="ov-bottom-btn" @click="codeVerClick">驗證碼覈銷</view>
			<view class="ov-bottom-btn" @click="wxCodeClick">掃碼覈銷</view>
		</view>
		<!-- 底部操作按鈕 end -->

		<view :class="ifKist?'hide':''" class="ifnulls">
			<image class="ifnulls-icon" src="../../../static/noorder.png"></image>
			<view class="ifnulls-text">你還沒有訂單哦!</view>
		</view>
		
		<uni-load-more :loadingType="loadingType" :contentText="contentText"></uni-load-more>

	</view>
</template>

<script>
	let _self;
	import wx from 'weixin-js-sdk'
	import uniLoadMore from "../../../components/uni-load-more.vue"
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				hotSearch: [
					"可輸入手機號或姓名進行搜索",
					"可輸入手機號或姓名進行搜索",
					"可輸入手機號或姓名進行搜索"
				], // 熱門搜索
				typeShow: false, // 是否顯示彈層
				menuList: [{
						"id": "3",
						"name": "全部",
						"menuSelected": "false"
					},
					{
						"id": "2",
						"name": "未覈銷",
						"menuSelected": "false"
					},
					{
						"id": "1",
						"name": "已完成",
						"menuSelected": "false"
					}
				], // 菜單列表
				orderList: [],
				ifshow: false, // 是否顯示輸入框
				ifhide: false, // 是否顯示佔位
				curPage: 1, // 當前頁碼
				keyWords: '', // 關鍵詞
				verifyStatus: '', // 0 未覈銷 1 已經覈銷
				loadingText: '加載中...',
				loadingType: 0, //定義加載方式 0---contentdown  1---contentrefresh 2---contentnomore
				contentText: {
					contentdown: '',
					contentrefresh: '正在加載...',
					contentnomore: ''
				},
				ifKist: false
			}
		},
		onLoad() {
			_self = this;
			_self.curPage = 1;
			_self.dataInit();
			_self.Qcode();
		},
		onPullDownRefresh: function() {
			//下拉刷新的時候請求一次數據
			_self.curPage = 1;
			_self.List();
		},
		onReachBottom: function() {
			//觸底的時候請求數據,即爲上拉加載更多
			//爲了更加清楚的看到效果,添加了定時器
			_self.curPage ++;
			if (timer != null) {
				clearTimeout(timer);
			}
			timer = setTimeout(function() {
				_self.List();
			}, 1000);

			// 正常應爲:
			// _self.getmorenews();
		},
		methods: {
			// 列表點擊
			itemClick(item){
				uni.navigateTo({
				    url: '../orderDetail/orderDetail?orderId='+item.orderId
				});
			},
			// 搜索
			searchClick(e) {
				_self.keyWords = e.mp.detail.value;
				_self.List();
			},
			// 顯示輸入框
			showInputClick() {
				_self.ifshow = true;
				_self.ifhide = true;
			},
			// 隱藏輸入框
			noInputClick() {
				_self.ifshow = false;
				_self.ifhide = false;
				_self.keyWords = '';
			},
			// 數據初始化
			dataInit() {
				_self.menuList.forEach(item => {
					this.$set(item, 'menuSelected', false);
				})
				_self.menuList[0].menuSelected = true;

				_self.List();
			},
			// 列表初始化
			async List() {

				_self.loading = true;
				let rest = '';
				rest = await _self.$api.List({
					keyWords: _self.keyWords,
					pageSize: 10,
					verifyStatus: _self.verifyStatus
				});
				_self.loading = false;
				
				let coded = rest.data.code;
				if (coded == 409) {
					uni.navigateTo({
						url: '/pages/Logins/login/login.vue'
					});
				}
				console.log("rest.data.data.list.length"+rest.data.data.list.length)
				if(rest.data.data.list.length == 0){
					_self.ifKist = false;
				}else{
					_self.ifKist = true;
				}
				
				_self.orderList = rest.data.data.list;
				uni.stopPullDownRefresh();
			},
			// 掃一掃初始化
			async Qcode() {

				_self.loading = true;
				let rest = '';
				rest = await _self.$api.Qcode({url:window.location.href});
				_self.loading = false;
				
				let coded = rest.data.code;
				if (coded == 409) {
					uni.showModal({
					    title: '提示',
					    content: "登陸已失效,請先登錄",
						showCancel: false,
					    success: function (res) {}
					});
					uni.navigateTo({
						url: '../../Logins/login/login'
					});
				}

				if (rest.data.data) {
					let data = rest.data.data;
					wx.config({
						debug: false, // 開啓調試模式,調用的所有api的返回值會在客戶端alert出來,若要查看傳入的參數,可以在pc端打開,參數信息會通過log打出,僅在pc端時纔會打印。
						appId: data.appId, // 必填,公衆號的唯一標識
						timestamp: data.timestamp, // 必填,生成簽名的時間戳
						nonceStr: data.nonceStr, // 必填,生成簽名的隨機串
						signature: data.signature, // 必填,簽名,見附錄1
						jsApiList: ["scanQRCode"] // 必填,需要使用的JS接口列表,所有JS接口列表見附錄2
					});
				}
			},
			// 菜單點擊切換
			menuClick(index) {
				_self.menuList.forEach(item => {
					this.$set(item, 'menuSelected', false);
				})
				_self.menuList[index].menuSelected = true;
				console.log("_self.menuList[index].id"+_self.menuList[index].id)
				if (_self.menuList[index].id == 1) {
					_self.verifyStatus = 1;
					_self.List();
				}
				if (_self.menuList[index].id == 2) {
					_self.verifyStatus = 2;
					_self.List();
				}
				if (_self.menuList[index].id == 3) {
					_self.verifyStatus = '';
					_self.List();
				}
			},
			// 類型彈窗
			typeClick() {
				_self.typeShow = !_self.typeShow;
			},
			// 驗證碼覈銷
			codeVerClick() {
				uni.navigateTo({
					url: '../codeVer/codeVer'
				});
			},
			// 掃一掃覈銷
			wxCodeClick() {
				wx.ready(function() {
					wx.scanQRCode({
						needResult: 1,
						desc: 'scanQRCode desc',
						success: function(res) {
							
							uni.navigateTo({
							    url: '../orderDetail/orderDetail?code=' + res.resultStr
							});
						}
					});
				});
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: rgba(243, 243, 243, 1);
	}

	.hide {
		display: none !important;
	}

	.pageov {
		.ifnulls{
			width: 100%;
			position: absolute;
			top: 450rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			.ifnulls-icon{
				width: 224rpx;
				height: 190rpx;
			}
			.ifnulls-text{
				font-size:28rpx;
				font-family:$yq-font-parimary;
				font-weight:400;
				color:rgba(140,140,140,1);
				line-height:40rpx;
			}
		}
		
		.ov-placed {
			width: 100%;
			height: 128rpx;
		}

		.ov-bottom-btns {
			background: rgba(255, 255, 255, 1);
			box-shadow: 0rpx -8rpx 32rpx 0rpx rgba(12, 12, 13, 0.06);
			padding: 16rpx 40rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			position: fixed;
			bottom: 0;
			left: 0;
			right: 0;

			.ov-bottom-btn {
				background: rgba(255, 206, 0, 1);
				border-radius: 200rpx;
				font-size: 36rpx;
				font-family: $yq-font-parimary;
				font-weight: 500;
				color: rgba(38, 38, 38, 1);
				line-height: 36rpx;
				padding: 30rpx 66rpx;
			}
		}

		.ov-menu-type {
			background: rgba(38, 38, 38, 1);
			width: 200rpx;
			position: fixed;
			right: 40rpx;
			top: 186rpx;
			z-index: 999;
			border-radius: 20rpx;

			.ov-menu-type-sanj {
				position: absolute;
				top: -17px;
				right: 28px;
			}

			.ov-menu-type-sanj:before,
			.top:after {
				position: absolute;
				content: '';
				border-top: 20rpx transparent dashed;
				border-left: 10rpx transparent dashed;
				border-right: 10rpx transparent dashed;
				border-bottom: 20rpx #fff solid;
			}

			.ov-menu-type-sanj:before {
				border-bottom: 20rpx #262626 solid;
			}

			.ov-menu-type-sanj:after {
				top: 2rpx;
				/*覆蓋並錯開1px*/
				border-bottom: 10px #fff solid;
			}

			.ov-menu-type-list {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				padding: 34rpx 34rpx;

				.ov-menu-type-item {
					font-size: 12px;
					font-family: $yq-font-parimary;
					font-weight: 400;
					color: rgba(255, 255, 255, 1);
					line-height: 17px;
				}

				.ov-menu-type-line {
					background: rgba(89, 89, 89, 1);
					width: 134rpx;
					height: 2rpx;
					margin: 24rpx 0;
				}
			}
		}

		.ov-list-box {
			padding: 20rpx;

			.ov-order-list-item {
				margin-bottom: 20rpx;
				background: rgba(255, 255, 255, 1);
				border-radius: 30rpx;

				.ov-list-item-tista {
					margin-top: 38rpx;

					.ov-list-item-time {
						font-size: 24rpx;
						font-family: $yq-font-parimary;
						font-weight: 400;
						color: rgba(89, 89, 89, 1);
						line-height: 34rpx;
					}

					.ov-list-item-statusb {
						display: flex;
						justify-content: center;
						align-items: center;
						font-size: 14px;
						font-family: $yq-font-parimary;
						font-weight: 400;
						color: rgba(38, 38, 38, 1);
						line-height: 20px;

						.ov-list-item-status {
							color: rgba(255, 127, 63, 1);
						}
						.ov-list-item-statuss{
							color:rgba(89,89,89,1);
						}
					}
				}

				.ov-list-item-natelimg {
					display: flex;
					justify-content: space-between;
					padding: 32rpx 40rpx 0 40rpx;

					.ov-list-item-img {
						width: 240rpx;
						height: 136rpx;
						border-radius: 10px;
					}

					.ov-list-item-nateldes {
						width: 350rpx;
						display: flex;
						flex-direction: column;

						.ov-list-item-desc {
							font-size: 24rpx;
							font-family: $yq-font-parimary;
							font-weight: 400;
							color: rgba(38, 38, 38, 1);
							line-height: 34rpx;
							padding-top: 8rpx;
						}

						.ov-list-item-nametel {
							display: flex;

							.ov-list-item-name {
								font-size: 32rpx;
								font-family: $yq-font-parimary;
								font-weight: 600;
								color: rgba(38, 38, 38, 1);
								line-height: 44rpx;
							}

							.ov-list-item-tel {
								font-size: 32rpx;
								padding-left: 30rpx;
								font-family: $yq-font-parimary;
								font-weight: 600;
								color: rgba(38, 38, 38, 1);
								line-height: 44rpx;
							}
						}
					}

				}

				.ov-list-item-tista {
					padding: 0 40rpx 32rpx 40rpx;
					display: flex;
					justify-content: space-between;
				}
			}
		}

		.tui-header {
			width: 100%;
			height: 100rpx;
			padding: 0 30rpx 0 20rpx;
			box-sizing: border-box;
			background: #FFFFFF;
			display: flex;
			align-items: center;
			justify-content: space-between;
		}

		.tui-category {
			font-size: 24rpx;
			color: #fff;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			margin: 0;
			margin-right: 22rpx;
			flex-shrink: 0;
		}

		.tui-rolling-search {
			width: 100%; //500rpx
			height: 60rpx;
			border-radius: 35rpx;
			padding: 0 40rpx 0 30rpx;
			box-sizing: border-box;
			background: rgba(243, 243, 243, 1);
			border-radius: 36rpx;
			display: flex;
			align-items: center;
			flex-wrap: nowrap;
			font-size: 24rpx;
			font-family: $yq-font-parimary;
			font-weight: 400;
			color: rgba(140, 140, 140, 1);
			line-height: 34rpx;
		}

		.tui-swiper {
			font-size: 26rpx;
			height: 60rpx;
			flex: 1;
			padding-left: 12rpx;
		}

		.tui-swiper-item {
			display: flex;
			align-items: center;
		}

		.tui-hot-item {
			line-height: 26rpx;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
		}

		.ov-texts {
			font-size: 28rpx;
			font-family: $yq-font-parimary;
			font-weight: 400;
			color: rgba(38, 38, 38, 1);
			line-height: 40rpx;
			display: flex;
			align-items: center;
		}

		.ov-menus-box {
			display: flex;
			padding: 26rpx 44rpx 0 44rpx;
			box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(0, 0, 0, 0.1);
			background: rgba(255, 255, 255, 1);

			.ov-menu-show {
				display: block;
			}

			.ov-menu-hide {
				display: none;
			}

			.ov-menu-selected {
				font-size: 40rpx;
				font-family: $yq-font-parimary;
				font-weight: 600;
				color: rgba(38, 38, 38, 1);
				line-height: 56rpx;
				display: flex;
				margin-right: 60rpx;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				.ov-menu-line {
					width: 44rpx;
					height: 6rpx;
					background: rgba(3, 3, 3, 1);
					border-radius: 4rpx;
					margin-top: 26rpx;
				}
			}

			.ov-menu-item {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				margin-right: 60rpx;

				.ov-menu {
					font-size: 24rpx;
					font-family: $yq-font-parimary;
					font-weight: 600;
					color: rgba(38, 38, 38, 1);
					line-height: 34rpx;
				}

				.ov-menu-line {
					width: 44rpx;
					height: 6rpx;
					background: rgba(3, 3, 3, 1);
					border-radius: 4rpx;
					margin-top: 26rpx;
				}


			}

		}
	}
</style>

上拉加載組件

<template>
	<view class="load-more">
		<view class="loading-img" v-show="loadingType === 1 && showImage">
			<view class="load1">
				<view :style="{background:color}"></view>
				<view :style="{background:color}"></view>
				<view :style="{background:color}"></view>
				<view :style="{background:color}"></view>
			</view>
			<view class="load2">
				<view :style="{background:color}"></view>
				<view :style="{background:color}"></view>
				<view :style="{background:color}"></view>
				<view :style="{background:color}"></view>
			</view>
			<view class="load3">
				<view :style="{background:color}"></view>
				<view :style="{background:color}"></view>
				<view :style="{background:color}"></view>
				<view :style="{background:color}"></view>
			</view>
		</view>
		<text class="loading-text" :style="{color:color}">
		{{loadingType === 0 ? contentText.contentdown : (loadingType === 1 ? contentText.contentrefresh : contentText.contentnomore)}}</text>
	</view>
</template>
 
<script>
	export default {
		name: "load-more",
		props: {
			loadingType: {
				//上拉的狀態:0-loading前;1-loading中;2-沒有更多了
				type: Number,
				default: 0
			},
			showImage: {
				type: Boolean,
				default: true
			},
			color: {
				type: String,
				default: "#777777"
			},
			contentText: {
				type: Object,
				default () {
					return {
						contentdown: "上拉顯示更多",
						contentrefresh: "正在加載...",
						contentnomore: "沒有更多數據了"
					};
				}
			}
		},
		data() {
			return {}
		}
	}
</script>
 
<style>
	.load-more {
		display: flex;
		flex-direction: row;
		height: 80upx;
		align-items: center;
		justify-content: center;
	}
 
	.loading-img {
		height: 24px;
		width: 24px;
		margin-right: 10px;
	}
 
	.loading-text {
		font-size: 28upx;
		color: #777777;
	}
 
	.loading-img>view {
		position: absolute;
	}
 
	.load1,
	.load2,
	.load3 {
		height: 24px;
		width: 24px;
	}
 
	.load2 {
		transform: rotate(30deg);
	}
 
	.load3 {
		transform: rotate(60deg);
	}
 
	.loading-img>view view {
		width: 6px;
		height: 2px;
		border-top-left-radius: 1px;
		border-bottom-left-radius: 1px;
		background: #777;
		position: absolute;
		opacity: 0.2;
		transform-origin: 50%;
		-webkit-animation: load 1.56s ease infinite;
	}
 
	.loading-img>view view:nth-child(1) {
		transform: rotate(90deg);
		top: 2px;
		left: 9px;
	}
 
	.loading-img>view view:nth-child(2) {
		-webkit-transform: rotate(180deg);
		top: 11px;
		right: 0px;
	}
 
	.loading-img>view view:nth-child(3) {
		transform: rotate(270deg);
		bottom: 2px;
		left: 9px;
	}
 
	.loading-img>view view:nth-child(4) {
		top: 11px;
		left: 0px;
	}
 
	.load1 view:nth-child(1) {
		animation-delay: 0s;
	}
 
	.load2 view:nth-child(1) {
		animation-delay: 0.13s;
	}
 
	.load3 view:nth-child(1) {
		animation-delay: 0.26s;
	}
 
	.load1 view:nth-child(2) {
		animation-delay: 0.39s;
	}
 
	.load2 view:nth-child(2) {
		animation-delay: 0.52s;
	}
 
	.load3 view:nth-child(2) {
		animation-delay: 0.65s;
	}
 
	.load1 view:nth-child(3) {
		animation-delay: 0.78s;
	}
 
	.load2 view:nth-child(3) {
		animation-delay: 0.91s;
	}
 
	.load3 view:nth-child(3) {
		animation-delay: 1.04s;
	}
 
	.load1 view:nth-child(4) {
		animation-delay: 1.17s;
	}
 
	.load2 view:nth-child(4) {
		animation-delay: 1.30s;
	}
 
	.load3 view:nth-child(4) {
		animation-delay: 1.43s;
	}
 
	@-webkit-keyframes load {
		0% {
			opacity: 1;
		}
 
		100% {
			opacity: 0.2;
		}
	}
</style>

 微信jssdk 也可以使用npm 博主採用的npm

! function (e, n) {
  module.exports = n(e)
}(window, function (e, n) {
  function i(n, i, t) {
    e.WeixinJSBridge ? WeixinJSBridge.invoke(n, o(i),
    function(e) {
      c(n, e, t)
    }) : u(n, t)
  }
  function t(n, i, t) {
    e.WeixinJSBridge ? WeixinJSBridge.on(n,
    function(e) {
      t && t.trigger && t.trigger(e),
      c(n, e, i)
    }) : t ? u(n, t) : u(n, i)
  }
  function o(e) {
    return e = e || {},
    e.appId = C.appId,
    e.verifyAppId = C.appId,
    e.verifySignType = "sha1",
    e.verifyTimestamp = C.timestamp + "",
    e.verifyNonceStr = C.nonceStr,
    e.verifySignature = C.signature,
    e
  }
  function r(e) {
    return {
      timeStamp: e.timestamp + "",
      nonceStr: e.nonceStr,
      package: e.package,
      paySign: e.paySign,
      signType: e.signType || "SHA1"
    }
  }
  function a(e) {
    return e.postalCode = e.addressPostalCode,
    delete e.addressPostalCode,
    e.provinceName = e.proviceFirstStageName,
    delete e.proviceFirstStageName,
    e.cityName = e.addressCitySecondStageName,
    delete e.addressCitySecondStageName,
    e.countryName = e.addressCountiesThirdStageName,
    delete e.addressCountiesThirdStageName,
    e.detailInfo = e.addressDetailInfo,
    delete e.addressDetailInfo,
    e
  }
  function c(e, n, i) {
    "openEnterpriseChat" == e && (n.errCode = n.err_code),
    delete n.err_code,
    delete n.err_desc,
    delete n.err_detail;
    var t = n.errMsg;
    t || (t = n.err_msg, delete n.err_msg, t = s(e, t), n.errMsg = t),
    (i = i || {})._complete && (i._complete(n), delete i._complete),
    t = n.errMsg || "",
    C.debug && !i.isInnerInvoke && alert(JSON.stringify(n));
    var o = t.indexOf(":");
    switch (t.substring(o + 1)) {
    case "ok":
      i.success && i.success(n);
      break;
    case "cancel":
      i.cancel && i.cancel(n);
      break;
    default:
      i.fail && i.fail(n)
    }
    i.complete && i.complete(n)
  }
  function s(e, n) {
    var i = e,
    t = v[i];
    t && (i = t);
    var o = "ok";
    if (n) {
      var r = n.indexOf(":");
      "confirm" == (o = n.substring(r + 1)) && (o = "ok"),
      "failed" == o && (o = "fail"),
      -1 != o.indexOf("failed_") && (o = o.substring(7)),
      -1 != o.indexOf("fail_") && (o = o.substring(5)),
      "access denied" != (o = (o = o.replace(/_/g, " ")).toLowerCase()) && "no permission to execute" != o || (o = "permission denied"),
      "config" == i && "function not exist" == o && (o = "ok"),
      "" == o && (o = "fail")
    }
    return n = i + ":" + o
  }
  function d(e) {
    if (e) {
      for (var n = 0,
      i = e.length; n < i; ++n) {
        var t = e[n],
        o = h[t];
        o && (e[n] = o)
      }
      return e
    }
  }
  function u(e, n) {
    if (! (!C.debug || n && n.isInnerInvoke)) {
      var i = v[e];
      i && (e = i),
      n && n._complete && delete n._complete,
      console.log('"' + e + '",', n || "")
    }
  }
  function l(e) {
    if (! (k || w || C.debug || x < "6.0.2" || V.systemType < 0)) {
      var n = new Image;
      V.appId = C.appId,
      V.initTime = A.initEndTime - A.initStartTime,
      V.preVerifyTime = A.preVerifyEndTime - A.preVerifyStartTime,
      N.getNetworkType({
        isInnerInvoke: !0,
        success: function(e) {
          V.networkType = e.networkType;
          var i = "https://open.weixin.qq.com/sdk/report?v=" + V.version + "&o=" + V.isPreVerifyOk + "&s=" + V.systemType + "&c=" + V.clientVersion + "&a=" + V.appId + "&n=" + V.networkType + "&i=" + V.initTime + "&p=" + V.preVerifyTime + "&u=" + V.url;
          n.src = i
        }
      })
    }
  }
  function p() {
    return (new Date).getTime()
  }
  function f(n) {
    T && (e.WeixinJSBridge ? n() : S.addEventListener && S.addEventListener("WeixinJSBridgeReady", n, !1))
  }
  function m() {
    N.invoke || (N.invoke = function(n, i, t) {
      e.WeixinJSBridge && WeixinJSBridge.invoke(n, o(i), t)
    },
    N.on = function(n, i) {
      e.WeixinJSBridge && WeixinJSBridge.on(n, i)
    })
  }
  function g(e) {
    if ("string" == typeof e && e.length > 0) {
      var n = e.split("?")[0],
      i = e.split("?")[1];
      return n += ".html",
      void 0 !== i ? n + "?" + i: n
    }
  }
  if (!e.jWeixin) {
    var h = {
      config: "preVerifyJSAPI",
      onMenuShareTimeline: "menu:share:timeline",
      onMenuShareAppMessage: "menu:share:appmessage",
      onMenuShareQQ: "menu:share:qq",
      onMenuShareWeibo: "menu:share:weiboApp",
      onMenuShareQZone: "menu:share:QZone",
      previewImage: "imagePreview",
      getLocation: "geoLocation",
      openProductSpecificView: "openProductViewWithPid",
      addCard: "batchAddCard",
      openCard: "batchViewCard",
      chooseWXPay: "getBrandWCPayRequest",
      openEnterpriseRedPacket: "getRecevieBizHongBaoRequest",
      startSearchBeacons: "startMonitoringBeacons",
      stopSearchBeacons: "stopMonitoringBeacons",
      onSearchBeacons: "onBeaconsInRange",
      consumeAndShareCard: "consumedShareCard",
      openAddress: "editAddress"
    },
    v = function() {
      var e = {};
      for (var n in h) e[h[n]] = n;
      return e
    } (),
    S = e.document,
    I = S.title,
    y = navigator.userAgent.toLowerCase(),
    _ = navigator.platform.toLowerCase(),
    k = !(!_.match("mac") && !_.match("win")),
    w = -1 != y.indexOf("wxdebugger"),
    T = -1 != y.indexOf("micromessenger"),
    M = -1 != y.indexOf("android"),
    P = -1 != y.indexOf("iphone") || -1 != y.indexOf("ipad"),
    x = function() {
      var e = y.match(/micromessenger\/(\d+\.\d+\.\d+)/) || y.match(/micromessenger\/(\d+\.\d+)/);
      return e ? e[1] : ""
    } (),
    A = {
      initStartTime: p(),
      initEndTime: 0,
      preVerifyStartTime: 0,
      preVerifyEndTime: 0
    },
    V = {
      version: 1,
      appId: "",
      initTime: 0,
      preVerifyTime: 0,
      networkType: "",
      isPreVerifyOk: 1,
      systemType: P ? 1 : M ? 2 : -1,
      clientVersion: x,
      url: encodeURIComponent(location.href)
    },
    C = {},
    L = {
      _completes: []
    },
    B = {
      state: 0,
      data: {}
    };
    f(function() {
      A.initEndTime = p()
    });
    var O = !1,
    E = [],
    N = {
      config: function(e) {
        C = e,
        u("config", e);
        var n = !1 !== C.check;
        f(function() {
          if (n) i(h.config, {
            verifyJsApiList: d(C.jsApiList)
          },
          function() {
            L._complete = function(e) {
              A.preVerifyEndTime = p(),
              B.state = 1,
              B.data = e
            },
            L.success = function(e) {
              V.isPreVerifyOk = 0
            },
            L.fail = function(e) {
              L._fail ? L._fail(e) : B.state = -1
            };
            var e = L._completes;
            return e.push(function() {
              l()
            }),
            L.complete = function(n) {
              for (var i = 0,
              t = e.length; i < t; ++i) e[i]();
              L._completes = []
            },
            L
          } ()),
          A.preVerifyStartTime = p();
          else {
            B.state = 1;
            for (var e = L._completes,
            t = 0,
            o = e.length; t < o; ++t) e[t]();
            L._completes = []
          }
        }),
        m()
      },
      ready: function(e) {
        0 != B.state ? e() : (L._completes.push(e), !T && C.debug && e())
      },
      error: function(e) {
        x < "6.0.2" || ( - 1 == B.state ? e(B.data) : L._fail = e)
      },
      checkJsApi: function(e) {
        var n = function(e) {
          var n = e.checkResult;
          for (var i in n) {
            var t = v[i];
            t && (n[t] = n[i], delete n[i])
          }
          return e
        };
        i("checkJsApi", {
          jsApiList: d(e.jsApiList)
        },
        (e._complete = function(e) {
          if (M) {
            var i = e.checkResult;
            i && (e.checkResult = JSON.parse(i))
          }
          e = n(e)
        },
        e))
      },
      onMenuShareTimeline: function(e) {
        t(h.onMenuShareTimeline, {
          complete: function() {
            i("shareTimeline", {
              title: e.title || I,
              desc: e.title || I,
              img_url: e.imgUrl || "",
              link: e.link || location.href,
              type: e.type || "link",
              data_url: e.dataUrl || ""
            },
            e)
          }
        },
        e)
      },
      onMenuShareAppMessage: function(e) {
        t(h.onMenuShareAppMessage, {
          complete: function(n) {
            "favorite" === n.scene ? i("sendAppMessage", {
              title: e.title || I,
              desc: e.desc || "",
              link: e.link || location.href,
              img_url: e.imgUrl || "",
              type: e.type || "link",
              data_url: e.dataUrl || ""
            }) : i("sendAppMessage", {
              title: e.title || I,
              desc: e.desc || "",
              link: e.link || location.href,
              img_url: e.imgUrl || "",
              type: e.type || "link",
              data_url: e.dataUrl || ""
            },
            e)
          }
        },
        e)
      },
      onMenuShareQQ: function(e) {
        t(h.onMenuShareQQ, {
          complete: function() {
            i("shareQQ", {
              title: e.title || I,
              desc: e.desc || "",
              img_url: e.imgUrl || "",
              link: e.link || location.href
            },
            e)
          }
        },
        e)
      },
      onMenuShareWeibo: function(e) {
        t(h.onMenuShareWeibo, {
          complete: function() {
            i("shareWeiboApp", {
              title: e.title || I,
              desc: e.desc || "",
              img_url: e.imgUrl || "",
              link: e.link || location.href
            },
            e)
          }
        },
        e)
      },
      onMenuShareQZone: function(e) {
        t(h.onMenuShareQZone, {
          complete: function() {
            i("shareQZone", {
              title: e.title || I,
              desc: e.desc || "",
              img_url: e.imgUrl || "",
              link: e.link || location.href
            },
            e)
          }
        },
        e)
      },
      updateTimelineShareData: function(e) {
        i("updateTimelineShareData", {
          title: e.title,
          link: e.link,
          imgUrl: e.imgUrl
        },
        e)
      },
      updateAppMessageShareData: function(e) {
        i("updateAppMessageShareData", {
          title: e.title,
          desc: e.desc,
          link: e.link,
          imgUrl: e.imgUrl
        },
        e)
      },
      startRecord: function(e) {
        i("startRecord", {},
        e)
      },
      stopRecord: function(e) {
        i("stopRecord", {},
        e)
      },
      onVoiceRecordEnd: function(e) {
        t("onVoiceRecordEnd", e)
      },
      playVoice: function(e) {
        i("playVoice", {
          localId: e.localId
        },
        e)
      },
      pauseVoice: function(e) {
        i("pauseVoice", {
          localId: e.localId
        },
        e)
      },
      stopVoice: function(e) {
        i("stopVoice", {
          localId: e.localId
        },
        e)
      },
      onVoicePlayEnd: function(e) {
        t("onVoicePlayEnd", e)
      },
      uploadVoice: function(e) {
        i("uploadVoice", {
          localId: e.localId,
          isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
        },
        e)
      },
      downloadVoice: function(e) {
        i("downloadVoice", {
          serverId: e.serverId,
          isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
        },
        e)
      },
      translateVoice: function(e) {
        i("translateVoice", {
          localId: e.localId,
          isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
        },
        e)
      },
      chooseImage: function(e) {
        i("chooseImage", {
          scene: "1|2",
          count: e.count || 9,
          sizeType: e.sizeType || ["original", "compressed"],
          sourceType: e.sourceType || ["album", "camera"]
        },
        (e._complete = function(e) {
          if (M) {
            var n = e.localIds;
            try {
              n && (e.localIds = JSON.parse(n))
            } catch(e) {}
          }
        },
        e))
      },
      getLocation: function(e) {},
      previewImage: function(e) {
        i(h.previewImage, {
          current: e.current,
          urls: e.urls
        },
        e)
      },
      uploadImage: function(e) {
        i("uploadImage", {
          localId: e.localId,
          isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
        },
        e)
      },
      downloadImage: function(e) {
        i("downloadImage", {
          serverId: e.serverId,
          isShowProgressTips: 0 == e.isShowProgressTips ? 0 : 1
        },
        e)
      },
      getLocalImgData: function(e) { ! 1 === O ? (O = !0, i("getLocalImgData", {
          localId: e.localId
        },
        (e._complete = function(e) {
          if (O = !1, E.length > 0) {
            var n = E.shift();
            wx.getLocalImgData(n)
          }
        },
        e))) : E.push(e)
      },
      getNetworkType: function(e) {
        var n = function(e) {
          var n = e.errMsg;
          e.errMsg = "getNetworkType:ok";
          var i = e.subtype;
          if (delete e.subtype, i) e.networkType = i;
          else {
            var t = n.indexOf(":"),
            o = n.substring(t + 1);
            switch (o) {
            case "wifi":
            case "edge":
            case "wwan":
              e.networkType = o;
              break;
            default:
              e.errMsg = "getNetworkType:fail"
            }
          }
          return e
        };
        i("getNetworkType", {},
        (e._complete = function(e) {
          e = n(e)
        },
        e))
      },
      openLocation: function(e) {
        i("openLocation", {
          latitude: e.latitude,
          longitude: e.longitude,
          name: e.name || "",
          address: e.address || "",
          scale: e.scale || 28,
          infoUrl: e.infoUrl || ""
        },
        e)
      },
      getLocation: function(e) {
        e = e || {},
        i(h.getLocation, {
          type: e.type || "wgs84"
        },
        (e._complete = function(e) {
          delete e.type
        },
        e))
      },
      hideOptionMenu: function(e) {
        i("hideOptionMenu", {},
        e)
      },
      showOptionMenu: function(e) {
        i("showOptionMenu", {},
        e)
      },
      closeWindow: function(e) {
        i("closeWindow", {},
        e = e || {})
      },
      hideMenuItems: function(e) {
        i("hideMenuItems", {
          menuList: e.menuList
        },
        e)
      },
      showMenuItems: function(e) {
        i("showMenuItems", {
          menuList: e.menuList
        },
        e)
      },
      hideAllNonBaseMenuItem: function(e) {
        i("hideAllNonBaseMenuItem", {},
        e)
      },
      showAllNonBaseMenuItem: function(e) {
        i("showAllNonBaseMenuItem", {},
        e)
      },
      scanQRCode: function(e) {
        i("scanQRCode", {
          needResult: (e = e || {}).needResult || 0,
          scanType: e.scanType || ["qrCode", "barCode"]
        },
        (e._complete = function(e) {
          if (P) {
            var n = e.resultStr;
            if (n) {
              var i = JSON.parse(n);
              e.resultStr = i && i.scan_code && i.scan_code.scan_result
            }
          }
        },
        e))
      },
      openAddress: function(e) {
        i(h.openAddress, {},
        (e._complete = function(e) {
          e = a(e)
        },
        e))
      },
      openProductSpecificView: function(e) {
        i(h.openProductSpecificView, {
          pid: e.productId,
          view_type: e.viewType || 0,
          ext_info: e.extInfo
        },
        e)
      },
      addCard: function(e) {
        for (var n = e.cardList,
        t = [], o = 0, r = n.length; o < r; ++o) {
          var a = n[o],
          c = {
            card_id: a.cardId,
            card_ext: a.cardExt
          };
          t.push(c)
        }
        i(h.addCard, {
          card_list: t
        },
        (e._complete = function(e) {
          var n = e.card_list;
          if (n) {
            for (var i = 0,
            t = (n = JSON.parse(n)).length; i < t; ++i) {
              var o = n[i];
              o.cardId = o.card_id,
              o.cardExt = o.card_ext,
              o.isSuccess = !!o.is_succ,
              delete o.card_id,
              delete o.card_ext,
              delete o.is_succ
            }
            e.cardList = n,
            delete e.card_list
          }
        },
        e))
      },
      chooseCard: function(e) {
        i("chooseCard", {
          app_id: C.appId,
          location_id: e.shopId || "",
          sign_type: e.signType || "SHA1",
          card_id: e.cardId || "",
          card_type: e.cardType || "",
          card_sign: e.cardSign,
          time_stamp: e.timestamp + "",
          nonce_str: e.nonceStr
        },
        (e._complete = function(e) {
          e.cardList = e.choose_card_info,
          delete e.choose_card_info
        },
        e))
      },
      openCard: function(e) {
        for (var n = e.cardList,
        t = [], o = 0, r = n.length; o < r; ++o) {
          var a = n[o],
          c = {
            card_id: a.cardId,
            code: a.code
          };
          t.push(c)
        }
        i(h.openCard, {
          card_list: t
        },
        e)
      },
      consumeAndShareCard: function(e) {
        i(h.consumeAndShareCard, {
          consumedCardId: e.cardId,
          consumedCode: e.code
        },
        e)
      },
      chooseWXPay: function(e) {
        i(h.chooseWXPay, r(e), e)
      },
      openEnterpriseRedPacket: function(e) {
        i(h.openEnterpriseRedPacket, r(e), e)
      },
      startSearchBeacons: function(e) {
        i(h.startSearchBeacons, {
          ticket: e.ticket
        },
        e)
      },
      stopSearchBeacons: function(e) {
        i(h.stopSearchBeacons, {},
        e)
      },
      onSearchBeacons: function(e) {
        t(h.onSearchBeacons, e)
      },
      openEnterpriseChat: function(e) {
        i("openEnterpriseChat", {
          useridlist: e.userIds,
          chatname: e.groupName
        },
        e)
      },
      launchMiniProgram: function(e) {
        i("launchMiniProgram", {
          targetAppId: e.targetAppId,
          path: g(e.path),
          envVersion: e.envVersion
        },
        e)
      },
      miniProgram: {
        navigateBack: function(e) {
          e = e || {},
          f(function() {
            i("invokeMiniProgramAPI", {
              name: "navigateBack",
              arg: {
                delta: e.delta || 1
              }
            },
            e)
          })
        },
        navigateTo: function(e) {
          f(function() {
            i("invokeMiniProgramAPI", {
              name: "navigateTo",
              arg: {
                url: e.url
              }
            },
            e)
          })
        },
        redirectTo: function(e) {
          f(function() {
            i("invokeMiniProgramAPI", {
              name: "redirectTo",
              arg: {
                url: e.url
              }
            },
            e)
          })
        },
        switchTab: function(e) {
          f(function() {
            i("invokeMiniProgramAPI", {
              name: "switchTab",
              arg: {
                url: e.url
              }
            },
            e)
          })
        },
        reLaunch: function(e) {
          f(function() {
            i("invokeMiniProgramAPI", {
              name: "reLaunch",
              arg: {
                url: e.url
              }
            },
            e)
          })
        },
        postMessage: function(e) {
          f(function() {
            i("invokeMiniProgramAPI", {
              name: "postMessage",
              arg: e.data || {}
            },
            e)
          })
        },
        getEnv: function(n) {
          f(function() {
            n({
              miniprogram: "miniprogram" === e.__wxjs_environment
            })
          })
        }
      }
    },
    b = 1,
    R = {};
    return S.addEventListener("error",
    function(e) {
      if (!M) {
        var n = e.target,
        i = n.tagName,
        t = n.src;
        if (("IMG" == i || "VIDEO" == i || "AUDIO" == i || "SOURCE" == i) && -1 != t.indexOf("wxlocalresource://")) {
          e.preventDefault(),
          e.stopPropagation();
          var o = n["wx-id"];
          if (o || (o = b++, n["wx-id"] = o), R[o]) return;
          R[o] = !0,
          wx.ready(function() {
            wx.getLocalImgData({
              localId: t,
              success: function(e) {
                n.src = e.localData
              }
            })
          })
        }
      }
    },
    !0),
    S.addEventListener("load",
    function(e) {
      if (!M) {
        var n = e.target,
        i = n.tagName;
        n.src;
        if ("IMG" == i || "VIDEO" == i || "AUDIO" == i || "SOURCE" == i) {
          var t = n["wx-id"];
          t && (R[t] = !1)
        }
      }
    },
    !0),
    n && (e.wx = e.jWeixin = N),
    N
  }
});

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章