Commit 8cd16d4b24ca7fda798a8259400bcb08092ca5c4

Authored by
1 parent d46806b9
Exists in master

feat:打卡模板创建

打卡模板创建
app.json
1 1 {
2 2 "pages": [
  3 + "pages/login/codeLogin/codeLogin",
3 4 "pages/index/rank/rank",
4 5 "pages/index/index",
5   - "pages/login/codeLogin/codeLogin",
6 6 "pages/index/achievement/achievement",
7 7 "pages/index/newPunch/newPunch",
8 8 "pages/mine/record/record",
... ...
package-lock.json
... ... @@ -8,6 +8,11 @@
8 8 "version": "1.10.5",
9 9 "resolved": "https://registry.npmmirror.com/@vant/weapp/-/weapp-1.10.5.tgz",
10 10 "integrity": "sha512-bAHp9r0ZiRsOqPOLzQHI/ZvkAlXzol1/TFhM70MyghuxkzJTjcDUd8RIfLkCN3c1MCK/PfBGw2an8/afygftCg=="
  11 + },
  12 + "moment": {
  13 + "version": "2.29.4",
  14 + "resolved": "https://registry.npmmirror.com/moment/-/moment-2.29.4.tgz",
  15 + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
11 16 }
12 17 }
13 18 }
... ...
package.json
... ... @@ -4,7 +4,8 @@
4 4 "description": "计划管家",
5 5 "main": "app.js",
6 6 "dependencies": {
7   - "@vant/weapp": "^1.10.5"
  7 + "@vant/weapp": "^1.10.5",
  8 + "moment": "^2.29.4"
8 9 },
9 10 "scripts": {
10 11 "test": "echo \"Error: no test specified\" && exit 1"
... ...
pages/index/index.js
... ... @@ -5,6 +5,7 @@ import request from '../../api/request.js'
5 5 Page({
6 6 data: {
7 7 active: 1,
  8 + taskList: []
8 9 // bannerList: [], // 轮播图
9 10 },
10 11 checkTabs(e) {
... ... @@ -13,11 +14,37 @@ Page({
13 14 active: index
14 15 }) //修改参数
15 16 },
  17 +
  18 + //打卡记录列表
  19 + getTaskList() {
  20 + request({
  21 + url: `/wx/task/cardTaskList`,
  22 + method: 'post',
  23 + data: {
  24 + "oneselfFlag": 1,
  25 + "page": 1,
  26 + "pageSize": 999,
  27 + "userId": wx.getStorageSync("userInfo_id")
  28 + },
  29 + }).then(res => {
  30 + if (res.code == 0) {
  31 + this.setData({
  32 + taskList: res.rows
  33 + })
  34 + } else {
  35 + wx.showToast({
  36 + title: res.msg,
  37 + icon: 'none',
  38 + duration: 1500
  39 + })
  40 + }
  41 + })
  42 + },
16 43  
17 44 //查看排行榜
18 45 toRank() {
19   - wx.navigateTo({
20   - url: `../index/rank/rank`
  46 + wx.switchTab({
  47 + url: './rank/rank',
21 48 })
22 49 },
23 50  
... ... @@ -40,6 +67,7 @@ Page({
40 67 // this.getBannerList() //获取banner
41 68 },
42 69 onShow: function (options) {
  70 + this.getTaskList()
43 71 this.setData({
44 72 showAdd: false
45 73 })
... ...
pages/index/index.wxml
... ... @@ -13,34 +13,34 @@
13 13 <view class="tabs_div"></view>
14 14 </view>
15 15 <view class="white_box">
16   - <view class="card">
  16 + <view class="card" wx:for="{{taskList}}" wx:key="index" wx:for-item="value">
17 17 <view class="card_title">
18 18 <view class="title_L">
19 19 <image class="title_pic" src="/img/answer/bj.png" alt="" />
20 20 </view>
21 21 <view class="title_R">
22   - <view>英语单词每日打卡</view>
23   - <view class="grey_font">我发布于09-09 08:21</view>
  22 + <view>{{value.taskTitle}}</view>
  23 + <view class="grey_font">开始时间 {{value.startDate}}</view>
24 24 </view>
25 25 </view>
26   - <view class="day_font">每日20个英文单词背诵</view>
27   - <view class="day_font2">已坚持打卡
  26 + <view class="day_font">{{value.taskDesc}}</view>
  27 + <!-- <view class="day_font2">已坚持打卡
28 28 <text class="day_font2_large">1/50 </text>天
29   - </view>
  29 + </view> -->
30 30 <view>
31 31 <van-progress percentage="50" color='#3F5EFF' stroke-width="13" pivot-text=' ' />
32 32 </view>
33 33 <view class="flex_font">
34 34 <text class="grey_flex">打卡频次:</text>
35   - 每天
  35 + {{value.taskFrequency}}
36 36 </view>
37   - <view class="flex_font">
  37 + <view class="flex_font" wx:if="{{value.submitCondition != null}}">
38 38 <text class="grey_flex">打卡要求:</text>
39   - 需填写单词个数
  39 + {{'需要' + value.submitCondition}}
40 40 </view>
41 41 <view class="flex_font">
42 42 <view class="grey_flex">其他:</view>
43   - 不允许补卡
  43 + {{value.allowRepairCard == 1 ? '允许补卡': '不允许补卡'}}
44 44 </view>
45 45 <view class="grey_line"></view>
46 46 <view class="blue_font">
... ...
pages/index/index.wxss
... ... @@ -63,10 +63,10 @@
63 63  
64 64 .card {
65 65 width: 90vw;
66   - height: 400px;
67 66 background-color: #fff;
68 67 border-radius: 8vw;
69 68 padding: 8vw 7vw;
  69 + margin-bottom: 30px;
70 70 box-sizing: border-box;
71 71 box-shadow: 1px 1px 1px 1px rgb(196, 196, 196);
72 72 }
... ...
pages/index/newPunch/newPunch.js
1 1 // pages/index/rank/rank.js
  2 +import request from '../../../api/request.js'
  3 +import moment from 'moment';
2 4 Page({
3 5  
4 6 /**
5 7 * 页面的初始数据
6 8 */
7 9 data: {
  10 + tempId: 0,
8 11 form: {
9   - biaoti: '',
10   - message: '',
11   - checked: true
  12 + taskTitle: '', //任务标题
  13 + taskDesc: '', //任务描述内容
  14 + allowRepairCard: false, //是否允许补卡 1是 2否
  15 + hasData: false, //是否需要提交数据 1是 2否
  16 + // id: '', // 任务ID
  17 + lackNum: '', // 缺卡次数
  18 + remindTime: '', // 打卡提醒时间点
  19 + startDate: '', // 打卡开始时间
  20 + statisticsUnit: '', // 统计单位 hasData=1 时,必传
  21 + submitCondition: '', //提交包含条件:图片、视频、音频
  22 + taskCycle: '', //打卡周期
  23 + taskFileUrl: [], //任务文件(含多个)
  24 + taskFrequency: '', //打卡频次
  25 + userId: '', //所属用户ID
12 26 },
  27 + fileList: [],
13 28 //弹出层
14 29 //统计单位
15 30 unitShow: false,
16   - columnsUnit: ['杭州', '宁波', '温州', '嘉兴', '湖州'],
  31 + columnsUnit: ['小时', '天', '月'],
17 32 //开始时间
18 33 startTimeShow: false,
19 34 columnsStartTime: ['9', '10', '11', '12'],
  35 + minDate: new Date().getTime(),
  36 + currentDate: new Date().getTime(),
  37 + formatter(type, value) {
  38 + if (type === 'year') {
  39 + return `${value}年`;
  40 + }
  41 + if (type === 'month') {
  42 + return `${value}月`;
  43 + }
  44 + return value;
  45 + },
20 46 //打卡周期
21 47 clockCycleShow: false,
22   - columnsClockCycle: ['30天', '60天', '90天', '120天'],
  48 + columnsClockCycle: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
23 49 //打卡频次
24 50 clockRateShow: false,
25 51 columnsClockRate: ['每天', '7天', '一个月'],
26 52 //打卡提醒
27 53 clockRemindShow: false,
28   - columnsClockRemind: ['18:00', '19:00'],
  54 + columnsClockRemind: [
  55 + {
  56 + values: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
  57 + defaultIndex: 2,
  58 + },
  59 + // 第二列
  60 + {
  61 + values: ['8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00'],
  62 + defaultIndex: 1,
  63 + },
  64 + ],
29 65 //打卡缺卡提醒
30 66 clockLackShow: false,
31   - columnsClockLack: ['缺卡三天以上', '缺卡十天以上', '缺卡三十天以上'],
  67 + columnsClockLack: [1,2,3],
32 68 //必须包含
33 69 containShow: false,
34   - columnsContain: ['图片', '视频', '音频'],
  70 + columnsContain: ['图片'],
  71 + },
  72 + //获取模板详情 / 空模板
  73 + getDetail() {
  74 + request({
  75 + url: `/wx/temp/getTempDetail`,
  76 + method: 'get',
  77 + data: {
  78 + "tempId": this.data.tempId,
  79 + },
  80 + }).then(res => {
  81 + if (res.code == 0) {
  82 + const data = res.data
  83 + this.setData({
  84 + 'form.taskTitle': data.taskTitle
  85 + })
  86 + this.setData({
  87 + 'form.taskDesc': data.taskDesc
  88 + })
  89 + this.setData({
  90 + 'form.allowRepairCard': data.allowRepairCard
  91 + })
  92 + this.setData({
  93 + 'form.hasData': data.hasData
  94 + })
  95 + this.setData({
  96 + 'form.lackNum': data.lackNum
  97 + })
  98 + this.setData({
  99 + 'form.remindTime': data.remindTime
  100 + })
  101 + this.setData({
  102 + 'form.startDate': data.startDate
  103 + })
  104 + this.setData({
  105 + 'form.statisticsUnit': data.statisticsUnit
  106 + })
  107 + this.setData({
  108 + 'form.submitCondition': data.submitCondition
  109 + })
  110 + this.setData({
  111 + 'form.taskCycle': data.taskCycle
  112 + })
  113 + this.setData({
  114 + 'form.taskFileUrl': []
  115 + })
  116 + this.setData({
  117 + 'form.taskFrequency': data.taskFrequency
  118 + })
  119 + } else {
  120 + wx.showToast({
  121 + title: res.msg,
  122 + icon: 'none',
  123 + duration: 1000
  124 + })
  125 + }
  126 + })
35 127 },
36 128 //输入
37   - onfieldChange() {
38   -
  129 + onfieldChange(e) {
  130 + this.setData({
  131 + 'form.taskTitle': e.detail
  132 + })
  133 + },
  134 + //输入
  135 + onfieldDescChange(e) {
  136 + this.setData({
  137 + 'form.taskDesc': e.detail
  138 + })
  139 + },
  140 + //开关
  141 + onSwitch(e) {
  142 + console.log(e)
  143 + this.setData({
  144 + 'form.hasData': e.detail
  145 + })
  146 + },
  147 + onChange(e) {
  148 + console.log(e)
  149 + this.setData({
  150 + 'form.allowRepairCard': e.detail
  151 + })
  152 + },
  153 + //文件上传
  154 + afterRead(event) {
  155 + const {
  156 + file
  157 + } = event.detail;
  158 + var that = this
  159 + // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  160 + wx.uploadFile({
  161 + url: 'https://market.myjxt.com:51311/file/fileUpload', // 仅为示例,非真实的接口地址
  162 + filePath: file.url,
  163 + name: 'file',
  164 + formData: {
  165 + user: 'test'
  166 + },
  167 + success(res) {
  168 + // 上传完成需要更新 fileList
  169 + const {
  170 + fileList = []
  171 + } = that.data;
  172 + fileList.push({
  173 + ...file,
  174 + url: res.data
  175 + });
  176 + console.log(res,fileList)
  177 + that.setData({
  178 + fileList
  179 + });
  180 + that.setData({
  181 + 'form.taskFileUrl': fileList.map(v => v.url)
  182 + })
  183 + },
  184 + });
39 185 },
40 186 //开关
41 187 onswitchChange({
... ... @@ -45,11 +191,39 @@ Page({
45 191 'form.checked': detail
46 192 });
47 193 },
  194 + //创建
  195 + createTask() {
  196 + console.log(this.data.form)
  197 + request({
  198 + url: `/wx/task/addCardTask`,
  199 + method: 'post',
  200 + data: this.data.form,
  201 + }).then(res => {
  202 + if (res.code == 0) {
  203 + wx.navigateTo({
  204 +    url: '../../mine/record/record'
  205 + })
  206 + }else {
  207 + wx.showToast({
  208 + title: res.msg,
  209 + icon: 'none',
  210 + duration: 1000
  211 + })
  212 + }
  213 + })
  214 + },
48 215 /**
49 216 * 生命周期函数--监听页面加载
50 217 */
51 218 onLoad(options) {
52   -
  219 + this.setData({
  220 + 'form.userId': wx.getStorageSync('userInfo_id')
  221 + })
  222 + this.setData({
  223 + tempId: options.tempId
  224 + }, () => {
  225 + this.getDetail()
  226 + })
53 227 },
54 228 // 创建完成
55 229 handleCreate() {
... ... @@ -81,7 +255,11 @@ Page({
81 255 unitShow: false
82 256 })
83 257 },
84   - changeUnitShow() {
  258 + changeUnitShow(e) {
  259 + console.log(e)
  260 + this.setData({
  261 + 'form.statisticsUnit': e.detail.value
  262 + })
85 263 this.setData({
86 264 unitShow: false
87 265 })
... ... @@ -99,7 +277,11 @@ Page({
99 277 startTimeShow: false
100 278 })
101 279 },
102   - changeStartTimeShow() {
  280 + changeStartTimeShow(e) {
  281 + let time = moment(e.detail).format('YYYY-MM-DD')
  282 + this.setData({
  283 + 'form.startDate': time,
  284 + });
103 285 this.setData({
104 286 startTimeShow: false
105 287 })
... ... @@ -117,7 +299,10 @@ Page({
117 299 clockCycleShow: false
118 300 })
119 301 },
120   - changeClockCycleShow() {
  302 + changeClockCycleShow(e) {
  303 + this.setData({
  304 + 'form.taskCycle': e.detail.value
  305 + })
121 306 this.setData({
122 307 clockCycleShow: false
123 308 })
... ... @@ -135,7 +320,10 @@ Page({
135 320 clockRateShow: false
136 321 })
137 322 },
138   - changeClockRateShow() {
  323 + changeClockRateShow(e) {
  324 + this.setData({
  325 + 'form.taskFrequency': e.detail.value
  326 + })
139 327 this.setData({
140 328 clockRateShow: false
141 329 })
... ... @@ -153,7 +341,10 @@ Page({
153 341 clockRemindShow: false
154 342 })
155 343 },
156   - changeClockRemindShow() {
  344 + changeClockRemindShow(e) {
  345 + this.setData({
  346 + 'form.remindTime': e.detail.value[0] + '::' + e.detail.value[1]
  347 + })
157 348 this.setData({
158 349 clockRemindShow: false
159 350 })
... ... @@ -171,7 +362,10 @@ Page({
171 362 clockLackShow: false
172 363 })
173 364 },
174   - changeClockLackShow() {
  365 + changeClockLackShow(e) {
  366 + this.setData({
  367 + 'form.lackNum': e.detail.value
  368 + })
175 369 this.setData({
176 370 clockLackShow: false
177 371 })
... ... @@ -189,7 +383,10 @@ Page({
189 383 containShow: false
190 384 })
191 385 },
192   - changeContainShow() {
  386 + changeContainShow(e) {
  387 + this.setData({
  388 + 'form.submitCondition': e.detail.value
  389 + })
193 390 this.setData({
194 391 containShow: false
195 392 })
... ...
pages/index/newPunch/newPunch.json
... ... @@ -7,7 +7,9 @@
7 7 "van-switch": "@vant/weapp/switch/index",
8 8 "van-button": "@vant/weapp/button/index",
9 9 "van-popup": "@vant/weapp/popup/index",
10   - "van-picker": "@vant/weapp/picker/index"
  10 + "van-picker": "@vant/weapp/picker/index",
  11 + "van-uploader": "@vant/weapp/uploader/index",
  12 + "van-datetime-picker": "@vant/weapp/datetime-picker/index"
11 13 },
12   - "navigationBarTitleText": "自定义打卡"
  14 + "navigationBarTitleText": "打卡模板"
13 15 }
14 16 \ No newline at end of file
... ...
pages/index/newPunch/newPunch.wxml
1 1 <!--pages/index/rank/rank.wxml-->
2 2 <view class="punch_detail">
3   - <view class="title_card">
4   - <van-cell-group>
5   - <van-field value="{{ form.biaoti }}" placeholder="请输入标题" border="{{ false }}" bind:change="onfieldChange" />
6   - </van-cell-group>
  3 + <view class="title_card">
  4 + <van-cell-group>
  5 + <van-field value="{{ form.taskTitle }}" placeholder="请输入标题" border="{{ false }}" bind:change="onfieldChange" />
  6 + </van-cell-group>
  7 + <view class="grey_line"></view>
  8 + <view class="box_card">
  9 + <van-cell-group>
  10 + <van-field value="{{ form.taskDesc }}" type="textarea" placeholder="请输入" autosize border="{{ false }}" bind:change="onfieldDescChange" />
  11 + </van-cell-group>
  12 + </view>
  13 + <view class="tip_card">
  14 + <van-uploader accept='image' file-list="{{ fileList }}" deletable="{{ true }}" bind:after-read="afterRead">
  15 + <view class="tip_item">
  16 + <image class="pic" src="/img/answer/tp1.png" alt="" />
  17 + </view>
  18 + </van-uploader>
  19 + <!-- <view class="tip_item">
  20 + <image class="pic" src="/img/answer/sp1.png" alt="" />
  21 + </view>
  22 + <view class="tip_item">
  23 + <image class="pic" src="/img/answer/yp1.png" alt="" />
  24 + </view> -->
  25 + </view>
  26 + </view>
  27 + <view class="white_card">
  28 + <view class="bold_font">需要提交数据</view>
  29 + <view>
  30 + <van-switch checked="{{ form.hasData }}" size='20' active-value='1' inactive-value='2' bind:change="onSwitch" />
  31 + </view>
  32 + </view>
7 33 <view class="grey_line"></view>
8   - <view class="box_card">
9   - <van-cell-group>
10   - <van-field value="{{ form.message }}" type="textarea" placeholder="请输入" autosize border="{{ false }}" />
11   - </van-cell-group>
  34 + <view class="white_card_nopadding">
  35 + <van-cell-group>
  36 + <van-cell title="统计单位" value="{{ form.statisticsUnit }}" is-link label="请选择统计单位" border="{{ false }}" bindtap="openUnitShow" />
  37 + </van-cell-group>
  38 + </view>
  39 + <view class="white_card">
  40 + <view>允许补卡</view>
  41 + <view>
  42 + <van-switch checked="{{ form.allowRepairCard }}" size='20' bind:change="onChange" active-value='1' inactive-value='2' />
  43 + </view>
12 44 </view>
13   - <view class="tip_card">
14   - <view class="tip_item">
15   - <image class="pic" src="/img/answer/tp1.png" alt="" />
16   - </view>
17   - <view class="tip_item">
18   - <image class="pic" src="/img/answer/sp1.png" alt="" />
19   - </view>
20   - <view class="tip_item">
21   - <image class="pic" src="/img/answer/yp1.png" alt="" />
22   - </view>
  45 + <view class="sm_grey_font">
  46 + 开启后,在打卡周期内,学生家长可对未打卡的任务进行补卡。
23 47 </view>
24   - </view>
25   - <view class="white_card">
26   - <view class="bold_font">需要提交数据</view>
27   - <view>
28   - <van-switch checked="{{ form.checked }}" size='20' bind:change="onChange" />
  48 + <view class="white_card_nopadding">
  49 + <van-cell-group>
  50 + <van-cell title="开始时间" value="{{ form.startDate }}" is-link border="{{ false }}" bindtap="openStartTimeShow" />
  51 + </van-cell-group>
29 52 </view>
30   - </view>
31   - <view class="grey_line"></view>
32   - <view class="white_card_nopadding">
33   - <van-cell-group>
34   - <van-cell title="统计单位" is-link label="请选择统计单位" border="{{ false }}" bindtap="openUnitShow"/>
35   - </van-cell-group>
36   - </view>
37   - <view class="white_card">
38   - <view>允许补卡</view>
39   - <view>
40   - <van-switch checked="{{ form.checked }}" size='20' bind:change="onChange" />
  53 + <view class="white_card_nopadding">
  54 + <van-cell-group>
  55 + <van-cell title="打卡周期" value="{{ form.taskCycle + ' 天'}}" is-link border="{{ false }}" bindtap="openClockCycleShow" />
  56 + </van-cell-group>
  57 + </view>
  58 + <view class="white_card_nopadding">
  59 + <van-cell-group>
  60 + <van-cell title="打卡频次" value="{{ form.taskFrequency }}" is-link border="{{ false }}" bindtap="openClockRateShow" />
  61 + </van-cell-group>
41 62 </view>
42   - </view>
43   - <view class="sm_grey_font">
44   - 开启后,在打卡周期内,学生家长可对未打卡的任务进行补卡。
45   - </view>
46   - <view class="white_card_nopadding">
47   - <van-cell-group>
48   - <van-cell title="开始时间" value='时间' is-link border="{{ false }}" bindtap="openStartTimeShow"/>
49   - </van-cell-group>
50   - </view>
51   - <view class="white_card_nopadding">
52   - <van-cell-group>
53   - <van-cell title="打卡周期" value='90天' is-link border="{{ false }}" bindtap="openClockCycleShow"/>
54   - </van-cell-group>
55   - </view>
56   - <view class="white_card_nopadding">
57   - <van-cell-group>
58   - <van-cell title="打卡频次" value='每天' is-link border="{{ false }}" bindtap="openClockRateShow"/>
59   - </van-cell-group>
60   - </view>
61 63  
62   - <view class="clearance"></view>
63   - <view class="white_card_nopadding">
64   - <van-cell-group>
65   - <van-cell title="打卡提醒" value='18:00' is-link border="{{ false }}" bindtap="openClockRemindShow"/>
66   - </van-cell-group>
67   - </view>
68   - <view class="white_card_nopadding">
69   - <van-cell-group>
70   - <van-cell title="缺卡打卡提醒" value='缺卡三天及以上' is-link border="{{ false }}" bindtap="openClockLackShow"/>
71   - </van-cell-group>
72   - </view>
  64 + <view class="clearance"></view>
  65 + <view class="white_card_nopadding">
  66 + <van-cell-group>
  67 + <van-cell title="打卡提醒" value="{{ form.remindTime }}" is-link border="{{ false }}" bindtap="openClockRemindShow" />
  68 + </van-cell-group>
  69 + </view>
  70 + <view class="white_card_nopadding">
  71 + <van-cell-group>
  72 + <van-cell title="缺卡打卡提醒" value="{{ form.lackNum + ' 次' }}" is-link border="{{ false }}" bindtap="openClockLackShow" />
  73 + </van-cell-group>
  74 + </view>
73 75  
74   - <view class="sm_grey_font">
75   - 学生如缺卡达到一定条件,将会提醒家长
76   - </view>
77   - <view class="white_card_nopadding">
78   - <van-cell-group>
79   - <van-cell title="提交时必须包含" value='图片' is-link border="{{ false }}" bindtap="openContainShow"/>
80   - </van-cell-group>
81   - </view>
  76 + <view class="sm_grey_font">
  77 + 学生如缺卡达到一定条件,将会提醒家长
  78 + </view>
  79 + <view class="white_card_nopadding">
  80 + <van-cell-group>
  81 + <van-cell title="提交时必须包含" value="{{ form.submitCondition }}" is-link border="{{ false }}" bindtap="openContainShow" />
  82 + </van-cell-group>
  83 + </view>
82 84  
83   - <view class="clearance"></view>
84   - <view class="btn">
85   - <van-button type="info" round block>创建打卡</van-button>
86   - </view>
  85 + <view class="clearance"></view>
  86 + <view class="btn">
  87 + <van-button type="info" round block bindtap="createTask">创建打卡</van-button>
  88 + </view>
87 89  
88 90 <!--统计单位-->
89   - <van-popup
90   - show="{{ unitShow }}"
91   - position="bottom"
92   - custom-style="height: 40%;"
93   - round
94   - bind:close="closeUnitShow"
95   - >
96   - <van-picker columns="{{ columnsUnit }}" bind:confirm="changeUnitShow" bind:cancel="closeUnitShow" show-toolbar title="统计单位"/>
  91 + <van-popup show="{{ unitShow }}" position="bottom" custom-style="height: 40%;" round bind:close="closeUnitShow">
  92 + <van-picker columns="{{ columnsUnit }}" bind:confirm="changeUnitShow" bind:cancel="closeUnitShow" show-toolbar title="统计单位" />
97 93 </van-popup>
98 94  
99 95 <!--开始时间-->
100   - <van-popup
101   - show="{{ startTimeShow }}"
102   - position="bottom"
103   - custom-style="height: 40%;"
104   - round
105   - bind:close="closeStartTimeShow"
106   - >
107   - <van-picker columns="{{ columnsStartTime }}" bind:confirm="changeStartTimeShow" bind:cancel="closeStartTimeShow" show-toolbar title="开始时间"/>
  96 + <van-popup show="{{ startTimeShow }}" position="bottom" custom-style="height: 40%;" round bind:close="closeStartTimeShow">
  97 + <!-- <van-picker columns="{{ columnsStartTime }}" bind:confirm="changeStartTimeShow" bind:cancel="closeStartTimeShow" show-toolbar title="开始时间" /> -->
  98 + <van-datetime-picker title="开始时间" type="date" value="{{ form.startTimeShow }}" min-date="{{ minDate }}" bind:confirm="changeStartTimeShow" bind:cancel="closeStartTimeShow" formatter="{{ formatter }}" />
108 99 </van-popup>
109 100  
110 101 <!--打卡周期-->
111   - <van-popup
112   - show="{{ clockCycleShow }}"
113   - position="bottom"
114   - custom-style="height: 40%;"
115   - round
116   - bind:close="closeClockCycleShow"
117   - >
118   - <van-picker columns="{{ columnsClockCycle }}" bind:confirm="changeClockCycleShow" bind:cancel="closeClockCycleShow" show-toolbar title="打卡周期"/>
  102 + <van-popup show="{{ clockCycleShow }}" position="bottom" custom-style="height: 40%;" round bind:close="closeClockCycleShow">
  103 + <van-picker columns="{{ columnsClockCycle }}" bind:confirm="changeClockCycleShow" bind:cancel="closeClockCycleShow" show-toolbar title="打卡周期" />
119 104 </van-popup>
120 105  
121 106 <!--打卡频次-->
122   - <van-popup
123   - show="{{ clockRateShow }}"
124   - position="bottom"
125   - custom-style="height: 40%;"
126   - round
127   - bind:close="closeClockRateShow"
128   - >
129   - <van-picker columns="{{ columnsClockRate }}" bind:confirm="changeClockRateShow" bind:cancel="closeClockRateShow" show-toolbar title="打卡频次"/>
  107 + <van-popup show="{{ clockRateShow }}" position="bottom" custom-style="height: 40%;" round bind:close="closeClockRateShow">
  108 + <van-picker columns="{{ columnsClockRate }}" bind:confirm="changeClockRateShow" bind:cancel="closeClockRateShow" show-toolbar title="打卡频次" />
130 109 </van-popup>
131 110  
132 111 <!--打卡提醒-->
133   - <van-popup
134   - show="{{ clockRemindShow }}"
135   - position="bottom"
136   - custom-style="height: 40%;"
137   - round
138   - bind:close="closeClockRemindShow"
139   - >
140   - <van-picker columns="{{ columnsClockRemind }}" bind:confirm="changeClockRemindShow" bind:cancel="closeClockRemindShow" show-toolbar title="打卡提醒"/>
  112 + <van-popup show="{{ clockRemindShow }}" position="bottom" custom-style="height: 40%;" round bind:close="closeClockRemindShow">
  113 + <van-picker columns="{{ columnsClockRemind }}" bind:confirm="changeClockRemindShow" bind:cancel="closeClockRemindShow" show-toolbar title="打卡提醒" />
141 114 </van-popup>
142 115  
143 116 <!--打卡缺卡提醒-->
144   - <van-popup
145   - show="{{ clockLackShow }}"
146   - position="bottom"
147   - custom-style="height: 40%;"
148   - round
149   - bind:close="closeClockLackShow"
150   - >
151   - <van-picker columns="{{ columnsClockLack }}" bind:confirm="changeClockLackShow" bind:cancel="closeClockLackShow" show-toolbar title="缺卡打卡提醒"/>
  117 + <van-popup show="{{ clockLackShow }}" position="bottom" custom-style="height: 40%;" round bind:close="closeClockLackShow">
  118 + <van-picker columns="{{ columnsClockLack }}" bind:confirm="changeClockLackShow" bind:cancel="closeClockLackShow" show-toolbar title="缺卡打卡提醒" />
152 119 </van-popup>
153 120  
154 121 <!-- 必须包含 -->
155   - <van-popup
156   - show="{{ containShow }}"
157   - position="bottom"
158   - custom-style="height: 40%;"
159   - round
160   - bind:close="closeContainShow"
161   - >
162   - <van-picker columns="{{ columnsContain }}" bind:confirm="changeContainShow" bind:cancel="closeContainShow" show-toolbar title="提交时必须包含"/>
  122 + <van-popup show="{{ containShow }}" position="bottom" custom-style="height: 40%;" round bind:close="closeContainShow">
  123 + <van-picker columns="{{ columnsContain }}" bind:confirm="changeContainShow" bind:cancel="closeContainShow" show-toolbar title="提交时必须包含" />
163 124 </van-popup>
164 125 </view>
165 126 \ No newline at end of file
... ...
pages/index/rank/rank.js
1 1 // pages/index/rank/rank.js
  2 +import request from '../../../api/request.js'
  3 +import moment from 'moment';
2 4 Page({
3 5  
4 6 /**
5 7 * 页面的初始数据
6 8 */
7 9 data: {
8   - rankList: [
9   - {name: '小米',num: 20},
10   - {name: '杰瑞',num: 110},
11   - {name: '王小明',num: 75},
12   - ]
  10 + rankList: [],
  11 + dayTime: '',
  12 + user: {
  13 + id: '',
  14 + name: '',
  15 + nickname: '',
  16 + phone: "",
  17 + token: "",
  18 + }
  19 + },
  20 +
  21 + //排行榜列表
  22 + getRankList() {
  23 + request({
  24 + url: `/wx/task/getSignRank`,
  25 + method: 'post',
  26 + data: {
  27 + "page": 1,
  28 + "pageSize": 999,
  29 + "userId": wx.getStorageSync("userInfo_id")
  30 + },
  31 + }).then(res => {
  32 + if (res.code == 0) {
  33 + this.setData({
  34 + rankList: res.rows
  35 + })
  36 + console.log(this.data.rankList)
  37 + } else {
  38 + wx.showToast({
  39 + title: res.msg,
  40 + icon: 'none',
  41 + duration: 1500
  42 + })
  43 + }
  44 + })
13 45 },
14   -
15 46 //去打卡
16 47 toOpen() {
17 48 wx.navigateTo({
... ... @@ -22,7 +53,13 @@ Page({
22 53 * 生命周期函数--监听页面加载
23 54 */
24 55 onLoad(options) {
25   -
  56 + this.setData({
  57 + 'user': wx.getStorageSync('userInfo')
  58 + })
  59 + this.setData({
  60 + "dayTime": moment(new Date().getTime()).format('YYYY-MM-DD')
  61 + })
  62 + this.getRankList()
26 63 },
27 64 // 统一返回
28 65 handleBack() {
... ...
pages/index/rank/rank.wxml
1 1 <!--pages/index/rank/rank.wxml-->
2 2 <!-- <view class="rank" style="background-image: url('https://szyundisk.oss-cn-hangzhou.aliyuncs.com/null/5f055580-1341-4c52-9154-c3b125c1107a.png')"> -->
3 3 <view class="rank" style="background-image: url('https://szyundisk.oss-cn-hangzhou.aliyuncs.com/AdmissionsManageSys/54ec1f3f-dbb4-4660-ba24-4a6731e88def.png')">
4   - <view class="rank_time">更新时间:2022-03-12</view>
  4 + <view class="rank_time">更新时间:{{dayTime}}</view>
5 5 <view class="white_box">
6 6 <view class="title_box">
7 7 <view class="title_pic">
8 8 <image class="pic" src="/img/answer/user.png" alt="" />
9   - 陈浩然
  9 + {{user.name}}
10 10 </view>
11   - <view class="red_title">已坚持12天</view>
12   - <view class="red_title">34次</view>
  11 + <view class="red_title">已坚持xx天</view>
  12 + <view class="red_title">xx次</view>
13 13 </view>
14 14 <view class="grey_title">
15 15 <view class="table_L">
... ... @@ -24,7 +24,7 @@
24 24 <image wx:if="{{index == 0}}" class="tem_pic" src="/img/answer/1.png" alt="" />
25 25 <image wx:if="{{index == 1}}" class="tem_pic" src="/img/answer/2.png" alt="" />
26 26 <image wx:if="{{index == 2}}" class="tem_pic" src="/img/answer/3.png" alt="" />
27   - <view wx:if="{{index != 0 && index != 1 && index != 2}}">{{index + 1}}</view>
  27 + <view class="tem_pic" wx:if="{{index != 0 && index != 1 && index != 2}}">{{index + 1}}</view>
28 28 <view>{{value.name}}</view>
29 29 </view>
30 30 <view class="table_R">
... ...
pages/index/rank/rank.wxss
... ... @@ -58,6 +58,10 @@
58 58 width: 28vw;
59 59 display: flex;
60 60 justify-content: space-between;
  61 +
  62 +}
  63 +.L_box {
  64 + width: 50px;
61 65 }
62 66  
63 67 .table_item {
... ... @@ -81,6 +85,7 @@
81 85 .tem_pic {
82 86 width: 22px;
83 87 height: 28px;
  88 + text-align: center;
84 89 }
85 90 .btn {
86 91 position: fixed;
... ...
pages/login/codeLogin/codeLogin.js
1 1 // pages/login/codeLogin/codeLogin.js
2   -var app = getApp();
  2 +// var app = getApp();
  3 +var api = 'https://proxy.shunzhi.net/';
  4 +var api_card = 'https://proxy.shunzhi.net/card/';
  5 +var appid = 'wx186236fdcd93edcc';
3 6 var util = require('../../../utils/md5.js')
4 7 import request from '../../../api/request.js'
5 8 Page({
... ... @@ -21,6 +24,7 @@ Page({
21 24 path: '', //登录后跳转页面
22 25 modelShow: false, //完善信息
23 26 phone: '', //getUserInfo获取到的手机号
  27 + openId: ''
24 28 },
25 29 onLoad: function (options) {
26 30 console.log('登录页options:', options)
... ... @@ -69,20 +73,25 @@ Page({
69 73 })
70 74 }
71 75 request({
72   - url: `h5/user/Oneclicklogin`,
73   - method: 'get',
  76 + url: `/wx/app/oneClickLogin/`+ appid,
  77 + method: 'post',
74 78 data: {
75 79 "encryptedData": this.data.encryptedData,
76   - "session_key": this.data.session_key,
  80 + "sessionKey": this.data.session_key,
77 81 "iv": this.data.iv,
  82 + "openId": this.data.openId
78 83 },
79 84 }).then(res => {
80   - if (res.success) {
  85 + if (res.code == 0) {
81 86 if (res.data) {
82 87 this.setData({
83 88 phone: res.data.phone
84 89 }, () => {
85   - this.getUserInfo()
  90 + wx.setStorageSync('userInfo', res.data)
  91 + wx.setStorageSync('userInfo_id', res.data.id)
  92 + wx.switchTab({
  93 + url: '/pages/index/rank/rank',
  94 + })
86 95 })
87 96 } else {
88 97 wx.showToast({
... ... @@ -107,23 +116,23 @@ Page({
107 116 }
108 117 },
109 118 getUserInfo() {
110   - let that = this
111   - request({
112   - url: `h5/user/getuserInfoNew`,
113   - method: 'get',
114   - data: {
115   - // PhoneName: '13355752969'
116   - PhoneName: this.data.phone
117   - },
118   - }).then((res) => {
119   - if (res.success) {
120   - if (res.data) {
121   - wx.setStorageSync('userInfo', res.data)
122   - wx.setStorageSync('showModal', '')
  119 + // let that = this
  120 + // request({
  121 + // url: `h5/user/getuserInfoNew`,
  122 + // method: 'get',
  123 + // data: {
  124 + // // PhoneName: '13355752969'
  125 + // PhoneName: this.data.phone
  126 + // },
  127 + // }).then((res) => {
  128 + // if (res.success) {
  129 + // if (res.data) {
  130 + // wx.setStorageSync('userInfo', res.data)
  131 + // wx.setStorageSync('showModal', '')
123 132  
124   - }
125   - }
126   - })
  133 + // }
  134 + // }
  135 + // })
127 136 },
128 137 getOpenId() {
129 138 return request({
... ... @@ -133,10 +142,13 @@ Page({
133 142 code: this.data.loginCode
134 143 },
135 144 }).then(res2 => {
136   - // console.log(res2.data);
137 145 this.setData({
138   - session_key: JSON.parse(res2.data).session_key
  146 + session_key: res2.data.sessionKey
139 147 })
  148 + this.setData({
  149 + openId: res2.data.openid
  150 + })
  151 + console.log(this.data);
140 152 })
141 153 },
142 154 bindUserName: function (e) {
... ... @@ -182,17 +194,16 @@ Page({
182 194 title: '请求中',
183 195 })
184 196 wx.request({
185   - url: api + '/wx/app/loginCode',
  197 + url: api_card + '/wx/app/loginCode',
186 198 data: {
187   - captcha: code,
188   - mobile: username
  199 + code: code,
  200 + phone: username
189 201 },
190   - method: 'get',
  202 + method: 'post',
191 203 success: (res) => {
192 204 wx.hideLoading();
193 205 if (res.data.success) {
194 206 console.log(res.data)
195   - return
196 207 if (res.data.data) {
197 208 this.setData({
198 209 phone: res.data.data.phone
... ... @@ -308,7 +319,7 @@ Page({
308 319 }
309 320 },
310 321 getPhoneNumber(e) {
311   - // console.log(e.detail)
  322 + console.log(e.detail)
312 323 if (e.detail.errMsg == 'getPhoneNumber:ok') {
313 324 this.setData({
314 325 encryptedData: e.detail.encryptedData,
... ... @@ -317,7 +328,6 @@ Page({
317 328 this.login()
318 329 })
319 330 }
320   -
321 331 },
322 332 //去查看协议
323 333 toProtocol() {
... ... @@ -333,7 +343,7 @@ Page({
333 343 },
334 344 goIndex() {
335 345 wx.switchTab({
336   - url: '/pages/index/index',
  346 + url: '/pages/index/rank/rank',
337 347 })
338 348 },
339 349  
... ...
pages/login/codeLogin/codeLogin.wxml
... ... @@ -7,18 +7,18 @@
7 7 <text class="title" selectable="false" space="false" decode="false">欢迎登录</text>
8 8 </view>
9 9 <view class="tips_box">
10   - <text class="tips" selectable="false" space="false" decode="false">请输入登录资料</text>
  10 + <!-- <text class="tips" selectable="false" space="false" decode="false">请输入登录资料</text> -->
11 11 </view>
12 12 <view class='cont-box'>
13   - <view class="phoneBox">
  13 + <!-- <view class="phoneBox">
14 14 <input type='number' placeholder='请输入手机号' bindinput="bindUserName" />
15 15 </view>
16 16 <view class="codeBox">
17 17 <input type='number' class="codeInput" placeholder='请输入短信验证码' bindinput="bindCode" />
18 18 <view class="getCode" bindtap="getCode">{{codeCont}}</view>
19   - </view>
  19 + </view> -->
20 20 <view class="btnBox">
21   - <text class="next button" bindtap='next'>登  录</text>
  21 + <!-- <text class="next button" bindtap='next'>登  录</text> -->
22 22 <!-- <navigator url="/pages/login/login" class="vipLogin button">微信登陆</navigator> -->
23 23 <button class="one_click_btn" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">微信一键登陆</button>
24 24 </view>
... ...
pages/mine/index.js
... ... @@ -6,7 +6,8 @@ Page({
6 6 * 页面的初始数据
7 7 */
8 8 data: {
9   -
  9 + user_name: '',
  10 + user_phone: '',
10 11 },
11 12 // 打卡记录
12 13 handleRecord(){
... ... @@ -21,6 +22,16 @@ Page({
21 22 })
22 23 },
23 24 /**
  25 + * 生命周期函数--监听页面加载
  26 + */
  27 + onLoad(options) {
  28 + let userInfo = wx.getStorageSync('userInfo')
  29 + this.setData({
  30 + "user_name": userInfo.name || userInfo.nickname,
  31 + "user_phone": userInfo.phone
  32 + })
  33 + },
  34 + /**
24 35 * 用户点击右上角分享
25 36 */
26 37 onShareAppMessage: function () {
... ...
pages/mine/index.wxml
... ... @@ -4,8 +4,8 @@
4 4 <image class="pic" src="/img/answer/user.png" alt="" />
5 5 </view>
6 6 <view class="title_box">
7   - <view class="title_name">陈浩然</view>
8   - <view class="grey_title">绍兴市高级中学.20级</view>
  7 + <view class="title_name">{{user_name}}</view>
  8 + <view class="grey_title">{{user_phone}}</view>
9 9 </view>
10 10 </view>
11 11 <view class="flex_card">
... ...
pages/mine/record/record.js
1 1 // pages/index/record/record.js
  2 +import request from '../../../api/request.js'
2 3 Page({
3 4  
4 5 /**
... ... @@ -7,16 +8,65 @@ Page({
7 8 data: {
8 9 tabindex: 0,
9 10 showAdd: false,
10   -
  11 + taskList: [],
  12 +
11 13 tempList: [
12   - {name:'自定义模板',url: '/img/answer/zdy.png'},
13   - {name:'英语模板',url: '/img/answer/english.png'},
14   - {name:'数学模板',url: '/img/answer/math.png'},
15   - ]
  14 + // {name:'自定义模板',url: '/img/answer/zdy.png'},
  15 + // {name:'英语模板',url: '/img/answer/english.png'},
  16 + // {name:'数学模板',url: '/img/answer/math.png'},
  17 + ]
  18 + },
  19 +
  20 + //打卡记录列表
  21 + getTaskList() {
  22 + request({
  23 + url: `/wx/task/cardTaskList`,
  24 + method: 'post',
  25 + data: {
  26 + "oneselfFlag": this.data.tabindex + 1,
  27 + "page": 1,
  28 + "pageSize": 999,
  29 + "userId": wx.getStorageSync("userInfo_id")
  30 + },
  31 + }).then(res => {
  32 + if (res.code == 0) {
  33 + this.setData({
  34 + taskList: res.rows
  35 + })
  36 + } else {
  37 + wx.showToast({
  38 + title: res.msg,
  39 + icon: 'none',
  40 + duration: 1500
  41 + })
  42 + }
  43 + })
  44 + },
  45 +
  46 + //模板列表
  47 + getTempList() {
  48 + request({
  49 + url: `/wx/temp/tempList`,
  50 + method: 'post',
  51 + data: {},
  52 + }).then(res => {
  53 + if (res.code == 0) {
  54 + this.setData({
  55 + tempList: res.data
  56 + })
  57 + } else {
  58 + wx.showToast({
  59 + title: res.msg,
  60 + icon: 'none',
  61 + duration: 1500
  62 + })
  63 + }
  64 + })
16 65 },
17 66  
18 67 //打卡
19 68 toShow(e) {
  69 + this.getTempList()
20 70 this.setData({
21 71 showAdd: true
22 72 })
... ... @@ -28,22 +78,25 @@ Page({
28 78 })
29 79 },
30 80 //选择模板
31   - toPunch() {
  81 + toPunch(e) {
  82 + let obj = e.currentTarget.dataset
  83 + let id = obj.value ? obj.value.id :0
32 84 wx.navigateTo({
33   - url: `../../index/newPunch/newPunch`
  85 + url: `../../index/newPunch/newPunch?tempId=${id}`
34 86 })
35 87 },
36 88 /**
37 89 * 生命周期函数--监听页面加载
38 90 */
39 91 onLoad(options) {
40   -
  92 + this.getTaskList()
41 93 },
42 94 //切换
43 95 handleTab(e) {
44 96 this.setData({
45 97 tabindex: e.detail.index
46 98 })
  99 + this.getTaskList()
47 100 },
48 101 // 打卡成果
49 102 handleAchievement() {
... ...
pages/mine/record/record.wxml
... ... @@ -8,34 +8,34 @@
8 8 </view>
9 9 <view class="bck">
10 10 <view class="grey_font">进行中打卡</view>
11   - <view class="card">
  11 + <view class="card" wx:for="{{taskList}}" wx:key="index" wx:for-item="value">
12 12 <view class="card_title">
13 13 <view class="title_L">
14 14 <image class="title_pic" src="/img/answer/bj.png" alt="" />
15 15 </view>
16 16 <view class="title_R">
17   - <view>英语单词每日打卡</view>
18   - <view class="grey_font">我发布于09-09 08:21</view>
  17 + <view>{{value.taskTitle}}</view>
  18 + <view class="grey_font">开始时间 {{value.startDate}}</view>
19 19 </view>
20 20 </view>
21   - <view class="day_font">每日20个英文单词背诵</view>
22   - <view class="day_font2">已坚持打卡
  21 + <view class="day_font" >{{value.taskDesc}}</view>
  22 + <!-- <view class="day_font2">已坚持打卡
23 23 <text class="day_font2_large">1/50 </text>天
24   - </view>
  24 + </view> -->
25 25 <view>
26 26 <van-progress percentage="50" color='#3F5EFF' stroke-width="13" pivot-text=' ' />
27 27 </view>
28 28 <view class="flex_font">
29 29 <text class="grey_flex">打卡频次:</text>
30   - 每天
  30 + {{value.taskFrequency}}
31 31 </view>
32   - <view class="flex_font">
  32 + <view class="flex_font" wx:if="{{value.submitCondition != null}}">
33 33 <text class="grey_flex">打卡要求:</text>
34   - 需填写单词个数
  34 + {{'需要' + value.submitCondition}}
35 35 </view>
36 36 <view class="flex_font">
37 37 <view class="grey_flex">其他:</view>
38   - 不允许补卡
  38 + {{value.allowRepairCard == 1 ? '允许补卡': '不允许补卡'}}
39 39 </view>
40 40 <view class="grey_line"></view>
41 41 <view class="blue_font" wx:if="{{tabindex == 1}}">
... ... @@ -58,9 +58,13 @@
58 58 <view class="pop_card">
59 59 <view class="pop_title">选择模板</view>
60 60 <view class="tem_box">
  61 + <view class="tem_item" bindtap="toPunch" >
  62 + <image class="tem_pic" src="/img/answer/zdy.png" alt="" />
  63 + <view class="tem_font">自定义模板</view>
  64 + </view>
61 65 <view class="tem_item" wx:for="{{tempList}}" wx:key="index" wx:for-item="value" bindtap="toPunch" data-value="{{value}}">
62   - <image class="tem_pic" src="{{value.url}}" alt="" />
63   - <view class="tem_font">{{value.name}}</view>
  66 + <image class="tem_pic" src="{{value.taskBackground}}" alt="" />
  67 + <view class="tem_font">{{value.taskTitle}}</view>
64 68 </view>
65 69 </view>
66 70 </view>
... ...