Browse Source

新版tabbar

xiaohaizhao 2 năm trước cách đây
mục cha
commit
9f78acec3a

+ 9 - 0
pages/index/home/index.js

@@ -0,0 +1,9 @@
+Component({
+	properties: {},
+	options: {
+		addGlobalClass: true,
+	},
+	data: {
+		appid: "wxc1b6ae925ac1d06a"
+	},
+})

+ 4 - 0
pages/index/home/index.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 59 - 0
pages/index/home/index.scss

@@ -0,0 +1,59 @@
+
+.grld {
+    width: 100vw;
+    background-color: #fff;
+    box-sizing: border-box;
+    padding-top: 30rpx;
+
+    .group {
+        margin-bottom: 30rpx;
+
+        .label {
+            height: 36rpx;
+            font-size: 30rpx;
+            font-family: AppleSystemUIFont-Bold, AppleSystemUIFont;
+            font-weight: bold;
+            color: #333333;
+            margin-bottom: 10rpx;
+
+            text {
+                margin: 0 20rpx 0 30rpx;
+            }
+        }
+
+        .main {
+            display: flex;
+            flex-wrap: wrap;
+
+            .item {
+                display: flex;
+                flex-direction: column;
+                align-items: center;
+                padding: 20rpx 0;
+                width: 20%;
+                border-radius: 16rpx;
+
+                .icon-box {
+                    width: 80rpx;
+                    border-radius: 16rpx;
+                    line-height: 80rpx;
+                    text-align: center;
+
+                    text {
+                        font-size: 40rpx;
+                    }
+                }
+
+                .name {
+                    width: 80%;
+                    line-height: 30rpx;
+                    font-size: 24rpx;
+                    font-family: AppleSystemUIFont-Regular, AppleSystemUIFont;
+                    color: #333333;
+                    margin-top: 16rpx;
+                    text-align: center;
+                }
+            }
+        }
+    }
+}

+ 23 - 0
pages/index/home/index.wxml

@@ -0,0 +1,23 @@
+<scroll-view scroll-y class="scrollPage">
+	<swiper class="screen-swiper square-dot" indicator-dots="true" circular="true" autoplay="true" interval="5000" duration="500">
+		<swiper-item wx:for="{{bannerList}}" wx:key>
+			<image src="{{item.attinfos[0].url}}" mode="aspectFill" />
+		</swiper-item>
+	</swiper>
+	<view class="grld">
+		<block wx:for="{{entrance}}" wx:key="index">
+			<view class="group" wx:if="{{item.list.length}}">
+				<view class="label"><text class="work {{item.icon}}" />{{item.label}}</view>
+				<view class="main">
+					<navigator version='trial' class="item" wx:for="{{item.list}}" wx:for-item="it" wx:for-index="i" target='{{item.appid!=appid?"miniProgram":"self"}}' app-id='{{item.appid}}' path="{{it.path+'?auth='+auth+'&userMsg='+userMsg+'&site='+site}}" url="{{it.path}}" open-type="{{it.openType||'navigate'}}" wx:key="name" data-it="{{it}}" data-item="{{item}}" bindtap="openRecord">
+						<view class="icon-box" style="background-color: {{it.bColor}};">
+							<text class="work {{it.icon}}" style="color: {{it.color}};" />
+						</view>
+						<view class="name">{{it.name}}</view>
+					</navigator>
+				</view>
+			</view>
+		</block>
+	</view>
+	<view style="height: 160rpx;" />
+</scroll-view>

+ 159 - 0
pages/index/index.js

