Commit 3329d4d5 authored by lvtz's avatar lvtz

新版打卡 add new page

parent 1c5a56c6
......@@ -120,7 +120,8 @@
"name": "businessdeskcenter",
"pages": [
"index",
"clocklist"
"clocklist",
"themetemplate"
]
},
{
......@@ -384,7 +385,9 @@
"info",
"accountsecurity",
"setting",
"pcwebsiteintroduction"
"pcwebsiteintroduction",
"newinfo",
"qxknow"
]
},
{
......
var app = getApp();
import { pointsGoodsGet } from "../../../service/business/points.js";
Page({
data: {
localImageRoot: "../../../images/",
imageRoot: app.globalData.imageRoot,
imageVersion: app.globalData.imageVersion,
templateList: [],
total: 0,
hasmore: true,
page: 1,
perPage: 10,
emptyPage: false,
listLoading: false,
sid: 0
},
onLoad: function(options) {
const { sid } = options;
this.setData({
sid: sid || 0
});
this.getTemplateList("init");
},
onShow: function() {},
onReachBottom: function() {
this.getTemplateList("up");
},
getTemplateList(type) {
if (!this.data.hasmore) {
return;
}
if (this.data.listLoading) {
return;
}
this.setData({
listLoading: true
});
pointsGoodsGet({
page: this.data.page,
perPage: this.data.perPage,
school_id: 449
})
.then(res => {
const { code, data } = res;
this.setData({
listLoading: false
});
if (code != 200) {
// 失败的处理
} else {
if (data.total) {
this.setData({
total: data.total
});
}
switch (type) {
case "init": //页面进来第一次加载
this.setData({
templateList: [data.list]
});
console.log(this.data.templateList);
if (
this.data.total > this.caculateArrLength(this.data.templateList)
) {
this.data.page = this.data.page + 1;
} else {
// 没有更多了
this.setData({
hasmore: false
});
}
break;
case "down": // 页面下拉刷新
this.setData(
{
templateList: [data.list]
},
() => {
if (
this.data.total >
this.caculateArrLength(this.data.templateList)
) {
this.data.page = this.data.page + 1;
} else {
// 没有更多了
this.setData({
hasmore: false
});
}
}
);
wx.stopPullDownRefresh();
break;
case "up": // 页面上拉刷新
let list = this.data.templateList;
this.setData(
{
[`templateList[${this.data.page - 1}]`]: data.list
},
() => {
if (
this.data.total >
this.caculateArrLength(this.data.templateList)
) {
this.data.page = this.data.page + 1;
} else {
// 没有更多了
this.setData({
hasmore: false
});
}
}
);
break;
default:
break;
}
if (this.caculateArrLength(this.data.templateList) == 0) {
this.setData({
emptyPage: true
});
} else {
this.setData({
emptyPage: false
});
}
}
})
.catch(e => {
this.setData({
listLoading: false
});
});
},
caculateArrLength(array) {
let _length = 0;
array.forEach(ele => {
_length = _length + ele.length;
});
return _length;
},
bindTemplateSelected(e) {
const { id } = e.currentTarget.dataset;
console.log(id);
wx.showModal({
title: "提示一下",
content: `选择的id是${id},然后没有然后`,
showCancel: false,
confirmColor: "#64B8F5"
});
},
createCustom() {
wx.showModal({
title: "提示",
content: `不知道跳哪去`,
showCancel: false,
confirmColor: "#64B8F5"
});
}
});
{
"navigationBarTitleText": "选择作业打卡模板",
"enablePullDownRefresh": false,
"usingComponents": {
"expiredTip": "../../../components/expiredTip",
"empty-content": "../../../components/emptycontent"
}
}
\ No newline at end of file
<wxs src="../../../filter/index.wxs" module="filter" />
<view class="container">
<view class="list clearfix" wx:if="{{!emptyPage}}">
<block wx:for="{{templateList}}" wx:for-item="bigitem" wx:key="bigindex" wx:for-index="bigindex">
<view class="item" wx:for="{{bigitem}}" wx:for-item="item" data-id="{{item.id}}" wx:key="index" bindtap="bindTemplateSelected">
<image class="item-cover" src="{{filter.imagify(item.cover)}}" mode="aspectFill"></image>
<view class="item-title">{{item.title}}</view>
</view>
</block>
</view>
<empty-content text="咋肥事咧,一个模板也没有~" emptyimg="" wx:if="{{emptyPage}}"></empty-content>
<view class="submitbtn-box">
<view class="submitbtn" bindtap="createCustom">创建自定义打卡</view>
</view>
</view>
\ No newline at end of file
page {
background: #f8f8f8;
}
.container {
min-height: 100vh;
padding-bottom: 150rpx;
}
.list {
padding: 18rpx;
}
.list .item {
width: 50%;
float: left;
padding: 18rpx;
}
.list .item .item-cover {
width: 100%;
height: 320rpx;
}
.list .item .item-title {
font-size: 26rpx;
color: #222;
line-height: 36rpx;
padding-top: 12rpx;
width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.submitbtn-box {
width: 100%;
background: #f8f8f8;
display: flex;
align-items: center;
justify-content: center;
position: fixed;
left: 0;
bottom: 0;
padding-bottom: env(safe-area-inset-bottom);
}
.submitbtn {
padding: 26rpx;
font-size: 28rpx;
color: #64b8f5;
}
import {
getCategory,
setSchoolInfo,
} from "../../../service/business/shopeditor.js";
import {
schoolDetailGet
} from "../../../service/business/common.js";
import {
wxAuthorize,
wxChooseLocation,
wxOpenSetting
} from "../../../utilities/wxApi.js";
import {
LocalStorage
} from "../../../utilities/index.js";
import permissionUtils from "../../../utilities/permission.js";
var app = getApp();
Page({
data: {
imageRoot: app.globalData.imageRoot,
localImageRoot: "../../../images/",
imageVersion: app.globalData.imageVersion,
sid: 0,
industrys: ["单校区", "连锁", "品牌总部"],
industryIndex: -1,
allSubject: ["书法", "美术", "舞蹈", "乐器", "艺术", "英语"], // 所有科目
allSubjectShow: true, // 所有科目选择框是否显示
selectedSubject: [], // 选中的学科
selectedSubjectStyle: {}, // 控制选中的学科样式
params: {
title: "", // 店铺名称
longitude: "",
latitude: "",
location_address: "",
address: "",
tel: "",
logo: "qingxiao/daka/images/2c/common/logologo.png",
type: -1,
category: "",
qr_code: ""
},
mobileArr: [""],
submitting: false,
callBackSchoolId: 0,
from: 0, // 页面来源 1登录页面 2注册页面 3 校区管理的校区列表编辑按钮 4 校区详情页面的编辑按钮
},
onLoad: function(options) {
const visitor = LocalStorage.getItem("visitor");
const { sid, from, school_id } = options;
let dakarole = LocalStorage.getItem("dakarole");
this.setData({
sid: sid || 0,
school_id: school_id || 0,
dakarole: dakarole,
from: from || 0
});
this.getCategory();
if (this.data.sid == 0) {
return;
}
wx.showLoading({
title: "数据加载中..."
});
schoolDetailGet({
id: this.data.sid,
school_id: this.data.sid
})
.then(res => {
wx.hideLoading();
if (res.code == 200) {
const { data } = res;
if (data) {
// 是编辑状态
const {
address,
created_at,
latitude,
location_address,
longitude,
title,
tel_phone,
logo,
type,
category,
qr_code
} = data;
let selectedArr = [];
let selectedSubjectStyle = {};
for (let i = 0; i < category.length; i++) {
// selectedArr.push(clock_category_address[i].category_id)
selectedSubjectStyle[category[i]] = true;
}
this.setData({
mobileArr: tel_phone ? JSON.parse(tel_phone) : [""],
selectedSubjectStyle: selectedSubjectStyle,
selectedSubject: category,
"params.title": title,
"params.longitude": longitude,
"params.latitude": latitude,
"params.address": address || "",
"params.location_address": location_address,
"params.addressname": "",
"params.logo": logo || "qingxiao/daka/images/2c/pclogin/logo.png",
"params.type": Number(type) - 1
});
} else {
// 是新建状态
}
}
})
.catch(() => {
wx.hideLoading();
});
},
onReady: function() {
// Do something when page ready.
},
onShow: function() {
},
//选择学科
selectSubject(event) {
const subject = event.currentTarget.dataset.activeItem;
let selectedSubject = this.data.selectedSubject;
let selectedSubjectStyle = this.data.selectedSubjectStyle;
let flag = true;
for (let i = 0; i < selectedSubject.length; i++) {
if (subject.id == selectedSubject[i]) {
selectedSubject.splice(i, 1);
selectedSubjectStyle[subject.id] = false;
flag = false;
}
}
if (flag) {
selectedSubject.push(subject.id);
selectedSubjectStyle[subject.id] = true;
}
this.setData({
selectedSubject,
selectedSubjectStyle
});
},
//获取所有学科
getCategory() {
getCategory()
.then(res => {
if (res.code == 200) {
// 成功的操作
this.setData({
allSubject: res.data.list
});
}
})
.catch(e => {});
},
titleInput(e) {
const { value } = e.detail;
this.setData({
"params.title": value
});
},
addressSelect() {
wxAuthorize("scope.userLocation")
.then(() => {
return wxChooseLocation();
})
.then(value => {
console.log(value, "value");
if (value.errMsg == "chooseLocation:ok") {
if (value.address == undefined || value.address == "undefined") {
wx.showModal({
title: "提示",
content: "地理位置获取失败,请重新获取",
showCancel: false
});
return;
}
this.setData({
"params.longitude": value.longitude,
"params.latitude": value.latitude,
"params.location_address": `${value.address}${value.name}`,
"params.address": `${value.address}${value.name}`,
"params.addressname": value.name
});
} else {
}
})
.catch(e => {
if (e && e.errMsg.indexOf("authorize:fail") != -1) {
wx.showModal({
title: "提示",
content: "点击确认前往设置页面开启使用我的地理位置",
confirmColor: "#66B8F4",
success(res) {
if (res.confirm) {
wxOpenSetting();
}
}
});
return;
}
});
},
addressInput(e) {
const { value } = e.detail;
this.setData({
"params.addressname": value
});
},
industrySelect(e) {
const { value } = e.detail;
const that = this;
that.setData({
"params.type": value
});
},
save(e) {
wx.redirectTo({
url: "/business/pages/organizationalmgt/qxknow"
});
return;
let saveParams = this.objValueTrim(this.data.params);
saveParams.type = Number(saveParams.type) + 1;
saveParams.category = this.data.selectedSubject.join(",");
if (!saveParams.logo) {
wx.showModal({
title: "提示",
content: "请上传机构LOGO",
showCancel: false,
confirmColor: "#66B8F4"
});
return;
}
if (!saveParams.title) {
wx.showModal({
title: "提示",
content: "机构名称不能为空",
showCancel: false,
confirmColor: "#66B8F4"
});
return;
}
if (saveParams.title.length > 30) {
wx.showModal({
title: "提示",
content: "机构名称不能超过30个字",
showCancel: false,
confirmColor: "#66B8F4"
});
return;
}
if (!saveParams.category) {
wx.showModal({
title: "提示",
content: "请选择机构类型",
showCancel: false,
confirmColor: "#66B8F4"
});
return;
}
if (!saveParams.longitude) {
wx.showModal({
title: "提示",
content: "请选择机构地址",
showCancel: false,
confirmColor: "#66B8F4"
});
return;
}
if (this.data.submitting) {
return;
}
this.setData({
submitting: true
});
wx.showLoading({
title: "保存中...",
mask: true
});
saveParams.sort = 0;
saveParams.id = this.data.sid;
saveParams.school_id =
this.data.sid != 0 ? this.data.sid : this.data.school_id;
setSchoolInfo(saveParams)
.then(res => {
this.setData({
submitting: false
});
wx.hideLoading();
if (res.code == 200) {
// 成功的操作
if (this.data.sid == 0) {
// 新增的操作
LocalStorage.setItem("dakarole", 1);
permissionUtils.myMenulistGet(res.data.id);
wx.reLaunch({
url: `/business/pages/classmgt/index?sid=${res.data.id}&newcreate=1`
});
} else {
wx.showToast({
title: "保存成功",
success() {
wx.navigateBack({
delta: 1 // 回退前 delta(默认为1) 页面
});
}
});
}
}
})
.catch(e => {
this.setData({
submitting: false
});
});
},
objValueTrim(obj) {
let newObj = {};
Object.keys(obj).forEach(key => {
newObj[key] = `${obj[key]}`.trim();
});
return newObj;
}
});
{
"navigationBarTitleText": "添加学校信息",
"usingComponents": {
"expiredTip": "../../components/expiredTip",
"permission-box":"../../components/permissionbox"
}
}
\ No newline at end of file
<wxs src="../../../filter/index.wxs" module="filter" />
<view class="container">
<permission-box cinfigid="{{sid==0 || dakarole==1? 0: 700}}">
<view slot="menubtn">
<view class="box">
<view class="line-item">
<view class="item-label">学校名称</view>
<view class="right">
<input type="text" placeholder-class="placeholderclass" class="iteminput" maxlength="30" value="{{params.title}}" bindinput="titleInput" placeholder="请输入学校名称"></input>
<!-- <image class="arrowsmall" src="{{imageRoot}}2b/organizationalmgt/right.png?{{imageVersion}}"></image> -->
</view>
</view>
<view class="line-item">
<view class="item-label">联系电话</view>
<view class="right">
<input type="text" placeholder-class="placeholderclass" class="iteminput" maxlength="11" value="" bindinput="" placeholder="请输入学校联系电话"></input>
<!-- <image class="arrowsmall" src="{{imageRoot}}2b/organizationalmgt/right.png?{{imageVersion}}"></image> -->
</view>
</view>
<view class="line-item">
<view class="item-label">地址</view>
<view class="right" bindtap="addressSelect">
<view class="iteminput">{{params.location_address ? params.location_address : '请选择地址'}}</view>
<!-- <image class="arrowsmall" src="{{imageRoot}}2b/organizationalmgt/right.png?{{imageVersion}}"></image> -->
</view>
</view>
<view class="line-item">
<view class="item-label">详细地址</view>
<view class="right">
<textarea class="iteminput" placeholder-class="placeholderclass" bindinput="addressInput" autoHeight="true" value="{{params.addressname}}" placeholder="所在街道,楼牌号等"></textarea>
<!-- <image class="arrowsmall" src="{{imageRoot}}2b/organizationalmgt/right.png?{{imageVersion}}"></image> -->
</view>
</view>
<view class="line-item line-item-subject">
<view class="item-label">学校类型<text>(可多选)</text></view>
<view class="right content-box">
<view class="item-box" wx:for="{{allSubject}}" wx:for-index="idx" wx:for-item="item" wx:key="idx" data-active-item="{{item}}" bindtap="selectSubject" >
<view class="{{selectedSubjectStyle[item.id]?'item-box-inner selectd-item-box-inner':'item-box-inner'}}">{{item.name}}
<image class="icon-select" src="{{localImageRoot}}2b/organizationalmgt/icon_select_active.png?{{imageVersion}}" wx:if="{{selectedSubjectStyle[item.id]}}"></image>
<image class="icon-select" src="{{localImageRoot}}2b/organizationalmgt/icon_select.png?{{imageVersion}}" wx:else></image>
</view>
</view>
</view>
</view>
</view>
<view class="submitbtn" bindtap="save">保存</view>
</view>
</permission-box>
</view>
<expiredTip/>
\ No newline at end of file
page {
background: #f7f7f9;
height: 100%;
}
.container {
padding-bottom: 100rpx;
border-top: 1px solid #eee;
}
.placeholderclass {
color: #939393;
font-size: 26rpx;
}
.box {
background: #fff;
padding: 0 24rpx;
}
.line-item {
display: flex;
align-items: center;
background: #fff;
position: relative;
padding: 35rpx 0;
}
.box .line-item::after {
content: "";
width: 726rpx;
height: 1px;
background: rgba(0, 0, 0, 0.05);
position: absolute;
bottom: 0;
left: 0;
}
.box .line-item:last-of-type::after {
display: none;
}
.line-item .item-label {
font-size: 26rpx;
color: #222;
min-width: 180rpx;
word-break: break-all;
}
.line-item .item-label text {
font-size: 24rpx;
color: #ccc;
padding-left: 10rpx;
}
.line-item .right {
display: flex;
align-items: center;
flex: 1;
}
.line-item .right .iteminput {
width: 100%;
color: #939393;
font-size: 26rpx;
word-break: break-all
}
.line-item .right .arrowsmall {
width: 12rpx;
height: 20rpx;
margin-left: 20rpx;
}
.line-item-subject {
flex-direction: column;
align-items: flex-start;
padding: 46rpx 0 10rpx;
}
.content-box {
padding-top: 32rpx;
display: flex;
flex-wrap: wrap;
}
.content-box .item-box {
width: 25%;
text-align: center;
height: 66rpx;
line-height: 66rpx;
padding-right: 4%;
margin-bottom: 32rpx;
}
.content-box .item-box:nth-child(4n) {
padding-right: 0;
}
.content-box .item-box .item-box-inner {
background: #fff;
border: 1px solid #dadbdc;
border-radius: 4rpx;
width: 100%;
position: relative;
}
.selectd-item-box-inner {
border: 1px solid #19b5ff !important;
color: #19b5ff !important;
}
.item-box-inner .icon-select {
position: absolute;
left: -2rpx;
bottom: -2rpx;
width: 26rpx;
height: 26rpx;
}
.submitbtn {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
height: 100rpx;
background: #66b8f4;
font-size: 36rpx;
color: #fff;
position: fixed;
bottom: 0;
left: 0;
}
Page({
data: {
imgList: [
"https://cdn.img.shangjiadao.cn/qingxiao/bargain/images/case/gif1.gif",
"https://cdn.img.shangjiadao.cn/qingxiao/bargain/images/case/code.png",
"https://cdn.img.shangjiadao.cn/qingxiao/bargain/images/case/idea.png",
"https://cdn.img.shangjiadao.cn/qingxiao/bargain/images/case/gif2.gif",
"https://cdn.img.shangjiadao.cn/qingxiao/bargain/images/case/gif3.gif",
"https://cdn.img.shangjiadao.cn/qingxiao/bargain/images/case/pic_03.png"
]
},
onLoad: function(options) {},
onShow: function() {},
toCreate() {
wx.navigateTo({
url: `/business/pages/deskcenter/themetemplate`
});
}
});
{
"navigationBarTitleText": "了解轻校",
"usingComponents": {}
}
\ No newline at end of file
<view class="container">
<view class="desc-box">
<image class="desc-img" wx:for="{{imgList}}" wx:key="index" src="{{item}}" mode="widthFix"></image>
</view>
<view class="submitbtn-box">
<view class="submitbtn" bindtap="toCreate">创建作业打卡</view>
</view>
</view>
page {
background: #f1f2f3;
}
.container {
padding-bottom: 200rpx;
}
.desc-box {
}
.desc-box .desc-img {
width: 100%;
display: block;
}
.submitbtn-box {
width: 100%;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
padding: 32rpx;
position: fixed;
left: 0;
bottom: 0;
}
.submitbtn {
width: 100%;
height: 98rpx;
background: #66b8f4;
font-size: 36rpx;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4rpx;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment