index.vue 11 KB

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