小言_互联网的博客

【免费开放源码】审批类小程序项目实战(预约审批端)

469人阅读  评论(0)

第一节:什么构成了微信小程序、创建一个自己的小程序

第二节:微信开发者工具使用教程

第三节:深入了解并掌握小程序核心组件

第四节:初始化云函数和数据库

第五节:云数据库的增删改查

第六节:项目大纲以及制作登录、注册页面

第七节:制作活动申请页面

第八节:活动申请页面的补充

第九节:我的页面制作

第十节:活动详情页面制作

第十一节:活动历史页面制作

第十二节:预约老师页面制作

第十三节:预约历史页面制作

第十四节:活动审批端制作

第十五节:预约审批端制作

目录

目录

前言

成品图

核心思想

实现步骤 

appointmentApproval.wxml

appointmentApproval.wxss

appointmentApproval.js

appointmentApproval3.wxml

appointmentApproval3.wxss

appointmentApproval3.js

getAll2.js

excel.js

getExcel.js

appointmentApproval2.wxml

appointmentApproval2.wxss

appointmentApproval2.js

appointmentDetail.wxml

appointmentDetail.wxss

appointmentDetail.js

题外话


前言

        上一节我们完成了活动审批端的搭建,这一节我们将要完成预约审批端的搭建,也就是本项目最后一个部分的搭建!我们先来看思维大纲~

        跟活动审批端同理,我们同样要在app.json文件中创建相关的页面。


  
  1. "pages/appointmentApproval/appointmentApproval",
  2. "pages/appointmentApproval2/appointmentApproval2",
  3. "pages/appointmentApproval3/appointmentApproval3",
  4. "pages/appointmentDetail/appointmentDetail"

         完成了上诉准备工作那么开始搭建吧~


成品图


核心思想

1.基本样式参照“我的”页面

2.导航栏参照活动审批端

3.需要老师版的预约详情页面

4.通过云开发来实现预约的审批(updata)

5.点击工具箱可实现一键导出预约信息的excel表格


实现步骤 

        该部分的难点在于如何一键导出预约信息的excel表格,其实node.js也支持这个功能,我们只需要稍加点改动就可以了。这里我直接将代码送上了~如果你对代码有疑问可以在底下留言。

        我们将按照思维大纲中 待审批——>已通过——>已驳回 的顺序来依次制作~


appointmentApproval.wxml


  
  1. <view class="container">
  2. <view class="container_content">
  3. <view class="box">
  4. <view class="mine_application">
  5. <!-- 活动标题 -->
  6. <view class="mine_application_title">
  7. <view>待审批的预约 </view> <image src="../../icon/rank.png" style="width: 50px;height: 35px;position: absolute; right: 20px; top: 0px;" bindtap="up"> </image>
  8. </view>
  9. <block wx:for="{{list}}"> </block>
  10. <!-- 活动内容 点击可跳转至详情页面 -->
  11. <view class="mine_application_content" wx:for="{{list}}" >
  12. <view class="event" bindtap="goDetail" data-id="{{item._id}}">
  13. <view class="appointmentTime">{{item.appointment}} </view>
  14. <view class="appointmentInstitute">预约组织:{{item.g1_orderInstitute}} </view>
  15. <view class='appointmentTeacher'>预约老师:{{item.g1_orderTeacher}} </view>
  16. <view class="time">{{item.time}} </view>
  17. <view class="subscriber">申请人:{{item.subscriber}} </view>
  18. </view>
  19. <!-- 右上角的状态栏 -->
  20. <!-- 用条件渲染来展示多种样式的活动内容 -->
  21. <!-- 状态为3代表已结束,2为已驳回,1为已通过,0为审核中 -->
  22. <block wx:if="{{item.state==0}}">
  23. <!-- 审核中 -->
  24. <view class="state_0">
  25. <view class="state_content">审核中 </view>
  26. </view>
  27. <!-- 活动下方的小点 -->
  28. <image src="../../icon/yellow.png" style="width: 11px;height: 11px;position: absolute;left: 15px;bottom: 15px;"> </image>
  29. </block>
  30. <block wx:if="{{item.state==1}}">
  31. <!-- 已通过 -->
  32. <view class="state_1">
  33. <view class="state_content">已通过 </view>
  34. </view>
  35. <!-- 活动下方的小点 -->
  36. <image src="../../icon/green.png" style="width: 11px;height: 11px;position: absolute;left: 15px;bottom: 15px;"> </image>
  37. <view class="next_location" >
  38. <button class="button_detail" size="mini" bindtap="goNext" data-id="{{item._id}}">下一步 >
  39. </button>
  40. </view>
  41. </block>
  42. <block wx:if="{{item.state==2}}">
  43. <!-- 已驳回 -->
  44. <view class="state_2">
  45. <view class="state_content">已驳回 </view>
  46. </view>
  47. <!-- 活动下方的小点 -->
  48. <image src="../../icon/red.png" style="width: 11px;height: 11px;position: absolute;left: 15px;bottom: 15px;"> </image>
  49. <view class="reject_location">
  50. <button class="button_detail" size="mini">驳回详情 >
  51. </button>
  52. </view>
  53. </block>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="tabar">
  58. <view class='goApprovalButton' bindtap="goApprovalPage">
  59. <image src="../../icon/approval.png" style="width: 40px; height: 40px; margin-top: 5px;"> </image>
  60. <view class="button_content">待审批 </view>
  61. </view>
  62. <view class="goPassButton" bindtap="goPassPage">
  63. <image src="../../icon/pass(1).png" style="width: 40px; height: 40px; margin-top: 5px;"> </image>
  64. <view class="button_content">已通过 </view>
  65. </view>
  66. <view class="goRejectButton" bindtap="goRejectPage">
  67. <image src="../../icon/reject(1).png" style="width: 40px; height: 40px; margin-top: 5px;"> </image>
  68. <view class="button_content">已驳回 </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>

appointmentApproval.wxss


  
  1. .mine_application{
  2. margin-left: 15px;
  3. margin-right: 15px;
  4. }
  5. .mine_application_title{
  6. border-bottom: 5rpx solid #A6A6A6;
  7. font-size: 28px;
  8. font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  9. }
  10. .mine_application_content{
  11. height: 250px;
  12. width: 100%;
  13. display: flex;
  14. position: relative;
  15. box-shadow: 16rpx 8rpx 24rpx rgba( 212, 48, 48, 0.1);
  16. margin-top: 15px;
  17. border-radius: 15px;
  18. }
  19. .event{
  20. font-size: 20px;
  21. font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  22. position: relative;
  23. margin: 15px;
  24. width: 90%;
  25. flex: 1;
  26. }
  27. .appointmentTime{
  28. margin-top: 0px;
  29. font-size: 16px;
  30. color: black;
  31. }
  32. .state_0{
  33. float: right;
  34. width: 80px;
  35. height: 40px;
  36. background-color: #FFC300;
  37. border-radius: 0 15px 0 15px;
  38. }
  39. .state_content{
  40. position: relative;
  41. margin-top: 10px ;
  42. margin-left: 15px;
  43. font-size: 12;
  44. color: white;
  45. }
  46. .appointmentInstitute{
  47. font-size: 20px;
  48. color: #FF5733;
  49. margin-top: 10px;
  50. }
  51. .appointmentTeacher{
  52. font-size: 20px;
  53. color: #611504;
  54. margin-top: 10px;
  55. }
  56. .time{
  57. margin-top: 10px;
  58. font-size: 18px;
  59. color: #A0A9BD;
  60. }
  61. .goApprovalButton{
  62. position: absolute;
  63. bottom: 0px ;
  64. left: 0%;
  65. color: #FFFFFF;
  66. background-color: #FFFFFF;
  67. border-top: 2px solid grey;
  68. width: 33.333%;
  69. height: 70px;
  70. text-align:center;
  71. margin-top: 10px;
  72. }
  73. .goPassButton{
  74. position: absolute;
  75. bottom: 0px ;
  76. left: 33.333%;
  77. color: #FFFFFF;
  78. background-color: #FFFFFF;
  79. border-top: 2px solid grey;
  80. width: 33.333%;
  81. height: 70px;
  82. text-align:center;
  83. margin-top: 10px;
  84. }
  85. .goRejectButton{
  86. position: absolute;
  87. bottom: 0px ;
  88. left: 66.666%;
  89. color: #FFFFFF;
  90. background-color: #FFFFFF;
  91. border-top: 2px solid grey;
  92. width: 33.333%;
  93. height: 70px;
  94. text-align:center;
  95. margin-top: 10px;
  96. }
  97. .button_content{
  98. font-size: 15px;
  99. color: black;
  100. }
  101. .box{
  102. margin-bottom: 50px;
  103. }
  104. .container{
  105. position: relative;
  106. }
  107. .container_content{
  108. position: relative;
  109. min-height: 100vh;
  110. box-sizing: border-box;
  111. padding-bottom: 60rpx;
  112. padding-top: 0rpx;
  113. }
  114. .subscriber{
  115. font-size: 20px;
  116. font-weight: 100;
  117. color: rgb( 23, 6, 175);
  118. }
  119. .tabar{
  120. width: 100%;
  121. text-align: center;
  122. letter-spacing: 4rpx;
  123. position: absolute;
  124. bottom: 0;
  125. }

appointmentApproval.js


  
  1. const db = wx. cloud. database()
  2. Page({
  3. data: {
  4. list:[]
  5. },
  6. onLoad( options) {
  7. console. log( "列表携带的值",options)
  8. db. collection( "appointment")
  9. . where({
  10. state: 0,
  11. })
  12. . get()
  13. . then( res=>{
  14. console. log( '查询数据库成功',res. data)
  15. //将返回的res.data里面的值赋值给list
  16. this. setData({
  17. list :res. data,
  18. })
  19. console. log( "这是list", this. data. list)
  20. })
  21. },
  22. up( ){
  23. db. collection( "appointment")
  24. . where({
  25. state: 0,
  26. })
  27. . orderBy( 'rank', 'asc')
  28. . get()
  29. . then( res=>{
  30. console. log( '升序成功',res. data)
  31. this. setData({
  32. list:res. data
  33. })
  34. })
  35. . catch( err=>{
  36. console. log( '升序失败')
  37. })
  38. },
  39. onPullDownRefresh( ) {
  40. },
  41. onReachBottom( ) {
  42. },
  43. goDetail( e){
  44. console. log( "点击了详情页面,将展示活动的id ",e)
  45. wx. navigateTo({
  46. // 跳转到活动详情页面并携带活动id
  47. url: '/pages/appointmentDetail/appointmentDetail?id=' +e. currentTarget. dataset. id
  48. })
  49. },
  50. // 前往待审批页面
  51. goApprovalPage( ){
  52. wx. showToast({
  53. title: '您已经在当前页面',
  54. icon: 'none'
  55. })
  56. },
  57. // 前往已通过页面
  58. goPassPage( ){
  59. wx. redirectTo({
  60. url: '../appointmentApproval3/appointmentApproval3',
  61. })
  62. },
  63. // 前往已驳回页面
  64. goRejectPage( ){
  65. wx. redirectTo({
  66. url: '../appointmentApproval2/appointmentApproval2',
  67. })
  68. },
  69. })

appointmentApproval3.wxml


  
  1. <view class="container">
  2. <view class="container_content">
  3. <view class="box">
  4. <view class="mine_application">
  5. <!-- 活动标题 -->
  6. <view class="mine_application_title">
  7. <view>已通过的预约历史 </view> <image src="../../icon/work-box.png" style="width: 40px;height: 40px;position: absolute; right: 20px; top: 0px;" bindtap="download"> </image>
  8. <image src="../../icon/guide.png" style="width: 40px;height:40px;position: absolute; right: 70px; top:0px;"bindtap="lookAll"> </image>
  9. </view>
  10. <block wx:for="{{list}}"> </block>
  11. <!-- 活动内容 点击可跳转至详情页面 -->
  12. <view class="mine_application_content" wx:for="{{list}}" >
  13. <view class="event" bindtap="goDetail" data-id="{{item._id}}">
  14. <view class="appointmentTime">{{item.appointment}} </view>
  15. <view class="appointmentInstitute">预约组织:{{item.g1_orderInstitute}} </view>
  16. <view class='appointmentTeacher'>预约老师:{{item.g1_orderTeacher}} </view>
  17. <view class="time">{{item.time}} </view>
  18. </view>
  19. <!-- 右上角的状态栏 -->
  20. <!-- 用条件渲染来展示多种样式的活动内容 -->
  21. <!-- 状态为3代表已结束,2为已驳回,1为已通过,0为审核中 -->
  22. <block wx:if="{{item.state==1}}">
  23. <!-- 已通过 -->
  24. <view class="state_1">
  25. <view class="state_content">已通过 </view>
  26. </view>
  27. <!-- 活动下方的小点 -->
  28. <image src="../../icon/green.png" style="width: 11px;height: 11px;position: absolute;left: 15px;bottom: 15px;"> </image>
  29. </block>
  30. <block wx:if="{{item.state==2}}">
  31. <!-- 已驳回 -->
  32. <view class="state_2">
  33. <view class="state_content">已驳回 </view>
  34. </view>
  35. <!-- 活动下方的小点 -->
  36. <image src="../../icon/red.png" style="width: 11px;height: 11px;position: absolute;left: 15px;bottom: 15px;"> </image>
  37. </block>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="tabar">
  42. <view class='goApprovalButton' bindtap="goApprovalPage">
  43. <image src="../../icon/approval(1).png" style="width: 40px; height: 40px; margin-top: 5px;"> </image>
  44. <view class="button_content">待审批 </view>
  45. </view>
  46. <view class="goPassButton" bindtap="goPassPage">
  47. <image src="../../icon/pass.png" style="width: 40px; height: 40px; margin-top: 5px;"> </image>
  48. <view class="button_content">已通过 </view>
  49. </view>
  50. <view class="goRejectButton" bindtap="goRejectPage">
  51. <image src="../../icon/reject(1).png" style="width: 40px; height: 40px; margin-top: 5px;"> </image>
  52. <view class="button_content">已驳回 </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>

appointmentApproval3.wxss


  
  1. .mine_application{
  2. margin-left: 15px;
  3. margin-right: 15px;
  4. }
  5. .mine_application_title{
  6. border-bottom: 5rpx solid #A6A6A6;
  7. font-size: 28px;
  8. font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  9. }
  10. .mine_application_content{
  11. height: 250px;
  12. width: 100%;
  13. display: flex;
  14. position: relative;
  15. box-shadow: 16rpx 8rpx 24rpx rgba( 212, 48, 48, 0.1);
  16. margin-top: 15px;
  17. border-radius: 15px;
  18. }
  19. .event{
  20. font-size: 20px;
  21. font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  22. position: relative;
  23. margin: 15px;
  24. width: 90%;
  25. flex: 1;
  26. }
  27. .appointmentTime{
  28. margin-top: 0px;
  29. font-size: 16px;
  30. color: black;
  31. }
  32. .state_1{
  33. width: 80px;
  34. height: 40px;
  35. background-color: #43CF7C;
  36. border-radius: 0 15px 0 15px;
  37. z-index: 2;
  38. flex-direction: row;
  39. position: relative;
  40. margin-left: 20px;
  41. }
  42. .state_content{
  43. position: relative;
  44. margin-top: 10px ;
  45. margin-left: 15px;
  46. font-size: 12;
  47. color: white;
  48. }
  49. .appointmentInstitute{
  50. font-size: 20px;
  51. color: #FF5733;
  52. margin-top: 10px;
  53. }
  54. .appointmentTeacher{
  55. font-size: 20px;
  56. color: #611504;
  57. margin-top: 10px;
  58. }
  59. .time{
  60. margin-top: 10px;
  61. font-size: 18px;
  62. color: #A0A9BD;
  63. }
  64. .goApprovalButton{
  65. position: absolute;
  66. bottom: 0px ;
  67. left: 0%;
  68. color: #FFFFFF;
  69. background-color: #FFFFFF;
  70. border-top: 2px solid grey;
  71. width: 33.333%;
  72. height: 70px;
  73. text-align:center;
  74. margin-top: 10px;
  75. }
  76. .goPassButton{
  77. position: absolute;
  78. bottom: 0px ;
  79. left: 33.333%;
  80. color: #FFFFFF;
  81. background-color: #FFFFFF;
  82. border-top: 2px solid grey;
  83. width: 33.333%;
  84. height: 70px;
  85. text-align:center;
  86. margin-top: 10px;
  87. }
  88. .goRejectButton{
  89. position: absolute;
  90. bottom: 0px ;
  91. left: 66.666%;
  92. color: #FFFFFF;
  93. background-color: #FFFFFF;
  94. border-top: 2px solid grey;
  95. width: 33.333%;
  96. height: 70px;
  97. text-align:center;
  98. margin-top: 10px;
  99. }
  100. .button_content{
  101. font-size: 15px;
  102. color: black;
  103. }
  104. .box{
  105. margin-bottom: 50px;
  106. }
  107. .container{
  108. position: relative;
  109. }
  110. .container_content{
  111. position: relative;
  112. min-height: 100vh;
  113. box-sizing: border-box;
  114. padding-bottom: 60rpx;
  115. padding-top: 0rpx;
  116. }
  117. /* 有无这个属性都行,之后可能会用到 */
  118. .tabar{
  119. width: 100%;
  120. text-align: center;
  121. letter-spacing: 4rpx;
  122. position: absolute;
  123. bottom: 0;
  124. }

appointmentApproval3.js


  
  1. const db = wx. cloud. database()
  2. const _ = db. command
  3. const t = new Date(). getTime(). toString(). slice( 0, - 3);
  4. Page({
  5. data: {
  6. list:[],
  7. // fileUrl:'',
  8. },
  9. onLoad( options) {
  10. //调用云函数来突破返回数据库的条数只有20条的限制
  11. wx. cloud. callFunction({
  12. name: 'getAll2'
  13. })
  14. . then( res=>{
  15. console. log( '成功',res)
  16. this. setData({
  17. list :res. result. data,
  18. })
  19. })
  20. . catch( res=>{
  21. console. log( "失败",res);
  22. })
  23. },
  24. onPullDownRefresh( ) {
  25. },
  26. onReachBottom( ) {
  27. },
  28. goDetail( e){
  29. console. log( "点击了详情页面,将展示活动的id ",e)
  30. wx. navigateTo({
  31. // 跳转到活动详情页面并携带活动id
  32. url: '/pages/appointmentDetail/appointmentDetail?id=' +e. currentTarget. dataset. id
  33. })
  34. },
  35. // 前往待审批页面
  36. goApprovalPage( ){
  37. wx. redirectTo({
  38. url: '../appointmentApproval/appointmentApproval',
  39. })
  40. },
  41. // 前往已通过页面
  42. goPassPage( ){
  43. wx. showToast({
  44. title: '您已经在当前页面',
  45. icon: 'none'
  46. })
  47. },
  48. // 前往已驳回页面
  49. goRejectPage( ){
  50. wx. redirectTo({
  51. url: '../appointmentApproval2/appointmentApproval2',
  52. })
  53. },
  54. //一键导出excel表格
  55. download( ){
  56. let that = this
  57. wx. showModal({
  58. title: '您是否需要导出已通过的预约',
  59. content: '',
  60. success (res) {
  61. if (res. confirm){
  62. console. log( '点击了一键导出excel')
  63. //引用了excel的云函数,调取了appointment里面的数据
  64. wx. cloud. callFunction({
  65. name: 'excel',
  66. success( res) {
  67. console. log( "读取成功", res. result. data)
  68. //将调取的数据存入函数里
  69. that. savaExcel(res. result. data)
  70. },
  71. })
  72. }
  73. else if (res. cancel) {
  74. //取消绑定的操作
  75. }
  76. }
  77. })
  78. },
  79. //把数据保存到excel里,并把excel保存到云存储
  80. savaExcel( userdata) {
  81. let that = this
  82. //调取getExcel云函数(核心)
  83. wx. cloud. callFunction({
  84. name: "getExcel",
  85. data: {
  86. userdata: userdata
  87. },
  88. success( res) {
  89. console. log( "保存成功", res)
  90. //调取获取地址的函数
  91. that. getFileUrl(res. result. fileID)
  92. },
  93. fail( res) {
  94. console. log( "保存失败", res)
  95. }
  96. })
  97. },
  98. //获取云存储文件下载地址,这个地址有效期一天
  99. getFileUrl( fileID) {
  100. let that = this;
  101. wx. cloud. getTempFileURL({
  102. fileList: [fileID],
  103. success: res => {
  104. // 这里的文件下载链接延迟很高,不能实时更新excel里面的数据,故采用文件下载链接拼接时间字符串的形式来达到可下载实时文件的目的
  105. console. log( "文件下载链接", res. fileList[ 0]. tempFileURL)
  106. // 这里就是拼接,方法来自 https://blog.csdn.net/sjn0503/article/details/74936613
  107. const finalUrl = `${res.fileList[0].tempFileURL}?${t}`
  108. console. log( "实时文件下载链接",finalUrl)
  109. that. setData({
  110. fileUrl: finalUrl
  111. })
  112. //获取到文件下载链接后,使用showModal和setClipboardData来达到给用户复制地址的目的
  113. wx. showModal({
  114. title: '一键导出excel成功',
  115. content:finalUrl,
  116. showCancel: true,
  117. confirmText: '复制地址',
  118. success( res){
  119. if (res. confirm) {
  120. wx. setClipboardData({
  121. data: that. data. fileUrl,
  122. success( res) {
  123. wx. getClipboardData({
  124. success( res) {
  125. console. log(res. data) // data
  126. }
  127. })
  128. }
  129. })
  130. }
  131. }
  132. })
  133. },
  134. })
  135. },
  136. })

其中在js中还用到了getAll2、excel、getExcel 三个云函数

getAll2.js


  
  1. // 云函数入口文件
  2. //获取所有已结束的活动
  3. const cloud = require( 'wx-server-sdk')
  4. let id= 0;
  5. // 云开发环境初始化
  6. cloud. init({ env: 'cloud1-0glmim4o153108f5'})
  7. const db = cloud. database()
  8. const _ = db. command
  9. exports. main = async (event, context) => {
  10. try{
  11. return await db. collection( 'appointment')
  12. . where(
  13. {
  14. state: 1
  15. }
  16. )
  17. //给申请到的预约数据排序
  18. . orderBy( 'rank', 'asc')
  19. . get({
  20. success: function ( res) {
  21. this. setData({
  22. id:res. _id
  23. })
  24. return res
  25. }
  26. })
  27. }
  28. catch(e){
  29. console. error(e)
  30. }
  31. }

excel.js


  
  1. //这个函数是用来获取预约集合里面的数据的,并没有存储到excel里
  2. // 云函数入口文件
  3. const cloud = require( 'wx-server-sdk')
  4. cloud. init({
  5. env: 'cloud1-0glmim4o153108f5'
  6. })
  7. // 云函数入口函数
  8. exports. main = async (event, context) => {
  9. return await cloud. database(). collection( 'appointment')
  10. . where({
  11. state: 1,
  12. })
  13. . orderBy( 'rank', 'asc')
  14. . get()
  15. }

getExcel.js


  
  1. const cloud = require( 'wx-server-sdk')
  2. cloud. init({
  3. env: "cloud1-0glmim4o153108f5"
  4. })
  5. //操作excel用的类库
  6. const xlsx = require( 'node-xlsx');
  7. // 云函数入口函数
  8. exports. main = async(event, context) => {
  9. try {
  10. let {userdata} = event
  11. //1,定义excel表格名
  12. let dataCVS = '预约.xlsx'
  13. //2,定义存储数据的
  14. let alldata = [];
  15. let row = [ '日期', '时间段', '组织', '预约老师', '预约事项', '预约人', '手机号']; //表属性
  16. alldata. push(row);
  17. for ( let key in userdata) {
  18. let arr = [];
  19. arr. push(userdata[key]. day);
  20. arr. push(userdata[key]. hour);
  21. arr. push(userdata[key]. g1_orderInstitute);
  22. arr. push(userdata[key]. g1_orderTeacher);
  23. arr. push(userdata[key]. content);
  24. arr. push(userdata[key]. subscriber);
  25. arr. push(userdata[key]. subscriberPhone);
  26. alldata. push(arr)
  27. }
  28. //3,把数据保存到excel里
  29. var buffer = await xlsx. build([{
  30. name: "mySheetName",
  31. data: alldata
  32. }]);
  33. //4,把excel文件保存到云存储里
  34. return await cloud. uploadFile({
  35. cloudPath: dataCVS,
  36. fileContent: buffer, //excel二进制文件
  37. })
  38. } catch (e) {
  39. console. error(e)
  40. return e
  41. }
  42. }

