<template>
	<view class="body">
		<view class="wrapper">
			<view class="box box-first">
				<u-row justify="around">
					<u-col :span="span" :offset="offset" @click="navigateToLedger">
						<view>
							<u-image src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/zhangdan.png"
								class="image" height="140rpx" width="140rpx"></u-image>
						</view>
						<view class="text box-first-txt">账单</view>
					</u-col>
					<u-col :span="span" :offset="offset" @click="navigateToQrList">
						<view>
							<u-image
								src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/shouyintai.png"
								class="image" height="140rpx" width="140rpx"></u-image>
						</view>
						<view class="text box-first-txt">收银台</view>
					</u-col>

					<u-col :span="span" :offset="offset" @click="navigateToReport">
						<view>
							<u-image src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/baobiao.png"
								class="image" height="140rpx" width="140rpx"></u-image>
						</view>
						<view class="text box-first-txt">报表</view>
					</u-col>
				</u-row>
			</view>

			<view class="box box-second">
				<u-row justify="around">
					<u-col class="row-second-cus" :span="span" :offset="offset" @click="autoMoneyHistory">
						<view>
							<u-image
								src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/aotu_money_history.png"
								class="image" height="75rpx" width="75rpx"></u-image>
						</view>
						<view class="text">结算记录</view>
					</u-col>

					<!-- <u-col class="row-second-cus" :span="span" :offset="offset" @click="navigateToBonus">
						<view>
							<u-image
								src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/home_reward.png"
								class="image" height="75rpx" width="75rpx"></u-image>
						</view>
						<view class="text">奖励金</view>
					</u-col>
					<u-col class="row-second-cus" :span="span" :offset="offset" @click="navigateToDepositCard">
						<view>
							<u-image
								src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/home_credit_card.png"
								class="image" height="75rpx" width="75rpx"></u-image>
						</view>
						<view class="text">储值卡</view>
					</u-col> -->
					<u-col class="row-second-cus" :span="span" :offset="offset" @click="credigGiveSetPage">
						<view>
							<u-image
								src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/credit_give.png"
								class="image" height="75rpx" width="75rpx"></u-image>
						</view>
						<view class="text">扫码送金豆</view>
					</u-col>

					<u-col class="row-second-cus" :span="span" :offset="offset"
						@click="credigGive">
						<view>
							<u-image
								src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/home_manage.png"
								class="image" height="75rpx" width="75rpx"></u-image>
						</view>
						<view class="text">金豆抵扣</view>
					</u-col>
					<u-col class="row-second-cus" :span="span" :offset="offset" @click="navigateToStoreSetup">
						<view>
							<u-image
								src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/home_shop_setting.png"
								class="image" height="75rpx" width="75rpx"></u-image>
						</view>
						<view class="text">店铺设置</view>
					</u-col>
					<!-- <u-col class="row-second-cus" :span="span" :offset="offset" @click="autoMoney">
						<view>
							<u-image src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/bank.png"
								class="image" height="75rpx" width="75rpx"></u-image>
						</view>
						<view class="text">结算银行卡</view>
					</u-col>
					<u-col class="row-second-cus" v-if="false" :span="span" :offset="offset" @click="autoMoney">
						<view>
							<u-image
								src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/aotu_money.png"
								class="image" height="75rpx" width="75rpx"></u-image>
						</view>
						<view class="text">进销存</view>
					</u-col>
					<u-col class="row-second-cus" :span="span" :offset="offset" @click="bindAlipay">
						<view>
							<u-image
								src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/icon_alipay.png"
								class="image" height="75rpx" width="75rpx"></u-image>
						</view>
						<view class="text">绑定支付宝</view>
					</u-col>
					<u-col class="row-second-cus" :span="span" :offset="offset"
						@click="go2Page('/pages/home/more_fun/more_fun')">
						<view>
							<u-image
								src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/more_function.png"
								class="image" height="75rpx" width="75rpx"></u-image>
						</view>
						<view class="text">更多功能</view>
					</u-col> -->
					<u-col class="row-second-cus" :span="span" :offset="offset" @click="safecenter">
						<view>
							<u-image
								src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/more_function.png"
								class="image" height="75rpx" width="75rpx"></u-image>
						</view>
						<view class="text">安全中心</view>
					</u-col>
					<u-col class="row-second-cus" :span="span" :offset="offset" @click="autoMoney">
						<view>
							<u-image src="http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/bank.png"
								class="image" height="75rpx" width="75rpx"></u-image>
						</view>
						<view class="text">结算银行卡</view>
					</u-col>
				</u-row>
			</view>

			<!--  <view>
        <u-notice-bar type="error" :show="showNoticeBar" @getMore="showNotice" @click="showNotice"
          @close="showNoticeBar = false" :more-icon='true' :text="notice" :close-icon="true"></u-notice-bar>
      </view> -->
			<!-- 首页广告 -->
			<view class="swiper">
				<u-swiper @change="swipChange" :height="250" :list="swipList" :effect3d="effect3d"
					:indicator-pos="indicatorPos" :mode="mode" :interval="3000" @click="newsClick"></u-swiper>
			</view>
			<!-- 首页广告 -->
		</view>
	</view>
