accessApplication.vue 6.0 KB

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