123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492 |
- <template>
- <view class="calender-page">
- <view class="calender-remind" @click="toMessagePage">
- <image
- :src="
- messageType
- ? '/static/mission/消息中心未读.png'
- : '/static/mission/消息中心已读.png'
- "
- mode=""
- ></image>
- </view>
- <view class="cheanged-time" @click="clickTile"
- >{{ changedYear }}年{{ changedMonth }}月
- <!-- <text class="weekDay">{{changedDay}}</text> -->
- </view>
- <view>
- <text v-for="item in dayArray1" class="calendarTitle">{{ item }}</text>
- </view>
- <view>
- <view v-for="item in data1">
- <!-- {{item}} -->
- <view
- v-for="(items, index) in item"
- class="calendarCon"
- @click="dateClick(items, index)"
- >
- <view class="date">
- {{
- items.time
- ? items.time.slice(9, 10) == "0"
- ? items.time.slice(10, 11)
- : items.time.slice(9, 11)
- : ""
- }}
- </view>
- <view class="yinDate">
- {{ items.yinTime ? items.yinTime : "" }}
- </view>
- <view :class="items.work ? 'work' : ''">
- <view class="sum">{{ items.work ? items.work : "" }}</view>
- <view class="danwei">{{ items.work ? "单位" : "" }}</view>
- </view>
- </view>
- </view>
- </view>
- <!-- <view v-for=""></view> -->
- <change-calendar
- v-if="showCC"
- :changedYear="changedYear"
- :changedMonth="changedMonth"
- @cancelCC="cancelCC"
- @sureCC="sureCC"
- ></change-calendar>
- <tm-tabbar />
- </view>
- </template>
- <script>
- import websocket from "../../utils/ws.js"; //引入websocket
- import moment from "moment";
- import changeCalendar from "./components/changeCalendar.vue";
- export default {
- data() {
- return {
- refTimer: null,
- isInitWs: null,
- messageType: null,
- dayArray: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
- dayArray1: ["日", "一", "二", "三", "四", "五", "六"],
- days_per_month: [],
- changedYear: moment().format("YYYY"),
- changedMonth: moment().format("MM"),
- changedDay: "",
- showCC: false,
- firstday: "",
- dayOfWeek: "",
- str_nums: "",
- data1: [],
- };
- },
- components: {
- changeCalendar,
- },
- created() {
- // this.getMissionList();
- // var data = '2021-02-19';
- this.changedDay = this.dayArray[new Date().getDay()];
- this.init(true);
- this.refTimer = setInterval(() => {
- this.isInitWs = websocket.ws ? false : true;
- this.init(this.isInitWs);
- }, 3 * 60 * 1000);
- },
- beforeDestroy() {
- // 关闭ws连接
- websocket.close();
- clearInterval(this.refTimer);
- },
- mounted() {
- this.days_per_month = new Array(
- 31,
- 28 + this.isLeap(this.changedYear),
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
- ); //创建月份数组
- this.getCanList2();
- },
- methods: {
- getCanList() {
- this.$store
- .dispatch({
- type: "calendar/commActions",
- payload: {
- key: "getDefault",
- data: {
- pageNum: 1,
- pageSize: 10,
- },
- },
- })
- .then((data) => {
- if (data) {
- let hiId = uni.getStorageSync("hiId");
- let user = uni.getStorageSync("id");
- let permission = uni.getStorageSync("nowPermission");
- this.isInitWs && this.initWebsocket(hiId, user, permission);
- }
- });
- },
- init(isInitWs) {
- this.isInitWs = isInitWs;
- this.getCanList();
- },
- initWebsocket(hiId, user, permission) {
- websocket.url = `ws://192.168.1.45:8088/imed/pfm/websocket/${hiId}/${user}/${permission}`;
- websocket.createWebSocket(this.resolverWsData.bind(this));
- },
- // 解析websocket返回数据
- resolverWsData(type) {
- let types = JSON.parse(type);
- console.log(types, "iiiiiii");
- switch (types.type) {
- case "TO_READ":
- alert("99999");
- this.messageType = true;
- break;
- default:
- this.messageType = false;
- break;
- }
- },
- toMessagePage() {
- uni.navigateTo({
- url: `/pages/messages/messages`,
- });
- },
- clickTile() {
- this.showCC = true;
- },
- cancelCC(data) {
- this.showCC = data;
- },
- sureCC(data, year, month) {
- this.showCC = data;
- this.changedYear = year;
- this.changedMonth = month;
- let day = year + "-" + month + "-01";
- this.changedDay = this.dayArray[new Date(day).getDay()];
- this.getCanList2();
- },
- isLeap(year) {
- return year % 4 == 0
- ? year % 100 != 0
- ? 1
- : year % 400 == 0
- ? 1
- : 0
- : 0;
- },
- getMonth(m) {
- console.log(m);
- if (m.substr(0, 1) == "0") {
- console.log(true);
- return m.substr(1, 2);
- } else {
- return m;
- }
- },
- //获取上个月的天数
- getPreMonthCount(year, month) {
- if (month === 0) {
- return getMonthCount(year - 1, 11);
- } else {
- return getMonthCount(year, month - 1);
- }
- },
- getCanList2() {
- this.$store
- .dispatch({
- type: "calendar/commActions",
- payload: {
- key: "getDefault",
- data: {
- pageNum: 1,
- pageSize: 10,
- },
- },
- })
- .then((data) => {
- let data1 = [
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: 5,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- {
- time: "2021-02-03",
- yinTime: "二十",
- work: null,
- },
- ];
- this.firstday = new Date(
- this.changedYear,
- this.changedMonth.slice(0, 1) == "0"
- ? this.changedMonth.slice(1, 2) - 1
- : this.changedMonth - 1,
- 1
- ); //获取每月第一天
- this.dayOfWeek = this.firstday.getDay(); //判断第一天是星期几(返回[0-6]中的一个,0代表星期天,1代表星期一,以此类推)
- this.str_nums = Math.ceil((this.dayOfWeek + data1.length) / 7); //确定日期表格所需的行数
- let data2 = [];
- for (let i = 0; i < this.str_nums; i++) {
- data2[i] = [];
- if (i == 0 && this.dayOfWeek != 0) {
- for (let j = 0; j < this.dayOfWeek; j++) {
- data2[i].push({});
- }
- let data3 = data1.splice(0, 7 - this.dayOfWeek);
- for (let k = 0; k < data3.length; k++) {
- data2[i].push(data3[k]);
- }
- } else if (i == 0 && this.dayOfWeek == 0) {
- data2[i] = data1.splice(0, 7);
- } else {
- if (i == this.str_nums - 1 && data1.length < 7) {
- data2[i] = data1.splice(0, 7);
- for (let k = 1; k < 7 - data1.length; k++) {
- data2[i].push({});
- }
- } else if (i == this.str_nums - 1 && data1.length == 7) {
- data2[i] = data1.splice(0, 7);
- } else {
- data2[i] = data1.splice(0, 7);
- }
- }
- }
- console.log(data2);
- this.data1 = data2;
- });
- },
- dateClick(data, i) {
- console.log(data, i);
- if (data && data.work) {
- // uni.navigateTo({
- // url: `/pages/mission-details/mission-details?taskId=${data.businessId}`,
- // });
- }
- },
- },
- };
- </script>
- <style lang="less">
- .calender-page {
- height: 100%;
- position: relative;
- .calender-remind {
- width: 62.5rpx;
- height: 62.5rpx;
- position: fixed;
- top: 12.5rpx;
- right: 25rpx;
- background: rgba(255, 255, 255, 0.95);
- border-radius: 50%;
- z-index: 2;
- image {
- margin-left: 17.5rpx;
- margin-top: 16.87rpx;
- width: 27.5rpx;
- height: 28.75rpx;
- }
- }
- .cheanged-time {
- padding: 25rpx 0rpx 15rpx 25rpx;
- font-size: 35rpx;
- .weekDay {
- padding-left: 15rpx;
- font-size: 20rpx;
- color: #666f80;
- }
- }
- .calendarTitle {
- background-color: #fff;
- display: inline-block;
- width: 14.286%;
- text-align: center;
- font-size: 20rpx;
- color: #666e80;
- line-height: 55rpx;
- }
- .calendarCon {
- margin-right: 1.25rpx;
- margin-top: 1.25rpx;
- height: 168.75rpx;
- background-color: #fff;
- float: left;
- width: 14.1%;
- text-align: center;
- font-size: 35rpx;
- color: #292c33;
- .date {
- padding-top: 25rpx;
- padding-bottom: 15rpx;
- }
- .yinDate {
- color: #666e80;
- font-size: 17.5rpx;
- line-height: 17.5rpx;
- }
- .work {
- width: 87.5rpx;
- height: 50rpx;
- background-color: #ff894d;
- border-radius: 5rpx;
- margin: 16.25rpx auto;
- .sum {
- font-size: 20rpx;
- color: #fff;
- font-weight: bold;
- line-height: 30rpx;
- }
- .danwei {
- font-weight: 400;
- font-size: 15rpx;
- color: #fff;
- line-height: 15rpx;
- }
- }
- }
- }
- </style>
|