@@ -0,0 +1,159 @@
+const pageInit = {};
+
+Page({
+	data: {
+		PageCur: 'Home',
+	},
+	onLoad() {
+		this.refreshData();
+	},
+	/**
+	 * 更新站点信息
+	 * 主要用来渲染首页的banner和宫格
+	 */
+	refreshData() {
+		let page = this.selectComponent("#Home");
+		if (page && wx.getStorageSync('userauth').length != 0) {
+			let authList = {},
+				entrance = [{
+					label: "E-订单",
+					appid: "wxc1b6ae925ac1d06a",
+					icon: "work-E-dingdan",
+					list: getedd()
+				}];
+			//E订单
+			function getedd() {
+				let paths = [{
+					name: "商城",
+					path: "/packageA/market/index",
+					icon: "work-shangcheng"
+				}, {
+					name: "销售订单",
+					path: "/packageA/orderForm/index",
+					icon: "work-dingdan"
+				}, {
+					name: "账户",
+					path: "/packageA/account/index",
+					icon: "work-zhanghu"
+				}, {
+					name: "促销活动",
+					path: "/packageA/activity/index",
+					icon: "work-cuxiaohuodong"
+				}, {
+					name: "购物车",
+					path: "/packageA/shopping/index",
+					icon: "work-gouwuche"
+				}, {
+					name: "打款凭证",
+					path: "/packageA/remitVoucher/index",
+					icon: "work-dakuanpingzheng"
+				}, {
+					name: "退返申请",
+					path: "/packageA/returnOne/index",
+					icon: "work-shujuchaxun"
+				}, {
+					name: "发货单",
+					path: "/packageA/dispatchBill/index",
+					icon: "icon-shouhuo"
+				}];
+				let edd = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ["E-订单"], ["商品档案", "销售管理", "财务管理", "售后管理", "发货与库存", "业绩查询"]),
+					list = [];
+				edd.forEach(v => {
+					v.apps.forEach(s => {
+						authList[s.name] = {
+							options: s.meta.auth.map(a => a.option),
+							optionnames: s.meta.auth.map(a => a.optionname),
+						}
+						if (authList[s.name].options.some(s => s == "read")) {
+							let i = paths.findIndex(k => k.name == s.meta.title);
+							if (i != -1) {
+								paths[i].index = i;
+								list.push(paths[i])
+							}
+						}
+					})
+				});
+				return dye(list.sort((a, b) => a.index - b.index))
+			};
+			//染色
+			function dye(list) {
+				let colorList = [{
+					color: "#3874F6",
+					bColor: "#F0F3FF",
+				}, {
+					color: "#5AB73F",
+					bColor: "#F4FAEF",
+				}, {
+					color: "#F29C37",
+					bColor: "#FCF6EF",
+				}, {
+					color: "#EB4B5C",
+					bColor: "#FDF1ED",
+				}, {
+					color: "#3874F6",
+					bColor: "#F0F3FF",
+				}, {
+					color: "#F29C37",
+					bColor: "#FCF6EF",
+				}, {
+					color: "#EB4B5C",
+					bColor: "#FDF1ED",
+				}, {
+					color: "#3874F6",
+					bColor: "#F0F3FF",
+				}, {
+					color: "#5AB73F",
+					bColor: "#F4FAEF",
+				}, {
+					color: "#F29C37",
+					bColor: "#FCF6EF",
+				}, {
+					color: "#5AB73F",
+					bColor: "#F4FAEF",
+				}, {
+					color: "#3874F6",
+					bColor: "#F0F3FF",
+				}, {
+					color: "#F29C37",
+					bColor: "#FCF6EF",
+				}, {
+					color: "#EB4B5C",
+					bColor: "#FDF1ED",
+				}, {
+					color: "#5AB73F",
+					bColor: "#F4FAEF",
+				}];
+				return list.map((v, i) => {
+					return {
+						...v,
+						...colorList[i > colorList.length - 1 ? i - colorList.length : i]
+					}
+				})
+			};
+			wx.setStorageSync('auth', authList)
+			let banner = wx.getStorageSync('banner_list').find(v => v.location == "index_top");
+			page.setData({
+				entrance,
+				bannerList: banner ? banner.ads : []
+			});
+			pageInit.Home = true;
+		} else {
+			setTimeout(this.refreshData, 10);
+			return;
+		}
+	},
+	/** 
+	 * 切换页面
+	 */
+	NavChange(e) {
+		let PageCur = e.currentTarget.dataset.cur;
+		if (!pageInit[PageCur]) {
+			let page = this.selectComponent("#" + PageCur);
+			page && page.init();
+			pageInit[PageCur] = true;
+		}
+		this.setData({
+			PageCur
+		})
+	},
+})

+ 6 - 0
pages/index/index.json

@@ -0,0 +1,6 @@
+{
+	"usingComponents": {
+		"Home": "./home/index",
+		"UserCenter": "./userCenter"
+	}
+}

+ 138 - 0
pages/index/index.scss

@@ -0,0 +1,138 @@
+.user-box {
+    width: 750rpx;
+    background-color: var(--bgColor);
+    padding: 30rpx;
+    box-sizing: border-box;
+    color: #FFFFFF;
+    font-family: PingFang SC-Regular, PingFang SC;
+
+    /* 用户展示内容 */
+    .user-con {
+        display: flex;
+        height: 128rpx;
+        align-items: center;
+        background: none;
+
+        .v-img {
+            margin-top: 5rpx;
+        }
+
+        .user-msg {
+            flex: 1;
+            height: 100%;
+            margin-left: 30rpx;
+
+            .user-name {
+                height: 50rpx;
+                font-size: 36rpx;
+                font-weight: bold;
+                margin-top: 16rpx;
+
+                text {
+                    display: inline-block;
+                    height: 40rpx;
+                    font-size: 28rpx;
+                    margin-left: 40rpx;
+                }
+            }
+
+            .user-phone {
+                height: 38rpx;
+                font-size: 24rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                line-height: 38rpx;
+                margin-top: 10rpx;
+            }
+        }
+    }
+}
+.operating {
+    width: 690rpx;
+    margin: 0 auto;
+    background-color: #fff;
+    margin-top: 40rpx;
+    border-radius: 16rpx;
+    overflow: hidden;
+
+    .item {
+        width: 100%;
+
+        .con {
+            display: flex;
+            justify-content: space-between;
+            width: calc(100% - 30rpx);
+            height: 90rpx;
+            line-height: 90rpx;
+            border-bottom: 1rpx solid #eeeeee;
+            margin-left: 30rpx;
+            padding-right: 20rpx;
+            box-sizing: border-box;
+
+            .label {
+                display: flex;
+                align-items: center;
+                font-size: 28rpx;
+                font-family: PingFang SC-Medium, PingFang SC;
+                font-weight: 500;
+                color: #333333;
+
+                text {
+                    font-size: 50rpx;
+                    margin-right: 10rpx;
+                }
+
+                .bd-wechat {
+                    width: 90rpx;
+                    height: 36rpx;
+                    line-height: 36rpx;
+                    text-align: center;
+                    border-radius: 4rpx;
+                    border: 1rpx solid #CCCCCC;
+                    font-size: 20rpx;
+                    font-family: PingFangSC-Regular-, PingFangSC-Regular;
+                    font-weight: normal;
+                    color: #999999;
+                    margin-left: 10rpx;
+                }
+            }
+
+        }
+    }
+
+    .item:last-child .con {
+        border-bottom: 0;
+    }
+
+    .item-right {
+        display: flex;
+        align-items: center;
+        line-height: 20rpx;
+
+        .user-img {
+            width: 58rpx;
+            height: 58rpx;
+            border-radius: 50%;
+            margin-right: 20rpx;
+        }
+    }
+
+    .tips {
+        font-size: 24rpx !important;
+        margin-top: -4rpx;
+        margin-right: 10rpx;
+        color: #333333;
+    }
+
+    .right-false {
+        color: var(--error);
+    }
+}
+/* 退出登录 */
+.out-login {
+    width: 500rpx;
+    height: 90rpx;
+    border-radius: 90rpx !important;
+    font-size: 28rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #333333 !important;
+}

+ 37 - 0
pages/index/index.wxml

