123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- <template>
- <view class="">
- <view>
- <!-- <view style="margin: 40px 0 0 20px; font-size: 20px;">
- {{form.orgName}}
- </view> -->
- <u-sticky>
- <view class="topToolsBody uni-flex uni-row">
- <view class="topTools flex-item" @click="takeMeal()" :style="'width:'+topToolsWidth">
- <view>
- <image src="../../static/img/home/sys.png"></image>
- </view>
- 扫一扫
- </view>
- <view class="topTools flex-item" @click="toPayCodePage" :style="'width:'+topToolsWidth">
- <view>
- <image src="../../static/img/home/qcCode.png"></image>
- </view>
- HS码
- </view>
- <view v-if="type === 3" class="topTools flex-item" @click="toIntegralPage"
- :style="'width:'+topToolsWidth">
- <view>
- <image src="../../static/img/home/jifenshangcheng.png"></image>
- </view>
- 兑换
- </view>
- <view class="topTools flex-item" :style="'width:'+topToolsWidth" @click="$showModal('功能暂未开放')">
- <view>
- <image src="../../static/img/home/task.png"></image>
- </view>
- 任务
- </view>
- <view class="topTools flex-item" style="position: relative;" @click="toXiaoxiPage"
- :style="'width:'+topToolsWidth">
- <view>
- <image src="../../static/img/home/xiaoxi.png"></image>
- </view>
- 消息
- <view v-if="msgNum > 0" class="hs-hzl-count count" :style="'left:' +xxjbleft+'rpx'">
- {{msgNum}}
- </view>
- </view>
- </view>
- </u-sticky>
- <view class="modules">
- <homelist title="单位通告" :limit="2" :showType="1" @click="onClick" :list="noticeList"
- :url="this.$BASE_URL">
- </homelist>
- </view>
- <view class="modules" v-if="type === 3">
- <homelist title="相关资讯" :limit="4" :showType="2" :list="xgzxList" :url="baseURL">
- </homelist>
- </view>
- <view class="modules">
- <homelist title="平台资讯" :limit="4" :showType="2" :list="ptzxList" :url="baseURL">
- </homelist>
- </view>
- </view>
- <!-- <wp-tabbar ref="tab" pagePath="/pages/home/index" :type="type"></wp-tabbar> -->
- </view>
- </template>
- <script>
- // 页面模块组件
- import Classify1 from '@/components/classify-1/classify-1.vue'
- import homelist from '@/components/homelist/homelist.vue'
- export default {
- name: 'Index',
- components: {
- Classify1,
- homelist
- },
- data() {
- return {
- msgNum: 0,
- topToolsWidth: "15%",
- baseURL: this.$BASE_URL,
- ptzxList: [],
- xgzxList: [],
- xxjbleft: 85,
- indexConfig: [{
- name: 'banner-1',
- data: []
- }, {
- name: 'classify-1',
- data: []
- }, {
- name: 'homelist',
- data: []
- }],
- noticeList: [],
- form: {
- },
- type: undefined,
- openid: '',
- tabMark: []
- }
- },
- mounted() {
- const userInfo = uni.getStorageSync('userInfo');
- const orgInfo = uni.getStorageSync('orgInfo');
- this.form.userName = userInfo.nickName
- this.form.userNo = userInfo.userName
- this.form.orgNo = orgInfo.organizationCode
- this.form.orgName = orgInfo.organizationName
- uni.setStorageSync('refreshStart', 1)
- let baseUrlSocket = this.$BASE_URL_SOCKET
- if (!uni.getStorageSync('deptData')) {
- this.$httpRequest({
- url: '/app/deptInfo?id=' + uni.getStorageSync('org_dept_parent_id'),
- urlType: this.$getUrlType()
- }).then(res => {
- if (res.data.code === 200) {
- uni.setStorageSync('deptData', res.data.data)
- }
- })
- }
- if (!uni.getStorageSync('postsData')) {
- this.$httpRequest({
- url: '/app/posts',
- urlType: this.$getUrlType()
- }).then(res => {
- if (res.data.code === 200) {
- uni.setStorageSync('postsData', res.data.data)
- }
- })
- }
- this.msgs()
- setInterval(() => {
- this.msgs()
- }, 600);
- this.type = uni.getStorageSync("tabType")
- if (this.type === 2) {
- this.topToolsWidth = "20%"
- this.xxjbleft = 100
- } else if (this.type === 3) {
- this.topToolsWidth = "15%"
- this.xxjbleft = 85
- } else if (this.type === 4) {
- this.topToolsWidth = "20%"
- this.xxjbleft = 100
- } else {
- this.topToolsWidth = "20%"
- this.xxjbleft = 100
- }
- this.getCachaData()
- //获取主页数据
- this.getHomeConfigData(this.$getUrlType())
- this.getApiHomeConfigData()
- //获取任务提示
- //this.getNotRead()
- //获取公告
- this.getNoice()
- this.getOpenIdtoDb()
- },
- onShow() {
- uni.reLaunch({
- url: '/pages/tabbar/wpTabbar'
- })
- this.getCachaData()
- //获取主页数据
- this.getHomeConfigData(this.$getUrlType())
- this.getApiHomeConfigData()
- //获取任务提示
- //this.getNotRead()
- //获取公告
- this.getNoice()
- this.getOpenIdtoDb()
- },
- onNavigationBarButtonTap() {
- },
- onHide() {},
- methods: {
- getCachaData() {
- const userInfo = uni.getStorageSync('userInfo');
- const orgInfo = uni.getStorageSync('orgInfo');
- if (!(userInfo && orgInfo)) {
- uni.reLaunch({
- url: '/pageA/login/login'
- })
- }
- this.form.userName = userInfo.nickName
- this.form.userNo = userInfo.userName
- this.form.orgNo = orgInfo.organizationCode
- this.form.orgName = orgInfo.organizationName
- uni.setNavigationBarTitle({
- title: this.form.orgName
- })
- },
- async getHomeConfigData(type) {
- const {
- data: res
- } = await this.$httpRequest({
- url: '/app/getHomeConfigData?orgCode=' + this.form.orgNo,
- method: 'get',
- urlType: type
- })
- if (res.code == 200) {
- if (type === 2) {
- this.ptzxList = res.data
- } else if (type === 3) {
- this.xgzxList = res.data
- }
- } else {
- this.indexConfig = []
- }
- },
- async getApiHomeConfigData() {
- const {
- data: res
- } = await this.$httpRequest({
- url: '/api/getHomeConfigData?orgCode=' + "G00000003",
- method: 'get',
- urlType: 2,
- isNotToken: true
- })
- if (res && res.code == 200) {
- this.ptzxList = res.data
- } else {
- this.indexConfig = []
- }
- },
- msgs() {
- let data = uni.getStorageSync("msgData")
- if (!data) {
- this.msgNum = 0
- return
- }
- data = JSON.parse(data)
- this.msgNum = data.m1 + data.m2 + data.m3 + data.m4 + data.m5 + data.m6 + data.m7 + data.m8 + data.m9
- },
- toPayCodePage() {
- //跳转非pages.json>tabbar>配置过的页面,使用navigateTo
- //跳转时保留老页面,一般用于需要返回
- uni.navigateTo({
- url: "../user/payCode"
- })
- },
- toIntegralPage() {
- //跳转非pages.json>tabbar>配置过的页面,使用navigateTo
- //跳转时保留老页面,一般用于需要返回
- let userInfo = uni.getStorageSync("userInfo")
- if (userInfo.userType != '1' && userInfo.userType != '2') {
- this.$showModal('仅限内部人员使用')
- return
- }
- uni.navigateTo({
- url: "../../pageA/integral/index"
- })
- },
- toXiaoxiPage() {
- uni.navigateTo({
- url: "../../pageA/msg/userMsgList"
- })
- },
- onClick(e) {
- },
- async getOpenIdtoDb(type) {
- },
- async getNotRead() {
- const {
- data: res
- } = await this.$httpRequest({
- url: '/api/yq/notRead?userNo=' + this.form.userNo +
- "&orgNo=" + this.form.orgNo,
- method: 'get',
- urlType: this.$getUrlType()
- })
- if (res.code == 200) {
- var num = res.data
- if (0 < num) {
- uni.setTabBarBadge({
- index: 1,
- text: num + ""
- })
- }
- } else {
- }
- },
- async getNoice() {
- this.$httpRequest({
- url: '/app/notice?orgNo=' + this.form.orgNo + '&pageNum=1&pageSize=2',
- method: 'get',
- urlType: this.$getUrlType()
- }).then(res => {
- if (res.data.code == 200) {
- this.noticeList = res.data.rows
- this.noticeList.forEach(n => {
- n.createTime = n.createTime.slice(0, 10)
- })
- }
- })
- this.$httpRequest({
- url: '/app/notice?orgNo=' + this.form.orgNo,
- method: 'get',
- urlType: this.$getUrlType()
- }).then(res => {
- if (res.data.code == 200) {
- this.noticeList = res.data.rows
- this.noticeList.forEach(n => {
- n.createTime = n.createTime.slice(0, 10)
- })
- }
- })
- },
- takeMeal() {
- var that = this;
- uni.scanCode({
- scanType: ['qrCode'],
- success: function(res) {
- uni.showModal({
- content: JSON.stringify(res) + "1",
- })
- },
- fail: function(a) {},
- complete: function(b) {}
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .uni-tabbar__icon {
- width: 48px;
- height: 24px;
- }
- page {
- background-color: #c6c6c6;
- padding: 0;
- }
- .topToolsBody {
- box-shadow: 0 0 4px 0px #828282;
- padding: 0 10px;
- border-radius: 2ch;
- margin: 10rpx 10rpx 20rpx;
- background-color: #f9f9f9;
- image {
- width: 40px;
- height: 40px;
- }
- }
- .topTools {
- align-items: center; //垂直居中
- padding: 2.5%;
- font-size: 30rpx;
- color: #717171;
- }
- .warp {
- height: 100%;
- padding-bottom: constant(safe-area-inset-bottom);
- padding-bottom: env(safe-area-inset-bottom);
- }
- .modules {
- // margin: 15rpx;
- // padding: 10upx;
- }
- .count {
- bottom: 110rpx;
- }
- </style>
|