accessApplication.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <!-- 准入申请 -->
  2. <template>
  3. <view id="accessApplication">
  4. <view class="button-max-box" @click="goFaceImage">
  5. <img src="@/images/basicsModules/icon_001.png">
  6. <view>身份验证</view>
  7. <view :class="!identifyType?'colorA':'marginType'">{{!identifyType?'去认证':'已认证'}}</view>
  8. <img v-if="!identifyType" src="@/images/basicsModules/icon_04.png">
  9. </view>
  10. <view class="for-box" v-for="(item,index) in dataList" :key="index">
  11. <view class="button-view" @click="selectImage(index)" v-if="!item.url">+ 添加</view>
  12. <img :src="item.url" @click="selectImage(index)" v-else>
  13. <view class="for-title">{{item.materialName}}</view>
  14. </view>
  15. <view class="null-p"></view>
  16. <view class="bottom-button-view" @click="accessReview">提交</view>
  17. </view>
  18. </template>
  19. <script>
  20. import { config } from '@/api/request/config.js'
  21. import { studentinfoFacemy,subjectMaterialList,accessReview } from '@/api/apiDemo/index.js'
  22. export default {
  23. data() {
  24. return {
  25. identifyType:1,
  26. itemData:{},
  27. dataList:[]
  28. }
  29. },
  30. onLoad(option) {
  31. this.itemData = JSON.parse(decodeURIComponent(option.item));
  32. this.dataList = JSON.parse(decodeURIComponent(option.list));
  33. console.log("this.itemData",this.itemData)
  34. console.log("this.dataList",this.dataList)
  35. this.studentinfoFacemy();
  36. // this.subjectMaterialList();
  37. },
  38. methods: {
  39. //提交接口
  40. async accessReview(){
  41. let self = this;
  42. if(!this.identifyType){
  43. uni.showToast({
  44. title: '请先认证身份验证',
  45. icon:"none",
  46. mask:true,
  47. duration: 2000
  48. });
  49. return
  50. }
  51. if(!this.dataList[0]){
  52. uni.showToast({
  53. title: '该实验室未配置准入资格,无法申请~',
  54. icon:"none",
  55. mask:true,
  56. duration: 2000
  57. });
  58. return
  59. }
  60. let obj = {
  61. subjectId:self.itemData.id,
  62. securityGroupId:self.dataList[0].configureId,
  63. buildId:self.itemData.buildId,
  64. deptId:self.itemData.deptId,
  65. approvalDetails:[],
  66. };
  67. for(let i=0;i<self.dataList.length;i++){
  68. if(!self.dataList[i].url){
  69. uni.showToast({
  70. title: '请上传'+self.dataList[i].materialName,
  71. icon:"none",
  72. mask:true,
  73. duration: 2000
  74. });
  75. return
  76. }
  77. let newObj = {
  78. materialName:self.dataList[i].materialName,
  79. materialUrl:self.dataList[i].url,
  80. }
  81. obj.approvalDetails.push(newObj);
  82. }
  83. const {data} = await accessReview(obj);
  84. if(data.code == 200){
  85. uni.showToast({
  86. title: '提交成功',
  87. icon:"none",
  88. mask:true,
  89. duration: 2000
  90. });
  91. setTimeout(function(){
  92. uni.navigateBack();
  93. },2000);
  94. }
  95. },
  96. //查询实验室下的安全准入资格材料表
  97. async subjectMaterialList(){
  98. let obj = {
  99. subjectId:this.itemData.id
  100. }
  101. const {data} = await subjectMaterialList(obj)
  102. if(data.code == 200){
  103. this.dataList = data.data;
  104. }
  105. },
  106. //获取当前身份人脸验证状态
  107. async studentinfoFacemy(){
  108. let obj = {
  109. studentsId:uni.getStorageSync('userId')
  110. }
  111. const {data} = await studentinfoFacemy(obj)
  112. if(data.code == 200){
  113. this.ifFaceFeature = data.data.ifFaceFeature;
  114. }
  115. },
  116. // 图片上传
  117. selectImage(index) {
  118. let self = this;
  119. wx.chooseImage({
  120. count: 1,
  121. sizeType: ["original", "compressed"],
  122. sourceType: ["album", "camera"],
  123. success: function(res) {
  124. let tempFilePaths = res.tempFilePaths[0];
  125. self.uploadImg(tempFilePaths,index);
  126. }
  127. });
  128. },
  129. async uploadImg(tempFilePaths,index){
  130. var self = this;
  131. uni.showLoading({
  132. title: '上传中',
  133. mask: true
  134. });
  135. uni.uploadFile({
  136. url: config.base_url+'/base/file/upload', //仅为示例,非真实的接口地址
  137. header:{'Authorization':uni.getStorageSync('token')},
  138. filePath: tempFilePaths,
  139. name: 'file',
  140. formData: {
  141. 'user': 'test'
  142. },
  143. success: (uploadFileRes) => {
  144. let res = JSON.parse(uploadFileRes.data);
  145. if(res.code == 200){
  146. self.$set(self.dataList[index],'url',config.base_url+res.data.url);
  147. }else{
  148. uni.showToast({
  149. title: res.msg,
  150. icon:"none",
  151. mask:true,
  152. duration: 2000
  153. });
  154. }
  155. },
  156. fail: err => {},
  157. complete: () => {
  158. uni.hideLoading()
  159. }
  160. });
  161. },
  162. goFaceImage(){
  163. if (!this.identifyType){
  164. uni.navigateTo({
  165. url: '/pages_basics/faceImage',
  166. });
  167. }
  168. },
  169. }
  170. }
  171. </script>
  172. <style lang="stylus" scoped>
  173. #accessApplication{
  174. height:100%;
  175. width:100%;
  176. display flex
  177. flex-direction column
  178. .button-max-box{
  179. height:100rpx;
  180. display flex
  181. background #fff
  182. margin-bottom:20rpx;
  183. img:nth-child(1){
  184. height:30rpx;
  185. width:30rpx;
  186. margin:37rpx 28rpx 33rpx 20rpx;
  187. }
  188. view{
  189. line-height:100rpx;
  190. }
  191. view:nth-child(2){
  192. flex:1;
  193. color:#333333;
  194. font-size: 28rpx;
  195. }
  196. view:nth-child(3){
  197. width:120rpx;
  198. text-align center;
  199. color:#CCCCCC;
  200. font-size: 28rpx;
  201. }
  202. img:nth-child(4){
  203. height:24rpx;
  204. width:12rpx;
  205. margin:39rpx 20rpx 0 0;
  206. }
  207. .colorA{
  208. color:#E45656!important;
  209. }
  210. .marginType{
  211. margin-right:12rpx;
  212. }
  213. }
  214. .for-box{
  215. height:430rpx;
  216. width:710rpx;
  217. margin:20rpx 20rpx 0;
  218. background: url("@/pages_student/images/icon_08.png")
  219. background-size 100%
  220. .button-view{
  221. text-align center
  222. line-height:348rpx;
  223. color: #999999;
  224. font-size:30rpx;
  225. }
  226. img{
  227. width:706rpx;
  228. height:344rpx;
  229. margin:2rpx;
  230. border-top-right-radius 20rpx
  231. border-top-left-radius 20rpx
  232. }
  233. .for-title{
  234. line-height:80rpx;
  235. margin-left:28rpx;
  236. color: #999999;
  237. font-size:30rpx;
  238. }
  239. }
  240. .bottom-button-view{
  241. font-size:30rpx;
  242. text-align center;
  243. color: #FFFFFF;
  244. width: 750rpx;
  245. height: 100rpx;
  246. line-height: 100rpx;
  247. background: #0183FA;
  248. margin-top:40rpx;
  249. }
  250. .null-p{
  251. flex:1;
  252. }
  253. }
  254. </style>