@@ -0,0 +1,37 @@
+<view hidden="{{PageCur!='Home'}}">
+	<Home id='Home' />
+</view>
+<view hidden="{{PageCur!='UserCenter'}}">
+	<UserCenter id='UserCenter' />
+</view>
+
+
+
+<view class="cu-bar tabbar bg-white foot">
+
+	<view class="action {{PageCur=='Home'?'text-blue':'text-gray'}}" bindtap="NavChange" data-cur="Home">
+		<view class="cuIcon-homefill"></view>
+		首页
+	</view>
+
+	<view class="action {{PageCur=='Home'?'text-blue':'text-gray'}}">
+		<view class="cuIcon-similar"></view> 分类
+	</view>
+
+	<view class="action {{PageCur=='Home'?'text-blue':'text-gray'}} add-action">
+		<button class="cu-btn cuIcon-shopfill bg-blue shadow"></button>
+		商城
+	</view>
+
+	<view class="action  {{PageCur=='Home'?'text-blue':'text-gray'}}">
+		<view class=" cuIcon-cart">
+			<view class="cu-tag badge">99</view>
+		</view>
+		购物车
+	</view>
+
+	<view class="action  {{PageCur=='UserCenter'?'text-blue':'text-gray'}}" bindtap="NavChange" data-cur="UserCenter">
+		<view class="cuIcon-my"></view>
+		我的
+	</view>
+</view>

+ 155 - 0
pages/index/userCenter/index.js

@@ -0,0 +1,155 @@
+const _Http = getApp().globalData.http;
+Component({
+	properties: {
+
+	},
+	options: {
+		addGlobalClass: true,
+	},
+	data: {},
+	methods: {
+		init() {
+			console.log("打开个人应用")
+			this.queryUserMsg();
+
+			let authlist = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['通用'], ['个人中心']);
+			let pathList = [{
+				name: "修改登录密码",
+				icon: "icon-a-wodeguanyuyingyong",
+				color: "var(--warning)",
+				path: `/pages/tabbar/mine/changePassword/index`
+			}]
+			if (authlist.length != 0) authlist[0].apps.forEach(v => {
+				switch (v.name) {
+					case "teamManagement":
+						console.log(v)
+						pathList.unshift({
+							name: "团队管理",
+							icon: "icon-a-wodetuanduiguanli",
+							color: "var(--assist)",
+							path: `/${v.path}`
+						})
+						this.setData({
+							teamAuth: JSON.stringify(v.meta.auth)
+						})
+						break;
+				}
+			});
+			this.setData({
+				pathList
+			})
+		},
+		/* 查询用户信息 */
+		queryUserMsg() {
+			_Http.basic({
+				"classname": "common.usercenter.usercenter",
+				"method": "queryUserMsg",
+				"content": {
+					"nocache": true
+				}
+			}).then(res => {
+				console.log("查询用户信息", res)
+				if (res.msg != '成功') {
+					wx.showToast({
+						title: res.msg,
+						icon: "none"
+					})
+				} else {
+					this.setData({
+						userMsg: res.data
+					})
+				}
+			})
+		},
+		/* 退出登录 */
+		outLogin() {
+			clearTimeout(downCount);
+			wx.showLoading({
+				title: '正在退出...',
+			})
+			downCount = setTimeout(() => {
+				_Http.logout().then(res => {
+					wx.showToast({
+						title: '退出成功'
+					});
+					let loginMsg = wx.getStorageSync("loginMsg");
+					wx.clearStorageSync();
+					wx.setStorageSync('loginMsg', loginMsg)
+					setTimeout(() => {
+						wx.reLaunch({
+							url: '/pages/login/phone',
+						})
+					}, 300)
+				})
+			}, 300);
+		},
+		/* 去修改用户信息 */
+		changeUserMsg() {
+			let {
+				name,
+				phonenumber,
+				attinfos,
+				hr
+			} = this.data.userMsg;
+			wx.navigateTo({
+				url: `./userMsg/index?attinfos=${JSON.stringify(attinfos)}&name=${name}&phonenumber=${phonenumber}&email=${hr.email}`
+			})
+		},
+		/* 绑定或解绑微信 */
+		bindingWechat(e) {
+			if (this.data.userMsg.iswechatbinding) {
+				let that = this;
+				wx.showModal({
+					title: "提示",
+					content: "是否解除绑定",
+					success: (res) => {
+						if (res.confirm) that.handleBDWechat(0);
+					}
+				})
+			} else {
+				this.handleBDWechat(1);
+			}
+		},
+		handleBDWechat(isbinging) {
+			let that = this;
+			wx.getUserProfile({
+				desc: '用于完善用户资料',
+				success: ({
+					userInfo
+				}) => {
+					wx.login({
+						success(res) {
+							if (res.code) _Http.basic({
+								"classname": "common.usercenter.usercenter",
+								"method": "WechatBinding",
+								content: {
+									"wechat_code": res.code,
+									isbinging, // 0解绑 1绑定
+									wechatuserinfo: userInfo
+								}
+							}).then(s => {
+								if (s.msg != '成功') return wx.showToast({
+									title: s.data,
+									icon: "none"
+								});
+								setTimeout(() => {
+									wx.showToast({
+										title: isbinging == 0 ? '解除成功' : '绑定成功',
+										icon: "none"
+									})
+								}, 100);
+								that.queryUserMsg();
+							})
+						}
+					})
+				},
+				fail: () => {
+					wx.showToast({
+						title: '操作失败,未获得授权',
+						icon: "none"
+					})
+				}
+			})
+		},
+	}
+})