</template>

<script>
	var that = {},
		userInfo, autoGo2CashTask
	export default {
		data() {
			return {
				span: 4,
				offset: 0,
				bgColor: 'none',
				halfWidth: 150,
				borderColor: '#dcdfe6',
				type: 'primary',
				color: '#909399',
				fontSize: '26',
				// swiper
				// swipList: [{
				// 	image: 'http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home_swiper.png',
				// 	title: '',
				// 	url: 'https://v1.angyakeji.com/appindex.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=article.list'
				// }],
				swipList: [
					'http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home_swiper.png',
					// title: '',
					// url: 'https://v1.angyakeji.com/appindex.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=article.list'
				],
				title: false,
				mode: 'round',
				indicatorPos: 'bottomCenter',
				notice: "",
				showNoticeBar: false,
				yldstoreDataLocal: uni.getStorageSync("yldstoreDataLocal"),
				effect3d: false
			}
		},
		onLoad: function() {
			that = this
			// this.autoGo2Cash()
		},
		onUnload() {
			clearTimeout(autoGo2CashTask)
		},
		onShow: function() {
			this.yldstoreDataLocal = uni.getStorageSync("yldstoreDataLocal")
			// userInfo = uni.getStorageSync(getApp().globalData.config.userDataKey)
			// if (typeof (userInfo) == 'undefined' || !userInfo || !userInfo.mobile || !userInfo.sign) {
			// 	uni.reLaunch({
			// 		url: '/pages/login/index'
			// 	})
			// 	return
			// } else {
			setTimeout(function() {
				// 获取轮播图
				// that.init()
			}, 299)
			//	}
		},
		onPullDownRefresh() {
			setTimeout(function() {
				uni.showToast({
					title: '刷新成功',
					icon: 'none'
				})
				uni.stopPullDownRefresh({
					success: (result) => {},
					fail: (error) => {}
				})
			}, 688)

		},
		methods: {
			init() {
				// 获取商家通知
				this.showNotice()
				//获取轮播图
				getApp().globalData.util.request({
					s: 'Merch.Mershop_Index.swiper'
				}).then(res => {
					that.swipList = res.data.data
				})
			},
			go2Page(page) {
				uni.navigateTo({
					url: page
				})
			},
			// 自动跳转到收银台
			autoGo2Cash() {
				//#ifdef APP-PLUS
				if (uni.getStorageSync("yldstoreDataLocal") && !uni.getStorageSync("yldstoreDataLocal").auto_go_cash) {
					return
				}
				autoGo2CashTask = setTimeout(function() {
					let pages = getCurrentPages() //关于获取页面的官方文档https://uniapp.dcloud.io/api/window/window
					let page = pages[pages.length - 1].route
					if (page == "pages/home/home") {
						uni.navigateTo({
							url: '/pages/store/cashier/cashier'
						})
					}
				}, 1000 * 30)
				// #endif
			},
			newsClick(index) {
				if (that.swipList[index].url) {
					that.navigateTo('/pages/web_view/web_view?title=最新活动&url=' + encodeURIComponent((that.swipList[index]
						.url)))
				}
			},
			swipChange(index) {
				// console.log(index);
			},
			navigateTo(urlPath) {
				uni.navigateTo({
					url: urlPath,
					success(res) {
						//console.log(res)
					},
					fail(res) {
						console.log(res)
					}
				})
			},
			//安全中心
			safecenter(){
				uni.navigateTo({
					url:'/pages/store/secret/secret'
				})
			},
			//金豆抵扣
			credigGive(){
				uni.navigateTo({
					url:'/pages/store/withdraw/credit'
				})
			},
			navigateToProductManage(type) {
				this.navigateTo('pages/goods/list?type=' + type)
			},
			//账单
			navigateToLedger() {
				this.navigateTo('/pages/fiance/ledger/ledger')
			},
			//报表
			navigateToReport() {
				this.navigateTo('/pages/fiance/report/report')
			},
			//店铺设置
			navigateToStoreSetup() {
				this.navigateTo('/pages/store/setup')
			},
			navigateToDepositCard() {
				this.navigateTo('/pages/store/deposit/index')
			},
			//收银台
			navigateToQrList() {
				this.navigateTo('/pages/store/cashier/cashier')
			},
			navigateToQrList_sy_s() {
				this.navigateTo('/pages/store/cashier_sy/cashier_sy_s')
			},
			navigateToQrList_sy_f() {
				this.navigateTo('/pages/store/cashier_sy/cashier_sy_f/cashier_sy_f')
			},
			navigateToQrList_sy_scan() {
				this.navigateTo('/pages/store/cashier_sy/cashier_sy_b/cashier_sy_f')
			},
			navigateToBonus() {
				this.navigateTo('/pages/fiance/bonus/bonus')
			},
			merchantTutorial() {
				this.navigateTo('/pages/web_view/web_view?title=商家教程&url=' + encodeURIComponent(
					'https://yld.angyakeji.com/api/admin/public/view/merch_help/'))
			},
			//结算银行卡 自动结算
			autoMoney() {
				uni.navigateTo({
					url: '/pages/store/card'
				});
			},
			bindAlipay() {
				uni.navigateTo({
					url: '/pages/store/withdraw/alipay'
				});
			},
			//结算记录
			autoMoneyHistory() {
				uni.navigateTo({
					url: '/pages/store/withdraw/withdraw'
				})
			},
			//扫码送金豆
			credigGiveSetPage() {
				uni.navigateTo({
					url: '/pages/store/withdraw/creditadd'
				})
			},
			go2MoreFun() {
				uni.navigateTo({
					url: '/pages/store/more_fun/index'
				})
			},
			showNotice() {
				// 获取商家通知
				// getApp().globalData.util.request({
				// 	s: 'Merch.Sys_Index.notice'
				// }).then(res => {
				// 	let noticeData = res.data.data
				// 	console.log(6666, noticeData);
				// 	let currentTime = new Date().getTime() / 1000
				// 	if (noticeData?.endtime > currentTime) {
				// 		if (noticeData.showNoticeBar) {
				// 			that.showNoticeBar = true
				// 		}
				// 		this.notice = noticeData.content
				// 		if (noticeData.forceDialog) {
				// 			let tempContent = ""
				// 			for (let item in noticeData.content) {
				// 				tempContent += noticeData.content[item] + "\n\n"
				// 			}
				// 			if (JSON.stringify(noticeData) != uni.getStorageSync("dontNoticeContent")) {
				// 				uni.showModal({
				// 					title: noticeData.title,
				// 					content: tempContent,
				// 					cancelText: "不再提示",
				// 					confirmText: '关闭',
				// 					success: (res) => {
				// 						if (res.cancel) {
				// 							uni.setStorageSync("dontNoticeContent", JSON.stringify(
				// 								noticeData))
				// 						}
				// 					}
				// 				})
				// 			}
				// 		}
				// 	}
				// })
			},
			// /methods
		},


	}
</script>

<style lang="scss" scoped>
	/deep/.wrapper .box-second .image {
		display: flex;
		align-items: center;
	}

	/deep/.u-row {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
	}

	.main {
		opacity: 1;
	}

	.box-second {
		padding: 30rpx 0;
	}

	.box-second .text {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		font-size: 25rpx;
		margin-top: 10rpx;
	}

	.row-second-cus {
		padding-top: 25rpx !important;
		padding-bottom: 25rpx !important;
	}

	.body {
		padding-top: 450rpx;
		background: url(http://yuledui.oss-cn-qingdao.aliyuncs.com/merch_manage/img/home/merch_index_bg.png);
		background-repeat: no-repeat;
		background-size: contain;
	}

	.box-first-txt {
		margin-top: -15rpx !important;
	}

	.swiper {
		margin-top: 45rpx;
	}

	/deep/.u-col-4 {
		display: flex;
		align-items: center !important;
	}
</style>