appointmentApproval2.wxml


  
  1. <view class="container">
  2. <view class="container_content">
  3. <view class="box">
  4. <view class="mine_application">
  5. <!-- 活动标题 -->
  6. <view class="mine_application_title">
  7. <view>已驳回的预约历史 </view>
  8. </view>
  9. <block wx:for="{{list}}"> </block>
  10. <!-- 活动内容 点击可跳转至详情页面 -->
  11. <view class="mine_application_content" wx:for="{{list}}" >
  12. <view class="event" bindtap="goDetail" data-id="{{item._id}}">
  13. <view class="appointmentTime">{{item.appointment}} </view>
  14. <view class="appointmentInstitute">预约组织:{{item.g1_orderInstitute}} </view>
  15. <view class='appointmentTeacher'>预约老师:{{item.g1_orderTeacher}} </view>
  16. <view class="time">{{item.time}} </view>
  17. <view class="subscriber">申请人:{{item.subscriber}} </view>
  18. </view>
  19. <!-- 右上角的状态栏 -->
  20. <!-- 用条件渲染来展示多种样式的活动内容 -->
  21. <!-- 状态为3代表已结束,2为已驳回,1为已通过,0为审核中 -->
  22. <block wx:if="{{item.state==2}}">
  23. <!-- 已驳回 -->
  24. <view class="state_2">
  25. <view class="state_content">已驳回 </view>
  26. </view>
  27. <!-- 活动下方的小点 -->
  28. <image src="../../icon/red.png" style="width: 11px;height: 11px;position: absolute;left: 15px;bottom: 15px;"> </image>
  29. </block>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="tabar">
  34. <view class='goApprovalButton' bindtap="goApprovalPage">
  35. <image src="../../icon/approval(1).png" style="width: 40px; height: 40px; margin-top: 5px;"> </image>
  36. <view class="button_content">待审批 </view>
  37. </view>
  38. <view class="goPassButton" bindtap="goPassPage">
  39. <image src="../../icon/pass(1).png" style="width: 40px; height: 40px; margin-top: 5px;"> </image>
  40. <view class="button_content">已通过 </view>
  41. </view>
  42. <view class="goRejectButton" bindtap="goRejectPage">
  43. <image src="../../icon/reject.png" style="width: 40px; height: 40px; margin-top: 5px;"> </image>
  44. <view class="button_content">已驳回 </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>

appointmentApproval2.wxss


  
  1. .mine_application{
  2. margin-left: 15px;
  3. margin-right: 15px;
  4. }
  5. .mine_application_title{
  6. border-bottom: 5rpx solid #A6A6A6;
  7. font-size: 28px;
  8. font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  9. }
  10. .mine_application_content{
  11. height: 250px;
  12. width: 100%;
  13. display: flex;
  14. position: relative;
  15. box-shadow: 16rpx 8rpx 24rpx rgba( 212, 48, 48, 0.1);
  16. margin-top: 15px;
  17. border-radius: 15px;
  18. }
  19. .event{
  20. font-size: 20px;
  21. font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  22. position: relative;
  23. margin: 15px;
  24. width: 90%;
  25. flex: 1;
  26. }
  27. .appointmentTime{
  28. margin-top: 0px;
  29. font-size: 16px;
  30. color: black;
  31. }
  32. .state_2{
  33. width: 80px;
  34. height: 40px;
  35. background-color: #FF5733;
  36. border-radius: 0 15px 0 15px;
  37. z-index: 2;
  38. }
  39. .state_content{
  40. position: relative;
  41. margin-top: 10px ;
  42. margin-left: 15px;
  43. font-size: 12;
  44. color: white;
  45. }
  46. .appointmentInstitute{
  47. font-size: 20px;
  48. color: #FF5733;
  49. margin-top: 10px;
  50. }
  51. .appointmentTeacher{
  52. font-size: 20px;
  53. color: #611504;
  54. margin-top: 10px;
  55. }
  56. .time{
  57. margin-top: 10px;
  58. font-size: 18px;
  59. color: #A0A9BD;
  60. }
  61. .goApprovalButton{
  62. position: absolute;
  63. bottom: 0px ;
  64. left: 0%;
  65. color: #FFFFFF;
  66. background-color: #FFFFFF;
  67. border-top: 2px solid grey;
  68. width: 33.333%;
  69. height: 70px;
  70. text-align:center;
  71. margin-top: 10px;
  72. }
  73. .goPassButton{
  74. position: absolute;
  75. bottom: 0px ;
  76. left: 33.333%;
  77. color: #FFFFFF;
  78. background-color: #FFFFFF;
  79. border-top: 2px solid grey;
  80. width: 33.333%;
  81. height: 70px;
  82. text-align:center;
  83. margin-top: 10px;
  84. }
  85. .goRejectButton{
  86. position: absolute;
  87. bottom: 0px ;
  88. left: 66.666%;
  89. color: #FFFFFF;
  90. background-color: #FFFFFF;
  91. border-top: 2px solid grey;
  92. width: 33.333%;
  93. height: 70px;
  94. text-align:center;
  95. margin-top: 10px;
  96. }
  97. .button_content{
  98. font-size: 15px;
  99. color: black;
  100. }
  101. .box{
  102. margin-bottom: 50px;
  103. }
  104. .container{
  105. position: relative;
  106. }
  107. .container_content{
  108. position: relative;
  109. min-height: 100vh;
  110. box-sizing: border-box;
  111. padding-bottom: 60rpx;
  112. padding-top: 0rpx;
  113. }
  114. /* 有无这个属性都行,之后可能会用到 */
  115. .tabar{
  116. width: 100%;
  117. text-align: center;
  118. letter-spacing: 4rpx;
  119. position: absolute;
  120. bottom: 0;
  121. }