+ 4 - 0
pages/index/userCenter/index.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 140 - 0
pages/index/userCenter/index.scss

@@ -0,0 +1,140 @@
+.user-box {
+    width: 750rpx;
+    background-color: var(--bgColor);
+    padding: 30rpx;
+    box-sizing: border-box;
+    color: #FFFFFF;
+    font-family: PingFang SC-Regular, PingFang SC;
+
+    /* 用户展示内容 */
+    .user-con {
+        display: flex;
+        height: 128rpx;
+        align-items: center;
+        background: none;
+
+        .v-img {
+            margin-top: 5rpx;
+        }
+
+        .user-msg {
+            flex: 1;
+            height: 100%;
+            margin-left: 30rpx;
+
+            .user-name {
+                height: 50rpx;
+                font-size: 36rpx;
+                font-weight: bold;
+                margin-top: 16rpx;
+
+                text {
+                    display: inline-block;
+                    height: 40rpx;
+                    font-size: 28rpx;
+                    margin-left: 40rpx;
+                }
+            }
+
+            .user-phone {
+                height: 38rpx;
+                font-size: 24rpx;
+                font-family: PingFang SC-Regular, PingFang SC;
+                line-height: 38rpx;
+                margin-top: 10rpx;
+            }
+        }
+    }
+}
+
+.operating {
+    width: 690rpx;
+    margin: 0 auto;
+    background-color: #fff;
+    margin-top: 40rpx;
+    border-radius: 16rpx;
+    overflow: hidden;
+
+    .item {
+        width: 100%;
+
+        .con {
+            display: flex;
+            justify-content: space-between;
+            width: calc(100% - 30rpx);
+            height: 90rpx;
+            line-height: 90rpx;
+            border-bottom: 1rpx solid #eeeeee;
+            margin-left: 30rpx;
+            padding-right: 20rpx;
+            box-sizing: border-box;
+
+            .label {
+                display: flex;
+                align-items: center;
+                font-size: 28rpx;
+                font-family: PingFang SC-Medium, PingFang SC;
+                font-weight: 500;
+                color: #333333;
+
+                text {
+                    font-size: 50rpx;
+                    margin-right: 10rpx;
+                }
+
+                .bd-wechat {
+                    width: 90rpx;
+                    height: 36rpx;
+                    line-height: 36rpx;
+                    text-align: center;
+                    border-radius: 4rpx;
+                    border: 1rpx solid #CCCCCC;
+                    font-size: 20rpx;
+                    font-family: PingFangSC-Regular-, PingFangSC-Regular;
+                    font-weight: normal;
+                    color: #999999;
+                    margin-left: 10rpx;
+                }
+            }
+
+        }
+    }
+
+    .item:last-child .con {
+        border-bottom: 0;
+    }
+
+    .item-right {
+        display: flex;
+        align-items: center;
+        line-height: 20rpx;
+
+        .user-img {
+            width: 58rpx;
+            height: 58rpx;
+            border-radius: 50%;
+            margin-right: 20rpx;
+        }
+    }
+
+    .tips {
+        font-size: 24rpx !important;
+        margin-top: -4rpx;
+        margin-right: 10rpx;
+        color: #333333;
+    }
+
+    .right-false {
+        color: var(--error);
+    }
+}
+
+/* 退出登录 */
+.out-login {
+    width: 500rpx;
+    height: 90rpx;
+    border-radius: 90rpx !important;
+    font-size: 28rpx;
+    font-family: PingFang SC-Regular, PingFang SC;
+    color: #333333 !important;
+}

