add.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="page">
  3. <view class="cu-form-group">
  4. <view >班次</view>
  5. <radio-group @change="handleClassesChange">
  6. <label class="radio margin-right" v-for="(item, index) in classesType" :key="index"><radio :value="item.key"
  7. :checked="item.key === sendDate.classes_id" :color="themeColor.color" style="transform: scale(0.75);"/>{{ item.value }}</label>
  8. </radio-group>
  9. </view>
  10. <view class="cu-form-group">
  11. <view>类型</view>
  12. <radio-group @change="handleStateChange">
  13. <label class="radio margin-right" v-for="(item, index) in checkType" :key="index">
  14. <radio :value="item.key" :checked="item.key === sendDate.type" :color="themeColor.color" style="transform: scale(0.75);" />
  15. {{ item.value }}
  16. </label>
  17. </radio-group>
  18. </view>
  19. <view class="covers-title">
  20. <text>现场图片(请上传打卡现场图片)</text>
  21. </view>
  22. <view class="covers-body covers-uploader oa-uploader">
  23. <view class="uni-uploader">
  24. <view class="uni-uploader-head">
  25. <view class="uni-uploader-title">点击预览图片</view>
  26. <view class="uni-uploader-info">{{ imageList.length }}/6</view>
  27. </view>
  28. <view class="uni-uploader-body">
  29. <view class="uni-uploader__files">
  30. <block v-for="(image, index) in imageList" :key="index">
  31. <view class="uni-uploader__file" style="position: relative;">
  32. <oa-image class="uni-uploader__img" :src="image"></oa-image>
  33. <view class="close-view" @tap="close(index)" :class="'bg-' + themeColor.name">x</view>
  34. </view>
  35. </block>
  36. <view class="uni-uploader__input-box" v-if="imageList.length < 6">
  37. <view class="uni-uploader__input" @tap="uploadImage"></view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <button
  44. class="confirm-btn"
  45. :class="'bg-' + themeColor.name"
  46. :disabled="btnLoading"
  47. :loading="btnLoading"
  48. @tap="send"
  49. >
  50. 提交打卡
  51. </button>
  52. </view>
  53. </template>
  54. <script>
  55. import { uploadImage } from '@/api/userInfo';
  56. import { check,attendCheckType,getAttendClasses } from '@/api/basic';
  57. import nativeUtil from "@/utils/native-nfc-util.js"
  58. export default {
  59. data() {
  60. return {
  61. sendDate: {
  62. classes_id:1,
  63. type:0,
  64. },
  65. place:{},
  66. checkType:[{"key":"0","value":"签到"},{"key":"1","value":"签退"}],
  67. classesType:[{"key":"1","value":"白班"}],
  68. imageList: [],
  69. btnLoading: false
  70. };
  71. },
  72. onShow() {
  73. uni.setNavigationBarColor({
  74. frontColor: '#ffffff',
  75. backgroundColor: this.themeColor.color,
  76. animation: {
  77. duration: 400,
  78. timingFunc: 'easeIn'
  79. }
  80. })
  81. },
  82. methods: {
  83. // 监听反馈类型事件
  84. handleClassesChange(e) {
  85. this.sendDate.classes_id = e.detail.value;
  86. },
  87. handleStateChange(e) {
  88. this.sendDate.type = e.detail.value;
  89. },
  90. // 打开相册选图
  91. uploadImage() {
  92. const _this = this;
  93. uni.chooseImage({
  94. count: 6, // 最多一次可以选择的图片张数
  95. sizeType: ['compressed'],
  96. sourceType: ['camera'], // album 从相册选图,camera 使用相机
  97. success: function(res) {
  98. if (_this.imageList.length + res.tempFiles.length > 6) {
  99. _this.$mHelper.toast('不要贪心哦,最多只可上传6张照片');
  100. return;
  101. }
  102. _this.handleUploadFile(res.tempFilePaths);
  103. }
  104. });
  105. },
  106. // 依次上传图片
  107. handleUploadFile(data) {
  108. this.$mHelper.toast('上传成功');
  109. },
  110. // 删除已选中图片
  111. close(e) {
  112. this.imageList.splice(e, 1);
  113. },
  114. // 发送数据
  115. async send() {
  116. this.$mHelper.toast('提交成功');
  117. }
  118. }
  119. };
  120. </script>
  121. <style lang="scss">
  122. page {
  123. background-color: $page-color-base;
  124. }
  125. .cu-form-group {
  126. border-style: none;
  127. background-color: $page-color-base;
  128. padding: $spacing-base;
  129. width: 100%;
  130. display: flex;
  131. align-items: center;
  132. // min-height: 100upx;
  133. justify-content: space-between;
  134. }
  135. /*表单标题*/
  136. .input-t {
  137. display: flex;
  138. flex-direction: row;
  139. justify-content: space-between;
  140. align-items: center;
  141. padding: $spacing-base;
  142. margin-top: $spacing-base;
  143. font-size: $font-base;
  144. }
  145. .tit {
  146. width: 80%;
  147. font-size: $font-sm + 2upx;
  148. color: $font-color-base;
  149. }
  150. .input-quick {
  151. position: relative;
  152. padding-right: 40upx;
  153. .iconfont {
  154. font-size: $font-sm;
  155. }
  156. }
  157. .input-body {
  158. background: $color-white;
  159. padding: $spacing-sm $spacing-base;
  160. .gender-item {
  161. margin-right: 20upx;
  162. .gender-item-text {
  163. padding-left: 10upx;
  164. }
  165. }
  166. }
  167. .input-textare {
  168. height: 200upx;
  169. font-size: 34upx;
  170. line-height: 50upx;
  171. width: 100%;
  172. box-sizing: border-box;
  173. padding: 20upx 30upx 0;
  174. }
  175. .covers-title {
  176. display: flex;
  177. flex-direction: row;
  178. justify-content: space-between;
  179. align-items: center;
  180. padding: $spacing-base;
  181. margin-top: $spacing-base;
  182. font-size: $font-base;
  183. }
  184. .covers-body {
  185. background: $color-white;
  186. padding: $spacing-sm $spacing-base;
  187. .gender-item {
  188. margin-right: 20upx;
  189. .gender-item-text {
  190. padding-left: 10upx;
  191. }
  192. radio .wx-radio-input.wx-radio-input-checked {
  193. background: $uni-color-primary;
  194. border-color: $uni-color-primary;
  195. }
  196. }
  197. }
  198. .covers-uploader {
  199. padding: 22upx 20upx;
  200. }
  201. </style>