schoolCard.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <div class="card" style="margin-bottom: 20px">
  3. <van-row style="border-bottom: solid 1px #e4e4e4;">
  4. <van-col span="14">
  5. <h3><strong>校卡审核</strong></h3>
  6. </van-col>
  7. <van-col span="6">
  8. <p :style="{ color: statusColor }">{{statusString}}</p>
  9. </van-col>
  10. </van-row>
  11. <div v-if="status===30 || status === 500">
  12. <add-photo @onRead="onRead"/>
  13. <p>{{note}}</p>
  14. <van-button
  15. type="primary"
  16. @click="schoolPresent"
  17. style="width: 100%"
  18. :loading="loading"
  19. >保存
  20. </van-button>
  21. </div>
  22. <div v-else>
  23. <img :src="schoolpic" style="max-width: 100%"/>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import {Row, Col, Toast, Button} from 'vant';
  29. import AddPhoto from "../components/addPhoto";
  30. import {BasicFunction} from "../connector/basic-service";
  31. export default {
  32. name: "schoolCard",
  33. components: {
  34. AddPhoto,
  35. [Row.name]: Row, [Col.name]: Col,
  36. [Button.name]: Button
  37. },
  38. data() {
  39. return {
  40. statusColor:'',
  41. statusString:'-----',
  42. photo: null,
  43. loading:false,
  44. status:0,
  45. imgage: null,
  46. imgDo:{},
  47. schoolpic:"",
  48. IMGPREFIX: "http://gift.fogice.com",
  49. note: ""
  50. }
  51. },
  52. methods: {
  53. schoolPresent() {
  54. // 检验输入
  55. this.loading=true;
  56. if (this.photo === null) {
  57. Toast.fail('请上传礼物照片');
  58. this.loading=false;
  59. return;
  60. }
  61. let that=this;
  62. console.log('------- photo -------');
  63. console.log(this.photo);
  64. let formData = new FormData();
  65. formData.append('file', this.photo);
  66. BasicFunction.get_data("http://gift.fogice.com/server/fileserver/upload?sign=abcdefg", function (res) {
  67. if (res.model === undefined || res.model.length === 0 || res === undefined ) {
  68. Toast.fail('上传失败,请重试');
  69. return;
  70. }
  71. if (res.ret === '10000') {
  72. let photoURL = res.model;
  73. let userid = localStorage.getItem('frontend-userid');
  74. BasicFunction.get_data('smartIdentity/list?userId=' + userid, function (res) {
  75. // console.log('----- User Identity -----');
  76. // console.log(res);
  77. if (res.ret === '10000') {
  78. let t = res.model.list[0];
  79. t.userSchoolCardPic = photoURL;
  80. t.userReviewStatus = 100;
  81. t.reviewerNote = "未审核";
  82. t.reviewerNoteToUser = "未审核";
  83. BasicFunction.get_data('smartIdentity/updateBatch', function (res) {
  84. if (res.ret === '10000') {
  85. Toast.success('上传成功');
  86. location.reload();
  87. }
  88. else Toast.fail('上传失败,请重试');
  89. }, [t]);
  90. } else Toast.fail('访问失败,请重试');
  91. }, {});
  92. } else {
  93. Toast.fail('上传失败');
  94. }
  95. }, formData);
  96. },
  97. onRead: function (e) {
  98. this.photo = e;
  99. }
  100. },
  101. created: function () {
  102. if (!localStorage.getItem('frontend-userid')) {
  103. this.$router.push('login');
  104. return;
  105. }
  106. let userid = localStorage.getItem('frontend-userid');
  107. let that = this;
  108. BasicFunction.get_data('smartIdentity/list?userId=' + userid, function (res) {
  109. // console.log('----- User Identity -----');
  110. // console.log(res);
  111. if(res === undefined || res.model === undefined )
  112. {
  113. Toast('读取失败,请检查网络');
  114. that.$router.push('verify');
  115. }
  116. if (res.ret === '10000') {
  117. var t=res.model.list;
  118. that.status=t[0].userReviewStatus;
  119. that.imgDo=t[0];
  120. that.note = t[0].reviewerNoteToUser;
  121. // console.log(that);
  122. if (res.model.list.length === 0 || that.status === 30) {
  123. that.statusColor='#c5c5c5';
  124. that.statusString='未上传校卡';
  125. that.$router.push('verify');
  126. return;
  127. } else if (that.status === 100 || that.status === 1000) {
  128. that.schoolpic=that.IMGPREFIX+t[0].userSchoolCardPic;
  129. if (that.status === 100)
  130. {
  131. that.statusColor='#c5c530';
  132. that.statusString='审核中'
  133. }
  134. if(that.status === 1000) {
  135. that.statusColor = '#00ff00';
  136. that.statusString='审核通过'
  137. }
  138. } else {
  139. that.statusColor='#ff0000';
  140. that.statusString='审核未通过'
  141. }
  142. }
  143. }, {});
  144. }
  145. }
  146. </script>
  147. <style scoped>
  148. p, h3 {
  149. color: #fd6740;
  150. }
  151. p, h3 {
  152. padding: 5px;
  153. }
  154. p {
  155. padding-top: 3px ;
  156. }
  157. .card {
  158. background-color: white;
  159. margin: 20px 20px;
  160. border: solid 1px #e4e4e4;
  161. padding: 15px;
  162. text-align: left;
  163. }
  164. .van-button {
  165. background-color: #fd6740;
  166. border-color: #fd6740;
  167. margin: 10px 0 10px;
  168. width: 55%;
  169. }
  170. </style>