index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <view class="container" :style="{'height':height}">
  3. <!-- 提示内容 -->
  4. <view class="h-title">
  5. <text>*请输选择1张服务对象人脸影像</text>
  6. </view>
  7. <view class="h-upload-wrap">
  8. <view class="h-item-row">
  9. <view @click="uploadImg1(1)" class="h-item">
  10. <view v-if="!imgUrl1" class="h-content">
  11. <image src="../../static/me/u01.png" mode=""></image>
  12. <view class="h-text">
  13. <text>添加人脸影像</text>
  14. </view>
  15. </view>
  16. <view v-else class="h-upload-img">
  17. <image mode="aspectFit" class="imgBox" :src="imgUrl1"></image>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 保存备案信息 -->
  23. <view class="uploadBox" @click="verifyFace()">
  24. <text>下一步</text>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. components: {
  31. },
  32. data() {
  33. return {
  34. height:'',
  35. errShow: false,
  36. okShow: false,
  37. imgUrl1: '',
  38. imgUrl2: '',
  39. imgUrl3: '',
  40. imgUrl4: '',
  41. imgUrl5: '',
  42. show: false,
  43. reqParm: {
  44. auth: true,
  45. facePath: '',
  46. businessId: ''
  47. },
  48. userInfo: {
  49. },
  50. parms: {
  51. userName: '',
  52. facePhoto: '',
  53. facePhotos: '',
  54. facePhotoUrl: ''
  55. },
  56. imgPaths: "",
  57. ossImg: {
  58. ossId1: "",
  59. ossId2: "",
  60. ossId3: "",
  61. ossId4: "",
  62. ossId5: ""
  63. },
  64. }
  65. },
  66. onReady() {
  67. },
  68. onLoad(option) {
  69. // 用户信息
  70. // let user = this.$store.state.loginUserInfo;
  71. // this.userInfo = user;
  72. let sysInfo= uni.getSystemInfoSync()
  73. this.height = sysInfo.screenHeight + 'px'
  74. },
  75. methods: {
  76. // 去签订协议
  77. gotoAutoLetter(){
  78. if(!this.$isDataEmpty(this.parms.userName)){
  79. this.okShow = false;
  80. uni.$u.route({
  81. url: '/pages/me/service-object-all-info',
  82. params: {
  83. data: JSON.stringify(this.userInfo)
  84. }
  85. })
  86. // uni.$u.route({
  87. // url: '/pages/me/service-object-auth-letter',
  88. // params: {
  89. // data: JSON.stringify(this.parms)
  90. // }
  91. // })
  92. } else{
  93. uni.$u.toast('请认真填写宝贝昵称')
  94. }
  95. },
  96. // 实名认证
  97. getoRealNameAuth(){
  98. this.errShow = false;
  99. // 已认证
  100. uni.$u.route({
  101. url: '/pages/me/real-name-auth',
  102. params: {
  103. }
  104. })
  105. },
  106. // 连接已上传的图片地址
  107. verifyImgUpload(){
  108. let img1 = this.ossImg.ossId1;
  109. let img2 = this.ossImg.ossId2;
  110. let img3 = this.ossImg.ossId3;
  111. let img4 = this.ossImg.ossId4;
  112. let img5 = this.ossImg.ossId5;
  113. if(!img1){
  114. uni.showToast({
  115. title: "请上传第1张图片"
  116. })
  117. return false;
  118. }
  119. /* if(this.$isDataEmpty(img2)){
  120. uni.showToast({
  121. title: "请上传第2张图片"
  122. })
  123. return false;
  124. }
  125. if(this.$isDataEmpty(img3)){
  126. uni.showToast({
  127. title: "请上传第3张图片"
  128. })
  129. return false;
  130. }
  131. if(this.$isDataEmpty(img4)){
  132. uni.showToast({
  133. title: "请上传第4张图片"
  134. })
  135. return false;
  136. }
  137. if(this.$isDataEmpty(img5)){
  138. uni.showToast({
  139. title: "请上传第5张图片"
  140. })
  141. return false;
  142. } */
  143. // this.parms.facePhotos = img1+","+img2+","+img3+","+img4+","+img5;
  144. this.parms.facePhotos = img1;
  145. return true;
  146. },
  147. // 验证人象
  148. verifyFace(){
  149. let that = this;
  150. // 验证图片是否全上传
  151. if(!that.verifyImgUpload()){
  152. return;
  153. }
  154. uni.showLoading({
  155. title: '人脸识别中'
  156. })
  157. this.$api.verifyFace(that.reqParm).then((res)=>{
  158. uni.hideLoading();
  159. if(res.data.data.code == '500'){ //人脸不存在
  160. res.facePhotoUrl = that.imgUrl1;
  161. res.facePhoto = that.ossImg.ossId1;
  162. res.facePhotos = that.parms.facePhotos;
  163. uni.navigateTo({
  164. url: '/myPages/serviceObjectAllInfo/index?data'+ JSON.stringify(res),
  165. })
  166. } else { // 人脸存在
  167. res.opType = "1";
  168. res.facePhotoUrl = res.facePhoto;
  169. res.facePhotos = that.parms.facePhotos;
  170. uni.navigateTo({
  171. url: '/myPages/serviceObjectInfo/index?data=' + JSON.stringify(res),
  172. })
  173. }
  174. }).catch(() =>{
  175. uni.showToast({
  176. title: "操作失败"
  177. })
  178. });
  179. },
  180. //头像上传
  181. uploadImg1(imgIndex) {
  182. let that = this;
  183. uni.chooseImage({
  184. count: 1,
  185. success: (chooseImageRes) => {
  186. const tempFilePaths = chooseImageRes.tempFilePaths;
  187. uni.uploadFile({
  188. url: that.$baseUrl + '/resource/oss/upload', //仅为示例,非真实的接口地址
  189. filePath: tempFilePaths[0],
  190. name: 'file',
  191. header: {
  192. 'Authorization': 'Bearer ' + uni.getStorageInfo('accessToken'),
  193. },
  194. success: (uploadFileRes) => {
  195. console.log("uploadFileRes:"+uploadFileRes)
  196. let res = JSON.parse(uploadFileRes.data)
  197. let ossId = res.data.ossId;
  198. let url = res.data.url;
  199. let imgUrl = url.startsWith("https")? res.data.url : url.replace("http", "https");
  200. console.log("imgUrl:"+imgUrl)
  201. if(imgIndex == 1){
  202. that.ossImg.ossId1 = ossId;
  203. that.parms.facePhotoUrl = imgUrl;
  204. that.imgUrl1 = imgUrl;
  205. }
  206. if(imgIndex == 2){
  207. that.ossImg.ossId2 = ossId;
  208. that.imgUrl2 = imgUrl;
  209. }
  210. if(imgIndex == 3){
  211. that.ossImg.ossId3 = ossId;
  212. that.imgUrl3 = imgUrl;
  213. }
  214. if(imgIndex == 4){
  215. that.ossImg.ossId4 = ossId;
  216. that.imgUrl4 = imgUrl;
  217. }
  218. if(imgIndex == 5){
  219. that.ossImg.ossId5 = ossId;
  220. that.imgUrl5 = imgUrl;
  221. }
  222. this.reqParm.facePath = ossId;
  223. this.parms.facePhoto = ossId;
  224. }
  225. });
  226. }
  227. });
  228. }
  229. }
  230. }
  231. </script>
  232. <style scoped lang="scss">
  233. .container{
  234. padding: 12px;
  235. background: #F6F6F6;
  236. }
  237. .h-title{
  238. height: 22px;
  239. font-size: 14px;
  240. font-family: PingFangSC-Regular, PingFang SC;
  241. font-weight: 400;
  242. color: #333333;
  243. line-height: 22px;
  244. }
  245. // 弹窗
  246. .h-popo-content{
  247. height: 170px;
  248. padding: 12px;
  249. width: 300px;
  250. text-align: center;
  251. font-size: 14px;
  252. font-family: PingFangSC-Semibold, PingFang SC;
  253. .h-img{
  254. display: flex;
  255. justify-content: center;
  256. }
  257. .h-text{
  258. margin-top: 12px;
  259. font-weight: 400;
  260. color: #666666;
  261. }
  262. .text{
  263. margin-top: 6px;
  264. font-weight: 400;
  265. color: #666666;
  266. }
  267. .h-btn-wrap{
  268. display: flex;
  269. justify-content: space-between;
  270. color: #333333;
  271. text-align: center;
  272. margin-top: 20px;
  273. .h-left-btn{
  274. height: 32px;
  275. line-height: 30px;
  276. background: #EEEEEE;
  277. width: 100px;
  278. text-align: center;
  279. border-radius: 16px;
  280. margin: 0 auto;
  281. }
  282. .h-right-btn{
  283. height: 32px;
  284. line-height: 30px;
  285. background: #FFE05C;
  286. width: 100px;
  287. border-radius: 16px;
  288. margin: 0 auto;
  289. }
  290. }
  291. }
  292. .h-upload-wrap{
  293. .h-item-row{
  294. width: 100%;
  295. display: flex;
  296. align-items: center;
  297. justify-content: center;
  298. margin-top: 12px;
  299. font-family: PingFangSC-Regular, PingFang SC;
  300. .h-item{
  301. background: #fff;
  302. width: 48%;
  303. text-align: center;
  304. height: 164px;
  305. display: flex;
  306. align-items: center;
  307. justify-content: center;
  308. border-radius: 6px;
  309. .h-content{
  310. image{
  311. height: 48px;
  312. width: 48px;
  313. }
  314. .h-text{
  315. margin-top: 10px;
  316. font-size: 12px;
  317. font-weight: 400;
  318. color: #999999;
  319. line-height: 20px;
  320. }
  321. }
  322. .h-upload-img{
  323. width: 100%;
  324. height: 164px;
  325. padding: 4px;
  326. .imgBox{
  327. width: 164px;
  328. height: 164px;
  329. }
  330. }
  331. }
  332. }
  333. }
  334. .uploadBox {
  335. width: 100%;
  336. margin-top: 30px;
  337. height: 42px;
  338. background: #FFE05C;
  339. border-radius: 27px;
  340. color: #333333;
  341. line-height: 42px;
  342. text-align: center;
  343. }
  344. </style>