+ 63 - 0
pages/index/userCenter/index.wxml

@@ -0,0 +1,63 @@
+<scroll-view scroll-y class="scrollPage">
+	<view class="user-box">
+		<navigator url="#" class="user-con" bindtap="changeUserMsg">
+			<van-image image-class="v-img" round width="128rpx" height="128rpx" src="{{userMsg.attinfos[0].url||'/static/image/user.png'}}" />
+			<view class="user-msg">
+				<view class="user-name">
+					{{userMsg.name}}<text>{{userMsg.hr.position}}</text>
+				</view>
+				<view class="user-phone">
+					{{userMsg.phonenumber}}
+				</view>
+			</view>
+			<van-icon size='40rpx' name="arrow" />
+		</navigator>
+	</view>
+	<view class="operating">
+		<navigator class="item" wx:if="{{userMsg.enterprise.sys_enterpriseid}}" url="/pages/tabbar/mine/address/index?id={{userMsg.enterprise.sys_enterpriseid}}">
+			<view class="con">
+				<view class="label">
+					<text class="iconfont icon-a-wodemendianxinxidizhi" style="color: #085CDF;" />
+					我的地址
+				</view>
+				<view class="item-right">
+					<van-icon size='30rpx' name="arrow" />
+				</view>
+			</view>
+		</navigator>
+		<navigator class="item" url="{{item.name=='团队管理'?item.path+'?auth='+teamAuth:item.path}}" wx:for="{{pathList}}">
+			<view class="con">
+				<view class="label">
+					<text class="iconfont {{item.icon}}" style="color: {{item.color}};" />
+					{{item.name}}
+				</view>
+				<view class="item-right">
+					<van-icon size='30rpx' name="arrow" />
+				</view>
+			</view>
+		</navigator>
+
+		<navigator class="item" url="#" bindtap="bindingWechat">
+			<view class="con">
+				<view class="label">
+					<text class="iconfont icon-a-wodebangdingweixin" style="color: var(--success);" />
+					绑定微信
+					<view wx:if="{{userMsg.iswechatbinding}}" class="bd-wechat">已绑定</view>
+				</view>
+				<view class="item-right">
+					<image class="user-img" wx:if="{{userMsg.iswechatbinding}}" src="{{userMsg.wechatuserinfo.avatarUrl}}" />
+					<view class="tips right-false" wx:else>
+						未绑定
+					</view>
+					<van-icon size='30rpx' name="arrow" />
+				</view>
+			</view>
+		</navigator>
+
+	</view>
+	<view style="width: 100vw;text-align: center;margin-top: 200rpx;">
+		<van-button custom-class='out-login' color="#CCC" bindtap="outLogin" plain>退出登录</van-button>
+	</view>
+
+
+</scroll-view>