关于程序员:一个开源的课程表小程序项目增加情侣课表

43次阅读

共计 5164 个字符,预计需要花费 13 分钟才能阅读完成。

引语:

高校教务零碎没有在手机端做适配的能够通过小程序来疾速查看课表信息,决定本人尝试做了个课程表小程序并开源,目前曾经反对增加删除课程表性能、周课表、日课表,以及自定义背景性能

因为近期在谈恋爱,想和女朋友一起上课,想着观看 Ta 的课表更不便一些,于是退出了情侣课表性能

情侣课表演示:

开源地址:
gitee 开源: (https://gitee.com/chengdu-gen…)

新增页面

判断绑定情侣、相干性能实现.wxml

<view wx:if="{{couplesId}}">
    <view class="headBox" style="height:{{CustomBar + 160}}px">
        <view style="height:{{CustomBar}}px;">
            <view class="cu-bar text-white ev-fr-start" bindtap="BackPage" style="height:{{CustomBar}}px;padding-top:{{StatusBar}}px;">
                <text class="cuIcon-back padding-lr-sm"></text>
                <view class="action text-white"> 情侣课表 </view>
            </view>
        </view>
        <view class="ev-fc-center padding">
            <view>
                <view class="cu-avatar xl round solids" style="background-image:url({{userInfo.avatar}})" />
                <text class="padding-lr-xs"></text>
                <view class="cu-avatar xl round solids" style="background-image:url({{loverInfo.avatar}})" />
            </view>
            <!-- <view class="ev-fr-center contactInfo text-white padding-top">
                <text> 和 {{loverInfo.nickname}} 结为情侣的第 </text>
                <text>{{123}}天 </text>
            </view> -->
            <view class="contactBind" bind:tap="removeBind"> 解除绑定关系 </view>
        </view>
        <image class="backgroundTexture" mode="heightFix" style="height:{{CustomBar + 160}}px" src="/images/couplesBG.png" />
    </view>
    <!-- 设置 -->
    <view class="settingBox bg-white" style="height:{{displayArea.windowHeight  - (displayArea.windowWidth / 3.75) - 30}}px;">
        <view class="padding-top">
            <view class="settitle padding-lr"> 历史留言 </view>
            <view class="messageHistory" style="height: {{displayArea.windowHeight - 200}}px;">
                <view wx:if="{{messageList.length == 0}}" class="coursenull">
                    <image style="width:100%;height:100%" mode="scaleToFill" src="/images/coursenull.png" />
                    <text> 暂无留言哦~</text>
                </view>
                <block wx:else>
                    <view wx:for="{{messageList}}" class="margin-top-xl" wx:key="index">
                        <view class="tips">{{item.time}}</view>
                        <view class="content">{{item.contents}}</view>
                    </view>
                </block>
            </view>
        </view>
    </view>
</view>
<view wx:else>
    <view style="height:{{CustomBar}}px;">
        <view class="cu-bar ev-fr-start" bindtap="BackPage" style="height:{{CustomBar}}px;padding-top:{{StatusBar}}px;">
            <text class="cuIcon-back padding-lr-sm"></text>
            <view class="action"> 情侣列表 </view>
        </view>
    </view>
    <view class="ev-mainBody">
        <view>
            <image class="message" mode="scaleToFill" src="/images/couplesSchedule.png" />
        </view>
        <view>
            <text class="title"> 绑定情侣课表 </text>
            <view class="padding-top-sm tips">
                绑定胜利后将可查看对方的本学期课程表,并首页显示对方今日
课程,为对方留言以及自定义课程表背景等性能…
            </view>
            <view class="padding-top-sm">
                <button open-type='share' class="ev-fc-center cardBox shareInvi padding-lr">
                    <image class="shareWechat" mode="scaleToFill" src="/images/wechat.png" />
                    <text class="padding-top-sm tips" style="font-size: 14px;"> 通过微信分享邀请 </text>
                </button>
            </view>
        </view>
    </view>
</view>
<view class="cu-modal {{removeBind ?'show':''}}">
    <view class="cu-dialog couplesInvite">
        <view class="ev-fc" style="margin-top:40px">
            <view class="removeIcon ev-fr-center">
                <image class="ev-icon" mode="scaleToFill" src="/images/removeBind.png" />
            </view>
            <view class="title padding"> 解除情侣绑定 </view>
            <view class="tips padding-bottom-xl"> 解除绑定后,课表将复原为集体课表是否确定?</view>
            <view class="padding-bottom padding-xl">
                <button class="cu-btn removeButton" data-type="{{true}}" bind:tap="removeBindConfirm">
                    确定
                </button>
                <button class="cu-btn bg-blue org margin-lr-sm" bind:tap="removeBindConfirm">
                    勾销
                </button>
            </view>
        </view>
    </view>
</view>

js 代码:

const app = getApp();
import {couplesInfo, couplesDel, couplesMsgList} from "../../utils/api/user";
import {serializePathQuery} from "../../utils/api/http";
import dayjs from "../../utils/dayjs/dayjs.min";
import {wxShowToast} from "../../utils/promisify";

Page({
    data: {
        StatusBar: app.globalData.StatusBar,
        CustomBar: app.globalData.CustomBar,
        displayArea: app.globalData.displayArea,
        ImgUrl: app.globalData.ImgUrl,
        couplesId: "",
        removeBind: false,
        userInfo: app.globalData.userInfo,
        messageList: null,
    },
    onLoad: function (query) {console.log(query, this.data.displayArea, "query");
        let couplesId =
            query.couplesId && query.couplesId !== "null"
                ? query.couplesId
                : null;
        if (couplesId) {
            this.setData({
                userInfo: app.globalData.userInfo,
                couplesId,
            });
            couplesMsgList({
                is_show: 1,
                tid: couplesId,
            }).then((v) => {console.log(v.data);
                let messageList = v.data.data.length > 0 ? v.data.data : [];
                messageList = messageList.filter((v) => v.love_sort_text !== "Love_sort 1"
                );
                messageList = messageList.map((v) => {
                    v.time = dayjs
                        .unix(v.starttime)
                        .format("YYYY 年 MM 月 DD 日 HH:mm");
                    return v;
                });
                this.setData({messageList,});
            });
            couplesInfo().then((v) => {
                this.setData({loverInfo: v.data,});
            });
        }
    },
    /**
     * 后退一页
     */
    BackPage() {
        wx.navigateBack({delta: 1,});
    },
    /**
     * 勾销绑定弹窗
     */
    removeBind() {
        this.setData({removeBind: true,});
    },
    /**
     * 勾销绑定确认按钮
     */
    removeBindConfirm(e) {
        let type = e.currentTarget.dataset.type;
        if (type) {couplesDel().then((v) => {v.code && wxShowToast("解绑胜利");
                app.getSet();});
        }
        this.setData({removeBind: false,});
        app.getSet().then(() => {this.BackPage();
        });
    },
    /**
     * 分享邀请
     */
    onShareAppMessage: function (options) {console.log(options);
        let nickname = app.globalData.userInfo.nickname;
        let avatar = app.globalData.userInfo.avatar;
        let id = app.globalData.userInfo.user_id;
        if (options.from == "button") {
            let shareObj = {title: `${nickname}申请和你绑定成情侣 `,
                path:
                    "/pages/index/index?" +
                    serializePathQuery({
                        couplesAdd: id,
                        nickname,
                        avatar,
                    }),
                imageUrl: "/images/share.png", // 自定义图片门路,能够是本地文件门路、代码包文件门路或者网络图片门路,反对 PNG 及 JPG,success: (res) => {
                    // 转发胜利之后的回调
                    if (res.errMsg == "shareAppMessage:ok") {return;}
                },
                fail: () => {
                    // 转发失败之后的回调
                    if (res.errMsg == "shareAppMessage:fail cancel") {return;} else if (res.errMsg == "shareAppMessage:fail") {return;}
                },
            };
            return shareObj;
        }
    },
});

正文完
 0