appointmentApproval2.js


  
  1. const db = wx. cloud. database()
  2. const _ = db. command
  3. Page({
  4. data: {
  5. list:[],
  6. },
  7. onLoad( options) {
  8. console. log( "列表携带的值",options)
  9. db. collection( "appointment")
  10. . where({
  11. state: 2,
  12. })
  13. . get()
  14. . then( res=>{
  15. console. log( '查询数据库成功',res. data)
  16. //将返回的res.data里面的值赋值给list
  17. this. setData({
  18. list :res. data,
  19. })
  20. console. log( "这是list", this. data. list)
  21. })
  22. },
  23. onPullDownRefresh( ) {
  24. },
  25. onReachBottom( ) {
  26. },
  27. goDetail( e){
  28. console. log( "点击了详情页面,将展示活动的id ",e)
  29. wx. navigateTo({
  30. // 跳转到活动详情页面并携带活动id
  31. url: '/pages/appointmentDetail/appointmentDetail?id=' +e. currentTarget. dataset. id
  32. })
  33. },
  34. // 前往待审批页面
  35. goApprovalPage( ){
  36. wx. redirectTo({
  37. url: '../appointmentApproval/appointmentApproval',
  38. })
  39. },
  40. // 前往已通过页面
  41. goPassPage( ){
  42. wx. redirectTo({
  43. url: '../appointmentApproval3/appointmentApproval3',
  44. })
  45. },
  46. // 前往已驳回页面
  47. goRejectPage( ){
  48. wx. showToast({
  49. title: '您已经在当前页面',
  50. icon: 'none'
  51. })
  52. },
  53. })

appointmentDetail.wxml


  
  1. <view class="container">
  2. <view class="">
  3. <!-- 预约信息 -->
  4. <view>
  5. <view class="subtitle_font">预约基本信息 </view>
  6. <view class="message">
  7. <view class="font">申请预约的组织:{{list.g1_orderInstitute}} </view>
  8. <view class="font">预约的老师:{{list.g1_orderTeacher}} </view>
  9. <view class="font">预约的时间:{{list.appointment}} </view>
  10. <view class="font">发出预约的时间:{{list.time}} </view>
  11. <view class="font">预约事项:{{list.content}} </view>
  12. <view class="font">预约人:{{list.subscriber}} </view>
  13. <view class="font">手机号:{{list.subscriberPhone}} </view>
  14. <block wx:if="{{list.state==2}}">
  15. <view class="font">驳回理由:{{list.rejectReason}} </view>
  16. </block>
  17. </view>
  18. </view>
  19. </view>
  20. <!-- 条件渲染,只有待审批的活动才能显示 -->
  21. <view>
  22. <block wx:if="{{list.state==0}}">
  23. <view class="subtitle_font">如果驳回,请备注驳回理由 </view>
  24. <input bindinput="rejectReason" class="rejectReason" placeholder="驳回的理由"> </input>
  25. <button bindtap="pass" class="button_location1" style="margin-left:2%; width: 48%;">审批通过 </button>
  26. <button bindtap="reject" class="button_location2" style="margin-right:2%;width:48%" >审批驳回 </button>
  27. </block>
  28. </view>
  29. </view>

appointmentDetail.wxss


  
  1. .rejectReason{
  2. margin-top: 15px;
  3. margin-left: 20px;
  4. margin-right: 20px;
  5. margin-bottom: 15px;
  6. padding-top: 3px;
  7. padding-bottom: 3px;
  8. padding-left: 15px;
  9. padding-right: 15px;
  10. border-radius: 30px;
  11. border: 1px solid #F2E6E6;
  12. }
  13. .inputborder{
  14. margin-top: 15px;
  15. margin-left: 20px;
  16. margin-right: 20px;
  17. margin-bottom: 15px;
  18. padding-top: 3px;
  19. padding-bottom: 3px;
  20. padding-left: 15px;
  21. padding-right: 15px;
  22. border-radius: 30px;
  23. border: 1px solid #F2E6E6;
  24. }
  25. .message{
  26. margin-top: 15px;
  27. margin-left: 20px;
  28. margin-right: 20px;
  29. margin-bottom: 15px;
  30. padding-top: 3px;
  31. padding-bottom: 3px;
  32. padding-left: 15px;
  33. padding-right: 15px;
  34. border-radius: 30px;
  35. border: 1px solid #F2E6E6;
  36. height: 400px;
  37. }
  38. .font{
  39. margin-top: 5px;
  40. font-size: 20px;
  41. font-weight: 100;
  42. }
  43. /* 小标题内容 */
  44. .subtitle_font{
  45. font-size: large;
  46. font-weight: 400;
  47. color: #D43C33;
  48. margin-left: 20px;
  49. }
  50. /* 审批通过 */
  51. .button_location1{
  52. border-radius: 80rpx;
  53. margin-top: 5%;
  54. color: #FFFFFF;
  55. background-color: #D43030;
  56. box-shadow: 16rpx 8rpx 24rpx rgba( 212, 48, 48, 0.35);
  57. float: left;
  58. }
  59. /* 审批驳回 */
  60. .button_location2{
  61. border-radius: 80rpx;
  62. margin-top: 5%;
  63. color: #FFFFFF;
  64. background-color: #D43030;
  65. box-shadow: 16rpx 8rpx 24rpx rgba( 212, 48, 48, 0.35);
  66. float: right;
  67. }
  68. .container{
  69. display: flex;
  70. width: 100%;
  71. height: 700px;
  72. flex-direction: column;
  73. justify-content: space-between;
  74. }

appointmentDetail.js


  
  1. let eventid = ''
  2. const DB = wx. cloud. database(). collection( "appointment")
  3. Page({
  4. data:{
  5. list:[],
  6. id: "",
  7. rejectReason: ""
  8. },
  9. onLoad( option){
  10. console. log( "列表所携带的值",option)
  11. var id = option. id
  12. this. setData({
  13. id :option. id
  14. })
  15. DB
  16. . doc(id)
  17. . get()
  18. . then( res=>{
  19. this. setData({
  20. list:res. data
  21. })
  22. })
  23. . catch( res=>{
  24. console. log( "活动详情页请求失败",res)
  25. })
  26. },
  27. pass( ){
  28. let that = this;
  29. wx. showLoading({
  30. title: '正在上传中……',
  31. mask: true
  32. })
  33. DB. doc( this. data. id)
  34. . update({ // updata指 插入数据库中的userlist表;
  35. //将我们获取到的新值代入
  36. data: {
  37. state: 1
  38. },
  39. }). then( res => {
  40. console. log( "上传成功", res)
  41. wx. showToast({
  42. title: '成功',
  43. })
  44. wx. navigateTo({
  45. url: '../appointmentApproval/appointmentApproval',
  46. })
  47. . then( ()=>{
  48. wx. startPullDownRefresh()
  49. })
  50. })
  51. . catch( err => {
  52. console. log( "上传失败", err)
  53. wx. showToast({
  54. title: '失败',
  55. icon: "none"
  56. })
  57. })
  58. },
  59. reject( ){
  60. let that = this;
  61. wx. showLoading({
  62. title: '正在上传中……',
  63. mask: true
  64. })
  65. DB. doc( this. data. id)
  66. . update({ // updata指 插入数据库中的userlist表;
  67. //将我们获取到的新值代入
  68. data: {
  69. state: 2,
  70. rejectReason: this. data. rejectReason
  71. },
  72. }). then( res => {
  73. console. log( "上传成功", res)
  74. wx. showToast({
  75. title: '成功',
  76. })
  77. wx. navigateTo({
  78. url: '../appointmentApproval/appointmentApproval',
  79. })
  80. . then( ()=>{
  81. wx. startPullDownRefresh()
  82. })
  83. })
  84. . catch( err => {
  85. console. log( "上传失败", err)
  86. wx. showToast({
  87. title: '失败',
  88. icon: "none"
  89. })
  90. })
  91. },
  92. rejectReason( event){
  93. console. log( "这是驳回输入框里的信息",event. detail. value)
  94. this. setData({
  95. rejectReason:event. detail. value
  96. })
  97. }
  98. })


题外话

这一系列文章会持续更新,手把手教你从零创建一个小程序项目!并且免费提供源码。如果有什么疑问欢迎大家在底下留言讨论!你的赞和收藏是我最大的动力!! 


转载:https://blog.csdn.net/Zchengjisihan/article/details/128513644
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场